@jitsu/js 0.0.0-alpha.110 → 0.0.0-alpha.115

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/jitsu.cjs.js CHANGED
@@ -67,970 +67,6 @@ function analyticsLib() {
67
67
  return ke(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
68
68
  }
69
69
 
70
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
71
-
72
- var alea$1 = {exports: {}};
73
-
74
- (function (module) {
75
- // A port of an algorithm by Johannes Baagøe <baagoe@baagoe.com>, 2010
76
- // http://baagoe.com/en/RandomMusings/javascript/
77
- // https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
78
- // Original work is under MIT license -
79
-
80
- // Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
81
- //
82
- // Permission is hereby granted, free of charge, to any person obtaining a copy
83
- // of this software and associated documentation files (the "Software"), to deal
84
- // in the Software without restriction, including without limitation the rights
85
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
86
- // copies of the Software, and to permit persons to whom the Software is
87
- // furnished to do so, subject to the following conditions:
88
- //
89
- // The above copyright notice and this permission notice shall be included in
90
- // all copies or substantial portions of the Software.
91
- //
92
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
93
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
94
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
95
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
96
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
97
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
98
- // THE SOFTWARE.
99
-
100
-
101
-
102
- (function(global, module, define) {
103
-
104
- function Alea(seed) {
105
- var me = this, mash = Mash();
106
-
107
- me.next = function() {
108
- var t = 2091639 * me.s0 + me.c * 2.3283064365386963e-10; // 2^-32
109
- me.s0 = me.s1;
110
- me.s1 = me.s2;
111
- return me.s2 = t - (me.c = t | 0);
112
- };
113
-
114
- // Apply the seeding algorithm from Baagoe.
115
- me.c = 1;
116
- me.s0 = mash(' ');
117
- me.s1 = mash(' ');
118
- me.s2 = mash(' ');
119
- me.s0 -= mash(seed);
120
- if (me.s0 < 0) { me.s0 += 1; }
121
- me.s1 -= mash(seed);
122
- if (me.s1 < 0) { me.s1 += 1; }
123
- me.s2 -= mash(seed);
124
- if (me.s2 < 0) { me.s2 += 1; }
125
- mash = null;
126
- }
127
-
128
- function copy(f, t) {
129
- t.c = f.c;
130
- t.s0 = f.s0;
131
- t.s1 = f.s1;
132
- t.s2 = f.s2;
133
- return t;
134
- }
135
-
136
- function impl(seed, opts) {
137
- var xg = new Alea(seed),
138
- state = opts && opts.state,
139
- prng = xg.next;
140
- prng.int32 = function() { return (xg.next() * 0x100000000) | 0; };
141
- prng.double = function() {
142
- return prng() + (prng() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
143
- };
144
- prng.quick = prng;
145
- if (state) {
146
- if (typeof(state) == 'object') copy(state, xg);
147
- prng.state = function() { return copy(xg, {}); };
148
- }
149
- return prng;
150
- }
151
-
152
- function Mash() {
153
- var n = 0xefc8249d;
154
-
155
- var mash = function(data) {
156
- data = String(data);
157
- for (var i = 0; i < data.length; i++) {
158
- n += data.charCodeAt(i);
159
- var h = 0.02519603282416938 * n;
160
- n = h >>> 0;
161
- h -= n;
162
- h *= n;
163
- n = h >>> 0;
164
- h -= n;
165
- n += h * 0x100000000; // 2^32
166
- }
167
- return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
168
- };
169
-
170
- return mash;
171
- }
172
-
173
-
174
- if (module && module.exports) {
175
- module.exports = impl;
176
- } else if (define && define.amd) {
177
- define(function() { return impl; });
178
- } else {
179
- this.alea = impl;
180
- }
181
-
182
- })(
183
- commonjsGlobal,
184
- module, // present in node.js
185
- (typeof undefined) == 'function' // present with an AMD loader
186
- );
187
- } (alea$1));
188
-
189
- var xor128$1 = {exports: {}};
190
-
191
- (function (module) {
192
- // A Javascript implementaion of the "xor128" prng algorithm by
193
- // George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
194
-
195
- (function(global, module, define) {
196
-
197
- function XorGen(seed) {
198
- var me = this, strseed = '';
199
-
200
- me.x = 0;
201
- me.y = 0;
202
- me.z = 0;
203
- me.w = 0;
204
-
205
- // Set up generator function.
206
- me.next = function() {
207
- var t = me.x ^ (me.x << 11);
208
- me.x = me.y;
209
- me.y = me.z;
210
- me.z = me.w;
211
- return me.w ^= (me.w >>> 19) ^ t ^ (t >>> 8);
212
- };
213
-
214
- if (seed === (seed | 0)) {
215
- // Integer seed.
216
- me.x = seed;
217
- } else {
218
- // String seed.
219
- strseed += seed;
220
- }
221
-
222
- // Mix in string seed, then discard an initial batch of 64 values.
223
- for (var k = 0; k < strseed.length + 64; k++) {
224
- me.x ^= strseed.charCodeAt(k) | 0;
225
- me.next();
226
- }
227
- }
228
-
229
- function copy(f, t) {
230
- t.x = f.x;
231
- t.y = f.y;
232
- t.z = f.z;
233
- t.w = f.w;
234
- return t;
235
- }
236
-
237
- function impl(seed, opts) {
238
- var xg = new XorGen(seed),
239
- state = opts && opts.state,
240
- prng = function() { return (xg.next() >>> 0) / 0x100000000; };
241
- prng.double = function() {
242
- do {
243
- var top = xg.next() >>> 11,
244
- bot = (xg.next() >>> 0) / 0x100000000,
245
- result = (top + bot) / (1 << 21);
246
- } while (result === 0);
247
- return result;
248
- };
249
- prng.int32 = xg.next;
250
- prng.quick = prng;
251
- if (state) {
252
- if (typeof(state) == 'object') copy(state, xg);
253
- prng.state = function() { return copy(xg, {}); };
254
- }
255
- return prng;
256
- }
257
-
258
- if (module && module.exports) {
259
- module.exports = impl;
260
- } else if (define && define.amd) {
261
- define(function() { return impl; });
262
- } else {
263
- this.xor128 = impl;
264
- }
265
-
266
- })(
267
- commonjsGlobal,
268
- module, // present in node.js
269
- (typeof undefined) == 'function' // present with an AMD loader
270
- );
271
- } (xor128$1));
272
-
273
- var xorwow$1 = {exports: {}};
274
-
275
- (function (module) {
276
- // A Javascript implementaion of the "xorwow" prng algorithm by
277
- // George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
278
-
279
- (function(global, module, define) {
280
-
281
- function XorGen(seed) {
282
- var me = this, strseed = '';
283
-
284
- // Set up generator function.
285
- me.next = function() {
286
- var t = (me.x ^ (me.x >>> 2));
287
- me.x = me.y; me.y = me.z; me.z = me.w; me.w = me.v;
288
- return (me.d = (me.d + 362437 | 0)) +
289
- (me.v = (me.v ^ (me.v << 4)) ^ (t ^ (t << 1))) | 0;
290
- };
291
-
292
- me.x = 0;
293
- me.y = 0;
294
- me.z = 0;
295
- me.w = 0;
296
- me.v = 0;
297
-
298
- if (seed === (seed | 0)) {
299
- // Integer seed.
300
- me.x = seed;
301
- } else {
302
- // String seed.
303
- strseed += seed;
304
- }
305
-
306
- // Mix in string seed, then discard an initial batch of 64 values.
307
- for (var k = 0; k < strseed.length + 64; k++) {
308
- me.x ^= strseed.charCodeAt(k) | 0;
309
- if (k == strseed.length) {
310
- me.d = me.x << 10 ^ me.x >>> 4;
311
- }
312
- me.next();
313
- }
314
- }
315
-
316
- function copy(f, t) {
317
- t.x = f.x;
318
- t.y = f.y;
319
- t.z = f.z;
320
- t.w = f.w;
321
- t.v = f.v;
322
- t.d = f.d;
323
- return t;
324
- }
325
-
326
- function impl(seed, opts) {
327
- var xg = new XorGen(seed),
328
- state = opts && opts.state,
329
- prng = function() { return (xg.next() >>> 0) / 0x100000000; };
330
- prng.double = function() {
331
- do {
332
- var top = xg.next() >>> 11,
333
- bot = (xg.next() >>> 0) / 0x100000000,
334
- result = (top + bot) / (1 << 21);
335
- } while (result === 0);
336
- return result;
337
- };
338
- prng.int32 = xg.next;
339
- prng.quick = prng;
340
- if (state) {
341
- if (typeof(state) == 'object') copy(state, xg);
342
- prng.state = function() { return copy(xg, {}); };
343
- }
344
- return prng;
345
- }
346
-
347
- if (module && module.exports) {
348
- module.exports = impl;
349
- } else if (define && define.amd) {
350
- define(function() { return impl; });
351
- } else {
352
- this.xorwow = impl;
353
- }
354
-
355
- })(
356
- commonjsGlobal,
357
- module, // present in node.js
358
- (typeof undefined) == 'function' // present with an AMD loader
359
- );
360
- } (xorwow$1));
361
-
362
- var xorshift7$1 = {exports: {}};
363
-
364
- (function (module) {
365
- // A Javascript implementaion of the "xorshift7" algorithm by
366
- // François Panneton and Pierre L'ecuyer:
367
- // "On the Xorgshift Random Number Generators"
368
- // http://saluc.engr.uconn.edu/refs/crypto/rng/panneton05onthexorshift.pdf
369
-
370
- (function(global, module, define) {
371
-
372
- function XorGen(seed) {
373
- var me = this;
374
-
375
- // Set up generator function.
376
- me.next = function() {
377
- // Update xor generator.
378
- var X = me.x, i = me.i, t, v;
379
- t = X[i]; t ^= (t >>> 7); v = t ^ (t << 24);
380
- t = X[(i + 1) & 7]; v ^= t ^ (t >>> 10);
381
- t = X[(i + 3) & 7]; v ^= t ^ (t >>> 3);
382
- t = X[(i + 4) & 7]; v ^= t ^ (t << 7);
383
- t = X[(i + 7) & 7]; t = t ^ (t << 13); v ^= t ^ (t << 9);
384
- X[i] = v;
385
- me.i = (i + 1) & 7;
386
- return v;
387
- };
388
-
389
- function init(me, seed) {
390
- var j, X = [];
391
-
392
- if (seed === (seed | 0)) {
393
- // Seed state array using a 32-bit integer.
394
- X[0] = seed;
395
- } else {
396
- // Seed state using a string.
397
- seed = '' + seed;
398
- for (j = 0; j < seed.length; ++j) {
399
- X[j & 7] = (X[j & 7] << 15) ^
400
- (seed.charCodeAt(j) + X[(j + 1) & 7] << 13);
401
- }
402
- }
403
- // Enforce an array length of 8, not all zeroes.
404
- while (X.length < 8) X.push(0);
405
- for (j = 0; j < 8 && X[j] === 0; ++j);
406
- if (j == 8) X[7] = -1; else X[j];
407
-
408
- me.x = X;
409
- me.i = 0;
410
-
411
- // Discard an initial 256 values.
412
- for (j = 256; j > 0; --j) {
413
- me.next();
414
- }
415
- }
416
-
417
- init(me, seed);
418
- }
419
-
420
- function copy(f, t) {
421
- t.x = f.x.slice();
422
- t.i = f.i;
423
- return t;
424
- }
425
-
426
- function impl(seed, opts) {
427
- if (seed == null) seed = +(new Date);
428
- var xg = new XorGen(seed),
429
- state = opts && opts.state,
430
- prng = function() { return (xg.next() >>> 0) / 0x100000000; };
431
- prng.double = function() {
432
- do {
433
- var top = xg.next() >>> 11,
434
- bot = (xg.next() >>> 0) / 0x100000000,
435
- result = (top + bot) / (1 << 21);
436
- } while (result === 0);
437
- return result;
438
- };
439
- prng.int32 = xg.next;
440
- prng.quick = prng;
441
- if (state) {
442
- if (state.x) copy(state, xg);
443
- prng.state = function() { return copy(xg, {}); };
444
- }
445
- return prng;
446
- }
447
-
448
- if (module && module.exports) {
449
- module.exports = impl;
450
- } else if (define && define.amd) {
451
- define(function() { return impl; });
452
- } else {
453
- this.xorshift7 = impl;
454
- }
455
-
456
- })(
457
- commonjsGlobal,
458
- module, // present in node.js
459
- (typeof undefined) == 'function' // present with an AMD loader
460
- );
461
- } (xorshift7$1));
462
-
463
- var xor4096$1 = {exports: {}};
464
-
465
- (function (module) {
466
- // A Javascript implementaion of Richard Brent's Xorgens xor4096 algorithm.
467
- //
468
- // This fast non-cryptographic random number generator is designed for
469
- // use in Monte-Carlo algorithms. It combines a long-period xorshift
470
- // generator with a Weyl generator, and it passes all common batteries
471
- // of stasticial tests for randomness while consuming only a few nanoseconds
472
- // for each prng generated. For background on the generator, see Brent's
473
- // paper: "Some long-period random number generators using shifts and xors."
474
- // http://arxiv.org/pdf/1004.3115v1.pdf
475
- //
476
- // Usage:
477
- //
478
- // var xor4096 = require('xor4096');
479
- // random = xor4096(1); // Seed with int32 or string.
480
- // assert.equal(random(), 0.1520436450538547); // (0, 1) range, 53 bits.
481
- // assert.equal(random.int32(), 1806534897); // signed int32, 32 bits.
482
- //
483
- // For nonzero numeric keys, this impelementation provides a sequence
484
- // identical to that by Brent's xorgens 3 implementaion in C. This
485
- // implementation also provides for initalizing the generator with
486
- // string seeds, or for saving and restoring the state of the generator.
487
- //
488
- // On Chrome, this prng benchmarks about 2.1 times slower than
489
- // Javascript's built-in Math.random().
490
-
491
- (function(global, module, define) {
492
-
493
- function XorGen(seed) {
494
- var me = this;
495
-
496
- // Set up generator function.
497
- me.next = function() {
498
- var w = me.w,
499
- X = me.X, i = me.i, t, v;
500
- // Update Weyl generator.
501
- me.w = w = (w + 0x61c88647) | 0;
502
- // Update xor generator.
503
- v = X[(i + 34) & 127];
504
- t = X[i = ((i + 1) & 127)];
505
- v ^= v << 13;
506
- t ^= t << 17;
507
- v ^= v >>> 15;
508
- t ^= t >>> 12;
509
- // Update Xor generator array state.
510
- v = X[i] = v ^ t;
511
- me.i = i;
512
- // Result is the combination.
513
- return (v + (w ^ (w >>> 16))) | 0;
514
- };
515
-
516
- function init(me, seed) {
517
- var t, v, i, j, w, X = [], limit = 128;
518
- if (seed === (seed | 0)) {
519
- // Numeric seeds initialize v, which is used to generates X.
520
- v = seed;
521
- seed = null;
522
- } else {
523
- // String seeds are mixed into v and X one character at a time.
524
- seed = seed + '\0';
525
- v = 0;
526
- limit = Math.max(limit, seed.length);
527
- }
528
- // Initialize circular array and weyl value.
529
- for (i = 0, j = -32; j < limit; ++j) {
530
- // Put the unicode characters into the array, and shuffle them.
531
- if (seed) v ^= seed.charCodeAt((j + 32) % seed.length);
532
- // After 32 shuffles, take v as the starting w value.
533
- if (j === 0) w = v;
534
- v ^= v << 10;
535
- v ^= v >>> 15;
536
- v ^= v << 4;
537
- v ^= v >>> 13;
538
- if (j >= 0) {
539
- w = (w + 0x61c88647) | 0; // Weyl.
540
- t = (X[j & 127] ^= (v + w)); // Combine xor and weyl to init array.
541
- i = (0 == t) ? i + 1 : 0; // Count zeroes.
542
- }
543
- }
544
- // We have detected all zeroes; make the key nonzero.
545
- if (i >= 128) {
546
- X[(seed && seed.length || 0) & 127] = -1;
547
- }
548
- // Run the generator 512 times to further mix the state before using it.
549
- // Factoring this as a function slows the main generator, so it is just
550
- // unrolled here. The weyl generator is not advanced while warming up.
551
- i = 127;
552
- for (j = 4 * 128; j > 0; --j) {
553
- v = X[(i + 34) & 127];
554
- t = X[i = ((i + 1) & 127)];
555
- v ^= v << 13;
556
- t ^= t << 17;
557
- v ^= v >>> 15;
558
- t ^= t >>> 12;
559
- X[i] = v ^ t;
560
- }
561
- // Storing state as object members is faster than using closure variables.
562
- me.w = w;
563
- me.X = X;
564
- me.i = i;
565
- }
566
-
567
- init(me, seed);
568
- }
569
-
570
- function copy(f, t) {
571
- t.i = f.i;
572
- t.w = f.w;
573
- t.X = f.X.slice();
574
- return t;
575
- }
576
- function impl(seed, opts) {
577
- if (seed == null) seed = +(new Date);
578
- var xg = new XorGen(seed),
579
- state = opts && opts.state,
580
- prng = function() { return (xg.next() >>> 0) / 0x100000000; };
581
- prng.double = function() {
582
- do {
583
- var top = xg.next() >>> 11,
584
- bot = (xg.next() >>> 0) / 0x100000000,
585
- result = (top + bot) / (1 << 21);
586
- } while (result === 0);
587
- return result;
588
- };
589
- prng.int32 = xg.next;
590
- prng.quick = prng;
591
- if (state) {
592
- if (state.X) copy(state, xg);
593
- prng.state = function() { return copy(xg, {}); };
594
- }
595
- return prng;
596
- }
597
-
598
- if (module && module.exports) {
599
- module.exports = impl;
600
- } else if (define && define.amd) {
601
- define(function() { return impl; });
602
- } else {
603
- this.xor4096 = impl;
604
- }
605
-
606
- })(
607
- commonjsGlobal, // window object or global
608
- module, // present in node.js
609
- (typeof undefined) == 'function' // present with an AMD loader
610
- );
611
- } (xor4096$1));
612
-
613
- var tychei$1 = {exports: {}};
614
-
615
- (function (module) {
616
- // A Javascript implementaion of the "Tyche-i" prng algorithm by
617
- // Samuel Neves and Filipe Araujo.
618
- // See https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
619
-
620
- (function(global, module, define) {
621
-
622
- function XorGen(seed) {
623
- var me = this, strseed = '';
624
-
625
- // Set up generator function.
626
- me.next = function() {
627
- var b = me.b, c = me.c, d = me.d, a = me.a;
628
- b = (b << 25) ^ (b >>> 7) ^ c;
629
- c = (c - d) | 0;
630
- d = (d << 24) ^ (d >>> 8) ^ a;
631
- a = (a - b) | 0;
632
- me.b = b = (b << 20) ^ (b >>> 12) ^ c;
633
- me.c = c = (c - d) | 0;
634
- me.d = (d << 16) ^ (c >>> 16) ^ a;
635
- return me.a = (a - b) | 0;
636
- };
637
-
638
- /* The following is non-inverted tyche, which has better internal
639
- * bit diffusion, but which is about 25% slower than tyche-i in JS.
640
- me.next = function() {
641
- var a = me.a, b = me.b, c = me.c, d = me.d;
642
- a = (me.a + me.b | 0) >>> 0;
643
- d = me.d ^ a; d = d << 16 ^ d >>> 16;
644
- c = me.c + d | 0;
645
- b = me.b ^ c; b = b << 12 ^ d >>> 20;
646
- me.a = a = a + b | 0;
647
- d = d ^ a; me.d = d = d << 8 ^ d >>> 24;
648
- me.c = c = c + d | 0;
649
- b = b ^ c;
650
- return me.b = (b << 7 ^ b >>> 25);
651
- }
652
- */
653
-
654
- me.a = 0;
655
- me.b = 0;
656
- me.c = 2654435769 | 0;
657
- me.d = 1367130551;
658
-
659
- if (seed === Math.floor(seed)) {
660
- // Integer seed.
661
- me.a = (seed / 0x100000000) | 0;
662
- me.b = seed | 0;
663
- } else {
664
- // String seed.
665
- strseed += seed;
666
- }
667
-
668
- // Mix in string seed, then discard an initial batch of 64 values.
669
- for (var k = 0; k < strseed.length + 20; k++) {
670
- me.b ^= strseed.charCodeAt(k) | 0;
671
- me.next();
672
- }
673
- }
674
-
675
- function copy(f, t) {
676
- t.a = f.a;
677
- t.b = f.b;
678
- t.c = f.c;
679
- t.d = f.d;
680
- return t;
681
- }
682
- function impl(seed, opts) {
683
- var xg = new XorGen(seed),
684
- state = opts && opts.state,
685
- prng = function() { return (xg.next() >>> 0) / 0x100000000; };
686
- prng.double = function() {
687
- do {
688
- var top = xg.next() >>> 11,
689
- bot = (xg.next() >>> 0) / 0x100000000,
690
- result = (top + bot) / (1 << 21);
691
- } while (result === 0);
692
- return result;
693
- };
694
- prng.int32 = xg.next;
695
- prng.quick = prng;
696
- if (state) {
697
- if (typeof(state) == 'object') copy(state, xg);
698
- prng.state = function() { return copy(xg, {}); };
699
- }
700
- return prng;
701
- }
702
-
703
- if (module && module.exports) {
704
- module.exports = impl;
705
- } else if (define && define.amd) {
706
- define(function() { return impl; });
707
- } else {
708
- this.tychei = impl;
709
- }
710
-
711
- })(
712
- commonjsGlobal,
713
- module, // present in node.js
714
- (typeof undefined) == 'function' // present with an AMD loader
715
- );
716
- } (tychei$1));
717
-
718
- var seedrandom$1 = {exports: {}};
719
-
720
- /*
721
- Copyright 2019 David Bau.
722
-
723
- Permission is hereby granted, free of charge, to any person obtaining
724
- a copy of this software and associated documentation files (the
725
- "Software"), to deal in the Software without restriction, including
726
- without limitation the rights to use, copy, modify, merge, publish,
727
- distribute, sublicense, and/or sell copies of the Software, and to
728
- permit persons to whom the Software is furnished to do so, subject to
729
- the following conditions:
730
-
731
- The above copyright notice and this permission notice shall be
732
- included in all copies or substantial portions of the Software.
733
-
734
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
735
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
736
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
737
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
738
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
739
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
740
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
741
-
742
- */
743
-
744
- (function (module) {
745
- (function (global, pool, math) {
746
- //
747
- // The following constants are related to IEEE 754 limits.
748
- //
749
-
750
- var width = 256, // each RC4 output is 0 <= x < 256
751
- chunks = 6, // at least six RC4 outputs for each double
752
- digits = 52, // there are 52 significant digits in a double
753
- rngname = 'random', // rngname: name for Math.random and Math.seedrandom
754
- startdenom = math.pow(width, chunks),
755
- significance = math.pow(2, digits),
756
- overflow = significance * 2,
757
- mask = width - 1,
758
- nodecrypto; // node.js crypto module, initialized at the bottom.
759
-
760
- //
761
- // seedrandom()
762
- // This is the seedrandom function described above.
763
- //
764
- function seedrandom(seed, options, callback) {
765
- var key = [];
766
- options = (options == true) ? { entropy: true } : (options || {});
767
-
768
- // Flatten the seed string or build one from local entropy if needed.
769
- var shortseed = mixkey(flatten(
770
- options.entropy ? [seed, tostring(pool)] :
771
- (seed == null) ? autoseed() : seed, 3), key);
772
-
773
- // Use the seed to initialize an ARC4 generator.
774
- var arc4 = new ARC4(key);
775
-
776
- // This function returns a random double in [0, 1) that contains
777
- // randomness in every bit of the mantissa of the IEEE 754 value.
778
- var prng = function() {
779
- var n = arc4.g(chunks), // Start with a numerator n < 2 ^ 48
780
- d = startdenom, // and denominator d = 2 ^ 48.
781
- x = 0; // and no 'extra last byte'.
782
- while (n < significance) { // Fill up all significant digits by
783
- n = (n + x) * width; // shifting numerator and
784
- d *= width; // denominator and generating a
785
- x = arc4.g(1); // new least-significant-byte.
786
- }
787
- while (n >= overflow) { // To avoid rounding up, before adding
788
- n /= 2; // last byte, shift everything
789
- d /= 2; // right using integer math until
790
- x >>>= 1; // we have exactly the desired bits.
791
- }
792
- return (n + x) / d; // Form the number within [0, 1).
793
- };
794
-
795
- prng.int32 = function() { return arc4.g(4) | 0; };
796
- prng.quick = function() { return arc4.g(4) / 0x100000000; };
797
- prng.double = prng;
798
-
799
- // Mix the randomness into accumulated entropy.
800
- mixkey(tostring(arc4.S), pool);
801
-
802
- // Calling convention: what to return as a function of prng, seed, is_math.
803
- return (options.pass || callback ||
804
- function(prng, seed, is_math_call, state) {
805
- if (state) {
806
- // Load the arc4 state from the given state if it has an S array.
807
- if (state.S) { copy(state, arc4); }
808
- // Only provide the .state method if requested via options.state.
809
- prng.state = function() { return copy(arc4, {}); };
810
- }
811
-
812
- // If called as a method of Math (Math.seedrandom()), mutate
813
- // Math.random because that is how seedrandom.js has worked since v1.0.
814
- if (is_math_call) { math[rngname] = prng; return seed; }
815
-
816
- // Otherwise, it is a newer calling convention, so return the
817
- // prng directly.
818
- else return prng;
819
- })(
820
- prng,
821
- shortseed,
822
- 'global' in options ? options.global : (this == math),
823
- options.state);
824
- }
825
-
826
- //
827
- // ARC4
828
- //
829
- // An ARC4 implementation. The constructor takes a key in the form of
830
- // an array of at most (width) integers that should be 0 <= x < (width).
831
- //
832
- // The g(count) method returns a pseudorandom integer that concatenates
833
- // the next (count) outputs from ARC4. Its return value is a number x
834
- // that is in the range 0 <= x < (width ^ count).
835
- //
836
- function ARC4(key) {
837
- var t, keylen = key.length,
838
- me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
839
-
840
- // The empty key [] is treated as [0].
841
- if (!keylen) { key = [keylen++]; }
842
-
843
- // Set up S using the standard key scheduling algorithm.
844
- while (i < width) {
845
- s[i] = i++;
846
- }
847
- for (i = 0; i < width; i++) {
848
- s[i] = s[j = mask & (j + key[i % keylen] + (t = s[i]))];
849
- s[j] = t;
850
- }
851
-
852
- // The "g" method returns the next (count) outputs as one number.
853
- (me.g = function(count) {
854
- // Using instance members instead of closure state nearly doubles speed.
855
- var t, r = 0,
856
- i = me.i, j = me.j, s = me.S;
857
- while (count--) {
858
- t = s[i = mask & (i + 1)];
859
- r = r * width + s[mask & ((s[i] = s[j = mask & (j + t)]) + (s[j] = t))];
860
- }
861
- me.i = i; me.j = j;
862
- return r;
863
- // For robust unpredictability, the function call below automatically
864
- // discards an initial batch of values. This is called RC4-drop[256].
865
- // See http://google.com/search?q=rsa+fluhrer+response&btnI
866
- })(width);
867
- }
868
-
869
- //
870
- // copy()
871
- // Copies internal state of ARC4 to or from a plain object.
872
- //
873
- function copy(f, t) {
874
- t.i = f.i;
875
- t.j = f.j;
876
- t.S = f.S.slice();
877
- return t;
878
- }
879
- //
880
- // flatten()
881
- // Converts an object tree to nested arrays of strings.
882
- //
883
- function flatten(obj, depth) {
884
- var result = [], typ = (typeof obj), prop;
885
- if (depth && typ == 'object') {
886
- for (prop in obj) {
887
- try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {}
888
- }
889
- }
890
- return (result.length ? result : typ == 'string' ? obj : obj + '\0');
891
- }
892
-
893
- //
894
- // mixkey()
895
- // Mixes a string seed into a key that is an array of integers, and
896
- // returns a shortened string seed that is equivalent to the result key.
897
- //
898
- function mixkey(seed, key) {
899
- var stringseed = seed + '', smear, j = 0;
900
- while (j < stringseed.length) {
901
- key[mask & j] =
902
- mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
903
- }
904
- return tostring(key);
905
- }
906
-
907
- //
908
- // autoseed()
909
- // Returns an object for autoseeding, using window.crypto and Node crypto
910
- // module if available.
911
- //
912
- function autoseed() {
913
- try {
914
- var out;
915
- if (nodecrypto && (out = nodecrypto.randomBytes)) {
916
- // The use of 'out' to remember randomBytes makes tight minified code.
917
- out = out(width);
918
- } else {
919
- out = new Uint8Array(width);
920
- (global.crypto || global.msCrypto).getRandomValues(out);
921
- }
922
- return tostring(out);
923
- } catch (e) {
924
- var browser = global.navigator,
925
- plugins = browser && browser.plugins;
926
- return [+new Date, global, plugins, global.screen, tostring(pool)];
927
- }
928
- }
929
-
930
- //
931
- // tostring()
932
- // Converts an array of charcodes to a string
933
- //
934
- function tostring(a) {
935
- return String.fromCharCode.apply(0, a);
936
- }
937
-
938
- //
939
- // When seedrandom.js is loaded, we immediately mix a few bits
940
- // from the built-in RNG into the entropy pool. Because we do
941
- // not want to interfere with deterministic PRNG state later,
942
- // seedrandom will not call math.random on its own again after
943
- // initialization.
944
- //
945
- mixkey(math.random(), pool);
946
-
947
- //
948
- // Nodejs and AMD support: export the implementation as a module using
949
- // either convention.
950
- //
951
- if (module.exports) {
952
- module.exports = seedrandom;
953
- // When in node.js, try using crypto package for autoseeding.
954
- try {
955
- nodecrypto = require('crypto');
956
- } catch (ex) {}
957
- } else {
958
- // When included as a plain script, set up Math.seedrandom global.
959
- math['seed' + rngname] = seedrandom;
960
- }
961
-
962
-
963
- // End anonymous scope, and pass initial values.
964
- })(
965
- // global: `self` in browsers (including strict mode and web workers),
966
- // otherwise `this` in Node and other environments
967
- (typeof self !== 'undefined') ? self : commonjsGlobal,
968
- [], // pool: entropy pool starts empty
969
- Math // math: package containing random, pow, and seedrandom
970
- );
971
- } (seedrandom$1));
972
-
973
- // A library of seedable RNGs implemented in Javascript.
974
- //
975
- // Usage:
976
- //
977
- // var seedrandom = require('seedrandom');
978
- // var random = seedrandom(1); // or any seed.
979
- // var x = random(); // 0 <= x < 1. Every bit is random.
980
- // var x = random.quick(); // 0 <= x < 1. 32 bits of randomness.
981
-
982
- // alea, a 53-bit multiply-with-carry generator by Johannes Baagøe.
983
- // Period: ~2^116
984
- // Reported to pass all BigCrush tests.
985
- var alea = alea$1.exports;
986
-
987
- // xor128, a pure xor-shift generator by George Marsaglia.
988
- // Period: 2^128-1.
989
- // Reported to fail: MatrixRank and LinearComp.
990
- var xor128 = xor128$1.exports;
991
-
992
- // xorwow, George Marsaglia's 160-bit xor-shift combined plus weyl.
993
- // Period: 2^192-2^32
994
- // Reported to fail: CollisionOver, SimpPoker, and LinearComp.
995
- var xorwow = xorwow$1.exports;
996
-
997
- // xorshift7, by François Panneton and Pierre L'ecuyer, takes
998
- // a different approach: it adds robustness by allowing more shifts
999
- // than Marsaglia's original three. It is a 7-shift generator
1000
- // with 256 bits, that passes BigCrush with no systmatic failures.
1001
- // Period 2^256-1.
1002
- // No systematic BigCrush failures reported.
1003
- var xorshift7 = xorshift7$1.exports;
1004
-
1005
- // xor4096, by Richard Brent, is a 4096-bit xor-shift with a
1006
- // very long period that also adds a Weyl generator. It also passes
1007
- // BigCrush with no systematic failures. Its long period may
1008
- // be useful if you have many generators and need to avoid
1009
- // collisions.
1010
- // Period: 2^4128-2^32.
1011
- // No systematic BigCrush failures reported.
1012
- var xor4096 = xor4096$1.exports;
1013
-
1014
- // Tyche-i, by Samuel Neves and Filipe Araujo, is a bit-shifting random
1015
- // number generator derived from ChaCha, a modern stream cipher.
1016
- // https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
1017
- // Period: ~2^127
1018
- // No systematic BigCrush failures reported.
1019
- var tychei = tychei$1.exports;
1020
-
1021
- // The original ARC4-based prng included in this library.
1022
- // Period: ~2^1600
1023
- var sr = seedrandom$1.exports;
1024
-
1025
- sr.alea = alea;
1026
- sr.xor128 = xor128;
1027
- sr.xorwow = xorwow;
1028
- sr.xorshift7 = xorshift7;
1029
- sr.xor4096 = xor4096;
1030
- sr.tychei = tychei;
1031
-
1032
- var seedrandom = sr;
1033
-
1034
70
  /* global analytics */
1035
71
  const config = {
1036
72
  /* Your segment writeKey */
@@ -1040,7 +76,6 @@ const config = {
1040
76
  debug: false,
1041
77
  fetch: null,
1042
78
  };
1043
- const autoSeedRandom = seedrandom();
1044
79
  const parseQuery = (qs) => {
1045
80
  if (!qs) {
1046
81
  return {};
@@ -1273,7 +308,7 @@ function adjustPayload(payload, config, storage) {
1273
308
  },
1274
309
  campaign: parseUtms(query),
1275
310
  };
1276
- const withContext = Object.assign(Object.assign({}, payload), { timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(), context: deepMerge(context, customContext) });
311
+ const withContext = Object.assign(Object.assign({}, payload), { timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), context: deepMerge(context, customContext) });
1277
312
  delete withContext.meta;
1278
313
  delete withContext.options;
1279
314
  return withContext;
@@ -1356,21 +391,24 @@ const jitsuAnalyticsPlugin = (pluginConfig = {}) => {
1356
391
  },
1357
392
  };
1358
393
  };
1359
- function randomId(digits = 24) {
1360
- let id = "";
1361
- for (let i = 0; i < digits; i++) {
1362
- id += randomChar(i === 0, autoSeedRandom);
1363
- }
1364
- return id;
394
+ function randomId(hashString = "") {
395
+ var _a, _b;
396
+ const d = new Date().getTime();
397
+ return (((Math.random() * d * hash(hashString !== null && hashString !== void 0 ? hashString : "", ((_a = window === null || window === void 0 ? void 0 : window.performance) === null || _a === void 0 ? void 0 : _a.now()) || d % 2147483647)) %
398
+ Number.MAX_SAFE_INTEGER).toString(36) +
399
+ ((Math.random() * d * hash(hashString !== null && hashString !== void 0 ? hashString : "", ((_b = window === null || window === void 0 ? void 0 : window.performance) === null || _b === void 0 ? void 0 : _b.now()) || d % 2147483647)) %
400
+ Number.MAX_SAFE_INTEGER).toString(36));
1365
401
  }
1366
- function randomChar(noDigits, rng = Math.random) {
1367
- const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1368
- while (true) {
1369
- const index = Math.floor(rng() * chars.length);
1370
- if (!noDigits || index > 9) {
1371
- return chars[index];
1372
- }
402
+ function hash(str, seed = 0) {
403
+ let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
404
+ for (let i = 0, ch; i < str.length; i++) {
405
+ ch = str.charCodeAt(i);
406
+ h1 = Math.imul(h1 ^ ch, 2654435761);
407
+ h2 = Math.imul(h2 ^ ch, 1597334677);
1373
408
  }
409
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
410
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
411
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
1374
412
  }
1375
413
 
1376
414
  function parse(input) {