@subiz/widget-v4 4.0.63 → 4.0.64

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 (55) hide show
  1. package/babel.config.js +2 -4
  2. package/compiled_src/bot.js +7 -1
  3. package/compiled_src/call/call.js +15 -12
  4. package/compiled_src/chatbox/DropdownSelect.js +75 -66
  5. package/compiled_src/chatbox/MessageInput.js +7 -4
  6. package/compiled_src/chatbox/Order.js +94 -90
  7. package/compiled_src/chatbox/Rating.js +10 -7
  8. package/compiled_src/chatbox/Widget.js +27 -23
  9. package/compiled_src/contact/contact.js +9 -6
  10. package/compiled_src/lib.js +14 -9
  11. package/compiled_src/notif/notif.js +15 -12
  12. package/compiled_src/order/address_picker.js +71 -63
  13. package/compiled_src/order/order.js +330 -316
  14. package/compiled_src/popup/countdown.js +7 -4
  15. package/compiled_src/popup/popup.js +12 -9
  16. package/compiled_src/store/api.js +110 -80
  17. package/compiled_src/store/api_fake.js +82 -55
  18. package/compiled_src/store/store.js +170 -133
  19. package/dist/132.js +633 -588
  20. package/dist/17ee31b89ac.132.js +1 -0
  21. package/dist/{17e757ccadd.178.js → 17ee31b89ac.178.js} +0 -0
  22. package/dist/17ee31b89ac.213.js +1 -0
  23. package/dist/17ee31b89ac.335.js +1 -0
  24. package/dist/{17e757ccadd.362.js → 17ee31b89ac.362.js} +1 -1
  25. package/dist/17ee31b89ac.441.js +1 -0
  26. package/dist/17ee31b89ac.605.js +1 -0
  27. package/dist/{17e757ccadd.678.js → 17ee31b89ac.678.js} +0 -0
  28. package/dist/{17e757ccadd.782.js → 17ee31b89ac.782.js} +1 -1
  29. package/dist/17ee31b89ac.app.js +1 -0
  30. package/dist/{17e757ccadd.index.html → 17ee31b89ac.index.html} +1 -1
  31. package/dist/{17e757ccadd.library.html → 17ee31b89ac.library.html} +1 -1
  32. package/dist/17ee31b89ac.library.js +1 -0
  33. package/dist/{17e757ccadd.preview.html → 17ee31b89ac.preview.html} +1 -1
  34. package/dist/17ee31b89ac.preview.js +1 -0
  35. package/dist/17ee31b89ac.screenshoot.js +1 -0
  36. package/dist/213.js +19 -13
  37. package/dist/335.js +9 -6
  38. package/dist/362.js +1 -1
  39. package/dist/441.js +2 -2
  40. package/dist/605.js +15 -12
  41. package/dist/782.js +1 -1
  42. package/dist/HASH +1 -1
  43. package/dist/screenshoot.html +1 -1
  44. package/dist/screenshoot.js +372 -273
  45. package/package.json +12 -12
  46. package/src/bot.js +2 -1
  47. package/dist/17e757ccadd.132.js +0 -1
  48. package/dist/17e757ccadd.213.js +0 -1
  49. package/dist/17e757ccadd.335.js +0 -1
  50. package/dist/17e757ccadd.441.js +0 -1
  51. package/dist/17e757ccadd.605.js +0 -1
  52. package/dist/17e757ccadd.app.js +0 -1
  53. package/dist/17e757ccadd.library.js +0 -1
  54. package/dist/17e757ccadd.preview.js +0 -1
  55. package/dist/17e757ccadd.screenshoot.js +0 -1
@@ -3476,6 +3476,8 @@ var lsdb = (__webpack_require__(6929)/* ["default"] */ .Z);
3476
3476
  inmem_localstorage
3477
3477
  });
3478
3478
  ;// CONCATENATED MODULE: ./src/store/api.js
3479
+ 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; }
3480
+
3479
3481
 
3480
3482
 
3481
3483
  const ajax = __webpack_require__(7460);
@@ -3492,6 +3494,112 @@ function jsonifyTextPlain(param, done) {
3492
3494
 
3493
3495
  /* harmony default export */ const api = (class {
3494
3496
  constructor(ApiURL, FileURL) {
3497
+ _defineProperty(this, "listConversations", _ => this.apireq.addQuery('user_id', this.uid).addQuery('integration_id', `${this.accid}.subizv4.subikon`).get('/conversations'));
3498
+
3499
+ _defineProperty(this, "listMessages", (cid, limit, start_id) => this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/conversations/${cid}/messages`));
3500
+
3501
+ _defineProperty(this, "ajax", ajax);
3502
+
3503
+ _defineProperty(this, "start", extraData => {
3504
+ let data = {
3505
+ starter_id: this.uid,
3506
+ starter_type: 'user',
3507
+ integration_id: `${this.accid}.subizv4.subikon`
3508
+ };
3509
+ util/* default.each */.Z.each(extraData, (v, k) => {
3510
+ data[k] = v;
3511
+ });
3512
+ return this.apireq.post('/conversations', data);
3513
+ });
3514
+
3515
+ _defineProperty(this, "sendConvoEvent", (cid, ev) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/events`, ev));
3516
+
3517
+ _defineProperty(this, "createPostback", (cid, p) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/postbacks`, p));
3518
+
3519
+ _defineProperty(this, "markAsReceived", (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/receive`));
3520
+
3521
+ _defineProperty(this, "markAsSeen", (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/seen`));
3522
+
3523
+ _defineProperty(this, "getConversation", cid => this.apireq.get(`/conversations/${cid}`));
3524
+
3525
+ _defineProperty(this, "getLocaleContent", locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`));
3526
+
3527
+ _defineProperty(this, "sendEvent", data => this.apireq.post(`/users/${this.uid}/events`, data));
3528
+
3529
+ _defineProperty(this, "sendTyping", cid => this.apireq.post(`/conversations/${cid}/typing`));
3530
+
3531
+ _defineProperty(this, "uploadToS3", async file => {
3532
+ let {
3533
+ body: signed,
3534
+ error
3535
+ } = await this.apireq.post(`/accounts/${this.accid}/files`, {
3536
+ account_id: this.accid,
3537
+ description: 'upload\n user-client: web-widget',
3538
+ name: file.name.replace(/\s+/g, '_'),
3539
+ size: file.size,
3540
+ type: file.type
3541
+ });
3542
+ if (error) return {
3543
+ error
3544
+ };
3545
+ let contentType = file.type || 'application/octet-stream';
3546
+ ({
3547
+ error
3548
+ } = await ajax.setContentType(contentType).put(signed.signed_url, file));
3549
+ if (error) return {
3550
+ error
3551
+ };
3552
+ let body;
3553
+ ({
3554
+ body,
3555
+ error
3556
+ } = await this.apireq.post(`/accounts/${this.accid}/files/${signed.id}`, {
3557
+ account_id: this.accid
3558
+ }));
3559
+ if (error) return {
3560
+ error
3561
+ };
3562
+ return {
3563
+ url: this.FileURL + body.url
3564
+ };
3565
+ });
3566
+
3567
+ _defineProperty(this, "getChallenge", accid => this.apireq.post(`/accounts/${accid}/scrypt-challenges`));
3568
+
3569
+ _defineProperty(this, "time", _ => this.apireq.get('/time'));
3570
+
3571
+ _defineProperty(this, "updateUser", data => this.apireq.post(`/users/${this.uid}`, data));
3572
+
3573
+ _defineProperty(this, "getUser", _ => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`));
3574
+
3575
+ _defineProperty(this, "getAccountSetting", () => this.apireq.get(`/accounts/${this.accid}/settings`));
3576
+
3577
+ _defineProperty(this, "getIsOnline", () => this.apireq.get(`/accounts/${this.accid}/is_online`));
3578
+
3579
+ _defineProperty(this, "sendImpression", impression => this.apireq.post(`/accounts/${this.accid}/campaigns/${impression.campaign_id}/impressions`, impression));
3580
+
3581
+ _defineProperty(this, "sendConversion", conversion => this.apireq.post(`/accounts/${this.accid}/campaigns/${conversion.campaign_id}/conversions`, conversion));
3582
+
3583
+ _defineProperty(this, "lookupOrder", key => ajax.setBaseUrl(this.ApiURL).setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json').addQuery('x-signed-key', key).get(`/orders/123`));
3584
+
3585
+ _defineProperty(this, "getOrder", id => this.apireq.get(`/accounts/${this.accid}/orders/` + id));
3586
+
3587
+ _defineProperty(this, "updateOrder", order => this.apireq.post(`/accounts/${this.accid}/orders/` + order.id, order));
3588
+
3589
+ _defineProperty(this, "fetchShippingAddresses", () => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`));
3590
+
3591
+ _defineProperty(this, "createShippingAddress", addr => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`, addr));
3592
+
3593
+ _defineProperty(this, "list_provinces", () => this.apireq.get(`/accounts/${this.accid}/provinces`));
3594
+
3595
+ _defineProperty(this, "list_districts", p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/districts`));
3596
+
3597
+ _defineProperty(this, "list_wards", p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/wards`));
3598
+
3599
+ _defineProperty(this, "suggest_address", keyword => this.apireq.setQuery({
3600
+ keyword: keyword
3601
+ }).get(`/accounts/${this.accid}/addresses`));
3602
+
3495
3603
  this.FileURL = FileURL;
3496
3604
  this.ApiURL = ApiURL;
3497
3605
  this.apireq = ajax.setBaseUrl(ApiURL).withCredentials(true).addQuery('v', '6').setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json').beforeHook((param, done) => {
@@ -3510,29 +3618,6 @@ function jsonifyTextPlain(param, done) {
3510
3618
  this.uid = obj.uid;
3511
3619
  }
3512
3620
 
3513
- listConversations = _ => this.apireq.addQuery('user_id', this.uid).addQuery('integration_id', `${this.accid}.subizv4.subikon`).get('/conversations');
3514
- listMessages = (cid, limit, start_id) => this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/conversations/${cid}/messages`);
3515
- ajax = ajax;
3516
- start = extraData => {
3517
- let data = {
3518
- starter_id: this.uid,
3519
- starter_type: 'user',
3520
- integration_id: `${this.accid}.subizv4.subikon`
3521
- };
3522
- util/* default.each */.Z.each(extraData, (v, k) => {
3523
- data[k] = v;
3524
- });
3525
- return this.apireq.post('/conversations', data);
3526
- };
3527
- sendConvoEvent = (cid, ev) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/events`, ev);
3528
- createPostback = (cid, p) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/postbacks`, p);
3529
- markAsReceived = (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/receive`);
3530
- markAsSeen = (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/seen`);
3531
- getConversation = cid => this.apireq.get(`/conversations/${cid}`);
3532
- getLocaleContent = locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`);
3533
- sendEvent = data => this.apireq.post(`/users/${this.uid}/events`, data);
3534
- sendTyping = cid => this.apireq.post(`/conversations/${cid}/typing`);
3535
-
3536
3621
  sendPresence(device, is_focused) {
3537
3622
  return this.sendEvent({
3538
3623
  by: {
@@ -3566,43 +3651,6 @@ function jsonifyTextPlain(param, done) {
3566
3651
  });
3567
3652
  }
3568
3653
 
3569
- uploadToS3 = async file => {
3570
- let {
3571
- body: signed,
3572
- error
3573
- } = await this.apireq.post(`/accounts/${this.accid}/files`, {
3574
- account_id: this.accid,
3575
- description: 'upload\n user-client: web-widget',
3576
- name: file.name.replace(/\s+/g, '_'),
3577
- size: file.size,
3578
- type: file.type
3579
- });
3580
- if (error) return {
3581
- error
3582
- };
3583
- let contentType = file.type || 'application/octet-stream';
3584
- ({
3585
- error
3586
- } = await ajax.setContentType(contentType).put(signed.signed_url, file));
3587
- if (error) return {
3588
- error
3589
- };
3590
- let body;
3591
- ({
3592
- body,
3593
- error
3594
- } = await this.apireq.post(`/accounts/${this.accid}/files/${signed.id}`, {
3595
- account_id: this.accid
3596
- }));
3597
- if (error) return {
3598
- error
3599
- };
3600
- return {
3601
- url: this.FileURL + body.url
3602
- };
3603
- };
3604
- getChallenge = accid => this.apireq.post(`/accounts/${accid}/scrypt-challenges`);
3605
-
3606
3654
  async createAgentUser(agenttoken) {
3607
3655
  for (var i = 0; i < 10; i++) {
3608
3656
  let {
@@ -3645,26 +3693,10 @@ function jsonifyTextPlain(param, done) {
3645
3693
  }
3646
3694
  }
3647
3695
 
3648
- time = _ => this.apireq.get('/time');
3649
- updateUser = data => this.apireq.post(`/users/${this.uid}`, data);
3650
- getUser = _ => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`);
3651
- getAccountSetting = () => this.apireq.get(`/accounts/${this.accid}/settings`);
3652
- getIsOnline = () => this.apireq.get(`/accounts/${this.accid}/is_online`);
3653
- sendImpression = impression => this.apireq.post(`/accounts/${this.accid}/campaigns/${impression.campaign_id}/impressions`, impression);
3654
- sendConversion = conversion => this.apireq.post(`/accounts/${this.accid}/campaigns/${conversion.campaign_id}/conversions`, conversion);
3655
- lookupOrder = key => ajax.setBaseUrl(this.ApiURL).setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json').addQuery('x-signed-key', key).get(`/orders/123`);
3656
- getOrder = id => this.apireq.get(`/accounts/${this.accid}/orders/` + id);
3657
- updateOrder = order => this.apireq.post(`/accounts/${this.accid}/orders/` + order.id, order);
3658
- fetchShippingAddresses = () => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`);
3659
- createShippingAddress = addr => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`, addr);
3660
- list_provinces = () => this.apireq.get(`/accounts/${this.accid}/provinces`);
3661
- list_districts = p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/districts`);
3662
- list_wards = p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/wards`);
3663
- suggest_address = keyword => this.apireq.setQuery({
3664
- keyword: keyword
3665
- }).get(`/accounts/${this.accid}/addresses`);
3666
3696
  });
3667
3697
  ;// CONCATENATED MODULE: ./src/store/api_fake.js
3698
+ function api_fake_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; }
3699
+
3668
3700
 
3669
3701
 
3670
3702
  const api_fake_ajax = __webpack_require__(7460);
@@ -3684,6 +3716,86 @@ const OK200 = Promise.resolve({
3684
3716
  });
3685
3717
  /* harmony default export */ const api_fake = (class {
3686
3718
  constructor(ApiURL, FileURL) {
3719
+ api_fake_defineProperty(this, "listConversations", _ => {
3720
+ let convo = makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
3721
+ return Promise.resolve({
3722
+ body: {
3723
+ anchor: '',
3724
+ conversations: [convo]
3725
+ },
3726
+ code: 200
3727
+ });
3728
+ });
3729
+
3730
+ api_fake_defineProperty(this, "listMessages", (cid, limit, start_id) => {
3731
+ let messages = makeFakeMessages(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
3732
+ return Promise.resolve({
3733
+ body: messages,
3734
+ code: 200
3735
+ });
3736
+ });
3737
+
3738
+ api_fake_defineProperty(this, "ajax", api_fake_ajax);
3739
+
3740
+ api_fake_defineProperty(this, "start", extraData => OK200);
3741
+
3742
+ api_fake_defineProperty(this, "sendConvoEvent", (cid, ev) => OK200);
3743
+
3744
+ api_fake_defineProperty(this, "createPostback", (cid, p) => OK200);
3745
+
3746
+ api_fake_defineProperty(this, "markAsReceived", (cid, messageId) => OK200);
3747
+
3748
+ api_fake_defineProperty(this, "markAsSeen", (cid, messageId) => OK200);
3749
+
3750
+ api_fake_defineProperty(this, "getConversation", cid => Promise.resolve({
3751
+ body: makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid),
3752
+ code: 200
3753
+ }));
3754
+
3755
+ api_fake_defineProperty(this, "getLocaleContent", locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`));
3756
+
3757
+ api_fake_defineProperty(this, "sendEvent", data => OK200);
3758
+
3759
+ api_fake_defineProperty(this, "sendTyping", cid => OK200);
3760
+
3761
+ api_fake_defineProperty(this, "sendPresence", data => OK200);
3762
+
3763
+ api_fake_defineProperty(this, "sendContent", data => OK200);
3764
+
3765
+ api_fake_defineProperty(this, "uploadToS3", async file => OK200);
3766
+
3767
+ api_fake_defineProperty(this, "getChallenge", accid => OK200);
3768
+
3769
+ api_fake_defineProperty(this, "createUser", accid => Promise.resolve({
3770
+ account_id: accid,
3771
+ id: 'usqzgtgfake',
3772
+ mask: 'fakemask'
3773
+ }));
3774
+
3775
+ api_fake_defineProperty(this, "createAgentUser", agenttoken => Promise.resolve('fakemask'));
3776
+
3777
+ api_fake_defineProperty(this, "time", _ => Promise.resolve({
3778
+ code: 200,
3779
+ body: new util/* default.Date */.Z.Date().toISOString()
3780
+ }));
3781
+
3782
+ api_fake_defineProperty(this, "updateUser", data => OK200);
3783
+
3784
+ api_fake_defineProperty(this, "getUser", _ => Promise.resolve({
3785
+ code: 200,
3786
+ body: {
3787
+ id: '-'
3788
+ }
3789
+ }));
3790
+
3791
+ api_fake_defineProperty(this, "getAccountSetting", () => this.apireq.get(`/accounts/${this.accid}/settings`));
3792
+
3793
+ api_fake_defineProperty(this, "getIsOnline", () => this.apireq.get(`/accounts/${this.accid}/is_online`));
3794
+
3795
+ api_fake_defineProperty(this, "sendImpression", impression => OK200);
3796
+
3797
+ api_fake_defineProperty(this, "sendConversion", conversion => OK200);
3798
+
3687
3799
  this.FileURL = FileURL;
3688
3800
  this.apireq = api_fake_ajax.setBaseUrl(ApiURL).setContentType('text/plain').beforeHook(api_fake_jsonifyTextPlain).setParser('json');
3689
3801
  }
@@ -3698,61 +3810,6 @@ const OK200 = Promise.resolve({
3698
3810
  this.uid = obj.uid;
3699
3811
  }
3700
3812
 
3701
- listConversations = _ => {
3702
- let convo = makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
3703
- return Promise.resolve({
3704
- body: {
3705
- anchor: '',
3706
- conversations: [convo]
3707
- },
3708
- code: 200
3709
- });
3710
- };
3711
- listMessages = (cid, limit, start_id) => {
3712
- let messages = makeFakeMessages(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
3713
- return Promise.resolve({
3714
- body: messages,
3715
- code: 200
3716
- });
3717
- };
3718
- ajax = api_fake_ajax;
3719
- start = extraData => OK200;
3720
- sendConvoEvent = (cid, ev) => OK200;
3721
- createPostback = (cid, p) => OK200;
3722
- markAsReceived = (cid, messageId) => OK200;
3723
- markAsSeen = (cid, messageId) => OK200;
3724
- getConversation = cid => Promise.resolve({
3725
- body: makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid),
3726
- code: 200
3727
- });
3728
- getLocaleContent = locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`);
3729
- sendEvent = data => OK200;
3730
- sendTyping = cid => OK200;
3731
- sendPresence = data => OK200;
3732
- sendContent = data => OK200;
3733
- uploadToS3 = async file => OK200;
3734
- getChallenge = accid => OK200;
3735
- createUser = accid => Promise.resolve({
3736
- account_id: accid,
3737
- id: 'usqzgtgfake',
3738
- mask: 'fakemask'
3739
- });
3740
- createAgentUser = agenttoken => Promise.resolve('fakemask');
3741
- time = _ => Promise.resolve({
3742
- code: 200,
3743
- body: new util/* default.Date */.Z.Date().toISOString()
3744
- });
3745
- updateUser = data => OK200;
3746
- getUser = _ => Promise.resolve({
3747
- code: 200,
3748
- body: {
3749
- id: '-'
3750
- }
3751
- });
3752
- getAccountSetting = () => this.apireq.get(`/accounts/${this.accid}/settings`);
3753
- getIsOnline = () => this.apireq.get(`/accounts/${this.accid}/is_online`);
3754
- sendImpression = impression => OK200;
3755
- sendConversion = conversion => OK200;
3756
3813
  });
3757
3814
 
3758
3815
  function makeFakeConvo(accid, convoid, userid, agentid) {
@@ -4105,6 +4162,8 @@ function makeFakeMessages(accid, convoid, userid, agentid) {
4105
4162
 
4106
4163
  });
4107
4164
  ;// CONCATENATED MODULE: ./src/store/store.js
4165
+ function store_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; }
4166
+
4108
4167
 
4109
4168
 
4110
4169
  var flow = __webpack_require__(3165);
@@ -4125,6 +4184,172 @@ const MAX_CONVO = 20;
4125
4184
  const page_loaded = util/* default.Date.now */.Z.Date.now();
4126
4185
  class Store {
4127
4186
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fakeapi, agenttoken) {
4187
+ store_defineProperty(this, "inmem", false);
4188
+
4189
+ store_defineProperty(this, "cookie", cookie);
4190
+
4191
+ store_defineProperty(this, "new_visitor", true);
4192
+
4193
+ store_defineProperty(this, "matchUser", () => {
4194
+ this._touchAcc();
4195
+
4196
+ return this.kv.match('user');
4197
+ });
4198
+
4199
+ store_defineProperty(this, "suggest_addresses", keyword => this.api.suggest_address(keyword));
4200
+
4201
+ store_defineProperty(this, "matchSession", () => this.kv.match('session') || {});
4202
+
4203
+ store_defineProperty(this, "matchAccount", () => this.cache.match('account'));
4204
+
4205
+ store_defineProperty(this, "matchPaymentMethods", () => this.cache.match('payment_methods'));
4206
+
4207
+ store_defineProperty(this, "matchUnread", () => {
4208
+ let user = this.matchUser();
4209
+ let allconvos = this.matchConvo('*');
4210
+ let unreadcount = 0;
4211
+ util/* default.map */.Z.map(allconvos, convo => {
4212
+ if (!util/* default.isConvoSeen */.Z.isConvoSeen(convo, user.id)) unreadcount++;
4213
+ });
4214
+ return unreadcount;
4215
+ });
4216
+
4217
+ store_defineProperty(this, "matchPlugin", () => {
4218
+ if (util/* default.size */.Z.size(this.forcePlugins) > 0) return util/* default.cloneDeep */.Z.cloneDeep(this.forcePlugins);
4219
+ return util/* default.cloneDeep */.Z.cloneDeep(this.cache.match('plugin')) || {};
4220
+ });
4221
+
4222
+ store_defineProperty(this, "device", {});
4223
+
4224
+ store_defineProperty(this, "browserVisibility", 'visible');
4225
+
4226
+ store_defineProperty(this, "matchAgent", id => {
4227
+ let agentM = this.cache.match('agent') || {};
4228
+ if (id === '*') return agentM;
4229
+ return agentM[id];
4230
+ });
4231
+
4232
+ store_defineProperty(this, "matchConvo", id => {
4233
+ if (!id) return;
4234
+
4235
+ if (id === '*') {
4236
+ this._touchAcc();
4237
+
4238
+ return util/* default.filter */.Z.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
4239
+ }
4240
+
4241
+ if (!this.isInsync(id)) this.fetchConvo(id);
4242
+ return this.cache.match('convo_' + id);
4243
+ });
4244
+
4245
+ store_defineProperty(this, "fetchConvo", async cid => {
4246
+ await this.readyGate.entry();
4247
+ await this.reconnectGate.entry(undefined, true);
4248
+ if (this.isInsync(cid)) return this.reconnectGate.open();
4249
+ this.markSync(cid);
4250
+ let {
4251
+ body: convo,
4252
+ error
4253
+ } = await this.api.getConversation(cid);
4254
+ if (convo && !error) this._setConvo(convo);
4255
+ return this.reconnectGate.open();
4256
+ });
4257
+
4258
+ store_defineProperty(this, "list_provinces", () => this.api.list_provinces());
4259
+
4260
+ store_defineProperty(this, "list_districts", p => this.api.list_districts(p));
4261
+
4262
+ store_defineProperty(this, "list_wards", p => this.api.list_wards(p));
4263
+
4264
+ store_defineProperty(this, "list_provices", void 0);
4265
+
4266
+ store_defineProperty(this, "listEvents", id => {
4267
+ if (!id || id === '*' || typeof id !== 'string') return;
4268
+
4269
+ if (!this.isInsync('events' + id)) {
4270
+ setTimeout(async () => {
4271
+ await this.readyGate.entry();
4272
+ await this.reconnectGate.entry(undefined, true);
4273
+ if (this.isInsync('events' + id)) return this.reconnectGate.open();
4274
+ this.markSync('events' + id);
4275
+ await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
4276
+ this.pubsub.publish('account');
4277
+ return this.reconnectGate.open();
4278
+ }, 10);
4279
+ }
4280
+
4281
+ return this.chain.listM(id);
4282
+ });
4283
+
4284
+ store_defineProperty(this, "fetchMoreEvents", async convoid => {
4285
+ let {
4286
+ error
4287
+ } = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
4288
+ this.pubsub.publish('account');
4289
+ return {
4290
+ error
4291
+ };
4292
+ });
4293
+
4294
+ store_defineProperty(this, "matchBot", () => this.cache.match('bot') || {});
4295
+
4296
+ store_defineProperty(this, "readyGate", new util/* default.Gate */.Z.Gate());
4297
+
4298
+ store_defineProperty(this, "convoGate", new util/* default.Gate */.Z.Gate(true));
4299
+
4300
+ store_defineProperty(this, "reconnectGate", new util/* default.Gate */.Z.Gate(true));
4301
+
4302
+ store_defineProperty(this, "matchLastview", () => this.kv.match('lastview') || {});
4303
+
4304
+ store_defineProperty(this, "matchIsOpen", () => !!this.kv.match('isopen'));
4305
+
4306
+ store_defineProperty(this, "matchHasManuallyClosed", () => !!this.kv.match('hasManuallyClosed'));
4307
+
4308
+ store_defineProperty(this, "matchClosePreviewAt", () => this.kv.match('close_preview_at') || 0);
4309
+
4310
+ store_defineProperty(this, "sendPresence", util/* default.throttle */.Z.throttle(async () => {
4311
+ await this.readyGate.entry();
4312
+ if (!util/* default.get */.Z.get(this.kv.match('user'), 'id')) return;
4313
+ if (util/* default.isUserBanned */.Z.isUserBanned(this.kv.match('user'))) return;
4314
+ return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
4315
+ }, 1000));
4316
+
4317
+ store_defineProperty(this, "now", () => util/* default.Date.now */.Z.Date.now() + this.timeDiff);
4318
+
4319
+ store_defineProperty(this, "seenQueue", []);
4320
+
4321
+ store_defineProperty(this, "_typing", util/* default.throttle */.Z.throttle(convoid => this.api.sendTyping(convoid), 3000));
4322
+
4323
+ store_defineProperty(this, "onConvoEvent", (o, cb) => this.pubsub.on2(o, 'events', cb));
4324
+
4325
+ store_defineProperty(this, "seenConvo", id => {
4326
+ if (!id || id === 'create') return;
4327
+ this.seenQueue.push(id);
4328
+ });
4329
+
4330
+ store_defineProperty(this, "onUpdate", (o, cb) => this.pubsub.on2(o, 'account', cb));
4331
+
4332
+ store_defineProperty(this, "onResetCSS", (o, cb) => this.pubsub.on2(o, 'resetCSS', cb));
4333
+
4334
+ store_defineProperty(this, "onHighlight", (o, cb) => this.pubsub.on2(o, 'highlight', cb));
4335
+
4336
+ store_defineProperty(this, "setHasManuallyClosed", () => this.kv.put('hasManuallyClosed', true));
4337
+
4338
+ store_defineProperty(this, "setIsOpen", isopen => {
4339
+ let lastisopen = this.kv.match('isopen');
4340
+ this.kv.put('isopen', isopen);
4341
+ if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
4342
+ });
4343
+
4344
+ store_defineProperty(this, "closePreview", () => this.kv.put('close_preview_at', new util/* default.Date */.Z.Date().getTime()));
4345
+
4346
+ store_defineProperty(this, "setLastview", (view, opts) => this.kv.put('lastview', {
4347
+ view,
4348
+ opts
4349
+ }));
4350
+
4351
+ store_defineProperty(this, "timeDiff", 0);
4352
+
4128
4353
  this.agent_token = agenttoken;
4129
4354
  this.g_sync = {};
4130
4355
  this.forceDevice = null;
@@ -4178,9 +4403,6 @@ class Store {
4178
4403
  }, 2000);
4179
4404
  }
4180
4405
 
4181
- inmem = false;
4182
- cookie = cookie;
4183
-
4184
4406
  isInsync(key) {
4185
4407
  return util/* default.Date.now */.Z.Date.now() - (this.g_sync[key] || 0) < 300000;
4186
4408
  }
@@ -4279,113 +4501,12 @@ class Store {
4279
4501
  this.g_sync[key] = util/* default.Date.now */.Z.Date.now();
4280
4502
  }
4281
4503
 
4282
- new_visitor = true;
4283
-
4284
4504
  async _touchAcc() {
4285
4505
  if (this.isInsync('account')) return;
4286
4506
  await this.readyGate.entry();
4287
4507
  if (!this.isInsync('account')) this.reconnect();
4288
4508
  }
4289
4509
 
4290
- matchUser = () => {
4291
- this._touchAcc();
4292
-
4293
- return this.kv.match('user');
4294
- };
4295
- suggest_addresses = keyword => this.api.suggest_address(keyword);
4296
- matchSession = () => this.kv.match('session') || {};
4297
- matchAccount = () => this.cache.match('account');
4298
- matchPaymentMethods = () => this.cache.match('payment_methods');
4299
- matchUnread = () => {
4300
- let user = this.matchUser();
4301
- let allconvos = this.matchConvo('*');
4302
- let unreadcount = 0;
4303
- util/* default.map */.Z.map(allconvos, convo => {
4304
- if (!util/* default.isConvoSeen */.Z.isConvoSeen(convo, user.id)) unreadcount++;
4305
- });
4306
- return unreadcount;
4307
- };
4308
- matchPlugin = () => {
4309
- if (util/* default.size */.Z.size(this.forcePlugins) > 0) return util/* default.cloneDeep */.Z.cloneDeep(this.forcePlugins);
4310
- return util/* default.cloneDeep */.Z.cloneDeep(this.cache.match('plugin')) || {};
4311
- };
4312
- device = {};
4313
- browserVisibility = 'visible';
4314
- matchAgent = id => {
4315
- let agentM = this.cache.match('agent') || {};
4316
- if (id === '*') return agentM;
4317
- return agentM[id];
4318
- };
4319
- matchConvo = id => {
4320
- if (!id) return;
4321
-
4322
- if (id === '*') {
4323
- this._touchAcc();
4324
-
4325
- return util/* default.filter */.Z.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
4326
- }
4327
-
4328
- if (!this.isInsync(id)) this.fetchConvo(id);
4329
- return this.cache.match('convo_' + id);
4330
- };
4331
- fetchConvo = async cid => {
4332
- await this.readyGate.entry();
4333
- await this.reconnectGate.entry(undefined, true);
4334
- if (this.isInsync(cid)) return this.reconnectGate.open();
4335
- this.markSync(cid);
4336
- let {
4337
- body: convo,
4338
- error
4339
- } = await this.api.getConversation(cid);
4340
- if (convo && !error) this._setConvo(convo);
4341
- return this.reconnectGate.open();
4342
- };
4343
- list_provinces = () => this.api.list_provinces();
4344
- list_districts = p => this.api.list_districts(p);
4345
- list_wards = p => this.api.list_wards(p);
4346
- list_provices;
4347
- listEvents = id => {
4348
- if (!id || id === '*' || typeof id !== 'string') return;
4349
-
4350
- if (!this.isInsync('events' + id)) {
4351
- setTimeout(async () => {
4352
- await this.readyGate.entry();
4353
- await this.reconnectGate.entry(undefined, true);
4354
- if (this.isInsync('events' + id)) return this.reconnectGate.open();
4355
- this.markSync('events' + id);
4356
- await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
4357
- this.pubsub.publish('account');
4358
- return this.reconnectGate.open();
4359
- }, 10);
4360
- }
4361
-
4362
- return this.chain.listM(id);
4363
- };
4364
- fetchMoreEvents = async convoid => {
4365
- let {
4366
- error
4367
- } = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
4368
- this.pubsub.publish('account');
4369
- return {
4370
- error
4371
- };
4372
- };
4373
- matchBot = () => this.cache.match('bot') || {};
4374
- readyGate = new util/* default.Gate */.Z.Gate();
4375
- convoGate = new util/* default.Gate */.Z.Gate(true);
4376
- reconnectGate = new util/* default.Gate */.Z.Gate(true);
4377
- matchLastview = () => this.kv.match('lastview') || {};
4378
- matchIsOpen = () => !!this.kv.match('isopen');
4379
- matchHasManuallyClosed = () => !!this.kv.match('hasManuallyClosed');
4380
- matchClosePreviewAt = () => this.kv.match('close_preview_at') || 0;
4381
- sendPresence = util/* default.throttle */.Z.throttle(async () => {
4382
- await this.readyGate.entry();
4383
- if (!util/* default.get */.Z.get(this.kv.match('user'), 'id')) return;
4384
- if (util/* default.isUserBanned */.Z.isUserBanned(this.kv.match('user'))) return;
4385
- return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
4386
- }, 1000);
4387
- now = () => util/* default.Date.now */.Z.Date.now() + this.timeDiff;
4388
-
4389
4510
  async init(accid, mask) {
4390
4511
  this.readyGate.close();
4391
4512
  accid = (accid || '').trim();
@@ -4444,8 +4565,6 @@ class Store {
4444
4565
  return mask;
4445
4566
  }
4446
4567
 
4447
- seenQueue = [];
4448
-
4449
4568
  seenLoop() {
4450
4569
  this.seenQueue = [];
4451
4570
  clearInterval(this._seenInterval);
@@ -4791,8 +4910,6 @@ class Store {
4791
4910
  this._typing(cid);
4792
4911
  }
4793
4912
 
4794
- _typing = util/* default.throttle */.Z.throttle(convoid => this.api.sendTyping(convoid), 3000);
4795
-
4796
4913
  async startConvo(req) {
4797
4914
  await this.readyGate.entry();
4798
4915
  this.convoGate.close();
@@ -4885,12 +5002,6 @@ class Store {
4885
5002
  sendEventToThirdParty('SUBIZ Chat', 'Sent', 'User');
4886
5003
  }
4887
5004
 
4888
- onConvoEvent = (o, cb) => this.pubsub.on2(o, 'events', cb);
4889
- seenConvo = id => {
4890
- if (!id || id === 'create') return;
4891
- this.seenQueue.push(id);
4892
- };
4893
-
4894
5005
  _setConvo(convo) {
4895
5006
  let count = 0;
4896
5007
  let user = this.kv.match('user');
@@ -4918,21 +5029,6 @@ class Store {
4918
5029
  this.cache.put('convo_' + convo.id, convo);
4919
5030
  }
4920
5031
 
4921
- onUpdate = (o, cb) => this.pubsub.on2(o, 'account', cb);
4922
- onResetCSS = (o, cb) => this.pubsub.on2(o, 'resetCSS', cb);
4923
- onHighlight = (o, cb) => this.pubsub.on2(o, 'highlight', cb);
4924
- setHasManuallyClosed = () => this.kv.put('hasManuallyClosed', true);
4925
- setIsOpen = isopen => {
4926
- let lastisopen = this.kv.match('isopen');
4927
- this.kv.put('isopen', isopen);
4928
- if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
4929
- };
4930
- closePreview = () => this.kv.put('close_preview_at', new util/* default.Date */.Z.Date().getTime());
4931
- setLastview = (view, opts) => this.kv.put('lastview', {
4932
- view,
4933
- opts
4934
- });
4935
-
4936
5032
  matchLastPluginRun(pluginid) {
4937
5033
  let log = this.kv.match('plugin_run_logs') || {};
4938
5034
  return log[pluginid];
@@ -5035,8 +5131,6 @@ class Store {
5035
5131
  return [events, anchor];
5036
5132
  }
5037
5133
 
5038
- timeDiff = 0;
5039
-
5040
5134
  async loopTime() {
5041
5135
  let startms = util/* default.Date.now */.Z.Date.now();
5042
5136
  if (!util/* default.get */.Z.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 30000);
@@ -5576,6 +5670,8 @@ class PluginMgr {
5576
5670
 
5577
5671
  }
5578
5672
  ;// CONCATENATED MODULE: ./src/lib.js
5673
+ function lib_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; }
5674
+
5579
5675
 
5580
5676
 
5581
5677
 
@@ -5587,6 +5683,18 @@ util/* default.preloadWebfonts */.Z.preloadWebfonts(['Roboto'], [400, 500]);
5587
5683
 
5588
5684
  class Widget {
5589
5685
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken) {
5686
+ lib_defineProperty(this, "version", () => '4.4');
5687
+
5688
+ lib_defineProperty(this, "setSetting", setting => this.store.setSetting({
5689
+ account_setting: setting
5690
+ }));
5691
+
5692
+ lib_defineProperty(this, "getSetting", _ => ({
5693
+ account_setting: util/* default.cloneDeep */.Z.cloneDeep(this.store.matchAccountSetting())
5694
+ }));
5695
+
5696
+ lib_defineProperty(this, "getUser", () => util/* default.parseJSON */.Z.parseJSON(util/* default.stringify */.Z.stringify(this.store.matchUser())));
5697
+
5590
5698
  this.domGate = new util/* default.Gate */.Z.Gate();
5591
5699
  this.store = new Store(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken);
5592
5700
  window.sbz_store = this.store;
@@ -5691,15 +5799,6 @@ class Widget {
5691
5799
  this.pluginMgr.hideCurrentChatbox();
5692
5800
  }
5693
5801
 
5694
- version = () => '4.4';
5695
- setSetting = setting => this.store.setSetting({
5696
- account_setting: setting
5697
- });
5698
- getSetting = _ => ({
5699
- account_setting: util/* default.cloneDeep */.Z.cloneDeep(this.store.matchAccountSetting())
5700
- });
5701
- getUser = () => util/* default.parseJSON */.Z.parseJSON(util/* default.stringify */.Z.stringify(this.store.matchUser()));
5702
-
5703
5802
  async setLocale(locale) {
5704
5803
  await this.domGate.entry();
5705
5804
  return this.pluginMgr.setCurrentChatboxLocale(locale);