decord/source/modules/autocompleter/native/useMentionAnchor.tsx

151 lines
4.2 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 11612
// Function ID: 11613
2026-07-29 08:29:29 +00:00
// Name: useMentionAnchor
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 19, 10215, 2]
2026-07-24 07:16:23 +00:00
// Exports: default
2026-08-24 06:08:38 +00:00
// Module 11612 (useMentionAnchor)
import closure_2 from "_slicedToArray" /* 32 */;
import closure_3 from "noop" /* 19 */;
2026-07-24 07:16:23 +00:00
const require = arg1;
2026-07-30 10:14:41 +00:00
let closure_4 = { kind: "idle" };
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/autocompleter/native/useMentionAnchor.tsx");
2026-07-29 08:29:29 +00:00
2026-07-30 10:14:41 +00:00
export default function useMentionAnchor(c22) {
const _require = arg2;
2026-07-29 08:29:29 +00:00
let obj = React;
2026-07-30 10:14:41 +00:00
let tmp = closure_4;
[anchor, tmp3] = callback(React.useState(closure_4), 2);
2026-08-24 06:08:38 +00:00
dependencyMap = tmp3;
2026-07-30 10:14:41 +00:00
anchor = null;
if ("idle" !== anchor.kind) {
anchor = anchor.anchor;
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
let tmp5 = arg2;
if (arg2) {
2026-07-29 08:29:29 +00:00
let startsWithResult = null != anchor;
if (startsWithResult) {
startsWithResult = anchor >= 0;
}
if (startsWithResult) {
2026-07-30 10:14:41 +00:00
startsWithResult = c22.startsWith(arg3, anchor);
2026-07-29 08:29:29 +00:00
}
if (startsWithResult) {
2026-07-30 10:14:41 +00:00
startsWithResult = arg1 >= anchor + arg3.length;
2026-07-29 08:29:29 +00:00
}
if (startsWithResult) {
2026-08-24 06:08:38 +00:00
obj1 = _require(10215);
2026-07-30 10:14:41 +00:00
startsWithResult = obj1.isUnbrokenRun(c22, anchor + arg3.length, arg1);
2026-07-29 08:29:29 +00:00
}
tmp5 = startsWithResult;
2026-07-24 07:16:23 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp9 = null;
if (tmp5) {
tmp9 = anchor;
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
let tmp10 = tmp;
if (arg2) {
const kind = anchor.kind;
2026-07-24 07:16:23 +00:00
if ("idle" === kind) {
2026-07-30 10:14:41 +00:00
const lastIndexOfResult = c22.lastIndexOf(arg3, arg1);
let tmp16 = null;
2026-07-24 07:16:23 +00:00
if (-1 !== lastIndexOfResult) {
2026-07-30 10:14:41 +00:00
let tmp18 = null;
if (obj9.isWhitespaceSeparatingBoundary(c22, lastIndexOfResult)) {
2026-07-29 08:29:29 +00:00
let startsWithResult1 = null != lastIndexOfResult;
if (startsWithResult1) {
startsWithResult1 = lastIndexOfResult >= 0;
}
if (startsWithResult1) {
2026-07-30 10:14:41 +00:00
startsWithResult1 = c22.startsWith(arg3, lastIndexOfResult);
2026-07-29 08:29:29 +00:00
}
if (startsWithResult1) {
2026-07-30 10:14:41 +00:00
startsWithResult1 = arg1 >= lastIndexOfResult + arg3.length;
2026-07-29 08:29:29 +00:00
}
if (startsWithResult1) {
2026-08-24 06:08:38 +00:00
startsWithResult1 = tmp25(10215).isUnbrokenRun(c22, lastIndexOfResult + arg3.length, arg1);
const tmp25Result = tmp25(10215);
2026-07-29 08:29:29 +00:00
}
2026-07-30 10:14:41 +00:00
tmp18 = null;
2026-07-29 08:29:29 +00:00
if (startsWithResult1) {
2026-07-30 10:14:41 +00:00
tmp18 = lastIndexOfResult;
2026-07-24 07:16:23 +00:00
}
}
2026-07-30 10:14:41 +00:00
tmp16 = tmp18;
2026-08-24 06:08:38 +00:00
obj9 = _require(10215);
2026-07-30 10:14:41 +00:00
tmp25 = _require;
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
if (null != tmp16) {
2026-07-29 08:29:29 +00:00
obj = { kind: "pending", anchor: null, seenText: null };
2026-07-30 10:14:41 +00:00
obj[1] = tmp16;
tmp = obj;
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
tmp10 = tmp;
2026-07-24 07:16:23 +00:00
} else if ("active" === kind) {
2026-07-30 10:14:41 +00:00
let tmp14 = tmp;
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-07-30 10:14:41 +00:00
tmp14 = anchor;
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
tmp10 = tmp14;
2026-07-24 07:16:23 +00:00
} else if ("pending" === kind) {
2026-07-30 10:14:41 +00:00
({ anchor: anchor2, seenText } = anchor);
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-07-30 10:14:41 +00:00
obj = { kind: "active", anchor: null };
obj[1] = anchor2;
let tmp11 = obj;
} else if (c22.startsWith(arg3, anchor2)) {
obj1 = { kind: "pending", anchor: null, seenText: null };
obj1[1] = anchor2;
tmp11 = obj1;
2026-07-29 08:29:29 +00:00
} else {
2026-07-30 10:14:41 +00:00
tmp11 = tmp;
if (anchor2 <= c22.length) {
if (null == seenText) {
const obj2 = { kind: "pending", anchor: null, seenText: null };
obj2[1] = anchor2;
obj2[2] = c22;
let tmp12 = obj2;
} else {
tmp12 = anchor;
if (seenText !== c22) {
tmp12 = tmp;
}
}
2026-07-29 08:29:29 +00:00
}
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
tmp10 = tmp11;
2026-07-24 07:16:23 +00:00
}
}
2026-07-30 10:14:41 +00:00
let tmp19 = anchor.kind === tmp10.kind;
if (tmp19) {
if ("idle" === anchor.kind) {
tmp19 = tmp20;
} else if ("active" === anchor.kind) {
let tmp22 = "active" === tmp10.kind;
if (tmp22) {
anchor = tmp10.anchor;
tmp22 = anchor.anchor === anchor;
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
let tmp21 = tmp22;
} else {
tmp21 = "pending" === tmp10.kind && anchor.anchor === tmp10.anchor && anchor.seenText === tmp10.seenText;
2026-07-24 07:16:23 +00:00
}
2026-07-29 08:29:29 +00:00
}
2026-07-30 10:14:41 +00:00
if (!tmp19) {
tmp3(tmp10);
2026-07-24 07:16:23 +00:00
}
2026-07-30 10:14:41 +00:00
const tmp2 = callback(React.useState(closure_4), 2);
const items = [arg2];
2026-07-29 08:29:29 +00:00
return {
anchor: tmp9,
beginSearch: obj.useCallback((arg0) => {
2026-07-30 10:14:41 +00:00
if (closure_0) {
const obj = { kind: "pending", anchor: null, seenText: null };
2026-07-29 08:29:29 +00:00
obj[1] = arg0;
tmp3 = tmp3(obj);
}
2026-07-30 10:14:41 +00:00
}, items)
2026-07-29 08:29:29 +00:00
};
2026-07-24 07:16:23 +00:00
};