@bigbinary/neeto-commons-frontend 2.0.88 → 2.0.90

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.
@@ -3482,18 +3482,6 @@ var usePrevious = function usePrevious(value) {
3482
3482
  return ref.current;
3483
3483
  };
3484
3484
 
3485
- var useStateWithDependency = function useStateWithDependency(defaultValue) {
3486
- var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [defaultValue];
3487
- var _useState = React.useState(defaultValue),
3488
- _useState2 = _slicedToArray(_useState, 2),
3489
- value = _useState2[0],
3490
- setValue = _useState2[1];
3491
- React.useEffect(function () {
3492
- setValue(defaultValue);
3493
- }, dependencies);
3494
- return [value, setValue];
3495
- };
3496
-
3497
3485
  function _typeof$1(obj) {
3498
3486
  "@babel/helpers - typeof";
3499
3487
 
@@ -3535,582 +3523,53 @@ function _defineProperty(obj, key, value) {
3535
3523
  return obj;
3536
3524
  }
3537
3525
 
3538
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
3539
- // require the crypto API and do not support built-in fallback to lower quality random number
3540
- // generators (like Math.random()).
3541
- let getRandomValues;
3542
- const rnds8 = new Uint8Array(16);
3543
- function rng() {
3544
- // lazy load so that environments that need to polyfill have a chance to do so
3545
- if (!getRandomValues) {
3546
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
3547
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
3548
-
3549
- if (!getRandomValues) {
3550
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
3551
- }
3552
- }
3553
-
3554
- return getRandomValues(rnds8);
3555
- }
3556
-
3557
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
3558
-
3559
- function validate(uuid) {
3560
- return typeof uuid === 'string' && REGEX.test(uuid);
3561
- }
3562
-
3563
- /**
3564
- * Convert array of 16 byte values to UUID string format of the form:
3565
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
3566
- */
3567
-
3568
- const byteToHex = [];
3569
-
3570
- for (let i = 0; i < 256; ++i) {
3571
- byteToHex.push((i + 0x100).toString(16).slice(1));
3572
- }
3573
-
3574
- function unsafeStringify(arr, offset = 0) {
3575
- // Note: Be careful editing this code! It's been tuned for performance
3576
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
3577
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
3578
- }
3579
-
3580
- function parse(uuid) {
3581
- if (!validate(uuid)) {
3582
- throw TypeError('Invalid UUID');
3526
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3527
+ try {
3528
+ var info = gen[key](arg);
3529
+ var value = info.value;
3530
+ } catch (error) {
3531
+ reject(error);
3532
+ return;
3583
3533
  }
3584
-
3585
- let v;
3586
- const arr = new Uint8Array(16); // Parse ########-....-....-....-............
3587
-
3588
- arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
3589
- arr[1] = v >>> 16 & 0xff;
3590
- arr[2] = v >>> 8 & 0xff;
3591
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
3592
-
3593
- arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
3594
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
3595
-
3596
- arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
3597
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
3598
-
3599
- arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
3600
- arr[9] = v & 0xff; // Parse ........-....-....-....-############
3601
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
3602
-
3603
- arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
3604
- arr[11] = v / 0x100000000 & 0xff;
3605
- arr[12] = v >>> 24 & 0xff;
3606
- arr[13] = v >>> 16 & 0xff;
3607
- arr[14] = v >>> 8 & 0xff;
3608
- arr[15] = v & 0xff;
3609
- return arr;
3610
- }
3611
-
3612
- function stringToBytes(str) {
3613
- str = unescape(encodeURIComponent(str)); // UTF8 escape
3614
-
3615
- const bytes = [];
3616
-
3617
- for (let i = 0; i < str.length; ++i) {
3618
- bytes.push(str.charCodeAt(i));
3534
+ if (info.done) {
3535
+ resolve(value);
3536
+ } else {
3537
+ Promise.resolve(value).then(_next, _throw);
3619
3538
  }
3620
-
3621
- return bytes;
3622
3539
  }
3623
-
3624
- const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
3625
- const URL$1 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
3626
- function v35(name, version, hashfunc) {
3627
- function generateUUID(value, namespace, buf, offset) {
3628
- var _namespace;
3629
-
3630
- if (typeof value === 'string') {
3631
- value = stringToBytes(value);
3632
- }
3633
-
3634
- if (typeof namespace === 'string') {
3635
- namespace = parse(namespace);
3636
- }
3637
-
3638
- if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
3639
- throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
3640
- } // Compute hash of namespace and value, Per 4.3
3641
- // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
3642
- // hashfunc([...namespace, ... value])`
3643
-
3644
-
3645
- let bytes = new Uint8Array(16 + value.length);
3646
- bytes.set(namespace);
3647
- bytes.set(value, namespace.length);
3648
- bytes = hashfunc(bytes);
3649
- bytes[6] = bytes[6] & 0x0f | version;
3650
- bytes[8] = bytes[8] & 0x3f | 0x80;
3651
-
3652
- if (buf) {
3653
- offset = offset || 0;
3654
-
3655
- for (let i = 0; i < 16; ++i) {
3656
- buf[offset + i] = bytes[i];
3540
+ function _asyncToGenerator(fn) {
3541
+ return function () {
3542
+ var self = this,
3543
+ args = arguments;
3544
+ return new Promise(function (resolve, reject) {
3545
+ var gen = fn.apply(self, args);
3546
+ function _next(value) {
3547
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
3657
3548
  }
3658
-
3659
- return buf;
3660
- }
3661
-
3662
- return unsafeStringify(bytes);
3663
- } // Function#name is not settable on some platforms (#270)
3664
-
3665
-
3666
- try {
3667
- generateUUID.name = name; // eslint-disable-next-line no-empty
3668
- } catch (err) {} // For CommonJS default export support
3669
-
3670
-
3671
- generateUUID.DNS = DNS;
3672
- generateUUID.URL = URL$1;
3673
- return generateUUID;
3674
- }
3675
-
3676
- /*
3677
- * Browser-compatible JavaScript MD5
3678
- *
3679
- * Modification of JavaScript MD5
3680
- * https://github.com/blueimp/JavaScript-MD5
3681
- *
3682
- * Copyright 2011, Sebastian Tschan
3683
- * https://blueimp.net
3684
- *
3685
- * Licensed under the MIT license:
3686
- * https://opensource.org/licenses/MIT
3687
- *
3688
- * Based on
3689
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
3690
- * Digest Algorithm, as defined in RFC 1321.
3691
- * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
3692
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
3693
- * Distributed under the BSD License
3694
- * See http://pajhome.org.uk/crypt/md5 for more info.
3695
- */
3696
- function md5(bytes) {
3697
- if (typeof bytes === 'string') {
3698
- const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
3699
-
3700
- bytes = new Uint8Array(msg.length);
3701
-
3702
- for (let i = 0; i < msg.length; ++i) {
3703
- bytes[i] = msg.charCodeAt(i);
3704
- }
3705
- }
3706
-
3707
- return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
3708
- }
3709
- /*
3710
- * Convert an array of little-endian words to an array of bytes
3711
- */
3712
-
3713
-
3714
- function md5ToHexEncodedArray(input) {
3715
- const output = [];
3716
- const length32 = input.length * 32;
3717
- const hexTab = '0123456789abcdef';
3718
-
3719
- for (let i = 0; i < length32; i += 8) {
3720
- const x = input[i >> 5] >>> i % 32 & 0xff;
3721
- const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
3722
- output.push(hex);
3723
- }
3724
-
3725
- return output;
3549
+ function _throw(err) {
3550
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
3551
+ }
3552
+ _next(undefined);
3553
+ });
3554
+ };
3726
3555
  }
3727
- /**
3728
- * Calculate output length with padding and bit length
3729
- */
3730
3556
 
3557
+ var regeneratorRuntime$1 = {exports: {}};
3731
3558
 
3732
- function getOutputLength(inputLength8) {
3733
- return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
3734
- }
3735
- /*
3736
- * Calculate the MD5 of an array of little-endian words, and a bit length.
3737
- */
3559
+ var _typeof = {exports: {}};
3738
3560
 
3561
+ (function (module) {
3562
+ function _typeof(obj) {
3563
+ "@babel/helpers - typeof";
3739
3564
 
3740
- function wordsToMd5(x, len) {
3741
- /* append padding */
3742
- x[len >> 5] |= 0x80 << len % 32;
3743
- x[getOutputLength(len) - 1] = len;
3744
- let a = 1732584193;
3745
- let b = -271733879;
3746
- let c = -1732584194;
3747
- let d = 271733878;
3748
-
3749
- for (let i = 0; i < x.length; i += 16) {
3750
- const olda = a;
3751
- const oldb = b;
3752
- const oldc = c;
3753
- const oldd = d;
3754
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
3755
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
3756
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
3757
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
3758
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
3759
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
3760
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
3761
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
3762
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
3763
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
3764
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
3765
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
3766
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
3767
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
3768
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
3769
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
3770
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
3771
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
3772
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
3773
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
3774
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
3775
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
3776
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
3777
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
3778
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
3779
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
3780
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
3781
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
3782
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
3783
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
3784
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
3785
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
3786
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
3787
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
3788
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
3789
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
3790
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
3791
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
3792
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
3793
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
3794
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
3795
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
3796
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
3797
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
3798
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
3799
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
3800
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
3801
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
3802
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
3803
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
3804
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
3805
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
3806
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
3807
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
3808
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
3809
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
3810
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
3811
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
3812
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
3813
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
3814
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
3815
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
3816
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
3817
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
3818
- a = safeAdd(a, olda);
3819
- b = safeAdd(b, oldb);
3820
- c = safeAdd(c, oldc);
3821
- d = safeAdd(d, oldd);
3822
- }
3823
-
3824
- return [a, b, c, d];
3825
- }
3826
- /*
3827
- * Convert an array bytes to an array of little-endian words
3828
- * Characters >255 have their high-byte silently ignored.
3829
- */
3830
-
3831
-
3832
- function bytesToWords(input) {
3833
- if (input.length === 0) {
3834
- return [];
3835
- }
3836
-
3837
- const length8 = input.length * 8;
3838
- const output = new Uint32Array(getOutputLength(length8));
3839
-
3840
- for (let i = 0; i < length8; i += 8) {
3841
- output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
3842
- }
3843
-
3844
- return output;
3845
- }
3846
- /*
3847
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
3848
- * to work around bugs in some JS interpreters.
3849
- */
3850
-
3851
-
3852
- function safeAdd(x, y) {
3853
- const lsw = (x & 0xffff) + (y & 0xffff);
3854
- const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
3855
- return msw << 16 | lsw & 0xffff;
3856
- }
3857
- /*
3858
- * Bitwise rotate a 32-bit number to the left.
3859
- */
3860
-
3861
-
3862
- function bitRotateLeft(num, cnt) {
3863
- return num << cnt | num >>> 32 - cnt;
3864
- }
3865
- /*
3866
- * These functions implement the four basic operations the algorithm uses.
3867
- */
3868
-
3869
-
3870
- function md5cmn(q, a, b, x, s, t) {
3871
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
3872
- }
3873
-
3874
- function md5ff(a, b, c, d, x, s, t) {
3875
- return md5cmn(b & c | ~b & d, a, b, x, s, t);
3876
- }
3877
-
3878
- function md5gg(a, b, c, d, x, s, t) {
3879
- return md5cmn(b & d | c & ~d, a, b, x, s, t);
3880
- }
3881
-
3882
- function md5hh(a, b, c, d, x, s, t) {
3883
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
3884
- }
3885
-
3886
- function md5ii(a, b, c, d, x, s, t) {
3887
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
3888
- }
3889
-
3890
- v35('v3', 0x30, md5);
3891
-
3892
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
3893
- var native = {
3894
- randomUUID
3895
- };
3896
-
3897
- function v4(options, buf, offset) {
3898
- if (native.randomUUID && !buf && !options) {
3899
- return native.randomUUID();
3900
- }
3901
-
3902
- options = options || {};
3903
- const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
3904
-
3905
- rnds[6] = rnds[6] & 0x0f | 0x40;
3906
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
3907
-
3908
- if (buf) {
3909
- offset = offset || 0;
3910
-
3911
- for (let i = 0; i < 16; ++i) {
3912
- buf[offset + i] = rnds[i];
3913
- }
3914
-
3915
- return buf;
3916
- }
3917
-
3918
- return unsafeStringify(rnds);
3919
- }
3920
-
3921
- // Adapted from Chris Veness' SHA1 code at
3922
- // http://www.movable-type.co.uk/scripts/sha1.html
3923
- function f(s, x, y, z) {
3924
- switch (s) {
3925
- case 0:
3926
- return x & y ^ ~x & z;
3927
-
3928
- case 1:
3929
- return x ^ y ^ z;
3930
-
3931
- case 2:
3932
- return x & y ^ x & z ^ y & z;
3933
-
3934
- case 3:
3935
- return x ^ y ^ z;
3936
- }
3937
- }
3938
-
3939
- function ROTL(x, n) {
3940
- return x << n | x >>> 32 - n;
3941
- }
3942
-
3943
- function sha1(bytes) {
3944
- const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
3945
- const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
3946
-
3947
- if (typeof bytes === 'string') {
3948
- const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
3949
-
3950
- bytes = [];
3951
-
3952
- for (let i = 0; i < msg.length; ++i) {
3953
- bytes.push(msg.charCodeAt(i));
3954
- }
3955
- } else if (!Array.isArray(bytes)) {
3956
- // Convert Array-like to Array
3957
- bytes = Array.prototype.slice.call(bytes);
3958
- }
3959
-
3960
- bytes.push(0x80);
3961
- const l = bytes.length / 4 + 2;
3962
- const N = Math.ceil(l / 16);
3963
- const M = new Array(N);
3964
-
3965
- for (let i = 0; i < N; ++i) {
3966
- const arr = new Uint32Array(16);
3967
-
3968
- for (let j = 0; j < 16; ++j) {
3969
- arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
3970
- }
3971
-
3972
- M[i] = arr;
3973
- }
3974
-
3975
- M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
3976
- M[N - 1][14] = Math.floor(M[N - 1][14]);
3977
- M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
3978
-
3979
- for (let i = 0; i < N; ++i) {
3980
- const W = new Uint32Array(80);
3981
-
3982
- for (let t = 0; t < 16; ++t) {
3983
- W[t] = M[i][t];
3984
- }
3985
-
3986
- for (let t = 16; t < 80; ++t) {
3987
- W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
3988
- }
3989
-
3990
- let a = H[0];
3991
- let b = H[1];
3992
- let c = H[2];
3993
- let d = H[3];
3994
- let e = H[4];
3995
-
3996
- for (let t = 0; t < 80; ++t) {
3997
- const s = Math.floor(t / 20);
3998
- const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
3999
- e = d;
4000
- d = c;
4001
- c = ROTL(b, 30) >>> 0;
4002
- b = a;
4003
- a = T;
4004
- }
4005
-
4006
- H[0] = H[0] + a >>> 0;
4007
- H[1] = H[1] + b >>> 0;
4008
- H[2] = H[2] + c >>> 0;
4009
- H[3] = H[3] + d >>> 0;
4010
- H[4] = H[4] + e >>> 0;
4011
- }
4012
-
4013
- return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
4014
- }
4015
-
4016
- v35('v5', 0x50, sha1);
4017
-
4018
- var useTimerStore = create$1(function () {
4019
- return {};
4020
- });
4021
- setInterval(function () {
4022
- var currentState = useTimerStore.getState();
4023
- var nextState = {};
4024
- var now = Date.now();
4025
- for (var key in currentState) {
4026
- var _currentState$key = currentState[key],
4027
- lastUpdated = _currentState$key.lastUpdated,
4028
- interval = _currentState$key.interval;
4029
- var shouldUpdate = now - lastUpdated >= interval;
4030
- if (shouldUpdate) nextState[key] = {
4031
- lastUpdated: now,
4032
- interval: interval
4033
- };
4034
- }
4035
- if (!ramda.isEmpty(nextState)) useTimerStore.setState(nextState);
4036
- }, 1000);
4037
- var useTimer = function useTimer() {
4038
- var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 60;
4039
- var key = React.useMemo(function () {
4040
- return v4();
4041
- }, []);
4042
- React.useEffect(function () {
4043
- useTimerStore.setState(_defineProperty({}, key, {
4044
- lastUpdated: Date.now(),
4045
- interval: 1000 * interval // convert seconds to ms
4046
- }));
4047
-
4048
- return function () {
4049
- return useTimerStore.setState(ramda.omit([key], useTimerStore.getState()), true);
4050
- };
4051
- }, [interval, key]);
4052
- return useTimerStore(ramda.prop(key));
4053
- };
4054
-
4055
- var useUpdateEffect = function useUpdateEffect(callback) {
4056
- var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4057
- var isInitialMount = React.useRef(true);
4058
- React.useEffect(function () {
4059
- if (isInitialMount.current) {
4060
- isInitialMount.current = false;
4061
- return;
4062
- }
4063
- callback();
4064
- }, dependencies);
4065
- };
4066
-
4067
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4068
- try {
4069
- var info = gen[key](arg);
4070
- var value = info.value;
4071
- } catch (error) {
4072
- reject(error);
4073
- return;
4074
- }
4075
- if (info.done) {
4076
- resolve(value);
4077
- } else {
4078
- Promise.resolve(value).then(_next, _throw);
4079
- }
4080
- }
4081
- function _asyncToGenerator(fn) {
4082
- return function () {
4083
- var self = this,
4084
- args = arguments;
4085
- return new Promise(function (resolve, reject) {
4086
- var gen = fn.apply(self, args);
4087
- function _next(value) {
4088
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
4089
- }
4090
- function _throw(err) {
4091
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
4092
- }
4093
- _next(undefined);
4094
- });
4095
- };
4096
- }
4097
-
4098
- var regeneratorRuntime$1 = {exports: {}};
4099
-
4100
- var _typeof = {exports: {}};
4101
-
4102
- (function (module) {
4103
- function _typeof(obj) {
4104
- "@babel/helpers - typeof";
4105
-
4106
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
4107
- return typeof obj;
4108
- } : function (obj) {
4109
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
4110
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
4111
- }
4112
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
4113
- } (_typeof));
3565
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
3566
+ return typeof obj;
3567
+ } : function (obj) {
3568
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
3569
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
3570
+ }
3571
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
3572
+ } (_typeof));
4114
3573
 
4115
3574
  (function (module) {
4116
3575
  var _typeof$1 = _typeof.exports["default"];
@@ -4418,303 +3877,862 @@ var _typeof = {exports: {}};
4418
3877
  module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
4419
3878
  } (regeneratorRuntime$1));
4420
3879
 
4421
- // TODO(Babel 8): Remove this file.
3880
+ // TODO(Babel 8): Remove this file.
3881
+
3882
+ var runtime = regeneratorRuntime$1.exports();
3883
+ var regenerator = runtime;
3884
+
3885
+ // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
3886
+ try {
3887
+ regeneratorRuntime = runtime;
3888
+ } catch (accidentalStrictMode) {
3889
+ if (typeof globalThis === "object") {
3890
+ globalThis.regeneratorRuntime = runtime;
3891
+ } else {
3892
+ Function("r", "regeneratorRuntime = r")(runtime);
3893
+ }
3894
+ }
3895
+
3896
+ // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
3897
+ var devicesBaseUrl = "/neeto_notifications/api/v1/devices";
3898
+ var create = function create(payload) {
3899
+ return axios__default["default"].post(devicesBaseUrl, payload);
3900
+ };
3901
+ var destroy = function destroy(deviceId) {
3902
+ return axios__default["default"]["delete"]("".concat(devicesBaseUrl, "/").concat(deviceId));
3903
+ };
3904
+ var devicesApi = {
3905
+ create: create,
3906
+ destroy: destroy
3907
+ };
3908
+
3909
+ // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
3910
+ // AND IS USED FOR BROWSER NOTIFICATIONS
3911
+ // CONTACT NEETO NOTIFICATIONS TEAM BEFORE MODIFYING THIS FILE
3912
+
3913
+ function urlB64ToUint8Array(base64String) {
3914
+ var padding = "=".repeat((4 - base64String.length % 4) % 4);
3915
+ var base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
3916
+ var rawData = window.atob(base64);
3917
+ var outputArray = new Uint8Array(rawData.length);
3918
+ for (var i = 0; i < rawData.length; ++i) {
3919
+ outputArray[i] = rawData.charCodeAt(i);
3920
+ }
3921
+ return outputArray;
3922
+ }
3923
+ var subscribeBrowserNotifications = /*#__PURE__*/function () {
3924
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(vapidPublicKey) {
3925
+ var subscription, permission, sw;
3926
+ return regenerator.wrap(function _callee$(_context) {
3927
+ while (1) switch (_context.prev = _context.next) {
3928
+ case 0:
3929
+ subscription = {};
3930
+ _context.prev = 1;
3931
+ _context.next = 4;
3932
+ return Notification.requestPermission();
3933
+ case 4:
3934
+ permission = _context.sent;
3935
+ if (!(permission !== "denied")) {
3936
+ _context.next = 15;
3937
+ break;
3938
+ }
3939
+ _context.next = 8;
3940
+ return navigator.serviceWorker.register("/serviceworker.js");
3941
+ case 8:
3942
+ _context.next = 10;
3943
+ return navigator.serviceWorker.ready;
3944
+ case 10:
3945
+ sw = _context.sent;
3946
+ _context.next = 13;
3947
+ return sw.pushManager.subscribe({
3948
+ userVisibleOnly: true,
3949
+ applicationServerKey: urlB64ToUint8Array(vapidPublicKey)
3950
+ });
3951
+ case 13:
3952
+ subscription = _context.sent;
3953
+ return _context.abrupt("return", subscription);
3954
+ case 15:
3955
+ logger.error("Notification Permission Denied");
3956
+ _context.next = 21;
3957
+ break;
3958
+ case 18:
3959
+ _context.prev = 18;
3960
+ _context.t0 = _context["catch"](1);
3961
+ logger.error(_context.t0);
3962
+ case 21:
3963
+ return _context.abrupt("return", null);
3964
+ case 22:
3965
+ case "end":
3966
+ return _context.stop();
3967
+ }
3968
+ }, _callee, null, [[1, 18]]);
3969
+ }));
3970
+ return function subscribeBrowserNotifications(_x) {
3971
+ return _ref.apply(this, arguments);
3972
+ };
3973
+ }();
3974
+ var unsubscribeBrowserNotifications = /*#__PURE__*/function () {
3975
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
3976
+ var sw, subscription, res;
3977
+ return regenerator.wrap(function _callee2$(_context2) {
3978
+ while (1) switch (_context2.prev = _context2.next) {
3979
+ case 0:
3980
+ _context2.prev = 0;
3981
+ _context2.next = 3;
3982
+ return navigator.serviceWorker.ready;
3983
+ case 3:
3984
+ sw = _context2.sent;
3985
+ _context2.next = 6;
3986
+ return sw.pushManager.getSubscription();
3987
+ case 6:
3988
+ subscription = _context2.sent;
3989
+ if (!subscription) {
3990
+ _context2.next = 12;
3991
+ break;
3992
+ }
3993
+ _context2.next = 10;
3994
+ return subscription.unsubscribe();
3995
+ case 10:
3996
+ res = _context2.sent;
3997
+ logger.error(res);
3998
+ case 12:
3999
+ _context2.next = 17;
4000
+ break;
4001
+ case 14:
4002
+ _context2.prev = 14;
4003
+ _context2.t0 = _context2["catch"](0);
4004
+ logger.error(_context2.t0);
4005
+ case 17:
4006
+ case "end":
4007
+ return _context2.stop();
4008
+ }
4009
+ }, _callee2, null, [[0, 14]]);
4010
+ }));
4011
+ return function unsubscribeBrowserNotifications() {
4012
+ return _ref2.apply(this, arguments);
4013
+ };
4014
+ }();
4015
+ var registerServiceWorker = /*#__PURE__*/function () {
4016
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(vapidPublicKey) {
4017
+ var res;
4018
+ return regenerator.wrap(function _callee3$(_context3) {
4019
+ while (1) switch (_context3.prev = _context3.next) {
4020
+ case 0:
4021
+ if (!(navigator.serviceWorker && vapidPublicKey)) {
4022
+ _context3.next = 5;
4023
+ break;
4024
+ }
4025
+ _context3.next = 3;
4026
+ return subscribeBrowserNotifications(vapidPublicKey);
4027
+ case 3:
4028
+ res = _context3.sent;
4029
+ return _context3.abrupt("return", res);
4030
+ case 5:
4031
+ logger.error("Service worker is not supported in this Browser");
4032
+ return _context3.abrupt("return", null);
4033
+ case 7:
4034
+ case "end":
4035
+ return _context3.stop();
4036
+ }
4037
+ }, _callee3);
4038
+ }));
4039
+ return function registerServiceWorker(_x2) {
4040
+ return _ref3.apply(this, arguments);
4041
+ };
4042
+ }();
4043
+
4044
+ var createBrowserSubscription = /*#__PURE__*/function () {
4045
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(subscription) {
4046
+ var payload;
4047
+ return regenerator.wrap(function _callee$(_context) {
4048
+ while (1) switch (_context.prev = _context.next) {
4049
+ case 0:
4050
+ if (!subscription) {
4051
+ _context.next = 13;
4052
+ break;
4053
+ }
4054
+ payload = {
4055
+ device: {
4056
+ subscription: subscription,
4057
+ platform: "browser"
4058
+ }
4059
+ };
4060
+ _context.prev = 2;
4061
+ _context.next = 5;
4062
+ return devicesApi.create(payload);
4063
+ case 5:
4064
+ localStorage.setItem("deviceId", JSON.stringify(subscription.toJSON().keys.auth));
4065
+ _context.next = 11;
4066
+ break;
4067
+ case 8:
4068
+ _context.prev = 8;
4069
+ _context.t0 = _context["catch"](2);
4070
+ logger.error("Device registration Failed: ", _context.t0);
4071
+ case 11:
4072
+ _context.next = 14;
4073
+ break;
4074
+ case 13:
4075
+ logger.error("Something went wrong while registering device for browser subscription");
4076
+ case 14:
4077
+ case "end":
4078
+ return _context.stop();
4079
+ }
4080
+ }, _callee, null, [[2, 8]]);
4081
+ }));
4082
+ return function createBrowserSubscription(_x) {
4083
+ return _ref.apply(this, arguments);
4084
+ };
4085
+ }();
4086
+ var destroyBrowserSubscription = /*#__PURE__*/function () {
4087
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
4088
+ var deviceId;
4089
+ return regenerator.wrap(function _callee2$(_context2) {
4090
+ while (1) switch (_context2.prev = _context2.next) {
4091
+ case 0:
4092
+ _context2.prev = 0;
4093
+ _context2.next = 3;
4094
+ return unsubscribeBrowserNotifications();
4095
+ case 3:
4096
+ deviceId = JSON.parse(localStorage.getItem("deviceId"));
4097
+ _context2.next = 6;
4098
+ return devicesApi.destroy(deviceId);
4099
+ case 6:
4100
+ localStorage.removeItem("deviceId");
4101
+ _context2.next = 12;
4102
+ break;
4103
+ case 9:
4104
+ _context2.prev = 9;
4105
+ _context2.t0 = _context2["catch"](0);
4106
+ logger.error("Something went wrong while unsubscribing browser notification:", _context2.t0);
4107
+ case 12:
4108
+ case "end":
4109
+ return _context2.stop();
4110
+ }
4111
+ }, _callee2, null, [[0, 9]]);
4112
+ }));
4113
+ return function destroyBrowserSubscription() {
4114
+ return _ref2.apply(this, arguments);
4115
+ };
4116
+ }();
4117
+ var registerBrowserNotifications = /*#__PURE__*/function () {
4118
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
4119
+ var vapidPublicKey,
4120
+ response,
4121
+ _args3 = arguments;
4122
+ return regenerator.wrap(function _callee3$(_context3) {
4123
+ while (1) switch (_context3.prev = _context3.next) {
4124
+ case 0:
4125
+ vapidPublicKey = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.env.VAPID_PUBLIC_KEY;
4126
+ _context3.next = 3;
4127
+ return registerServiceWorker(vapidPublicKey);
4128
+ case 3:
4129
+ response = _context3.sent;
4130
+ _context3.next = 6;
4131
+ return createBrowserSubscription(response);
4132
+ case 6:
4133
+ case "end":
4134
+ return _context3.stop();
4135
+ }
4136
+ }, _callee3);
4137
+ }));
4138
+ return function registerBrowserNotifications() {
4139
+ return _ref3.apply(this, arguments);
4140
+ };
4141
+ }();
4142
+
4143
+ var handleMetaClick = ramda.curry(function (history, params, event) {
4144
+ return isMetaKeyPressed(event) ? window.open(params.pathname || params, "_blank") : history.push(params);
4145
+ });
4146
+ var isMetaKeyPressed = function isMetaKeyPressed(event) {
4147
+ return !!(event !== null && event !== void 0 && event.ctrlKey || event !== null && event !== void 0 && event.metaKey);
4148
+ };
4149
+
4150
+ var withTitle = function withTitle(Component) {
4151
+ var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
4152
+ var PageTitle = function PageTitle(props) {
4153
+ var pageTitle = title ? "".concat(title, " | ").concat(globalProps.appName) : globalProps.appName;
4154
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactHelmet.Helmet, null, /*#__PURE__*/React__default["default"].createElement("title", null, pageTitle)), /*#__PURE__*/React__default["default"].createElement(Component, props));
4155
+ };
4156
+ return PageTitle;
4157
+ };
4158
+
4159
+ var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
4160
+ return function (partial) {
4161
+ return set(function (previous) {
4162
+ if (typeof partial === "function") partial = partial(previous);
4163
+ var overwrittenActions = ramda.keys(partial).filter(function (key) {
4164
+ return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && partial[key] !== previous[key];
4165
+ });
4166
+ if (!ramda.isEmpty(overwrittenActions)) {
4167
+ throw new Error("Actions should not be modified. Touched action(s): ".concat(overwrittenActions.join(", ")));
4168
+ }
4169
+ return partial;
4170
+ }, false);
4171
+ };
4172
+ };
4173
+ var withImmutableActions = function withImmutableActions(config) {
4174
+ return function (set, get, api) {
4175
+ return config(setWithoutModifyingActions(set), get, api);
4176
+ };
4177
+ };
4178
+
4179
+ /** @type {import("neetocommons/react-utils").ZustandStoreHook} */
4180
+ var useCheckpointStore = create$1(withImmutableActions(function (set) {
4181
+ return {
4182
+ checkpoints: {},
4183
+ setCheckpoint: function setCheckpoint(key, path) {
4184
+ return set(ramda.mergeDeepLeft({
4185
+ checkpoints: _defineProperty({}, key, path)
4186
+ }));
4187
+ }
4188
+ };
4189
+ }));
4190
+ var useRegisterNavigationCheckpoint = function useRegisterNavigationCheckpoint() {
4191
+ return useCheckpointStore(ramda.prop("setCheckpoint"));
4192
+ };
4193
+ var useNavigationCheckpoint = function useNavigationCheckpoint(key) {
4194
+ return useCheckpointStore(ramda.path(["checkpoints", key]));
4195
+ };
4196
+
4197
+ var useStateWithDependency = function useStateWithDependency(defaultValue) {
4198
+ var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [defaultValue];
4199
+ var _useState = React.useState(defaultValue),
4200
+ _useState2 = _slicedToArray(_useState, 2),
4201
+ value = _useState2[0],
4202
+ setValue = _useState2[1];
4203
+ React.useEffect(function () {
4204
+ setValue(defaultValue);
4205
+ }, dependencies);
4206
+ return [value, setValue];
4207
+ };
4208
+
4209
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
4210
+ // require the crypto API and do not support built-in fallback to lower quality random number
4211
+ // generators (like Math.random()).
4212
+ let getRandomValues;
4213
+ const rnds8 = new Uint8Array(16);
4214
+ function rng() {
4215
+ // lazy load so that environments that need to polyfill have a chance to do so
4216
+ if (!getRandomValues) {
4217
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
4218
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
4219
+
4220
+ if (!getRandomValues) {
4221
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
4222
+ }
4223
+ }
4224
+
4225
+ return getRandomValues(rnds8);
4226
+ }
4227
+
4228
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
4229
+
4230
+ function validate(uuid) {
4231
+ return typeof uuid === 'string' && REGEX.test(uuid);
4232
+ }
4233
+
4234
+ /**
4235
+ * Convert array of 16 byte values to UUID string format of the form:
4236
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
4237
+ */
4238
+
4239
+ const byteToHex = [];
4240
+
4241
+ for (let i = 0; i < 256; ++i) {
4242
+ byteToHex.push((i + 0x100).toString(16).slice(1));
4243
+ }
4244
+
4245
+ function unsafeStringify(arr, offset = 0) {
4246
+ // Note: Be careful editing this code! It's been tuned for performance
4247
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
4248
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
4249
+ }
4250
+
4251
+ function parse(uuid) {
4252
+ if (!validate(uuid)) {
4253
+ throw TypeError('Invalid UUID');
4254
+ }
4255
+
4256
+ let v;
4257
+ const arr = new Uint8Array(16); // Parse ########-....-....-....-............
4258
+
4259
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
4260
+ arr[1] = v >>> 16 & 0xff;
4261
+ arr[2] = v >>> 8 & 0xff;
4262
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
4263
+
4264
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
4265
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
4266
+
4267
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
4268
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
4269
+
4270
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
4271
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
4272
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
4273
+
4274
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
4275
+ arr[11] = v / 0x100000000 & 0xff;
4276
+ arr[12] = v >>> 24 & 0xff;
4277
+ arr[13] = v >>> 16 & 0xff;
4278
+ arr[14] = v >>> 8 & 0xff;
4279
+ arr[15] = v & 0xff;
4280
+ return arr;
4281
+ }
4282
+
4283
+ function stringToBytes(str) {
4284
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
4285
+
4286
+ const bytes = [];
4287
+
4288
+ for (let i = 0; i < str.length; ++i) {
4289
+ bytes.push(str.charCodeAt(i));
4290
+ }
4291
+
4292
+ return bytes;
4293
+ }
4294
+
4295
+ const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
4296
+ const URL$1 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
4297
+ function v35(name, version, hashfunc) {
4298
+ function generateUUID(value, namespace, buf, offset) {
4299
+ var _namespace;
4300
+
4301
+ if (typeof value === 'string') {
4302
+ value = stringToBytes(value);
4303
+ }
4304
+
4305
+ if (typeof namespace === 'string') {
4306
+ namespace = parse(namespace);
4307
+ }
4308
+
4309
+ if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
4310
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
4311
+ } // Compute hash of namespace and value, Per 4.3
4312
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
4313
+ // hashfunc([...namespace, ... value])`
4314
+
4315
+
4316
+ let bytes = new Uint8Array(16 + value.length);
4317
+ bytes.set(namespace);
4318
+ bytes.set(value, namespace.length);
4319
+ bytes = hashfunc(bytes);
4320
+ bytes[6] = bytes[6] & 0x0f | version;
4321
+ bytes[8] = bytes[8] & 0x3f | 0x80;
4322
+
4323
+ if (buf) {
4324
+ offset = offset || 0;
4325
+
4326
+ for (let i = 0; i < 16; ++i) {
4327
+ buf[offset + i] = bytes[i];
4328
+ }
4329
+
4330
+ return buf;
4331
+ }
4332
+
4333
+ return unsafeStringify(bytes);
4334
+ } // Function#name is not settable on some platforms (#270)
4335
+
4336
+
4337
+ try {
4338
+ generateUUID.name = name; // eslint-disable-next-line no-empty
4339
+ } catch (err) {} // For CommonJS default export support
4340
+
4341
+
4342
+ generateUUID.DNS = DNS;
4343
+ generateUUID.URL = URL$1;
4344
+ return generateUUID;
4345
+ }
4346
+
4347
+ /*
4348
+ * Browser-compatible JavaScript MD5
4349
+ *
4350
+ * Modification of JavaScript MD5
4351
+ * https://github.com/blueimp/JavaScript-MD5
4352
+ *
4353
+ * Copyright 2011, Sebastian Tschan
4354
+ * https://blueimp.net
4355
+ *
4356
+ * Licensed under the MIT license:
4357
+ * https://opensource.org/licenses/MIT
4358
+ *
4359
+ * Based on
4360
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
4361
+ * Digest Algorithm, as defined in RFC 1321.
4362
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
4363
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
4364
+ * Distributed under the BSD License
4365
+ * See http://pajhome.org.uk/crypt/md5 for more info.
4366
+ */
4367
+ function md5(bytes) {
4368
+ if (typeof bytes === 'string') {
4369
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
4370
+
4371
+ bytes = new Uint8Array(msg.length);
4372
+
4373
+ for (let i = 0; i < msg.length; ++i) {
4374
+ bytes[i] = msg.charCodeAt(i);
4375
+ }
4376
+ }
4377
+
4378
+ return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
4379
+ }
4380
+ /*
4381
+ * Convert an array of little-endian words to an array of bytes
4382
+ */
4383
+
4384
+
4385
+ function md5ToHexEncodedArray(input) {
4386
+ const output = [];
4387
+ const length32 = input.length * 32;
4388
+ const hexTab = '0123456789abcdef';
4389
+
4390
+ for (let i = 0; i < length32; i += 8) {
4391
+ const x = input[i >> 5] >>> i % 32 & 0xff;
4392
+ const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
4393
+ output.push(hex);
4394
+ }
4395
+
4396
+ return output;
4397
+ }
4398
+ /**
4399
+ * Calculate output length with padding and bit length
4400
+ */
4401
+
4402
+
4403
+ function getOutputLength(inputLength8) {
4404
+ return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
4405
+ }
4406
+ /*
4407
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
4408
+ */
4409
+
4410
+
4411
+ function wordsToMd5(x, len) {
4412
+ /* append padding */
4413
+ x[len >> 5] |= 0x80 << len % 32;
4414
+ x[getOutputLength(len) - 1] = len;
4415
+ let a = 1732584193;
4416
+ let b = -271733879;
4417
+ let c = -1732584194;
4418
+ let d = 271733878;
4419
+
4420
+ for (let i = 0; i < x.length; i += 16) {
4421
+ const olda = a;
4422
+ const oldb = b;
4423
+ const oldc = c;
4424
+ const oldd = d;
4425
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
4426
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
4427
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
4428
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
4429
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
4430
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
4431
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
4432
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
4433
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
4434
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
4435
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
4436
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
4437
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
4438
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
4439
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
4440
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
4441
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
4442
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
4443
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
4444
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
4445
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
4446
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
4447
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
4448
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
4449
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
4450
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
4451
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
4452
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
4453
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
4454
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
4455
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
4456
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
4457
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
4458
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
4459
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
4460
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
4461
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
4462
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
4463
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
4464
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
4465
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
4466
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
4467
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
4468
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
4469
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
4470
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
4471
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
4472
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
4473
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
4474
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
4475
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
4476
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
4477
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
4478
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
4479
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
4480
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
4481
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
4482
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
4483
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
4484
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
4485
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
4486
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
4487
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
4488
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
4489
+ a = safeAdd(a, olda);
4490
+ b = safeAdd(b, oldb);
4491
+ c = safeAdd(c, oldc);
4492
+ d = safeAdd(d, oldd);
4493
+ }
4494
+
4495
+ return [a, b, c, d];
4496
+ }
4497
+ /*
4498
+ * Convert an array bytes to an array of little-endian words
4499
+ * Characters >255 have their high-byte silently ignored.
4500
+ */
4422
4501
 
4423
- var runtime = regeneratorRuntime$1.exports();
4424
- var regenerator = runtime;
4425
4502
 
4426
- // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
4427
- try {
4428
- regeneratorRuntime = runtime;
4429
- } catch (accidentalStrictMode) {
4430
- if (typeof globalThis === "object") {
4431
- globalThis.regeneratorRuntime = runtime;
4432
- } else {
4433
- Function("r", "regeneratorRuntime = r")(runtime);
4503
+ function bytesToWords(input) {
4504
+ if (input.length === 0) {
4505
+ return [];
4506
+ }
4507
+
4508
+ const length8 = input.length * 8;
4509
+ const output = new Uint32Array(getOutputLength(length8));
4510
+
4511
+ for (let i = 0; i < length8; i += 8) {
4512
+ output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
4434
4513
  }
4514
+
4515
+ return output;
4435
4516
  }
4517
+ /*
4518
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
4519
+ * to work around bugs in some JS interpreters.
4520
+ */
4436
4521
 
4437
- // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
4438
- var devicesBaseUrl = "/neeto_notifications/api/v1/devices";
4439
- var create = function create(payload) {
4440
- return axios__default["default"].post(devicesBaseUrl, payload);
4441
- };
4442
- var destroy = function destroy(deviceId) {
4443
- return axios__default["default"]["delete"]("".concat(devicesBaseUrl, "/").concat(deviceId));
4444
- };
4445
- var devicesApi = {
4446
- create: create,
4447
- destroy: destroy
4522
+
4523
+ function safeAdd(x, y) {
4524
+ const lsw = (x & 0xffff) + (y & 0xffff);
4525
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
4526
+ return msw << 16 | lsw & 0xffff;
4527
+ }
4528
+ /*
4529
+ * Bitwise rotate a 32-bit number to the left.
4530
+ */
4531
+
4532
+
4533
+ function bitRotateLeft(num, cnt) {
4534
+ return num << cnt | num >>> 32 - cnt;
4535
+ }
4536
+ /*
4537
+ * These functions implement the four basic operations the algorithm uses.
4538
+ */
4539
+
4540
+
4541
+ function md5cmn(q, a, b, x, s, t) {
4542
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
4543
+ }
4544
+
4545
+ function md5ff(a, b, c, d, x, s, t) {
4546
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
4547
+ }
4548
+
4549
+ function md5gg(a, b, c, d, x, s, t) {
4550
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
4551
+ }
4552
+
4553
+ function md5hh(a, b, c, d, x, s, t) {
4554
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
4555
+ }
4556
+
4557
+ function md5ii(a, b, c, d, x, s, t) {
4558
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
4559
+ }
4560
+
4561
+ v35('v3', 0x30, md5);
4562
+
4563
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
4564
+ var native = {
4565
+ randomUUID
4448
4566
  };
4449
4567
 
4450
- // THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
4451
- // AND IS USED FOR BROWSER NOTIFICATIONS
4452
- // CONTACT NEETO NOTIFICATIONS TEAM BEFORE MODIFYING THIS FILE
4568
+ function v4(options, buf, offset) {
4569
+ if (native.randomUUID && !buf && !options) {
4570
+ return native.randomUUID();
4571
+ }
4453
4572
 
4454
- function urlB64ToUint8Array(base64String) {
4455
- var padding = "=".repeat((4 - base64String.length % 4) % 4);
4456
- var base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
4457
- var rawData = window.atob(base64);
4458
- var outputArray = new Uint8Array(rawData.length);
4459
- for (var i = 0; i < rawData.length; ++i) {
4460
- outputArray[i] = rawData.charCodeAt(i);
4573
+ options = options || {};
4574
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
4575
+
4576
+ rnds[6] = rnds[6] & 0x0f | 0x40;
4577
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
4578
+
4579
+ if (buf) {
4580
+ offset = offset || 0;
4581
+
4582
+ for (let i = 0; i < 16; ++i) {
4583
+ buf[offset + i] = rnds[i];
4584
+ }
4585
+
4586
+ return buf;
4461
4587
  }
4462
- return outputArray;
4588
+
4589
+ return unsafeStringify(rnds);
4463
4590
  }
4464
- var subscribeBrowserNotifications = /*#__PURE__*/function () {
4465
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(vapidPublicKey) {
4466
- var subscription, permission, sw;
4467
- return regenerator.wrap(function _callee$(_context) {
4468
- while (1) switch (_context.prev = _context.next) {
4469
- case 0:
4470
- subscription = {};
4471
- _context.prev = 1;
4472
- _context.next = 4;
4473
- return Notification.requestPermission();
4474
- case 4:
4475
- permission = _context.sent;
4476
- if (!(permission !== "denied")) {
4477
- _context.next = 15;
4478
- break;
4479
- }
4480
- _context.next = 8;
4481
- return navigator.serviceWorker.register("/serviceworker.js");
4482
- case 8:
4483
- _context.next = 10;
4484
- return navigator.serviceWorker.ready;
4485
- case 10:
4486
- sw = _context.sent;
4487
- _context.next = 13;
4488
- return sw.pushManager.subscribe({
4489
- userVisibleOnly: true,
4490
- applicationServerKey: urlB64ToUint8Array(vapidPublicKey)
4491
- });
4492
- case 13:
4493
- subscription = _context.sent;
4494
- return _context.abrupt("return", subscription);
4495
- case 15:
4496
- logger.error("Notification Permission Denied");
4497
- _context.next = 21;
4498
- break;
4499
- case 18:
4500
- _context.prev = 18;
4501
- _context.t0 = _context["catch"](1);
4502
- logger.error(_context.t0);
4503
- case 21:
4504
- return _context.abrupt("return", null);
4505
- case 22:
4506
- case "end":
4507
- return _context.stop();
4508
- }
4509
- }, _callee, null, [[1, 18]]);
4510
- }));
4511
- return function subscribeBrowserNotifications(_x) {
4512
- return _ref.apply(this, arguments);
4513
- };
4514
- }();
4515
- var unsubscribeBrowserNotifications = /*#__PURE__*/function () {
4516
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
4517
- var sw, subscription, res;
4518
- return regenerator.wrap(function _callee2$(_context2) {
4519
- while (1) switch (_context2.prev = _context2.next) {
4520
- case 0:
4521
- _context2.prev = 0;
4522
- _context2.next = 3;
4523
- return navigator.serviceWorker.ready;
4524
- case 3:
4525
- sw = _context2.sent;
4526
- _context2.next = 6;
4527
- return sw.pushManager.getSubscription();
4528
- case 6:
4529
- subscription = _context2.sent;
4530
- if (!subscription) {
4531
- _context2.next = 12;
4532
- break;
4533
- }
4534
- _context2.next = 10;
4535
- return subscription.unsubscribe();
4536
- case 10:
4537
- res = _context2.sent;
4538
- logger.error(res);
4539
- case 12:
4540
- _context2.next = 17;
4541
- break;
4542
- case 14:
4543
- _context2.prev = 14;
4544
- _context2.t0 = _context2["catch"](0);
4545
- logger.error(_context2.t0);
4546
- case 17:
4547
- case "end":
4548
- return _context2.stop();
4549
- }
4550
- }, _callee2, null, [[0, 14]]);
4551
- }));
4552
- return function unsubscribeBrowserNotifications() {
4553
- return _ref2.apply(this, arguments);
4554
- };
4555
- }();
4556
- var registerServiceWorker = /*#__PURE__*/function () {
4557
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(vapidPublicKey) {
4558
- var res;
4559
- return regenerator.wrap(function _callee3$(_context3) {
4560
- while (1) switch (_context3.prev = _context3.next) {
4561
- case 0:
4562
- if (!(navigator.serviceWorker && vapidPublicKey)) {
4563
- _context3.next = 5;
4564
- break;
4565
- }
4566
- _context3.next = 3;
4567
- return subscribeBrowserNotifications(vapidPublicKey);
4568
- case 3:
4569
- res = _context3.sent;
4570
- return _context3.abrupt("return", res);
4571
- case 5:
4572
- logger.error("Service worker is not supported in this Browser");
4573
- return _context3.abrupt("return", null);
4574
- case 7:
4575
- case "end":
4576
- return _context3.stop();
4577
- }
4578
- }, _callee3);
4579
- }));
4580
- return function registerServiceWorker(_x2) {
4581
- return _ref3.apply(this, arguments);
4582
- };
4583
- }();
4584
4591
 
4585
- var createBrowserSubscription = /*#__PURE__*/function () {
4586
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(subscription) {
4587
- var payload;
4588
- return regenerator.wrap(function _callee$(_context) {
4589
- while (1) switch (_context.prev = _context.next) {
4590
- case 0:
4591
- if (!subscription) {
4592
- _context.next = 13;
4593
- break;
4594
- }
4595
- payload = {
4596
- device: {
4597
- subscription: subscription,
4598
- platform: "browser"
4599
- }
4600
- };
4601
- _context.prev = 2;
4602
- _context.next = 5;
4603
- return devicesApi.create(payload);
4604
- case 5:
4605
- localStorage.setItem("deviceId", JSON.stringify(subscription.toJSON().keys.auth));
4606
- _context.next = 11;
4607
- break;
4608
- case 8:
4609
- _context.prev = 8;
4610
- _context.t0 = _context["catch"](2);
4611
- logger.error("Device registration Failed: ", _context.t0);
4612
- case 11:
4613
- _context.next = 14;
4614
- break;
4615
- case 13:
4616
- logger.error("Something went wrong while registering device for browser subscription");
4617
- case 14:
4618
- case "end":
4619
- return _context.stop();
4620
- }
4621
- }, _callee, null, [[2, 8]]);
4622
- }));
4623
- return function createBrowserSubscription(_x) {
4624
- return _ref.apply(this, arguments);
4625
- };
4626
- }();
4627
- var destroyBrowserSubscription = /*#__PURE__*/function () {
4628
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
4629
- var deviceId;
4630
- return regenerator.wrap(function _callee2$(_context2) {
4631
- while (1) switch (_context2.prev = _context2.next) {
4632
- case 0:
4633
- _context2.prev = 0;
4634
- _context2.next = 3;
4635
- return unsubscribeBrowserNotifications();
4636
- case 3:
4637
- deviceId = JSON.parse(localStorage.getItem("deviceId"));
4638
- _context2.next = 6;
4639
- return devicesApi.destroy(deviceId);
4640
- case 6:
4641
- localStorage.removeItem("deviceId");
4642
- _context2.next = 12;
4643
- break;
4644
- case 9:
4645
- _context2.prev = 9;
4646
- _context2.t0 = _context2["catch"](0);
4647
- logger.error("Something went wrong while unsubscribing browser notification:", _context2.t0);
4648
- case 12:
4649
- case "end":
4650
- return _context2.stop();
4651
- }
4652
- }, _callee2, null, [[0, 9]]);
4653
- }));
4654
- return function destroyBrowserSubscription() {
4655
- return _ref2.apply(this, arguments);
4656
- };
4657
- }();
4658
- var registerBrowserNotifications = /*#__PURE__*/function () {
4659
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
4660
- var vapidPublicKey,
4661
- response,
4662
- _args3 = arguments;
4663
- return regenerator.wrap(function _callee3$(_context3) {
4664
- while (1) switch (_context3.prev = _context3.next) {
4665
- case 0:
4666
- vapidPublicKey = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.env.VAPID_PUBLIC_KEY;
4667
- _context3.next = 3;
4668
- return registerServiceWorker(vapidPublicKey);
4669
- case 3:
4670
- response = _context3.sent;
4671
- _context3.next = 6;
4672
- return createBrowserSubscription(response);
4673
- case 6:
4674
- case "end":
4675
- return _context3.stop();
4676
- }
4677
- }, _callee3);
4678
- }));
4679
- return function registerBrowserNotifications() {
4680
- return _ref3.apply(this, arguments);
4681
- };
4682
- }();
4592
+ // Adapted from Chris Veness' SHA1 code at
4593
+ // http://www.movable-type.co.uk/scripts/sha1.html
4594
+ function f(s, x, y, z) {
4595
+ switch (s) {
4596
+ case 0:
4597
+ return x & y ^ ~x & z;
4598
+
4599
+ case 1:
4600
+ return x ^ y ^ z;
4601
+
4602
+ case 2:
4603
+ return x & y ^ x & z ^ y & z;
4604
+
4605
+ case 3:
4606
+ return x ^ y ^ z;
4607
+ }
4608
+ }
4683
4609
 
4684
- var handleMetaClick = ramda.curry(function (history, params, event) {
4685
- return isMetaKeyPressed(event) ? window.open(params.pathname || params, "_blank") : history.push(params);
4610
+ function ROTL(x, n) {
4611
+ return x << n | x >>> 32 - n;
4612
+ }
4613
+
4614
+ function sha1(bytes) {
4615
+ const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
4616
+ const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
4617
+
4618
+ if (typeof bytes === 'string') {
4619
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
4620
+
4621
+ bytes = [];
4622
+
4623
+ for (let i = 0; i < msg.length; ++i) {
4624
+ bytes.push(msg.charCodeAt(i));
4625
+ }
4626
+ } else if (!Array.isArray(bytes)) {
4627
+ // Convert Array-like to Array
4628
+ bytes = Array.prototype.slice.call(bytes);
4629
+ }
4630
+
4631
+ bytes.push(0x80);
4632
+ const l = bytes.length / 4 + 2;
4633
+ const N = Math.ceil(l / 16);
4634
+ const M = new Array(N);
4635
+
4636
+ for (let i = 0; i < N; ++i) {
4637
+ const arr = new Uint32Array(16);
4638
+
4639
+ for (let j = 0; j < 16; ++j) {
4640
+ arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
4641
+ }
4642
+
4643
+ M[i] = arr;
4644
+ }
4645
+
4646
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
4647
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
4648
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
4649
+
4650
+ for (let i = 0; i < N; ++i) {
4651
+ const W = new Uint32Array(80);
4652
+
4653
+ for (let t = 0; t < 16; ++t) {
4654
+ W[t] = M[i][t];
4655
+ }
4656
+
4657
+ for (let t = 16; t < 80; ++t) {
4658
+ W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
4659
+ }
4660
+
4661
+ let a = H[0];
4662
+ let b = H[1];
4663
+ let c = H[2];
4664
+ let d = H[3];
4665
+ let e = H[4];
4666
+
4667
+ for (let t = 0; t < 80; ++t) {
4668
+ const s = Math.floor(t / 20);
4669
+ const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
4670
+ e = d;
4671
+ d = c;
4672
+ c = ROTL(b, 30) >>> 0;
4673
+ b = a;
4674
+ a = T;
4675
+ }
4676
+
4677
+ H[0] = H[0] + a >>> 0;
4678
+ H[1] = H[1] + b >>> 0;
4679
+ H[2] = H[2] + c >>> 0;
4680
+ H[3] = H[3] + d >>> 0;
4681
+ H[4] = H[4] + e >>> 0;
4682
+ }
4683
+
4684
+ return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
4685
+ }
4686
+
4687
+ v35('v5', 0x50, sha1);
4688
+
4689
+ var useTimerStore = create$1(function () {
4690
+ return {};
4686
4691
  });
4687
- var isMetaKeyPressed = function isMetaKeyPressed(event) {
4688
- return !!(event !== null && event !== void 0 && event.ctrlKey || event !== null && event !== void 0 && event.metaKey);
4689
- };
4692
+ setInterval(function () {
4693
+ var currentState = useTimerStore.getState();
4694
+ var nextState = {};
4695
+ var now = Date.now();
4696
+ for (var key in currentState) {
4697
+ var _currentState$key = currentState[key],
4698
+ lastUpdated = _currentState$key.lastUpdated,
4699
+ interval = _currentState$key.interval;
4700
+ var shouldUpdate = now - lastUpdated >= interval;
4701
+ if (shouldUpdate) nextState[key] = {
4702
+ lastUpdated: now,
4703
+ interval: interval
4704
+ };
4705
+ }
4706
+ if (!ramda.isEmpty(nextState)) useTimerStore.setState(nextState);
4707
+ }, 1000);
4708
+ var useTimer = function useTimer() {
4709
+ var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 60;
4710
+ var key = React.useMemo(function () {
4711
+ return v4();
4712
+ }, []);
4713
+ React.useEffect(function () {
4714
+ useTimerStore.setState(_defineProperty({}, key, {
4715
+ lastUpdated: Date.now(),
4716
+ interval: 1000 * interval // convert seconds to ms
4717
+ }));
4690
4718
 
4691
- var withTitle = function withTitle(Component) {
4692
- var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
4693
- var PageTitle = function PageTitle(props) {
4694
- var pageTitle = title ? "".concat(title, " | ").concat(globalProps.appName) : globalProps.appName;
4695
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactHelmet.Helmet, null, /*#__PURE__*/React__default["default"].createElement("title", null, pageTitle)), /*#__PURE__*/React__default["default"].createElement(Component, props));
4696
- };
4697
- return PageTitle;
4719
+ return function () {
4720
+ return useTimerStore.setState(ramda.omit([key], useTimerStore.getState()), true);
4721
+ };
4722
+ }, [interval, key]);
4723
+ return useTimerStore(ramda.prop(key));
4698
4724
  };
4699
4725
 
4700
- var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
4701
- return function (partial) {
4702
- return set(function (previous) {
4703
- if (typeof partial === "function") partial = partial(previous);
4704
- var overwrittenActions = ramda.keys(partial).filter(function (key) {
4705
- return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && partial[key] !== previous[key];
4706
- });
4707
- if (!ramda.isEmpty(overwrittenActions)) {
4708
- throw new Error("Actions should not be modified. Touched action(s): ".concat(overwrittenActions.join(", ")));
4709
- }
4710
- return partial;
4711
- }, false);
4712
- };
4713
- };
4714
- var withImmutableActions = function withImmutableActions(config) {
4715
- return function (set, get, api) {
4716
- return config(setWithoutModifyingActions(set), get, api);
4717
- };
4726
+ var useUpdateEffect = function useUpdateEffect(callback) {
4727
+ var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4728
+ var isInitialMount = React.useRef(true);
4729
+ React.useEffect(function () {
4730
+ if (isInitialMount.current) {
4731
+ isInitialMount.current = false;
4732
+ return;
4733
+ }
4734
+ callback();
4735
+ }, dependencies);
4718
4736
  };
4719
4737
 
4720
4738
  exports.HoneybadgerErrorBoundary = HoneybadgerErrorBoundary;
@@ -4731,8 +4749,10 @@ exports.useHotKeys = useHotKeys;
4731
4749
  exports.useIsElementVisibleInDom = useIsElementVisibleInDom;
4732
4750
  exports.useKeyboardShortcutsPaneState = useKeyboardShortcutsPaneState;
4733
4751
  exports.useLocalStorage = useLocalStorage;
4752
+ exports.useNavigationCheckpoint = useNavigationCheckpoint;
4734
4753
  exports.useOnClickOutside = useOnClickOutside;
4735
4754
  exports.usePrevious = usePrevious;
4755
+ exports.useRegisterNavigationCheckpoint = useRegisterNavigationCheckpoint;
4736
4756
  exports.useStateWithDependency = useStateWithDependency;
4737
4757
  exports.useTimer = useTimer;
4738
4758
  exports.useUpdateEffect = useUpdateEffect;