@xapp/chat-widget 1.55.1 → 1.56.0
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.
- package/dist/components/ActionItem/ActionItem.d.ts +0 -0
- package/dist/components/Carousel/Carousel.d.ts +0 -0
- package/dist/components/CarouselItem/CarouselItem.d.ts +0 -0
- package/dist/components/ChatMarkdownMessage/ChatMarkdownMessage.d.ts +0 -0
- package/dist/components/ChatWidget/ChatWidget.stories.d.ts +1 -0
- package/dist/components/List/List.d.ts +0 -0
- package/dist/components/ListItem/ListItem.d.ts +0 -0
- package/dist/components/MessageList/MessageList.d.ts +0 -0
- package/dist/components/OptionalLink/OptionalLink.d.ts +0 -0
- package/dist/hooks/useOpenUrlCallback.d.ts +0 -0
- package/dist/index.css +2 -2
- package/dist/index.es.js +178 -1342
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +175 -1339
- package/dist/index.js.map +1 -1
- package/dist/middlewares/message-middleware.d.ts +0 -0
- package/dist/store/ChatAction.d.ts +0 -0
- package/dist/store/ChatState.d.ts +0 -0
- package/dist/store/actions/sendVisitorInfo.d.ts +0 -0
- package/dist/store/actions/setSessionId.d.ts +0 -0
- package/dist/store/actions/setVisualStatus.d.ts +0 -0
- package/dist/utils/PersistentStorage.d.ts +0 -0
- package/dist/utils/__tests__/insertSorted.test.d.ts +1 -0
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/insertSorted.d.ts +0 -0
- package/dist/xapp/ChatServer.d.ts +0 -0
- package/dist/xapp/LogChat.d.ts +0 -0
- package/dist/xapp/StentorDirectChat.d.ts +0 -0
- package/dist/xapp/StentorRouterChat.d.ts +0 -0
- package/dist/xapp/StentorServerChat.d.ts +0 -0
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +5 -3
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -127,6 +127,7 @@ function __spreadArray$1(to, from, pack) {
|
|
|
127
127
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/*! Copyright (c) 2021, XAPPmedia */
|
|
130
131
|
function insertSorted(array, obj, comparer) {
|
|
131
132
|
if (!array.length) {
|
|
132
133
|
array.push(obj);
|
|
@@ -137,11 +138,19 @@ function insertSorted(array, obj, comparer) {
|
|
|
137
138
|
while ((rightIndex - leftIndex) > 0) {
|
|
138
139
|
var left = array[leftIndex];
|
|
139
140
|
var right = array[rightIndex];
|
|
140
|
-
|
|
141
|
+
var compLeft = comparer(obj, left);
|
|
142
|
+
if (compLeft === 0) {
|
|
143
|
+
return array; // exist
|
|
144
|
+
}
|
|
145
|
+
if (compLeft < 0) {
|
|
141
146
|
array.splice(leftIndex, 0, obj);
|
|
142
147
|
return array;
|
|
143
148
|
}
|
|
144
|
-
|
|
149
|
+
var compRight = comparer(obj, right);
|
|
150
|
+
if (compRight === 0) {
|
|
151
|
+
return array; // exist
|
|
152
|
+
}
|
|
153
|
+
if (compRight > 0) {
|
|
145
154
|
array.splice(rightIndex + 1, 0, obj);
|
|
146
155
|
return array;
|
|
147
156
|
}
|
|
@@ -178,1279 +187,6 @@ function isAgent(nick) {
|
|
|
178
187
|
return nick.startsWith("agent:");
|
|
179
188
|
}
|
|
180
189
|
|
|
181
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
182
|
-
|
|
183
|
-
var assign$1 = make_assign();
|
|
184
|
-
var create$1 = make_create();
|
|
185
|
-
var trim$1 = make_trim();
|
|
186
|
-
var Global$5 = (typeof window !== 'undefined' ? window : commonjsGlobal);
|
|
187
|
-
|
|
188
|
-
var util$6 = {
|
|
189
|
-
assign: assign$1,
|
|
190
|
-
create: create$1,
|
|
191
|
-
trim: trim$1,
|
|
192
|
-
bind: bind$1,
|
|
193
|
-
slice: slice$1,
|
|
194
|
-
each: each$7,
|
|
195
|
-
map: map$1,
|
|
196
|
-
pluck: pluck$1,
|
|
197
|
-
isList: isList$2,
|
|
198
|
-
isFunction: isFunction$1,
|
|
199
|
-
isObject: isObject$1,
|
|
200
|
-
Global: Global$5
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
function make_assign() {
|
|
204
|
-
if (Object.assign) {
|
|
205
|
-
return Object.assign
|
|
206
|
-
} else {
|
|
207
|
-
return function shimAssign(obj, props1, props2, etc) {
|
|
208
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
209
|
-
each$7(Object(arguments[i]), function(val, key) {
|
|
210
|
-
obj[key] = val;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
return obj
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function make_create() {
|
|
219
|
-
if (Object.create) {
|
|
220
|
-
return function create(obj, assignProps1, assignProps2, etc) {
|
|
221
|
-
var assignArgsList = slice$1(arguments, 1);
|
|
222
|
-
return assign$1.apply(this, [Object.create(obj)].concat(assignArgsList))
|
|
223
|
-
}
|
|
224
|
-
} else {
|
|
225
|
-
function F() {} // eslint-disable-line no-inner-declarations
|
|
226
|
-
return function create(obj, assignProps1, assignProps2, etc) {
|
|
227
|
-
var assignArgsList = slice$1(arguments, 1);
|
|
228
|
-
F.prototype = obj;
|
|
229
|
-
return assign$1.apply(this, [new F()].concat(assignArgsList))
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function make_trim() {
|
|
235
|
-
if (String.prototype.trim) {
|
|
236
|
-
return function trim(str) {
|
|
237
|
-
return String.prototype.trim.call(str)
|
|
238
|
-
}
|
|
239
|
-
} else {
|
|
240
|
-
return function trim(str) {
|
|
241
|
-
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '')
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function bind$1(obj, fn) {
|
|
247
|
-
return function() {
|
|
248
|
-
return fn.apply(obj, Array.prototype.slice.call(arguments, 0))
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function slice$1(arr, index) {
|
|
253
|
-
return Array.prototype.slice.call(arr, index || 0)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function each$7(obj, fn) {
|
|
257
|
-
pluck$1(obj, function(val, key) {
|
|
258
|
-
fn(val, key);
|
|
259
|
-
return false
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function map$1(obj, fn) {
|
|
264
|
-
var res = (isList$2(obj) ? [] : {});
|
|
265
|
-
pluck$1(obj, function(v, k) {
|
|
266
|
-
res[k] = fn(v, k);
|
|
267
|
-
return false
|
|
268
|
-
});
|
|
269
|
-
return res
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function pluck$1(obj, fn) {
|
|
273
|
-
if (isList$2(obj)) {
|
|
274
|
-
for (var i=0; i<obj.length; i++) {
|
|
275
|
-
if (fn(obj[i], i)) {
|
|
276
|
-
return obj[i]
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
for (var key in obj) {
|
|
281
|
-
if (obj.hasOwnProperty(key)) {
|
|
282
|
-
if (fn(obj[key], key)) {
|
|
283
|
-
return obj[key]
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function isList$2(val) {
|
|
291
|
-
return (val != null && typeof val != 'function' && typeof val.length == 'number')
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function isFunction$1(val) {
|
|
295
|
-
return val && {}.toString.call(val) === '[object Function]'
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function isObject$1(val) {
|
|
299
|
-
return val && {}.toString.call(val) === '[object Object]'
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
var util$5 = util$6;
|
|
303
|
-
var slice = util$5.slice;
|
|
304
|
-
var pluck = util$5.pluck;
|
|
305
|
-
var each$6 = util$5.each;
|
|
306
|
-
var bind = util$5.bind;
|
|
307
|
-
var create = util$5.create;
|
|
308
|
-
var isList$1 = util$5.isList;
|
|
309
|
-
var isFunction = util$5.isFunction;
|
|
310
|
-
var isObject = util$5.isObject;
|
|
311
|
-
|
|
312
|
-
var storeEngine = {
|
|
313
|
-
createStore: createStore
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
var storeAPI = {
|
|
317
|
-
version: '2.0.12',
|
|
318
|
-
enabled: false,
|
|
319
|
-
|
|
320
|
-
// get returns the value of the given key. If that value
|
|
321
|
-
// is undefined, it returns optionalDefaultValue instead.
|
|
322
|
-
get: function(key, optionalDefaultValue) {
|
|
323
|
-
var data = this.storage.read(this._namespacePrefix + key);
|
|
324
|
-
return this._deserialize(data, optionalDefaultValue)
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
// set will store the given value at key and returns value.
|
|
328
|
-
// Calling set with value === undefined is equivalent to calling remove.
|
|
329
|
-
set: function(key, value) {
|
|
330
|
-
if (value === undefined) {
|
|
331
|
-
return this.remove(key)
|
|
332
|
-
}
|
|
333
|
-
this.storage.write(this._namespacePrefix + key, this._serialize(value));
|
|
334
|
-
return value
|
|
335
|
-
},
|
|
336
|
-
|
|
337
|
-
// remove deletes the key and value stored at the given key.
|
|
338
|
-
remove: function(key) {
|
|
339
|
-
this.storage.remove(this._namespacePrefix + key);
|
|
340
|
-
},
|
|
341
|
-
|
|
342
|
-
// each will call the given callback once for each key-value pair
|
|
343
|
-
// in this store.
|
|
344
|
-
each: function(callback) {
|
|
345
|
-
var self = this;
|
|
346
|
-
this.storage.each(function(val, namespacedKey) {
|
|
347
|
-
callback.call(self, self._deserialize(val), (namespacedKey || '').replace(self._namespaceRegexp, ''));
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
// clearAll will remove all the stored key-value pairs in this store.
|
|
352
|
-
clearAll: function() {
|
|
353
|
-
this.storage.clearAll();
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
// additional functionality that can't live in plugins
|
|
357
|
-
// ---------------------------------------------------
|
|
358
|
-
|
|
359
|
-
// hasNamespace returns true if this store instance has the given namespace.
|
|
360
|
-
hasNamespace: function(namespace) {
|
|
361
|
-
return (this._namespacePrefix == '__storejs_'+namespace+'_')
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
// createStore creates a store.js instance with the first
|
|
365
|
-
// functioning storage in the list of storage candidates,
|
|
366
|
-
// and applies the the given mixins to the instance.
|
|
367
|
-
createStore: function() {
|
|
368
|
-
return createStore.apply(this, arguments)
|
|
369
|
-
},
|
|
370
|
-
|
|
371
|
-
addPlugin: function(plugin) {
|
|
372
|
-
this._addPlugin(plugin);
|
|
373
|
-
},
|
|
374
|
-
|
|
375
|
-
namespace: function(namespace) {
|
|
376
|
-
return createStore(this.storage, this.plugins, namespace)
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
function _warn() {
|
|
381
|
-
var _console = (typeof console == 'undefined' ? null : console);
|
|
382
|
-
if (!_console) { return }
|
|
383
|
-
var fn = (_console.warn ? _console.warn : _console.log);
|
|
384
|
-
fn.apply(_console, arguments);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function createStore(storages, plugins, namespace) {
|
|
388
|
-
if (!namespace) {
|
|
389
|
-
namespace = '';
|
|
390
|
-
}
|
|
391
|
-
if (storages && !isList$1(storages)) {
|
|
392
|
-
storages = [storages];
|
|
393
|
-
}
|
|
394
|
-
if (plugins && !isList$1(plugins)) {
|
|
395
|
-
plugins = [plugins];
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
var namespacePrefix = (namespace ? '__storejs_'+namespace+'_' : '');
|
|
399
|
-
var namespaceRegexp = (namespace ? new RegExp('^'+namespacePrefix) : null);
|
|
400
|
-
var legalNamespaces = /^[a-zA-Z0-9_\-]*$/; // alpha-numeric + underscore and dash
|
|
401
|
-
if (!legalNamespaces.test(namespace)) {
|
|
402
|
-
throw new Error('store.js namespaces can only have alphanumerics + underscores and dashes')
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
var _privateStoreProps = {
|
|
406
|
-
_namespacePrefix: namespacePrefix,
|
|
407
|
-
_namespaceRegexp: namespaceRegexp,
|
|
408
|
-
|
|
409
|
-
_testStorage: function(storage) {
|
|
410
|
-
try {
|
|
411
|
-
var testStr = '__storejs__test__';
|
|
412
|
-
storage.write(testStr, testStr);
|
|
413
|
-
var ok = (storage.read(testStr) === testStr);
|
|
414
|
-
storage.remove(testStr);
|
|
415
|
-
return ok
|
|
416
|
-
} catch(e) {
|
|
417
|
-
return false
|
|
418
|
-
}
|
|
419
|
-
},
|
|
420
|
-
|
|
421
|
-
_assignPluginFnProp: function(pluginFnProp, propName) {
|
|
422
|
-
var oldFn = this[propName];
|
|
423
|
-
this[propName] = function pluginFn() {
|
|
424
|
-
var args = slice(arguments, 0);
|
|
425
|
-
var self = this;
|
|
426
|
-
|
|
427
|
-
// super_fn calls the old function which was overwritten by
|
|
428
|
-
// this mixin.
|
|
429
|
-
function super_fn() {
|
|
430
|
-
if (!oldFn) { return }
|
|
431
|
-
each$6(arguments, function(arg, i) {
|
|
432
|
-
args[i] = arg;
|
|
433
|
-
});
|
|
434
|
-
return oldFn.apply(self, args)
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// Give mixing function access to super_fn by prefixing all mixin function
|
|
438
|
-
// arguments with super_fn.
|
|
439
|
-
var newFnArgs = [super_fn].concat(args);
|
|
440
|
-
|
|
441
|
-
return pluginFnProp.apply(self, newFnArgs)
|
|
442
|
-
};
|
|
443
|
-
},
|
|
444
|
-
|
|
445
|
-
_serialize: function(obj) {
|
|
446
|
-
return JSON.stringify(obj)
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
_deserialize: function(strVal, defaultVal) {
|
|
450
|
-
if (!strVal) { return defaultVal }
|
|
451
|
-
// It is possible that a raw string value has been previously stored
|
|
452
|
-
// in a storage without using store.js, meaning it will be a raw
|
|
453
|
-
// string value instead of a JSON serialized string. By defaulting
|
|
454
|
-
// to the raw string value in case of a JSON parse error, we allow
|
|
455
|
-
// for past stored values to be forwards-compatible with store.js
|
|
456
|
-
var val = '';
|
|
457
|
-
try { val = JSON.parse(strVal); }
|
|
458
|
-
catch(e) { val = strVal; }
|
|
459
|
-
|
|
460
|
-
return (val !== undefined ? val : defaultVal)
|
|
461
|
-
},
|
|
462
|
-
|
|
463
|
-
_addStorage: function(storage) {
|
|
464
|
-
if (this.enabled) { return }
|
|
465
|
-
if (this._testStorage(storage)) {
|
|
466
|
-
this.storage = storage;
|
|
467
|
-
this.enabled = true;
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
|
|
471
|
-
_addPlugin: function(plugin) {
|
|
472
|
-
var self = this;
|
|
473
|
-
|
|
474
|
-
// If the plugin is an array, then add all plugins in the array.
|
|
475
|
-
// This allows for a plugin to depend on other plugins.
|
|
476
|
-
if (isList$1(plugin)) {
|
|
477
|
-
each$6(plugin, function(plugin) {
|
|
478
|
-
self._addPlugin(plugin);
|
|
479
|
-
});
|
|
480
|
-
return
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Keep track of all plugins we've seen so far, so that we
|
|
484
|
-
// don't add any of them twice.
|
|
485
|
-
var seenPlugin = pluck(this.plugins, function(seenPlugin) {
|
|
486
|
-
return (plugin === seenPlugin)
|
|
487
|
-
});
|
|
488
|
-
if (seenPlugin) {
|
|
489
|
-
return
|
|
490
|
-
}
|
|
491
|
-
this.plugins.push(plugin);
|
|
492
|
-
|
|
493
|
-
// Check that the plugin is properly formed
|
|
494
|
-
if (!isFunction(plugin)) {
|
|
495
|
-
throw new Error('Plugins must be function values that return objects')
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
var pluginProperties = plugin.call(this);
|
|
499
|
-
if (!isObject(pluginProperties)) {
|
|
500
|
-
throw new Error('Plugins must return an object of function properties')
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
// Add the plugin function properties to this store instance.
|
|
504
|
-
each$6(pluginProperties, function(pluginFnProp, propName) {
|
|
505
|
-
if (!isFunction(pluginFnProp)) {
|
|
506
|
-
throw new Error('Bad plugin property: '+propName+' from plugin '+plugin.name+'. Plugins should only return functions.')
|
|
507
|
-
}
|
|
508
|
-
self._assignPluginFnProp(pluginFnProp, propName);
|
|
509
|
-
});
|
|
510
|
-
},
|
|
511
|
-
|
|
512
|
-
// Put deprecated properties in the private API, so as to not expose it to accidential
|
|
513
|
-
// discovery through inspection of the store object.
|
|
514
|
-
|
|
515
|
-
// Deprecated: addStorage
|
|
516
|
-
addStorage: function(storage) {
|
|
517
|
-
_warn('store.addStorage(storage) is deprecated. Use createStore([storages])');
|
|
518
|
-
this._addStorage(storage);
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
var store = create(_privateStoreProps, storeAPI, {
|
|
523
|
-
plugins: []
|
|
524
|
-
});
|
|
525
|
-
store.raw = {};
|
|
526
|
-
each$6(store, function(prop, propName) {
|
|
527
|
-
if (isFunction(prop)) {
|
|
528
|
-
store.raw[propName] = bind(store, prop);
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
each$6(storages, function(storage) {
|
|
532
|
-
store._addStorage(storage);
|
|
533
|
-
});
|
|
534
|
-
each$6(plugins, function(plugin) {
|
|
535
|
-
store._addPlugin(plugin);
|
|
536
|
-
});
|
|
537
|
-
return store
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
var util$4 = util$6;
|
|
541
|
-
var Global$4 = util$4.Global;
|
|
542
|
-
|
|
543
|
-
var localStorage_1 = {
|
|
544
|
-
name: 'localStorage',
|
|
545
|
-
read: read$5,
|
|
546
|
-
write: write$5,
|
|
547
|
-
each: each$5,
|
|
548
|
-
remove: remove$5,
|
|
549
|
-
clearAll: clearAll$5,
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
function localStorage$1() {
|
|
553
|
-
return Global$4.localStorage
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
function read$5(key) {
|
|
557
|
-
return localStorage$1().getItem(key)
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
function write$5(key, data) {
|
|
561
|
-
return localStorage$1().setItem(key, data)
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
function each$5(fn) {
|
|
565
|
-
for (var i = localStorage$1().length - 1; i >= 0; i--) {
|
|
566
|
-
var key = localStorage$1().key(i);
|
|
567
|
-
fn(read$5(key), key);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
function remove$5(key) {
|
|
572
|
-
return localStorage$1().removeItem(key)
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
function clearAll$5() {
|
|
576
|
-
return localStorage$1().clear()
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// oldFF-globalStorage provides storage for Firefox
|
|
580
|
-
// versions 6 and 7, where no localStorage, etc
|
|
581
|
-
// is available.
|
|
582
|
-
|
|
583
|
-
var util$3 = util$6;
|
|
584
|
-
var Global$3 = util$3.Global;
|
|
585
|
-
|
|
586
|
-
var oldFFGlobalStorage = {
|
|
587
|
-
name: 'oldFF-globalStorage',
|
|
588
|
-
read: read$4,
|
|
589
|
-
write: write$4,
|
|
590
|
-
each: each$4,
|
|
591
|
-
remove: remove$4,
|
|
592
|
-
clearAll: clearAll$4,
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
var globalStorage = Global$3.globalStorage;
|
|
596
|
-
|
|
597
|
-
function read$4(key) {
|
|
598
|
-
return globalStorage[key]
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function write$4(key, data) {
|
|
602
|
-
globalStorage[key] = data;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
function each$4(fn) {
|
|
606
|
-
for (var i = globalStorage.length - 1; i >= 0; i--) {
|
|
607
|
-
var key = globalStorage.key(i);
|
|
608
|
-
fn(globalStorage[key], key);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
function remove$4(key) {
|
|
613
|
-
return globalStorage.removeItem(key)
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
function clearAll$4() {
|
|
617
|
-
each$4(function(key, _) {
|
|
618
|
-
delete globalStorage[key];
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// oldIE-userDataStorage provides storage for Internet Explorer
|
|
623
|
-
// versions 6 and 7, where no localStorage, sessionStorage, etc
|
|
624
|
-
// is available.
|
|
625
|
-
|
|
626
|
-
var util$2 = util$6;
|
|
627
|
-
var Global$2 = util$2.Global;
|
|
628
|
-
|
|
629
|
-
var oldIEUserDataStorage = {
|
|
630
|
-
name: 'oldIE-userDataStorage',
|
|
631
|
-
write: write$3,
|
|
632
|
-
read: read$3,
|
|
633
|
-
each: each$3,
|
|
634
|
-
remove: remove$3,
|
|
635
|
-
clearAll: clearAll$3,
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
var storageName = 'storejs';
|
|
639
|
-
var doc$1 = Global$2.document;
|
|
640
|
-
var _withStorageEl = _makeIEStorageElFunction();
|
|
641
|
-
var disable = (Global$2.navigator ? Global$2.navigator.userAgent : '').match(/ (MSIE 8|MSIE 9|MSIE 10)\./); // MSIE 9.x, MSIE 10.x
|
|
642
|
-
|
|
643
|
-
function write$3(unfixedKey, data) {
|
|
644
|
-
if (disable) { return }
|
|
645
|
-
var fixedKey = fixKey(unfixedKey);
|
|
646
|
-
_withStorageEl(function(storageEl) {
|
|
647
|
-
storageEl.setAttribute(fixedKey, data);
|
|
648
|
-
storageEl.save(storageName);
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
function read$3(unfixedKey) {
|
|
653
|
-
if (disable) { return }
|
|
654
|
-
var fixedKey = fixKey(unfixedKey);
|
|
655
|
-
var res = null;
|
|
656
|
-
_withStorageEl(function(storageEl) {
|
|
657
|
-
res = storageEl.getAttribute(fixedKey);
|
|
658
|
-
});
|
|
659
|
-
return res
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
function each$3(callback) {
|
|
663
|
-
_withStorageEl(function(storageEl) {
|
|
664
|
-
var attributes = storageEl.XMLDocument.documentElement.attributes;
|
|
665
|
-
for (var i=attributes.length-1; i>=0; i--) {
|
|
666
|
-
var attr = attributes[i];
|
|
667
|
-
callback(storageEl.getAttribute(attr.name), attr.name);
|
|
668
|
-
}
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
function remove$3(unfixedKey) {
|
|
673
|
-
var fixedKey = fixKey(unfixedKey);
|
|
674
|
-
_withStorageEl(function(storageEl) {
|
|
675
|
-
storageEl.removeAttribute(fixedKey);
|
|
676
|
-
storageEl.save(storageName);
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
function clearAll$3() {
|
|
681
|
-
_withStorageEl(function(storageEl) {
|
|
682
|
-
var attributes = storageEl.XMLDocument.documentElement.attributes;
|
|
683
|
-
storageEl.load(storageName);
|
|
684
|
-
for (var i=attributes.length-1; i>=0; i--) {
|
|
685
|
-
storageEl.removeAttribute(attributes[i].name);
|
|
686
|
-
}
|
|
687
|
-
storageEl.save(storageName);
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
// Helpers
|
|
692
|
-
//////////
|
|
693
|
-
|
|
694
|
-
// In IE7, keys cannot start with a digit or contain certain chars.
|
|
695
|
-
// See https://github.com/marcuswestin/store.js/issues/40
|
|
696
|
-
// See https://github.com/marcuswestin/store.js/issues/83
|
|
697
|
-
var forbiddenCharsRegex = new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]", "g");
|
|
698
|
-
function fixKey(key) {
|
|
699
|
-
return key.replace(/^\d/, '___$&').replace(forbiddenCharsRegex, '___')
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
function _makeIEStorageElFunction() {
|
|
703
|
-
if (!doc$1 || !doc$1.documentElement || !doc$1.documentElement.addBehavior) {
|
|
704
|
-
return null
|
|
705
|
-
}
|
|
706
|
-
var scriptTag = 'script',
|
|
707
|
-
storageOwner,
|
|
708
|
-
storageContainer,
|
|
709
|
-
storageEl;
|
|
710
|
-
|
|
711
|
-
// Since #userData storage applies only to specific paths, we need to
|
|
712
|
-
// somehow link our data to a specific path. We choose /favicon.ico
|
|
713
|
-
// as a pretty safe option, since all browsers already make a request to
|
|
714
|
-
// this URL anyway and being a 404 will not hurt us here. We wrap an
|
|
715
|
-
// iframe pointing to the favicon in an ActiveXObject(htmlfile) object
|
|
716
|
-
// (see: http://msdn.microsoft.com/en-us/library/aa752574(v=VS.85).aspx)
|
|
717
|
-
// since the iframe access rules appear to allow direct access and
|
|
718
|
-
// manipulation of the document element, even for a 404 page. This
|
|
719
|
-
// document can be used instead of the current document (which would
|
|
720
|
-
// have been limited to the current path) to perform #userData storage.
|
|
721
|
-
try {
|
|
722
|
-
/* global ActiveXObject */
|
|
723
|
-
storageContainer = new ActiveXObject('htmlfile');
|
|
724
|
-
storageContainer.open();
|
|
725
|
-
storageContainer.write('<'+scriptTag+'>document.w=window</'+scriptTag+'><iframe src="/favicon.ico"></iframe>');
|
|
726
|
-
storageContainer.close();
|
|
727
|
-
storageOwner = storageContainer.w.frames[0].document;
|
|
728
|
-
storageEl = storageOwner.createElement('div');
|
|
729
|
-
} catch(e) {
|
|
730
|
-
// somehow ActiveXObject instantiation failed (perhaps some special
|
|
731
|
-
// security settings or otherwse), fall back to per-path storage
|
|
732
|
-
storageEl = doc$1.createElement('div');
|
|
733
|
-
storageOwner = doc$1.body;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
return function(storeFunction) {
|
|
737
|
-
var args = [].slice.call(arguments, 0);
|
|
738
|
-
args.unshift(storageEl);
|
|
739
|
-
// See http://msdn.microsoft.com/en-us/library/ms531081(v=VS.85).aspx
|
|
740
|
-
// and http://msdn.microsoft.com/en-us/library/ms531424(v=VS.85).aspx
|
|
741
|
-
storageOwner.appendChild(storageEl);
|
|
742
|
-
storageEl.addBehavior('#default#userData');
|
|
743
|
-
storageEl.load(storageName);
|
|
744
|
-
storeFunction.apply(this, args);
|
|
745
|
-
storageOwner.removeChild(storageEl);
|
|
746
|
-
return
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// cookieStorage is useful Safari private browser mode, where localStorage
|
|
751
|
-
// doesn't work but cookies do. This implementation is adopted from
|
|
752
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage
|
|
753
|
-
|
|
754
|
-
var util$1 = util$6;
|
|
755
|
-
var Global$1 = util$1.Global;
|
|
756
|
-
var trim = util$1.trim;
|
|
757
|
-
|
|
758
|
-
var cookieStorage = {
|
|
759
|
-
name: 'cookieStorage',
|
|
760
|
-
read: read$2,
|
|
761
|
-
write: write$2,
|
|
762
|
-
each: each$2,
|
|
763
|
-
remove: remove$2,
|
|
764
|
-
clearAll: clearAll$2,
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
var doc = Global$1.document;
|
|
768
|
-
|
|
769
|
-
function read$2(key) {
|
|
770
|
-
if (!key || !_has(key)) { return null }
|
|
771
|
-
var regexpStr = "(?:^|.*;\\s*)" +
|
|
772
|
-
escape(key).replace(/[\-\.\+\*]/g, "\\$&") +
|
|
773
|
-
"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";
|
|
774
|
-
return unescape(doc.cookie.replace(new RegExp(regexpStr), "$1"))
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
function each$2(callback) {
|
|
778
|
-
var cookies = doc.cookie.split(/; ?/g);
|
|
779
|
-
for (var i = cookies.length - 1; i >= 0; i--) {
|
|
780
|
-
if (!trim(cookies[i])) {
|
|
781
|
-
continue
|
|
782
|
-
}
|
|
783
|
-
var kvp = cookies[i].split('=');
|
|
784
|
-
var key = unescape(kvp[0]);
|
|
785
|
-
var val = unescape(kvp[1]);
|
|
786
|
-
callback(val, key);
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
function write$2(key, data) {
|
|
791
|
-
if(!key) { return }
|
|
792
|
-
doc.cookie = escape(key) + "=" + escape(data) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
function remove$2(key) {
|
|
796
|
-
if (!key || !_has(key)) {
|
|
797
|
-
return
|
|
798
|
-
}
|
|
799
|
-
doc.cookie = escape(key) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
function clearAll$2() {
|
|
803
|
-
each$2(function(_, key) {
|
|
804
|
-
remove$2(key);
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
function _has(key) {
|
|
809
|
-
return (new RegExp("(?:^|;\\s*)" + escape(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(doc.cookie)
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
var util = util$6;
|
|
813
|
-
var Global = util.Global;
|
|
814
|
-
|
|
815
|
-
var sessionStorage_1 = {
|
|
816
|
-
name: 'sessionStorage',
|
|
817
|
-
read: read$1,
|
|
818
|
-
write: write$1,
|
|
819
|
-
each: each$1,
|
|
820
|
-
remove: remove$1,
|
|
821
|
-
clearAll: clearAll$1
|
|
822
|
-
};
|
|
823
|
-
|
|
824
|
-
function sessionStorage() {
|
|
825
|
-
return Global.sessionStorage
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
function read$1(key) {
|
|
829
|
-
return sessionStorage().getItem(key)
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
function write$1(key, data) {
|
|
833
|
-
return sessionStorage().setItem(key, data)
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
function each$1(fn) {
|
|
837
|
-
for (var i = sessionStorage().length - 1; i >= 0; i--) {
|
|
838
|
-
var key = sessionStorage().key(i);
|
|
839
|
-
fn(read$1(key), key);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
function remove$1(key) {
|
|
844
|
-
return sessionStorage().removeItem(key)
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
function clearAll$1() {
|
|
848
|
-
return sessionStorage().clear()
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
// memoryStorage is a useful last fallback to ensure that the store
|
|
852
|
-
// is functions (meaning store.get(), store.set(), etc will all function).
|
|
853
|
-
// However, stored values will not persist when the browser navigates to
|
|
854
|
-
// a new page or reloads the current page.
|
|
855
|
-
|
|
856
|
-
var memoryStorage_1 = {
|
|
857
|
-
name: 'memoryStorage',
|
|
858
|
-
read: read,
|
|
859
|
-
write: write,
|
|
860
|
-
each: each,
|
|
861
|
-
remove: remove,
|
|
862
|
-
clearAll: clearAll,
|
|
863
|
-
};
|
|
864
|
-
|
|
865
|
-
var memoryStorage = {};
|
|
866
|
-
|
|
867
|
-
function read(key) {
|
|
868
|
-
return memoryStorage[key]
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
function write(key, data) {
|
|
872
|
-
memoryStorage[key] = data;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
function each(callback) {
|
|
876
|
-
for (var key in memoryStorage) {
|
|
877
|
-
if (memoryStorage.hasOwnProperty(key)) {
|
|
878
|
-
callback(memoryStorage[key], key);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
function remove(key) {
|
|
884
|
-
delete memoryStorage[key];
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
function clearAll(key) {
|
|
888
|
-
memoryStorage = {};
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
var all = [
|
|
892
|
-
// Listed in order of usage preference
|
|
893
|
-
localStorage_1,
|
|
894
|
-
oldFFGlobalStorage,
|
|
895
|
-
oldIEUserDataStorage,
|
|
896
|
-
cookieStorage,
|
|
897
|
-
sessionStorage_1,
|
|
898
|
-
memoryStorage_1
|
|
899
|
-
];
|
|
900
|
-
|
|
901
|
-
var json2$1 = {};
|
|
902
|
-
|
|
903
|
-
/* eslint-disable */
|
|
904
|
-
|
|
905
|
-
var hasRequiredJson2;
|
|
906
|
-
|
|
907
|
-
function requireJson2 () {
|
|
908
|
-
if (hasRequiredJson2) return json2$1;
|
|
909
|
-
hasRequiredJson2 = 1;
|
|
910
|
-
// json2.js
|
|
911
|
-
// 2016-10-28
|
|
912
|
-
// Public Domain.
|
|
913
|
-
// NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
|
914
|
-
// See http://www.JSON.org/js.html
|
|
915
|
-
// This code should be minified before deployment.
|
|
916
|
-
// See http://javascript.crockford.com/jsmin.html
|
|
917
|
-
|
|
918
|
-
// USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
|
919
|
-
// NOT CONTROL.
|
|
920
|
-
|
|
921
|
-
// This file creates a global JSON object containing two methods: stringify
|
|
922
|
-
// and parse. This file provides the ES5 JSON capability to ES3 systems.
|
|
923
|
-
// If a project might run on IE8 or earlier, then this file should be included.
|
|
924
|
-
// This file does nothing on ES5 systems.
|
|
925
|
-
|
|
926
|
-
// JSON.stringify(value, replacer, space)
|
|
927
|
-
// value any JavaScript value, usually an object or array.
|
|
928
|
-
// replacer an optional parameter that determines how object
|
|
929
|
-
// values are stringified for objects. It can be a
|
|
930
|
-
// function or an array of strings.
|
|
931
|
-
// space an optional parameter that specifies the indentation
|
|
932
|
-
// of nested structures. If it is omitted, the text will
|
|
933
|
-
// be packed without extra whitespace. If it is a number,
|
|
934
|
-
// it will specify the number of spaces to indent at each
|
|
935
|
-
// level. If it is a string (such as "\t" or " "),
|
|
936
|
-
// it contains the characters used to indent at each level.
|
|
937
|
-
// This method produces a JSON text from a JavaScript value.
|
|
938
|
-
// When an object value is found, if the object contains a toJSON
|
|
939
|
-
// method, its toJSON method will be called and the result will be
|
|
940
|
-
// stringified. A toJSON method does not serialize: it returns the
|
|
941
|
-
// value represented by the name/value pair that should be serialized,
|
|
942
|
-
// or undefined if nothing should be serialized. The toJSON method
|
|
943
|
-
// will be passed the key associated with the value, and this will be
|
|
944
|
-
// bound to the value.
|
|
945
|
-
|
|
946
|
-
// For example, this would serialize Dates as ISO strings.
|
|
947
|
-
|
|
948
|
-
// Date.prototype.toJSON = function (key) {
|
|
949
|
-
// function f(n) {
|
|
950
|
-
// // Format integers to have at least two digits.
|
|
951
|
-
// return (n < 10)
|
|
952
|
-
// ? "0" + n
|
|
953
|
-
// : n;
|
|
954
|
-
// }
|
|
955
|
-
// return this.getUTCFullYear() + "-" +
|
|
956
|
-
// f(this.getUTCMonth() + 1) + "-" +
|
|
957
|
-
// f(this.getUTCDate()) + "T" +
|
|
958
|
-
// f(this.getUTCHours()) + ":" +
|
|
959
|
-
// f(this.getUTCMinutes()) + ":" +
|
|
960
|
-
// f(this.getUTCSeconds()) + "Z";
|
|
961
|
-
// };
|
|
962
|
-
|
|
963
|
-
// You can provide an optional replacer method. It will be passed the
|
|
964
|
-
// key and value of each member, with this bound to the containing
|
|
965
|
-
// object. The value that is returned from your method will be
|
|
966
|
-
// serialized. If your method returns undefined, then the member will
|
|
967
|
-
// be excluded from the serialization.
|
|
968
|
-
|
|
969
|
-
// If the replacer parameter is an array of strings, then it will be
|
|
970
|
-
// used to select the members to be serialized. It filters the results
|
|
971
|
-
// such that only members with keys listed in the replacer array are
|
|
972
|
-
// stringified.
|
|
973
|
-
|
|
974
|
-
// Values that do not have JSON representations, such as undefined or
|
|
975
|
-
// functions, will not be serialized. Such values in objects will be
|
|
976
|
-
// dropped; in arrays they will be replaced with null. You can use
|
|
977
|
-
// a replacer function to replace those with JSON values.
|
|
978
|
-
|
|
979
|
-
// JSON.stringify(undefined) returns undefined.
|
|
980
|
-
|
|
981
|
-
// The optional space parameter produces a stringification of the
|
|
982
|
-
// value that is filled with line breaks and indentation to make it
|
|
983
|
-
// easier to read.
|
|
984
|
-
|
|
985
|
-
// If the space parameter is a non-empty string, then that string will
|
|
986
|
-
// be used for indentation. If the space parameter is a number, then
|
|
987
|
-
// the indentation will be that many spaces.
|
|
988
|
-
|
|
989
|
-
// Example:
|
|
990
|
-
|
|
991
|
-
// text = JSON.stringify(["e", {pluribus: "unum"}]);
|
|
992
|
-
// // text is '["e",{"pluribus":"unum"}]'
|
|
993
|
-
|
|
994
|
-
// text = JSON.stringify(["e", {pluribus: "unum"}], null, "\t");
|
|
995
|
-
// // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
|
996
|
-
|
|
997
|
-
// text = JSON.stringify([new Date()], function (key, value) {
|
|
998
|
-
// return this[key] instanceof Date
|
|
999
|
-
// ? "Date(" + this[key] + ")"
|
|
1000
|
-
// : value;
|
|
1001
|
-
// });
|
|
1002
|
-
// // text is '["Date(---current time---)"]'
|
|
1003
|
-
|
|
1004
|
-
// JSON.parse(text, reviver)
|
|
1005
|
-
// This method parses a JSON text to produce an object or array.
|
|
1006
|
-
// It can throw a SyntaxError exception.
|
|
1007
|
-
|
|
1008
|
-
// The optional reviver parameter is a function that can filter and
|
|
1009
|
-
// transform the results. It receives each of the keys and values,
|
|
1010
|
-
// and its return value is used instead of the original value.
|
|
1011
|
-
// If it returns what it received, then the structure is not modified.
|
|
1012
|
-
// If it returns undefined then the member is deleted.
|
|
1013
|
-
|
|
1014
|
-
// Example:
|
|
1015
|
-
|
|
1016
|
-
// // Parse the text. Values that look like ISO date strings will
|
|
1017
|
-
// // be converted to Date objects.
|
|
1018
|
-
|
|
1019
|
-
// myData = JSON.parse(text, function (key, value) {
|
|
1020
|
-
// var a;
|
|
1021
|
-
// if (typeof value === "string") {
|
|
1022
|
-
// a =
|
|
1023
|
-
// /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
|
1024
|
-
// if (a) {
|
|
1025
|
-
// return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
|
1026
|
-
// +a[5], +a[6]));
|
|
1027
|
-
// }
|
|
1028
|
-
// }
|
|
1029
|
-
// return value;
|
|
1030
|
-
// });
|
|
1031
|
-
|
|
1032
|
-
// myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
|
1033
|
-
// var d;
|
|
1034
|
-
// if (typeof value === "string" &&
|
|
1035
|
-
// value.slice(0, 5) === "Date(" &&
|
|
1036
|
-
// value.slice(-1) === ")") {
|
|
1037
|
-
// d = new Date(value.slice(5, -1));
|
|
1038
|
-
// if (d) {
|
|
1039
|
-
// return d;
|
|
1040
|
-
// }
|
|
1041
|
-
// }
|
|
1042
|
-
// return value;
|
|
1043
|
-
// });
|
|
1044
|
-
|
|
1045
|
-
// This is a reference implementation. You are free to copy, modify, or
|
|
1046
|
-
// redistribute.
|
|
1047
|
-
|
|
1048
|
-
/*jslint
|
|
1049
|
-
eval, for, this
|
|
1050
|
-
*/
|
|
1051
|
-
|
|
1052
|
-
/*property
|
|
1053
|
-
JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
|
1054
|
-
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
|
1055
|
-
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
|
1056
|
-
test, toJSON, toString, valueOf
|
|
1057
|
-
*/
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
// Create a JSON object only if one does not already exist. We create the
|
|
1061
|
-
// methods in a closure to avoid creating global variables.
|
|
1062
|
-
|
|
1063
|
-
if (typeof JSON !== "object") {
|
|
1064
|
-
JSON = {};
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
(function () {
|
|
1068
|
-
|
|
1069
|
-
var rx_one = /^[\],:{}\s]*$/;
|
|
1070
|
-
var rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;
|
|
1071
|
-
var rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
|
|
1072
|
-
var rx_four = /(?:^|:|,)(?:\s*\[)+/g;
|
|
1073
|
-
var rx_escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
|
1074
|
-
var rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
|
1075
|
-
|
|
1076
|
-
function f(n) {
|
|
1077
|
-
// Format integers to have at least two digits.
|
|
1078
|
-
return n < 10
|
|
1079
|
-
? "0" + n
|
|
1080
|
-
: n;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
function this_value() {
|
|
1084
|
-
return this.valueOf();
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
if (typeof Date.prototype.toJSON !== "function") {
|
|
1088
|
-
|
|
1089
|
-
Date.prototype.toJSON = function () {
|
|
1090
|
-
|
|
1091
|
-
return isFinite(this.valueOf())
|
|
1092
|
-
? this.getUTCFullYear() + "-" +
|
|
1093
|
-
f(this.getUTCMonth() + 1) + "-" +
|
|
1094
|
-
f(this.getUTCDate()) + "T" +
|
|
1095
|
-
f(this.getUTCHours()) + ":" +
|
|
1096
|
-
f(this.getUTCMinutes()) + ":" +
|
|
1097
|
-
f(this.getUTCSeconds()) + "Z"
|
|
1098
|
-
: null;
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
Boolean.prototype.toJSON = this_value;
|
|
1102
|
-
Number.prototype.toJSON = this_value;
|
|
1103
|
-
String.prototype.toJSON = this_value;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
var gap;
|
|
1107
|
-
var indent;
|
|
1108
|
-
var meta;
|
|
1109
|
-
var rep;
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
function quote(string) {
|
|
1113
|
-
|
|
1114
|
-
// If the string contains no control characters, no quote characters, and no
|
|
1115
|
-
// backslash characters, then we can safely slap some quotes around it.
|
|
1116
|
-
// Otherwise we must also replace the offending characters with safe escape
|
|
1117
|
-
// sequences.
|
|
1118
|
-
|
|
1119
|
-
rx_escapable.lastIndex = 0;
|
|
1120
|
-
return rx_escapable.test(string)
|
|
1121
|
-
? "\"" + string.replace(rx_escapable, function (a) {
|
|
1122
|
-
var c = meta[a];
|
|
1123
|
-
return typeof c === "string"
|
|
1124
|
-
? c
|
|
1125
|
-
: "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
|
|
1126
|
-
}) + "\""
|
|
1127
|
-
: "\"" + string + "\"";
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
function str(key, holder) {
|
|
1132
|
-
|
|
1133
|
-
// Produce a string from holder[key].
|
|
1134
|
-
|
|
1135
|
-
var i; // The loop counter.
|
|
1136
|
-
var k; // The member key.
|
|
1137
|
-
var v; // The member value.
|
|
1138
|
-
var length;
|
|
1139
|
-
var mind = gap;
|
|
1140
|
-
var partial;
|
|
1141
|
-
var value = holder[key];
|
|
1142
|
-
|
|
1143
|
-
// If the value has a toJSON method, call it to obtain a replacement value.
|
|
1144
|
-
|
|
1145
|
-
if (value && typeof value === "object" &&
|
|
1146
|
-
typeof value.toJSON === "function") {
|
|
1147
|
-
value = value.toJSON(key);
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
// If we were called with a replacer function, then call the replacer to
|
|
1151
|
-
// obtain a replacement value.
|
|
1152
|
-
|
|
1153
|
-
if (typeof rep === "function") {
|
|
1154
|
-
value = rep.call(holder, key, value);
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// What happens next depends on the value's type.
|
|
1158
|
-
|
|
1159
|
-
switch (typeof value) {
|
|
1160
|
-
case "string":
|
|
1161
|
-
return quote(value);
|
|
1162
|
-
|
|
1163
|
-
case "number":
|
|
1164
|
-
|
|
1165
|
-
// JSON numbers must be finite. Encode non-finite numbers as null.
|
|
1166
|
-
|
|
1167
|
-
return isFinite(value)
|
|
1168
|
-
? String(value)
|
|
1169
|
-
: "null";
|
|
1170
|
-
|
|
1171
|
-
case "boolean":
|
|
1172
|
-
case "null":
|
|
1173
|
-
|
|
1174
|
-
// If the value is a boolean or null, convert it to a string. Note:
|
|
1175
|
-
// typeof null does not produce "null". The case is included here in
|
|
1176
|
-
// the remote chance that this gets fixed someday.
|
|
1177
|
-
|
|
1178
|
-
return String(value);
|
|
1179
|
-
|
|
1180
|
-
// If the type is "object", we might be dealing with an object or an array or
|
|
1181
|
-
// null.
|
|
1182
|
-
|
|
1183
|
-
case "object":
|
|
1184
|
-
|
|
1185
|
-
// Due to a specification blunder in ECMAScript, typeof null is "object",
|
|
1186
|
-
// so watch out for that case.
|
|
1187
|
-
|
|
1188
|
-
if (!value) {
|
|
1189
|
-
return "null";
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
// Make an array to hold the partial results of stringifying this object value.
|
|
1193
|
-
|
|
1194
|
-
gap += indent;
|
|
1195
|
-
partial = [];
|
|
1196
|
-
|
|
1197
|
-
// Is the value an array?
|
|
1198
|
-
|
|
1199
|
-
if (Object.prototype.toString.apply(value) === "[object Array]") {
|
|
1200
|
-
|
|
1201
|
-
// The value is an array. Stringify every element. Use null as a placeholder
|
|
1202
|
-
// for non-JSON values.
|
|
1203
|
-
|
|
1204
|
-
length = value.length;
|
|
1205
|
-
for (i = 0; i < length; i += 1) {
|
|
1206
|
-
partial[i] = str(i, value) || "null";
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
// Join all of the elements together, separated with commas, and wrap them in
|
|
1210
|
-
// brackets.
|
|
1211
|
-
|
|
1212
|
-
v = partial.length === 0
|
|
1213
|
-
? "[]"
|
|
1214
|
-
: gap
|
|
1215
|
-
? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]"
|
|
1216
|
-
: "[" + partial.join(",") + "]";
|
|
1217
|
-
gap = mind;
|
|
1218
|
-
return v;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
// If the replacer is an array, use it to select the members to be stringified.
|
|
1222
|
-
|
|
1223
|
-
if (rep && typeof rep === "object") {
|
|
1224
|
-
length = rep.length;
|
|
1225
|
-
for (i = 0; i < length; i += 1) {
|
|
1226
|
-
if (typeof rep[i] === "string") {
|
|
1227
|
-
k = rep[i];
|
|
1228
|
-
v = str(k, value);
|
|
1229
|
-
if (v) {
|
|
1230
|
-
partial.push(quote(k) + (
|
|
1231
|
-
gap
|
|
1232
|
-
? ": "
|
|
1233
|
-
: ":"
|
|
1234
|
-
) + v);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
} else {
|
|
1239
|
-
|
|
1240
|
-
// Otherwise, iterate through all of the keys in the object.
|
|
1241
|
-
|
|
1242
|
-
for (k in value) {
|
|
1243
|
-
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
|
1244
|
-
v = str(k, value);
|
|
1245
|
-
if (v) {
|
|
1246
|
-
partial.push(quote(k) + (
|
|
1247
|
-
gap
|
|
1248
|
-
? ": "
|
|
1249
|
-
: ":"
|
|
1250
|
-
) + v);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
// Join all of the member texts together, separated with commas,
|
|
1257
|
-
// and wrap them in braces.
|
|
1258
|
-
|
|
1259
|
-
v = partial.length === 0
|
|
1260
|
-
? "{}"
|
|
1261
|
-
: gap
|
|
1262
|
-
? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}"
|
|
1263
|
-
: "{" + partial.join(",") + "}";
|
|
1264
|
-
gap = mind;
|
|
1265
|
-
return v;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
// If the JSON object does not yet have a stringify method, give it one.
|
|
1270
|
-
|
|
1271
|
-
if (typeof JSON.stringify !== "function") {
|
|
1272
|
-
meta = { // table of character substitutions
|
|
1273
|
-
"\b": "\\b",
|
|
1274
|
-
"\t": "\\t",
|
|
1275
|
-
"\n": "\\n",
|
|
1276
|
-
"\f": "\\f",
|
|
1277
|
-
"\r": "\\r",
|
|
1278
|
-
"\"": "\\\"",
|
|
1279
|
-
"\\": "\\\\"
|
|
1280
|
-
};
|
|
1281
|
-
JSON.stringify = function (value, replacer, space) {
|
|
1282
|
-
|
|
1283
|
-
// The stringify method takes a value and an optional replacer, and an optional
|
|
1284
|
-
// space parameter, and returns a JSON text. The replacer can be a function
|
|
1285
|
-
// that can replace values, or an array of strings that will select the keys.
|
|
1286
|
-
// A default replacer method can be provided. Use of the space parameter can
|
|
1287
|
-
// produce text that is more easily readable.
|
|
1288
|
-
|
|
1289
|
-
var i;
|
|
1290
|
-
gap = "";
|
|
1291
|
-
indent = "";
|
|
1292
|
-
|
|
1293
|
-
// If the space parameter is a number, make an indent string containing that
|
|
1294
|
-
// many spaces.
|
|
1295
|
-
|
|
1296
|
-
if (typeof space === "number") {
|
|
1297
|
-
for (i = 0; i < space; i += 1) {
|
|
1298
|
-
indent += " ";
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
// If the space parameter is a string, it will be used as the indent string.
|
|
1302
|
-
|
|
1303
|
-
} else if (typeof space === "string") {
|
|
1304
|
-
indent = space;
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
// If there is a replacer, it must be a function or an array.
|
|
1308
|
-
// Otherwise, throw an error.
|
|
1309
|
-
|
|
1310
|
-
rep = replacer;
|
|
1311
|
-
if (replacer && typeof replacer !== "function" &&
|
|
1312
|
-
(typeof replacer !== "object" ||
|
|
1313
|
-
typeof replacer.length !== "number")) {
|
|
1314
|
-
throw new Error("JSON.stringify");
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
// Make a fake root object containing our value under the key of "".
|
|
1318
|
-
// Return the result of stringifying the value.
|
|
1319
|
-
|
|
1320
|
-
return str("", {"": value});
|
|
1321
|
-
};
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
// If the JSON object does not yet have a parse method, give it one.
|
|
1326
|
-
|
|
1327
|
-
if (typeof JSON.parse !== "function") {
|
|
1328
|
-
JSON.parse = function (text, reviver) {
|
|
1329
|
-
|
|
1330
|
-
// The parse method takes a text and an optional reviver function, and returns
|
|
1331
|
-
// a JavaScript value if the text is a valid JSON text.
|
|
1332
|
-
|
|
1333
|
-
var j;
|
|
1334
|
-
|
|
1335
|
-
function walk(holder, key) {
|
|
1336
|
-
|
|
1337
|
-
// The walk method is used to recursively walk the resulting structure so
|
|
1338
|
-
// that modifications can be made.
|
|
1339
|
-
|
|
1340
|
-
var k;
|
|
1341
|
-
var v;
|
|
1342
|
-
var value = holder[key];
|
|
1343
|
-
if (value && typeof value === "object") {
|
|
1344
|
-
for (k in value) {
|
|
1345
|
-
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
|
1346
|
-
v = walk(value, k);
|
|
1347
|
-
if (v !== undefined) {
|
|
1348
|
-
value[k] = v;
|
|
1349
|
-
} else {
|
|
1350
|
-
delete value[k];
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
return reviver.call(holder, key, value);
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
// Parsing happens in four stages. In the first stage, we replace certain
|
|
1360
|
-
// Unicode characters with escape sequences. JavaScript handles many characters
|
|
1361
|
-
// incorrectly, either silently deleting them, or treating them as line endings.
|
|
1362
|
-
|
|
1363
|
-
text = String(text);
|
|
1364
|
-
rx_dangerous.lastIndex = 0;
|
|
1365
|
-
if (rx_dangerous.test(text)) {
|
|
1366
|
-
text = text.replace(rx_dangerous, function (a) {
|
|
1367
|
-
return "\\u" +
|
|
1368
|
-
("0000" + a.charCodeAt(0).toString(16)).slice(-4);
|
|
1369
|
-
});
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// In the second stage, we run the text against regular expressions that look
|
|
1373
|
-
// for non-JSON patterns. We are especially concerned with "()" and "new"
|
|
1374
|
-
// because they can cause invocation, and "=" because it can cause mutation.
|
|
1375
|
-
// But just to be safe, we want to reject all unexpected forms.
|
|
1376
|
-
|
|
1377
|
-
// We split the second stage into 4 regexp operations in order to work around
|
|
1378
|
-
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
|
1379
|
-
// replace the JSON backslash pairs with "@" (a non-JSON character). Second, we
|
|
1380
|
-
// replace all simple value tokens with "]" characters. Third, we delete all
|
|
1381
|
-
// open brackets that follow a colon or comma or that begin the text. Finally,
|
|
1382
|
-
// we look to see that the remaining characters are only whitespace or "]" or
|
|
1383
|
-
// "," or ":" or "{" or "}". If that is so, then the text is safe for eval.
|
|
1384
|
-
|
|
1385
|
-
if (
|
|
1386
|
-
rx_one.test(
|
|
1387
|
-
text
|
|
1388
|
-
.replace(rx_two, "@")
|
|
1389
|
-
.replace(rx_three, "]")
|
|
1390
|
-
.replace(rx_four, "")
|
|
1391
|
-
)
|
|
1392
|
-
) {
|
|
1393
|
-
|
|
1394
|
-
// In the third stage we use the eval function to compile the text into a
|
|
1395
|
-
// JavaScript structure. The "{" operator is subject to a syntactic ambiguity
|
|
1396
|
-
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
|
1397
|
-
// in parens to eliminate the ambiguity.
|
|
1398
|
-
|
|
1399
|
-
j = eval("(" + text + ")");
|
|
1400
|
-
|
|
1401
|
-
// In the optional fourth stage, we recursively walk the new structure, passing
|
|
1402
|
-
// each name/value pair to a reviver function for possible transformation.
|
|
1403
|
-
|
|
1404
|
-
return (typeof reviver === "function")
|
|
1405
|
-
? walk({"": j}, "")
|
|
1406
|
-
: j;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
|
1410
|
-
|
|
1411
|
-
throw new SyntaxError("JSON.parse");
|
|
1412
|
-
};
|
|
1413
|
-
}
|
|
1414
|
-
}());
|
|
1415
|
-
return json2$1;
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
var json2 = json2Plugin;
|
|
1419
|
-
|
|
1420
|
-
function json2Plugin() {
|
|
1421
|
-
requireJson2();
|
|
1422
|
-
return {}
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
var engine = storeEngine;
|
|
1426
|
-
|
|
1427
|
-
var storages = all;
|
|
1428
|
-
var plugins = [json2];
|
|
1429
|
-
|
|
1430
|
-
var store_legacy = engine.createStore(storages, plugins);
|
|
1431
|
-
|
|
1432
|
-
var PREFIX = "xappWidget.";
|
|
1433
|
-
/**
|
|
1434
|
-
* Get an item off of local storage by key
|
|
1435
|
-
*
|
|
1436
|
-
* @param key
|
|
1437
|
-
*/
|
|
1438
|
-
function get(key) {
|
|
1439
|
-
if (store_legacy.enabled)
|
|
1440
|
-
return store_legacy.get(PREFIX + key);
|
|
1441
|
-
return undefined;
|
|
1442
|
-
}
|
|
1443
|
-
/**
|
|
1444
|
-
* Set an item on local storage by key
|
|
1445
|
-
*
|
|
1446
|
-
* @param key
|
|
1447
|
-
* @param value
|
|
1448
|
-
*/
|
|
1449
|
-
function set$1(key, value) {
|
|
1450
|
-
if (store_legacy.enabled)
|
|
1451
|
-
return store_legacy.set(PREFIX + key, value);
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
190
|
function useIsMounted() {
|
|
1455
191
|
var ref = React$1.useRef(false);
|
|
1456
192
|
React$1.useEffect(function () {
|
|
@@ -1632,11 +368,17 @@ function getItemUrl(item) {
|
|
|
1632
368
|
return item.url || item.imageActionUrl;
|
|
1633
369
|
}
|
|
1634
370
|
|
|
371
|
+
function useChatDispatch() {
|
|
372
|
+
return reactRedux.useDispatch();
|
|
373
|
+
}
|
|
374
|
+
|
|
1635
375
|
var OptionalLink = function (props) {
|
|
376
|
+
var chatDispatch = useChatDispatch();
|
|
377
|
+
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
1636
378
|
var url = props.url, className = props.className, onOpen = props.onOpen;
|
|
1637
379
|
var handleOpenUrl = React$1.useCallback(function () {
|
|
1638
380
|
if (onOpen) {
|
|
1639
|
-
onOpen(url);
|
|
381
|
+
onOpen(url, chatDispatch, visuals);
|
|
1640
382
|
}
|
|
1641
383
|
}, [url, onOpen]);
|
|
1642
384
|
if (url) {
|
|
@@ -2010,24 +752,43 @@ function throwBadKind$1(x) {
|
|
|
2010
752
|
throw new Error("Unknown kind " + x);
|
|
2011
753
|
}
|
|
2012
754
|
|
|
2013
|
-
function
|
|
755
|
+
function setVisualStatus(status) {
|
|
756
|
+
return {
|
|
757
|
+
type: "visual_status",
|
|
758
|
+
detail: {
|
|
759
|
+
status: status,
|
|
760
|
+
timestamp: new Date().getTime()
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function execute(url, dispatch, visuals, behavior) {
|
|
766
|
+
if (!dispatch || !visuals) {
|
|
767
|
+
throw new Error("OpenUrl: No dispatch and/or visual.");
|
|
768
|
+
}
|
|
2014
769
|
var type = behavior.type;
|
|
2015
770
|
switch (type) {
|
|
2016
771
|
case "newWindow":
|
|
2017
|
-
if (
|
|
2018
|
-
|
|
772
|
+
if (visuals.opened) {
|
|
773
|
+
dispatch(setVisualStatus({
|
|
774
|
+
opened: false
|
|
775
|
+
}));
|
|
2019
776
|
}
|
|
2020
777
|
window.open(url, "callout-option", "toolbar=0,status=0,width=".concat(behavior.width || 1000, ",height=").concat(behavior.height || 700));
|
|
2021
778
|
break;
|
|
2022
779
|
case "newTab":
|
|
2023
|
-
if (
|
|
2024
|
-
|
|
780
|
+
if (visuals.opened) {
|
|
781
|
+
dispatch(setVisualStatus({
|
|
782
|
+
opened: false
|
|
783
|
+
}));
|
|
2025
784
|
}
|
|
2026
785
|
window.open(url, "_blank");
|
|
2027
786
|
break;
|
|
2028
787
|
case "sameWindow":
|
|
2029
|
-
if (!
|
|
2030
|
-
|
|
788
|
+
if (!visuals.opened) {
|
|
789
|
+
dispatch(setVisualStatus({
|
|
790
|
+
opened: true
|
|
791
|
+
}));
|
|
2031
792
|
}
|
|
2032
793
|
window.open(url, "_self");
|
|
2033
794
|
break;
|
|
@@ -2037,11 +798,11 @@ function execute(url, behavior) {
|
|
|
2037
798
|
}
|
|
2038
799
|
function useOpenUrlCallback() {
|
|
2039
800
|
var env = useWidgetEnv();
|
|
2040
|
-
return React$1.useCallback(function (url, behavior) {
|
|
801
|
+
return React$1.useCallback(function (url, dispatch, visuals, behavior) {
|
|
2041
802
|
if (!behavior) {
|
|
2042
803
|
behavior = (env === null || env === void 0 ? void 0 : env.urls) ? resolveUrlPolicy(url, env.urls) : defaultBehavior;
|
|
2043
804
|
}
|
|
2044
|
-
execute(url, behavior);
|
|
805
|
+
execute(url, dispatch, visuals, behavior);
|
|
2045
806
|
}, [env]);
|
|
2046
807
|
}
|
|
2047
808
|
|
|
@@ -2176,9 +937,9 @@ function sendTyping(typing) {
|
|
|
2176
937
|
}; };
|
|
2177
938
|
}
|
|
2178
939
|
|
|
2179
|
-
function sendVisitorInfo(msg) {
|
|
940
|
+
function sendVisitorInfo(msg, sessionId) {
|
|
2180
941
|
return function (chatServer) { return function () {
|
|
2181
|
-
chatServer.setVisitorInfo(msg, function (err) {
|
|
942
|
+
chatServer.setVisitorInfo(msg, sessionId, function (err) {
|
|
2182
943
|
if (err) {
|
|
2183
944
|
log(err);
|
|
2184
945
|
}
|
|
@@ -2232,10 +993,6 @@ function reset() {
|
|
|
2232
993
|
};
|
|
2233
994
|
}
|
|
2234
995
|
|
|
2235
|
-
function useChatDispatch() {
|
|
2236
|
-
return reactRedux.useDispatch();
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
996
|
var LogChat = /** @class */ (function () {
|
|
2240
997
|
function LogChat(inner) {
|
|
2241
998
|
this.inner = inner;
|
|
@@ -2267,9 +1024,9 @@ var LogChat = /** @class */ (function () {
|
|
|
2267
1024
|
log("CLIENT: sendTyping: ".concat(JSON.stringify(isTyping)));
|
|
2268
1025
|
this.inner.sendTyping(isTyping);
|
|
2269
1026
|
};
|
|
2270
|
-
LogChat.prototype.setVisitorInfo = function (visitorInfo, cb) {
|
|
2271
|
-
log("CLIENT: setVisitorInfo: ".concat(JSON.stringify(visitorInfo)));
|
|
2272
|
-
this.inner.setVisitorInfo(visitorInfo, cb);
|
|
1027
|
+
LogChat.prototype.setVisitorInfo = function (visitorInfo, sessionId, cb) {
|
|
1028
|
+
log("CLIENT: setVisitorInfo: ".concat(JSON.stringify(visitorInfo), " session id: ").concat(sessionId));
|
|
1029
|
+
this.inner.setVisitorInfo(visitorInfo, sessionId, cb);
|
|
2273
1030
|
};
|
|
2274
1031
|
LogChat.prototype.sendChatRating = function (rating) {
|
|
2275
1032
|
log("CLIENT: sendChatRating: ".concat(JSON.stringify(rating)));
|
|
@@ -2294,6 +1051,8 @@ var LogChat = /** @class */ (function () {
|
|
|
2294
1051
|
return LogChat;
|
|
2295
1052
|
}());
|
|
2296
1053
|
|
|
1054
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
1055
|
+
|
|
2297
1056
|
var dist = {};
|
|
2298
1057
|
|
|
2299
1058
|
Object.defineProperty(dist, '__esModule', { value: true });
|
|
@@ -3182,6 +1941,16 @@ function getConfigurableMessagesConfig(messages) {
|
|
|
3182
1941
|
return config;
|
|
3183
1942
|
}
|
|
3184
1943
|
|
|
1944
|
+
function setSessionId(sessionId) {
|
|
1945
|
+
return {
|
|
1946
|
+
type: "session_id",
|
|
1947
|
+
detail: {
|
|
1948
|
+
sessionId: sessionId,
|
|
1949
|
+
timestamp: new Date().getTime()
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
|
|
3185
1954
|
var PERMISSION_QUESTION_EXPIRATION_MS$1 = 300000; // 5 minutes
|
|
3186
1955
|
// interface UserLeaveMessage {
|
|
3187
1956
|
// readonly user: ChatUserInfo;
|
|
@@ -3371,7 +2140,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3371
2140
|
};
|
|
3372
2141
|
StentorDirectChat.prototype.sendTyping = function () {
|
|
3373
2142
|
};
|
|
3374
|
-
StentorDirectChat.prototype.setVisitorInfo = function (visitorInfo, cb) {
|
|
2143
|
+
StentorDirectChat.prototype.setVisitorInfo = function (visitorInfo, sessionId, cb) {
|
|
3375
2144
|
this.visitorInfo = visitorInfo;
|
|
3376
2145
|
this._attributes = __assign({}, this.visitorInfo.attributes);
|
|
3377
2146
|
// do not set currentUrl if localhost, localhost is not liked by some firewalls, like AWS WAF
|
|
@@ -3390,7 +2159,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3390
2159
|
user: this.getBot(undefined),
|
|
3391
2160
|
token: ""
|
|
3392
2161
|
});
|
|
3393
|
-
this.startSession();
|
|
2162
|
+
this.startSession(sessionId);
|
|
3394
2163
|
cb();
|
|
3395
2164
|
};
|
|
3396
2165
|
StentorDirectChat.prototype.sendChatRating = function () {
|
|
@@ -3585,7 +2354,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3585
2354
|
});
|
|
3586
2355
|
});
|
|
3587
2356
|
};
|
|
3588
|
-
StentorDirectChat.prototype.startSession = function () {
|
|
2357
|
+
StentorDirectChat.prototype.startSession = function (sessionId) {
|
|
3589
2358
|
if (this.visitorInfo.visitorId) {
|
|
3590
2359
|
this._userId = "".concat(this.visitorInfo.visitorId);
|
|
3591
2360
|
}
|
|
@@ -3595,12 +2364,14 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
3595
2364
|
else {
|
|
3596
2365
|
this._userId = "stentor-widget-user-".concat(uuid_1());
|
|
3597
2366
|
}
|
|
3598
|
-
if (
|
|
3599
|
-
this._sessionId =
|
|
2367
|
+
if (sessionId) {
|
|
2368
|
+
this._sessionId = sessionId;
|
|
2369
|
+
log("Using persisted session id: ".concat(this._sessionId));
|
|
3600
2370
|
}
|
|
3601
2371
|
else {
|
|
3602
2372
|
this._sessionId = "stentor-widget-session-".concat(uuid_1());
|
|
3603
|
-
|
|
2373
|
+
this.dispatch(setSessionId(this._sessionId));
|
|
2374
|
+
log("Using generated session id: ".concat(this._sessionId));
|
|
3604
2375
|
}
|
|
3605
2376
|
// This is a flag that is cleared after the first message is sent
|
|
3606
2377
|
this.isNewSession = true;
|
|
@@ -4020,6 +2791,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
4020
2791
|
data: data,
|
|
4021
2792
|
sender: this.visitorInfo,
|
|
4022
2793
|
sessionId: this._sessionId,
|
|
2794
|
+
timeMs: new Date().getTime()
|
|
4023
2795
|
});
|
|
4024
2796
|
log("Widget says: ".concat(payloadData));
|
|
4025
2797
|
if (!this.ws) {
|
|
@@ -4121,7 +2893,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
4121
2893
|
// TODO: Is this too much traffic?
|
|
4122
2894
|
// this.emit(isTyping ? "typing" : "stop typing");
|
|
4123
2895
|
};
|
|
4124
|
-
StentorRouterChat.prototype.setVisitorInfo = function (visitorInfoMessage, cb) {
|
|
2896
|
+
StentorRouterChat.prototype.setVisitorInfo = function (visitorInfoMessage, sessionId, cb) {
|
|
4125
2897
|
log("Visitor Info Message = ".concat(JSON.stringify(visitorInfoMessage)));
|
|
4126
2898
|
this.visitorInfo = {
|
|
4127
2899
|
deviceId: "Widget",
|
|
@@ -4133,7 +2905,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
4133
2905
|
};
|
|
4134
2906
|
this.attributes = __assign(__assign(__assign({}, visitorInfoMessage.attributes), this.attributes), { currentUrl: window.location.href });
|
|
4135
2907
|
this.accessToken = visitorInfoMessage.accessToken;
|
|
4136
|
-
this.startSession();
|
|
2908
|
+
this.startSession(sessionId);
|
|
4137
2909
|
this.postVisitorInfo(); // we, the widget, joined the server
|
|
4138
2910
|
cb();
|
|
4139
2911
|
};
|
|
@@ -4186,7 +2958,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
4186
2958
|
});
|
|
4187
2959
|
});
|
|
4188
2960
|
};
|
|
4189
|
-
StentorRouterChat.prototype.startSession = function () {
|
|
2961
|
+
StentorRouterChat.prototype.startSession = function (sessionId) {
|
|
4190
2962
|
if (this.visitorInfo.userId) {
|
|
4191
2963
|
this._userId = "".concat(this.visitorInfo.userId);
|
|
4192
2964
|
}
|
|
@@ -4199,16 +2971,16 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
4199
2971
|
var joinSessionId = new URL(window.location.href).searchParams.get("sessionId");
|
|
4200
2972
|
if (joinSessionId) {
|
|
4201
2973
|
this._sessionId = joinSessionId;
|
|
4202
|
-
|
|
2974
|
+
this.dispatch(setSessionId(this._sessionId));
|
|
4203
2975
|
log("Using enforced session id: ".concat(this._sessionId));
|
|
4204
2976
|
}
|
|
4205
|
-
else if (
|
|
4206
|
-
this._sessionId =
|
|
2977
|
+
else if (sessionId) {
|
|
2978
|
+
this._sessionId = sessionId;
|
|
4207
2979
|
log("Using persisted session id: ".concat(this._sessionId));
|
|
4208
2980
|
}
|
|
4209
2981
|
else {
|
|
4210
2982
|
this._sessionId = "stentor-widget-session-".concat(uuid_1());
|
|
4211
|
-
|
|
2983
|
+
this.dispatch(setSessionId(this._sessionId));
|
|
4212
2984
|
log("Using generated session id: ".concat(this._sessionId));
|
|
4213
2985
|
}
|
|
4214
2986
|
// Always. This triggers a LAUNCH_REQUEST most of the time
|
|
@@ -7759,7 +6531,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
7759
6531
|
StentorServerChat.prototype.sendTyping = function (isTyping) {
|
|
7760
6532
|
this.socket.emit(isTyping ? "typing" : "stop typing");
|
|
7761
6533
|
};
|
|
7762
|
-
StentorServerChat.prototype.setVisitorInfo = function (visitorInfo, cb) {
|
|
6534
|
+
StentorServerChat.prototype.setVisitorInfo = function (visitorInfo, _sessionId, cb) {
|
|
7763
6535
|
this.visitorInfo = visitorInfo;
|
|
7764
6536
|
this.socket.emit("add user", visitorInfo);
|
|
7765
6537
|
cb();
|
|
@@ -7854,11 +6626,13 @@ function useChatServerDispatch() {
|
|
|
7854
6626
|
var ChatChipsContainer = function (_) {
|
|
7855
6627
|
var dispatch = useChatServerDispatch();
|
|
7856
6628
|
var chips = reactRedux.useSelector(function (state) { return state.chips; });
|
|
6629
|
+
var chatDispatch = useChatDispatch();
|
|
6630
|
+
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
7857
6631
|
var openUrl = useOpenUrlCallback();
|
|
7858
6632
|
function optionOnChange(option) {
|
|
7859
6633
|
var actionUrl = isChatServerActionLink(option) && option.actionUrl;
|
|
7860
6634
|
if (actionUrl) {
|
|
7861
|
-
openUrl(actionUrl);
|
|
6635
|
+
openUrl(actionUrl, chatDispatch, visuals);
|
|
7862
6636
|
}
|
|
7863
6637
|
else {
|
|
7864
6638
|
dispatch(executeAction(getChatServerActionLinkLabel(option)));
|
|
@@ -7962,6 +6736,8 @@ var ChatMenu = function (props) {
|
|
|
7962
6736
|
var items = props.items, opened = props.opened;
|
|
7963
6737
|
var openFrom = props.openFrom || "bottom";
|
|
7964
6738
|
var handleOpenUrl = useOpenUrlCallback();
|
|
6739
|
+
var chatDispatch = useChatDispatch();
|
|
6740
|
+
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
7965
6741
|
return (React__default$1["default"].createElement("div", { className: "chat-menu-".concat(openFrom, " ").concat(opened ? "chat-menu-".concat(openFrom, "--opened") : "chat-menu-".concat(openFrom, "--closed")) }, items.map(function (item, i) {
|
|
7966
6742
|
if (lib.isStandardMenuItem(item)) {
|
|
7967
6743
|
return React__default$1["default"].createElement(ChatMenuItem, { key: i, onClick: props.onItemClick, label: item.label, subtitle: item.subtitle });
|
|
@@ -7980,7 +6756,7 @@ var ChatMenu = function (props) {
|
|
|
7980
6756
|
React__default$1["default"].createElement("div", { className: "chat-menu-item-static-text--body" }, item.body))));
|
|
7981
6757
|
}
|
|
7982
6758
|
else if (lib.isOpenURLMenuItem(item)) {
|
|
7983
|
-
return React__default$1["default"].createElement("button", { key: i, className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, item.behavior) }, item.text);
|
|
6759
|
+
return React__default$1["default"].createElement("button", { key: i, className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, chatDispatch, visuals, item.behavior) }, item.text);
|
|
7984
6760
|
}
|
|
7985
6761
|
return React__default$1["default"].createElement("p", null, "Unknown");
|
|
7986
6762
|
})));
|
|
@@ -8007,15 +6783,17 @@ function useExecuteActionCallback() {
|
|
|
8007
6783
|
|
|
8008
6784
|
function useButtonCallback() {
|
|
8009
6785
|
var handleOpenUrl = useOpenUrlCallback();
|
|
6786
|
+
var chatDispatch = useChatDispatch();
|
|
6787
|
+
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
8010
6788
|
var executeAction = useExecuteActionCallback();
|
|
8011
6789
|
return React$1.useCallback(function (button) {
|
|
8012
6790
|
if (button.actionUrl) {
|
|
8013
|
-
handleOpenUrl(button.actionUrl);
|
|
6791
|
+
handleOpenUrl(button.actionUrl, chatDispatch, visuals);
|
|
8014
6792
|
}
|
|
8015
6793
|
else {
|
|
8016
6794
|
executeAction(button.label);
|
|
8017
6795
|
}
|
|
8018
|
-
}, [executeAction, handleOpenUrl]);
|
|
6796
|
+
}, [chatDispatch, executeAction, handleOpenUrl, visuals]);
|
|
8019
6797
|
}
|
|
8020
6798
|
|
|
8021
6799
|
/**
|
|
@@ -8409,12 +7187,14 @@ var ChatMarkdownMessage = function (props) {
|
|
|
8409
7187
|
var onOpenUrl = props.onOpenUrl;
|
|
8410
7188
|
var agentMessage = isAgent(props.message.user.nick);
|
|
8411
7189
|
var ref = React$1.useRef();
|
|
7190
|
+
var chatDispatch = useChatDispatch();
|
|
7191
|
+
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
8412
7192
|
var html = props.message.msg.html;
|
|
8413
7193
|
var handleLinkClick = React$1.useCallback(function (ev) {
|
|
8414
7194
|
if (onOpenUrl) {
|
|
8415
7195
|
var link = ev.target;
|
|
8416
7196
|
ev.preventDefault();
|
|
8417
|
-
onOpenUrl(link.href);
|
|
7197
|
+
onOpenUrl(link.href, chatDispatch, visuals);
|
|
8418
7198
|
}
|
|
8419
7199
|
}, [onOpenUrl]);
|
|
8420
7200
|
React$1.useEffect(function () {
|
|
@@ -8674,6 +7454,7 @@ function useGreeting(active) {
|
|
|
8674
7454
|
var snapshotRef = React$1.useRef(null);
|
|
8675
7455
|
var ctx = React$1.useContext(ChatConfigContext);
|
|
8676
7456
|
var isAdmin = ctx.env.isAdmin;
|
|
7457
|
+
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
8677
7458
|
React$1.useEffect(function () {
|
|
8678
7459
|
if (active) {
|
|
8679
7460
|
if (snapshotRef.current !== curr) {
|
|
@@ -8685,7 +7466,7 @@ function useGreeting(active) {
|
|
|
8685
7466
|
userId: curr.userId,
|
|
8686
7467
|
accessToken: curr.accessToken,
|
|
8687
7468
|
attributes: __assign(__assign({}, curr.attributes), { currentUrl: window.location.href })
|
|
8688
|
-
}));
|
|
7469
|
+
}, sessionId));
|
|
8689
7470
|
if (!isAdmin) {
|
|
8690
7471
|
var timeoutId_1 = setTimeout(function () {
|
|
8691
7472
|
var greetingAction = sendGreeting();
|
|
@@ -8968,6 +7749,7 @@ var Suggestions = function (props) {
|
|
|
8968
7749
|
|
|
8969
7750
|
var ChatFooter = function (props) {
|
|
8970
7751
|
var _a, _b, _c;
|
|
7752
|
+
var innerDispatch = useChatDispatch();
|
|
8971
7753
|
var placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, footerConfig = props.footerConfig, menuConfig = props.menuConfig, inputConfig = props.inputConfig, onSubmit = props.onSubmit;
|
|
8972
7754
|
var _d = React$1.useState(false), drawerOpen = _d[0], setDrawerState = _d[1]; // false initially
|
|
8973
7755
|
var _e = React$1.useState(), suggestionSearch = _e[0], setSuggestionSearch = _e[1];
|
|
@@ -8988,7 +7770,9 @@ var ChatFooter = function (props) {
|
|
|
8988
7770
|
function toggleDrawer() {
|
|
8989
7771
|
var newDrawer = !drawerOpen;
|
|
8990
7772
|
setDrawerState(newDrawer);
|
|
8991
|
-
|
|
7773
|
+
innerDispatch(setVisualStatus({
|
|
7774
|
+
drawer: newDrawer
|
|
7775
|
+
}));
|
|
8992
7776
|
}
|
|
8993
7777
|
function handleMenuItem(label) {
|
|
8994
7778
|
setDrawerState(false);
|
|
@@ -31367,16 +30151,17 @@ var PrechatForm = function (props) {
|
|
|
31367
30151
|
|
|
31368
30152
|
var PrechatFormContainer = function (props) {
|
|
31369
30153
|
var dispatch = useChatServerDispatch();
|
|
30154
|
+
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
31370
30155
|
var handleSubmit = React$1.useCallback(function (data) {
|
|
31371
30156
|
// Don't send empty messages
|
|
31372
30157
|
if (!data.message)
|
|
31373
30158
|
return;
|
|
31374
30159
|
dispatch(sendVisitorInfo({
|
|
31375
30160
|
displayName: data.name,
|
|
31376
|
-
email: data.email
|
|
31377
|
-
}));
|
|
30161
|
+
email: data.email,
|
|
30162
|
+
}, sessionId));
|
|
31378
30163
|
dispatch(executeAction(data.message));
|
|
31379
|
-
}, [dispatch]);
|
|
30164
|
+
}, [dispatch, sessionId]);
|
|
31380
30165
|
return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
31381
30166
|
React__default$1["default"].createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
|
|
31382
30167
|
React__default$1["default"].createElement(PrechatForm, { onSubmit: handleSubmit })));
|
|
@@ -31637,6 +30422,7 @@ var minimizeButtonAriaLabel = "To minimize widget click on minus icon in top rig
|
|
|
31637
30422
|
var closeButtonAriaLabel = "To close widget click on close icon in top right side of widget.";
|
|
31638
30423
|
var ChatHeader = function (props) {
|
|
31639
30424
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
30425
|
+
var innerDispatch = useChatDispatch();
|
|
31640
30426
|
var menuConfig = props.menuConfig, onSubmit = props.onSubmit;
|
|
31641
30427
|
var _s = React$1.useState(false), drawerOpen = _s[0], setDrawerState = _s[1]; // false initially
|
|
31642
30428
|
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
@@ -31648,7 +30434,9 @@ var ChatHeader = function (props) {
|
|
|
31648
30434
|
function toggleDrawer() {
|
|
31649
30435
|
var newDrawer = !drawerOpen;
|
|
31650
30436
|
setDrawerState(newDrawer);
|
|
31651
|
-
|
|
30437
|
+
innerDispatch(setVisualStatus({
|
|
30438
|
+
drawer: newDrawer
|
|
30439
|
+
}));
|
|
31652
30440
|
}
|
|
31653
30441
|
function handleMenuItem(label) {
|
|
31654
30442
|
setDrawerState(false);
|
|
@@ -31983,7 +30771,7 @@ var ChatWidgetWrapper = function (props) {
|
|
|
31983
30771
|
React__default$1["default"].createElement(ChatWidget, __assign({}, props)))));
|
|
31984
30772
|
};
|
|
31985
30773
|
var ChatWidget = function (props) {
|
|
31986
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
30774
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
31987
30775
|
var innerDispatch = useChatDispatch();
|
|
31988
30776
|
var dispatch = useChatServerDispatch();
|
|
31989
30777
|
// From Redux
|
|
@@ -32009,20 +30797,34 @@ var ChatWidget = function (props) {
|
|
|
32009
30797
|
else {
|
|
32010
30798
|
canCancel = !dockedMode && !staticMode;
|
|
32011
30799
|
}
|
|
30800
|
+
// For backward compatibility. Note: the action will create the actual "visuals" object" (this is a copy).
|
|
30801
|
+
if (!chatState.visuals) {
|
|
30802
|
+
chatState.visuals = {};
|
|
30803
|
+
}
|
|
32012
30804
|
// Our state - pull from storage
|
|
32013
|
-
var
|
|
32014
|
-
!!get("visible") ||
|
|
30805
|
+
var _1 = React$1.useState((!canMinimize && !canCancel) ||
|
|
30806
|
+
// !!get("visible") ||
|
|
30807
|
+
chatState.visuals.visible ||
|
|
32015
30808
|
(((_k = props.config) === null || _k === void 0 ? void 0 : _k.autoOpenOnWidth) &&
|
|
32016
|
-
window.matchMedia("(min-width: ".concat((_l = props.config) === null || _l === void 0 ? void 0 : _l.autoOpenOnWidth, ")")).matches)), visible =
|
|
32017
|
-
var
|
|
30809
|
+
window.matchMedia("(min-width: ".concat((_l = props.config) === null || _l === void 0 ? void 0 : _l.autoOpenOnWidth, ")")).matches)), visible = _1[0], setVisibleState = _1[1];
|
|
30810
|
+
var _2 = React$1.useState(false), typing = _2[0], setTypingState = _2[1]; // false initially
|
|
32018
30811
|
var chatServer = React$1.useContext(ChatServerContext);
|
|
30812
|
+
var patternsConfig = (_o = (_m = props.config) === null || _m === void 0 ? void 0 : _m.autoOpenOnPattern) === null || _o === void 0 ? void 0 : _o.patterns;
|
|
30813
|
+
var currentUrl = window.location.href;
|
|
30814
|
+
var patternExist = patternsConfig && patternsConfig.length > 0;
|
|
30815
|
+
var patternMatches = patternsConfig === null || patternsConfig === void 0 ? void 0 : patternsConfig.some(function (pattern) { return currentUrl.includes(pattern); });
|
|
30816
|
+
var configWidth = (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.autoOpenOnPattern) === null || _q === void 0 ? void 0 : _q.minimumWidth;
|
|
30817
|
+
// eslint-disable-next-line no-restricted-globals
|
|
30818
|
+
var currentWidth = screen.width;
|
|
32019
30819
|
var setVisible = React$1.useCallback(function (newVisible) {
|
|
32020
30820
|
if (staticMode) {
|
|
32021
30821
|
return;
|
|
32022
30822
|
}
|
|
32023
30823
|
setVisibleState(newVisible);
|
|
32024
|
-
|
|
32025
|
-
|
|
30824
|
+
innerDispatch(setVisualStatus({
|
|
30825
|
+
visible: newVisible
|
|
30826
|
+
}));
|
|
30827
|
+
}, [innerDispatch, staticMode]);
|
|
32026
30828
|
React$1.useEffect(function () {
|
|
32027
30829
|
var _a, _b;
|
|
32028
30830
|
document.addEventListener("keydown", function (event) {
|
|
@@ -32033,17 +30835,26 @@ var ChatWidget = function (props) {
|
|
|
32033
30835
|
}
|
|
32034
30836
|
});
|
|
32035
30837
|
if (checkSessionExpiration((chatState === null || chatState === void 0 ? void 0 : chatState.sessionExpiration) || ((_a = props.config) === null || _a === void 0 ? void 0 : _a.sessionExpiration), (_b = chatState === null || chatState === void 0 ? void 0 : chatState.chats[chatState.chats.length - 1]) === null || _b === void 0 ? void 0 : _b.timestamp, chatState === null || chatState === void 0 ? void 0 : chatState.lastTimestamp)) {
|
|
32036
|
-
|
|
30838
|
+
innerDispatch(setSessionId(undefined));
|
|
32037
30839
|
innerDispatch(reset());
|
|
32038
30840
|
}
|
|
32039
30841
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32040
30842
|
}, []);
|
|
32041
30843
|
React$1.useEffect(function () {
|
|
32042
30844
|
// For reopen widget after move on same windowyar
|
|
32043
|
-
if (get("opened")) {
|
|
30845
|
+
// if (get("opened")) {
|
|
30846
|
+
// setVisible(true);
|
|
30847
|
+
// }
|
|
30848
|
+
if (chatState.visuals.opened) {
|
|
30849
|
+
setVisible(true);
|
|
30850
|
+
}
|
|
30851
|
+
if (patternExist && patternMatches) {
|
|
32044
30852
|
setVisible(true);
|
|
32045
30853
|
}
|
|
32046
|
-
|
|
30854
|
+
if (currentWidth < +configWidth) {
|
|
30855
|
+
setVisible(false);
|
|
30856
|
+
}
|
|
30857
|
+
}, [currentWidth, patternExist, patternMatches, configWidth, setVisible, chatState.visuals.opened]);
|
|
32047
30858
|
function handleOnChange() {
|
|
32048
30859
|
if (!typing) {
|
|
32049
30860
|
dispatch(sendTyping(true));
|
|
@@ -32094,16 +30905,23 @@ var ChatWidget = function (props) {
|
|
|
32094
30905
|
innerDispatch(reset());
|
|
32095
30906
|
}
|
|
32096
30907
|
function minimizeOnClick() {
|
|
32097
|
-
|
|
30908
|
+
innerDispatch(setVisualStatus({
|
|
30909
|
+
opened: false
|
|
30910
|
+
}));
|
|
32098
30911
|
setVisible(false);
|
|
32099
30912
|
}
|
|
32100
30913
|
function cancelOnClick() {
|
|
32101
|
-
set
|
|
30914
|
+
//set("opened", false);
|
|
30915
|
+
innerDispatch(setVisualStatus({
|
|
30916
|
+
opened: false
|
|
30917
|
+
}));
|
|
32102
30918
|
innerDispatch(reset());
|
|
32103
30919
|
setVisible(false);
|
|
32104
30920
|
}
|
|
32105
30921
|
function chatButtonOnClick() {
|
|
32106
|
-
|
|
30922
|
+
innerDispatch(setVisualStatus({
|
|
30923
|
+
opened: true
|
|
30924
|
+
}));
|
|
32107
30925
|
setVisible(true);
|
|
32108
30926
|
setTimeout(function () {
|
|
32109
30927
|
document.getElementById("chatWidgetInput").focus();
|
|
@@ -32151,22 +30969,22 @@ var ChatWidget = function (props) {
|
|
|
32151
30969
|
onConnectionStatusChange(connectionStatus);
|
|
32152
30970
|
}
|
|
32153
30971
|
}, [connectionStatus, onConnectionStatusChange]);
|
|
32154
|
-
useExternalScript((
|
|
30972
|
+
useExternalScript((_r = props.config) === null || _r === void 0 ? void 0 : _r.middlewareUrl);
|
|
32155
30973
|
// This is a pseudo agent. It represent's the widget (shown in the header avatar for instance)
|
|
32156
|
-
var widgetAgent = ((
|
|
30974
|
+
var widgetAgent = ((_s = chatState.agents["agent:robot"]) === null || _s === void 0 ? void 0 : _s.user) || (config === null || config === void 0 ? void 0 : config.agent)
|
|
32157
30975
|
|| { nick: "agent:robot", avatarPath: config.avatarUrl, display_name: "Agent" };
|
|
32158
30976
|
return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
32159
30977
|
React__default$1["default"].createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
32160
30978
|
React__default$1["default"].createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
32161
30979
|
React__default$1["default"].createElement(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: openModal, minimizeOnClick: minimizeOnClick, cancelOnClick: cancelOnClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, onSubmit: handleOnSubmit }),
|
|
32162
|
-
React__default$1["default"].createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (
|
|
30980
|
+
React__default$1["default"].createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_u = (_t = props.config) === null || _t === void 0 ? void 0 : _t.typingStatus) === null || _u === void 0 ? void 0 : _u.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
32163
30981
|
React__default$1["default"].createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
32164
30982
|
React__default$1["default"].createElement("div", { className: "spinner" })),
|
|
32165
30983
|
connectionStatus === "offline" && React__default$1["default"].createElement(ServerOffline, null),
|
|
32166
|
-
React__default$1["default"].createElement(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (
|
|
30984
|
+
React__default$1["default"].createElement(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_v = config === null || config === void 0 ? void 0 : config.input) === null || _v === void 0 ? void 0 : _v.placeholder, sendButtonIcon: (_x = (_w = config === null || config === void 0 ? void 0 : config.footer) === null || _w === void 0 ? void 0 : _w.sendButton) === null || _x === void 0 ? void 0 : _x.icon, visible: visible, menuConfig: props.config.menu, footerConfig: (_y = props.config) === null || _y === void 0 ? void 0 : _y.footer, inputConfig: (_z = props.config) === null || _z === void 0 ? void 0 : _z.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }),
|
|
32167
30985
|
React__default$1["default"].createElement("div", { className: "restartModal", ref: modalRef, onClick: closeModal },
|
|
32168
30986
|
React__default$1["default"].createElement(ModalContent, { onClose: closeModal, onReset: refreshOnClick }))),
|
|
32169
|
-
React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (
|
|
30987
|
+
React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_0 = props.config) === null || _0 === void 0 ? void 0 : _0.cta, visible: visible })));
|
|
32170
30988
|
};
|
|
32171
30989
|
|
|
32172
30990
|
function tryParseJson(str) {
|
|
@@ -32223,7 +31041,7 @@ function createDefaultState(state) {
|
|
|
32223
31041
|
connectionStatus: "offline",
|
|
32224
31042
|
token: null,
|
|
32225
31043
|
greetingRequested: false
|
|
32226
|
-
}, accountStatus: "offline", departments: {}, visitor: DEFAULT_VISITOR, agents: {}, chats: [], lastTimestamp: 0, lastRatingRequestTimestamp: 0, hasRating: false, isChatting: false, queuePosition: 0, failureMsg: null, visitorId: visitorFingerprint(), chips: [], sessionExpiration: "24h" }, state);
|
|
31044
|
+
}, accountStatus: "offline", departments: {}, visitor: DEFAULT_VISITOR, agents: {}, chats: [], lastTimestamp: 0, lastRatingRequestTimestamp: 0, hasRating: false, isChatting: false, queuePosition: 0, failureMsg: null, visitorId: visitorFingerprint(), chips: [], sessionExpiration: "24h", visuals: {} }, state);
|
|
32227
31045
|
}
|
|
32228
31046
|
var DEFAULT_STATE = createDefaultState();
|
|
32229
31047
|
|
|
@@ -32369,6 +31187,24 @@ function update(state, action) {
|
|
|
32369
31187
|
return state;
|
|
32370
31188
|
case "account_status":
|
|
32371
31189
|
return __assign(__assign({}, state), { accountStatus: action.detail.status });
|
|
31190
|
+
case "session_id":
|
|
31191
|
+
return __assign(__assign({}, state), { sessionId: action.detail.sessionId });
|
|
31192
|
+
case "visual_status":
|
|
31193
|
+
var newVisualState = __assign({}, state);
|
|
31194
|
+
// Backward compatibility
|
|
31195
|
+
if (!newVisualState.visuals) {
|
|
31196
|
+
newVisualState.visuals = {};
|
|
31197
|
+
}
|
|
31198
|
+
if (action.detail.status.drawer !== undefined) {
|
|
31199
|
+
newVisualState.visuals.drawer = action.detail.status.drawer;
|
|
31200
|
+
}
|
|
31201
|
+
if (action.detail.status.opened !== undefined) {
|
|
31202
|
+
newVisualState.visuals.opened = action.detail.status.opened;
|
|
31203
|
+
}
|
|
31204
|
+
if (action.detail.status.visible !== undefined) {
|
|
31205
|
+
newVisualState.visuals.visible = action.detail.status.visible;
|
|
31206
|
+
}
|
|
31207
|
+
return newVisualState;
|
|
32372
31208
|
case "department_update":
|
|
32373
31209
|
return __assign(__assign({}, state), { departments: __assign(__assign({}, state.departments), (_a = {}, _a[action.detail.id] = __assign({}, action.detail), _a)) });
|
|
32374
31210
|
case "visitor_update":
|
|
@@ -32618,7 +31454,7 @@ var StaticChatWidgetContainer = function (props) {
|
|
|
32618
31454
|
|
|
32619
31455
|
function createStateFromMessages(messages) {
|
|
32620
31456
|
var def = createDefaultState();
|
|
32621
|
-
return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), isChatting: true });
|
|
31457
|
+
return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), isChatting: true, visuals: {} });
|
|
32622
31458
|
}
|
|
32623
31459
|
|
|
32624
31460
|
var StaticMessagesChatWidgetContainer = function (props) {
|