@unifold/ui-web 0.1.58 → 0.1.59
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/index.js +2046 -24
- package/dist/index.mjs +2046 -24
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -3242,11 +3242,11 @@ var require_react_dom_client_production = __commonJS({
|
|
|
3242
3242
|
valueField
|
|
3243
3243
|
);
|
|
3244
3244
|
if (!node.hasOwnProperty(valueField) && "undefined" !== typeof descriptor && "function" === typeof descriptor.get && "function" === typeof descriptor.set) {
|
|
3245
|
-
var
|
|
3245
|
+
var get2 = descriptor.get, set = descriptor.set;
|
|
3246
3246
|
Object.defineProperty(node, valueField, {
|
|
3247
3247
|
configurable: true,
|
|
3248
3248
|
get: function() {
|
|
3249
|
-
return
|
|
3249
|
+
return get2.call(this);
|
|
3250
3250
|
},
|
|
3251
3251
|
set: function(value) {
|
|
3252
3252
|
currentValue = "" + value;
|
|
@@ -15396,11 +15396,11 @@ var require_react_dom_client_development = __commonJS({
|
|
|
15396
15396
|
valueField
|
|
15397
15397
|
);
|
|
15398
15398
|
if (!node.hasOwnProperty(valueField) && "undefined" !== typeof descriptor && "function" === typeof descriptor.get && "function" === typeof descriptor.set) {
|
|
15399
|
-
var
|
|
15399
|
+
var get2 = descriptor.get, set = descriptor.set;
|
|
15400
15400
|
Object.defineProperty(node, valueField, {
|
|
15401
15401
|
configurable: true,
|
|
15402
15402
|
get: function() {
|
|
15403
|
-
return
|
|
15403
|
+
return get2.call(this);
|
|
15404
15404
|
},
|
|
15405
15405
|
set: function(value) {
|
|
15406
15406
|
checkFormFieldValueStringCoercion(value);
|
|
@@ -43232,12 +43232,12 @@ var ExecutionStatus = /* @__PURE__ */ ((ExecutionStatus2) => {
|
|
|
43232
43232
|
ExecutionStatus2["WAITING"] = "waiting";
|
|
43233
43233
|
return ExecutionStatus2;
|
|
43234
43234
|
})(ExecutionStatus || {});
|
|
43235
|
-
async function queryExecutions(externalUserId, publishableKey, actionType) {
|
|
43235
|
+
async function queryExecutions(externalUserId, publishableKey, actionType = "deposit") {
|
|
43236
43236
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
43237
43237
|
validatePublishableKey(pk);
|
|
43238
43238
|
const body = {
|
|
43239
43239
|
external_user_id: externalUserId,
|
|
43240
|
-
|
|
43240
|
+
action_type: actionType
|
|
43241
43241
|
};
|
|
43242
43242
|
const response = await fetch(
|
|
43243
43243
|
`${API_BASE_URL}/v1/public/direct_executions/query`,
|
|
@@ -44146,6 +44146,2002 @@ var cva = (base, config) => (props) => {
|
|
|
44146
44146
|
}, []);
|
|
44147
44147
|
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
44148
44148
|
};
|
|
44149
|
+
function isArray(value) {
|
|
44150
|
+
return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
|
|
44151
|
+
}
|
|
44152
|
+
function baseToString(value) {
|
|
44153
|
+
if (typeof value == "string") {
|
|
44154
|
+
return value;
|
|
44155
|
+
}
|
|
44156
|
+
if (typeof value === "bigint") {
|
|
44157
|
+
return value.toString();
|
|
44158
|
+
}
|
|
44159
|
+
const result = value + "";
|
|
44160
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
44161
|
+
}
|
|
44162
|
+
function toString(value) {
|
|
44163
|
+
return value == null ? "" : baseToString(value);
|
|
44164
|
+
}
|
|
44165
|
+
function isString(value) {
|
|
44166
|
+
return typeof value === "string";
|
|
44167
|
+
}
|
|
44168
|
+
function isNumber2(value) {
|
|
44169
|
+
return typeof value === "number";
|
|
44170
|
+
}
|
|
44171
|
+
function isBoolean(value) {
|
|
44172
|
+
return value === true || value === false || isObjectLike(value) && getTag(value) == "[object Boolean]";
|
|
44173
|
+
}
|
|
44174
|
+
function isObject(value) {
|
|
44175
|
+
return typeof value === "object";
|
|
44176
|
+
}
|
|
44177
|
+
function isObjectLike(value) {
|
|
44178
|
+
return isObject(value) && value !== null;
|
|
44179
|
+
}
|
|
44180
|
+
function isDefined(value) {
|
|
44181
|
+
return value !== void 0 && value !== null;
|
|
44182
|
+
}
|
|
44183
|
+
function isBlank(value) {
|
|
44184
|
+
return !value.trim().length;
|
|
44185
|
+
}
|
|
44186
|
+
function getTag(value) {
|
|
44187
|
+
return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
|
|
44188
|
+
}
|
|
44189
|
+
var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
|
|
44190
|
+
var INVALID_DOC_INDEX = "Invalid doc index: must be a non-negative integer within the bounds of the docs array";
|
|
44191
|
+
var LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`;
|
|
44192
|
+
var PATTERN_LENGTH_TOO_LARGE = (max2) => `Pattern length exceeds max of ${max2}.`;
|
|
44193
|
+
var MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
|
|
44194
|
+
var INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`;
|
|
44195
|
+
var FUSE_MATCH_TOKEN_SEARCH_UNSUPPORTED = `Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.`;
|
|
44196
|
+
var hasOwn2 = Object.prototype.hasOwnProperty;
|
|
44197
|
+
var KeyStore = class {
|
|
44198
|
+
constructor(keys) {
|
|
44199
|
+
this._keys = [];
|
|
44200
|
+
this._keyMap = {};
|
|
44201
|
+
let totalWeight = 0;
|
|
44202
|
+
keys.forEach((key) => {
|
|
44203
|
+
const obj = createKey(key);
|
|
44204
|
+
this._keys.push(obj);
|
|
44205
|
+
this._keyMap[obj.id] = obj;
|
|
44206
|
+
totalWeight += obj.weight;
|
|
44207
|
+
});
|
|
44208
|
+
this._keys.forEach((key) => {
|
|
44209
|
+
key.weight /= totalWeight;
|
|
44210
|
+
});
|
|
44211
|
+
}
|
|
44212
|
+
get(keyId) {
|
|
44213
|
+
return this._keyMap[keyId];
|
|
44214
|
+
}
|
|
44215
|
+
keys() {
|
|
44216
|
+
return this._keys;
|
|
44217
|
+
}
|
|
44218
|
+
toJSON() {
|
|
44219
|
+
return JSON.stringify(this._keys);
|
|
44220
|
+
}
|
|
44221
|
+
};
|
|
44222
|
+
function createKey(key) {
|
|
44223
|
+
let path = null;
|
|
44224
|
+
let id = null;
|
|
44225
|
+
let src = null;
|
|
44226
|
+
let weight = 1;
|
|
44227
|
+
let getFn = null;
|
|
44228
|
+
if (isString(key) || isArray(key)) {
|
|
44229
|
+
src = key;
|
|
44230
|
+
path = createKeyPath(key);
|
|
44231
|
+
id = createKeyId(key);
|
|
44232
|
+
} else {
|
|
44233
|
+
if (!hasOwn2.call(key, "name")) {
|
|
44234
|
+
throw new Error(MISSING_KEY_PROPERTY("name"));
|
|
44235
|
+
}
|
|
44236
|
+
const name = key.name;
|
|
44237
|
+
src = name;
|
|
44238
|
+
if (hasOwn2.call(key, "weight") && key.weight !== void 0) {
|
|
44239
|
+
weight = key.weight;
|
|
44240
|
+
if (weight <= 0) {
|
|
44241
|
+
throw new Error(INVALID_KEY_WEIGHT_VALUE(createKeyId(name)));
|
|
44242
|
+
}
|
|
44243
|
+
}
|
|
44244
|
+
path = createKeyPath(name);
|
|
44245
|
+
id = createKeyId(name);
|
|
44246
|
+
getFn = key.getFn ?? null;
|
|
44247
|
+
}
|
|
44248
|
+
return {
|
|
44249
|
+
path,
|
|
44250
|
+
id,
|
|
44251
|
+
weight,
|
|
44252
|
+
src,
|
|
44253
|
+
getFn
|
|
44254
|
+
};
|
|
44255
|
+
}
|
|
44256
|
+
function createKeyPath(key) {
|
|
44257
|
+
return isArray(key) ? key : key.split(".");
|
|
44258
|
+
}
|
|
44259
|
+
function createKeyId(key) {
|
|
44260
|
+
return isArray(key) ? key.join(".") : key;
|
|
44261
|
+
}
|
|
44262
|
+
function get(obj, path) {
|
|
44263
|
+
const list = [];
|
|
44264
|
+
let arr = false;
|
|
44265
|
+
const deepGet = (obj2, path2, index2, arrayIndex) => {
|
|
44266
|
+
if (!isDefined(obj2)) {
|
|
44267
|
+
return;
|
|
44268
|
+
}
|
|
44269
|
+
if (!path2[index2]) {
|
|
44270
|
+
list.push(arrayIndex !== void 0 ? {
|
|
44271
|
+
v: obj2,
|
|
44272
|
+
i: arrayIndex
|
|
44273
|
+
} : obj2);
|
|
44274
|
+
} else {
|
|
44275
|
+
const key = path2[index2];
|
|
44276
|
+
const value = obj2[key];
|
|
44277
|
+
if (!isDefined(value)) {
|
|
44278
|
+
return;
|
|
44279
|
+
}
|
|
44280
|
+
if (index2 === path2.length - 1 && (isString(value) || isNumber2(value) || isBoolean(value) || typeof value === "bigint")) {
|
|
44281
|
+
list.push(arrayIndex !== void 0 ? {
|
|
44282
|
+
v: toString(value),
|
|
44283
|
+
i: arrayIndex
|
|
44284
|
+
} : toString(value));
|
|
44285
|
+
} else if (isArray(value)) {
|
|
44286
|
+
arr = true;
|
|
44287
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
44288
|
+
deepGet(value[i], path2, index2 + 1, i);
|
|
44289
|
+
}
|
|
44290
|
+
} else if (path2.length) {
|
|
44291
|
+
deepGet(value, path2, index2 + 1, arrayIndex);
|
|
44292
|
+
}
|
|
44293
|
+
}
|
|
44294
|
+
};
|
|
44295
|
+
deepGet(obj, isString(path) ? path.split(".") : path, 0);
|
|
44296
|
+
return arr ? list : list[0];
|
|
44297
|
+
}
|
|
44298
|
+
var MatchOptions = {
|
|
44299
|
+
includeMatches: false,
|
|
44300
|
+
findAllMatches: false,
|
|
44301
|
+
minMatchCharLength: 1
|
|
44302
|
+
};
|
|
44303
|
+
var BasicOptions = {
|
|
44304
|
+
isCaseSensitive: false,
|
|
44305
|
+
ignoreDiacritics: false,
|
|
44306
|
+
includeScore: false,
|
|
44307
|
+
keys: [],
|
|
44308
|
+
shouldSort: true,
|
|
44309
|
+
sortFn: (a, b) => a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1
|
|
44310
|
+
};
|
|
44311
|
+
var FuzzyOptions = {
|
|
44312
|
+
location: 0,
|
|
44313
|
+
threshold: 0.6,
|
|
44314
|
+
distance: 100
|
|
44315
|
+
};
|
|
44316
|
+
var AdvancedOptions = {
|
|
44317
|
+
useExtendedSearch: false,
|
|
44318
|
+
useTokenSearch: false,
|
|
44319
|
+
tokenize: void 0,
|
|
44320
|
+
tokenMatch: "any",
|
|
44321
|
+
getFn: get,
|
|
44322
|
+
ignoreLocation: false,
|
|
44323
|
+
ignoreFieldNorm: false,
|
|
44324
|
+
fieldNormWeight: 1
|
|
44325
|
+
};
|
|
44326
|
+
var Config = Object.freeze({
|
|
44327
|
+
...BasicOptions,
|
|
44328
|
+
...MatchOptions,
|
|
44329
|
+
...FuzzyOptions,
|
|
44330
|
+
...AdvancedOptions
|
|
44331
|
+
});
|
|
44332
|
+
function norm(weight = 1, mantissa = 3) {
|
|
44333
|
+
const cache = /* @__PURE__ */ new Map();
|
|
44334
|
+
const m = Math.pow(10, mantissa);
|
|
44335
|
+
return {
|
|
44336
|
+
get(value) {
|
|
44337
|
+
let numTokens = 1;
|
|
44338
|
+
let inSpace = false;
|
|
44339
|
+
for (let i = 0; i < value.length; i++) {
|
|
44340
|
+
if (value.charCodeAt(i) === 32) {
|
|
44341
|
+
if (!inSpace) {
|
|
44342
|
+
numTokens++;
|
|
44343
|
+
inSpace = true;
|
|
44344
|
+
}
|
|
44345
|
+
} else {
|
|
44346
|
+
inSpace = false;
|
|
44347
|
+
}
|
|
44348
|
+
}
|
|
44349
|
+
if (cache.has(numTokens)) {
|
|
44350
|
+
return cache.get(numTokens);
|
|
44351
|
+
}
|
|
44352
|
+
const n = Math.round(m / Math.pow(numTokens, 0.5 * weight)) / m;
|
|
44353
|
+
cache.set(numTokens, n);
|
|
44354
|
+
return n;
|
|
44355
|
+
},
|
|
44356
|
+
clear() {
|
|
44357
|
+
cache.clear();
|
|
44358
|
+
}
|
|
44359
|
+
};
|
|
44360
|
+
}
|
|
44361
|
+
var FuseIndex = class {
|
|
44362
|
+
constructor({
|
|
44363
|
+
getFn = Config.getFn,
|
|
44364
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
44365
|
+
} = {}) {
|
|
44366
|
+
this.norm = norm(fieldNormWeight, 3);
|
|
44367
|
+
this.getFn = getFn;
|
|
44368
|
+
this.isCreated = false;
|
|
44369
|
+
this.docs = [];
|
|
44370
|
+
this.keys = [];
|
|
44371
|
+
this._keysMap = {};
|
|
44372
|
+
this.setIndexRecords();
|
|
44373
|
+
}
|
|
44374
|
+
setSources(docs = []) {
|
|
44375
|
+
this.docs = docs;
|
|
44376
|
+
}
|
|
44377
|
+
setIndexRecords(records = []) {
|
|
44378
|
+
this.records = records;
|
|
44379
|
+
}
|
|
44380
|
+
setKeys(keys = []) {
|
|
44381
|
+
this.keys = keys;
|
|
44382
|
+
this._keysMap = {};
|
|
44383
|
+
keys.forEach((key, idx) => {
|
|
44384
|
+
this._keysMap[key.id] = idx;
|
|
44385
|
+
});
|
|
44386
|
+
}
|
|
44387
|
+
create() {
|
|
44388
|
+
if (this.isCreated || !this.docs.length) {
|
|
44389
|
+
return;
|
|
44390
|
+
}
|
|
44391
|
+
this.isCreated = true;
|
|
44392
|
+
const len = this.docs.length;
|
|
44393
|
+
this.records = new Array(len);
|
|
44394
|
+
let recordCount = 0;
|
|
44395
|
+
if (isString(this.docs[0])) {
|
|
44396
|
+
for (let i = 0; i < len; i++) {
|
|
44397
|
+
const record = this._createStringRecord(this.docs[i], i);
|
|
44398
|
+
if (record) {
|
|
44399
|
+
this.records[recordCount++] = record;
|
|
44400
|
+
}
|
|
44401
|
+
}
|
|
44402
|
+
} else {
|
|
44403
|
+
for (let i = 0; i < len; i++) {
|
|
44404
|
+
this.records[recordCount++] = this._createObjectRecord(this.docs[i], i);
|
|
44405
|
+
}
|
|
44406
|
+
}
|
|
44407
|
+
this.records.length = recordCount;
|
|
44408
|
+
this.norm.clear();
|
|
44409
|
+
}
|
|
44410
|
+
// Appends a record for `doc` at `docIndex` (the doc's position in the source
|
|
44411
|
+
// array). Returns the appended record, or null when `doc` is a blank string
|
|
44412
|
+
// (those are skipped at record creation; see `_createStringRecord`). Callers
|
|
44413
|
+
// use the return value to gate downstream bookkeeping like the inverted
|
|
44414
|
+
// index, which must not be touched when no record was produced.
|
|
44415
|
+
add(doc, docIndex) {
|
|
44416
|
+
if (!Number.isInteger(docIndex) || docIndex < 0) {
|
|
44417
|
+
throw new Error(INVALID_DOC_INDEX);
|
|
44418
|
+
}
|
|
44419
|
+
if (isString(doc)) {
|
|
44420
|
+
const record2 = this._createStringRecord(doc, docIndex);
|
|
44421
|
+
if (record2) {
|
|
44422
|
+
this.records.push(record2);
|
|
44423
|
+
}
|
|
44424
|
+
return record2;
|
|
44425
|
+
}
|
|
44426
|
+
const record = this._createObjectRecord(doc, docIndex);
|
|
44427
|
+
this.records.push(record);
|
|
44428
|
+
return record;
|
|
44429
|
+
}
|
|
44430
|
+
// Removes the record for the doc at the specified source-array (docs) index.
|
|
44431
|
+
// Blank string docs have no record; callers may pass such an index and the
|
|
44432
|
+
// splice is a no-op, but subsequent records still need their .i decremented
|
|
44433
|
+
// to track the docs array that the caller is splicing in parallel.
|
|
44434
|
+
removeAt(idx) {
|
|
44435
|
+
if (!Number.isInteger(idx) || idx < 0) {
|
|
44436
|
+
throw new Error(INVALID_DOC_INDEX);
|
|
44437
|
+
}
|
|
44438
|
+
for (let i = 0, len = this.records.length; i < len; i += 1) {
|
|
44439
|
+
if (this.records[i].i === idx) {
|
|
44440
|
+
this.records.splice(i, 1);
|
|
44441
|
+
break;
|
|
44442
|
+
}
|
|
44443
|
+
}
|
|
44444
|
+
for (let i = 0, len = this.records.length; i < len; i += 1) {
|
|
44445
|
+
if (this.records[i].i > idx) {
|
|
44446
|
+
this.records[i].i -= 1;
|
|
44447
|
+
}
|
|
44448
|
+
}
|
|
44449
|
+
}
|
|
44450
|
+
// Removes records for the docs at the specified source-array indices, then
|
|
44451
|
+
// shifts every surviving record's .i down by the count of removed indices
|
|
44452
|
+
// strictly less than it (mirrors removeAndShiftInvertedIndex's shift math).
|
|
44453
|
+
// Invalid entries (non-integer, negative) in `indices` are dropped silently
|
|
44454
|
+
// — removeAll's natural use case is "caller passed a list of matched doc
|
|
44455
|
+
// indices"; asymmetric throw-vs-no-op would be more surprising than a clean
|
|
44456
|
+
// filter.
|
|
44457
|
+
removeAll(indices) {
|
|
44458
|
+
const toRemove = /* @__PURE__ */ new Set();
|
|
44459
|
+
for (const v of indices) {
|
|
44460
|
+
if (Number.isInteger(v) && v >= 0) {
|
|
44461
|
+
toRemove.add(v);
|
|
44462
|
+
}
|
|
44463
|
+
}
|
|
44464
|
+
if (toRemove.size === 0) {
|
|
44465
|
+
return;
|
|
44466
|
+
}
|
|
44467
|
+
this.records = this.records.filter((r2) => !toRemove.has(r2.i));
|
|
44468
|
+
const sorted = Array.from(toRemove).sort((a, b) => a - b);
|
|
44469
|
+
for (const record of this.records) {
|
|
44470
|
+
let lo = 0;
|
|
44471
|
+
let hi = sorted.length;
|
|
44472
|
+
while (lo < hi) {
|
|
44473
|
+
const mid = lo + hi >>> 1;
|
|
44474
|
+
if (sorted[mid] < record.i) lo = mid + 1;
|
|
44475
|
+
else hi = mid;
|
|
44476
|
+
}
|
|
44477
|
+
record.i -= lo;
|
|
44478
|
+
}
|
|
44479
|
+
}
|
|
44480
|
+
getValueForItemAtKeyId(item, keyId) {
|
|
44481
|
+
return item[this._keysMap[keyId]];
|
|
44482
|
+
}
|
|
44483
|
+
size() {
|
|
44484
|
+
return this.records.length;
|
|
44485
|
+
}
|
|
44486
|
+
_createStringRecord(doc, docIndex) {
|
|
44487
|
+
if (!isDefined(doc) || isBlank(doc)) {
|
|
44488
|
+
return null;
|
|
44489
|
+
}
|
|
44490
|
+
return {
|
|
44491
|
+
v: doc,
|
|
44492
|
+
i: docIndex,
|
|
44493
|
+
n: this.norm.get(doc)
|
|
44494
|
+
};
|
|
44495
|
+
}
|
|
44496
|
+
_createObjectRecord(doc, docIndex) {
|
|
44497
|
+
const record = {
|
|
44498
|
+
i: docIndex,
|
|
44499
|
+
$: {}
|
|
44500
|
+
};
|
|
44501
|
+
for (let keyIndex = 0, keyLen = this.keys.length; keyIndex < keyLen; keyIndex++) {
|
|
44502
|
+
const key = this.keys[keyIndex];
|
|
44503
|
+
const value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
|
|
44504
|
+
if (!isDefined(value)) {
|
|
44505
|
+
continue;
|
|
44506
|
+
}
|
|
44507
|
+
if (isArray(value)) {
|
|
44508
|
+
const subRecords = [];
|
|
44509
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
44510
|
+
const item = value[i];
|
|
44511
|
+
if (!isDefined(item)) {
|
|
44512
|
+
continue;
|
|
44513
|
+
}
|
|
44514
|
+
if (isString(item)) {
|
|
44515
|
+
if (!isBlank(item)) {
|
|
44516
|
+
const subRecord = {
|
|
44517
|
+
v: item,
|
|
44518
|
+
i,
|
|
44519
|
+
n: this.norm.get(item)
|
|
44520
|
+
};
|
|
44521
|
+
subRecords.push(subRecord);
|
|
44522
|
+
}
|
|
44523
|
+
} else if (isDefined(item.v)) {
|
|
44524
|
+
const text = isString(item.v) ? item.v : toString(item.v);
|
|
44525
|
+
if (!isBlank(text)) {
|
|
44526
|
+
const subRecord = {
|
|
44527
|
+
v: text,
|
|
44528
|
+
i: item.i,
|
|
44529
|
+
n: this.norm.get(text)
|
|
44530
|
+
};
|
|
44531
|
+
subRecords.push(subRecord);
|
|
44532
|
+
}
|
|
44533
|
+
}
|
|
44534
|
+
}
|
|
44535
|
+
record.$[keyIndex] = subRecords;
|
|
44536
|
+
} else if (isString(value) && !isBlank(value)) {
|
|
44537
|
+
const subRecord = {
|
|
44538
|
+
v: value,
|
|
44539
|
+
n: this.norm.get(value)
|
|
44540
|
+
};
|
|
44541
|
+
record.$[keyIndex] = subRecord;
|
|
44542
|
+
}
|
|
44543
|
+
}
|
|
44544
|
+
return record;
|
|
44545
|
+
}
|
|
44546
|
+
toJSON() {
|
|
44547
|
+
return {
|
|
44548
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44549
|
+
keys: this.keys.map(({
|
|
44550
|
+
getFn,
|
|
44551
|
+
...key
|
|
44552
|
+
}) => key),
|
|
44553
|
+
records: this.records
|
|
44554
|
+
};
|
|
44555
|
+
}
|
|
44556
|
+
};
|
|
44557
|
+
function createIndex(keys, docs, {
|
|
44558
|
+
getFn = Config.getFn,
|
|
44559
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
44560
|
+
} = {}) {
|
|
44561
|
+
const myIndex = new FuseIndex({
|
|
44562
|
+
getFn,
|
|
44563
|
+
fieldNormWeight
|
|
44564
|
+
});
|
|
44565
|
+
myIndex.setKeys(keys.map(createKey));
|
|
44566
|
+
myIndex.setSources(docs);
|
|
44567
|
+
myIndex.create();
|
|
44568
|
+
return myIndex;
|
|
44569
|
+
}
|
|
44570
|
+
function parseIndex(data, {
|
|
44571
|
+
getFn = Config.getFn,
|
|
44572
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
44573
|
+
} = {}) {
|
|
44574
|
+
const {
|
|
44575
|
+
keys,
|
|
44576
|
+
records
|
|
44577
|
+
} = data;
|
|
44578
|
+
const myIndex = new FuseIndex({
|
|
44579
|
+
getFn,
|
|
44580
|
+
fieldNormWeight
|
|
44581
|
+
});
|
|
44582
|
+
myIndex.setKeys(keys);
|
|
44583
|
+
myIndex.setIndexRecords(records);
|
|
44584
|
+
return myIndex;
|
|
44585
|
+
}
|
|
44586
|
+
function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) {
|
|
44587
|
+
const indices = [];
|
|
44588
|
+
let start = -1;
|
|
44589
|
+
let end = -1;
|
|
44590
|
+
let i = 0;
|
|
44591
|
+
for (let len = matchmask.length; i < len; i += 1) {
|
|
44592
|
+
const match = matchmask[i];
|
|
44593
|
+
if (match && start === -1) {
|
|
44594
|
+
start = i;
|
|
44595
|
+
} else if (!match && start !== -1) {
|
|
44596
|
+
end = i - 1;
|
|
44597
|
+
if (end - start + 1 >= minMatchCharLength) {
|
|
44598
|
+
indices.push([start, end]);
|
|
44599
|
+
}
|
|
44600
|
+
start = -1;
|
|
44601
|
+
}
|
|
44602
|
+
}
|
|
44603
|
+
if (matchmask[i - 1] && i - start >= minMatchCharLength) {
|
|
44604
|
+
indices.push([start, i - 1]);
|
|
44605
|
+
}
|
|
44606
|
+
return indices;
|
|
44607
|
+
}
|
|
44608
|
+
var MAX_BITS = 32;
|
|
44609
|
+
function search(text, pattern, patternAlphabet, {
|
|
44610
|
+
location = Config.location,
|
|
44611
|
+
distance = Config.distance,
|
|
44612
|
+
threshold = Config.threshold,
|
|
44613
|
+
findAllMatches = Config.findAllMatches,
|
|
44614
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
44615
|
+
includeMatches = Config.includeMatches,
|
|
44616
|
+
ignoreLocation = Config.ignoreLocation
|
|
44617
|
+
} = {}) {
|
|
44618
|
+
if (pattern.length > MAX_BITS) {
|
|
44619
|
+
throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
|
|
44620
|
+
}
|
|
44621
|
+
const patternLen = pattern.length;
|
|
44622
|
+
const textLen = text.length;
|
|
44623
|
+
const expectedLocation = Math.max(0, Math.min(location, textLen));
|
|
44624
|
+
let currentThreshold = threshold;
|
|
44625
|
+
let bestLocation = expectedLocation;
|
|
44626
|
+
const calcScore = (errors, currentLocation) => {
|
|
44627
|
+
const accuracy = errors / patternLen;
|
|
44628
|
+
if (ignoreLocation) return accuracy;
|
|
44629
|
+
const proximity = Math.abs(expectedLocation - currentLocation);
|
|
44630
|
+
if (!distance) return proximity ? 1 : accuracy;
|
|
44631
|
+
return accuracy + proximity / distance;
|
|
44632
|
+
};
|
|
44633
|
+
const computeMatches = minMatchCharLength > 1 || includeMatches;
|
|
44634
|
+
const matchMask = computeMatches ? Array(textLen) : [];
|
|
44635
|
+
let index2;
|
|
44636
|
+
while ((index2 = text.indexOf(pattern, bestLocation)) > -1) {
|
|
44637
|
+
const score = calcScore(0, index2);
|
|
44638
|
+
currentThreshold = Math.min(score, currentThreshold);
|
|
44639
|
+
bestLocation = index2 + patternLen;
|
|
44640
|
+
if (computeMatches) {
|
|
44641
|
+
let i = 0;
|
|
44642
|
+
while (i < patternLen) {
|
|
44643
|
+
matchMask[index2 + i] = 1;
|
|
44644
|
+
i += 1;
|
|
44645
|
+
}
|
|
44646
|
+
}
|
|
44647
|
+
}
|
|
44648
|
+
bestLocation = -1;
|
|
44649
|
+
let lastBitArr = [];
|
|
44650
|
+
let finalScore = 1;
|
|
44651
|
+
let bestErrors = 0;
|
|
44652
|
+
let binMax = patternLen + textLen;
|
|
44653
|
+
const mask = 1 << patternLen - 1;
|
|
44654
|
+
for (let i = 0; i < patternLen; i += 1) {
|
|
44655
|
+
let binMin = 0;
|
|
44656
|
+
let binMid = binMax;
|
|
44657
|
+
while (binMin < binMid) {
|
|
44658
|
+
const score2 = calcScore(i, expectedLocation + binMid);
|
|
44659
|
+
if (score2 <= currentThreshold) {
|
|
44660
|
+
binMin = binMid;
|
|
44661
|
+
} else {
|
|
44662
|
+
binMax = binMid;
|
|
44663
|
+
}
|
|
44664
|
+
binMid = Math.floor((binMax - binMin) / 2 + binMin);
|
|
44665
|
+
}
|
|
44666
|
+
binMax = binMid;
|
|
44667
|
+
let start = Math.max(1, expectedLocation - binMid + 1);
|
|
44668
|
+
const finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
|
|
44669
|
+
const bitArr = Array(finish + 2);
|
|
44670
|
+
bitArr[finish + 1] = (1 << i) - 1;
|
|
44671
|
+
for (let j = finish; j >= start; j -= 1) {
|
|
44672
|
+
const currentLocation = j - 1;
|
|
44673
|
+
const charMatch = patternAlphabet[text[currentLocation]];
|
|
44674
|
+
bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
|
|
44675
|
+
if (i) {
|
|
44676
|
+
bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
|
|
44677
|
+
}
|
|
44678
|
+
if (bitArr[j] & mask) {
|
|
44679
|
+
finalScore = calcScore(i, currentLocation);
|
|
44680
|
+
if (finalScore <= currentThreshold) {
|
|
44681
|
+
currentThreshold = finalScore;
|
|
44682
|
+
bestLocation = currentLocation;
|
|
44683
|
+
bestErrors = i;
|
|
44684
|
+
if (bestLocation <= expectedLocation) {
|
|
44685
|
+
break;
|
|
44686
|
+
}
|
|
44687
|
+
start = Math.max(1, 2 * expectedLocation - bestLocation);
|
|
44688
|
+
}
|
|
44689
|
+
}
|
|
44690
|
+
}
|
|
44691
|
+
const score = calcScore(i + 1, expectedLocation);
|
|
44692
|
+
if (score > currentThreshold) {
|
|
44693
|
+
break;
|
|
44694
|
+
}
|
|
44695
|
+
lastBitArr = bitArr;
|
|
44696
|
+
}
|
|
44697
|
+
if (computeMatches && bestLocation >= 0) {
|
|
44698
|
+
const matchEnd = Math.min(textLen - 1, bestLocation + patternLen - 1 + bestErrors);
|
|
44699
|
+
for (let k = bestLocation; k <= matchEnd; k += 1) {
|
|
44700
|
+
if (patternAlphabet[text[k]]) {
|
|
44701
|
+
matchMask[k] = 1;
|
|
44702
|
+
}
|
|
44703
|
+
}
|
|
44704
|
+
}
|
|
44705
|
+
const result = {
|
|
44706
|
+
isMatch: bestLocation >= 0,
|
|
44707
|
+
// Count exact matches (those with a score of 0) to be "almost" exact
|
|
44708
|
+
score: Math.max(1e-3, finalScore)
|
|
44709
|
+
};
|
|
44710
|
+
if (computeMatches) {
|
|
44711
|
+
const indices = convertMaskToIndices(matchMask, minMatchCharLength);
|
|
44712
|
+
if (!indices.length) {
|
|
44713
|
+
result.isMatch = false;
|
|
44714
|
+
} else if (includeMatches) {
|
|
44715
|
+
result.indices = indices;
|
|
44716
|
+
}
|
|
44717
|
+
}
|
|
44718
|
+
return result;
|
|
44719
|
+
}
|
|
44720
|
+
function createPatternAlphabet(pattern) {
|
|
44721
|
+
const mask = {};
|
|
44722
|
+
for (let i = 0, len = pattern.length; i < len; i += 1) {
|
|
44723
|
+
const char = pattern.charAt(i);
|
|
44724
|
+
mask[char] = (mask[char] || 0) | 1 << len - i - 1;
|
|
44725
|
+
}
|
|
44726
|
+
return mask;
|
|
44727
|
+
}
|
|
44728
|
+
function mergeIndices(indices) {
|
|
44729
|
+
if (indices.length <= 1) return indices;
|
|
44730
|
+
indices.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
44731
|
+
const merged = [indices[0]];
|
|
44732
|
+
for (let i = 1, len = indices.length; i < len; i += 1) {
|
|
44733
|
+
const last = merged[merged.length - 1];
|
|
44734
|
+
const curr = indices[i];
|
|
44735
|
+
if (curr[0] <= last[1] + 1) {
|
|
44736
|
+
last[1] = Math.max(last[1], curr[1]);
|
|
44737
|
+
} else {
|
|
44738
|
+
merged.push(curr);
|
|
44739
|
+
}
|
|
44740
|
+
}
|
|
44741
|
+
return merged;
|
|
44742
|
+
}
|
|
44743
|
+
var NON_DECOMPOSABLE_MAP = {
|
|
44744
|
+
"\u0142": "l",
|
|
44745
|
+
// ł
|
|
44746
|
+
"\u0141": "L",
|
|
44747
|
+
// Ł
|
|
44748
|
+
"\u0111": "d",
|
|
44749
|
+
// đ
|
|
44750
|
+
"\u0110": "D",
|
|
44751
|
+
// Đ
|
|
44752
|
+
"\xF8": "o",
|
|
44753
|
+
// ø
|
|
44754
|
+
"\xD8": "O",
|
|
44755
|
+
// Ø
|
|
44756
|
+
"\u0127": "h",
|
|
44757
|
+
// ħ
|
|
44758
|
+
"\u0126": "H",
|
|
44759
|
+
// Ħ
|
|
44760
|
+
"\u0167": "t",
|
|
44761
|
+
// ŧ
|
|
44762
|
+
"\u0166": "T",
|
|
44763
|
+
// Ŧ
|
|
44764
|
+
"\u0131": "i",
|
|
44765
|
+
// ı
|
|
44766
|
+
"\xDF": "ss"
|
|
44767
|
+
// ß
|
|
44768
|
+
};
|
|
44769
|
+
var NON_DECOMPOSABLE_RE = new RegExp("[" + Object.keys(NON_DECOMPOSABLE_MAP).join("") + "]", "g");
|
|
44770
|
+
var stripDiacritics = typeof String.prototype.normalize === "function" ? (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, "").replace(NON_DECOMPOSABLE_RE, (ch) => NON_DECOMPOSABLE_MAP[ch]) : (str) => str;
|
|
44771
|
+
var BitapSearch = class {
|
|
44772
|
+
constructor(pattern, {
|
|
44773
|
+
location = Config.location,
|
|
44774
|
+
threshold = Config.threshold,
|
|
44775
|
+
distance = Config.distance,
|
|
44776
|
+
includeMatches = Config.includeMatches,
|
|
44777
|
+
findAllMatches = Config.findAllMatches,
|
|
44778
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
44779
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
44780
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
44781
|
+
ignoreLocation = Config.ignoreLocation
|
|
44782
|
+
} = {}) {
|
|
44783
|
+
this.options = {
|
|
44784
|
+
location,
|
|
44785
|
+
threshold,
|
|
44786
|
+
distance,
|
|
44787
|
+
includeMatches,
|
|
44788
|
+
findAllMatches,
|
|
44789
|
+
minMatchCharLength,
|
|
44790
|
+
isCaseSensitive,
|
|
44791
|
+
ignoreDiacritics,
|
|
44792
|
+
ignoreLocation
|
|
44793
|
+
};
|
|
44794
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
44795
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
44796
|
+
this.pattern = pattern;
|
|
44797
|
+
this.chunks = [];
|
|
44798
|
+
if (!this.pattern.length) {
|
|
44799
|
+
return;
|
|
44800
|
+
}
|
|
44801
|
+
const addChunk = (pattern2, startIndex) => {
|
|
44802
|
+
this.chunks.push({
|
|
44803
|
+
pattern: pattern2,
|
|
44804
|
+
alphabet: createPatternAlphabet(pattern2),
|
|
44805
|
+
startIndex
|
|
44806
|
+
});
|
|
44807
|
+
};
|
|
44808
|
+
const len = this.pattern.length;
|
|
44809
|
+
if (len > MAX_BITS) {
|
|
44810
|
+
let i = 0;
|
|
44811
|
+
const remainder = len % MAX_BITS;
|
|
44812
|
+
const end = len - remainder;
|
|
44813
|
+
while (i < end) {
|
|
44814
|
+
addChunk(this.pattern.substr(i, MAX_BITS), i);
|
|
44815
|
+
i += MAX_BITS;
|
|
44816
|
+
}
|
|
44817
|
+
if (remainder) {
|
|
44818
|
+
const startIndex = len - MAX_BITS;
|
|
44819
|
+
addChunk(this.pattern.substr(startIndex), startIndex);
|
|
44820
|
+
}
|
|
44821
|
+
} else {
|
|
44822
|
+
addChunk(this.pattern, 0);
|
|
44823
|
+
}
|
|
44824
|
+
}
|
|
44825
|
+
searchIn(text) {
|
|
44826
|
+
const {
|
|
44827
|
+
isCaseSensitive,
|
|
44828
|
+
ignoreDiacritics,
|
|
44829
|
+
includeMatches
|
|
44830
|
+
} = this.options;
|
|
44831
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
44832
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
44833
|
+
if (this.pattern === text) {
|
|
44834
|
+
const result2 = {
|
|
44835
|
+
isMatch: true,
|
|
44836
|
+
score: 0
|
|
44837
|
+
};
|
|
44838
|
+
if (includeMatches) {
|
|
44839
|
+
result2.indices = [[0, text.length - 1]];
|
|
44840
|
+
}
|
|
44841
|
+
return result2;
|
|
44842
|
+
}
|
|
44843
|
+
const {
|
|
44844
|
+
location,
|
|
44845
|
+
distance,
|
|
44846
|
+
threshold,
|
|
44847
|
+
findAllMatches,
|
|
44848
|
+
minMatchCharLength,
|
|
44849
|
+
ignoreLocation
|
|
44850
|
+
} = this.options;
|
|
44851
|
+
const allIndices = [];
|
|
44852
|
+
let totalScore = 0;
|
|
44853
|
+
let hasMatches = false;
|
|
44854
|
+
this.chunks.forEach(({
|
|
44855
|
+
pattern,
|
|
44856
|
+
alphabet,
|
|
44857
|
+
startIndex
|
|
44858
|
+
}) => {
|
|
44859
|
+
const {
|
|
44860
|
+
isMatch,
|
|
44861
|
+
score,
|
|
44862
|
+
indices
|
|
44863
|
+
} = search(text, pattern, alphabet, {
|
|
44864
|
+
location: location + startIndex,
|
|
44865
|
+
distance,
|
|
44866
|
+
threshold,
|
|
44867
|
+
findAllMatches,
|
|
44868
|
+
minMatchCharLength,
|
|
44869
|
+
includeMatches,
|
|
44870
|
+
ignoreLocation
|
|
44871
|
+
});
|
|
44872
|
+
if (isMatch) {
|
|
44873
|
+
hasMatches = true;
|
|
44874
|
+
}
|
|
44875
|
+
totalScore += score;
|
|
44876
|
+
if (isMatch && indices) {
|
|
44877
|
+
allIndices.push(...indices);
|
|
44878
|
+
}
|
|
44879
|
+
});
|
|
44880
|
+
const result = {
|
|
44881
|
+
isMatch: hasMatches,
|
|
44882
|
+
score: hasMatches ? totalScore / this.chunks.length : 1
|
|
44883
|
+
};
|
|
44884
|
+
if (hasMatches && includeMatches) {
|
|
44885
|
+
result.indices = mergeIndices(allIndices);
|
|
44886
|
+
}
|
|
44887
|
+
return result;
|
|
44888
|
+
}
|
|
44889
|
+
};
|
|
44890
|
+
var MULTI_MATCH_TYPES = /* @__PURE__ */ new Set(["fuzzy", "include"]);
|
|
44891
|
+
function isInverse(type) {
|
|
44892
|
+
return type.startsWith("inverse");
|
|
44893
|
+
}
|
|
44894
|
+
var matchers = [
|
|
44895
|
+
// =term — exact match
|
|
44896
|
+
{
|
|
44897
|
+
type: "exact",
|
|
44898
|
+
multiRegex: /^="(.*)"$/,
|
|
44899
|
+
singleRegex: /^=(.*)$/,
|
|
44900
|
+
create: (pattern) => ({
|
|
44901
|
+
type: "exact",
|
|
44902
|
+
search(text) {
|
|
44903
|
+
const isMatch = text === pattern;
|
|
44904
|
+
return {
|
|
44905
|
+
isMatch,
|
|
44906
|
+
score: isMatch ? 0 : 1,
|
|
44907
|
+
indices: [0, pattern.length - 1]
|
|
44908
|
+
};
|
|
44909
|
+
}
|
|
44910
|
+
})
|
|
44911
|
+
},
|
|
44912
|
+
// 'term — include (substring) match
|
|
44913
|
+
{
|
|
44914
|
+
type: "include",
|
|
44915
|
+
multiRegex: /^'"(.*)"$/,
|
|
44916
|
+
singleRegex: /^'(.*)$/,
|
|
44917
|
+
create: (pattern) => ({
|
|
44918
|
+
type: "include",
|
|
44919
|
+
search(text) {
|
|
44920
|
+
let location = 0;
|
|
44921
|
+
let index2;
|
|
44922
|
+
const indices = [];
|
|
44923
|
+
const patternLen = pattern.length;
|
|
44924
|
+
while ((index2 = text.indexOf(pattern, location)) > -1) {
|
|
44925
|
+
location = index2 + patternLen;
|
|
44926
|
+
indices.push([index2, location - 1]);
|
|
44927
|
+
}
|
|
44928
|
+
const isMatch = !!indices.length;
|
|
44929
|
+
return {
|
|
44930
|
+
isMatch,
|
|
44931
|
+
score: isMatch ? 0 : 1,
|
|
44932
|
+
indices
|
|
44933
|
+
};
|
|
44934
|
+
}
|
|
44935
|
+
})
|
|
44936
|
+
},
|
|
44937
|
+
// ^term — prefix match
|
|
44938
|
+
{
|
|
44939
|
+
type: "prefix-exact",
|
|
44940
|
+
multiRegex: /^\^"(.*)"$/,
|
|
44941
|
+
singleRegex: /^\^(.*)$/,
|
|
44942
|
+
create: (pattern) => ({
|
|
44943
|
+
type: "prefix-exact",
|
|
44944
|
+
search(text) {
|
|
44945
|
+
const isMatch = text.startsWith(pattern);
|
|
44946
|
+
return {
|
|
44947
|
+
isMatch,
|
|
44948
|
+
score: isMatch ? 0 : 1,
|
|
44949
|
+
indices: [0, pattern.length - 1]
|
|
44950
|
+
};
|
|
44951
|
+
}
|
|
44952
|
+
})
|
|
44953
|
+
},
|
|
44954
|
+
// !^term — inverse prefix match
|
|
44955
|
+
{
|
|
44956
|
+
type: "inverse-prefix-exact",
|
|
44957
|
+
multiRegex: /^!\^"(.*)"$/,
|
|
44958
|
+
singleRegex: /^!\^(.*)$/,
|
|
44959
|
+
create: (pattern) => ({
|
|
44960
|
+
type: "inverse-prefix-exact",
|
|
44961
|
+
search(text) {
|
|
44962
|
+
const isMatch = !text.startsWith(pattern);
|
|
44963
|
+
return {
|
|
44964
|
+
isMatch,
|
|
44965
|
+
score: isMatch ? 0 : 1,
|
|
44966
|
+
indices: [0, text.length - 1]
|
|
44967
|
+
};
|
|
44968
|
+
}
|
|
44969
|
+
})
|
|
44970
|
+
},
|
|
44971
|
+
// !term$ — inverse suffix match
|
|
44972
|
+
{
|
|
44973
|
+
type: "inverse-suffix-exact",
|
|
44974
|
+
multiRegex: /^!"(.*)"\$$/,
|
|
44975
|
+
singleRegex: /^!(.*)\$$/,
|
|
44976
|
+
create: (pattern) => ({
|
|
44977
|
+
type: "inverse-suffix-exact",
|
|
44978
|
+
search(text) {
|
|
44979
|
+
const isMatch = !text.endsWith(pattern);
|
|
44980
|
+
return {
|
|
44981
|
+
isMatch,
|
|
44982
|
+
score: isMatch ? 0 : 1,
|
|
44983
|
+
indices: [0, text.length - 1]
|
|
44984
|
+
};
|
|
44985
|
+
}
|
|
44986
|
+
})
|
|
44987
|
+
},
|
|
44988
|
+
// term$ — suffix match
|
|
44989
|
+
{
|
|
44990
|
+
type: "suffix-exact",
|
|
44991
|
+
multiRegex: /^"(.*)"\$$/,
|
|
44992
|
+
singleRegex: /^(.*)\$$/,
|
|
44993
|
+
create: (pattern) => ({
|
|
44994
|
+
type: "suffix-exact",
|
|
44995
|
+
search(text) {
|
|
44996
|
+
const isMatch = text.endsWith(pattern);
|
|
44997
|
+
return {
|
|
44998
|
+
isMatch,
|
|
44999
|
+
score: isMatch ? 0 : 1,
|
|
45000
|
+
indices: [text.length - pattern.length, text.length - 1]
|
|
45001
|
+
};
|
|
45002
|
+
}
|
|
45003
|
+
})
|
|
45004
|
+
},
|
|
45005
|
+
// !term — inverse exact (does not contain)
|
|
45006
|
+
{
|
|
45007
|
+
type: "inverse-exact",
|
|
45008
|
+
multiRegex: /^!"(.*)"$/,
|
|
45009
|
+
singleRegex: /^!(.*)$/,
|
|
45010
|
+
create: (pattern) => ({
|
|
45011
|
+
type: "inverse-exact",
|
|
45012
|
+
search(text) {
|
|
45013
|
+
const isMatch = text.indexOf(pattern) === -1;
|
|
45014
|
+
return {
|
|
45015
|
+
isMatch,
|
|
45016
|
+
score: isMatch ? 0 : 1,
|
|
45017
|
+
indices: [0, text.length - 1]
|
|
45018
|
+
};
|
|
45019
|
+
}
|
|
45020
|
+
})
|
|
45021
|
+
},
|
|
45022
|
+
// term — fuzzy match (catch-all, must be last)
|
|
45023
|
+
{
|
|
45024
|
+
type: "fuzzy",
|
|
45025
|
+
multiRegex: /^"(.*)"$/,
|
|
45026
|
+
singleRegex: /^(.*)$/,
|
|
45027
|
+
create: (pattern, options2 = {}) => {
|
|
45028
|
+
const bitap = new BitapSearch(pattern, {
|
|
45029
|
+
location: options2.location ?? Config.location,
|
|
45030
|
+
threshold: options2.threshold ?? Config.threshold,
|
|
45031
|
+
distance: options2.distance ?? Config.distance,
|
|
45032
|
+
includeMatches: options2.includeMatches ?? Config.includeMatches,
|
|
45033
|
+
findAllMatches: options2.findAllMatches ?? Config.findAllMatches,
|
|
45034
|
+
minMatchCharLength: options2.minMatchCharLength ?? Config.minMatchCharLength,
|
|
45035
|
+
isCaseSensitive: options2.isCaseSensitive ?? Config.isCaseSensitive,
|
|
45036
|
+
ignoreDiacritics: options2.ignoreDiacritics ?? Config.ignoreDiacritics,
|
|
45037
|
+
ignoreLocation: options2.ignoreLocation ?? Config.ignoreLocation
|
|
45038
|
+
});
|
|
45039
|
+
return {
|
|
45040
|
+
type: "fuzzy",
|
|
45041
|
+
search(text) {
|
|
45042
|
+
return bitap.searchIn(text);
|
|
45043
|
+
}
|
|
45044
|
+
};
|
|
45045
|
+
}
|
|
45046
|
+
}
|
|
45047
|
+
];
|
|
45048
|
+
var matchersLen = matchers.length;
|
|
45049
|
+
var ESCAPED_PIPE = "\0";
|
|
45050
|
+
var OR_TOKEN = "|";
|
|
45051
|
+
function tokenize(pattern) {
|
|
45052
|
+
const tokens = [];
|
|
45053
|
+
const len = pattern.length;
|
|
45054
|
+
let i = 0;
|
|
45055
|
+
while (i < len) {
|
|
45056
|
+
while (i < len && pattern[i] === " ") i++;
|
|
45057
|
+
if (i >= len) break;
|
|
45058
|
+
let j = i;
|
|
45059
|
+
while (j < len && pattern[j] !== " " && pattern[j] !== '"') j++;
|
|
45060
|
+
if (j < len && pattern[j] === '"') {
|
|
45061
|
+
j++;
|
|
45062
|
+
while (j < len) {
|
|
45063
|
+
if (pattern[j] === '"') {
|
|
45064
|
+
const next = j + 1;
|
|
45065
|
+
if (next >= len || pattern[next] === " ") {
|
|
45066
|
+
j++;
|
|
45067
|
+
break;
|
|
45068
|
+
}
|
|
45069
|
+
if (pattern[next] === "$" && (next + 1 >= len || pattern[next + 1] === " ")) {
|
|
45070
|
+
j += 2;
|
|
45071
|
+
break;
|
|
45072
|
+
}
|
|
45073
|
+
}
|
|
45074
|
+
j++;
|
|
45075
|
+
}
|
|
45076
|
+
tokens.push(pattern.substring(i, j));
|
|
45077
|
+
i = j;
|
|
45078
|
+
} else {
|
|
45079
|
+
while (j < len && pattern[j] !== " ") j++;
|
|
45080
|
+
tokens.push(pattern.substring(i, j));
|
|
45081
|
+
i = j;
|
|
45082
|
+
}
|
|
45083
|
+
}
|
|
45084
|
+
return tokens;
|
|
45085
|
+
}
|
|
45086
|
+
function getMatch(pattern, exp) {
|
|
45087
|
+
const matches = pattern.match(exp);
|
|
45088
|
+
return matches ? matches[1] : null;
|
|
45089
|
+
}
|
|
45090
|
+
function parseQuery(pattern, options2 = {}) {
|
|
45091
|
+
const escaped = pattern.replace(/\\\|/g, ESCAPED_PIPE);
|
|
45092
|
+
return escaped.split(OR_TOKEN).map((item) => {
|
|
45093
|
+
const restored = item.replace(/\u0000/g, "|");
|
|
45094
|
+
const query = tokenize(restored.trim()).filter((item2) => item2 && !!item2.trim());
|
|
45095
|
+
const results = [];
|
|
45096
|
+
for (let i = 0, len = query.length; i < len; i += 1) {
|
|
45097
|
+
const queryItem = query[i];
|
|
45098
|
+
let found = false;
|
|
45099
|
+
let idx = -1;
|
|
45100
|
+
while (!found && ++idx < matchersLen) {
|
|
45101
|
+
const def = matchers[idx];
|
|
45102
|
+
const token = getMatch(queryItem, def.multiRegex);
|
|
45103
|
+
if (token) {
|
|
45104
|
+
results.push(def.create(token, options2));
|
|
45105
|
+
found = true;
|
|
45106
|
+
}
|
|
45107
|
+
}
|
|
45108
|
+
if (found) {
|
|
45109
|
+
continue;
|
|
45110
|
+
}
|
|
45111
|
+
idx = -1;
|
|
45112
|
+
while (++idx < matchersLen) {
|
|
45113
|
+
const def = matchers[idx];
|
|
45114
|
+
const token = getMatch(queryItem, def.singleRegex);
|
|
45115
|
+
if (token) {
|
|
45116
|
+
results.push(def.create(token, options2));
|
|
45117
|
+
break;
|
|
45118
|
+
}
|
|
45119
|
+
}
|
|
45120
|
+
}
|
|
45121
|
+
return results;
|
|
45122
|
+
});
|
|
45123
|
+
}
|
|
45124
|
+
var ExtendedSearch = class {
|
|
45125
|
+
constructor(pattern, {
|
|
45126
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
45127
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
45128
|
+
includeMatches = Config.includeMatches,
|
|
45129
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
45130
|
+
ignoreLocation = Config.ignoreLocation,
|
|
45131
|
+
findAllMatches = Config.findAllMatches,
|
|
45132
|
+
location = Config.location,
|
|
45133
|
+
threshold = Config.threshold,
|
|
45134
|
+
distance = Config.distance
|
|
45135
|
+
} = {}) {
|
|
45136
|
+
this.query = null;
|
|
45137
|
+
this.options = {
|
|
45138
|
+
isCaseSensitive,
|
|
45139
|
+
ignoreDiacritics,
|
|
45140
|
+
includeMatches,
|
|
45141
|
+
minMatchCharLength,
|
|
45142
|
+
findAllMatches,
|
|
45143
|
+
ignoreLocation,
|
|
45144
|
+
location,
|
|
45145
|
+
threshold,
|
|
45146
|
+
distance
|
|
45147
|
+
};
|
|
45148
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
45149
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
45150
|
+
this.pattern = pattern;
|
|
45151
|
+
this.query = parseQuery(this.pattern, this.options);
|
|
45152
|
+
}
|
|
45153
|
+
static condition(_, options2) {
|
|
45154
|
+
return options2.useExtendedSearch;
|
|
45155
|
+
}
|
|
45156
|
+
// Note: searchIn operates on a single text value and sets hasInverse on the
|
|
45157
|
+
// result when inverse patterns are involved. _searchObjectList uses this to
|
|
45158
|
+
// switch from "ANY key" to "ALL keys" aggregation. See #712.
|
|
45159
|
+
searchIn(text) {
|
|
45160
|
+
const query = this.query;
|
|
45161
|
+
if (!query) {
|
|
45162
|
+
return {
|
|
45163
|
+
isMatch: false,
|
|
45164
|
+
score: 1
|
|
45165
|
+
};
|
|
45166
|
+
}
|
|
45167
|
+
const {
|
|
45168
|
+
includeMatches,
|
|
45169
|
+
isCaseSensitive,
|
|
45170
|
+
ignoreDiacritics
|
|
45171
|
+
} = this.options;
|
|
45172
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
45173
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
45174
|
+
let numMatches = 0;
|
|
45175
|
+
const allIndices = [];
|
|
45176
|
+
let totalScore = 0;
|
|
45177
|
+
let hasInverse = false;
|
|
45178
|
+
for (let i = 0, qLen = query.length; i < qLen; i += 1) {
|
|
45179
|
+
const searchers = query[i];
|
|
45180
|
+
allIndices.length = 0;
|
|
45181
|
+
numMatches = 0;
|
|
45182
|
+
hasInverse = false;
|
|
45183
|
+
for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
|
|
45184
|
+
const matcher = searchers[j];
|
|
45185
|
+
const {
|
|
45186
|
+
isMatch,
|
|
45187
|
+
indices,
|
|
45188
|
+
score
|
|
45189
|
+
} = matcher.search(text);
|
|
45190
|
+
if (isMatch) {
|
|
45191
|
+
numMatches += 1;
|
|
45192
|
+
totalScore += score;
|
|
45193
|
+
if (isInverse(matcher.type)) {
|
|
45194
|
+
hasInverse = true;
|
|
45195
|
+
}
|
|
45196
|
+
if (includeMatches) {
|
|
45197
|
+
if (MULTI_MATCH_TYPES.has(matcher.type)) {
|
|
45198
|
+
allIndices.push(...indices);
|
|
45199
|
+
} else {
|
|
45200
|
+
allIndices.push(indices);
|
|
45201
|
+
}
|
|
45202
|
+
}
|
|
45203
|
+
} else {
|
|
45204
|
+
totalScore = 0;
|
|
45205
|
+
numMatches = 0;
|
|
45206
|
+
allIndices.length = 0;
|
|
45207
|
+
hasInverse = false;
|
|
45208
|
+
break;
|
|
45209
|
+
}
|
|
45210
|
+
}
|
|
45211
|
+
if (numMatches) {
|
|
45212
|
+
const result = {
|
|
45213
|
+
isMatch: true,
|
|
45214
|
+
score: totalScore / numMatches
|
|
45215
|
+
};
|
|
45216
|
+
if (hasInverse) {
|
|
45217
|
+
result.hasInverse = true;
|
|
45218
|
+
}
|
|
45219
|
+
if (includeMatches) {
|
|
45220
|
+
result.indices = mergeIndices(allIndices);
|
|
45221
|
+
}
|
|
45222
|
+
return result;
|
|
45223
|
+
}
|
|
45224
|
+
}
|
|
45225
|
+
return {
|
|
45226
|
+
isMatch: false,
|
|
45227
|
+
score: 1
|
|
45228
|
+
};
|
|
45229
|
+
}
|
|
45230
|
+
};
|
|
45231
|
+
var registeredSearchers = [];
|
|
45232
|
+
function register(...args) {
|
|
45233
|
+
registeredSearchers.push(...args);
|
|
45234
|
+
}
|
|
45235
|
+
function createSearcher(pattern, options2) {
|
|
45236
|
+
for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
|
|
45237
|
+
const searcherClass = registeredSearchers[i];
|
|
45238
|
+
if (searcherClass.condition(pattern, options2)) {
|
|
45239
|
+
return new searcherClass(pattern, options2);
|
|
45240
|
+
}
|
|
45241
|
+
}
|
|
45242
|
+
return new BitapSearch(pattern, options2);
|
|
45243
|
+
}
|
|
45244
|
+
var LogicalOperator = {
|
|
45245
|
+
AND: "$and",
|
|
45246
|
+
OR: "$or"
|
|
45247
|
+
};
|
|
45248
|
+
var KeyType = {
|
|
45249
|
+
PATH: "$path",
|
|
45250
|
+
PATTERN: "$val"
|
|
45251
|
+
};
|
|
45252
|
+
var isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
|
|
45253
|
+
var isPath = (query) => !!query[KeyType.PATH];
|
|
45254
|
+
var isLeaf = (query) => !isArray(query) && isObject(query) && !isExpression(query);
|
|
45255
|
+
var convertToExplicit = (query) => ({
|
|
45256
|
+
[LogicalOperator.AND]: Object.keys(query).map((key) => ({
|
|
45257
|
+
[key]: query[key]
|
|
45258
|
+
}))
|
|
45259
|
+
});
|
|
45260
|
+
function parse2(query, options2, {
|
|
45261
|
+
auto = true
|
|
45262
|
+
} = {}) {
|
|
45263
|
+
const next = (query2) => {
|
|
45264
|
+
if (isString(query2)) {
|
|
45265
|
+
const obj = {
|
|
45266
|
+
keyId: null,
|
|
45267
|
+
pattern: query2
|
|
45268
|
+
};
|
|
45269
|
+
if (auto) {
|
|
45270
|
+
obj.searcher = createSearcher(query2, options2);
|
|
45271
|
+
}
|
|
45272
|
+
return obj;
|
|
45273
|
+
}
|
|
45274
|
+
const keys = Object.keys(query2);
|
|
45275
|
+
const isQueryPath = isPath(query2);
|
|
45276
|
+
if (!isQueryPath && keys.length > 1 && !isExpression(query2)) {
|
|
45277
|
+
return next(convertToExplicit(query2));
|
|
45278
|
+
}
|
|
45279
|
+
if (isLeaf(query2)) {
|
|
45280
|
+
const key = isQueryPath ? query2[KeyType.PATH] : keys[0];
|
|
45281
|
+
const pattern = isQueryPath ? query2[KeyType.PATTERN] : query2[key];
|
|
45282
|
+
if (!isString(pattern)) {
|
|
45283
|
+
throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
|
|
45284
|
+
}
|
|
45285
|
+
const obj = {
|
|
45286
|
+
keyId: createKeyId(key),
|
|
45287
|
+
pattern
|
|
45288
|
+
};
|
|
45289
|
+
if (auto) {
|
|
45290
|
+
obj.searcher = createSearcher(pattern, options2);
|
|
45291
|
+
}
|
|
45292
|
+
return obj;
|
|
45293
|
+
}
|
|
45294
|
+
const node = {
|
|
45295
|
+
children: [],
|
|
45296
|
+
operator: keys[0]
|
|
45297
|
+
};
|
|
45298
|
+
keys.forEach((key) => {
|
|
45299
|
+
const value = query2[key];
|
|
45300
|
+
if (isArray(value)) {
|
|
45301
|
+
value.forEach((item) => {
|
|
45302
|
+
node.children.push(next(item));
|
|
45303
|
+
});
|
|
45304
|
+
}
|
|
45305
|
+
});
|
|
45306
|
+
return node;
|
|
45307
|
+
};
|
|
45308
|
+
if (!isExpression(query)) {
|
|
45309
|
+
query = convertToExplicit(query);
|
|
45310
|
+
}
|
|
45311
|
+
return next(query);
|
|
45312
|
+
}
|
|
45313
|
+
function computeScoreSingle(matches, {
|
|
45314
|
+
ignoreFieldNorm = Config.ignoreFieldNorm
|
|
45315
|
+
}) {
|
|
45316
|
+
let totalScore = 1;
|
|
45317
|
+
matches.forEach(({
|
|
45318
|
+
key,
|
|
45319
|
+
norm: norm2,
|
|
45320
|
+
score
|
|
45321
|
+
}) => {
|
|
45322
|
+
const weight = key ? key.weight : null;
|
|
45323
|
+
totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm2));
|
|
45324
|
+
});
|
|
45325
|
+
return totalScore;
|
|
45326
|
+
}
|
|
45327
|
+
function computeScore(results, {
|
|
45328
|
+
ignoreFieldNorm = Config.ignoreFieldNorm
|
|
45329
|
+
}) {
|
|
45330
|
+
results.forEach((result) => {
|
|
45331
|
+
result.score = computeScoreSingle(result.matches, {
|
|
45332
|
+
ignoreFieldNorm
|
|
45333
|
+
});
|
|
45334
|
+
});
|
|
45335
|
+
}
|
|
45336
|
+
var MaxHeap = class {
|
|
45337
|
+
constructor(limit) {
|
|
45338
|
+
this.limit = limit;
|
|
45339
|
+
this.heap = [];
|
|
45340
|
+
}
|
|
45341
|
+
get size() {
|
|
45342
|
+
return this.heap.length;
|
|
45343
|
+
}
|
|
45344
|
+
shouldInsert(score) {
|
|
45345
|
+
return this.size < this.limit || score < this.heap[0].score;
|
|
45346
|
+
}
|
|
45347
|
+
insert(item) {
|
|
45348
|
+
if (this.size < this.limit) {
|
|
45349
|
+
this.heap.push(item);
|
|
45350
|
+
this._bubbleUp(this.size - 1);
|
|
45351
|
+
} else if (item.score < this.heap[0].score) {
|
|
45352
|
+
this.heap[0] = item;
|
|
45353
|
+
this._sinkDown(0);
|
|
45354
|
+
}
|
|
45355
|
+
}
|
|
45356
|
+
extractSorted(sortFn) {
|
|
45357
|
+
return this.heap.sort(sortFn);
|
|
45358
|
+
}
|
|
45359
|
+
_bubbleUp(i) {
|
|
45360
|
+
const heap = this.heap;
|
|
45361
|
+
while (i > 0) {
|
|
45362
|
+
const parent = i - 1 >> 1;
|
|
45363
|
+
if (heap[i].score <= heap[parent].score) break;
|
|
45364
|
+
const tmp = heap[i];
|
|
45365
|
+
heap[i] = heap[parent];
|
|
45366
|
+
heap[parent] = tmp;
|
|
45367
|
+
i = parent;
|
|
45368
|
+
}
|
|
45369
|
+
}
|
|
45370
|
+
_sinkDown(i) {
|
|
45371
|
+
const heap = this.heap;
|
|
45372
|
+
const len = heap.length;
|
|
45373
|
+
let largest = i;
|
|
45374
|
+
do {
|
|
45375
|
+
i = largest;
|
|
45376
|
+
const left = 2 * i + 1;
|
|
45377
|
+
const right = 2 * i + 2;
|
|
45378
|
+
if (left < len && heap[left].score > heap[largest].score) {
|
|
45379
|
+
largest = left;
|
|
45380
|
+
}
|
|
45381
|
+
if (right < len && heap[right].score > heap[largest].score) {
|
|
45382
|
+
largest = right;
|
|
45383
|
+
}
|
|
45384
|
+
if (largest !== i) {
|
|
45385
|
+
const tmp = heap[i];
|
|
45386
|
+
heap[i] = heap[largest];
|
|
45387
|
+
heap[largest] = tmp;
|
|
45388
|
+
}
|
|
45389
|
+
} while (largest !== i);
|
|
45390
|
+
}
|
|
45391
|
+
};
|
|
45392
|
+
function formatMatches(result) {
|
|
45393
|
+
const matches = [];
|
|
45394
|
+
result.matches.forEach((match) => {
|
|
45395
|
+
if (!isDefined(match.indices) || !match.indices.length) {
|
|
45396
|
+
return;
|
|
45397
|
+
}
|
|
45398
|
+
const obj = {
|
|
45399
|
+
indices: match.indices,
|
|
45400
|
+
value: match.value
|
|
45401
|
+
};
|
|
45402
|
+
if (match.key) {
|
|
45403
|
+
obj.key = match.key.id;
|
|
45404
|
+
}
|
|
45405
|
+
if (match.idx > -1) {
|
|
45406
|
+
obj.refIndex = match.idx;
|
|
45407
|
+
}
|
|
45408
|
+
matches.push(obj);
|
|
45409
|
+
});
|
|
45410
|
+
return matches;
|
|
45411
|
+
}
|
|
45412
|
+
function format(results, docs, {
|
|
45413
|
+
includeMatches = Config.includeMatches,
|
|
45414
|
+
includeScore = Config.includeScore
|
|
45415
|
+
} = {}) {
|
|
45416
|
+
return results.map((result) => {
|
|
45417
|
+
const {
|
|
45418
|
+
idx
|
|
45419
|
+
} = result;
|
|
45420
|
+
const data = {
|
|
45421
|
+
item: docs[idx],
|
|
45422
|
+
refIndex: idx
|
|
45423
|
+
};
|
|
45424
|
+
if (includeMatches) data.matches = formatMatches(result);
|
|
45425
|
+
if (includeScore) data.score = result.score;
|
|
45426
|
+
return data;
|
|
45427
|
+
});
|
|
45428
|
+
}
|
|
45429
|
+
var DEFAULT_TOKEN = /[\p{L}\p{M}\p{N}_]+/gu;
|
|
45430
|
+
var warned = /* @__PURE__ */ new WeakSet();
|
|
45431
|
+
function warnNonGlobal(regex) {
|
|
45432
|
+
if (!warned.has(regex)) {
|
|
45433
|
+
warned.add(regex);
|
|
45434
|
+
console.warn(`[Fuse] tokenize regex ${regex} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`);
|
|
45435
|
+
}
|
|
45436
|
+
}
|
|
45437
|
+
function resolveTokenize(tokenize2) {
|
|
45438
|
+
if (typeof tokenize2 === "function") {
|
|
45439
|
+
let validated = false;
|
|
45440
|
+
return (text) => {
|
|
45441
|
+
const result = tokenize2(text);
|
|
45442
|
+
if (!validated) {
|
|
45443
|
+
validated = true;
|
|
45444
|
+
if (!Array.isArray(result) || result.some((t12) => typeof t12 !== "string")) {
|
|
45445
|
+
throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(result) ? "array containing non-strings" : typeof result}.`);
|
|
45446
|
+
}
|
|
45447
|
+
}
|
|
45448
|
+
return result;
|
|
45449
|
+
};
|
|
45450
|
+
}
|
|
45451
|
+
if (tokenize2 instanceof RegExp) {
|
|
45452
|
+
if (!tokenize2.global) warnNonGlobal(tokenize2);
|
|
45453
|
+
return (text) => text.match(tokenize2) || [];
|
|
45454
|
+
}
|
|
45455
|
+
return (text) => text.match(DEFAULT_TOKEN) || [];
|
|
45456
|
+
}
|
|
45457
|
+
function createAnalyzer({
|
|
45458
|
+
isCaseSensitive = false,
|
|
45459
|
+
ignoreDiacritics = false,
|
|
45460
|
+
tokenize: tokenize2
|
|
45461
|
+
} = {}) {
|
|
45462
|
+
const tokenizeFn = resolveTokenize(tokenize2);
|
|
45463
|
+
return {
|
|
45464
|
+
tokenize(text) {
|
|
45465
|
+
if (!isCaseSensitive) {
|
|
45466
|
+
text = text.toLowerCase();
|
|
45467
|
+
}
|
|
45468
|
+
if (ignoreDiacritics) {
|
|
45469
|
+
text = stripDiacritics(text);
|
|
45470
|
+
}
|
|
45471
|
+
return tokenizeFn(text);
|
|
45472
|
+
}
|
|
45473
|
+
};
|
|
45474
|
+
}
|
|
45475
|
+
var MAX_MASK_TERMS = 31;
|
|
45476
|
+
var TokenSearch = class {
|
|
45477
|
+
// `tokenMatch: 'all'` (AND) coverage. When true, searchIn reports which
|
|
45478
|
+
// query terms matched each text so the core loop can require record-level
|
|
45479
|
+
// coverage of every term. Bitmask is the ≤31-term fast path; Set is the
|
|
45480
|
+
// ≥32-term fallback (JS bitwise ops are 32-bit signed).
|
|
45481
|
+
static condition(_, options2) {
|
|
45482
|
+
return options2.useTokenSearch;
|
|
45483
|
+
}
|
|
45484
|
+
constructor(pattern, options2) {
|
|
45485
|
+
this.options = options2;
|
|
45486
|
+
this.analyzer = createAnalyzer({
|
|
45487
|
+
isCaseSensitive: options2.isCaseSensitive,
|
|
45488
|
+
ignoreDiacritics: options2.ignoreDiacritics,
|
|
45489
|
+
tokenize: options2.tokenize
|
|
45490
|
+
});
|
|
45491
|
+
const queryTerms = this.analyzer.tokenize(pattern);
|
|
45492
|
+
const invertedIndex = options2._invertedIndex;
|
|
45493
|
+
const {
|
|
45494
|
+
df,
|
|
45495
|
+
fieldCount
|
|
45496
|
+
} = invertedIndex;
|
|
45497
|
+
this.termSearchers = [];
|
|
45498
|
+
this.idfWeights = [];
|
|
45499
|
+
for (const term of queryTerms) {
|
|
45500
|
+
this.termSearchers.push(new BitapSearch(term, {
|
|
45501
|
+
location: options2.location,
|
|
45502
|
+
threshold: options2.threshold,
|
|
45503
|
+
distance: options2.distance,
|
|
45504
|
+
includeMatches: options2.includeMatches,
|
|
45505
|
+
findAllMatches: options2.findAllMatches,
|
|
45506
|
+
minMatchCharLength: options2.minMatchCharLength,
|
|
45507
|
+
isCaseSensitive: options2.isCaseSensitive,
|
|
45508
|
+
ignoreDiacritics: options2.ignoreDiacritics,
|
|
45509
|
+
ignoreLocation: true
|
|
45510
|
+
}));
|
|
45511
|
+
const docFreq = df.get(term) || 0;
|
|
45512
|
+
const idf = Math.log(1 + (fieldCount - docFreq + 0.5) / (docFreq + 0.5));
|
|
45513
|
+
this.idfWeights.push(idf);
|
|
45514
|
+
}
|
|
45515
|
+
this.combineAll = options2.tokenMatch === "all";
|
|
45516
|
+
this.numTerms = this.termSearchers.length;
|
|
45517
|
+
this.useMask = this.numTerms <= MAX_MASK_TERMS;
|
|
45518
|
+
}
|
|
45519
|
+
searchIn(text) {
|
|
45520
|
+
if (!this.termSearchers.length) {
|
|
45521
|
+
return {
|
|
45522
|
+
isMatch: false,
|
|
45523
|
+
score: 1
|
|
45524
|
+
};
|
|
45525
|
+
}
|
|
45526
|
+
const allIndices = [];
|
|
45527
|
+
let weightedScore = 0;
|
|
45528
|
+
let maxPossibleScore = 0;
|
|
45529
|
+
let matchedCount = 0;
|
|
45530
|
+
let matchedMask = 0;
|
|
45531
|
+
const matchedTerms = this.combineAll && !this.useMask ? /* @__PURE__ */ new Set() : null;
|
|
45532
|
+
for (let i = 0; i < this.termSearchers.length; i++) {
|
|
45533
|
+
const result = this.termSearchers[i].searchIn(text);
|
|
45534
|
+
const idf = this.idfWeights[i];
|
|
45535
|
+
maxPossibleScore += idf;
|
|
45536
|
+
if (result.isMatch) {
|
|
45537
|
+
matchedCount++;
|
|
45538
|
+
weightedScore += idf * (1 - result.score);
|
|
45539
|
+
if (result.indices) {
|
|
45540
|
+
allIndices.push(...result.indices);
|
|
45541
|
+
}
|
|
45542
|
+
if (this.combineAll) {
|
|
45543
|
+
if (this.useMask) {
|
|
45544
|
+
matchedMask |= 1 << i;
|
|
45545
|
+
} else {
|
|
45546
|
+
matchedTerms.add(i);
|
|
45547
|
+
}
|
|
45548
|
+
}
|
|
45549
|
+
}
|
|
45550
|
+
}
|
|
45551
|
+
if (matchedCount === 0) {
|
|
45552
|
+
return {
|
|
45553
|
+
isMatch: false,
|
|
45554
|
+
score: 1
|
|
45555
|
+
};
|
|
45556
|
+
}
|
|
45557
|
+
const normalized = maxPossibleScore > 0 ? 1 - weightedScore / maxPossibleScore : 0;
|
|
45558
|
+
const searchResult = {
|
|
45559
|
+
isMatch: true,
|
|
45560
|
+
score: Math.max(1e-3, normalized)
|
|
45561
|
+
};
|
|
45562
|
+
if (this.options.includeMatches && allIndices.length) {
|
|
45563
|
+
searchResult.indices = mergeIndices(allIndices);
|
|
45564
|
+
}
|
|
45565
|
+
if (this.combineAll) {
|
|
45566
|
+
if (this.useMask) {
|
|
45567
|
+
searchResult.matchedMask = matchedMask;
|
|
45568
|
+
} else {
|
|
45569
|
+
searchResult.matchedTerms = matchedTerms;
|
|
45570
|
+
}
|
|
45571
|
+
searchResult.termCount = this.numTerms;
|
|
45572
|
+
}
|
|
45573
|
+
return searchResult;
|
|
45574
|
+
}
|
|
45575
|
+
};
|
|
45576
|
+
function addField(index2, text, docIdx, analyzer) {
|
|
45577
|
+
const tokens = analyzer.tokenize(text);
|
|
45578
|
+
if (!tokens.length) return;
|
|
45579
|
+
index2.fieldCount++;
|
|
45580
|
+
index2.docFieldCount.set(docIdx, (index2.docFieldCount.get(docIdx) || 0) + 1);
|
|
45581
|
+
const distinctTerms = new Set(tokens);
|
|
45582
|
+
let perDocTerms = index2.docTermFieldHits.get(docIdx);
|
|
45583
|
+
if (!perDocTerms) {
|
|
45584
|
+
perDocTerms = /* @__PURE__ */ new Map();
|
|
45585
|
+
index2.docTermFieldHits.set(docIdx, perDocTerms);
|
|
45586
|
+
}
|
|
45587
|
+
for (const term of distinctTerms) {
|
|
45588
|
+
perDocTerms.set(term, (perDocTerms.get(term) || 0) + 1);
|
|
45589
|
+
index2.df.set(term, (index2.df.get(term) || 0) + 1);
|
|
45590
|
+
}
|
|
45591
|
+
}
|
|
45592
|
+
function ingestRecord(index2, record, keyCount, analyzer) {
|
|
45593
|
+
const {
|
|
45594
|
+
i: docIdx,
|
|
45595
|
+
v,
|
|
45596
|
+
$: fields
|
|
45597
|
+
} = record;
|
|
45598
|
+
if (v !== void 0) {
|
|
45599
|
+
addField(index2, v, docIdx, analyzer);
|
|
45600
|
+
return;
|
|
45601
|
+
}
|
|
45602
|
+
if (!fields) return;
|
|
45603
|
+
for (let keyIdx = 0; keyIdx < keyCount; keyIdx++) {
|
|
45604
|
+
const value = fields[keyIdx];
|
|
45605
|
+
if (!value) continue;
|
|
45606
|
+
if (Array.isArray(value)) {
|
|
45607
|
+
for (const sub of value) addField(index2, sub.v, docIdx, analyzer);
|
|
45608
|
+
} else {
|
|
45609
|
+
addField(index2, value.v, docIdx, analyzer);
|
|
45610
|
+
}
|
|
45611
|
+
}
|
|
45612
|
+
}
|
|
45613
|
+
function buildInvertedIndex(records, keyCount, analyzer) {
|
|
45614
|
+
const index2 = {
|
|
45615
|
+
fieldCount: 0,
|
|
45616
|
+
df: /* @__PURE__ */ new Map(),
|
|
45617
|
+
docFieldCount: /* @__PURE__ */ new Map(),
|
|
45618
|
+
docTermFieldHits: /* @__PURE__ */ new Map()
|
|
45619
|
+
};
|
|
45620
|
+
for (const record of records) {
|
|
45621
|
+
ingestRecord(index2, record, keyCount, analyzer);
|
|
45622
|
+
}
|
|
45623
|
+
return index2;
|
|
45624
|
+
}
|
|
45625
|
+
function addToInvertedIndex(index2, record, keyCount, analyzer) {
|
|
45626
|
+
ingestRecord(index2, record, keyCount, analyzer);
|
|
45627
|
+
}
|
|
45628
|
+
function removeFromInvertedIndex(index2, docIdx) {
|
|
45629
|
+
const fieldCount = index2.docFieldCount.get(docIdx);
|
|
45630
|
+
if (fieldCount === void 0) return;
|
|
45631
|
+
index2.fieldCount -= fieldCount;
|
|
45632
|
+
index2.docFieldCount.delete(docIdx);
|
|
45633
|
+
const perDocTerms = index2.docTermFieldHits.get(docIdx);
|
|
45634
|
+
if (!perDocTerms) return;
|
|
45635
|
+
for (const [term, hits] of perDocTerms) {
|
|
45636
|
+
const next = (index2.df.get(term) || 0) - hits;
|
|
45637
|
+
if (next <= 0) {
|
|
45638
|
+
index2.df.delete(term);
|
|
45639
|
+
} else {
|
|
45640
|
+
index2.df.set(term, next);
|
|
45641
|
+
}
|
|
45642
|
+
}
|
|
45643
|
+
index2.docTermFieldHits.delete(docIdx);
|
|
45644
|
+
}
|
|
45645
|
+
function removeAndShiftInvertedIndex(index2, removedIndices) {
|
|
45646
|
+
if (removedIndices.length === 0) return;
|
|
45647
|
+
const sorted = Array.from(new Set(removedIndices)).sort((a, b) => a - b);
|
|
45648
|
+
for (const idx of sorted) {
|
|
45649
|
+
removeFromInvertedIndex(index2, idx);
|
|
45650
|
+
}
|
|
45651
|
+
const shift4 = (oldIdx) => {
|
|
45652
|
+
let lo = 0;
|
|
45653
|
+
let hi = sorted.length;
|
|
45654
|
+
while (lo < hi) {
|
|
45655
|
+
const mid = lo + hi >>> 1;
|
|
45656
|
+
if (sorted[mid] < oldIdx) lo = mid + 1;
|
|
45657
|
+
else hi = mid;
|
|
45658
|
+
}
|
|
45659
|
+
return oldIdx - lo;
|
|
45660
|
+
};
|
|
45661
|
+
const firstRemoved = sorted[0];
|
|
45662
|
+
const shiftedDocFieldCount = /* @__PURE__ */ new Map();
|
|
45663
|
+
for (const [oldKey, count3] of index2.docFieldCount) {
|
|
45664
|
+
shiftedDocFieldCount.set(oldKey > firstRemoved ? shift4(oldKey) : oldKey, count3);
|
|
45665
|
+
}
|
|
45666
|
+
index2.docFieldCount = shiftedDocFieldCount;
|
|
45667
|
+
const shiftedDocTermFieldHits = /* @__PURE__ */ new Map();
|
|
45668
|
+
for (const [oldKey, terms] of index2.docTermFieldHits) {
|
|
45669
|
+
shiftedDocTermFieldHits.set(oldKey > firstRemoved ? shift4(oldKey) : oldKey, terms);
|
|
45670
|
+
}
|
|
45671
|
+
index2.docTermFieldHits = shiftedDocTermFieldHits;
|
|
45672
|
+
}
|
|
45673
|
+
var Fuse = class {
|
|
45674
|
+
// Statics are assigned in entry.ts
|
|
45675
|
+
constructor(docs, options2, index2) {
|
|
45676
|
+
this.options = {
|
|
45677
|
+
...Config,
|
|
45678
|
+
...options2
|
|
45679
|
+
};
|
|
45680
|
+
if (this.options.useExtendedSearch && false) ;
|
|
45681
|
+
if (this.options.useTokenSearch && false) ;
|
|
45682
|
+
this._keyStore = new KeyStore(this.options.keys);
|
|
45683
|
+
this._docs = docs;
|
|
45684
|
+
this._myIndex = null;
|
|
45685
|
+
this._invertedIndex = null;
|
|
45686
|
+
this.setCollection(docs, index2);
|
|
45687
|
+
this._lastQuery = null;
|
|
45688
|
+
this._lastSearcher = null;
|
|
45689
|
+
}
|
|
45690
|
+
_getSearcher(query) {
|
|
45691
|
+
if (this._lastQuery === query) {
|
|
45692
|
+
return this._lastSearcher;
|
|
45693
|
+
}
|
|
45694
|
+
const opts = this._invertedIndex ? {
|
|
45695
|
+
...this.options,
|
|
45696
|
+
_invertedIndex: this._invertedIndex
|
|
45697
|
+
} : this.options;
|
|
45698
|
+
const searcher = createSearcher(query, opts);
|
|
45699
|
+
this._lastQuery = query;
|
|
45700
|
+
this._lastSearcher = searcher;
|
|
45701
|
+
return searcher;
|
|
45702
|
+
}
|
|
45703
|
+
setCollection(docs, index2) {
|
|
45704
|
+
this._docs = docs;
|
|
45705
|
+
if (index2 && !(index2 instanceof FuseIndex)) {
|
|
45706
|
+
throw new Error(INCORRECT_INDEX_TYPE);
|
|
45707
|
+
}
|
|
45708
|
+
this._myIndex = index2 || createIndex(this.options.keys, this._docs, {
|
|
45709
|
+
getFn: this.options.getFn,
|
|
45710
|
+
fieldNormWeight: this.options.fieldNormWeight
|
|
45711
|
+
});
|
|
45712
|
+
if (this.options.useTokenSearch) {
|
|
45713
|
+
const analyzer = createAnalyzer({
|
|
45714
|
+
isCaseSensitive: this.options.isCaseSensitive,
|
|
45715
|
+
ignoreDiacritics: this.options.ignoreDiacritics,
|
|
45716
|
+
tokenize: this.options.tokenize
|
|
45717
|
+
});
|
|
45718
|
+
this._invertedIndex = buildInvertedIndex(this._myIndex.records, this._myIndex.keys.length, analyzer);
|
|
45719
|
+
}
|
|
45720
|
+
this._invalidateSearcherCache();
|
|
45721
|
+
}
|
|
45722
|
+
add(doc) {
|
|
45723
|
+
if (!isDefined(doc)) {
|
|
45724
|
+
return;
|
|
45725
|
+
}
|
|
45726
|
+
this._docs.push(doc);
|
|
45727
|
+
const record = this._myIndex.add(doc, this._docs.length - 1);
|
|
45728
|
+
if (this._invertedIndex && record) {
|
|
45729
|
+
const analyzer = createAnalyzer({
|
|
45730
|
+
isCaseSensitive: this.options.isCaseSensitive,
|
|
45731
|
+
ignoreDiacritics: this.options.ignoreDiacritics,
|
|
45732
|
+
tokenize: this.options.tokenize
|
|
45733
|
+
});
|
|
45734
|
+
addToInvertedIndex(this._invertedIndex, record, this._myIndex.keys.length, analyzer);
|
|
45735
|
+
}
|
|
45736
|
+
this._invalidateSearcherCache();
|
|
45737
|
+
}
|
|
45738
|
+
remove(predicate = () => false) {
|
|
45739
|
+
const results = [];
|
|
45740
|
+
const indicesToRemove = [];
|
|
45741
|
+
for (let i = 0, len = this._docs.length; i < len; i += 1) {
|
|
45742
|
+
if (predicate(this._docs[i], i)) {
|
|
45743
|
+
results.push(this._docs[i]);
|
|
45744
|
+
indicesToRemove.push(i);
|
|
45745
|
+
}
|
|
45746
|
+
}
|
|
45747
|
+
if (indicesToRemove.length) {
|
|
45748
|
+
if (this._invertedIndex) {
|
|
45749
|
+
removeAndShiftInvertedIndex(this._invertedIndex, indicesToRemove);
|
|
45750
|
+
}
|
|
45751
|
+
const toRemove = new Set(indicesToRemove);
|
|
45752
|
+
this._docs = this._docs.filter((_, i) => !toRemove.has(i));
|
|
45753
|
+
this._myIndex.removeAll(indicesToRemove);
|
|
45754
|
+
this._invalidateSearcherCache();
|
|
45755
|
+
}
|
|
45756
|
+
return results;
|
|
45757
|
+
}
|
|
45758
|
+
removeAt(idx) {
|
|
45759
|
+
if (!Number.isInteger(idx) || idx < 0 || idx >= this._docs.length) {
|
|
45760
|
+
throw new Error(INVALID_DOC_INDEX);
|
|
45761
|
+
}
|
|
45762
|
+
if (this._invertedIndex) {
|
|
45763
|
+
removeAndShiftInvertedIndex(this._invertedIndex, [idx]);
|
|
45764
|
+
}
|
|
45765
|
+
const doc = this._docs.splice(idx, 1)[0];
|
|
45766
|
+
this._myIndex.removeAt(idx);
|
|
45767
|
+
this._invalidateSearcherCache();
|
|
45768
|
+
return doc;
|
|
45769
|
+
}
|
|
45770
|
+
_invalidateSearcherCache() {
|
|
45771
|
+
this._lastQuery = null;
|
|
45772
|
+
this._lastSearcher = null;
|
|
45773
|
+
}
|
|
45774
|
+
getIndex() {
|
|
45775
|
+
return this._myIndex;
|
|
45776
|
+
}
|
|
45777
|
+
search(query, options2) {
|
|
45778
|
+
const {
|
|
45779
|
+
limit = -1
|
|
45780
|
+
} = options2 || {};
|
|
45781
|
+
const {
|
|
45782
|
+
includeMatches,
|
|
45783
|
+
includeScore,
|
|
45784
|
+
shouldSort,
|
|
45785
|
+
sortFn,
|
|
45786
|
+
ignoreFieldNorm
|
|
45787
|
+
} = this.options;
|
|
45788
|
+
if (isString(query) && !query.trim()) {
|
|
45789
|
+
let docs = this._docs.map((item, idx) => ({
|
|
45790
|
+
item,
|
|
45791
|
+
refIndex: idx
|
|
45792
|
+
}));
|
|
45793
|
+
if (isNumber2(limit) && limit > -1) {
|
|
45794
|
+
docs = docs.slice(0, limit);
|
|
45795
|
+
}
|
|
45796
|
+
return docs;
|
|
45797
|
+
}
|
|
45798
|
+
const useHeap = isNumber2(limit) && limit > 0 && isString(query);
|
|
45799
|
+
let results;
|
|
45800
|
+
if (useHeap) {
|
|
45801
|
+
const heap = new MaxHeap(limit);
|
|
45802
|
+
if (isString(this._docs[0])) {
|
|
45803
|
+
this._searchStringList(query, {
|
|
45804
|
+
heap,
|
|
45805
|
+
ignoreFieldNorm
|
|
45806
|
+
});
|
|
45807
|
+
} else {
|
|
45808
|
+
this._searchObjectList(query, {
|
|
45809
|
+
heap,
|
|
45810
|
+
ignoreFieldNorm
|
|
45811
|
+
});
|
|
45812
|
+
}
|
|
45813
|
+
results = heap.extractSorted(sortFn);
|
|
45814
|
+
} else {
|
|
45815
|
+
results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
|
|
45816
|
+
computeScore(results, {
|
|
45817
|
+
ignoreFieldNorm
|
|
45818
|
+
});
|
|
45819
|
+
if (shouldSort) {
|
|
45820
|
+
results.sort(sortFn);
|
|
45821
|
+
}
|
|
45822
|
+
if (isNumber2(limit) && limit > -1) {
|
|
45823
|
+
results = results.slice(0, limit);
|
|
45824
|
+
}
|
|
45825
|
+
}
|
|
45826
|
+
return format(results, this._docs, {
|
|
45827
|
+
includeMatches,
|
|
45828
|
+
includeScore
|
|
45829
|
+
});
|
|
45830
|
+
}
|
|
45831
|
+
_searchStringList(query, {
|
|
45832
|
+
heap,
|
|
45833
|
+
ignoreFieldNorm
|
|
45834
|
+
} = {}) {
|
|
45835
|
+
const searcher = this._getSearcher(query);
|
|
45836
|
+
const requireAllTokens = this.options.useTokenSearch && this.options.tokenMatch === "all";
|
|
45837
|
+
const {
|
|
45838
|
+
records
|
|
45839
|
+
} = this._myIndex;
|
|
45840
|
+
const results = heap ? null : [];
|
|
45841
|
+
records.forEach(({
|
|
45842
|
+
v: text,
|
|
45843
|
+
i: idx,
|
|
45844
|
+
n: norm2
|
|
45845
|
+
}) => {
|
|
45846
|
+
if (!isDefined(text)) {
|
|
45847
|
+
return;
|
|
45848
|
+
}
|
|
45849
|
+
const searchResult = searcher.searchIn(text);
|
|
45850
|
+
if (searchResult.isMatch) {
|
|
45851
|
+
const match = {
|
|
45852
|
+
score: searchResult.score,
|
|
45853
|
+
value: text,
|
|
45854
|
+
norm: norm2,
|
|
45855
|
+
indices: searchResult.indices
|
|
45856
|
+
};
|
|
45857
|
+
if (requireAllTokens) {
|
|
45858
|
+
match.matchedMask = searchResult.matchedMask;
|
|
45859
|
+
match.matchedTerms = searchResult.matchedTerms;
|
|
45860
|
+
match.termCount = searchResult.termCount;
|
|
45861
|
+
}
|
|
45862
|
+
const matches = [match];
|
|
45863
|
+
if (!requireAllTokens || this._coversAllTokens(matches)) {
|
|
45864
|
+
const result = {
|
|
45865
|
+
item: text,
|
|
45866
|
+
idx,
|
|
45867
|
+
matches
|
|
45868
|
+
};
|
|
45869
|
+
if (heap) {
|
|
45870
|
+
result.score = computeScoreSingle(result.matches, {
|
|
45871
|
+
ignoreFieldNorm
|
|
45872
|
+
});
|
|
45873
|
+
if (heap.shouldInsert(result.score)) {
|
|
45874
|
+
heap.insert(result);
|
|
45875
|
+
}
|
|
45876
|
+
} else {
|
|
45877
|
+
results.push(result);
|
|
45878
|
+
}
|
|
45879
|
+
}
|
|
45880
|
+
}
|
|
45881
|
+
});
|
|
45882
|
+
return results;
|
|
45883
|
+
}
|
|
45884
|
+
_searchLogical(query) {
|
|
45885
|
+
const expression = parse2(query, this.options);
|
|
45886
|
+
const evaluate2 = (node, item, idx) => {
|
|
45887
|
+
if (!("children" in node)) {
|
|
45888
|
+
const {
|
|
45889
|
+
keyId,
|
|
45890
|
+
searcher
|
|
45891
|
+
} = node;
|
|
45892
|
+
let matches;
|
|
45893
|
+
if (keyId === null) {
|
|
45894
|
+
matches = [];
|
|
45895
|
+
this._myIndex.keys.forEach((key, keyIndex) => {
|
|
45896
|
+
matches.push(...this._findMatches({
|
|
45897
|
+
key,
|
|
45898
|
+
value: item[keyIndex],
|
|
45899
|
+
searcher
|
|
45900
|
+
}));
|
|
45901
|
+
});
|
|
45902
|
+
} else {
|
|
45903
|
+
matches = this._findMatches({
|
|
45904
|
+
key: this._keyStore.get(keyId),
|
|
45905
|
+
value: this._myIndex.getValueForItemAtKeyId(item, keyId),
|
|
45906
|
+
searcher
|
|
45907
|
+
});
|
|
45908
|
+
}
|
|
45909
|
+
if (matches && matches.length) {
|
|
45910
|
+
return [{
|
|
45911
|
+
idx,
|
|
45912
|
+
item,
|
|
45913
|
+
matches
|
|
45914
|
+
}];
|
|
45915
|
+
}
|
|
45916
|
+
return [];
|
|
45917
|
+
}
|
|
45918
|
+
const {
|
|
45919
|
+
children,
|
|
45920
|
+
operator
|
|
45921
|
+
} = node;
|
|
45922
|
+
const res = [];
|
|
45923
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
45924
|
+
const child = children[i];
|
|
45925
|
+
const result = evaluate2(child, item, idx);
|
|
45926
|
+
if (result.length) {
|
|
45927
|
+
res.push(...result);
|
|
45928
|
+
} else if (operator === LogicalOperator.AND) {
|
|
45929
|
+
return [];
|
|
45930
|
+
}
|
|
45931
|
+
}
|
|
45932
|
+
return res;
|
|
45933
|
+
};
|
|
45934
|
+
const records = this._myIndex.records;
|
|
45935
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
45936
|
+
const results = [];
|
|
45937
|
+
records.forEach(({
|
|
45938
|
+
$: item,
|
|
45939
|
+
i: idx
|
|
45940
|
+
}) => {
|
|
45941
|
+
if (isDefined(item)) {
|
|
45942
|
+
const expResults = evaluate2(expression, item, idx);
|
|
45943
|
+
if (expResults.length) {
|
|
45944
|
+
if (!resultMap.has(idx)) {
|
|
45945
|
+
resultMap.set(idx, {
|
|
45946
|
+
idx,
|
|
45947
|
+
item,
|
|
45948
|
+
matches: []
|
|
45949
|
+
});
|
|
45950
|
+
results.push(resultMap.get(idx));
|
|
45951
|
+
}
|
|
45952
|
+
expResults.forEach(({
|
|
45953
|
+
matches
|
|
45954
|
+
}) => {
|
|
45955
|
+
resultMap.get(idx).matches.push(...matches);
|
|
45956
|
+
});
|
|
45957
|
+
}
|
|
45958
|
+
}
|
|
45959
|
+
});
|
|
45960
|
+
return results;
|
|
45961
|
+
}
|
|
45962
|
+
// When a search involves inverse patterns (e.g. !Syrup), the aggregation
|
|
45963
|
+
// across keys switches from "ANY key matches" to "ALL keys must match."
|
|
45964
|
+
// This is signaled by hasInverse on the SearchResult from ExtendedSearch.
|
|
45965
|
+
//
|
|
45966
|
+
// For mixed patterns like "^hello !Syrup", a key failure is ambiguous —
|
|
45967
|
+
// it could be the positive or inverse term that failed. In that case we
|
|
45968
|
+
// conservatively exclude the item, which is strictly better than the old
|
|
45969
|
+
// behavior of including it. See: https://github.com/krisk/Fuse/issues/712
|
|
45970
|
+
_searchObjectList(query, {
|
|
45971
|
+
heap,
|
|
45972
|
+
ignoreFieldNorm
|
|
45973
|
+
} = {}) {
|
|
45974
|
+
const searcher = this._getSearcher(query);
|
|
45975
|
+
const requireAllTokens = this.options.useTokenSearch && this.options.tokenMatch === "all";
|
|
45976
|
+
const {
|
|
45977
|
+
keys,
|
|
45978
|
+
records
|
|
45979
|
+
} = this._myIndex;
|
|
45980
|
+
const results = heap ? null : [];
|
|
45981
|
+
records.forEach(({
|
|
45982
|
+
$: item,
|
|
45983
|
+
i: idx
|
|
45984
|
+
}) => {
|
|
45985
|
+
if (!isDefined(item)) {
|
|
45986
|
+
return;
|
|
45987
|
+
}
|
|
45988
|
+
const matches = [];
|
|
45989
|
+
let anyKeyFailed = false;
|
|
45990
|
+
let hasInverse = false;
|
|
45991
|
+
keys.forEach((key, keyIndex) => {
|
|
45992
|
+
const keyMatches = this._findMatches({
|
|
45993
|
+
key,
|
|
45994
|
+
value: item[keyIndex],
|
|
45995
|
+
searcher
|
|
45996
|
+
});
|
|
45997
|
+
if (keyMatches.length) {
|
|
45998
|
+
matches.push(...keyMatches);
|
|
45999
|
+
if (keyMatches[0].hasInverse) {
|
|
46000
|
+
hasInverse = true;
|
|
46001
|
+
}
|
|
46002
|
+
} else {
|
|
46003
|
+
anyKeyFailed = true;
|
|
46004
|
+
}
|
|
46005
|
+
});
|
|
46006
|
+
if (hasInverse && anyKeyFailed) {
|
|
46007
|
+
return;
|
|
46008
|
+
}
|
|
46009
|
+
if (matches.length && (!requireAllTokens || this._coversAllTokens(matches))) {
|
|
46010
|
+
const result = {
|
|
46011
|
+
idx,
|
|
46012
|
+
item,
|
|
46013
|
+
matches
|
|
46014
|
+
};
|
|
46015
|
+
if (heap) {
|
|
46016
|
+
result.score = computeScoreSingle(result.matches, {
|
|
46017
|
+
ignoreFieldNorm
|
|
46018
|
+
});
|
|
46019
|
+
if (heap.shouldInsert(result.score)) {
|
|
46020
|
+
heap.insert(result);
|
|
46021
|
+
}
|
|
46022
|
+
} else {
|
|
46023
|
+
results.push(result);
|
|
46024
|
+
}
|
|
46025
|
+
}
|
|
46026
|
+
});
|
|
46027
|
+
return results;
|
|
46028
|
+
}
|
|
46029
|
+
_findMatches({
|
|
46030
|
+
key,
|
|
46031
|
+
value,
|
|
46032
|
+
searcher
|
|
46033
|
+
}) {
|
|
46034
|
+
if (!isDefined(value)) {
|
|
46035
|
+
return [];
|
|
46036
|
+
}
|
|
46037
|
+
const matches = [];
|
|
46038
|
+
if (isArray(value)) {
|
|
46039
|
+
value.forEach(({
|
|
46040
|
+
v: text,
|
|
46041
|
+
i: idx,
|
|
46042
|
+
n: norm2
|
|
46043
|
+
}) => {
|
|
46044
|
+
if (!isDefined(text)) {
|
|
46045
|
+
return;
|
|
46046
|
+
}
|
|
46047
|
+
const searchResult = searcher.searchIn(text);
|
|
46048
|
+
if (searchResult.isMatch) {
|
|
46049
|
+
const match = {
|
|
46050
|
+
score: searchResult.score,
|
|
46051
|
+
key,
|
|
46052
|
+
value: text,
|
|
46053
|
+
idx,
|
|
46054
|
+
norm: norm2,
|
|
46055
|
+
indices: searchResult.indices,
|
|
46056
|
+
hasInverse: searchResult.hasInverse
|
|
46057
|
+
};
|
|
46058
|
+
if (searchResult.termCount !== void 0) {
|
|
46059
|
+
match.matchedMask = searchResult.matchedMask;
|
|
46060
|
+
match.matchedTerms = searchResult.matchedTerms;
|
|
46061
|
+
match.termCount = searchResult.termCount;
|
|
46062
|
+
}
|
|
46063
|
+
matches.push(match);
|
|
46064
|
+
}
|
|
46065
|
+
});
|
|
46066
|
+
} else {
|
|
46067
|
+
const {
|
|
46068
|
+
v: text,
|
|
46069
|
+
n: norm2
|
|
46070
|
+
} = value;
|
|
46071
|
+
const searchResult = searcher.searchIn(text);
|
|
46072
|
+
if (searchResult.isMatch) {
|
|
46073
|
+
const match = {
|
|
46074
|
+
score: searchResult.score,
|
|
46075
|
+
key,
|
|
46076
|
+
value: text,
|
|
46077
|
+
norm: norm2,
|
|
46078
|
+
indices: searchResult.indices,
|
|
46079
|
+
hasInverse: searchResult.hasInverse
|
|
46080
|
+
};
|
|
46081
|
+
if (searchResult.termCount !== void 0) {
|
|
46082
|
+
match.matchedMask = searchResult.matchedMask;
|
|
46083
|
+
match.matchedTerms = searchResult.matchedTerms;
|
|
46084
|
+
match.termCount = searchResult.termCount;
|
|
46085
|
+
}
|
|
46086
|
+
matches.push(match);
|
|
46087
|
+
}
|
|
46088
|
+
}
|
|
46089
|
+
return matches;
|
|
46090
|
+
}
|
|
46091
|
+
// Record-level AND gate for token search (`tokenMatch: 'all'`). Returns true
|
|
46092
|
+
// unless the matched terms across ALL of a record's field/array-element
|
|
46093
|
+
// matches fail to cover every query term. `termCount` is only set by
|
|
46094
|
+
// TokenSearch in 'all' mode, so non-token / 'any' searches always pass.
|
|
46095
|
+
_coversAllTokens(matches) {
|
|
46096
|
+
const termCount = matches.length ? matches[0].termCount : void 0;
|
|
46097
|
+
if (termCount === void 0) {
|
|
46098
|
+
return true;
|
|
46099
|
+
}
|
|
46100
|
+
if (termCount <= MAX_MASK_TERMS) {
|
|
46101
|
+
let coverage2 = 0;
|
|
46102
|
+
for (let i = 0; i < matches.length; i++) {
|
|
46103
|
+
coverage2 |= matches[i].matchedMask || 0;
|
|
46104
|
+
}
|
|
46105
|
+
return coverage2 === 2 ** termCount - 1;
|
|
46106
|
+
}
|
|
46107
|
+
const coverage = /* @__PURE__ */ new Set();
|
|
46108
|
+
for (let i = 0; i < matches.length; i++) {
|
|
46109
|
+
const terms = matches[i].matchedTerms;
|
|
46110
|
+
if (terms) {
|
|
46111
|
+
for (const t12 of terms) {
|
|
46112
|
+
coverage.add(t12);
|
|
46113
|
+
}
|
|
46114
|
+
}
|
|
46115
|
+
}
|
|
46116
|
+
return coverage.size === termCount;
|
|
46117
|
+
}
|
|
46118
|
+
};
|
|
46119
|
+
Fuse.version = "7.4.0";
|
|
46120
|
+
Fuse.createIndex = createIndex;
|
|
46121
|
+
Fuse.parseIndex = parseIndex;
|
|
46122
|
+
Fuse.config = Config;
|
|
46123
|
+
Fuse.match = function(pattern, text, options2) {
|
|
46124
|
+
if (options2 && options2.useTokenSearch) {
|
|
46125
|
+
throw new Error(FUSE_MATCH_TOKEN_SEARCH_UNSUPPORTED);
|
|
46126
|
+
}
|
|
46127
|
+
const searcher = createSearcher(pattern, {
|
|
46128
|
+
...Config,
|
|
46129
|
+
...options2
|
|
46130
|
+
});
|
|
46131
|
+
return searcher.searchIn(text);
|
|
46132
|
+
};
|
|
46133
|
+
{
|
|
46134
|
+
Fuse.parseQuery = parse2;
|
|
46135
|
+
}
|
|
46136
|
+
{
|
|
46137
|
+
register(ExtendedSearch);
|
|
46138
|
+
}
|
|
46139
|
+
{
|
|
46140
|
+
register(TokenSearch);
|
|
46141
|
+
}
|
|
46142
|
+
Fuse.use = function(...plugins) {
|
|
46143
|
+
plugins.forEach((plugin) => register(plugin));
|
|
46144
|
+
};
|
|
44149
46145
|
var sides = ["top", "right", "bottom", "left"];
|
|
44150
46146
|
var min = Math.min;
|
|
44151
46147
|
var max = Math.max;
|
|
@@ -47044,10 +49040,10 @@ var SelectTrigger = React35.forwardRef(
|
|
|
47044
49040
|
const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
|
|
47045
49041
|
const getItems = useCollection(__scopeSelect);
|
|
47046
49042
|
const pointerTypeRef = React35.useRef("touch");
|
|
47047
|
-
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((
|
|
49043
|
+
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search2) => {
|
|
47048
49044
|
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
47049
49045
|
const currentItem = enabledItems.find((item) => item.value === context.value);
|
|
47050
|
-
const nextItem = findNextItem(enabledItems,
|
|
49046
|
+
const nextItem = findNextItem(enabledItems, search2, currentItem);
|
|
47051
49047
|
if (nextItem !== void 0) {
|
|
47052
49048
|
context.onValueChange(nextItem.value);
|
|
47053
49049
|
}
|
|
@@ -47274,10 +49270,10 @@ var SelectContentImpl = React35.forwardRef(
|
|
|
47274
49270
|
window.removeEventListener("resize", close);
|
|
47275
49271
|
};
|
|
47276
49272
|
}, [onOpenChange]);
|
|
47277
|
-
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((
|
|
49273
|
+
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search2) => {
|
|
47278
49274
|
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
47279
49275
|
const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
|
|
47280
|
-
const nextItem = findNextItem(enabledItems,
|
|
49276
|
+
const nextItem = findNextItem(enabledItems, search2, currentItem);
|
|
47281
49277
|
if (nextItem) {
|
|
47282
49278
|
setTimeout(() => nextItem.ref.current.focus());
|
|
47283
49279
|
}
|
|
@@ -48006,13 +50002,13 @@ function useTypeaheadSearch(onSearchChange) {
|
|
|
48006
50002
|
const timerRef = React35.useRef(0);
|
|
48007
50003
|
const handleTypeaheadSearch = React35.useCallback(
|
|
48008
50004
|
(key) => {
|
|
48009
|
-
const
|
|
48010
|
-
handleSearchChange(
|
|
50005
|
+
const search2 = searchRef.current + key;
|
|
50006
|
+
handleSearchChange(search2);
|
|
48011
50007
|
(function updateSearch(value) {
|
|
48012
50008
|
searchRef.current = value;
|
|
48013
50009
|
window.clearTimeout(timerRef.current);
|
|
48014
50010
|
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
48015
|
-
})(
|
|
50011
|
+
})(search2);
|
|
48016
50012
|
},
|
|
48017
50013
|
[handleSearchChange]
|
|
48018
50014
|
);
|
|
@@ -48025,9 +50021,9 @@ function useTypeaheadSearch(onSearchChange) {
|
|
|
48025
50021
|
}, []);
|
|
48026
50022
|
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
|
48027
50023
|
}
|
|
48028
|
-
function findNextItem(items,
|
|
48029
|
-
const isRepeated =
|
|
48030
|
-
const normalizedSearch = isRepeated ?
|
|
50024
|
+
function findNextItem(items, search2, currentItem) {
|
|
50025
|
+
const isRepeated = search2.length > 1 && Array.from(search2).every((char) => char === search2[0]);
|
|
50026
|
+
const normalizedSearch = isRepeated ? search2[0] : search2;
|
|
48031
50027
|
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
48032
50028
|
let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
|
|
48033
50029
|
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
@@ -58054,13 +60050,25 @@ function TokenSelectorSheet({
|
|
|
58054
60050
|
});
|
|
58055
60051
|
setRecentTokens(updated);
|
|
58056
60052
|
};
|
|
60053
|
+
const fuse = (0, import_react21.useMemo)(
|
|
60054
|
+
() => new Fuse(allOptions, {
|
|
60055
|
+
keys: [
|
|
60056
|
+
{ name: "token.symbol", weight: 2 },
|
|
60057
|
+
{ name: "token.name", weight: 1 },
|
|
60058
|
+
{ name: "chain.chain_name", weight: 0.5 }
|
|
60059
|
+
],
|
|
60060
|
+
threshold: 0.2,
|
|
60061
|
+
ignoreLocation: true,
|
|
60062
|
+
minMatchCharLength: 2
|
|
60063
|
+
}),
|
|
60064
|
+
[allOptions]
|
|
60065
|
+
);
|
|
58057
60066
|
const filteredOptions = (0, import_react21.useMemo)(() => {
|
|
58058
60067
|
if (!searchQuery.trim()) return allOptions;
|
|
58059
|
-
const query = searchQuery.
|
|
58060
|
-
|
|
58061
|
-
|
|
58062
|
-
|
|
58063
|
-
}, [allOptions, searchQuery]);
|
|
60068
|
+
const query = searchQuery.trim();
|
|
60069
|
+
const results = fuse.search(query);
|
|
60070
|
+
return results.map((r2) => r2.item);
|
|
60071
|
+
}, [fuse, allOptions, searchQuery]);
|
|
58064
60072
|
const isCommonToken = (symbol, chainType, chainId) => {
|
|
58065
60073
|
return COMMON_TOKENS.some(
|
|
58066
60074
|
(ct) => ct.symbol === symbol && ct.chainType === chainType && ct.chainId === chainId
|
|
@@ -61703,6 +63711,7 @@ function DepositModal({
|
|
|
61703
63711
|
enableConnectWallet = false,
|
|
61704
63712
|
browserWalletAmountQuickSelect = "percentage",
|
|
61705
63713
|
enablePayWithExchange,
|
|
63714
|
+
enableFiatOnramp,
|
|
61706
63715
|
enableConnectExchange = false,
|
|
61707
63716
|
enableCashApp = false,
|
|
61708
63717
|
hideDepositFlowInfo = false,
|
|
@@ -61724,8 +63733,9 @@ function DepositModal({
|
|
|
61724
63733
|
const s = initialScreen ?? "main";
|
|
61725
63734
|
if (s === "tracker" && hideDepositTracker) return "main";
|
|
61726
63735
|
if (s === "cashapp" && !enableCashApp) return "main";
|
|
63736
|
+
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
61727
63737
|
return s;
|
|
61728
|
-
}, [initialScreen, hideDepositTracker, enableCashApp]);
|
|
63738
|
+
}, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
|
|
61729
63739
|
const [containerEl, setContainerEl] = (0, import_react3.useState)(null);
|
|
61730
63740
|
const containerCallbackRef = (0, import_react3.useCallback)((el) => {
|
|
61731
63741
|
setContainerEl(el);
|
|
@@ -61841,6 +63851,13 @@ function DepositModal({
|
|
|
61841
63851
|
enabled: open
|
|
61842
63852
|
});
|
|
61843
63853
|
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
63854
|
+
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
63855
|
+
(0, import_react3.useEffect)(() => {
|
|
63856
|
+
if (view === "card" && !showFiatOnramp) {
|
|
63857
|
+
setView("main");
|
|
63858
|
+
setCardView("amount");
|
|
63859
|
+
}
|
|
63860
|
+
}, [view, showFiatOnramp]);
|
|
61844
63861
|
const { exchanges, isLoading: exchangesLoading } = useExchanges({
|
|
61845
63862
|
publishableKey,
|
|
61846
63863
|
enabled: open && showPayWithExchange
|
|
@@ -62150,7 +64167,7 @@ function DepositModal({
|
|
|
62150
64167
|
featuredWallets: projectConfig?.connect_wallet?.wallets
|
|
62151
64168
|
}
|
|
62152
64169
|
),
|
|
62153
|
-
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64170
|
+
showFiatOnramp && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
62154
64171
|
DepositWithCardButton,
|
|
62155
64172
|
{
|
|
62156
64173
|
onClick: () => setView("card"),
|
|
@@ -65149,6 +67166,7 @@ function UnifoldProvider2({
|
|
|
65149
67166
|
transferInputVariant: config?.transferInputVariant,
|
|
65150
67167
|
enableConnectWallet: config?.enableConnectWallet,
|
|
65151
67168
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
67169
|
+
enableFiatOnramp: config?.enableFiatOnramp,
|
|
65152
67170
|
enableConnectExchange: config?.enableConnectExchange,
|
|
65153
67171
|
enableCashApp: config?.enableCashApp,
|
|
65154
67172
|
onDepositSuccess: handleDepositSuccess,
|
|
@@ -65268,7 +67286,11 @@ function createUnifold(publishableKey, config) {
|
|
|
65268
67286
|
return resolvedHandle.beginWithdraw(withdrawConfig);
|
|
65269
67287
|
},
|
|
65270
67288
|
closeWithdraw: () => resolvedHandle?.closeWithdraw(),
|
|
65271
|
-
destroy:
|
|
67289
|
+
destroy: () => {
|
|
67290
|
+
resolvedHandle?.closeDeposit();
|
|
67291
|
+
resolvedHandle?.closeWithdraw();
|
|
67292
|
+
cleanup();
|
|
67293
|
+
}
|
|
65272
67294
|
};
|
|
65273
67295
|
const refCallback = (handle) => {
|
|
65274
67296
|
if (handle) {
|