330 lines
10 KiB
JavaScript
330 lines
10 KiB
JavaScript
// Metro module 12629 (f12630).
|
|
import * as __extends from "./_extends";
|
|
import * as _removeAccents from "./removeAccents";
|
|
let c8716_0, c8716_1, c8716_2, defaultBaseSortFn, attributes;
|
|
const getMatchRanking = function getMatchRanking(itemValue, a1, a2) {
|
|
let r58, r70, NO_MATCH;
|
|
const r21 = "" + itemValue;
|
|
const r19 = a2.keepDiacritics ? r21 : c8716_1.default(r21);
|
|
const r26 = "" + a1;
|
|
const r28 = a2.keepDiacritics ? r26 : c8716_1.default(r26);
|
|
L45: {
|
|
if (r28.length > r19.length) {
|
|
NO_MATCH = c8716_2.NO_MATCH;
|
|
} else if (r19 === r28) {
|
|
NO_MATCH = c8716_2.CASE_SENSITIVE_EQUAL;
|
|
} else {
|
|
const r34 = r19.toLowerCase();
|
|
const r36 = r28.toLowerCase();
|
|
if (r34 === r36) {
|
|
NO_MATCH = c8716_2.EQUAL;
|
|
} else if (r34.startsWith(r36)) {
|
|
NO_MATCH = c8716_2.STARTS_WITH;
|
|
} else if (r34.includes(" " + r36)) {
|
|
NO_MATCH = c8716_2.WORD_STARTS_WITH;
|
|
} else if (r34.includes(r36)) {
|
|
NO_MATCH = c8716_2.CONTAINS;
|
|
} else if (r36.length === 1) {
|
|
NO_MATCH = c8716_2.NO_MATCH;
|
|
} else {
|
|
let c19943_0 = "";
|
|
r34.split(" ").forEach(function(a0) {
|
|
a0.split("-").forEach(function(item) {
|
|
c19943_0 = c19943_0 + item.substr(0, 1);
|
|
});
|
|
});
|
|
if (c19943_0.includes(r36)) {
|
|
NO_MATCH = c8716_2.ACRONYM;
|
|
} else {
|
|
const r55 = r36[0];
|
|
const length = r34.length;
|
|
const r15 = 0 < length;
|
|
let r7 = 0;
|
|
let r11 = 0;
|
|
let r14 = -1;
|
|
if (r15) {
|
|
do {
|
|
const r57 = r34[r7];
|
|
const r9 = r7;
|
|
if (r57 === r55) {
|
|
r14 = r9 + 1;
|
|
r11 = 1;
|
|
break;
|
|
}
|
|
const r10 = r9 + 1;
|
|
r58 = r10 < length;
|
|
r7 = r10;
|
|
r11 = 0;
|
|
r14 = -1;
|
|
} while (r58);
|
|
}
|
|
if (r14 < 0) {
|
|
NO_MATCH = c8716_2.NO_MATCH;
|
|
} else {
|
|
const length2 = r36.length;
|
|
const r60 = 1 < length2;
|
|
let r61 = r11;
|
|
let r62 = 1;
|
|
let r63 = r14;
|
|
let r64 = r61;
|
|
let r65 = r63;
|
|
if (r60) {
|
|
do {
|
|
const r66 = r36[r62];
|
|
const length3 = r34.length;
|
|
const r68 = r63 < length3;
|
|
const r6 = r61;
|
|
const r13 = r62;
|
|
let r0 = r63;
|
|
let r3 = r6;
|
|
let r4 = -1;
|
|
if (r68) {
|
|
do {
|
|
const r69 = r34[r0];
|
|
const r2 = r0;
|
|
if (r69 === r66) {
|
|
r3 = r6 + 1;
|
|
r4 = r2 + 1;
|
|
break;
|
|
}
|
|
const r1 = r2 + 1;
|
|
r70 = r1 < length3;
|
|
r0 = r1;
|
|
r3 = r6;
|
|
r4 = -1;
|
|
} while (r70);
|
|
}
|
|
if (!(-1 < r4)) {
|
|
NO_MATCH = c8716_2.NO_MATCH;
|
|
break L45;
|
|
}
|
|
r62 = r13 + 1;
|
|
r61 = r3;
|
|
r63 = r4;
|
|
r64 = r61;
|
|
r65 = r63;
|
|
} while (r62 < length2);
|
|
}
|
|
NO_MATCH = c8716_2.MATCHES + r64 / r36.length * (1 / (r65 - r14));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return NO_MATCH;
|
|
};
|
|
c8716_0 = __extends && typeof __extends === "object" ? "default" in __extends ? __extends : {
|
|
default: __extends
|
|
} : {
|
|
default: __extends
|
|
};
|
|
const r22 = _removeAccents && typeof _removeAccents === "object" ? "default" in _removeAccents ? _removeAccents : {
|
|
default: _removeAccents
|
|
} : {
|
|
default: _removeAccents
|
|
};
|
|
export function matchSorter(a0, c19942_0, a2) {
|
|
let r6 = a2;
|
|
let c19942_1 = a2;
|
|
if (a2 === void 0) {
|
|
const r3 = {};
|
|
c19942_1 = r3;
|
|
r6 = r3;
|
|
}
|
|
const { keys, threshold = c8716_2.MATCHES } = r6;
|
|
const MATCHES = threshold;
|
|
let baseSort = r6.baseSort;
|
|
if (baseSort === void 0) {
|
|
baseSort = defaultBaseSortFn;
|
|
}
|
|
const defaultBaseSortFn2 = baseSort;
|
|
let sorter = r6.sorter;
|
|
if (sorter === void 0) {
|
|
sorter = function(a0) {
|
|
return a0.sort(function(a, b) {
|
|
const { rank, keyIndex: keyIndex2 } = a;
|
|
const { rank: rank2, keyIndex } = b;
|
|
return rank === rank2 ? keyIndex2 === keyIndex ? defaultBaseSortFn2(a, b) : keyIndex2 < keyIndex ? -1 : 1 : rank > rank2 ? -1 : 1;
|
|
});
|
|
};
|
|
}
|
|
return sorter(a0.reduce(function reduceItemsToRanked(acc, a1, a2) {
|
|
let r17, r48, r71;
|
|
let c27347_0 = c19942_0;
|
|
let c27347_1 = c19942_1;
|
|
if (keys) {
|
|
const r16 = [];
|
|
const length = keys.length;
|
|
const r8 = 0 < length;
|
|
let r44 = 0;
|
|
if (r8) {
|
|
do {
|
|
const r24 = keys[r44];
|
|
const r7 = r44;
|
|
const attributes2 = typeof r24 === "string" ? attributes : c8716_0.default({}, attributes, r24);
|
|
let r46 = r24;
|
|
if (typeof r46 === "object") {
|
|
r46 = r24.key;
|
|
}
|
|
L39: {
|
|
if (typeof r46 === "function") {
|
|
r48 = r46(a1);
|
|
} else {
|
|
const r47 = a1 == null;
|
|
r48 = null;
|
|
if (!r47) {
|
|
if (Object.hasOwnProperty.call(a1, r46)) {
|
|
r48 = a1[r46];
|
|
} else {
|
|
const r54 = r46.includes(".");
|
|
r48 = null;
|
|
if (r54) {
|
|
const r28 = r46.split(".");
|
|
const r29 = [a1];
|
|
const length3 = r28.length;
|
|
const r57 = 0 < length3;
|
|
let r2 = 0;
|
|
let r58 = r29;
|
|
let r30 = r58;
|
|
if (r57) {
|
|
do {
|
|
const r34 = r28[r2];
|
|
let r31 = [];
|
|
const length2 = r58.length;
|
|
const r59 = 0 < length2;
|
|
const r5 = r2;
|
|
const r32 = r58;
|
|
let r0 = 0;
|
|
let r60 = r31;
|
|
if (r59) {
|
|
do {
|
|
const r37 = r32[r0];
|
|
const r1 = r0;
|
|
const r36 = r31;
|
|
let r35 = r36;
|
|
if (r37 != null) {
|
|
if (Object.hasOwnProperty.call(r37, r34)) {
|
|
const r64 = r37[r34];
|
|
r35 = r36;
|
|
if (r64 != null) {
|
|
r36.push(r64);
|
|
r35 = r36;
|
|
}
|
|
} else {
|
|
r35 = r34 === "*" ? r36.concat(r37) : r36;
|
|
}
|
|
}
|
|
r0 = r1 + 1;
|
|
r31 = r35;
|
|
r60 = r31;
|
|
} while (r0 < length2);
|
|
}
|
|
r2 = r5 + 1;
|
|
r58 = r60;
|
|
r30 = r58;
|
|
} while (r2 < length3);
|
|
}
|
|
const isArray = Array.isArray(r30[0]);
|
|
r71 = r30;
|
|
if (!isArray) {
|
|
break L39;
|
|
}
|
|
const r72 = [];
|
|
r71 = r72.concat.apply(r72, r30);
|
|
break L39;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
r71 = r48 == null ? [] : Array.isArray(r48) ? r48 : [String(r48)];
|
|
}
|
|
const length4 = r71.length;
|
|
const r83 = 0 < length4;
|
|
let r84 = 0;
|
|
if (r83) {
|
|
do {
|
|
r16.push({
|
|
itemValue: r71[r84],
|
|
attributes: attributes2
|
|
});
|
|
r84 = r84 + 1;
|
|
} while (r84 < length4);
|
|
}
|
|
r44 = r7 + 1;
|
|
} while (r44 < length);
|
|
}
|
|
r17 = r16.reduce(function(acc, item, index) {
|
|
let rank = acc.rank;
|
|
let rankedValue = acc.rankedValue;
|
|
let keyIndex = acc.keyIndex;
|
|
let keyThreshold = acc.keyThreshold;
|
|
const { itemValue, attributes: attributes2 } = item;
|
|
const matchRanking = getMatchRanking(itemValue, c27347_0, c27347_1);
|
|
let minRanking = attributes2.minRanking;
|
|
const { maxRanking, threshold } = attributes2;
|
|
if (!(matchRanking < minRanking && matchRanking >= c8716_2.MATCHES)) {
|
|
minRanking = matchRanking;
|
|
if (minRanking > maxRanking) {
|
|
minRanking = maxRanking;
|
|
}
|
|
}
|
|
if (minRanking > rank) {
|
|
keyIndex = index;
|
|
rankedValue = itemValue;
|
|
keyThreshold = threshold;
|
|
rank = minRanking;
|
|
}
|
|
return {
|
|
rankedValue,
|
|
rank,
|
|
keyIndex,
|
|
keyThreshold
|
|
};
|
|
}, {
|
|
rankedValue: a1,
|
|
rank: c8716_2.NO_MATCH,
|
|
keyIndex: -1,
|
|
keyThreshold: c19942_1.threshold
|
|
});
|
|
} else {
|
|
r17 = {
|
|
rankedValue: a1,
|
|
rank: getMatchRanking(a1, c19942_0, c19942_1),
|
|
keyIndex: -1,
|
|
keyThreshold: c19942_1.threshold
|
|
};
|
|
}
|
|
const { rank, keyThreshold = MATCHES } = r17;
|
|
if (rank >= keyThreshold) {
|
|
acc.push(c8716_0.default({}, r17, {
|
|
item: a1,
|
|
index: a2
|
|
}));
|
|
}
|
|
return acc;
|
|
}, [])).map(function(item) {
|
|
return item.item;
|
|
});
|
|
}
|
|
c8716_1 = r22;
|
|
c8716_2 = {
|
|
CASE_SENSITIVE_EQUAL: 7,
|
|
EQUAL: 6,
|
|
STARTS_WITH: 5,
|
|
WORD_STARTS_WITH: 4,
|
|
CONTAINS: 3,
|
|
ACRONYM: 2,
|
|
MATCHES: 1,
|
|
NO_MATCH: 0
|
|
};
|
|
matchSorter.rankings = c8716_2;
|
|
defaultBaseSortFn = function defaultBaseSortFn(a0, a1) {
|
|
return String(a0.rankedValue).localeCompare(String(a1.rankedValue));
|
|
};
|
|
attributes = {
|
|
maxRanking: Infinity,
|
|
minRanking: -Infinity
|
|
};
|
|
export { defaultBaseSortFn };
|
|
export { c8716_2 as rankings };
|