@hellotext/hellotext 2.5.7 → 2.5.8

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 (102) hide show
  1. package/README.md +0 -25
  2. package/dist/hellotext.js +1 -1
  3. package/index.d.ts +0 -6
  4. package/lib/api/acks.cjs +17 -31
  5. package/lib/api/acks.js +17 -42
  6. package/lib/api/businesses.cjs +14 -28
  7. package/lib/api/businesses.js +13 -36
  8. package/lib/api/events.cjs +26 -40
  9. package/lib/api/events.js +28 -52
  10. package/lib/api/forms.cjs +24 -40
  11. package/lib/api/forms.js +24 -57
  12. package/lib/api/identifications.cjs +15 -29
  13. package/lib/api/identifications.js +15 -40
  14. package/lib/api/index.cjs +25 -51
  15. package/lib/api/index.js +27 -54
  16. package/lib/api/push/identities.cjs +30 -46
  17. package/lib/api/push/identities.js +30 -63
  18. package/lib/api/response.cjs +30 -52
  19. package/lib/api/response.js +31 -60
  20. package/lib/api/submissions.cjs +18 -34
  21. package/lib/api/submissions.js +18 -48
  22. package/lib/api/webchat/messages.cjs +44 -64
  23. package/lib/api/webchat/messages.js +44 -80
  24. package/lib/api/webchats.cjs +37 -56
  25. package/lib/api/webchats.js +37 -65
  26. package/lib/api/whatsapp_widgets.cjs +49 -72
  27. package/lib/api/whatsapp_widgets.js +48 -91
  28. package/lib/builders/input_builder.cjs +36 -48
  29. package/lib/builders/input_builder.js +36 -48
  30. package/lib/builders/logo_builder.cjs +10 -29
  31. package/lib/builders/logo_builder.js +20 -28
  32. package/lib/channels/application_channel.cjs +136 -178
  33. package/lib/channels/application_channel.js +137 -180
  34. package/lib/channels/webchat_channel.cjs +125 -170
  35. package/lib/channels/webchat_channel.js +125 -170
  36. package/lib/controllers/form_controller.cjs +82 -121
  37. package/lib/controllers/form_controller.js +82 -130
  38. package/lib/controllers/message_controller.cjs +211 -282
  39. package/lib/controllers/message_controller.js +209 -284
  40. package/lib/controllers/mixins/usePopover.cjs +3 -6
  41. package/lib/controllers/mixins/usePopover.js +17 -22
  42. package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
  43. package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
  44. package/lib/controllers/webchat/useBehaviour.js +5 -5
  45. package/lib/controllers/webchat/useOpeningSequence.js +6 -6
  46. package/lib/controllers/webchat/useTeaser.js +9 -9
  47. package/lib/controllers/webchat_controller.cjs +916 -1088
  48. package/lib/controllers/webchat_controller.js +926 -1152
  49. package/lib/core/configuration/forms.cjs +21 -35
  50. package/lib/core/configuration/forms.js +20 -35
  51. package/lib/core/configuration/locale.cjs +36 -71
  52. package/lib/core/configuration/locale.js +36 -70
  53. package/lib/core/configuration/push.cjs +9 -21
  54. package/lib/core/configuration/push.js +8 -20
  55. package/lib/core/configuration/webchat.cjs +142 -182
  56. package/lib/core/configuration/webchat.js +145 -189
  57. package/lib/core/configuration/whatsapp.cjs +76 -102
  58. package/lib/core/configuration/whatsapp.js +76 -105
  59. package/lib/core/configuration.cjs +60 -78
  60. package/lib/core/configuration.js +59 -78
  61. package/lib/core/event.cjs +36 -59
  62. package/lib/core/event.js +35 -61
  63. package/lib/core/sanitize_html.js +4 -4
  64. package/lib/errors/invalid_event.cjs +5 -26
  65. package/lib/errors/invalid_event.js +5 -26
  66. package/lib/errors/not_initialized_error.cjs +5 -26
  67. package/lib/errors/not_initialized_error.js +5 -26
  68. package/lib/hellotext.cjs +185 -223
  69. package/lib/hellotext.js +188 -247
  70. package/lib/index.js +1 -1
  71. package/lib/models/business.cjs +114 -152
  72. package/lib/models/business.js +117 -162
  73. package/lib/models/cookies.cjs +34 -51
  74. package/lib/models/cookies.js +34 -51
  75. package/lib/models/fingerprint.cjs +8 -23
  76. package/lib/models/fingerprint.js +25 -58
  77. package/lib/models/form.cjs +106 -142
  78. package/lib/models/form.js +105 -153
  79. package/lib/models/form_collection.cjs +63 -101
  80. package/lib/models/form_collection.js +61 -107
  81. package/lib/models/page.cjs +106 -129
  82. package/lib/models/page.js +106 -131
  83. package/lib/models/push.cjs +278 -322
  84. package/lib/models/push.js +284 -357
  85. package/lib/models/query.cjs +21 -41
  86. package/lib/models/query.js +21 -41
  87. package/lib/models/session.cjs +33 -65
  88. package/lib/models/session.js +30 -63
  89. package/lib/models/user.cjs +29 -51
  90. package/lib/models/user.js +29 -51
  91. package/lib/models/utm.cjs +15 -27
  92. package/lib/models/utm.js +17 -32
  93. package/lib/models/webchat.cjs +52 -76
  94. package/lib/models/webchat.js +52 -90
  95. package/lib/models/whatsapp_widget.cjs +41 -59
  96. package/lib/models/whatsapp_widget.js +41 -73
  97. package/lib/vanilla.cjs +4 -7
  98. package/lib/vanilla.js +2 -1
  99. package/package.json +1 -9
  100. package/src/index.bundle.js +0 -1
  101. package/src/vanilla.js +2 -1
  102. package/styles/index.css +0 -30
@@ -1,8 +1,3 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- 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); }
6
1
  /**
7
2
  * @typedef {'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'} Placement
8
3
  * @description Valid placements for the webchat.
@@ -11,7 +6,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
11
6
  /**
12
7
  * @enum {Placement}
13
8
  */
14
- var placements = {
9
+ const placements = {
15
10
  TOP_LEFT: 'top-left',
16
11
  TOP_RIGHT: 'top-right',
17
12
  BOTTOM_LEFT: 'bottom-left',
@@ -27,7 +22,7 @@ var placements = {
27
22
  * @enum {Strategy}
28
23
  */
29
24
 
30
- var strategies = {
25
+ const strategies = {
31
26
  ABSOLUTE: 'absolute',
32
27
  FIXED: 'fixed'
33
28
  };
@@ -39,7 +34,7 @@ var strategies = {
39
34
  /**
40
35
  * @enum {Mode}
41
36
  */
42
- var modes = {
37
+ const modes = {
43
38
  MODAL: 'modal',
44
39
  POPOVER: 'popover'
45
40
  };
@@ -79,208 +74,169 @@ var modes = {
79
74
  * @property {WhatsApp} whatsapp - WhatsApp handoff overrides.
80
75
  * @property {Strategy} strategy - the strategy used to position the webchat. Defaults to 'absolute'
81
76
  */
82
- var Webchat = /*#__PURE__*/function () {
83
- function Webchat() {
84
- _classCallCheck(this, Webchat);
77
+
78
+ class Webchat {
79
+ static _id;
80
+ static _container = 'body';
81
+ static _placement = 'bottom-right';
82
+ static _style = {};
83
+ static _appearance = {};
84
+ static _whatsapp = {};
85
+ static _mode = modes.POPOVER;
86
+ static _behaviour = null;
87
+ static _hasBehaviourOverride = false;
88
+ static _strategy = null;
89
+ static set container(value) {
90
+ this._container = value;
85
91
  }
86
- _createClass(Webchat, null, [{
87
- key: "container",
88
- get: function get() {
89
- return this._container;
90
- },
91
- set: function set(value) {
92
- this._container = value;
93
- }
94
- }, {
95
- key: "placement",
96
- get: function get() {
97
- return this._placement;
98
- },
99
- set: function set(value) {
100
- if (!Object.values(placements).includes(value)) {
101
- throw new Error("Invalid placement value: ".concat(value));
102
- }
103
- this._placement = value;
104
- }
105
- }, {
106
- key: "id",
107
- get: function get() {
108
- return this._id;
109
- },
110
- set: function set(value) {
111
- this._id = value;
92
+ static get container() {
93
+ return this._container;
94
+ }
95
+ static set placement(value) {
96
+ if (!Object.values(placements).includes(value)) {
97
+ throw new Error(`Invalid placement value: ${value}`);
112
98
  }
113
- }, {
114
- key: "isSet",
115
- get: function get() {
116
- return !!this._id;
99
+ this._placement = value;
100
+ }
101
+ static get placement() {
102
+ return this._placement;
103
+ }
104
+ static set id(value) {
105
+ this._id = value;
106
+ }
107
+ static get id() {
108
+ return this._id;
109
+ }
110
+ static get isSet() {
111
+ return !!this._id;
112
+ }
113
+ static get style() {
114
+ return this._style;
115
+ }
116
+ static set style(value) {
117
+ if (typeof value !== 'object') {
118
+ throw new Error('Style must be an object');
117
119
  }
118
- }, {
119
- key: "style",
120
- get: function get() {
121
- return this._style;
122
- },
123
- set: function set(value) {
124
- if (typeof value !== 'object') {
125
- throw new Error('Style must be an object');
120
+ Object.entries(value).forEach(([key, value]) => {
121
+ if (!['primaryColor', 'secondaryColor', 'typography'].includes(key)) {
122
+ throw new Error(`Invalid style property: ${key}`);
126
123
  }
127
- Object.entries(value).forEach(_ref => {
128
- var [key, value] = _ref;
129
- if (!['primaryColor', 'secondaryColor', 'typography'].includes(key)) {
130
- throw new Error("Invalid style property: ".concat(key));
131
- }
132
- if (key === 'typography') {
133
- return;
134
- }
135
- if (!this.isHexOrRgba(value)) {
136
- throw new Error("Invalid color value: ".concat(value, " for ").concat(key, ". Colors must be hex or rgb/a."));
137
- }
138
- });
139
- this._style = value;
140
- }
141
- }, {
142
- key: "appearance",
143
- get: function get() {
144
- return this._appearance;
145
- },
146
- set: function set(value) {
147
- if (!this.isPlainObject(value)) {
148
- throw new Error('Appearance must be an object');
124
+ if (key === 'typography') {
125
+ return;
149
126
  }
150
- Object.entries(value).forEach(_ref2 => {
151
- var [key, nestedValue] = _ref2;
152
- if (!['header', 'launcher'].includes(key)) {
153
- throw new Error("Invalid appearance property: ".concat(key));
154
- }
155
- if (!this.isPlainObject(nestedValue)) {
156
- throw new Error("Appearance ".concat(key, " must be an object"));
157
- }
158
- Object.entries(nestedValue).forEach(_ref3 => {
159
- var [nestedKey, propertyValue] = _ref3;
160
- if (key === 'header' && nestedKey !== 'name') {
161
- throw new Error("Invalid appearance header property: ".concat(nestedKey));
162
- }
163
- if (key === 'launcher' && nestedKey !== 'iconUrl') {
164
- throw new Error("Invalid appearance launcher property: ".concat(nestedKey));
165
- }
166
- if (propertyValue == null) {
167
- return;
168
- }
169
- if (typeof propertyValue !== 'string') {
170
- throw new Error("Invalid appearance ".concat(key, ".").concat(nestedKey, " value: ").concat(propertyValue));
171
- }
172
- });
173
- });
174
- this._appearance = value;
127
+ if (!this.isHexOrRgba(value)) {
128
+ throw new Error(`Invalid color value: ${value} for ${key}. Colors must be hex or rgb/a.`);
129
+ }
130
+ });
131
+ this._style = value;
132
+ }
133
+ static get appearance() {
134
+ return this._appearance;
135
+ }
136
+ static set appearance(value) {
137
+ if (!this.isPlainObject(value)) {
138
+ throw new Error('Appearance must be an object');
175
139
  }
176
- }, {
177
- key: "whatsapp",
178
- get: function get() {
179
- return this._whatsapp;
180
- },
181
- set: function set(value) {
182
- if (!this.isPlainObject(value)) {
183
- throw new Error('WhatsApp must be an object');
140
+ Object.entries(value).forEach(([key, nestedValue]) => {
141
+ if (!['header', 'launcher'].includes(key)) {
142
+ throw new Error(`Invalid appearance property: ${key}`);
143
+ }
144
+ if (!this.isPlainObject(nestedValue)) {
145
+ throw new Error(`Appearance ${key} must be an object`);
184
146
  }
185
- Object.entries(value).forEach(_ref4 => {
186
- var [key, nestedValue] = _ref4;
187
- if (!['number', 'restrictToChannel'].includes(key)) {
188
- throw new Error("Invalid WhatsApp property: ".concat(key));
147
+ Object.entries(nestedValue).forEach(([nestedKey, propertyValue]) => {
148
+ if (key === 'header' && nestedKey !== 'name') {
149
+ throw new Error(`Invalid appearance header property: ${nestedKey}`);
189
150
  }
190
- if (nestedValue == null) {
191
- return;
151
+ if (key === 'launcher' && nestedKey !== 'iconUrl') {
152
+ throw new Error(`Invalid appearance launcher property: ${nestedKey}`);
192
153
  }
193
- if (key === 'number' && typeof nestedValue !== 'string') {
194
- throw new Error("Invalid WhatsApp number value: ".concat(nestedValue));
154
+ if (propertyValue == null) {
155
+ return;
195
156
  }
196
- if (key === 'restrictToChannel' && typeof nestedValue !== 'boolean') {
197
- throw new Error("Invalid WhatsApp restrictToChannel value: ".concat(nestedValue));
157
+ if (typeof propertyValue !== 'string') {
158
+ throw new Error(`Invalid appearance ${key}.${nestedKey} value: ${propertyValue}`);
198
159
  }
199
160
  });
200
- this._whatsapp = value;
161
+ });
162
+ this._appearance = value;
163
+ }
164
+ static get whatsapp() {
165
+ return this._whatsapp;
166
+ }
167
+ static set whatsapp(value) {
168
+ if (!this.isPlainObject(value)) {
169
+ throw new Error('WhatsApp must be an object');
201
170
  }
202
- }, {
203
- key: "mode",
204
- get: function get() {
205
- return this._mode;
206
- },
207
- set: function set(value) {
208
- if (!Object.values(modes).includes(value)) {
209
- throw new Error("Invalid mode value: ".concat(value));
171
+ Object.entries(value).forEach(([key, nestedValue]) => {
172
+ if (!['number', 'restrictToChannel'].includes(key)) {
173
+ throw new Error(`Invalid WhatsApp property: ${key}`);
210
174
  }
211
- this._mode = value;
212
- }
213
- }, {
214
- key: "behaviour",
215
- get: function get() {
216
- return this._behaviour;
217
- },
218
- set: function set(value) {
219
- if (value == null) {
220
- this._behaviour = value;
175
+ if (nestedValue == null) {
221
176
  return;
222
177
  }
223
- if (typeof value !== 'object' || Array.isArray(value)) {
224
- throw new Error("Invalid behaviour value: ".concat(value));
178
+ if (key === 'number' && typeof nestedValue !== 'string') {
179
+ throw new Error(`Invalid WhatsApp number value: ${nestedValue}`);
225
180
  }
226
- this._behaviour = value;
181
+ if (key === 'restrictToChannel' && typeof nestedValue !== 'boolean') {
182
+ throw new Error(`Invalid WhatsApp restrictToChannel value: ${nestedValue}`);
183
+ }
184
+ });
185
+ this._whatsapp = value;
186
+ }
187
+ static get mode() {
188
+ return this._mode;
189
+ }
190
+ static set mode(value) {
191
+ if (!Object.values(modes).includes(value)) {
192
+ throw new Error(`Invalid mode value: ${value}`);
227
193
  }
228
- }, {
229
- key: "hasBehaviourOverride",
230
- get: function get() {
231
- return this._hasBehaviourOverride;
194
+ this._mode = value;
195
+ }
196
+ static get behaviour() {
197
+ return this._behaviour;
198
+ }
199
+ static set behaviour(value) {
200
+ if (value == null) {
201
+ this._behaviour = value;
202
+ return;
232
203
  }
233
- }, {
234
- key: "behaviourOverride",
235
- set: function set(value) {
236
- this._hasBehaviourOverride = !!value;
204
+ if (typeof value !== 'object' || Array.isArray(value)) {
205
+ throw new Error(`Invalid behaviour value: ${value}`);
237
206
  }
238
- }, {
239
- key: "strategy",
240
- get: function get() {
241
- if (this._strategy) {
242
- return this._strategy;
243
- }
244
- return this.container == 'body' ? strategies.FIXED : strategies.ABSOLUTE;
245
- },
246
- set: function set(value) {
247
- if (value && !Object.values(strategies).includes(value)) {
248
- throw new Error("Invalid strategy value: ".concat(value));
249
- }
250
- this._strategy = value;
251
- }
252
- }, {
253
- key: "assign",
254
- value: function assign(props) {
255
- if (props) {
256
- Object.entries(props).forEach(_ref5 => {
257
- var [key, value] = _ref5;
258
- this[key] = value;
259
- });
260
- }
261
- return this;
207
+ this._behaviour = value;
208
+ }
209
+ static get hasBehaviourOverride() {
210
+ return this._hasBehaviourOverride;
211
+ }
212
+ static set behaviourOverride(value) {
213
+ this._hasBehaviourOverride = !!value;
214
+ }
215
+ static get strategy() {
216
+ if (this._strategy) {
217
+ return this._strategy;
262
218
  }
263
- }, {
264
- key: "isHexOrRgba",
265
- value: function isHexOrRgba(value) {
266
- return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(value) || /^rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3},?\s*(0|1|0?\.\d+)?\s*\)$/.test(value);
219
+ return this.container == 'body' ? strategies.FIXED : strategies.ABSOLUTE;
220
+ }
221
+ static set strategy(value) {
222
+ if (value && !Object.values(strategies).includes(value)) {
223
+ throw new Error(`Invalid strategy value: ${value}`);
267
224
  }
268
- }, {
269
- key: "isPlainObject",
270
- value: function isPlainObject(value) {
271
- return typeof value === 'object' && value !== null && !Array.isArray(value);
225
+ this._strategy = value;
226
+ }
227
+ static assign(props) {
228
+ if (props) {
229
+ Object.entries(props).forEach(([key, value]) => {
230
+ this[key] = value;
231
+ });
272
232
  }
273
- }]);
274
- return Webchat;
275
- }();
276
- Webchat._id = void 0;
277
- Webchat._container = 'body';
278
- Webchat._placement = 'bottom-right';
279
- Webchat._style = {};
280
- Webchat._appearance = {};
281
- Webchat._whatsapp = {};
282
- Webchat._mode = modes.POPOVER;
283
- Webchat._behaviour = null;
284
- Webchat._hasBehaviourOverride = false;
285
- Webchat._strategy = null;
233
+ return this;
234
+ }
235
+ static isHexOrRgba(value) {
236
+ return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(value) || /^rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3},?\s*(0|1|0?\.\d+)?\s*\)$/.test(value);
237
+ }
238
+ static isPlainObject(value) {
239
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
240
+ }
241
+ }
286
242
  export { modes, Webchat };
@@ -4,11 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.WhatsApp = void 0;
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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); }
12
7
  /**
13
8
  * @typedef {'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'} Placement
14
9
  * @description Valid placements for the WhatsApp widget.
@@ -40,111 +35,90 @@ const placements = {
40
35
  * @property {String} body - Prefilled WhatsApp compose text.
41
36
  * @property {WhatsAppWidgetAppearance} appearance - Appearance overrides.
42
37
  */
43
- let WhatsApp = /*#__PURE__*/function () {
44
- function WhatsApp() {
45
- _classCallCheck(this, WhatsApp);
38
+ class WhatsApp {
39
+ static _id;
40
+ static _container = 'body';
41
+ static _placement = 'bottom-right';
42
+ static _appearance = {};
43
+ static _number = null;
44
+ static _body = null;
45
+ static set id(value) {
46
+ this._id = value;
46
47
  }
47
- _createClass(WhatsApp, null, [{
48
- key: "id",
49
- get: function () {
50
- return this._id;
51
- },
52
- set: function (value) {
53
- this._id = value;
48
+ static get id() {
49
+ return this._id;
50
+ }
51
+ static set container(value) {
52
+ this._container = value;
53
+ }
54
+ static get container() {
55
+ return this._container;
56
+ }
57
+ static set placement(value) {
58
+ if (!Object.values(placements).includes(value)) {
59
+ throw new Error(`Invalid placement value: ${value}`);
54
60
  }
55
- }, {
56
- key: "container",
57
- get: function () {
58
- return this._container;
59
- },
60
- set: function (value) {
61
- this._container = value;
61
+ this._placement = value;
62
+ }
63
+ static get placement() {
64
+ return this._placement;
65
+ }
66
+ static get appearance() {
67
+ return this._appearance;
68
+ }
69
+ static set appearance(value) {
70
+ if (!this.isPlainObject(value)) {
71
+ throw new Error('Appearance must be an object');
62
72
  }
63
- }, {
64
- key: "placement",
65
- get: function () {
66
- return this._placement;
67
- },
68
- set: function (value) {
69
- if (!Object.values(placements).includes(value)) {
70
- throw new Error(`Invalid placement value: ${value}`);
73
+ Object.entries(value).forEach(([key, nestedValue]) => {
74
+ if (key !== 'launcher') {
75
+ throw new Error(`Invalid appearance property: ${key}`);
71
76
  }
72
- this._placement = value;
73
- }
74
- }, {
75
- key: "appearance",
76
- get: function () {
77
- return this._appearance;
78
- },
79
- set: function (value) {
80
- if (!this.isPlainObject(value)) {
81
- throw new Error('Appearance must be an object');
77
+ if (!this.isPlainObject(nestedValue)) {
78
+ throw new Error(`Appearance ${key} must be an object`);
82
79
  }
83
- Object.entries(value).forEach(([key, nestedValue]) => {
84
- if (key !== 'launcher') {
85
- throw new Error(`Invalid appearance property: ${key}`);
80
+ Object.entries(nestedValue).forEach(([nestedKey, propertyValue]) => {
81
+ if (nestedKey !== 'iconUrl') {
82
+ throw new Error(`Invalid appearance launcher property: ${nestedKey}`);
83
+ }
84
+ if (propertyValue == null) {
85
+ return;
86
86
  }
87
- if (!this.isPlainObject(nestedValue)) {
88
- throw new Error(`Appearance ${key} must be an object`);
87
+ if (typeof propertyValue !== 'string') {
88
+ throw new Error(`Invalid appearance ${key}.${nestedKey} value: ${propertyValue}`);
89
89
  }
90
- Object.entries(nestedValue).forEach(([nestedKey, propertyValue]) => {
91
- if (nestedKey !== 'iconUrl') {
92
- throw new Error(`Invalid appearance launcher property: ${nestedKey}`);
93
- }
94
- if (propertyValue == null) {
95
- return;
96
- }
97
- if (typeof propertyValue !== 'string') {
98
- throw new Error(`Invalid appearance ${key}.${nestedKey} value: ${propertyValue}`);
99
- }
100
- });
101
90
  });
102
- this._appearance = value;
103
- }
104
- }, {
105
- key: "number",
106
- get: function () {
107
- return this._number;
108
- },
109
- set: function (value) {
110
- if (value != null && typeof value !== 'string') {
111
- throw new Error(`Invalid number value: ${value}`);
112
- }
113
- this._number = value;
114
- }
115
- }, {
116
- key: "body",
117
- get: function () {
118
- return this._body;
119
- },
120
- set: function (value) {
121
- if (value != null && typeof value !== 'string') {
122
- throw new Error(`Invalid body value: ${value}`);
123
- }
124
- this._body = value;
91
+ });
92
+ this._appearance = value;
93
+ }
94
+ static get number() {
95
+ return this._number;
96
+ }
97
+ static set number(value) {
98
+ if (value != null && typeof value !== 'string') {
99
+ throw new Error(`Invalid number value: ${value}`);
125
100
  }
126
- }, {
127
- key: "assign",
128
- value: function assign(props) {
129
- if (props) {
130
- Object.entries(props).forEach(([key, value]) => {
131
- this[key] = value;
132
- });
133
- }
134
- return this;
101
+ this._number = value;
102
+ }
103
+ static get body() {
104
+ return this._body;
105
+ }
106
+ static set body(value) {
107
+ if (value != null && typeof value !== 'string') {
108
+ throw new Error(`Invalid body value: ${value}`);
135
109
  }
136
- }, {
137
- key: "isPlainObject",
138
- value: function isPlainObject(value) {
139
- return typeof value === 'object' && value !== null && !Array.isArray(value);
110
+ this._body = value;
111
+ }
112
+ static assign(props) {
113
+ if (props) {
114
+ Object.entries(props).forEach(([key, value]) => {
115
+ this[key] = value;
116
+ });
140
117
  }
141
- }]);
142
- return WhatsApp;
143
- }();
144
- exports.WhatsApp = WhatsApp;
145
- WhatsApp._id = void 0;
146
- WhatsApp._container = 'body';
147
- WhatsApp._placement = 'bottom-right';
148
- WhatsApp._appearance = {};
149
- WhatsApp._number = null;
150
- WhatsApp._body = null;
118
+ return this;
119
+ }
120
+ static isPlainObject(value) {
121
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
122
+ }
123
+ }
124
+ exports.WhatsApp = WhatsApp;