@helpdice/ui 1.4.9 → 1.5.1
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/CircularProgress/index.js +6 -6
- package/dist/Placeholder/index.js +41 -41
- package/dist/auto-complete/index.js +60 -60
- package/dist/avatar/index.js +28 -28
- package/dist/badge/index.js +27 -27
- package/dist/breadcrumbs/index.js +34 -34
- package/dist/button/button.compact.d.ts +2 -2
- package/dist/button/index.js +46 -45
- package/dist/button-dropdown/index.js +34 -34
- package/dist/button-group/index.js +25 -25
- package/dist/capacity/index.js +26 -26
- package/dist/card/index.js +44 -44
- package/dist/checkbox/index.js +30 -30
- package/dist/code/index.js +27 -27
- package/dist/col/index.js +8 -8
- package/dist/collapse/index.js +30 -30
- package/dist/css-baseline/index.js +6 -6
- package/dist/description/index.js +26 -26
- package/dist/display/index.js +26 -26
- package/dist/divider/index.js +26 -26
- package/dist/dot/index.js +25 -25
- package/dist/drawer/index.js +53 -53
- package/dist/fieldset/index.js +33 -33
- package/dist/form/FormWrapper.d.ts +7 -7
- package/dist/form/connect.d.ts +1 -0
- package/dist/grid/index.js +33 -33
- package/dist/html-renderer/index.d.ts +6 -0
- package/dist/image/index.js +37 -37
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1899 -547
- package/dist/input/index.js +40 -40
- package/dist/keyboard/index.js +28 -28
- package/dist/link/index.js +29 -29
- package/dist/loading/index.js +26 -26
- package/dist/modal/index.js +75 -75
- package/dist/note/index.js +27 -27
- package/dist/page/index.js +30 -30
- package/dist/pagination/index.js +27 -27
- package/dist/popover/index.js +57 -57
- package/dist/progress/index.js +29 -29
- package/dist/radio/index.js +30 -30
- package/dist/rating/index.js +29 -29
- package/dist/row/index.js +11 -11
- package/dist/search-bar/index.js +1826 -61
- package/dist/select/index.js +60 -60
- package/dist/slider/index.js +35 -35
- package/dist/snippet/index.js +30 -30
- package/dist/spacer/index.js +25 -25
- package/dist/spinner/index.js +24 -24
- package/dist/table/index.js +224 -211
- package/dist/tabs/index.js +39 -39
- package/dist/tag/index.js +26 -26
- package/dist/text/index.js +40 -40
- package/dist/textarea/index.js +29 -29
- package/dist/themes/index.js +2 -2
- package/dist/toggle/index.js +27 -27
- package/dist/tooltip/index.js +42 -42
- package/dist/tree/index.js +23 -23
- package/dist/ui-provider/index.js +48 -48
- package/dist/use-all-themes/index.js +2 -2
- package/dist/use-body-scroll/index.js +5 -5
- package/dist/use-clipboard/index.js +1 -1
- package/dist/use-current-state/index.js +1 -1
- package/dist/use-input/index.js +1 -1
- package/dist/use-keyboard/index.js +5 -5
- package/dist/use-media-query/index.js +5 -5
- package/dist/use-modal/index.js +1 -1
- package/dist/use-scale/index.js +19 -19
- package/dist/use-tabs/index.js +1 -1
- package/dist/use-theme/index.js +2 -2
- package/dist/use-toasts/index.js +3 -3
- package/dist/user/index.js +36 -36
- package/esm/button/button.compact.d.ts +2 -2
- package/esm/button/button.compact.js +4 -2
- package/esm/form/FastField.js +1 -1
- package/esm/form/FormWrapper.d.ts +7 -7
- package/esm/form/FormWrapper.js +2 -2
- package/esm/form/connect.d.ts +1 -0
- package/esm/form/connect.js +2 -1
- package/esm/html-renderer/index.d.ts +6 -0
- package/esm/html-renderer/index.js +12 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/link/link.js +2 -0
- package/esm/login-with/LoginSocialAmazon/index.js +162 -134
- package/esm/login-with/index.js +2 -0
- package/esm/search-bar/components/index.js +4 -7
- package/esm/table/data-table.js +6 -4
- package/esm/table/table.js +12 -1
- package/package.json +5 -3
- package/esm/formik-native/src/index.js +0 -12
- package/esm/formik-native/test/blah.test.js +0 -5
package/dist/search-bar/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var o = require('react');
|
|
6
|
-
var Fuse = require('fuse.js');
|
|
7
6
|
|
|
8
7
|
function _arrayLikeToArray(r, a) {
|
|
9
8
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -91,8 +90,8 @@ function _taggedTemplateLiteral(e, t) {
|
|
|
91
90
|
function _toPrimitive(t, r) {
|
|
92
91
|
if ("object" != typeof t || !t) return t;
|
|
93
92
|
var e = t[Symbol.toPrimitive];
|
|
94
|
-
if (
|
|
95
|
-
var i = e.call(t, r
|
|
93
|
+
if (void 0 !== e) {
|
|
94
|
+
var i = e.call(t, r);
|
|
96
95
|
if ("object" != typeof i) return i;
|
|
97
96
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
98
97
|
}
|
|
@@ -106,7 +105,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
106
105
|
if (r) {
|
|
107
106
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
108
107
|
var t = {}.toString.call(r).slice(8, -1);
|
|
109
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) :
|
|
108
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
|
|
@@ -140,7 +139,7 @@ function requireIndex () {
|
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
141
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
143
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
142
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
144
143
|
return Constructor;
|
|
145
144
|
}
|
|
146
145
|
var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
|
|
@@ -149,7 +148,7 @@ function requireIndex () {
|
|
|
149
148
|
};
|
|
150
149
|
var StyleSheet = /*#__PURE__*/ function() {
|
|
151
150
|
function StyleSheet(param) {
|
|
152
|
-
var ref = param ===
|
|
151
|
+
var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
|
|
153
152
|
invariant$1(isString(name), "`name` must be a string");
|
|
154
153
|
this._name = name;
|
|
155
154
|
this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
|
|
@@ -407,7 +406,7 @@ function requireIndex () {
|
|
|
407
406
|
}
|
|
408
407
|
|
|
409
408
|
function mapRulesToStyle(cssRules, options) {
|
|
410
|
-
if (options ===
|
|
409
|
+
if (options === void 0) options = {};
|
|
411
410
|
return cssRules.map(function(args) {
|
|
412
411
|
var id = args[0];
|
|
413
412
|
var css = args[1];
|
|
@@ -424,7 +423,7 @@ function requireIndex () {
|
|
|
424
423
|
}
|
|
425
424
|
var StyleSheetRegistry = /*#__PURE__*/ function() {
|
|
426
425
|
function StyleSheetRegistry(param) {
|
|
427
|
-
var ref = param ===
|
|
426
|
+
var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
|
|
428
427
|
this._sheet = styleSheet || new StyleSheet({
|
|
429
428
|
name: "styled-jsx",
|
|
430
429
|
optimizeForSpeed: optimizeForSpeed
|
|
@@ -634,23 +633,1792 @@ function requireStyle () {
|
|
|
634
633
|
var styleExports = requireStyle();
|
|
635
634
|
var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);
|
|
636
635
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
636
|
+
/**
|
|
637
|
+
* Fuse.js v7.1.0 - Lightweight fuzzy-search (http://fusejs.io)
|
|
638
|
+
*
|
|
639
|
+
* Copyright (c) 2025 Kiro Risk (http://kiro.me)
|
|
640
|
+
* All Rights Reserved. Apache Software License 2.0
|
|
641
|
+
*
|
|
642
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
643
|
+
*/
|
|
644
|
+
|
|
645
|
+
function isArray(value) {
|
|
646
|
+
return !Array.isArray
|
|
647
|
+
? getTag(value) === '[object Array]'
|
|
648
|
+
: Array.isArray(value)
|
|
649
|
+
}
|
|
650
|
+
function baseToString(value) {
|
|
651
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
652
|
+
if (typeof value == 'string') {
|
|
653
|
+
return value
|
|
654
|
+
}
|
|
655
|
+
let result = value + '';
|
|
656
|
+
return result == '0' && 1 / value == -Infinity ? '-0' : result
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function toString(value) {
|
|
660
|
+
return value == null ? '' : baseToString(value)
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function isString(value) {
|
|
664
|
+
return typeof value === 'string'
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function isNumber(value) {
|
|
668
|
+
return typeof value === 'number'
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
|
|
672
|
+
function isBoolean(value) {
|
|
673
|
+
return (
|
|
674
|
+
value === true ||
|
|
675
|
+
value === false ||
|
|
676
|
+
(isObjectLike(value) && getTag(value) == '[object Boolean]')
|
|
677
|
+
)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function isObject(value) {
|
|
681
|
+
return typeof value === 'object'
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// Checks if `value` is object-like.
|
|
685
|
+
function isObjectLike(value) {
|
|
686
|
+
return isObject(value) && value !== null
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function isDefined(value) {
|
|
690
|
+
return value !== undefined && value !== null
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
function isBlank(value) {
|
|
694
|
+
return !value.trim().length
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// Gets the `toStringTag` of `value`.
|
|
698
|
+
// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
|
|
699
|
+
function getTag(value) {
|
|
700
|
+
return value == null
|
|
701
|
+
? value === undefined
|
|
702
|
+
? '[object Undefined]'
|
|
703
|
+
: '[object Null]'
|
|
704
|
+
: Object.prototype.toString.call(value)
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
|
|
708
|
+
|
|
709
|
+
const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
|
|
710
|
+
`Invalid value for key ${key}`;
|
|
711
|
+
|
|
712
|
+
const PATTERN_LENGTH_TOO_LARGE = (max) =>
|
|
713
|
+
`Pattern length exceeds max of ${max}.`;
|
|
714
|
+
|
|
715
|
+
const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
|
|
716
|
+
|
|
717
|
+
const INVALID_KEY_WEIGHT_VALUE = (key) =>
|
|
718
|
+
`Property 'weight' in key '${key}' must be a positive integer`;
|
|
719
|
+
|
|
720
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
721
|
+
|
|
722
|
+
class KeyStore {
|
|
723
|
+
constructor(keys) {
|
|
724
|
+
this._keys = [];
|
|
725
|
+
this._keyMap = {};
|
|
726
|
+
|
|
727
|
+
let totalWeight = 0;
|
|
728
|
+
|
|
729
|
+
keys.forEach((key) => {
|
|
730
|
+
let obj = createKey(key);
|
|
731
|
+
|
|
732
|
+
this._keys.push(obj);
|
|
733
|
+
this._keyMap[obj.id] = obj;
|
|
734
|
+
|
|
735
|
+
totalWeight += obj.weight;
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
// Normalize weights so that their sum is equal to 1
|
|
739
|
+
this._keys.forEach((key) => {
|
|
740
|
+
key.weight /= totalWeight;
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
get(keyId) {
|
|
744
|
+
return this._keyMap[keyId]
|
|
745
|
+
}
|
|
746
|
+
keys() {
|
|
747
|
+
return this._keys
|
|
748
|
+
}
|
|
749
|
+
toJSON() {
|
|
750
|
+
return JSON.stringify(this._keys)
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function createKey(key) {
|
|
755
|
+
let path = null;
|
|
756
|
+
let id = null;
|
|
757
|
+
let src = null;
|
|
758
|
+
let weight = 1;
|
|
759
|
+
let getFn = null;
|
|
760
|
+
|
|
761
|
+
if (isString(key) || isArray(key)) {
|
|
762
|
+
src = key;
|
|
763
|
+
path = createKeyPath(key);
|
|
764
|
+
id = createKeyId(key);
|
|
765
|
+
} else {
|
|
766
|
+
if (!hasOwn.call(key, 'name')) {
|
|
767
|
+
throw new Error(MISSING_KEY_PROPERTY('name'))
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
const name = key.name;
|
|
771
|
+
src = name;
|
|
772
|
+
|
|
773
|
+
if (hasOwn.call(key, 'weight')) {
|
|
774
|
+
weight = key.weight;
|
|
775
|
+
|
|
776
|
+
if (weight <= 0) {
|
|
777
|
+
throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
path = createKeyPath(name);
|
|
782
|
+
id = createKeyId(name);
|
|
783
|
+
getFn = key.getFn;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
return { path, id, weight, src, getFn }
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function createKeyPath(key) {
|
|
790
|
+
return isArray(key) ? key : key.split('.')
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function createKeyId(key) {
|
|
794
|
+
return isArray(key) ? key.join('.') : key
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function get(obj, path) {
|
|
798
|
+
let list = [];
|
|
799
|
+
let arr = false;
|
|
800
|
+
|
|
801
|
+
const deepGet = (obj, path, index) => {
|
|
802
|
+
if (!isDefined(obj)) {
|
|
803
|
+
return
|
|
804
|
+
}
|
|
805
|
+
if (!path[index]) {
|
|
806
|
+
// If there's no path left, we've arrived at the object we care about.
|
|
807
|
+
list.push(obj);
|
|
808
|
+
} else {
|
|
809
|
+
let key = path[index];
|
|
810
|
+
|
|
811
|
+
const value = obj[key];
|
|
812
|
+
|
|
813
|
+
if (!isDefined(value)) {
|
|
814
|
+
return
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// If we're at the last value in the path, and if it's a string/number/bool,
|
|
818
|
+
// add it to the list
|
|
819
|
+
if (
|
|
820
|
+
index === path.length - 1 &&
|
|
821
|
+
(isString(value) || isNumber(value) || isBoolean(value))
|
|
822
|
+
) {
|
|
823
|
+
list.push(toString(value));
|
|
824
|
+
} else if (isArray(value)) {
|
|
825
|
+
arr = true;
|
|
826
|
+
// Search each item in the array.
|
|
827
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
828
|
+
deepGet(value[i], path, index + 1);
|
|
829
|
+
}
|
|
830
|
+
} else if (path.length) {
|
|
831
|
+
// An object. Recurse further.
|
|
832
|
+
deepGet(value, path, index + 1);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
// Backwards compatibility (since path used to be a string)
|
|
838
|
+
deepGet(obj, isString(path) ? path.split('.') : path, 0);
|
|
839
|
+
|
|
840
|
+
return arr ? list : list[0]
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
const MatchOptions = {
|
|
844
|
+
// Whether the matches should be included in the result set. When `true`, each record in the result
|
|
845
|
+
// set will include the indices of the matched characters.
|
|
846
|
+
// These can consequently be used for highlighting purposes.
|
|
847
|
+
includeMatches: false,
|
|
848
|
+
// When `true`, the matching function will continue to the end of a search pattern even if
|
|
849
|
+
// a perfect match has already been located in the string.
|
|
850
|
+
findAllMatches: false,
|
|
851
|
+
// Minimum number of characters that must be matched before a result is considered a match
|
|
852
|
+
minMatchCharLength: 1
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
const BasicOptions = {
|
|
856
|
+
// When `true`, the algorithm continues searching to the end of the input even if a perfect
|
|
857
|
+
// match is found before the end of the same input.
|
|
858
|
+
isCaseSensitive: false,
|
|
859
|
+
// When `true`, the algorithm will ignore diacritics (accents) in comparisons
|
|
860
|
+
ignoreDiacritics: false,
|
|
861
|
+
// When true, the matching function will continue to the end of a search pattern even if
|
|
862
|
+
includeScore: false,
|
|
863
|
+
// List of properties that will be searched. This also supports nested properties.
|
|
864
|
+
keys: [],
|
|
865
|
+
// Whether to sort the result list, by score
|
|
866
|
+
shouldSort: true,
|
|
867
|
+
// Default sort function: sort by ascending score, ascending index
|
|
868
|
+
sortFn: (a, b) =>
|
|
869
|
+
a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
const FuzzyOptions = {
|
|
873
|
+
// Approximately where in the text is the pattern expected to be found?
|
|
874
|
+
location: 0,
|
|
875
|
+
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
|
|
876
|
+
// (of both letters and location), a threshold of '1.0' would match anything.
|
|
877
|
+
threshold: 0.6,
|
|
878
|
+
// Determines how close the match must be to the fuzzy location (specified above).
|
|
879
|
+
// An exact letter match which is 'distance' characters away from the fuzzy location
|
|
880
|
+
// would score as a complete mismatch. A distance of '0' requires the match be at
|
|
881
|
+
// the exact location specified, a threshold of '1000' would require a perfect match
|
|
882
|
+
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
|
|
883
|
+
distance: 100
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
const AdvancedOptions = {
|
|
887
|
+
// When `true`, it enables the use of unix-like search commands
|
|
888
|
+
useExtendedSearch: false,
|
|
889
|
+
// The get function to use when fetching an object's properties.
|
|
890
|
+
// The default will search nested paths *ie foo.bar.baz*
|
|
891
|
+
getFn: get,
|
|
892
|
+
// When `true`, search will ignore `location` and `distance`, so it won't matter
|
|
893
|
+
// where in the string the pattern appears.
|
|
894
|
+
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
|
|
895
|
+
ignoreLocation: false,
|
|
896
|
+
// When `true`, the calculation for the relevance score (used for sorting) will
|
|
897
|
+
// ignore the field-length norm.
|
|
898
|
+
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
|
|
899
|
+
ignoreFieldNorm: false,
|
|
900
|
+
// The weight to determine how much field length norm effects scoring.
|
|
901
|
+
fieldNormWeight: 1
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
var Config = {
|
|
905
|
+
...BasicOptions,
|
|
906
|
+
...MatchOptions,
|
|
907
|
+
...FuzzyOptions,
|
|
908
|
+
...AdvancedOptions
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
const SPACE = /[^ ]+/g;
|
|
912
|
+
|
|
913
|
+
// Field-length norm: the shorter the field, the higher the weight.
|
|
914
|
+
// Set to 3 decimals to reduce index size.
|
|
915
|
+
function norm(weight = 1, mantissa = 3) {
|
|
916
|
+
const cache = new Map();
|
|
917
|
+
const m = Math.pow(10, mantissa);
|
|
918
|
+
|
|
919
|
+
return {
|
|
920
|
+
get(value) {
|
|
921
|
+
const numTokens = value.match(SPACE).length;
|
|
922
|
+
|
|
923
|
+
if (cache.has(numTokens)) {
|
|
924
|
+
return cache.get(numTokens)
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// Default function is 1/sqrt(x), weight makes that variable
|
|
928
|
+
const norm = 1 / Math.pow(numTokens, 0.5 * weight);
|
|
929
|
+
|
|
930
|
+
// In place of `toFixed(mantissa)`, for faster computation
|
|
931
|
+
const n = parseFloat(Math.round(norm * m) / m);
|
|
932
|
+
|
|
933
|
+
cache.set(numTokens, n);
|
|
934
|
+
|
|
935
|
+
return n
|
|
936
|
+
},
|
|
937
|
+
clear() {
|
|
938
|
+
cache.clear();
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
class FuseIndex {
|
|
944
|
+
constructor({
|
|
945
|
+
getFn = Config.getFn,
|
|
946
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
947
|
+
} = {}) {
|
|
948
|
+
this.norm = norm(fieldNormWeight, 3);
|
|
949
|
+
this.getFn = getFn;
|
|
950
|
+
this.isCreated = false;
|
|
951
|
+
|
|
952
|
+
this.setIndexRecords();
|
|
953
|
+
}
|
|
954
|
+
setSources(docs = []) {
|
|
955
|
+
this.docs = docs;
|
|
956
|
+
}
|
|
957
|
+
setIndexRecords(records = []) {
|
|
958
|
+
this.records = records;
|
|
959
|
+
}
|
|
960
|
+
setKeys(keys = []) {
|
|
961
|
+
this.keys = keys;
|
|
962
|
+
this._keysMap = {};
|
|
963
|
+
keys.forEach((key, idx) => {
|
|
964
|
+
this._keysMap[key.id] = idx;
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
create() {
|
|
968
|
+
if (this.isCreated || !this.docs.length) {
|
|
969
|
+
return
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
this.isCreated = true;
|
|
973
|
+
|
|
974
|
+
// List is Array<String>
|
|
975
|
+
if (isString(this.docs[0])) {
|
|
976
|
+
this.docs.forEach((doc, docIndex) => {
|
|
977
|
+
this._addString(doc, docIndex);
|
|
978
|
+
});
|
|
979
|
+
} else {
|
|
980
|
+
// List is Array<Object>
|
|
981
|
+
this.docs.forEach((doc, docIndex) => {
|
|
982
|
+
this._addObject(doc, docIndex);
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
this.norm.clear();
|
|
987
|
+
}
|
|
988
|
+
// Adds a doc to the end of the index
|
|
989
|
+
add(doc) {
|
|
990
|
+
const idx = this.size();
|
|
991
|
+
|
|
992
|
+
if (isString(doc)) {
|
|
993
|
+
this._addString(doc, idx);
|
|
994
|
+
} else {
|
|
995
|
+
this._addObject(doc, idx);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
// Removes the doc at the specified index of the index
|
|
999
|
+
removeAt(idx) {
|
|
1000
|
+
this.records.splice(idx, 1);
|
|
1001
|
+
|
|
1002
|
+
// Change ref index of every subsquent doc
|
|
1003
|
+
for (let i = idx, len = this.size(); i < len; i += 1) {
|
|
1004
|
+
this.records[i].i -= 1;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
getValueForItemAtKeyId(item, keyId) {
|
|
1008
|
+
return item[this._keysMap[keyId]]
|
|
1009
|
+
}
|
|
1010
|
+
size() {
|
|
1011
|
+
return this.records.length
|
|
1012
|
+
}
|
|
1013
|
+
_addString(doc, docIndex) {
|
|
1014
|
+
if (!isDefined(doc) || isBlank(doc)) {
|
|
1015
|
+
return
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
let record = {
|
|
1019
|
+
v: doc,
|
|
1020
|
+
i: docIndex,
|
|
1021
|
+
n: this.norm.get(doc)
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
this.records.push(record);
|
|
1025
|
+
}
|
|
1026
|
+
_addObject(doc, docIndex) {
|
|
1027
|
+
let record = { i: docIndex, $: {} };
|
|
1028
|
+
|
|
1029
|
+
// Iterate over every key (i.e, path), and fetch the value at that key
|
|
1030
|
+
this.keys.forEach((key, keyIndex) => {
|
|
1031
|
+
let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
|
|
1032
|
+
|
|
1033
|
+
if (!isDefined(value)) {
|
|
1034
|
+
return
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
if (isArray(value)) {
|
|
1038
|
+
let subRecords = [];
|
|
1039
|
+
const stack = [{ nestedArrIndex: -1, value }];
|
|
1040
|
+
|
|
1041
|
+
while (stack.length) {
|
|
1042
|
+
const { nestedArrIndex, value } = stack.pop();
|
|
1043
|
+
|
|
1044
|
+
if (!isDefined(value)) {
|
|
1045
|
+
continue
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
if (isString(value) && !isBlank(value)) {
|
|
1049
|
+
let subRecord = {
|
|
1050
|
+
v: value,
|
|
1051
|
+
i: nestedArrIndex,
|
|
1052
|
+
n: this.norm.get(value)
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
subRecords.push(subRecord);
|
|
1056
|
+
} else if (isArray(value)) {
|
|
1057
|
+
value.forEach((item, k) => {
|
|
1058
|
+
stack.push({
|
|
1059
|
+
nestedArrIndex: k,
|
|
1060
|
+
value: item
|
|
1061
|
+
});
|
|
1062
|
+
});
|
|
1063
|
+
} else ;
|
|
1064
|
+
}
|
|
1065
|
+
record.$[keyIndex] = subRecords;
|
|
1066
|
+
} else if (isString(value) && !isBlank(value)) {
|
|
1067
|
+
let subRecord = {
|
|
1068
|
+
v: value,
|
|
1069
|
+
n: this.norm.get(value)
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
record.$[keyIndex] = subRecord;
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
this.records.push(record);
|
|
1077
|
+
}
|
|
1078
|
+
toJSON() {
|
|
1079
|
+
return {
|
|
1080
|
+
keys: this.keys,
|
|
1081
|
+
records: this.records
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
function createIndex(
|
|
1087
|
+
keys,
|
|
1088
|
+
docs,
|
|
1089
|
+
{ getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
|
|
1090
|
+
) {
|
|
1091
|
+
const myIndex = new FuseIndex({ getFn, fieldNormWeight });
|
|
1092
|
+
myIndex.setKeys(keys.map(createKey));
|
|
1093
|
+
myIndex.setSources(docs);
|
|
1094
|
+
myIndex.create();
|
|
1095
|
+
return myIndex
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
function parseIndex(
|
|
1099
|
+
data,
|
|
1100
|
+
{ getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
|
|
1101
|
+
) {
|
|
1102
|
+
const { keys, records } = data;
|
|
1103
|
+
const myIndex = new FuseIndex({ getFn, fieldNormWeight });
|
|
1104
|
+
myIndex.setKeys(keys);
|
|
1105
|
+
myIndex.setIndexRecords(records);
|
|
1106
|
+
return myIndex
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
function computeScore$1(
|
|
1110
|
+
pattern,
|
|
1111
|
+
{
|
|
1112
|
+
errors = 0,
|
|
1113
|
+
currentLocation = 0,
|
|
1114
|
+
expectedLocation = 0,
|
|
1115
|
+
distance = Config.distance,
|
|
1116
|
+
ignoreLocation = Config.ignoreLocation
|
|
1117
|
+
} = {}
|
|
1118
|
+
) {
|
|
1119
|
+
const accuracy = errors / pattern.length;
|
|
1120
|
+
|
|
1121
|
+
if (ignoreLocation) {
|
|
1122
|
+
return accuracy
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
const proximity = Math.abs(expectedLocation - currentLocation);
|
|
1126
|
+
|
|
1127
|
+
if (!distance) {
|
|
1128
|
+
// Dodge divide by zero error.
|
|
1129
|
+
return proximity ? 1.0 : accuracy
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
return accuracy + proximity / distance
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
function convertMaskToIndices(
|
|
1136
|
+
matchmask = [],
|
|
1137
|
+
minMatchCharLength = Config.minMatchCharLength
|
|
1138
|
+
) {
|
|
1139
|
+
let indices = [];
|
|
1140
|
+
let start = -1;
|
|
1141
|
+
let end = -1;
|
|
1142
|
+
let i = 0;
|
|
1143
|
+
|
|
1144
|
+
for (let len = matchmask.length; i < len; i += 1) {
|
|
1145
|
+
let match = matchmask[i];
|
|
1146
|
+
if (match && start === -1) {
|
|
1147
|
+
start = i;
|
|
1148
|
+
} else if (!match && start !== -1) {
|
|
1149
|
+
end = i - 1;
|
|
1150
|
+
if (end - start + 1 >= minMatchCharLength) {
|
|
1151
|
+
indices.push([start, end]);
|
|
1152
|
+
}
|
|
1153
|
+
start = -1;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
// (i-1 - start) + 1 => i - start
|
|
1158
|
+
if (matchmask[i - 1] && i - start >= minMatchCharLength) {
|
|
1159
|
+
indices.push([start, i - 1]);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
return indices
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
// Machine word size
|
|
1166
|
+
const MAX_BITS = 32;
|
|
1167
|
+
|
|
1168
|
+
function search(
|
|
1169
|
+
text,
|
|
1170
|
+
pattern,
|
|
1171
|
+
patternAlphabet,
|
|
1172
|
+
{
|
|
1173
|
+
location = Config.location,
|
|
1174
|
+
distance = Config.distance,
|
|
1175
|
+
threshold = Config.threshold,
|
|
1176
|
+
findAllMatches = Config.findAllMatches,
|
|
1177
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
1178
|
+
includeMatches = Config.includeMatches,
|
|
1179
|
+
ignoreLocation = Config.ignoreLocation
|
|
1180
|
+
} = {}
|
|
1181
|
+
) {
|
|
1182
|
+
if (pattern.length > MAX_BITS) {
|
|
1183
|
+
throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
const patternLen = pattern.length;
|
|
1187
|
+
// Set starting location at beginning text and initialize the alphabet.
|
|
1188
|
+
const textLen = text.length;
|
|
1189
|
+
// Handle the case when location > text.length
|
|
1190
|
+
const expectedLocation = Math.max(0, Math.min(location, textLen));
|
|
1191
|
+
// Highest score beyond which we give up.
|
|
1192
|
+
let currentThreshold = threshold;
|
|
1193
|
+
// Is there a nearby exact match? (speedup)
|
|
1194
|
+
let bestLocation = expectedLocation;
|
|
1195
|
+
|
|
1196
|
+
// Performance: only computer matches when the minMatchCharLength > 1
|
|
1197
|
+
// OR if `includeMatches` is true.
|
|
1198
|
+
const computeMatches = minMatchCharLength > 1 || includeMatches;
|
|
1199
|
+
// A mask of the matches, used for building the indices
|
|
1200
|
+
const matchMask = computeMatches ? Array(textLen) : [];
|
|
1201
|
+
|
|
1202
|
+
let index;
|
|
1203
|
+
|
|
1204
|
+
// Get all exact matches, here for speed up
|
|
1205
|
+
while ((index = text.indexOf(pattern, bestLocation)) > -1) {
|
|
1206
|
+
let score = computeScore$1(pattern, {
|
|
1207
|
+
currentLocation: index,
|
|
1208
|
+
expectedLocation,
|
|
1209
|
+
distance,
|
|
1210
|
+
ignoreLocation
|
|
1211
|
+
});
|
|
1212
|
+
|
|
1213
|
+
currentThreshold = Math.min(score, currentThreshold);
|
|
1214
|
+
bestLocation = index + patternLen;
|
|
1215
|
+
|
|
1216
|
+
if (computeMatches) {
|
|
1217
|
+
let i = 0;
|
|
1218
|
+
while (i < patternLen) {
|
|
1219
|
+
matchMask[index + i] = 1;
|
|
1220
|
+
i += 1;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// Reset the best location
|
|
1226
|
+
bestLocation = -1;
|
|
1227
|
+
|
|
1228
|
+
let lastBitArr = [];
|
|
1229
|
+
let finalScore = 1;
|
|
1230
|
+
let binMax = patternLen + textLen;
|
|
1231
|
+
|
|
1232
|
+
const mask = 1 << (patternLen - 1);
|
|
1233
|
+
|
|
1234
|
+
for (let i = 0; i < patternLen; i += 1) {
|
|
1235
|
+
// Scan for the best match; each iteration allows for one more error.
|
|
1236
|
+
// Run a binary search to determine how far from the match location we can stray
|
|
1237
|
+
// at this error level.
|
|
1238
|
+
let binMin = 0;
|
|
1239
|
+
let binMid = binMax;
|
|
1240
|
+
|
|
1241
|
+
while (binMin < binMid) {
|
|
1242
|
+
const score = computeScore$1(pattern, {
|
|
1243
|
+
errors: i,
|
|
1244
|
+
currentLocation: expectedLocation + binMid,
|
|
1245
|
+
expectedLocation,
|
|
1246
|
+
distance,
|
|
1247
|
+
ignoreLocation
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
if (score <= currentThreshold) {
|
|
1251
|
+
binMin = binMid;
|
|
1252
|
+
} else {
|
|
1253
|
+
binMax = binMid;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
binMid = Math.floor((binMax - binMin) / 2 + binMin);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// Use the result from this iteration as the maximum for the next.
|
|
1260
|
+
binMax = binMid;
|
|
1261
|
+
|
|
1262
|
+
let start = Math.max(1, expectedLocation - binMid + 1);
|
|
1263
|
+
let finish = findAllMatches
|
|
1264
|
+
? textLen
|
|
1265
|
+
: Math.min(expectedLocation + binMid, textLen) + patternLen;
|
|
1266
|
+
|
|
1267
|
+
// Initialize the bit array
|
|
1268
|
+
let bitArr = Array(finish + 2);
|
|
1269
|
+
|
|
1270
|
+
bitArr[finish + 1] = (1 << i) - 1;
|
|
1271
|
+
|
|
1272
|
+
for (let j = finish; j >= start; j -= 1) {
|
|
1273
|
+
let currentLocation = j - 1;
|
|
1274
|
+
let charMatch = patternAlphabet[text.charAt(currentLocation)];
|
|
1275
|
+
|
|
1276
|
+
if (computeMatches) {
|
|
1277
|
+
// Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
|
|
1278
|
+
matchMask[currentLocation] = +!!charMatch;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
// First pass: exact match
|
|
1282
|
+
bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
|
|
1283
|
+
|
|
1284
|
+
// Subsequent passes: fuzzy match
|
|
1285
|
+
if (i) {
|
|
1286
|
+
bitArr[j] |=
|
|
1287
|
+
((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
if (bitArr[j] & mask) {
|
|
1291
|
+
finalScore = computeScore$1(pattern, {
|
|
1292
|
+
errors: i,
|
|
1293
|
+
currentLocation,
|
|
1294
|
+
expectedLocation,
|
|
1295
|
+
distance,
|
|
1296
|
+
ignoreLocation
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
// This match will almost certainly be better than any existing match.
|
|
1300
|
+
// But check anyway.
|
|
1301
|
+
if (finalScore <= currentThreshold) {
|
|
1302
|
+
// Indeed it is
|
|
1303
|
+
currentThreshold = finalScore;
|
|
1304
|
+
bestLocation = currentLocation;
|
|
1305
|
+
|
|
1306
|
+
// Already passed `loc`, downhill from here on in.
|
|
1307
|
+
if (bestLocation <= expectedLocation) {
|
|
1308
|
+
break
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
|
|
1312
|
+
start = Math.max(1, 2 * expectedLocation - bestLocation);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// No hope for a (better) match at greater error levels.
|
|
1318
|
+
const score = computeScore$1(pattern, {
|
|
1319
|
+
errors: i + 1,
|
|
1320
|
+
currentLocation: expectedLocation,
|
|
1321
|
+
expectedLocation,
|
|
1322
|
+
distance,
|
|
1323
|
+
ignoreLocation
|
|
1324
|
+
});
|
|
1325
|
+
|
|
1326
|
+
if (score > currentThreshold) {
|
|
1327
|
+
break
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
lastBitArr = bitArr;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
const result = {
|
|
1334
|
+
isMatch: bestLocation >= 0,
|
|
1335
|
+
// Count exact matches (those with a score of 0) to be "almost" exact
|
|
1336
|
+
score: Math.max(0.001, finalScore)
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
if (computeMatches) {
|
|
1340
|
+
const indices = convertMaskToIndices(matchMask, minMatchCharLength);
|
|
1341
|
+
if (!indices.length) {
|
|
1342
|
+
result.isMatch = false;
|
|
1343
|
+
} else if (includeMatches) {
|
|
1344
|
+
result.indices = indices;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
return result
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
function createPatternAlphabet(pattern) {
|
|
1352
|
+
let mask = {};
|
|
1353
|
+
|
|
1354
|
+
for (let i = 0, len = pattern.length; i < len; i += 1) {
|
|
1355
|
+
const char = pattern.charAt(i);
|
|
1356
|
+
mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
return mask
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
const stripDiacritics = String.prototype.normalize
|
|
1363
|
+
? ((str) => str.normalize('NFD').replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, ''))
|
|
1364
|
+
: ((str) => str);
|
|
1365
|
+
|
|
1366
|
+
class BitapSearch {
|
|
1367
|
+
constructor(
|
|
1368
|
+
pattern,
|
|
1369
|
+
{
|
|
1370
|
+
location = Config.location,
|
|
1371
|
+
threshold = Config.threshold,
|
|
1372
|
+
distance = Config.distance,
|
|
1373
|
+
includeMatches = Config.includeMatches,
|
|
1374
|
+
findAllMatches = Config.findAllMatches,
|
|
1375
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
1376
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
1377
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
1378
|
+
ignoreLocation = Config.ignoreLocation
|
|
1379
|
+
} = {}
|
|
1380
|
+
) {
|
|
1381
|
+
this.options = {
|
|
1382
|
+
location,
|
|
1383
|
+
threshold,
|
|
1384
|
+
distance,
|
|
1385
|
+
includeMatches,
|
|
1386
|
+
findAllMatches,
|
|
1387
|
+
minMatchCharLength,
|
|
1388
|
+
isCaseSensitive,
|
|
1389
|
+
ignoreDiacritics,
|
|
1390
|
+
ignoreLocation
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
1394
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
1395
|
+
this.pattern = pattern;
|
|
1396
|
+
|
|
1397
|
+
this.chunks = [];
|
|
1398
|
+
|
|
1399
|
+
if (!this.pattern.length) {
|
|
1400
|
+
return
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
const addChunk = (pattern, startIndex) => {
|
|
1404
|
+
this.chunks.push({
|
|
1405
|
+
pattern,
|
|
1406
|
+
alphabet: createPatternAlphabet(pattern),
|
|
1407
|
+
startIndex
|
|
1408
|
+
});
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
const len = this.pattern.length;
|
|
1412
|
+
|
|
1413
|
+
if (len > MAX_BITS) {
|
|
1414
|
+
let i = 0;
|
|
1415
|
+
const remainder = len % MAX_BITS;
|
|
1416
|
+
const end = len - remainder;
|
|
1417
|
+
|
|
1418
|
+
while (i < end) {
|
|
1419
|
+
addChunk(this.pattern.substr(i, MAX_BITS), i);
|
|
1420
|
+
i += MAX_BITS;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
if (remainder) {
|
|
1424
|
+
const startIndex = len - MAX_BITS;
|
|
1425
|
+
addChunk(this.pattern.substr(startIndex), startIndex);
|
|
1426
|
+
}
|
|
1427
|
+
} else {
|
|
1428
|
+
addChunk(this.pattern, 0);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
searchIn(text) {
|
|
1433
|
+
const { isCaseSensitive, ignoreDiacritics, includeMatches } = this.options;
|
|
1434
|
+
|
|
1435
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
1436
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
1437
|
+
|
|
1438
|
+
// Exact match
|
|
1439
|
+
if (this.pattern === text) {
|
|
1440
|
+
let result = {
|
|
1441
|
+
isMatch: true,
|
|
1442
|
+
score: 0
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
if (includeMatches) {
|
|
1446
|
+
result.indices = [[0, text.length - 1]];
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
return result
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
// Otherwise, use Bitap algorithm
|
|
1453
|
+
const {
|
|
1454
|
+
location,
|
|
1455
|
+
distance,
|
|
1456
|
+
threshold,
|
|
1457
|
+
findAllMatches,
|
|
1458
|
+
minMatchCharLength,
|
|
1459
|
+
ignoreLocation
|
|
1460
|
+
} = this.options;
|
|
1461
|
+
|
|
1462
|
+
let allIndices = [];
|
|
1463
|
+
let totalScore = 0;
|
|
1464
|
+
let hasMatches = false;
|
|
1465
|
+
|
|
1466
|
+
this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
|
|
1467
|
+
const { isMatch, score, indices } = search(text, pattern, alphabet, {
|
|
1468
|
+
location: location + startIndex,
|
|
1469
|
+
distance,
|
|
1470
|
+
threshold,
|
|
1471
|
+
findAllMatches,
|
|
1472
|
+
minMatchCharLength,
|
|
1473
|
+
includeMatches,
|
|
1474
|
+
ignoreLocation
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1477
|
+
if (isMatch) {
|
|
1478
|
+
hasMatches = true;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
totalScore += score;
|
|
1482
|
+
|
|
1483
|
+
if (isMatch && indices) {
|
|
1484
|
+
allIndices = [...allIndices, ...indices];
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
|
|
1488
|
+
let result = {
|
|
1489
|
+
isMatch: hasMatches,
|
|
1490
|
+
score: hasMatches ? totalScore / this.chunks.length : 1
|
|
1491
|
+
};
|
|
1492
|
+
|
|
1493
|
+
if (hasMatches && includeMatches) {
|
|
1494
|
+
result.indices = allIndices;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
return result
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
class BaseMatch {
|
|
1502
|
+
constructor(pattern) {
|
|
1503
|
+
this.pattern = pattern;
|
|
1504
|
+
}
|
|
1505
|
+
static isMultiMatch(pattern) {
|
|
1506
|
+
return getMatch(pattern, this.multiRegex)
|
|
1507
|
+
}
|
|
1508
|
+
static isSingleMatch(pattern) {
|
|
1509
|
+
return getMatch(pattern, this.singleRegex)
|
|
1510
|
+
}
|
|
1511
|
+
search(/*text*/) {}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function getMatch(pattern, exp) {
|
|
1515
|
+
const matches = pattern.match(exp);
|
|
1516
|
+
return matches ? matches[1] : null
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
// Token: 'file
|
|
1520
|
+
|
|
1521
|
+
class ExactMatch extends BaseMatch {
|
|
1522
|
+
constructor(pattern) {
|
|
1523
|
+
super(pattern);
|
|
1524
|
+
}
|
|
1525
|
+
static get type() {
|
|
1526
|
+
return 'exact'
|
|
1527
|
+
}
|
|
1528
|
+
static get multiRegex() {
|
|
1529
|
+
return /^="(.*)"$/
|
|
1530
|
+
}
|
|
1531
|
+
static get singleRegex() {
|
|
1532
|
+
return /^=(.*)$/
|
|
1533
|
+
}
|
|
1534
|
+
search(text) {
|
|
1535
|
+
const isMatch = text === this.pattern;
|
|
1536
|
+
|
|
1537
|
+
return {
|
|
1538
|
+
isMatch,
|
|
1539
|
+
score: isMatch ? 0 : 1,
|
|
1540
|
+
indices: [0, this.pattern.length - 1]
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
// Token: !fire
|
|
1546
|
+
|
|
1547
|
+
class InverseExactMatch extends BaseMatch {
|
|
1548
|
+
constructor(pattern) {
|
|
1549
|
+
super(pattern);
|
|
1550
|
+
}
|
|
1551
|
+
static get type() {
|
|
1552
|
+
return 'inverse-exact'
|
|
1553
|
+
}
|
|
1554
|
+
static get multiRegex() {
|
|
1555
|
+
return /^!"(.*)"$/
|
|
1556
|
+
}
|
|
1557
|
+
static get singleRegex() {
|
|
1558
|
+
return /^!(.*)$/
|
|
1559
|
+
}
|
|
1560
|
+
search(text) {
|
|
1561
|
+
const index = text.indexOf(this.pattern);
|
|
1562
|
+
const isMatch = index === -1;
|
|
1563
|
+
|
|
1564
|
+
return {
|
|
1565
|
+
isMatch,
|
|
1566
|
+
score: isMatch ? 0 : 1,
|
|
1567
|
+
indices: [0, text.length - 1]
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// Token: ^file
|
|
1573
|
+
|
|
1574
|
+
class PrefixExactMatch extends BaseMatch {
|
|
1575
|
+
constructor(pattern) {
|
|
1576
|
+
super(pattern);
|
|
1577
|
+
}
|
|
1578
|
+
static get type() {
|
|
1579
|
+
return 'prefix-exact'
|
|
1580
|
+
}
|
|
1581
|
+
static get multiRegex() {
|
|
1582
|
+
return /^\^"(.*)"$/
|
|
1583
|
+
}
|
|
1584
|
+
static get singleRegex() {
|
|
1585
|
+
return /^\^(.*)$/
|
|
1586
|
+
}
|
|
1587
|
+
search(text) {
|
|
1588
|
+
const isMatch = text.startsWith(this.pattern);
|
|
1589
|
+
|
|
1590
|
+
return {
|
|
1591
|
+
isMatch,
|
|
1592
|
+
score: isMatch ? 0 : 1,
|
|
1593
|
+
indices: [0, this.pattern.length - 1]
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// Token: !^fire
|
|
1599
|
+
|
|
1600
|
+
class InversePrefixExactMatch extends BaseMatch {
|
|
1601
|
+
constructor(pattern) {
|
|
1602
|
+
super(pattern);
|
|
1603
|
+
}
|
|
1604
|
+
static get type() {
|
|
1605
|
+
return 'inverse-prefix-exact'
|
|
1606
|
+
}
|
|
1607
|
+
static get multiRegex() {
|
|
1608
|
+
return /^!\^"(.*)"$/
|
|
1609
|
+
}
|
|
1610
|
+
static get singleRegex() {
|
|
1611
|
+
return /^!\^(.*)$/
|
|
1612
|
+
}
|
|
1613
|
+
search(text) {
|
|
1614
|
+
const isMatch = !text.startsWith(this.pattern);
|
|
1615
|
+
|
|
1616
|
+
return {
|
|
1617
|
+
isMatch,
|
|
1618
|
+
score: isMatch ? 0 : 1,
|
|
1619
|
+
indices: [0, text.length - 1]
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
// Token: .file$
|
|
1625
|
+
|
|
1626
|
+
class SuffixExactMatch extends BaseMatch {
|
|
1627
|
+
constructor(pattern) {
|
|
1628
|
+
super(pattern);
|
|
1629
|
+
}
|
|
1630
|
+
static get type() {
|
|
1631
|
+
return 'suffix-exact'
|
|
1632
|
+
}
|
|
1633
|
+
static get multiRegex() {
|
|
1634
|
+
return /^"(.*)"\$$/
|
|
1635
|
+
}
|
|
1636
|
+
static get singleRegex() {
|
|
1637
|
+
return /^(.*)\$$/
|
|
1638
|
+
}
|
|
1639
|
+
search(text) {
|
|
1640
|
+
const isMatch = text.endsWith(this.pattern);
|
|
1641
|
+
|
|
1642
|
+
return {
|
|
1643
|
+
isMatch,
|
|
1644
|
+
score: isMatch ? 0 : 1,
|
|
1645
|
+
indices: [text.length - this.pattern.length, text.length - 1]
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
// Token: !.file$
|
|
1651
|
+
|
|
1652
|
+
class InverseSuffixExactMatch extends BaseMatch {
|
|
1653
|
+
constructor(pattern) {
|
|
1654
|
+
super(pattern);
|
|
1655
|
+
}
|
|
1656
|
+
static get type() {
|
|
1657
|
+
return 'inverse-suffix-exact'
|
|
1658
|
+
}
|
|
1659
|
+
static get multiRegex() {
|
|
1660
|
+
return /^!"(.*)"\$$/
|
|
1661
|
+
}
|
|
1662
|
+
static get singleRegex() {
|
|
1663
|
+
return /^!(.*)\$$/
|
|
1664
|
+
}
|
|
1665
|
+
search(text) {
|
|
1666
|
+
const isMatch = !text.endsWith(this.pattern);
|
|
1667
|
+
return {
|
|
1668
|
+
isMatch,
|
|
1669
|
+
score: isMatch ? 0 : 1,
|
|
1670
|
+
indices: [0, text.length - 1]
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
class FuzzyMatch extends BaseMatch {
|
|
1676
|
+
constructor(
|
|
1677
|
+
pattern,
|
|
1678
|
+
{
|
|
1679
|
+
location = Config.location,
|
|
1680
|
+
threshold = Config.threshold,
|
|
1681
|
+
distance = Config.distance,
|
|
1682
|
+
includeMatches = Config.includeMatches,
|
|
1683
|
+
findAllMatches = Config.findAllMatches,
|
|
1684
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
1685
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
1686
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
1687
|
+
ignoreLocation = Config.ignoreLocation
|
|
1688
|
+
} = {}
|
|
1689
|
+
) {
|
|
1690
|
+
super(pattern);
|
|
1691
|
+
this._bitapSearch = new BitapSearch(pattern, {
|
|
1692
|
+
location,
|
|
1693
|
+
threshold,
|
|
1694
|
+
distance,
|
|
1695
|
+
includeMatches,
|
|
1696
|
+
findAllMatches,
|
|
1697
|
+
minMatchCharLength,
|
|
1698
|
+
isCaseSensitive,
|
|
1699
|
+
ignoreDiacritics,
|
|
1700
|
+
ignoreLocation
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
static get type() {
|
|
1704
|
+
return 'fuzzy'
|
|
1705
|
+
}
|
|
1706
|
+
static get multiRegex() {
|
|
1707
|
+
return /^"(.*)"$/
|
|
1708
|
+
}
|
|
1709
|
+
static get singleRegex() {
|
|
1710
|
+
return /^(.*)$/
|
|
1711
|
+
}
|
|
1712
|
+
search(text) {
|
|
1713
|
+
return this._bitapSearch.searchIn(text)
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// Token: 'file
|
|
1718
|
+
|
|
1719
|
+
class IncludeMatch extends BaseMatch {
|
|
1720
|
+
constructor(pattern) {
|
|
1721
|
+
super(pattern);
|
|
1722
|
+
}
|
|
1723
|
+
static get type() {
|
|
1724
|
+
return 'include'
|
|
1725
|
+
}
|
|
1726
|
+
static get multiRegex() {
|
|
1727
|
+
return /^'"(.*)"$/
|
|
1728
|
+
}
|
|
1729
|
+
static get singleRegex() {
|
|
1730
|
+
return /^'(.*)$/
|
|
1731
|
+
}
|
|
1732
|
+
search(text) {
|
|
1733
|
+
let location = 0;
|
|
1734
|
+
let index;
|
|
1735
|
+
|
|
1736
|
+
const indices = [];
|
|
1737
|
+
const patternLen = this.pattern.length;
|
|
1738
|
+
|
|
1739
|
+
// Get all exact matches
|
|
1740
|
+
while ((index = text.indexOf(this.pattern, location)) > -1) {
|
|
1741
|
+
location = index + patternLen;
|
|
1742
|
+
indices.push([index, location - 1]);
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
const isMatch = !!indices.length;
|
|
1746
|
+
|
|
1747
|
+
return {
|
|
1748
|
+
isMatch,
|
|
1749
|
+
score: isMatch ? 0 : 1,
|
|
1750
|
+
indices
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// ❗Order is important. DO NOT CHANGE.
|
|
1756
|
+
const searchers = [
|
|
1757
|
+
ExactMatch,
|
|
1758
|
+
IncludeMatch,
|
|
1759
|
+
PrefixExactMatch,
|
|
1760
|
+
InversePrefixExactMatch,
|
|
1761
|
+
InverseSuffixExactMatch,
|
|
1762
|
+
SuffixExactMatch,
|
|
1763
|
+
InverseExactMatch,
|
|
1764
|
+
FuzzyMatch
|
|
1765
|
+
];
|
|
1766
|
+
|
|
1767
|
+
const searchersLen = searchers.length;
|
|
1768
|
+
|
|
1769
|
+
// Regex to split by spaces, but keep anything in quotes together
|
|
1770
|
+
const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
|
|
1771
|
+
const OR_TOKEN = '|';
|
|
1772
|
+
|
|
1773
|
+
// Return a 2D array representation of the query, for simpler parsing.
|
|
1774
|
+
// Example:
|
|
1775
|
+
// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
|
|
1776
|
+
function parseQuery(pattern, options = {}) {
|
|
1777
|
+
return pattern.split(OR_TOKEN).map((item) => {
|
|
1778
|
+
let query = item
|
|
1779
|
+
.trim()
|
|
1780
|
+
.split(SPACE_RE)
|
|
1781
|
+
.filter((item) => item && !!item.trim());
|
|
1782
|
+
|
|
1783
|
+
let results = [];
|
|
1784
|
+
for (let i = 0, len = query.length; i < len; i += 1) {
|
|
1785
|
+
const queryItem = query[i];
|
|
1786
|
+
|
|
1787
|
+
// 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
|
|
1788
|
+
let found = false;
|
|
1789
|
+
let idx = -1;
|
|
1790
|
+
while (!found && ++idx < searchersLen) {
|
|
1791
|
+
const searcher = searchers[idx];
|
|
1792
|
+
let token = searcher.isMultiMatch(queryItem);
|
|
1793
|
+
if (token) {
|
|
1794
|
+
results.push(new searcher(token, options));
|
|
1795
|
+
found = true;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
if (found) {
|
|
1800
|
+
continue
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
// 2. Handle single query matches (i.e, once that are *not* quoted)
|
|
1804
|
+
idx = -1;
|
|
1805
|
+
while (++idx < searchersLen) {
|
|
1806
|
+
const searcher = searchers[idx];
|
|
1807
|
+
let token = searcher.isSingleMatch(queryItem);
|
|
1808
|
+
if (token) {
|
|
1809
|
+
results.push(new searcher(token, options));
|
|
1810
|
+
break
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
return results
|
|
1816
|
+
})
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
// These extended matchers can return an array of matches, as opposed
|
|
1820
|
+
// to a singl match
|
|
1821
|
+
const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* Command-like searching
|
|
1825
|
+
* ======================
|
|
1826
|
+
*
|
|
1827
|
+
* Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
|
|
1828
|
+
* search in a given text.
|
|
1829
|
+
*
|
|
1830
|
+
* Search syntax:
|
|
1831
|
+
*
|
|
1832
|
+
* | Token | Match type | Description |
|
|
1833
|
+
* | ----------- | -------------------------- | -------------------------------------- |
|
|
1834
|
+
* | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
|
|
1835
|
+
* | `=scheme` | exact-match | Items that are `scheme` |
|
|
1836
|
+
* | `'python` | include-match | Items that include `python` |
|
|
1837
|
+
* | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
|
|
1838
|
+
* | `^java` | prefix-exact-match | Items that start with `java` |
|
|
1839
|
+
* | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
|
|
1840
|
+
* | `.js$` | suffix-exact-match | Items that end with `.js` |
|
|
1841
|
+
* | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
|
|
1842
|
+
*
|
|
1843
|
+
* A single pipe character acts as an OR operator. For example, the following
|
|
1844
|
+
* query matches entries that start with `core` and end with either`go`, `rb`,
|
|
1845
|
+
* or`py`.
|
|
1846
|
+
*
|
|
1847
|
+
* ```
|
|
1848
|
+
* ^core go$ | rb$ | py$
|
|
1849
|
+
* ```
|
|
1850
|
+
*/
|
|
1851
|
+
class ExtendedSearch {
|
|
1852
|
+
constructor(
|
|
1853
|
+
pattern,
|
|
1854
|
+
{
|
|
1855
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
1856
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
1857
|
+
includeMatches = Config.includeMatches,
|
|
1858
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
1859
|
+
ignoreLocation = Config.ignoreLocation,
|
|
1860
|
+
findAllMatches = Config.findAllMatches,
|
|
1861
|
+
location = Config.location,
|
|
1862
|
+
threshold = Config.threshold,
|
|
1863
|
+
distance = Config.distance
|
|
1864
|
+
} = {}
|
|
1865
|
+
) {
|
|
1866
|
+
this.query = null;
|
|
1867
|
+
this.options = {
|
|
1868
|
+
isCaseSensitive,
|
|
1869
|
+
ignoreDiacritics,
|
|
1870
|
+
includeMatches,
|
|
1871
|
+
minMatchCharLength,
|
|
1872
|
+
findAllMatches,
|
|
1873
|
+
ignoreLocation,
|
|
1874
|
+
location,
|
|
1875
|
+
threshold,
|
|
1876
|
+
distance
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1879
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
1880
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
1881
|
+
this.pattern = pattern;
|
|
1882
|
+
this.query = parseQuery(this.pattern, this.options);
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
static condition(_, options) {
|
|
1886
|
+
return options.useExtendedSearch
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
searchIn(text) {
|
|
1890
|
+
const query = this.query;
|
|
1891
|
+
|
|
1892
|
+
if (!query) {
|
|
1893
|
+
return {
|
|
1894
|
+
isMatch: false,
|
|
1895
|
+
score: 1
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
const { includeMatches, isCaseSensitive, ignoreDiacritics } = this.options;
|
|
1900
|
+
|
|
1901
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
1902
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
1903
|
+
|
|
1904
|
+
let numMatches = 0;
|
|
1905
|
+
let allIndices = [];
|
|
1906
|
+
let totalScore = 0;
|
|
1907
|
+
|
|
1908
|
+
// ORs
|
|
1909
|
+
for (let i = 0, qLen = query.length; i < qLen; i += 1) {
|
|
1910
|
+
const searchers = query[i];
|
|
1911
|
+
|
|
1912
|
+
// Reset indices
|
|
1913
|
+
allIndices.length = 0;
|
|
1914
|
+
numMatches = 0;
|
|
1915
|
+
|
|
1916
|
+
// ANDs
|
|
1917
|
+
for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
|
|
1918
|
+
const searcher = searchers[j];
|
|
1919
|
+
const { isMatch, indices, score } = searcher.search(text);
|
|
1920
|
+
|
|
1921
|
+
if (isMatch) {
|
|
1922
|
+
numMatches += 1;
|
|
1923
|
+
totalScore += score;
|
|
1924
|
+
if (includeMatches) {
|
|
1925
|
+
const type = searcher.constructor.type;
|
|
1926
|
+
if (MultiMatchSet.has(type)) {
|
|
1927
|
+
allIndices = [...allIndices, ...indices];
|
|
1928
|
+
} else {
|
|
1929
|
+
allIndices.push(indices);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
} else {
|
|
1933
|
+
totalScore = 0;
|
|
1934
|
+
numMatches = 0;
|
|
1935
|
+
allIndices.length = 0;
|
|
1936
|
+
break
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
// OR condition, so if TRUE, return
|
|
1941
|
+
if (numMatches) {
|
|
1942
|
+
let result = {
|
|
1943
|
+
isMatch: true,
|
|
1944
|
+
score: totalScore / numMatches
|
|
1945
|
+
};
|
|
1946
|
+
|
|
1947
|
+
if (includeMatches) {
|
|
1948
|
+
result.indices = allIndices;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
return result
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// Nothing was matched
|
|
1956
|
+
return {
|
|
1957
|
+
isMatch: false,
|
|
1958
|
+
score: 1
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
const registeredSearchers = [];
|
|
1964
|
+
|
|
1965
|
+
function register(...args) {
|
|
1966
|
+
registeredSearchers.push(...args);
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
function createSearcher(pattern, options) {
|
|
1970
|
+
for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
|
|
1971
|
+
let searcherClass = registeredSearchers[i];
|
|
1972
|
+
if (searcherClass.condition(pattern, options)) {
|
|
1973
|
+
return new searcherClass(pattern, options)
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
return new BitapSearch(pattern, options)
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
const LogicalOperator = {
|
|
1981
|
+
AND: '$and',
|
|
1982
|
+
OR: '$or'
|
|
1983
|
+
};
|
|
1984
|
+
|
|
1985
|
+
const KeyType = {
|
|
1986
|
+
PATH: '$path',
|
|
1987
|
+
PATTERN: '$val'
|
|
653
1988
|
};
|
|
1989
|
+
|
|
1990
|
+
const isExpression = (query) =>
|
|
1991
|
+
!!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
|
|
1992
|
+
|
|
1993
|
+
const isPath = (query) => !!query[KeyType.PATH];
|
|
1994
|
+
|
|
1995
|
+
const isLeaf = (query) =>
|
|
1996
|
+
!isArray(query) && isObject(query) && !isExpression(query);
|
|
1997
|
+
|
|
1998
|
+
const convertToExplicit = (query) => ({
|
|
1999
|
+
[LogicalOperator.AND]: Object.keys(query).map((key) => ({
|
|
2000
|
+
[key]: query[key]
|
|
2001
|
+
}))
|
|
2002
|
+
});
|
|
2003
|
+
|
|
2004
|
+
// When `auto` is `true`, the parse function will infer and initialize and add
|
|
2005
|
+
// the appropriate `Searcher` instance
|
|
2006
|
+
function parse$1(query, options, { auto = true } = {}) {
|
|
2007
|
+
const next = (query) => {
|
|
2008
|
+
let keys = Object.keys(query);
|
|
2009
|
+
|
|
2010
|
+
const isQueryPath = isPath(query);
|
|
2011
|
+
|
|
2012
|
+
if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
|
|
2013
|
+
return next(convertToExplicit(query))
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
if (isLeaf(query)) {
|
|
2017
|
+
const key = isQueryPath ? query[KeyType.PATH] : keys[0];
|
|
2018
|
+
|
|
2019
|
+
const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
|
|
2020
|
+
|
|
2021
|
+
if (!isString(pattern)) {
|
|
2022
|
+
throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
const obj = {
|
|
2026
|
+
keyId: createKeyId(key),
|
|
2027
|
+
pattern
|
|
2028
|
+
};
|
|
2029
|
+
|
|
2030
|
+
if (auto) {
|
|
2031
|
+
obj.searcher = createSearcher(pattern, options);
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
return obj
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
let node = {
|
|
2038
|
+
children: [],
|
|
2039
|
+
operator: keys[0]
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
keys.forEach((key) => {
|
|
2043
|
+
const value = query[key];
|
|
2044
|
+
|
|
2045
|
+
if (isArray(value)) {
|
|
2046
|
+
value.forEach((item) => {
|
|
2047
|
+
node.children.push(next(item));
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
|
|
2052
|
+
return node
|
|
2053
|
+
};
|
|
2054
|
+
|
|
2055
|
+
if (!isExpression(query)) {
|
|
2056
|
+
query = convertToExplicit(query);
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
return next(query)
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
// Practical scoring function
|
|
2063
|
+
function computeScore(
|
|
2064
|
+
results,
|
|
2065
|
+
{ ignoreFieldNorm = Config.ignoreFieldNorm }
|
|
2066
|
+
) {
|
|
2067
|
+
results.forEach((result) => {
|
|
2068
|
+
let totalScore = 1;
|
|
2069
|
+
|
|
2070
|
+
result.matches.forEach(({ key, norm, score }) => {
|
|
2071
|
+
const weight = key ? key.weight : null;
|
|
2072
|
+
|
|
2073
|
+
totalScore *= Math.pow(
|
|
2074
|
+
score === 0 && weight ? Number.EPSILON : score,
|
|
2075
|
+
(weight || 1) * (ignoreFieldNorm ? 1 : norm)
|
|
2076
|
+
);
|
|
2077
|
+
});
|
|
2078
|
+
|
|
2079
|
+
result.score = totalScore;
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
function transformMatches(result, data) {
|
|
2084
|
+
const matches = result.matches;
|
|
2085
|
+
data.matches = [];
|
|
2086
|
+
|
|
2087
|
+
if (!isDefined(matches)) {
|
|
2088
|
+
return
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
matches.forEach((match) => {
|
|
2092
|
+
if (!isDefined(match.indices) || !match.indices.length) {
|
|
2093
|
+
return
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
const { indices, value } = match;
|
|
2097
|
+
|
|
2098
|
+
let obj = {
|
|
2099
|
+
indices,
|
|
2100
|
+
value
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2103
|
+
if (match.key) {
|
|
2104
|
+
obj.key = match.key.src;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
if (match.idx > -1) {
|
|
2108
|
+
obj.refIndex = match.idx;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
data.matches.push(obj);
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
function transformScore(result, data) {
|
|
2116
|
+
data.score = result.score;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
function format(
|
|
2120
|
+
results,
|
|
2121
|
+
docs,
|
|
2122
|
+
{
|
|
2123
|
+
includeMatches = Config.includeMatches,
|
|
2124
|
+
includeScore = Config.includeScore
|
|
2125
|
+
} = {}
|
|
2126
|
+
) {
|
|
2127
|
+
const transformers = [];
|
|
2128
|
+
|
|
2129
|
+
if (includeMatches) transformers.push(transformMatches);
|
|
2130
|
+
if (includeScore) transformers.push(transformScore);
|
|
2131
|
+
|
|
2132
|
+
return results.map((result) => {
|
|
2133
|
+
const { idx } = result;
|
|
2134
|
+
|
|
2135
|
+
const data = {
|
|
2136
|
+
item: docs[idx],
|
|
2137
|
+
refIndex: idx
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
if (transformers.length) {
|
|
2141
|
+
transformers.forEach((transformer) => {
|
|
2142
|
+
transformer(result, data);
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
return data
|
|
2147
|
+
})
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
class Fuse {
|
|
2151
|
+
constructor(docs, options = {}, index) {
|
|
2152
|
+
this.options = { ...Config, ...options };
|
|
2153
|
+
|
|
2154
|
+
if (
|
|
2155
|
+
this.options.useExtendedSearch &&
|
|
2156
|
+
false
|
|
2157
|
+
) ;
|
|
2158
|
+
|
|
2159
|
+
this._keyStore = new KeyStore(this.options.keys);
|
|
2160
|
+
|
|
2161
|
+
this.setCollection(docs, index);
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
setCollection(docs, index) {
|
|
2165
|
+
this._docs = docs;
|
|
2166
|
+
|
|
2167
|
+
if (index && !(index instanceof FuseIndex)) {
|
|
2168
|
+
throw new Error(INCORRECT_INDEX_TYPE)
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
this._myIndex =
|
|
2172
|
+
index ||
|
|
2173
|
+
createIndex(this.options.keys, this._docs, {
|
|
2174
|
+
getFn: this.options.getFn,
|
|
2175
|
+
fieldNormWeight: this.options.fieldNormWeight
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
add(doc) {
|
|
2180
|
+
if (!isDefined(doc)) {
|
|
2181
|
+
return
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
this._docs.push(doc);
|
|
2185
|
+
this._myIndex.add(doc);
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
remove(predicate = (/* doc, idx */) => false) {
|
|
2189
|
+
const results = [];
|
|
2190
|
+
|
|
2191
|
+
for (let i = 0, len = this._docs.length; i < len; i += 1) {
|
|
2192
|
+
const doc = this._docs[i];
|
|
2193
|
+
if (predicate(doc, i)) {
|
|
2194
|
+
this.removeAt(i);
|
|
2195
|
+
i -= 1;
|
|
2196
|
+
len -= 1;
|
|
2197
|
+
|
|
2198
|
+
results.push(doc);
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
return results
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
removeAt(idx) {
|
|
2206
|
+
this._docs.splice(idx, 1);
|
|
2207
|
+
this._myIndex.removeAt(idx);
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
getIndex() {
|
|
2211
|
+
return this._myIndex
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
search(query, { limit = -1 } = {}) {
|
|
2215
|
+
const {
|
|
2216
|
+
includeMatches,
|
|
2217
|
+
includeScore,
|
|
2218
|
+
shouldSort,
|
|
2219
|
+
sortFn,
|
|
2220
|
+
ignoreFieldNorm
|
|
2221
|
+
} = this.options;
|
|
2222
|
+
|
|
2223
|
+
let results = isString(query)
|
|
2224
|
+
? isString(this._docs[0])
|
|
2225
|
+
? this._searchStringList(query)
|
|
2226
|
+
: this._searchObjectList(query)
|
|
2227
|
+
: this._searchLogical(query);
|
|
2228
|
+
|
|
2229
|
+
computeScore(results, { ignoreFieldNorm });
|
|
2230
|
+
|
|
2231
|
+
if (shouldSort) {
|
|
2232
|
+
results.sort(sortFn);
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
if (isNumber(limit) && limit > -1) {
|
|
2236
|
+
results = results.slice(0, limit);
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
return format(results, this._docs, {
|
|
2240
|
+
includeMatches,
|
|
2241
|
+
includeScore
|
|
2242
|
+
})
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
_searchStringList(query) {
|
|
2246
|
+
const searcher = createSearcher(query, this.options);
|
|
2247
|
+
const { records } = this._myIndex;
|
|
2248
|
+
const results = [];
|
|
2249
|
+
|
|
2250
|
+
// Iterate over every string in the index
|
|
2251
|
+
records.forEach(({ v: text, i: idx, n: norm }) => {
|
|
2252
|
+
if (!isDefined(text)) {
|
|
2253
|
+
return
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
2257
|
+
|
|
2258
|
+
if (isMatch) {
|
|
2259
|
+
results.push({
|
|
2260
|
+
item: text,
|
|
2261
|
+
idx,
|
|
2262
|
+
matches: [{ score, value: text, norm, indices }]
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
|
|
2267
|
+
return results
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
_searchLogical(query) {
|
|
2271
|
+
|
|
2272
|
+
const expression = parse$1(query, this.options);
|
|
2273
|
+
|
|
2274
|
+
const evaluate = (node, item, idx) => {
|
|
2275
|
+
if (!node.children) {
|
|
2276
|
+
const { keyId, searcher } = node;
|
|
2277
|
+
|
|
2278
|
+
const matches = this._findMatches({
|
|
2279
|
+
key: this._keyStore.get(keyId),
|
|
2280
|
+
value: this._myIndex.getValueForItemAtKeyId(item, keyId),
|
|
2281
|
+
searcher
|
|
2282
|
+
});
|
|
2283
|
+
|
|
2284
|
+
if (matches && matches.length) {
|
|
2285
|
+
return [
|
|
2286
|
+
{
|
|
2287
|
+
idx,
|
|
2288
|
+
item,
|
|
2289
|
+
matches
|
|
2290
|
+
}
|
|
2291
|
+
]
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
return []
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
const res = [];
|
|
2298
|
+
for (let i = 0, len = node.children.length; i < len; i += 1) {
|
|
2299
|
+
const child = node.children[i];
|
|
2300
|
+
const result = evaluate(child, item, idx);
|
|
2301
|
+
if (result.length) {
|
|
2302
|
+
res.push(...result);
|
|
2303
|
+
} else if (node.operator === LogicalOperator.AND) {
|
|
2304
|
+
return []
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
return res
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2310
|
+
const records = this._myIndex.records;
|
|
2311
|
+
const resultMap = {};
|
|
2312
|
+
const results = [];
|
|
2313
|
+
|
|
2314
|
+
records.forEach(({ $: item, i: idx }) => {
|
|
2315
|
+
if (isDefined(item)) {
|
|
2316
|
+
let expResults = evaluate(expression, item, idx);
|
|
2317
|
+
|
|
2318
|
+
if (expResults.length) {
|
|
2319
|
+
// Dedupe when adding
|
|
2320
|
+
if (!resultMap[idx]) {
|
|
2321
|
+
resultMap[idx] = { idx, item, matches: [] };
|
|
2322
|
+
results.push(resultMap[idx]);
|
|
2323
|
+
}
|
|
2324
|
+
expResults.forEach(({ matches }) => {
|
|
2325
|
+
resultMap[idx].matches.push(...matches);
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
});
|
|
2330
|
+
|
|
2331
|
+
return results
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
_searchObjectList(query) {
|
|
2335
|
+
const searcher = createSearcher(query, this.options);
|
|
2336
|
+
const { keys, records } = this._myIndex;
|
|
2337
|
+
const results = [];
|
|
2338
|
+
|
|
2339
|
+
// List is Array<Object>
|
|
2340
|
+
records.forEach(({ $: item, i: idx }) => {
|
|
2341
|
+
if (!isDefined(item)) {
|
|
2342
|
+
return
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
let matches = [];
|
|
2346
|
+
|
|
2347
|
+
// Iterate over every key (i.e, path), and fetch the value at that key
|
|
2348
|
+
keys.forEach((key, keyIndex) => {
|
|
2349
|
+
matches.push(
|
|
2350
|
+
...this._findMatches({
|
|
2351
|
+
key,
|
|
2352
|
+
value: item[keyIndex],
|
|
2353
|
+
searcher
|
|
2354
|
+
})
|
|
2355
|
+
);
|
|
2356
|
+
});
|
|
2357
|
+
|
|
2358
|
+
if (matches.length) {
|
|
2359
|
+
results.push({
|
|
2360
|
+
idx,
|
|
2361
|
+
item,
|
|
2362
|
+
matches
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
});
|
|
2366
|
+
|
|
2367
|
+
return results
|
|
2368
|
+
}
|
|
2369
|
+
_findMatches({ key, value, searcher }) {
|
|
2370
|
+
if (!isDefined(value)) {
|
|
2371
|
+
return []
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
let matches = [];
|
|
2375
|
+
|
|
2376
|
+
if (isArray(value)) {
|
|
2377
|
+
value.forEach(({ v: text, i: idx, n: norm }) => {
|
|
2378
|
+
if (!isDefined(text)) {
|
|
2379
|
+
return
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
2383
|
+
|
|
2384
|
+
if (isMatch) {
|
|
2385
|
+
matches.push({
|
|
2386
|
+
score,
|
|
2387
|
+
key,
|
|
2388
|
+
value: text,
|
|
2389
|
+
idx,
|
|
2390
|
+
norm,
|
|
2391
|
+
indices
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
} else {
|
|
2396
|
+
const { v: text, n: norm } = value;
|
|
2397
|
+
|
|
2398
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
2399
|
+
|
|
2400
|
+
if (isMatch) {
|
|
2401
|
+
matches.push({ score, key, value: text, norm, indices });
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
return matches
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
Fuse.version = '7.1.0';
|
|
2410
|
+
Fuse.createIndex = createIndex;
|
|
2411
|
+
Fuse.parseIndex = parseIndex;
|
|
2412
|
+
Fuse.config = Config;
|
|
2413
|
+
|
|
2414
|
+
{
|
|
2415
|
+
Fuse.parseQuery = parse$1;
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
{
|
|
2419
|
+
register(ExtendedSearch);
|
|
2420
|
+
}
|
|
2421
|
+
|
|
654
2422
|
var defaultFuseOptions = {
|
|
655
2423
|
shouldSort: true,
|
|
656
2424
|
threshold: 0.6,
|
|
@@ -1590,7 +3358,7 @@ var unitlessKeys = {
|
|
|
1590
3358
|
strokeWidth: 1
|
|
1591
3359
|
};
|
|
1592
3360
|
|
|
1593
|
-
var f="undefined"!=typeof process&&undefined!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",m="active",y="data-styled-version",v="6.1.14",g="/*!sc*/\n",S="undefined"!=typeof window&&"HTMLElement"in window,w=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&undefined!==process.env&&undefined!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&undefined!==process.env&&undefined!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),E=/invalid hook call/i,N=new Set,P=function(t,n){if("production"!==process.env.NODE_ENV){var o$1=n?' with the id of "'.concat(n,'"'):"",s="The component ".concat(t).concat(o$1," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.",i=console.error;try{var a=!0;console.error=function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];E.test(t)?(a=!1,N.delete(s)):i.apply(void 0,__spreadArray([t],n,!1));},o.useRef(),a&&!N.has(s)&&(console.warn(s),N.add(s));}catch(e){E.test(e.message)&&N.delete(s);}finally{console.error=i;}}},_=Object.freeze([]),C=Object.freeze({});function I(e,t,n){return undefined===n&&(n=C),e.theme!==n.theme&&e.theme||t||n.theme}var A=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),O=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,D=/(^-|-$)/g;function R(e){return e.replace(O,"-").replace(D,"")}var T=/(a)(d)/gi,k=52,j=function(e){return String.fromCharCode(e+(e>25?39:97))};function x(e){var t,n="";for(t=Math.abs(e);t>k;t=t/k|0)n=j(t%k)+n;return (j(t%k)+n).replace(T,"$1-$2")}var V,F=5381,M=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},z=function(e){return M(F,e)};function $(e){return x(z(e)>>>0)}function B(e){return "production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function L(e){return "string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var G="function"==typeof Symbol&&Symbol.for,Y=G?Symbol.for("react.memo"):60115,W=G?Symbol.for("react.forward_ref"):60112,q={childContextTypes:true,contextType:true,contextTypes:true,defaultProps:true,displayName:true,getDefaultProps:true,getDerivedStateFromError:true,getDerivedStateFromProps:true,mixins:true,propTypes:true,type:true},H={name:true,length:true,prototype:true,caller:true,callee:true,arguments:true,arity:true},U={$$typeof:true,compare:true,defaultProps:true,displayName:true,propTypes:true,type:true},J=((V={})[W]={$$typeof:true,render:true,defaultProps:true,displayName:true,propTypes:true},V[Y]=U,V);function X(e){return ("type"in(t=e)&&t.type.$$typeof)===Y?U:"$$typeof"in e?J[e.$$typeof]:q;var t;}var Z=Object.defineProperty,K=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,ee=Object.getOwnPropertyDescriptor,te=Object.getPrototypeOf,ne=Object.prototype;function oe(e,t,n){if("string"!=typeof t){if(ne){var o=te(t);o&&o!==ne&&oe(e,o,n);}var r=K(t);Q&&(r=r.concat(Q(t)));for(var s=X(e),i=X(t),a=0;a<r.length;++a){var c=r[a];if(!(c in H||n&&n[c]||i&&c in i||s&&c in s)){var l=ee(t,c);try{Z(e,c,l);}catch(e){}}}}return e}function re(e){return "function"==typeof e}function se(e){return "object"==typeof e&&"styledComponentId"in e}function ie(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function ae(e,t){if(0===e.length)return "";for(var n=e[0],o=1;o<e.length;o++)n+=e[o];return n}function ce(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function le(e,t,n){if(undefined===n&&(n=false),!n&&!ce(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var o=0;o<t.length;o++)e[o]=le(e[o],t[o]);else if(ce(t))for(var o in t)e[o]=le(e[o],t[o]);return e}function ue(e,t){Object.defineProperty(e,"toString",{value:t});}var pe="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function de(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],o=[],r=1,s=e.length;r<s;r+=1)o.push(e[r]);return o.forEach(function(e){n=n.replace(/%[a-z]/,e);}),n}function he(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return "production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(n.length>0?" Args: ".concat(n.join(", ")):"")):new Error(de.apply(undefined,__spreadArray([pe[t]],n,false)).trim())}var fe=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e;}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,o=n.length,r=o;e>=r;)if((r<<=1)<0)throw he(16,"".concat(e));this.groupSizes=new Uint32Array(r),this.groupSizes.set(n),this.length=r;for(var s=o;s<r;s++)this.groupSizes[s]=0;}for(var i=this.indexOfGroup(e+1),a=(s=0,t.length);s<a;s++)this.tag.insertRule(i,t[s])&&(this.groupSizes[e]++,i++);},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),o=n+t;this.groupSizes[e]=0;for(var r=n;r<o;r++)this.tag.deleteRule(n);}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],o=this.indexOfGroup(e),r=o+n,s=o;s<r;s++)t+="".concat(this.tag.getRule(s)).concat(g);return t},e}(),me=1<<30,ye=new Map,ve=new Map,ge=1,Se=function(e){if(ye.has(e))return ye.get(e);for(;ve.has(ge);)ge++;var t=ge++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>me))throw he(16,"".concat(t));return ye.set(e,t),ve.set(t,e),t},we=function(e,t){ge=t+1,ye.set(e,t),ve.set(t,e);},be="style[".concat(f,"][").concat(y,'="').concat(v,'"]'),Ee=new RegExp("^".concat(f,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Ne=function(e,t,n){for(var o,r=n.split(","),s=0,i=r.length;s<i;s++)(o=r[s])&&e.registerName(t,o);},Pe=function(e,t){for(var n,o=(null!==(n=t.textContent)&&undefined!==n?n:"").split(g),r=[],s=0,i=o.length;s<i;s++){var a=o[s].trim();if(a){var c=a.match(Ee);if(c){var l=0|parseInt(c[1],10),u=c[2];0!==l&&(we(u,l),Ne(e,u,c[3]),e.getTag().insertRules(l,r)),r.length=0;}else r.push(a);}}},_e=function(e){for(var t=document.querySelectorAll(be),n=0,o=t.length;n<o;n++){var r=t[n];r&&r.getAttribute(f)!==m&&(Pe(e,r),r.parentNode&&r.parentNode.removeChild(r));}};function Ce(){return "undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null}var Ie=function(e){var t=document.head,n=e||t,o=document.createElement("style"),r=function(e){var t=Array.from(e.querySelectorAll("style[".concat(f,"]")));return t[t.length-1]}(n),s=undefined!==r?r.nextSibling:null;o.setAttribute(f,m),o.setAttribute(y,v);var i=Ce();return i&&o.setAttribute("nonce",i),n.insertBefore(o,s),o},Ae=function(){function e(e){this.element=Ie(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,o=t.length;n<o;n++){var r=t[n];if(r.ownerNode===e)return r}throw he(17)}(this.element),this.length=0;}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return false}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--;},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Oe=function(){function e(e){this.element=Ie(e),this.nodes=this.element.childNodes,this.length=0;}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,true}return false},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--;},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),De=function(){function e(e){this.rules=[],this.length=0;}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,true)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--;},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Re=S,Te={isServer:!S,useCSSOMInjection:!w},ke=function(){function e(e,n,o){ undefined===e&&(e=C),undefined===n&&(n={});var r=this;this.options=__assign(__assign({},Te),e),this.gs=n,this.names=new Map(o),this.server=!!e.isServer,!this.server&&S&&Re&&(Re=false,_e(this)),ue(this,function(){return function(e){for(var t=e.getTag(),n=t.length,o="",r=function(n){var r=function(e){return ve.get(e)}(n);if(undefined===r)return "continue";var s=e.names.get(r),i=t.getGroup(n);if(undefined===s||!s.size||0===i.length)return "continue";var a="".concat(f,".g").concat(n,'[id="').concat(r,'"]'),c="";undefined!==s&&s.forEach(function(e){e.length>0&&(c+="".concat(e,","));}),o+="".concat(i).concat(a,'{content:"').concat(c,'"}').concat(g);},s=0;s<n;s++)r(s);return o}(r)});}return e.registerId=function(e){return Se(e)},e.prototype.rehydrate=function(){!this.server&&S&&_e(this);},e.prototype.reconstructWithOptions=function(n,o){return undefined===o&&(o=true),new e(__assign(__assign({},this.options),n),this.gs,o&&this.names||undefined)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new De(n):t?new Ae(n):new Oe(n)}(this.options),new fe(e)));var e;},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(Se(e),this.names.has(e))this.names.get(e).add(t);else {var n=new Set;n.add(t),this.names.set(e,n);}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(Se(e),n);},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear();},e.prototype.clearRules=function(e){this.getTag().clearGroup(Se(e)),this.clearNames(e);},e.prototype.clearTag=function(){this.tag=undefined;},e}(),je=/&/g,xe=/^\s*\/\/.*$/gm;function Ve(e,t){return e.map(function(e){return "rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map(function(e){return "".concat(t," ").concat(e)})),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=Ve(e.children,t)),e})}function Fe(e){var t,n,o,r=C,s=r.options,i=undefined===s?C:s,a=r.plugins,c=undefined===a?_:a,l=function(e,o,r){return r.startsWith(n)&&r.endsWith(n)&&r.replaceAll(n,"").length>0?".".concat(t):e},u=c.slice();u.push(function(e){e.type===RULESET&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(je,n).replace(o,l));}),i.prefix&&u.push(prefixer),u.push(stringify);var p=function(e,r,s,a){ undefined===r&&(r=""),undefined===s&&(s=""),undefined===a&&(a="&"),t=a,n=r,o=new RegExp("\\".concat(n,"\\b"),"g");var c=e.replace(xe,""),l=compile(s||r?"".concat(s," ").concat(r," { ").concat(c," }"):c);i.namespace&&(l=Ve(l,i.namespace));var p=[];return serialize(l,middleware(u.concat(rulesheet(function(e){return p.push(e)})))),p};return p.hash=c.length?c.reduce(function(e,t){return t.name||he(15),M(e,t.name)},F).toString():"",p}var Me=new ke,ze=Fe(),$e=o.createContext({shouldForwardProp:undefined,styleSheet:Me,stylis:ze});$e.Consumer;o.createContext(undefined);function Ge(){return o.useContext($e)}var We=function(){function e(e,t){var n=this;this.inject=function(e,t){ undefined===t&&(t=ze);var o=n.name+t.hash;e.hasNameForId(n.id,o)||e.insertRules(n.id,o,t(n.rules,o,"@keyframes"));},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t,ue(this,function(){throw he(12,String(n.name))});}return e.prototype.getName=function(e){return undefined===e&&(e=ze),this.name+e.hash},e}(),qe=function(e){return e>="A"&&e<="Z"};function He(e){for(var t="",n=0;n<e.length;n++){var o=e[n];if(1===n&&"-"===o&&"-"===e[0])return e;qe(o)?t+="-"+o.toLowerCase():t+=o;}return t.startsWith("ms-")?"-"+t:t}var Ue=function(e){return null==e||false===e||""===e},Je=function(t){var n,o,r=[];for(var s in t){var i=t[s];t.hasOwnProperty(s)&&!Ue(i)&&(Array.isArray(i)&&i.isCss||re(i)?r.push("".concat(He(s),":"),i,";"):ce(i)?r.push.apply(r,__spreadArray(__spreadArray(["".concat(s," {")],Je(i),false),["}"],false)):r.push("".concat(He(s),": ").concat((n=s,null==(o=i)||"boolean"==typeof o||""===o?"":"number"!=typeof o||0===o||n in unitlessKeys||n.startsWith("--")?String(o).trim():"".concat(o,"px")),";")));}return r};function Xe(e,t,n,o){if(Ue(e))return [];if(se(e))return [".".concat(e.styledComponentId)];if(re(e)){if(!re(s=e)||s.prototype&&s.prototype.isReactComponent||!t)return [e];var r=e(t);return "production"===process.env.NODE_ENV||"object"!=typeof r||Array.isArray(r)||r instanceof We||ce(r)||null===r||console.error("".concat(B(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Xe(r,t,n,o)}var s;return e instanceof We?n?(e.inject(n,o),[e.getName(o)]):[e]:ce(e)?Je(e):Array.isArray(e)?Array.prototype.concat.apply(_,e.map(function(e){return Xe(e,t,n,o)})):[e.toString()]}function Ze(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(re(n)&&!se(n))return false}return true}var Ke=z(v),Qe=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(undefined===n||n.isStatic)&&Ze(e),this.componentId=t,this.baseHash=M(Ke,t),this.baseStyle=n,ke.registerId(t);}return e.prototype.generateAndInjectStyles=function(e,t,n){var o=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))o=ie(o,this.staticRulesId);else {var r=ae(Xe(this.rules,e,t,n)),s=x(M(this.baseHash,r)>>>0);if(!t.hasNameForId(this.componentId,s)){var i=n(r,".".concat(s),undefined,this.componentId);t.insertRules(this.componentId,s,i);}o=ie(o,s),this.staticRulesId=s;}else {for(var a=M(this.baseHash,n.hash),c="",l=0;l<this.rules.length;l++){var u=this.rules[l];if("string"==typeof u)c+=u,"production"!==process.env.NODE_ENV&&(a=M(a,u));else if(u){var p=ae(Xe(u,e,t,n));a=M(a,p+l),c+=p;}}if(c){var d=x(a>>>0);t.hasNameForId(this.componentId,d)||t.insertRules(this.componentId,d,n(c,".".concat(d),undefined,this.componentId)),o=ie(o,d);}}return o},e}(),et=o.createContext(undefined);et.Consumer;var rt={},st=new Set;function it(e,r,s){var i=se(e),a=e,c=!L(e),p=r.attrs,d=undefined===p?_:p,h=r.componentId,f=undefined===h?function(e,t){var n="string"!=typeof e?"sc":R(e);rt[n]=(rt[n]||0)+1;var o="".concat(n,"-").concat($(v+n+rt[n]));return t?"".concat(t,"-").concat(o):o}(r.displayName,r.parentComponentId):h,m=r.displayName,y=undefined===m?function(e){return L(e)?"styled.".concat(e):"Styled(".concat(B(e),")")}(e):m,g=r.displayName&&r.componentId?"".concat(R(r.displayName),"-").concat(r.componentId):r.componentId||f,S=i&&a.attrs?a.attrs.concat(d).filter(Boolean):d,w=r.shouldForwardProp;if(i&&a.shouldForwardProp){var b=a.shouldForwardProp;if(r.shouldForwardProp){var E=r.shouldForwardProp;w=function(e,t){return b(e,t)&&E(e,t)};}else w=b;}var N=new Qe(s,g,i?a.componentStyle:undefined);function O(e,r){return function(e,r,s){var i=e.attrs,a=e.componentStyle,c=e.defaultProps,p=e.foldedComponentIds,d=e.styledComponentId,h=e.target,f=o.useContext(et),m=Ge(),y=e.shouldForwardProp||m.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(d);var v=I(r,f,c)||C,g=function(e,n,o){for(var r,s=__assign(__assign({},n),{className:undefined,theme:o}),i=0;i<e.length;i+=1){var a=re(r=e[i])?r(s):r;for(var c in a)s[c]="className"===c?ie(s[c],a[c]):"style"===c?__assign(__assign({},s[c]),a[c]):a[c];}return n.className&&(s.className=ie(s.className,n.className)),s}(i,r,v),S=g.as||h,w={};for(var b in g) undefined===g[b]||"$"===b[0]||"as"===b||"theme"===b&&g.theme===v||("forwardedAs"===b?w.as=g.forwardedAs:y&&!y(b,S)||(w[b]=g[b],y||"development"!==process.env.NODE_ENV||isPropValid(b)||st.has(b)||!A.has(S)||(st.add(b),console.warn('styled-components: it looks like an unknown prop "'.concat(b,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var E=function(e,t){var n=Ge(),o$1=e.generateAndInjectStyles(t,n.styleSheet,n.stylis);return "production"!==process.env.NODE_ENV&&o.useDebugValue(o$1),o$1}(a,g);"production"!==process.env.NODE_ENV&&e.warnTooManyClasses&&e.warnTooManyClasses(E);var N=ie(p,d);return E&&(N+=" "+E),g.className&&(N+=" "+g.className),w[L(S)&&!A.has(S)?"class":"className"]=N,s&&(w.ref=s),o.createElement(S,w)}(D,e,r)}O.displayName=y;var D=o.forwardRef(O);return D.attrs=S,D.componentStyle=N,D.displayName=y,D.shouldForwardProp=w,D.foldedComponentIds=i?ie(a.foldedComponentIds,a.styledComponentId):"",D.styledComponentId=g,D.target=i?a.target:e,Object.defineProperty(D,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=i?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var o=0,r=t;o<r.length;o++)le(e,r[o],true);return e}({},a.defaultProps,e):e;}}),"production"!==process.env.NODE_ENV&&(P(y,g),D.warnTooManyClasses=function(e,t){var n={},o=false;return function(r){if(!o&&(n[r]=true,Object.keys(n).length>=200)){var s=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(s,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),o=true,n={};}}}(y,g)),ue(D,function(){return ".".concat(D.styledComponentId)}),c&&oe(D,e,{attrs:true,componentStyle:true,displayName:true,foldedComponentIds:true,shouldForwardProp:true,styledComponentId:true,target:true}),D}function at(e,t){for(var n=[e[0]],o=0,r=t.length;o<r;o+=1)n.push(t[o],e[o+1]);return n}var ct=function(e){return Object.assign(e,{isCss:true})};function lt(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(re(t)||ce(t))return ct(Xe(at(_,__spreadArray([t],n,true))));var r=t;return 0===n.length&&1===r.length&&"string"==typeof r[0]?Xe(r):ct(Xe(at(r,n)))}function ut(n,o,r){if(undefined===r&&(r=C),!o)throw he(1,o);var s=function(t){for(var s=[],i=1;i<arguments.length;i++)s[i-1]=arguments[i];return n(o,r,lt.apply(undefined,__spreadArray([t],s,false)))};return s.attrs=function(e){return ut(n,o,__assign(__assign({},r),{attrs:Array.prototype.concat(r.attrs,e).filter(Boolean)}))},s.withConfig=function(e){return ut(n,o,__assign(__assign({},r),e))},s}var pt=function(e){return ut(it,e)},dt=pt;A.forEach(function(e){dt[e]=pt(e);});"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var St="__sc-".concat(f,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[St]||(window[St]=0),1===window[St]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[St]+=1);
|
|
3361
|
+
var f="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",m="active",y="data-styled-version",v="6.1.15",g="/*!sc*/\n",S="undefined"!=typeof window&&"HTMLElement"in window,w=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),E=/invalid hook call/i,N=new Set,P=function(t,n){if("production"!==process.env.NODE_ENV){var o$1=n?' with the id of "'.concat(n,'"'):"",s="The component ".concat(t).concat(o$1," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.",i=console.error;try{var a=!0;console.error=function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];E.test(t)?(a=!1,N.delete(s)):i.apply(void 0,__spreadArray([t],n,!1));},o.useRef(),a&&!N.has(s)&&(console.warn(s),N.add(s));}catch(e){E.test(e.message)&&N.delete(s);}finally{console.error=i;}}},_=Object.freeze([]),C=Object.freeze({});function I(e,t,n){return void 0===n&&(n=C),e.theme!==n.theme&&e.theme||t||n.theme}var A=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),O=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,D=/(^-|-$)/g;function R(e){return e.replace(O,"-").replace(D,"")}var T=/(a)(d)/gi,k=52,j=function(e){return String.fromCharCode(e+(e>25?39:97))};function x(e){var t,n="";for(t=Math.abs(e);t>k;t=t/k|0)n=j(t%k)+n;return (j(t%k)+n).replace(T,"$1-$2")}var V,F=5381,M=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},z=function(e){return M(F,e)};function $(e){return x(z(e)>>>0)}function B(e){return "production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function L(e){return "string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var G="function"==typeof Symbol&&Symbol.for,Y=G?Symbol.for("react.memo"):60115,W=G?Symbol.for("react.forward_ref"):60112,q={childContextTypes:true,contextType:true,contextTypes:true,defaultProps:true,displayName:true,getDefaultProps:true,getDerivedStateFromError:true,getDerivedStateFromProps:true,mixins:true,propTypes:true,type:true},H={name:true,length:true,prototype:true,caller:true,callee:true,arguments:true,arity:true},U={$$typeof:true,compare:true,defaultProps:true,displayName:true,propTypes:true,type:true},J=((V={})[W]={$$typeof:true,render:true,defaultProps:true,displayName:true,propTypes:true},V[Y]=U,V);function X(e){return ("type"in(t=e)&&t.type.$$typeof)===Y?U:"$$typeof"in e?J[e.$$typeof]:q;var t;}var Z=Object.defineProperty,K=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,ee=Object.getOwnPropertyDescriptor,te=Object.getPrototypeOf,ne=Object.prototype;function oe(e,t,n){if("string"!=typeof t){if(ne){var o=te(t);o&&o!==ne&&oe(e,o,n);}var r=K(t);Q&&(r=r.concat(Q(t)));for(var s=X(e),i=X(t),a=0;a<r.length;++a){var c=r[a];if(!(c in H||n&&n[c]||i&&c in i||s&&c in s)){var l=ee(t,c);try{Z(e,c,l);}catch(e){}}}}return e}function re(e){return "function"==typeof e}function se(e){return "object"==typeof e&&"styledComponentId"in e}function ie(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function ae(e,t){if(0===e.length)return "";for(var n=e[0],o=1;o<e.length;o++)n+=e[o];return n}function ce(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function le(e,t,n){if(void 0===n&&(n=false),!n&&!ce(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var o=0;o<t.length;o++)e[o]=le(e[o],t[o]);else if(ce(t))for(var o in t)e[o]=le(e[o],t[o]);return e}function ue(e,t){Object.defineProperty(e,"toString",{value:t});}var pe="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function de(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],o=[],r=1,s=e.length;r<s;r+=1)o.push(e[r]);return o.forEach(function(e){n=n.replace(/%[a-z]/,e);}),n}function he(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return "production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(n.length>0?" Args: ".concat(n.join(", ")):"")):new Error(de.apply(void 0,__spreadArray([pe[t]],n,false)).trim())}var fe=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e;}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,o=n.length,r=o;e>=r;)if((r<<=1)<0)throw he(16,"".concat(e));this.groupSizes=new Uint32Array(r),this.groupSizes.set(n),this.length=r;for(var s=o;s<r;s++)this.groupSizes[s]=0;}for(var i=this.indexOfGroup(e+1),a=(s=0,t.length);s<a;s++)this.tag.insertRule(i,t[s])&&(this.groupSizes[e]++,i++);},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),o=n+t;this.groupSizes[e]=0;for(var r=n;r<o;r++)this.tag.deleteRule(n);}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],o=this.indexOfGroup(e),r=o+n,s=o;s<r;s++)t+="".concat(this.tag.getRule(s)).concat(g);return t},e}(),me=1<<30,ye=new Map,ve=new Map,ge=1,Se=function(e){if(ye.has(e))return ye.get(e);for(;ve.has(ge);)ge++;var t=ge++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>me))throw he(16,"".concat(t));return ye.set(e,t),ve.set(t,e),t},we=function(e,t){ge=t+1,ye.set(e,t),ve.set(t,e);},be="style[".concat(f,"][").concat(y,'="').concat(v,'"]'),Ee=new RegExp("^".concat(f,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Ne=function(e,t,n){for(var o,r=n.split(","),s=0,i=r.length;s<i;s++)(o=r[s])&&e.registerName(t,o);},Pe=function(e,t){for(var n,o=(null!==(n=t.textContent)&&void 0!==n?n:"").split(g),r=[],s=0,i=o.length;s<i;s++){var a=o[s].trim();if(a){var c=a.match(Ee);if(c){var l=0|parseInt(c[1],10),u=c[2];0!==l&&(we(u,l),Ne(e,u,c[3]),e.getTag().insertRules(l,r)),r.length=0;}else r.push(a);}}},_e=function(e){for(var t=document.querySelectorAll(be),n=0,o=t.length;n<o;n++){var r=t[n];r&&r.getAttribute(f)!==m&&(Pe(e,r),r.parentNode&&r.parentNode.removeChild(r));}};function Ce(){return "undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null}var Ie=function(e){var t=document.head,n=e||t,o=document.createElement("style"),r=function(e){var t=Array.from(e.querySelectorAll("style[".concat(f,"]")));return t[t.length-1]}(n),s=void 0!==r?r.nextSibling:null;o.setAttribute(f,m),o.setAttribute(y,v);var i=Ce();return i&&o.setAttribute("nonce",i),n.insertBefore(o,s),o},Ae=function(){function e(e){this.element=Ie(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,o=t.length;n<o;n++){var r=t[n];if(r.ownerNode===e)return r}throw he(17)}(this.element),this.length=0;}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return false}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--;},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Oe=function(){function e(e){this.element=Ie(e),this.nodes=this.element.childNodes,this.length=0;}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,true}return false},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--;},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),De=function(){function e(e){this.rules=[],this.length=0;}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,true)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--;},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Re=S,Te={isServer:!S,useCSSOMInjection:!w},ke=function(){function e(e,n,o){ void 0===e&&(e=C),void 0===n&&(n={});var r=this;this.options=__assign(__assign({},Te),e),this.gs=n,this.names=new Map(o),this.server=!!e.isServer,!this.server&&S&&Re&&(Re=false,_e(this)),ue(this,function(){return function(e){for(var t=e.getTag(),n=t.length,o="",r=function(n){var r=function(e){return ve.get(e)}(n);if(void 0===r)return "continue";var s=e.names.get(r),i=t.getGroup(n);if(void 0===s||!s.size||0===i.length)return "continue";var a="".concat(f,".g").concat(n,'[id="').concat(r,'"]'),c="";void 0!==s&&s.forEach(function(e){e.length>0&&(c+="".concat(e,","));}),o+="".concat(i).concat(a,'{content:"').concat(c,'"}').concat(g);},s=0;s<n;s++)r(s);return o}(r)});}return e.registerId=function(e){return Se(e)},e.prototype.rehydrate=function(){!this.server&&S&&_e(this);},e.prototype.reconstructWithOptions=function(n,o){return void 0===o&&(o=true),new e(__assign(__assign({},this.options),n),this.gs,o&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new De(n):t?new Ae(n):new Oe(n)}(this.options),new fe(e)));var e;},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(Se(e),this.names.has(e))this.names.get(e).add(t);else {var n=new Set;n.add(t),this.names.set(e,n);}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(Se(e),n);},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear();},e.prototype.clearRules=function(e){this.getTag().clearGroup(Se(e)),this.clearNames(e);},e.prototype.clearTag=function(){this.tag=void 0;},e}(),je=/&/g,xe=/^\s*\/\/.*$/gm;function Ve(e,t){return e.map(function(e){return "rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map(function(e){return "".concat(t," ").concat(e)})),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=Ve(e.children,t)),e})}function Fe(e){var t,n,o,r=C,s=r.options,i=void 0===s?C:s,a=r.plugins,c=void 0===a?_:a,l=function(e,o,r){return r.startsWith(n)&&r.endsWith(n)&&r.replaceAll(n,"").length>0?".".concat(t):e},u=c.slice();u.push(function(e){e.type===RULESET&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(je,n).replace(o,l));}),i.prefix&&u.push(prefixer),u.push(stringify);var p=function(e,r,s,a){ void 0===r&&(r=""),void 0===s&&(s=""),void 0===a&&(a="&"),t=a,n=r,o=new RegExp("\\".concat(n,"\\b"),"g");var c=e.replace(xe,""),l=compile(s||r?"".concat(s," ").concat(r," { ").concat(c," }"):c);i.namespace&&(l=Ve(l,i.namespace));var p=[];return serialize(l,middleware(u.concat(rulesheet(function(e){return p.push(e)})))),p};return p.hash=c.length?c.reduce(function(e,t){return t.name||he(15),M(e,t.name)},F).toString():"",p}var Me=new ke,ze=Fe(),$e=o.createContext({shouldForwardProp:void 0,styleSheet:Me,stylis:ze});$e.Consumer;o.createContext(void 0);function Ge(){return o.useContext($e)}var We=function(){function e(e,t){var n=this;this.inject=function(e,t){ void 0===t&&(t=ze);var o=n.name+t.hash;e.hasNameForId(n.id,o)||e.insertRules(n.id,o,t(n.rules,o,"@keyframes"));},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t,ue(this,function(){throw he(12,String(n.name))});}return e.prototype.getName=function(e){return void 0===e&&(e=ze),this.name+e.hash},e}(),qe=function(e){return e>="A"&&e<="Z"};function He(e){for(var t="",n=0;n<e.length;n++){var o=e[n];if(1===n&&"-"===o&&"-"===e[0])return e;qe(o)?t+="-"+o.toLowerCase():t+=o;}return t.startsWith("ms-")?"-"+t:t}var Ue=function(e){return null==e||false===e||""===e},Je=function(t){var n,o,r=[];for(var s in t){var i=t[s];t.hasOwnProperty(s)&&!Ue(i)&&(Array.isArray(i)&&i.isCss||re(i)?r.push("".concat(He(s),":"),i,";"):ce(i)?r.push.apply(r,__spreadArray(__spreadArray(["".concat(s," {")],Je(i),false),["}"],false)):r.push("".concat(He(s),": ").concat((n=s,null==(o=i)||"boolean"==typeof o||""===o?"":"number"!=typeof o||0===o||n in unitlessKeys||n.startsWith("--")?String(o).trim():"".concat(o,"px")),";")));}return r};function Xe(e,t,n,o){if(Ue(e))return [];if(se(e))return [".".concat(e.styledComponentId)];if(re(e)){if(!re(s=e)||s.prototype&&s.prototype.isReactComponent||!t)return [e];var r=e(t);return "production"===process.env.NODE_ENV||"object"!=typeof r||Array.isArray(r)||r instanceof We||ce(r)||null===r||console.error("".concat(B(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Xe(r,t,n,o)}var s;return e instanceof We?n?(e.inject(n,o),[e.getName(o)]):[e]:ce(e)?Je(e):Array.isArray(e)?Array.prototype.concat.apply(_,e.map(function(e){return Xe(e,t,n,o)})):[e.toString()]}function Ze(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(re(n)&&!se(n))return false}return true}var Ke=z(v),Qe=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(void 0===n||n.isStatic)&&Ze(e),this.componentId=t,this.baseHash=M(Ke,t),this.baseStyle=n,ke.registerId(t);}return e.prototype.generateAndInjectStyles=function(e,t,n){var o=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))o=ie(o,this.staticRulesId);else {var r=ae(Xe(this.rules,e,t,n)),s=x(M(this.baseHash,r)>>>0);if(!t.hasNameForId(this.componentId,s)){var i=n(r,".".concat(s),void 0,this.componentId);t.insertRules(this.componentId,s,i);}o=ie(o,s),this.staticRulesId=s;}else {for(var a=M(this.baseHash,n.hash),c="",l=0;l<this.rules.length;l++){var u=this.rules[l];if("string"==typeof u)c+=u,"production"!==process.env.NODE_ENV&&(a=M(a,u));else if(u){var p=ae(Xe(u,e,t,n));a=M(a,p+l),c+=p;}}if(c){var d=x(a>>>0);t.hasNameForId(this.componentId,d)||t.insertRules(this.componentId,d,n(c,".".concat(d),void 0,this.componentId)),o=ie(o,d);}}return o},e}(),et=o.createContext(void 0);et.Consumer;var rt={},st=new Set;function it(e,r,s){var i=se(e),a=e,c=!L(e),p=r.attrs,d=void 0===p?_:p,h=r.componentId,f=void 0===h?function(e,t){var n="string"!=typeof e?"sc":R(e);rt[n]=(rt[n]||0)+1;var o="".concat(n,"-").concat($(v+n+rt[n]));return t?"".concat(t,"-").concat(o):o}(r.displayName,r.parentComponentId):h,m=r.displayName,y=void 0===m?function(e){return L(e)?"styled.".concat(e):"Styled(".concat(B(e),")")}(e):m,g=r.displayName&&r.componentId?"".concat(R(r.displayName),"-").concat(r.componentId):r.componentId||f,S=i&&a.attrs?a.attrs.concat(d).filter(Boolean):d,w=r.shouldForwardProp;if(i&&a.shouldForwardProp){var b=a.shouldForwardProp;if(r.shouldForwardProp){var E=r.shouldForwardProp;w=function(e,t){return b(e,t)&&E(e,t)};}else w=b;}var N=new Qe(s,g,i?a.componentStyle:void 0);function O(e,r){return function(e,r,s){var i=e.attrs,a=e.componentStyle,c=e.defaultProps,p=e.foldedComponentIds,d=e.styledComponentId,h=e.target,f=o.useContext(et),m=Ge(),y=e.shouldForwardProp||m.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(d);var v=I(r,f,c)||C,g=function(e,n,o){for(var r,s=__assign(__assign({},n),{className:void 0,theme:o}),i=0;i<e.length;i+=1){var a=re(r=e[i])?r(s):r;for(var c in a)s[c]="className"===c?ie(s[c],a[c]):"style"===c?__assign(__assign({},s[c]),a[c]):a[c];}return n.className&&(s.className=ie(s.className,n.className)),s}(i,r,v),S=g.as||h,w={};for(var b in g) void 0===g[b]||"$"===b[0]||"as"===b||"theme"===b&&g.theme===v||("forwardedAs"===b?w.as=g.forwardedAs:y&&!y(b,S)||(w[b]=g[b],y||"development"!==process.env.NODE_ENV||isPropValid(b)||st.has(b)||!A.has(S)||(st.add(b),console.warn('styled-components: it looks like an unknown prop "'.concat(b,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var E=function(e,t){var n=Ge(),o$1=e.generateAndInjectStyles(t,n.styleSheet,n.stylis);return "production"!==process.env.NODE_ENV&&o.useDebugValue(o$1),o$1}(a,g);"production"!==process.env.NODE_ENV&&e.warnTooManyClasses&&e.warnTooManyClasses(E);var N=ie(p,d);return E&&(N+=" "+E),g.className&&(N+=" "+g.className),w[L(S)&&!A.has(S)?"class":"className"]=N,s&&(w.ref=s),o.createElement(S,w)}(D,e,r)}O.displayName=y;var D=o.forwardRef(O);return D.attrs=S,D.componentStyle=N,D.displayName=y,D.shouldForwardProp=w,D.foldedComponentIds=i?ie(a.foldedComponentIds,a.styledComponentId):"",D.styledComponentId=g,D.target=i?a.target:e,Object.defineProperty(D,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=i?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var o=0,r=t;o<r.length;o++)le(e,r[o],true);return e}({},a.defaultProps,e):e;}}),"production"!==process.env.NODE_ENV&&(P(y,g),D.warnTooManyClasses=function(e,t){var n={},o=false;return function(r){if(!o&&(n[r]=true,Object.keys(n).length>=200)){var s=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(s,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),o=true,n={};}}}(y,g)),ue(D,function(){return ".".concat(D.styledComponentId)}),c&&oe(D,e,{attrs:true,componentStyle:true,displayName:true,foldedComponentIds:true,shouldForwardProp:true,styledComponentId:true,target:true}),D}function at(e,t){for(var n=[e[0]],o=0,r=t.length;o<r;o+=1)n.push(t[o],e[o+1]);return n}var ct=function(e){return Object.assign(e,{isCss:true})};function lt(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(re(t)||ce(t))return ct(Xe(at(_,__spreadArray([t],n,true))));var r=t;return 0===n.length&&1===r.length&&"string"==typeof r[0]?Xe(r):ct(Xe(at(r,n)))}function ut(n,o,r){if(void 0===r&&(r=C),!o)throw he(1,o);var s=function(t){for(var s=[],i=1;i<arguments.length;i++)s[i-1]=arguments[i];return n(o,r,lt.apply(void 0,__spreadArray([t],s,false)))};return s.attrs=function(e){return ut(n,o,__assign(__assign({},r),{attrs:Array.prototype.concat(r.attrs,e).filter(Boolean)}))},s.withConfig=function(e){return ut(n,o,__assign(__assign({},r),e))},s}var pt=function(e){return ut(it,e)},dt=pt;A.forEach(function(e){dt[e]=pt(e);});"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var St="__sc-".concat(f,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[St]||(window[St]=0),1===window[St]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[St]+=1);
|
|
1594
3362
|
|
|
1595
3363
|
var _templateObject$3;
|
|
1596
3364
|
var SearchIcon = function SearchIcon(_ref) {
|
|
@@ -1618,20 +3386,20 @@ var StyledSearchIcon = dt.svg(_templateObject$3 || (_templateObject$3 = _taggedT
|
|
|
1618
3386
|
var _templateObject$2;
|
|
1619
3387
|
function Results(_ref) {
|
|
1620
3388
|
var _ref$results = _ref.results,
|
|
1621
|
-
results = _ref$results ===
|
|
3389
|
+
results = _ref$results === void 0 ? [] : _ref$results,
|
|
1622
3390
|
onClick = _ref.onClick,
|
|
1623
3391
|
setSearchString = _ref.setSearchString,
|
|
1624
3392
|
showIcon = _ref.showIcon,
|
|
1625
3393
|
maxResults = _ref.maxResults,
|
|
1626
3394
|
_ref$resultStringKeyN = _ref.resultStringKeyName,
|
|
1627
|
-
resultStringKeyName = _ref$resultStringKeyN ===
|
|
3395
|
+
resultStringKeyName = _ref$resultStringKeyN === void 0 ? 'name' : _ref$resultStringKeyN,
|
|
1628
3396
|
highlightedItem = _ref.highlightedItem,
|
|
1629
3397
|
setHighlightedItem = _ref.setHighlightedItem,
|
|
1630
3398
|
formatResult = _ref.formatResult,
|
|
1631
3399
|
_ref$showNoResultsFla = _ref.showNoResultsFlag,
|
|
1632
|
-
showNoResultsFlag = _ref$showNoResultsFla ===
|
|
3400
|
+
showNoResultsFlag = _ref$showNoResultsFla === void 0 ? true : _ref$showNoResultsFla,
|
|
1633
3401
|
_ref$showNoResultsTex = _ref.showNoResultsText,
|
|
1634
|
-
showNoResultsText = _ref$showNoResultsTex ===
|
|
3402
|
+
showNoResultsText = _ref$showNoResultsTex === void 0 ? 'No results' : _ref$showNoResultsTex;
|
|
1635
3403
|
var formatResultWithKey = formatResult ? formatResult : function (item) {
|
|
1636
3404
|
return item[resultStringKeyName];
|
|
1637
3405
|
};
|
|
@@ -1656,7 +3424,7 @@ function Results(_ref) {
|
|
|
1656
3424
|
className: "ellipsis"
|
|
1657
3425
|
}, showNoResultsText)));
|
|
1658
3426
|
}
|
|
1659
|
-
if ((results === null || results ===
|
|
3427
|
+
if ((results === null || results === void 0 ? void 0 : results.length) <= 0 && !showNoResultsFlag) {
|
|
1660
3428
|
return null;
|
|
1661
3429
|
}
|
|
1662
3430
|
return /*#__PURE__*/React.createElement(ResultsWrapper, null, results.slice(0, maxResults).map(function (result, index) {
|
|
@@ -1719,7 +3487,7 @@ var ClearIcon = function ClearIcon(_ref) {
|
|
|
1719
3487
|
if (!showClear) {
|
|
1720
3488
|
return null;
|
|
1721
3489
|
}
|
|
1722
|
-
if (!searchString || (searchString === null || searchString ===
|
|
3490
|
+
if (!searchString || (searchString === null || searchString === void 0 ? void 0 : searchString.length) <= 0) {
|
|
1723
3491
|
return null;
|
|
1724
3492
|
}
|
|
1725
3493
|
return /*#__PURE__*/React.createElement(StyledClearIcon, {
|
|
@@ -1752,15 +3520,15 @@ function SearchInput(_ref) {
|
|
|
1752
3520
|
onClear = _ref.onClear,
|
|
1753
3521
|
placeholder = _ref.placeholder,
|
|
1754
3522
|
_ref$showIcon = _ref.showIcon,
|
|
1755
|
-
showIcon = _ref$showIcon ===
|
|
3523
|
+
showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
|
|
1756
3524
|
_ref$showClear = _ref.showClear,
|
|
1757
|
-
showClear = _ref$showClear ===
|
|
3525
|
+
showClear = _ref$showClear === void 0 ? true : _ref$showClear,
|
|
1758
3526
|
maxLength = _ref.maxLength;
|
|
1759
3527
|
var ref = o.useRef(null);
|
|
1760
3528
|
var manualFocus = true;
|
|
1761
3529
|
var setFocus = function setFocus() {
|
|
1762
3530
|
manualFocus = false;
|
|
1763
|
-
(ref === null || ref ===
|
|
3531
|
+
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.focus();
|
|
1764
3532
|
manualFocus = true;
|
|
1765
3533
|
};
|
|
1766
3534
|
var handleOnFocus = function handleOnFocus(event) {
|
|
@@ -1813,48 +3581,45 @@ var DEFAULT_INPUT_DEBOUNCE = 200;
|
|
|
1813
3581
|
var MAX_RESULTS = 10;
|
|
1814
3582
|
function ReactSearchAutocomplete(_ref) {
|
|
1815
3583
|
var _ref$items = _ref.items,
|
|
1816
|
-
items = _ref$items ===
|
|
3584
|
+
items = _ref$items === void 0 ? [] : _ref$items,
|
|
1817
3585
|
_ref$fuseOptions = _ref.fuseOptions,
|
|
1818
|
-
fuseOptions = _ref$fuseOptions ===
|
|
3586
|
+
fuseOptions = _ref$fuseOptions === void 0 ? defaultFuseOptions : _ref$fuseOptions,
|
|
1819
3587
|
_ref$inputDebounce = _ref.inputDebounce,
|
|
1820
|
-
inputDebounce = _ref$inputDebounce ===
|
|
3588
|
+
inputDebounce = _ref$inputDebounce === void 0 ? DEFAULT_INPUT_DEBOUNCE : _ref$inputDebounce,
|
|
1821
3589
|
_ref$onSearch = _ref.onSearch,
|
|
1822
|
-
onSearch = _ref$onSearch ===
|
|
3590
|
+
onSearch = _ref$onSearch === void 0 ? function () {} : _ref$onSearch,
|
|
1823
3591
|
_ref$onHover = _ref.onHover,
|
|
1824
|
-
onHover = _ref$onHover ===
|
|
3592
|
+
onHover = _ref$onHover === void 0 ? function () {} : _ref$onHover,
|
|
1825
3593
|
_ref$onSelect = _ref.onSelect,
|
|
1826
|
-
onSelect = _ref$onSelect ===
|
|
3594
|
+
onSelect = _ref$onSelect === void 0 ? function () {} : _ref$onSelect,
|
|
1827
3595
|
_ref$onFocus = _ref.onFocus,
|
|
1828
|
-
onFocus = _ref$onFocus ===
|
|
3596
|
+
onFocus = _ref$onFocus === void 0 ? function () {} : _ref$onFocus,
|
|
1829
3597
|
_ref$onClear = _ref.onClear,
|
|
1830
|
-
onClear = _ref$onClear ===
|
|
3598
|
+
onClear = _ref$onClear === void 0 ? function () {} : _ref$onClear,
|
|
1831
3599
|
_ref$showIcon = _ref.showIcon,
|
|
1832
|
-
showIcon = _ref$showIcon ===
|
|
3600
|
+
showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
|
|
1833
3601
|
_ref$showClear = _ref.showClear,
|
|
1834
|
-
showClear = _ref$showClear ===
|
|
3602
|
+
showClear = _ref$showClear === void 0 ? true : _ref$showClear,
|
|
1835
3603
|
_ref$maxResults = _ref.maxResults,
|
|
1836
|
-
maxResults = _ref$maxResults ===
|
|
3604
|
+
maxResults = _ref$maxResults === void 0 ? MAX_RESULTS : _ref$maxResults,
|
|
1837
3605
|
_ref$placeholder = _ref.placeholder,
|
|
1838
|
-
placeholder = _ref$placeholder ===
|
|
3606
|
+
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
1839
3607
|
_ref$autoFocus = _ref.autoFocus,
|
|
1840
|
-
autoFocus = _ref$autoFocus ===
|
|
1841
|
-
_ref$styling = _ref.styling,
|
|
1842
|
-
styling = _ref$styling === undefined ? {} : _ref$styling,
|
|
3608
|
+
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
|
|
1843
3609
|
_ref$resultStringKeyN = _ref.resultStringKeyName,
|
|
1844
|
-
resultStringKeyName = _ref$resultStringKeyN ===
|
|
3610
|
+
resultStringKeyName = _ref$resultStringKeyN === void 0 ? 'name' : _ref$resultStringKeyN,
|
|
1845
3611
|
_ref$inputSearchStrin = _ref.inputSearchString,
|
|
1846
|
-
inputSearchString = _ref$inputSearchStrin ===
|
|
3612
|
+
inputSearchString = _ref$inputSearchStrin === void 0 ? '' : _ref$inputSearchStrin,
|
|
1847
3613
|
formatResult = _ref.formatResult,
|
|
1848
3614
|
_ref$showNoResults = _ref.showNoResults,
|
|
1849
|
-
showNoResults = _ref$showNoResults ===
|
|
3615
|
+
showNoResults = _ref$showNoResults === void 0 ? true : _ref$showNoResults,
|
|
1850
3616
|
_ref$showNoResultsTex = _ref.showNoResultsText,
|
|
1851
|
-
showNoResultsText = _ref$showNoResultsTex ===
|
|
3617
|
+
showNoResultsText = _ref$showNoResultsTex === void 0 ? 'No results' : _ref$showNoResultsTex,
|
|
1852
3618
|
_ref$showItemsOnFocus = _ref.showItemsOnFocus,
|
|
1853
|
-
showItemsOnFocus = _ref$showItemsOnFocus ===
|
|
3619
|
+
showItemsOnFocus = _ref$showItemsOnFocus === void 0 ? false : _ref$showItemsOnFocus,
|
|
1854
3620
|
_ref$maxLength = _ref.maxLength,
|
|
1855
|
-
maxLength = _ref$maxLength ===
|
|
1856
|
-
|
|
1857
|
-
_objectSpread2(_objectSpread2({}, defaultTheme), styling);
|
|
3621
|
+
maxLength = _ref$maxLength === void 0 ? 0 : _ref$maxLength;
|
|
3622
|
+
// const theme = { ...defaultTheme, ...styling }
|
|
1858
3623
|
var options = _objectSpread2(_objectSpread2({}, defaultFuseOptions), fuseOptions);
|
|
1859
3624
|
var fuse = new Fuse(items, options);
|
|
1860
3625
|
fuse.setCollection(items);
|
|
@@ -1896,7 +3661,7 @@ function ReactSearchAutocomplete(_ref) {
|
|
|
1896
3661
|
};
|
|
1897
3662
|
}, [inputSearchString]);
|
|
1898
3663
|
o.useEffect(function () {
|
|
1899
|
-
(searchString === null || searchString ===
|
|
3664
|
+
(searchString === null || searchString === void 0 ? void 0 : searchString.length) > 0 && results && (results === null || results === void 0 ? void 0 : results.length) > 0 && setResults(fuseResults(searchString));
|
|
1900
3665
|
}, [items]);
|
|
1901
3666
|
o.useEffect(function () {
|
|
1902
3667
|
if (showNoResults && searchString.length > 0 && !isTyping && results.length === 0 && !isSearchComplete) {
|
|
@@ -1926,7 +3691,7 @@ function ReactSearchAutocomplete(_ref) {
|
|
|
1926
3691
|
};
|
|
1927
3692
|
var callOnSearch = function callOnSearch(keyword) {
|
|
1928
3693
|
var newResults = [];
|
|
1929
|
-
(keyword === null || keyword ===
|
|
3694
|
+
(keyword === null || keyword === void 0 ? void 0 : keyword.length) > 0 && (newResults = fuseResults(keyword));
|
|
1930
3695
|
setResults(newResults);
|
|
1931
3696
|
onSearch(keyword, newResults);
|
|
1932
3697
|
setIsTyping(false);
|
|
@@ -1969,11 +3734,11 @@ function ReactSearchAutocomplete(_ref) {
|
|
|
1969
3734
|
var itemIndex = -1;
|
|
1970
3735
|
var setValues = function setValues(index) {
|
|
1971
3736
|
setHighlightedItem(index);
|
|
1972
|
-
(results === null || results ===
|
|
3737
|
+
(results === null || results === void 0 ? void 0 : results[index]) && onHover(results[index]);
|
|
1973
3738
|
};
|
|
1974
3739
|
if (index !== undefined) {
|
|
1975
3740
|
setHighlightedItem(index);
|
|
1976
|
-
(results === null || results ===
|
|
3741
|
+
(results === null || results === void 0 ? void 0 : results[index]) && onHover(results[index]);
|
|
1977
3742
|
} else if (event) {
|
|
1978
3743
|
switch (event.key) {
|
|
1979
3744
|
case 'Enter':
|