@aintela/chat 0.4.29 → 0.4.31
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/components.js +2868 -2852
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +7 -6
- package/dist/index.js +77 -76
- package/dist/{predictionRows-CtyrlEUr.js → predictionRows-Cn0gzEx3.js} +15 -13
- package/dist/{predictionRows-CtyrlEUr.js.map → predictionRows-Cn0gzEx3.js.map} +1 -1
- package/dist/src/hooks/index.d.ts +1 -1
- package/dist/src/hooks/usePromptAssist.d.ts +8 -0
- package/dist/src/utils/swallowNextClick.d.ts +12 -1
- package/dist/src/utils/swallowNextClick.test.d.ts +1 -0
- package/dist/useContainerWidth-C33sJaCi.js +383 -0
- package/dist/useContainerWidth-C33sJaCi.js.map +1 -0
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/useContainerWidth-pE_-xmTN.js +0 -342
- package/dist/useContainerWidth-pE_-xmTN.js.map +0 -1
|
@@ -2,5 +2,5 @@ export { default as useInterval } from './useIntervalHook';
|
|
|
2
2
|
export { useContainerRectangle } from './useContainerWidth';
|
|
3
3
|
export { useChatSessions } from './useChatSessions';
|
|
4
4
|
export type { UseChatSessionsOptions, UseChatSessionsResult, ChatSessionListItem, ChatSessionGroup, } from './useChatSessions';
|
|
5
|
-
export { usePromptAssist } from './usePromptAssist';
|
|
5
|
+
export { slotDatesFor, usePromptAssist } from './usePromptAssist';
|
|
6
6
|
export type { PredictionItem, ResolvedDateItem, PromptAssistAdapter, PromptAssistFetchers, PromptAssistOptions, AssistOutcome, SearchVertical, } from './usePromptAssist';
|
|
@@ -43,6 +43,14 @@ export type ResolvedDateItem = {
|
|
|
43
43
|
text: string;
|
|
44
44
|
display: string;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* The Data rows an `@` picker should still carry once the user has typed `query` after the `@` (Issue 1362).
|
|
48
|
+
* `slotDateOptions` is computed when the picker opens and never looks at the query, so at a mixed caret typing
|
|
49
|
+
* "flori" kept every date on top and pushed the matching places under them. A quick date stays while the query is a
|
|
50
|
+
* word-prefix of its label; the calendar row stays while the query is empty, starts with a digit, or is the start of
|
|
51
|
+
* a date word. Nothing left ⇒ `[]`, and the places lead. Hosts splice the result above their `@` rows.
|
|
52
|
+
*/
|
|
53
|
+
export declare function slotDatesFor(options: SlotDateOption[], query: string): SlotDateOption[];
|
|
46
54
|
/**
|
|
47
55
|
* Send-time summary of what the assist UI did during ONE composition (issue #159 Phase 1) — attached to the
|
|
48
56
|
* commit so the server can store {prompt, outcome} as a behavioral label and emit gate-precision metrics:
|
|
@@ -12,5 +12,16 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Capture phase, so it never reaches the target (or a document-level away-listener); self-removing,
|
|
14
14
|
* and time-boxed in case no click arrives at all (the browser is not obliged to send one).
|
|
15
|
+
*
|
|
16
|
+
* `mousedown: true` eats the gesture's compatibility `mousedown` as well. Pass it when you act on
|
|
17
|
+
* `pointerUP`: that mousedown arrives after your handler has already re-rendered, and its default
|
|
18
|
+
* action — move focus, place the caret — lands on whatever is under the finger NOW. On Android that
|
|
19
|
+
* is how a `/`-template pick lost its caret: the pick put the caret after the template's `@` and
|
|
20
|
+
* opened the docked `@` panel in the spot the command list had just vacated, and the tap's mousedown
|
|
21
|
+
* then hit that panel, blurring the textarea (keyboard down, caret gone), or hit the textarea itself
|
|
22
|
+
* and re-homed the caret to the tap point. iOS never showed it — WebKit does not move focus to a
|
|
23
|
+
* non-focusable element on tap. A new `pointerdown` disarms it, so a genuine next tap is never eaten.
|
|
15
24
|
*/
|
|
16
|
-
export declare function swallowNextClick(
|
|
25
|
+
export declare function swallowNextClick(options?: {
|
|
26
|
+
mousedown?: boolean;
|
|
27
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
var Et = Object.defineProperty;
|
|
2
|
+
var p = (r, m) => Et(r, "name", { value: m, configurable: !0 });
|
|
3
|
+
import { useState as l, useRef as i, useCallback as A, useEffect as de } from "react";
|
|
4
|
+
const Ue = /* @__PURE__ */ p((r) => r.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), "foldForCompare"), Be = /* @__PURE__ */ p((r) => r.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").toLowerCase().replace(/\s+/g, " ").trim(), "fold"), Pt = [
|
|
5
|
+
"hoje",
|
|
6
|
+
"amanha",
|
|
7
|
+
"depois",
|
|
8
|
+
"dia",
|
|
9
|
+
"semana",
|
|
10
|
+
"proxima",
|
|
11
|
+
"proximo",
|
|
12
|
+
"fim",
|
|
13
|
+
"feriado",
|
|
14
|
+
"manha",
|
|
15
|
+
"tarde",
|
|
16
|
+
"noite",
|
|
17
|
+
"segunda",
|
|
18
|
+
"terca",
|
|
19
|
+
"quarta",
|
|
20
|
+
"quinta",
|
|
21
|
+
"sexta",
|
|
22
|
+
"sabado",
|
|
23
|
+
"domingo",
|
|
24
|
+
"janeiro",
|
|
25
|
+
"fevereiro",
|
|
26
|
+
"marco",
|
|
27
|
+
"abril",
|
|
28
|
+
"maio",
|
|
29
|
+
"junho",
|
|
30
|
+
"julho",
|
|
31
|
+
"agosto",
|
|
32
|
+
"setembro",
|
|
33
|
+
"outubro",
|
|
34
|
+
"novembro",
|
|
35
|
+
"dezembro"
|
|
36
|
+
];
|
|
37
|
+
function Ot(r, m) {
|
|
38
|
+
const x = Be(m);
|
|
39
|
+
if (x === "" || r.length === 0) return r;
|
|
40
|
+
const v = r.filter((c) => c.kind === "date" && ` ${Be(c.label)}`.includes(` ${x}`)), C = /^\d/.test(x) || v.length > 0 || Pt.some((c) => c.startsWith(x.split(" ")[0]));
|
|
41
|
+
return r.filter((c) => c.kind === "calendar" ? C : v.includes(c));
|
|
42
|
+
}
|
|
43
|
+
p(Ot, "slotDatesFor");
|
|
44
|
+
const Qe = /* @__PURE__ */ p((r) => r.vertical ?? (Ee(r) ? "hotel" : "air"), "verticalOf"), Ee = /* @__PURE__ */ p((r) => r.placesExpected ?? r.hotelExpected ?? !1, "lodgingOf"), Ve = /* @__PURE__ */ p((r) => r.placesConfidence ?? r.hotelConfidence ?? 0, "lodgingScoreOf"), Ht = /* @__PURE__ */ p((r) => r === "hotel" ? "Hotéis e locais" : r === "air" ? "Aeroportos" : void 0, "sectionLabel"), Se = "Data", Xe = "Localização", Ae = /* @__PURE__ */ p(() => ({
|
|
45
|
+
maxLocationConfidence: 0,
|
|
46
|
+
maxPersonConfidence: 0,
|
|
47
|
+
maxHotelConfidence: 0,
|
|
48
|
+
locationGateFired: !1,
|
|
49
|
+
suggestionAccepted: !1,
|
|
50
|
+
ghostShown: !1,
|
|
51
|
+
ghostAccepted: !1,
|
|
52
|
+
atOpened: !1,
|
|
53
|
+
atAccepted: null,
|
|
54
|
+
manualAt: !1
|
|
55
|
+
}), "emptyOutcome"), Ze = /* @__PURE__ */ p(() => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`, "newSessionId"), Je = /* @__PURE__ */ p((r, m, x) => {
|
|
56
|
+
var c;
|
|
57
|
+
const v = r.length;
|
|
58
|
+
let C = m;
|
|
59
|
+
for (let $ = 0; $ < v; $++)
|
|
60
|
+
if (C = (C + x + v) % v, !((c = r[C]) != null && c.disabled)) return C;
|
|
61
|
+
return m;
|
|
62
|
+
}, "nextEnabledIndex");
|
|
63
|
+
function Nt(r, m, x = {}) {
|
|
64
|
+
const { debugGhostKey: v } = x, [C, c] = l(null), [$, S] = l(null), [L, z] = l(!1), [fe, U] = l(0), [Ye, et] = l(0), [tt, nt] = l(!1), [rt, ot] = l("air"), [ct, st] = l(0), [it, at] = l(!1), [lt, ut] = l(0), [dt, he] = l(!1), [ft, pe] = l(""), [ht, pt] = l([]), [ge, Pe] = l(!1), [me, G] = l(0), [gt, He] = l([]), [mt, Le] = l([]), [xt, xe] = l(""), re = i(""), B = i(null), K = i(r);
|
|
65
|
+
K.current = r;
|
|
66
|
+
const M = i(m);
|
|
67
|
+
M.current = m;
|
|
68
|
+
const Q = i(x);
|
|
69
|
+
Q.current = x;
|
|
70
|
+
const V = i(null), X = i(null), qe = i(0), Ie = i(0), Ce = i(null), oe = i(""), Z = i(null), ye = i(null), ke = i(Ze()), J = i(null);
|
|
71
|
+
J.current = C;
|
|
72
|
+
const Y = i(null);
|
|
73
|
+
Y.current = $;
|
|
74
|
+
const ee = i(0), te = i(null), W = i(!1), Ct = 8, yt = 0.5, ne = i(null), Oe = i(""), Ne = i(() => {
|
|
75
|
+
}), H = i(Ae()), q = i(!1), kt = A(() => {
|
|
76
|
+
c(null), pe("");
|
|
77
|
+
}, []), vt = A(() => {
|
|
78
|
+
He([]), Le([]), xe(""), re.current = "", Z.current = null, ke.current = Ze(), H.current = Ae(), q.current = !1, Pe(!1), ee.current = 0, te.current = null, W.current = !1, S(null);
|
|
79
|
+
}, []), ve = A((e) => {
|
|
80
|
+
if (e.disabled) return;
|
|
81
|
+
H.current.suggestionAccepted = !0, e.kind === "location" && (q.current = !0), c(null);
|
|
82
|
+
const n = K.current, o = n.getTextarea();
|
|
83
|
+
if (!o) return;
|
|
84
|
+
const y = o.selectionStart ?? o.value.length, f = o.value.slice(0, y), E = o.value.slice(y), I = e.kind === "namedLocation" || e.kind === "location";
|
|
85
|
+
let t;
|
|
86
|
+
if (I) {
|
|
87
|
+
const h = Oe.current, g = f.replace(/\s+$/, "");
|
|
88
|
+
t = h && g.endsWith(h) ? g.slice(0, g.length - h.length) : f;
|
|
89
|
+
} else {
|
|
90
|
+
const h = f.search(/\S+$/), g = h === -1 ? "" : f.slice(h);
|
|
91
|
+
t = g.length > 0 && (e.kind === "date" && e.insert ? Ue(e.insert).startsWith(Ue(g)) : /^[\d./-]+$/.test(g)) ? f.slice(0, h) : f;
|
|
92
|
+
}
|
|
93
|
+
const u = t.length > 0 && !/\s$/.test(t);
|
|
94
|
+
if (e.kind === "date") {
|
|
95
|
+
const h = Q.current.enableHashDatePicker ? "#" : "", g = `${u ? " " : ""}${h}${e.insert} `, _ = `${t}${g}${E}`;
|
|
96
|
+
n.setDraft(_), n.focusCaret(t.length + g.length), oe.current = _, Z.current = null, Ne.current();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (e.kind === "namedLocation" && e.insert) {
|
|
100
|
+
const h = `@${e.insert.replace(/ /g, " ")}`, g = `${u ? " " : ""}${h} `;
|
|
101
|
+
n.setDraft(`${t}${g}${E}`), n.focusCaret(t.length + g.length);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const d = e.kind === "location" ? "@" : "#", b = `${u ? " " : ""}${d}`;
|
|
105
|
+
n.setDraft(`${t}${b}${E}`), n.focusCaret(t.length + b.length), requestAnimationFrame(() => {
|
|
106
|
+
const h = n.getTextarea();
|
|
107
|
+
h && n.syncTrigger(h);
|
|
108
|
+
});
|
|
109
|
+
}, []), be = A(async () => {
|
|
110
|
+
var f;
|
|
111
|
+
const e = M.current.resolveDates;
|
|
112
|
+
if (!e) return;
|
|
113
|
+
const n = oe.current;
|
|
114
|
+
if (n.trim() === "") {
|
|
115
|
+
Z.current = null;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (n === Z.current || n.split(" ").length <= 2) return;
|
|
119
|
+
Z.current = n, (f = ye.current) == null || f.abort();
|
|
120
|
+
const y = new AbortController();
|
|
121
|
+
ye.current = y;
|
|
122
|
+
try {
|
|
123
|
+
const { dates: E, locations: I } = await e(n, ke.current, y.signal);
|
|
124
|
+
if (oe.current !== n) return;
|
|
125
|
+
const t = E.filter((d) => d.display).map((d) => ({ text: d.text, display: d.display }));
|
|
126
|
+
Le(t), He(I.map((d) => d.text).filter((d) => d.trim().length > 0));
|
|
127
|
+
const u = t.map((d) => `${d.text}=${d.display}`).join("|");
|
|
128
|
+
t.length > 0 && u !== re.current && (re.current = u, xe(t[t.length - 1].text), B.current != null && window.clearTimeout(B.current), B.current = window.setTimeout(() => xe(""), 2e3)), t.length === 0 && (re.current = "");
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
}, []);
|
|
132
|
+
Ne.current = be;
|
|
133
|
+
const bt = A((e, n, o) => {
|
|
134
|
+
if (oe.current = e, Y.current !== null && (ee.current += 1, ee.current >= Ct && (W.current = !0, S(null))), e.split(" ").length <= 2) return;
|
|
135
|
+
const f = M.current.analyze;
|
|
136
|
+
f && (!o || J.current !== null || Y.current !== null) && (V.current != null && window.clearTimeout(V.current), V.current = window.setTimeout(async () => {
|
|
137
|
+
var I;
|
|
138
|
+
const E = ++qe.current;
|
|
139
|
+
try {
|
|
140
|
+
const t = await f(e, n);
|
|
141
|
+
if (E !== qe.current) return;
|
|
142
|
+
const u = K.current, d = u.getTextarea();
|
|
143
|
+
if (!d || d.value !== e) return;
|
|
144
|
+
K.current.isPickerOpen() || (et(t.personConfidence ?? 0), U(t.locationConfidence ?? 0), nt(Ee(t)), ot(Qe(t)), st(Ve(t)), at(t.hotelNameExpected ?? !1), ut(t.hotelNameConfidence ?? 0));
|
|
145
|
+
const b = H.current;
|
|
146
|
+
b.maxPersonConfidence = Math.max(b.maxPersonConfidence, t.personConfidence ?? 0), b.maxLocationConfidence = Math.max(b.maxLocationConfidence, t.locationConfidence ?? 0), b.maxHotelConfidence = Math.max(b.maxHotelConfidence ?? 0, Ve(t)), S(null);
|
|
147
|
+
const h = d.selectionStart ?? n, g = h === e.length, _ = e.slice(0, h), Dt = e.slice(h), we = !g && /\s$/.test(_) && !/^\s*@/.test(Dt), ce = g || we, Re = u.hasAtQuery, se = u.isPickerOpen(), Fe = t.suggestions ?? [], { enableHashDatePicker: ie = !1, datePresets: ze = ["amanhã de manhã", "quarta-feira à noite"] } = Q.current;
|
|
148
|
+
let T = t.category === "location" ? "location" : t.category === "date" ? "date" : t.locationExpected ? "location" : t.dateExpected ? "date" : null;
|
|
149
|
+
T !== "location" && t.locationCount < 2 && M.current.suggest && J.current !== null && ne.current === "location" && ce && /\s$/.test(_) && (T = "location");
|
|
150
|
+
const Ge = t.secondary ?? "";
|
|
151
|
+
let D = ie && Re && (T === "location" && Ge === "date" || T === "date" && Ge === "location");
|
|
152
|
+
if (D && t.locationCount >= 2 && t.locationPartialEmpty && (D = !1, T = "date"), !se) {
|
|
153
|
+
const s = (t.suggestions ?? []).filter((a) => a.kind === "date").map((a) => a.value);
|
|
154
|
+
pt(D ? [
|
|
155
|
+
...ie ? [{ id: "cal", label: "# Escolher no calendário", value: "#", kind: "calendar", section: Se }] : [],
|
|
156
|
+
// "#"-prefixed, because this row REPLACES the "@" the user typed to open the picker
|
|
157
|
+
// (Issue 1190): the splice hands `value` the whole `@…` token, so a bare phrase ate the
|
|
158
|
+
// trigger and left the date wearing the wrong sigil — or none. `#` is the one the Data
|
|
159
|
+
// half of a mixed caret takes. Only reachable with the calendar wired (`mixed` requires
|
|
160
|
+
// `enableHashDatePicker`), so the character always has a picker behind it.
|
|
161
|
+
...(s.length > 0 ? s : ze).map((a) => ({ id: `date:${a}`, label: a, value: `#${a}`, kind: "date", section: Se }))
|
|
162
|
+
] : []);
|
|
163
|
+
}
|
|
164
|
+
const Te = !!(D && Q.current.promptHint && ce && !se);
|
|
165
|
+
if (Pe(Te), Te && (W.current || (te.current = "mixed", z(we), S("mixed"), b.ghostShown = !0, b.locationGateFired = !0)), Q.current.promptHint && ce && !se && !Te) {
|
|
166
|
+
const s = t.personConfidence ?? 0, a = t.locationConfidence ?? 0, P = T === "location" && !D && !(t.locationCount >= 2 && t.locationPartialEmpty), R = t.hotelNameExpected ?? !1 ? "hotelname" : Ee(t) ? "places" : "location", N = T === "date" && !D && ie, j = s >= yt && s >= a && !N ? "person" : N ? "date" : P ? R : null;
|
|
167
|
+
if (j) {
|
|
168
|
+
W.current || (te.current = j, z(we), S(j), b.ghostShown = !0, j === "location" && (b.locationGateFired = !0)), c(null), ne.current = null;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
te.current = null;
|
|
172
|
+
}
|
|
173
|
+
if (T === "location" && t.locationCount >= 2 && t.locationPartialEmpty) {
|
|
174
|
+
c(null), ne.current = null;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (T === null || !(ce && !se && (T === "location" ? Re : T === "date"))) {
|
|
178
|
+
c(null), ne.current = null;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const w = D ? "location" : T;
|
|
182
|
+
ne.current = w, w === "location" && (b.locationGateFired = !0);
|
|
183
|
+
const Ke = Fe.filter((s) => s.kind === "location"), Me = Fe.filter((s) => s.kind === "date").map((s) => s.value), ae = /* @__PURE__ */ p(({ quickDates: s }) => {
|
|
184
|
+
if (w !== "date" && !D) return [];
|
|
185
|
+
const a = D ? Se : void 0, P = [];
|
|
186
|
+
if (ie && P.push({ key: "cal", label: "# Escolher no calendário", kind: "calendar", icon: "calendar", section: a }), s)
|
|
187
|
+
for (const R of Me.length > 0 ? Me : ze)
|
|
188
|
+
P.push({ key: `date:${R}`, label: R, kind: "date", icon: "date", insert: R, section: a });
|
|
189
|
+
return P;
|
|
190
|
+
}, "dateRows"), St = /* @__PURE__ */ p((s, a) => (a ? Ht(s) : void 0) ?? (D ? Xe : void 0), "locSection"), O = [];
|
|
191
|
+
if (w === "location") {
|
|
192
|
+
O.push(...ae({ quickDates: !0 }));
|
|
193
|
+
for (const s of Ke)
|
|
194
|
+
O.push({
|
|
195
|
+
key: `loc:${s.value}`,
|
|
196
|
+
label: s.label,
|
|
197
|
+
kind: "namedLocation",
|
|
198
|
+
insert: s.value,
|
|
199
|
+
icon: "place",
|
|
200
|
+
section: D ? Xe : void 0
|
|
201
|
+
});
|
|
202
|
+
} else
|
|
203
|
+
O.push(...ae({ quickDates: !0 }));
|
|
204
|
+
const le = M.current.suggest, At = w === "location" ? Ke.length > 0 : !0;
|
|
205
|
+
if (w === "location" && !At && !le && !D) {
|
|
206
|
+
if (!o && t.locationExpected && t.locationPartialEmpty && t.locationCount < 2 && Re && u.currentTriggerChar() !== "@") {
|
|
207
|
+
const s = d.selectionStart ?? e.length, a = e.slice(0, s), P = a.length > 0 && !/\s$/.test(a);
|
|
208
|
+
if (!a.endsWith("@")) {
|
|
209
|
+
const R = P ? " @" : "@";
|
|
210
|
+
q.current = !0, c(null), u.setDraft(`${a}${R}${e.slice(s)}`), u.focusCaret(s + R.length), requestAnimationFrame(() => {
|
|
211
|
+
const N = u.getTextarea();
|
|
212
|
+
N && u.syncTrigger(N);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
c(null);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (le ? J.current === null && O.length > 0 && (G(0), he(!0), c(O)) : (pe(""), O.length > 0 ? (G(0), he(!0), c(O)) : c(null)), le) {
|
|
221
|
+
const s = e.slice(0, d.selectionStart ?? e.length), a = s.search(/[ \t\r\n](?=[^ \t\r\n]*$)/), P = a === -1 ? s : s.slice(a + 1), R = w === "location" && t.locationPartial !== void 0 ? t.locationPartial : P;
|
|
222
|
+
w === "location" && (Oe.current = R), pe(R);
|
|
223
|
+
const N = w === "location" ? [...e.matchAll(/@\(([A-Za-z]{3})\)/g)].map((ue) => ue[1].toUpperCase()) : void 0, j = ++Ie.current;
|
|
224
|
+
(I = Ce.current) == null || I.abort();
|
|
225
|
+
const We = new AbortController();
|
|
226
|
+
Ce.current = We;
|
|
227
|
+
try {
|
|
228
|
+
const ue = w === "location" ? Qe(t) : "air", De = await le(R, w, We.signal, N, ue);
|
|
229
|
+
if (j !== Ie.current) return;
|
|
230
|
+
const _e = u.getTextarea();
|
|
231
|
+
if (!_e || _e.value !== e || w === "location" && De.length === 0) return;
|
|
232
|
+
const F = [];
|
|
233
|
+
if (w === "location") {
|
|
234
|
+
F.push(...ae({ quickDates: !0 }));
|
|
235
|
+
for (const k of De)
|
|
236
|
+
F.push({
|
|
237
|
+
key: `loc:${k.insert}`,
|
|
238
|
+
label: k.label,
|
|
239
|
+
kind: "namedLocation",
|
|
240
|
+
insert: k.insert,
|
|
241
|
+
hint: [k.iata, k.region, k.country].filter(Boolean).join(" · ") || void 0,
|
|
242
|
+
// parity with the `@` picker
|
|
243
|
+
disabled: k.disabled,
|
|
244
|
+
// already in the prompt (same city) — greyed, not pickable
|
|
245
|
+
// An IATA code is what makes a row an AIRPORT; everything else is a place.
|
|
246
|
+
icon: k.iata ? "airport" : "place",
|
|
247
|
+
section: St(k.source, ue === "both")
|
|
248
|
+
});
|
|
249
|
+
} else {
|
|
250
|
+
F.push(...ae({ quickDates: !1 }));
|
|
251
|
+
for (const k of De)
|
|
252
|
+
F.push({ key: `date:${k.insert}`, label: k.label, kind: "date", icon: "date", insert: k.insert });
|
|
253
|
+
}
|
|
254
|
+
if (F.length === 0) {
|
|
255
|
+
c(null);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const je = F.findIndex((k) => !k.disabled);
|
|
259
|
+
G(je < 0 ? 0 : je), he(R.trim() === ""), c(F);
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
}
|
|
265
|
+
}, 200)), X.current != null && window.clearTimeout(X.current), X.current = window.setTimeout(() => {
|
|
266
|
+
be();
|
|
267
|
+
}, 300);
|
|
268
|
+
}, [be]), $t = A((e) => {
|
|
269
|
+
var o, y;
|
|
270
|
+
const n = e.trim();
|
|
271
|
+
n && ((y = (o = M.current).commitIntent) == null || y.call(o, n, ke.current, H.current)), H.current = Ae(), q.current = !1;
|
|
272
|
+
}, []), wt = A(() => {
|
|
273
|
+
const e = H.current;
|
|
274
|
+
e.atOpened = !0, q.current ? q.current = !1 : Y.current === null && J.current === null && (e.manualAt = !0);
|
|
275
|
+
}, []), Rt = A((e) => {
|
|
276
|
+
H.current.atAccepted = e ?? "location";
|
|
277
|
+
}, []), $e = A(() => {
|
|
278
|
+
H.current.ghostAccepted = !0;
|
|
279
|
+
const e = Y.current === "date" ? "#" : "@";
|
|
280
|
+
q.current = !0, ee.current = 0, te.current = null, S(null);
|
|
281
|
+
const n = K.current, o = n.getTextarea();
|
|
282
|
+
if (!o) return;
|
|
283
|
+
const y = o.selectionStart ?? o.value.length, f = o.value.slice(0, y), E = o.value.slice(y), t = `${f.length > 0 && !/\s$/.test(f) ? " " : ""}${e}`;
|
|
284
|
+
n.setDraft(`${f}${t}${E}`), n.focusCaret(y + t.length), requestAnimationFrame(() => {
|
|
285
|
+
const u = n.getTextarea();
|
|
286
|
+
u && n.syncTrigger(u);
|
|
287
|
+
});
|
|
288
|
+
}, []), Tt = A((e) => {
|
|
289
|
+
const n = ge ? null : C;
|
|
290
|
+
if (v && e.key === v && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
291
|
+
e.preventDefault();
|
|
292
|
+
const o = K.current.getTextarea(), y = (o == null ? void 0 : o.selectionStart) ?? (o == null ? void 0 : o.value.length) ?? 0, f = o ? o.value.slice(y) : "";
|
|
293
|
+
return W.current = !1, ee.current = 0, z(f.trim().length > 0), S($ === "location" ? "person" : "location"), !0;
|
|
294
|
+
}
|
|
295
|
+
if ($ !== null && (!n || n.length === 0)) {
|
|
296
|
+
if (e.key === "Tab" || e.key === "ArrowRight" && !L)
|
|
297
|
+
return e.preventDefault(), $e(), !0;
|
|
298
|
+
if (e.key === "Escape")
|
|
299
|
+
return e.preventDefault(), W.current = !0, S(null), !0;
|
|
300
|
+
}
|
|
301
|
+
if (!n || n.length === 0) return !1;
|
|
302
|
+
if (e.key === "ArrowDown")
|
|
303
|
+
return e.preventDefault(), G((o) => Je(n, o, 1)), !0;
|
|
304
|
+
if (e.key === "ArrowUp")
|
|
305
|
+
return e.preventDefault(), G((o) => Je(n, o, -1)), !0;
|
|
306
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
307
|
+
e.preventDefault();
|
|
308
|
+
const o = n[me];
|
|
309
|
+
return o && !o.disabled && ve(o), !0;
|
|
310
|
+
}
|
|
311
|
+
return e.key === "Escape" ? (e.preventDefault(), c(null), !0) : !1;
|
|
312
|
+
}, [C, ge, me, ve, $, L, $e, v]);
|
|
313
|
+
return de(() => () => {
|
|
314
|
+
var e, n;
|
|
315
|
+
V.current != null && window.clearTimeout(V.current), X.current != null && window.clearTimeout(X.current), B.current != null && window.clearTimeout(B.current), (e = ye.current) == null || e.abort(), (n = Ce.current) == null || n.abort();
|
|
316
|
+
}, []), {
|
|
317
|
+
predictions: ge ? null : C,
|
|
318
|
+
predictionsRecents: dt,
|
|
319
|
+
predictionQuery: ft,
|
|
320
|
+
slotDateOptions: ht,
|
|
321
|
+
predictionHighlight: me,
|
|
322
|
+
setPredictionHighlight: G,
|
|
323
|
+
applyPrediction: ve,
|
|
324
|
+
clearPredictions: kt,
|
|
325
|
+
hint: $,
|
|
326
|
+
hintMidSentence: L,
|
|
327
|
+
acceptHint: $e,
|
|
328
|
+
resolvedLocations: gt,
|
|
329
|
+
resolvedDates: mt,
|
|
330
|
+
forceTooltipText: xt,
|
|
331
|
+
personConfidence: Ye,
|
|
332
|
+
locationConfidence: fe,
|
|
333
|
+
hotelExpected: tt,
|
|
334
|
+
hotelConfidence: ct,
|
|
335
|
+
vertical: rt,
|
|
336
|
+
hotelNameExpected: it,
|
|
337
|
+
hotelNameConfidence: lt,
|
|
338
|
+
scheduleAssist: bt,
|
|
339
|
+
commit: $t,
|
|
340
|
+
onKeyDown: Tt,
|
|
341
|
+
resetSession: vt,
|
|
342
|
+
noteAtOpened: wt,
|
|
343
|
+
noteAtAccepted: Rt
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
p(Nt, "usePromptAssist");
|
|
347
|
+
function Ft(r, m) {
|
|
348
|
+
const x = i(r), [v, C] = l(null);
|
|
349
|
+
return de(() => {
|
|
350
|
+
x.current = r;
|
|
351
|
+
}, [r]), de(() => {
|
|
352
|
+
function c() {
|
|
353
|
+
x.current();
|
|
354
|
+
}
|
|
355
|
+
if (p(c, "tick"), m !== null) {
|
|
356
|
+
const $ = setInterval(c, m);
|
|
357
|
+
return C($), () => {
|
|
358
|
+
clearInterval($);
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
}, [m]), v;
|
|
362
|
+
}
|
|
363
|
+
p(Ft, "useInterval");
|
|
364
|
+
function zt(r, m, x = 0, v = 0) {
|
|
365
|
+
const [C, c] = l(x), [$, S] = l(v);
|
|
366
|
+
return de(() => {
|
|
367
|
+
const L = r.current;
|
|
368
|
+
if (!L) return;
|
|
369
|
+
const z = new ResizeObserver((fe) => {
|
|
370
|
+
const U = fe[0];
|
|
371
|
+
U && (S(U.contentRect.height), c(U.contentRect.width));
|
|
372
|
+
});
|
|
373
|
+
return z.observe(L), c(L.getBoundingClientRect().width), () => z.disconnect();
|
|
374
|
+
}, [r, m]), [C, $];
|
|
375
|
+
}
|
|
376
|
+
p(zt, "useContainerRectangle");
|
|
377
|
+
export {
|
|
378
|
+
Ft as a,
|
|
379
|
+
Nt as b,
|
|
380
|
+
Ot as s,
|
|
381
|
+
zt as u
|
|
382
|
+
};
|
|
383
|
+
//# sourceMappingURL=useContainerWidth-C33sJaCi.js.map
|