@aintela/chat 0.4.19 → 0.4.21
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 +4698 -4645
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.js +81 -80
- package/dist/{predictionRows-CkZdmdsi.js → predictionRows-CtyrlEUr.js} +15 -14
- package/dist/{predictionRows-CkZdmdsi.js.map → predictionRows-CtyrlEUr.js.map} +1 -1
- package/dist/src/components/v2/MentionPickerPanel.d.ts +3 -1
- package/dist/src/components/v2/PromptV2.d.ts +2 -2
- package/dist/src/components/v2/TriggerDropdown.d.ts +5 -1
- package/dist/src/components/v2/styles.d.ts +25 -0
- package/dist/src/utils/atMentions.d.ts +7 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/promptTriggers.d.ts +4 -0
- package/dist/useContainerWidth-DKSIf5HQ.js +343 -0
- package/dist/useContainerWidth-DKSIf5HQ.js.map +1 -0
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/useContainerWidth-DD7G1OoW.js +0 -340
- package/dist/useContainerWidth-DD7G1OoW.js.map +0 -1
|
@@ -19,6 +19,8 @@ export interface MentionPickerPanelProps {
|
|
|
19
19
|
hotelLabel?: string;
|
|
20
20
|
/** Shown while the list is empty and nothing is in flight. */
|
|
21
21
|
emptyLabel?: string;
|
|
22
|
+
/** Which slot of the prompt this panel is filling — its title (see TriggerDropdown's `slotLabel`). */
|
|
23
|
+
slotLabel?: string;
|
|
22
24
|
/**
|
|
23
25
|
* Ceiling on the panel's height, as a percentage of the dynamic viewport. Default 75 — enough that the list
|
|
24
26
|
* dominates the screen without running to the very edge, and short enough that whatever the host keeps down
|
|
@@ -32,4 +34,4 @@ export interface MentionPickerPanelProps {
|
|
|
32
34
|
*/
|
|
33
35
|
bottomInset?: number;
|
|
34
36
|
}
|
|
35
|
-
export declare function MentionPickerPanel({ open, anchorEl, startAtTopOfEl, items, loading, onSelect, personLabel, locationLabel, hotelLabel, emptyLabel, maxHeightVh, bottomInset, }: MentionPickerPanelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
export declare function MentionPickerPanel({ open, anchorEl, startAtTopOfEl, items, loading, onSelect, personLabel, locationLabel, hotelLabel, emptyLabel, slotLabel, maxHeightVh, bottomInset, }: MentionPickerPanelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { AtQueryContext } from '../../utils/atMentions';
|
|
2
|
+
import { AtPersonQueryContext, AtQueryContext } from '../../utils/atMentions';
|
|
3
3
|
import { PromptTriggerItem } from '../../utils/promptTriggers';
|
|
4
4
|
import { PromptAnalysis, PromptResolution, SuggestItem } from '../../services/httpPromptAssistService';
|
|
5
5
|
export type { PromptTriggerItem } from '../../utils/promptTriggers';
|
|
@@ -171,7 +171,7 @@ interface PromptV2Props {
|
|
|
171
171
|
* surrounding text reads as "who travels", location-first otherwise — one anchor, no opaque relevance merge.
|
|
172
172
|
* Return `@[Name](user:id)`-style values so the agent gets the passenger id without a lookup.
|
|
173
173
|
*/
|
|
174
|
-
onAtPersonQuery?: (query: string) => Promise<PromptTriggerItem[]>;
|
|
174
|
+
onAtPersonQuery?: (query: string, context?: AtPersonQueryContext) => Promise<PromptTriggerItem[]>;
|
|
175
175
|
/**
|
|
176
176
|
* Live prompt-assist quick path (debounced ~300ms). Given the text + caret, the server
|
|
177
177
|
* (Qwen next-word + NER) categorizes what's coming so the composer can auto-open the `@`
|
|
@@ -37,6 +37,10 @@ export interface TriggerDropdownProps<T extends DropdownItem = DropdownItem> {
|
|
|
37
37
|
/** What the list is filtering on right now, shown in the header as the user typed it ("@mar", "flori"). The
|
|
38
38
|
* header only appears when there is an echo or a key legend to put in it. */
|
|
39
39
|
queryEcho?: string;
|
|
40
|
+
/** Which SLOT of the prompt is being filled — a guided template's placeholder text ("data de ida"). On TOUCH
|
|
41
|
+
* this is what the header says, in place of keys a phone does not have: the guided flow moves the caret to the
|
|
42
|
+
* next placeholder on its own, and without a title the list that reopens looks like the one just answered. */
|
|
43
|
+
slotLabel?: string;
|
|
40
44
|
/** A line UNDER the rows, in the composer's own size, inviting more typing ("…ou continue digitando"). */
|
|
41
45
|
trailingNote?: string;
|
|
42
46
|
/** Layout overrides for the container — the docked panel uses this to fill its host box. */
|
|
@@ -57,4 +61,4 @@ export interface TriggerDropdownProps<T extends DropdownItem = DropdownItem> {
|
|
|
57
61
|
* the browser fires `pointercancel` the moment it claims the gesture for scrolling, which is the authoritative
|
|
58
62
|
* "this was a scroll, not a tap" signal. The slop check is a belt-and-braces for a shaky finger.
|
|
59
63
|
*/
|
|
60
|
-
export declare function TriggerDropdown<T extends DropdownItem = DropdownItem>({ items, highlight, onHighlight, onSelect, loading, personLabel, locationLabel, hotelLabel, touch, emptyLabel, keyHints, queryEcho, trailingNote, sx, }: TriggerDropdownProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
export declare function TriggerDropdown<T extends DropdownItem = DropdownItem>({ items, highlight, onHighlight, onSelect, loading, personLabel, locationLabel, hotelLabel, touch, emptyLabel, keyHints, queryEcho, slotLabel, trailingNote, sx, }: TriggerDropdownProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,3 +4,28 @@ export declare const v2IconBtn: SxProps<Theme>;
|
|
|
4
4
|
export declare const v2Card: SxProps<Theme>;
|
|
5
5
|
export declare const v2MonoMeta: SxProps<Theme>;
|
|
6
6
|
export declare const v2SectionLabel: SxProps<Theme>;
|
|
7
|
+
/**
|
|
8
|
+
* The touch surfaces' ENTRANCE — a slot picker sliding in from above (Ciro, 2026-09-11).
|
|
9
|
+
*
|
|
10
|
+
* On a phone the guided template flow answers one slot and moves the caret to the next by itself, and the picker
|
|
11
|
+
* that reopens looks exactly like the one just answered: same list, same place on screen, no caret to watch. The
|
|
12
|
+
* title says which slot it is; this says that it CHANGED. Keyed on the slot by the host, so a swap replays it.
|
|
13
|
+
*
|
|
14
|
+
* Honours `prefers-reduced-motion`, which is the setting a user who finds this distracting will already have on.
|
|
15
|
+
*/
|
|
16
|
+
export declare const slotEnterSx: {
|
|
17
|
+
readonly animation: "aiaSlotEnter 180ms cubic-bezier(0.2, 0, 0.2, 1)";
|
|
18
|
+
readonly '@keyframes aiaSlotEnter': {
|
|
19
|
+
readonly from: {
|
|
20
|
+
readonly opacity: 0;
|
|
21
|
+
readonly transform: "translateY(-14px)";
|
|
22
|
+
};
|
|
23
|
+
readonly to: {
|
|
24
|
+
readonly opacity: 1;
|
|
25
|
+
readonly transform: "none";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly '@media (prefers-reduced-motion: reduce)': {
|
|
29
|
+
readonly animation: "none";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -25,11 +25,17 @@ export interface AtQueryContext {
|
|
|
25
25
|
* keeps places and airports below. Undefined when the host or the server predates the head. */
|
|
26
26
|
hotelNameConfidence?: number;
|
|
27
27
|
}
|
|
28
|
+
/** Context handed to the person source (2026-09-11) — the mirror of {@link AtQueryContext} for the other half. */
|
|
29
|
+
export interface AtPersonQueryContext {
|
|
30
|
+
/** This source's rows will LEAD the list (person-intent won). A blank query then wants a full page of the
|
|
31
|
+
* directory rather than the handful that fits under a place list — Ciro asked for a top 20. */
|
|
32
|
+
leading: boolean;
|
|
33
|
+
}
|
|
28
34
|
export interface AtMentionFetchers {
|
|
29
35
|
/** Location source (airports / cities — or hotel places when `context.vertical` says so, issue #876). */
|
|
30
36
|
onAtQuery?: (query: string, context?: AtQueryContext) => Promise<PromptTriggerItem[]>;
|
|
31
37
|
/** Person / passenger source (company directory). */
|
|
32
|
-
onAtPersonQuery?: (query: string) => Promise<PromptTriggerItem[]>;
|
|
38
|
+
onAtPersonQuery?: (query: string, context?: AtPersonQueryContext) => Promise<PromptTriggerItem[]>;
|
|
33
39
|
}
|
|
34
40
|
export interface AtMentionOptions {
|
|
35
41
|
/** Person-intent confidence from the analyze pass; orders the two sections. Default 0. */
|
|
@@ -18,6 +18,6 @@ export { swallowNextClick } from './swallowNextClick';
|
|
|
18
18
|
export { detectTrigger, applyTriggerInsertion, findPlaceholder, placeholderAt, activatePlaceholder, advanceToPlaceholder, } from './promptTriggers';
|
|
19
19
|
export type { TriggerChar, ActiveTrigger, TriggerInsertion, TemplatePlaceholder, MentionKind } from './promptTriggers';
|
|
20
20
|
export { fetchAtMentions, isSectionStart } from './atMentions';
|
|
21
|
-
export type { AtMentionItem, MentionGroup, AtMentionFetchers, AtMentionOptions, AtQueryContext, AtQueryVertical } from './atMentions';
|
|
21
|
+
export type { AtMentionItem, MentionGroup, AtMentionFetchers, AtMentionOptions, AtQueryContext, AtPersonQueryContext, AtQueryVertical } from './atMentions';
|
|
22
22
|
export { toPredictionRows } from './predictionRows';
|
|
23
23
|
export type { PredictionRow } from './predictionRows';
|
|
@@ -56,6 +56,10 @@ export type TriggerInsertion = {
|
|
|
56
56
|
selectionEnd: number;
|
|
57
57
|
/** True when the inserted value ends in a trigger char — the host should re-run detection so that picker opens. */
|
|
58
58
|
reopenTrigger: boolean;
|
|
59
|
+
/** The placeholder this insertion ACTIVATED, by its bracket text ("data de ida") — the slot the user is now
|
|
60
|
+
* being asked to fill. Undefined when no placeholder was activated. Hosts title their picker with it: the
|
|
61
|
+
* guided flow moves the caret on its own, and a phone has no visible caret to notice it move. */
|
|
62
|
+
placeholderLabel?: string;
|
|
59
63
|
};
|
|
60
64
|
/** A `[placeholder]` in a template — optionally typed by a leading trigger char. */
|
|
61
65
|
export type TemplatePlaceholder = {
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
var Pe = Object.defineProperty;
|
|
2
|
+
var x = (o, v) => Pe(o, "name", { value: v, configurable: !0 });
|
|
3
|
+
import { useState as u, useRef as s, useCallback as D, useEffect as dt } from "react";
|
|
4
|
+
const Bt = /* @__PURE__ */ x((o) => o.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), "foldForCompare"), Qt = /* @__PURE__ */ x((o) => o.vertical ?? (Jt(o) ? "hotel" : "air"), "verticalOf"), Jt = /* @__PURE__ */ x((o) => o.placesExpected ?? o.hotelExpected ?? !1, "lodgingOf"), jt = /* @__PURE__ */ x((o) => o.placesConfidence ?? o.hotelConfidence ?? 0, "lodgingScoreOf"), He = /* @__PURE__ */ x((o) => o === "hotel" ? "Hotéis e locais" : o === "air" ? "Aeroportos" : void 0, "sectionLabel"), Dt = "Data", Vt = "Localização", Et = /* @__PURE__ */ x(() => ({
|
|
5
|
+
maxLocationConfidence: 0,
|
|
6
|
+
maxPersonConfidence: 0,
|
|
7
|
+
maxHotelConfidence: 0,
|
|
8
|
+
locationGateFired: !1,
|
|
9
|
+
suggestionAccepted: !1,
|
|
10
|
+
ghostShown: !1,
|
|
11
|
+
ghostAccepted: !1,
|
|
12
|
+
atOpened: !1,
|
|
13
|
+
atAccepted: null,
|
|
14
|
+
manualAt: !1
|
|
15
|
+
}), "emptyOutcome"), Xt = /* @__PURE__ */ x(() => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`, "newSessionId"), Zt = /* @__PURE__ */ x((o, v, A) => {
|
|
16
|
+
var a;
|
|
17
|
+
const T = o.length;
|
|
18
|
+
let k = v;
|
|
19
|
+
for (let w = 0; w < T; w++)
|
|
20
|
+
if (k = (k + A + T) % T, !((a = o[k]) != null && a.disabled)) return k;
|
|
21
|
+
return v;
|
|
22
|
+
}, "nextEnabledIndex");
|
|
23
|
+
function qe(o, v, A = {}) {
|
|
24
|
+
const { debugGhostKey: T } = A, [k, a] = u(null), [w, S] = u(null), [O, K] = u(!1), [ft, j] = u(0), [Yt, te] = u(0), [ee, ne] = u(!1), [re, oe] = u("air"), [ce, se] = u(0), [ie, le] = u(!1), [ae, ue] = u(0), [de, ht] = u(!1), [fe, pt] = u(""), [he, pe] = u([]), [gt, mt] = u(!1), E = s(null), [xt, z] = u(0), [ge, Pt] = u([]), [me, Ht] = u([]), [xe, yt] = u(""), et = s(""), V = s(null), M = s(o);
|
|
25
|
+
M.current = o;
|
|
26
|
+
const U = s(v);
|
|
27
|
+
U.current = v;
|
|
28
|
+
const nt = s(A);
|
|
29
|
+
nt.current = A;
|
|
30
|
+
const X = s(null), Z = s(null), It = s(0), Lt = s(0), Ct = s(null), rt = s(""), J = s(null), vt = s(null), kt = s(Xt()), Y = s(null);
|
|
31
|
+
Y.current = k;
|
|
32
|
+
const W = s(null);
|
|
33
|
+
W.current = w;
|
|
34
|
+
const _ = s(0), B = s(null), Q = s(!1), ye = 8, Ce = 0.5, tt = s(null), Ot = s(""), qt = s(() => {
|
|
35
|
+
}), L = s(Et()), q = s(!1), ve = D(() => {
|
|
36
|
+
a(null), pt(""), E.current = null;
|
|
37
|
+
}, []), ke = D(() => {
|
|
38
|
+
Pt([]), Ht([]), yt(""), et.current = "", J.current = null, kt.current = Xt(), L.current = Et(), q.current = !1, E.current = null, mt(!1), _.current = 0, B.current = null, Q.current = !1, S(null);
|
|
39
|
+
}, []), wt = D((t) => {
|
|
40
|
+
if (t.disabled) return;
|
|
41
|
+
L.current.suggestionAccepted = !0, E.current = null, t.kind === "location" && (q.current = !0), a(null);
|
|
42
|
+
const n = M.current, r = n.getTextarea();
|
|
43
|
+
if (!r) return;
|
|
44
|
+
const g = r.selectionStart ?? r.value.length, h = r.value.slice(0, g), P = r.value.slice(g), N = t.kind === "namedLocation" || t.kind === "location";
|
|
45
|
+
let e;
|
|
46
|
+
if (N) {
|
|
47
|
+
const f = Ot.current, p = h.replace(/\s+$/, "");
|
|
48
|
+
e = f && p.endsWith(f) ? p.slice(0, p.length - f.length) : h;
|
|
49
|
+
} else {
|
|
50
|
+
const f = h.search(/\S+$/), p = f === -1 ? "" : h.slice(f);
|
|
51
|
+
e = p.length > 0 && (t.kind === "date" && t.insert ? Bt(t.insert).startsWith(Bt(p)) : /^[\d./-]+$/.test(p)) ? h.slice(0, f) : h;
|
|
52
|
+
}
|
|
53
|
+
const i = e.length > 0 && !/\s$/.test(e);
|
|
54
|
+
if (t.kind === "date") {
|
|
55
|
+
const f = `${i ? " " : ""}${t.insert} `, p = `${e}${f}${P}`;
|
|
56
|
+
n.setDraft(p), n.focusCaret(e.length + f.length), rt.current = p, J.current = null, qt.current();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (t.kind === "namedLocation" && t.insert) {
|
|
60
|
+
const f = `@${t.insert.replace(/ /g, " ")}`, p = `${i ? " " : ""}${f} `;
|
|
61
|
+
n.setDraft(`${e}${p}${P}`), n.focusCaret(e.length + p.length);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const d = t.kind === "location" ? "@" : "#", y = `${i ? " " : ""}${d}`;
|
|
65
|
+
n.setDraft(`${e}${y}${P}`), n.focusCaret(e.length + y.length), requestAnimationFrame(() => {
|
|
66
|
+
const f = n.getTextarea();
|
|
67
|
+
f && n.syncTrigger(f);
|
|
68
|
+
});
|
|
69
|
+
}, []), Rt = D(async () => {
|
|
70
|
+
var h;
|
|
71
|
+
const t = U.current.resolveDates;
|
|
72
|
+
if (!t) return;
|
|
73
|
+
const n = rt.current;
|
|
74
|
+
if (n.trim() === "") {
|
|
75
|
+
J.current = null;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (n === J.current || n.split(" ").length <= 2) return;
|
|
79
|
+
J.current = n, (h = vt.current) == null || h.abort();
|
|
80
|
+
const g = new AbortController();
|
|
81
|
+
vt.current = g;
|
|
82
|
+
try {
|
|
83
|
+
const { dates: P, locations: N } = await t(n, kt.current, g.signal);
|
|
84
|
+
if (rt.current !== n) return;
|
|
85
|
+
const e = P.filter((d) => d.display).map((d) => ({ text: d.text, display: d.display }));
|
|
86
|
+
Ht(e), Pt(N.map((d) => d.text).filter((d) => d.trim().length > 0));
|
|
87
|
+
const i = e.map((d) => `${d.text}=${d.display}`).join("|");
|
|
88
|
+
e.length > 0 && i !== et.current && (et.current = i, yt(e[e.length - 1].text), V.current != null && window.clearTimeout(V.current), V.current = window.setTimeout(() => yt(""), 2e3)), e.length === 0 && (et.current = "");
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}, []);
|
|
92
|
+
qt.current = Rt;
|
|
93
|
+
const we = D((t, n, r) => {
|
|
94
|
+
if (rt.current = t, W.current !== null && (_.current += 1, _.current >= ye && (Q.current = !0, S(null))), t.split(" ").length <= 2) return;
|
|
95
|
+
const h = U.current.analyze;
|
|
96
|
+
h && (!r || Y.current !== null || W.current !== null) && (X.current != null && window.clearTimeout(X.current), X.current = window.setTimeout(async () => {
|
|
97
|
+
var N;
|
|
98
|
+
const P = ++It.current;
|
|
99
|
+
try {
|
|
100
|
+
const e = await h(t, n);
|
|
101
|
+
if (P !== It.current) return;
|
|
102
|
+
const i = M.current, d = i.getTextarea();
|
|
103
|
+
if (!d || d.value !== t) return;
|
|
104
|
+
te(e.personConfidence ?? 0), j(e.locationConfidence ?? 0), ne(Jt(e)), oe(Qt(e)), se(jt(e)), le(e.hotelNameExpected ?? !1), ue(e.hotelNameConfidence ?? 0);
|
|
105
|
+
const y = L.current;
|
|
106
|
+
y.maxPersonConfidence = Math.max(y.maxPersonConfidence, e.personConfidence ?? 0), y.maxLocationConfidence = Math.max(y.maxLocationConfidence, e.locationConfidence ?? 0), y.maxHotelConfidence = Math.max(y.maxHotelConfidence ?? 0, jt(e)), S(null);
|
|
107
|
+
const f = d.selectionStart ?? n, p = f === t.length, ot = t.slice(0, f), Se = t.slice(f), bt = !p && /\s$/.test(ot) && !/^\s*@/.test(Se), ct = p || bt, Tt = i.hasAtQuery, st = i.isPickerOpen(), Nt = e.suggestions ?? [], { enableHashDatePicker: it = !1, datePresets: Ft = ["amanhã de manhã", "quarta-feira à noite"] } = nt.current;
|
|
108
|
+
let b = e.category === "location" ? "location" : e.category === "date" ? "date" : e.locationExpected ? "location" : e.dateExpected ? "date" : null;
|
|
109
|
+
b !== "location" && e.locationCount < 2 && U.current.suggest && Y.current !== null && tt.current === "location" && ct && /\s$/.test(ot) && (b = "location");
|
|
110
|
+
const Gt = e.secondary ?? "";
|
|
111
|
+
let R = it && Tt && (b === "location" && Gt === "date" || b === "date" && Gt === "location");
|
|
112
|
+
if (R && e.locationCount >= 2 && e.locationPartialEmpty && (R = !1, b = "date"), !st) {
|
|
113
|
+
const c = (e.suggestions ?? []).filter((l) => l.kind === "date").map((l) => l.value);
|
|
114
|
+
pe(R ? [
|
|
115
|
+
...it ? [{ id: "cal", label: "# Escolher no calendário", value: "#", kind: "calendar", section: Dt }] : [],
|
|
116
|
+
...(c.length > 0 ? c : Ft).map((l) => ({ id: `date:${l}`, label: l, value: l, kind: "date", section: Dt }))
|
|
117
|
+
] : []);
|
|
118
|
+
}
|
|
119
|
+
const St = !!(R && nt.current.promptHint && ct && !st);
|
|
120
|
+
E.current !== null && !ot.startsWith(E.current) && (E.current = null), R || (E.current = null);
|
|
121
|
+
const Kt = E.current !== null;
|
|
122
|
+
if (mt(St && !Kt), St && !Kt && (Q.current || (B.current = "mixed", K(bt), S("mixed"), y.ghostShown = !0, y.locationGateFired = !0)), nt.current.promptHint && ct && !st && !St) {
|
|
123
|
+
const c = e.personConfidence ?? 0, l = e.locationConfidence ?? 0, H = b === "location" && !R && !(e.locationCount >= 2 && e.locationPartialEmpty), C = b === "date" && !R && it, I = c >= Ce && c >= l && !C ? "person" : C ? "date" : H ? "location" : null;
|
|
124
|
+
if (I) {
|
|
125
|
+
Q.current || (B.current = I, K(bt), S(I), y.ghostShown = !0, I === "location" && (y.locationGateFired = !0)), a(null), tt.current = null;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
B.current = null;
|
|
129
|
+
}
|
|
130
|
+
if (b === "location" && e.locationCount >= 2 && e.locationPartialEmpty) {
|
|
131
|
+
a(null), tt.current = null;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (b === null || !(ct && !st && (b === "location" ? Tt : b === "date"))) {
|
|
135
|
+
a(null), tt.current = null;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const $ = R ? "location" : b;
|
|
139
|
+
tt.current = $, $ === "location" && (y.locationGateFired = !0);
|
|
140
|
+
const zt = Nt.filter((c) => c.kind === "location"), Mt = Nt.filter((c) => c.kind === "date").map((c) => c.value), lt = /* @__PURE__ */ x(({ quickDates: c }) => {
|
|
141
|
+
if ($ !== "date" && !R) return [];
|
|
142
|
+
const l = R ? Dt : void 0, H = [];
|
|
143
|
+
if (it && H.push({ key: "cal", label: "# Escolher no calendário", kind: "calendar", icon: "calendar", section: l }), c)
|
|
144
|
+
for (const C of Mt.length > 0 ? Mt : Ft)
|
|
145
|
+
H.push({ key: `date:${C}`, label: C, kind: "date", icon: "date", insert: C, section: l });
|
|
146
|
+
return H;
|
|
147
|
+
}, "dateRows"), Ae = /* @__PURE__ */ x((c, l) => (l ? He(c) : void 0) ?? (R ? Vt : void 0), "locSection"), F = [];
|
|
148
|
+
if ($ === "location") {
|
|
149
|
+
F.push(...lt({ quickDates: !0 }));
|
|
150
|
+
for (const c of zt)
|
|
151
|
+
F.push({
|
|
152
|
+
key: `loc:${c.value}`,
|
|
153
|
+
label: c.label,
|
|
154
|
+
kind: "namedLocation",
|
|
155
|
+
insert: c.value,
|
|
156
|
+
icon: "place",
|
|
157
|
+
section: R ? Vt : void 0
|
|
158
|
+
});
|
|
159
|
+
} else
|
|
160
|
+
F.push(...lt({ quickDates: !0 }));
|
|
161
|
+
const at = U.current.suggest, De = $ === "location" ? zt.length > 0 : !0;
|
|
162
|
+
if ($ === "location" && !De && !at && !R) {
|
|
163
|
+
if (!r && e.locationExpected && e.locationPartialEmpty && e.locationCount < 2 && Tt && i.currentTriggerChar() !== "@") {
|
|
164
|
+
const c = d.selectionStart ?? t.length, l = t.slice(0, c), H = l.length > 0 && !/\s$/.test(l);
|
|
165
|
+
if (!l.endsWith("@")) {
|
|
166
|
+
const C = H ? " @" : "@";
|
|
167
|
+
q.current = !0, a(null), i.setDraft(`${l}${C}${t.slice(c)}`), i.focusCaret(c + C.length), requestAnimationFrame(() => {
|
|
168
|
+
const I = i.getTextarea();
|
|
169
|
+
I && i.syncTrigger(I);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
a(null);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (at ? Y.current === null && F.length > 0 && (z(0), ht(!0), a(F)) : (pt(""), F.length > 0 ? (z(0), ht(!0), a(F)) : a(null)), at) {
|
|
178
|
+
const c = t.slice(0, d.selectionStart ?? t.length), l = c.search(/[ \t\r\n](?=[^ \t\r\n]*$)/), H = l === -1 ? c : c.slice(l + 1), C = $ === "location" && e.locationPartial !== void 0 ? e.locationPartial : H;
|
|
179
|
+
$ === "location" && (Ot.current = C), pt(C);
|
|
180
|
+
const I = $ === "location" ? [...t.matchAll(/@\(([A-Za-z]{3})\)/g)].map((ut) => ut[1].toUpperCase()) : void 0, Ee = ++Lt.current;
|
|
181
|
+
(N = Ct.current) == null || N.abort();
|
|
182
|
+
const Ut = new AbortController();
|
|
183
|
+
Ct.current = Ut;
|
|
184
|
+
try {
|
|
185
|
+
const ut = $ === "location" ? Qt(e) : "air", At = await at(C, $, Ut.signal, I, ut);
|
|
186
|
+
if (Ee !== Lt.current) return;
|
|
187
|
+
const Wt = i.getTextarea();
|
|
188
|
+
if (!Wt || Wt.value !== t || $ === "location" && At.length === 0) return;
|
|
189
|
+
const G = [];
|
|
190
|
+
if ($ === "location") {
|
|
191
|
+
G.push(...lt({ quickDates: !0 }));
|
|
192
|
+
for (const m of At)
|
|
193
|
+
G.push({
|
|
194
|
+
key: `loc:${m.insert}`,
|
|
195
|
+
label: m.label,
|
|
196
|
+
kind: "namedLocation",
|
|
197
|
+
insert: m.insert,
|
|
198
|
+
hint: [m.iata, m.region, m.country].filter(Boolean).join(" · ") || void 0,
|
|
199
|
+
// parity with the `@` picker
|
|
200
|
+
disabled: m.disabled,
|
|
201
|
+
// already in the prompt (same city) — greyed, not pickable
|
|
202
|
+
// An IATA code is what makes a row an AIRPORT; everything else is a place.
|
|
203
|
+
icon: m.iata ? "airport" : "place",
|
|
204
|
+
section: Ae(m.source, ut === "both")
|
|
205
|
+
});
|
|
206
|
+
} else {
|
|
207
|
+
G.push(...lt({ quickDates: !1 }));
|
|
208
|
+
for (const m of At)
|
|
209
|
+
G.push({ key: `date:${m.insert}`, label: m.label, kind: "date", icon: "date", insert: m.insert });
|
|
210
|
+
}
|
|
211
|
+
if (G.length === 0) {
|
|
212
|
+
a(null);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const _t = G.findIndex((m) => !m.disabled);
|
|
216
|
+
z(_t < 0 ? 0 : _t), ht(C.trim() === ""), a(G);
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} catch {
|
|
221
|
+
}
|
|
222
|
+
}, 200)), Z.current != null && window.clearTimeout(Z.current), Z.current = window.setTimeout(() => {
|
|
223
|
+
Rt();
|
|
224
|
+
}, 300);
|
|
225
|
+
}, [Rt]), Re = D((t) => {
|
|
226
|
+
var r, g;
|
|
227
|
+
const n = t.trim();
|
|
228
|
+
n && ((g = (r = U.current).commitIntent) == null || g.call(r, n, kt.current, L.current)), L.current = Et(), q.current = !1;
|
|
229
|
+
}, []), $e = D(() => {
|
|
230
|
+
const t = L.current;
|
|
231
|
+
t.atOpened = !0, q.current ? q.current = !1 : W.current === null && Y.current === null && (t.manualAt = !0);
|
|
232
|
+
}, []), be = D((t) => {
|
|
233
|
+
L.current.atAccepted = t ?? "location";
|
|
234
|
+
}, []), $t = D(() => {
|
|
235
|
+
if (L.current.ghostAccepted = !0, W.current === "mixed") {
|
|
236
|
+
const i = M.current.getTextarea();
|
|
237
|
+
E.current = i ? i.value.slice(0, i.selectionStart ?? i.value.length) : "", mt(!1), _.current = 0, B.current = null, S(null);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const t = W.current === "date" ? "#" : "@";
|
|
241
|
+
q.current = !0, _.current = 0, B.current = null, S(null);
|
|
242
|
+
const n = M.current, r = n.getTextarea();
|
|
243
|
+
if (!r) return;
|
|
244
|
+
const g = r.selectionStart ?? r.value.length, h = r.value.slice(0, g), P = r.value.slice(g), e = `${h.length > 0 && !/\s$/.test(h) ? " " : ""}${t}`;
|
|
245
|
+
n.setDraft(`${h}${e}${P}`), n.focusCaret(g + e.length), requestAnimationFrame(() => {
|
|
246
|
+
const i = n.getTextarea();
|
|
247
|
+
i && n.syncTrigger(i);
|
|
248
|
+
});
|
|
249
|
+
}, []), Te = D((t) => {
|
|
250
|
+
const n = gt ? null : k;
|
|
251
|
+
if (T && t.key === T && !t.ctrlKey && !t.metaKey && !t.altKey) {
|
|
252
|
+
t.preventDefault();
|
|
253
|
+
const r = M.current.getTextarea(), g = (r == null ? void 0 : r.selectionStart) ?? (r == null ? void 0 : r.value.length) ?? 0, h = r ? r.value.slice(g) : "";
|
|
254
|
+
return Q.current = !1, _.current = 0, K(h.trim().length > 0), S(w === "location" ? "person" : "location"), !0;
|
|
255
|
+
}
|
|
256
|
+
if (w !== null && (!n || n.length === 0)) {
|
|
257
|
+
if (t.key === "Tab" || t.key === "ArrowRight" && !O)
|
|
258
|
+
return t.preventDefault(), $t(), !0;
|
|
259
|
+
if (t.key === "Escape")
|
|
260
|
+
return t.preventDefault(), Q.current = !0, S(null), !0;
|
|
261
|
+
}
|
|
262
|
+
if (!n || n.length === 0) return !1;
|
|
263
|
+
if (t.key === "ArrowDown")
|
|
264
|
+
return t.preventDefault(), z((r) => Zt(n, r, 1)), !0;
|
|
265
|
+
if (t.key === "ArrowUp")
|
|
266
|
+
return t.preventDefault(), z((r) => Zt(n, r, -1)), !0;
|
|
267
|
+
if (t.key === "Enter" || t.key === "Tab") {
|
|
268
|
+
t.preventDefault();
|
|
269
|
+
const r = n[xt];
|
|
270
|
+
return r && !r.disabled && wt(r), !0;
|
|
271
|
+
}
|
|
272
|
+
return t.key === "Escape" ? (t.preventDefault(), a(null), !0) : !1;
|
|
273
|
+
}, [k, gt, xt, wt, w, O, $t, T]);
|
|
274
|
+
return dt(() => () => {
|
|
275
|
+
var t, n;
|
|
276
|
+
X.current != null && window.clearTimeout(X.current), Z.current != null && window.clearTimeout(Z.current), V.current != null && window.clearTimeout(V.current), (t = vt.current) == null || t.abort(), (n = Ct.current) == null || n.abort();
|
|
277
|
+
}, []), {
|
|
278
|
+
predictions: gt ? null : k,
|
|
279
|
+
predictionsRecents: de,
|
|
280
|
+
predictionQuery: fe,
|
|
281
|
+
slotDateOptions: he,
|
|
282
|
+
predictionHighlight: xt,
|
|
283
|
+
setPredictionHighlight: z,
|
|
284
|
+
applyPrediction: wt,
|
|
285
|
+
clearPredictions: ve,
|
|
286
|
+
hint: w,
|
|
287
|
+
hintMidSentence: O,
|
|
288
|
+
acceptHint: $t,
|
|
289
|
+
resolvedLocations: ge,
|
|
290
|
+
resolvedDates: me,
|
|
291
|
+
forceTooltipText: xe,
|
|
292
|
+
personConfidence: Yt,
|
|
293
|
+
locationConfidence: ft,
|
|
294
|
+
hotelExpected: ee,
|
|
295
|
+
hotelConfidence: ce,
|
|
296
|
+
vertical: re,
|
|
297
|
+
hotelNameExpected: ie,
|
|
298
|
+
hotelNameConfidence: ae,
|
|
299
|
+
scheduleAssist: we,
|
|
300
|
+
commit: Re,
|
|
301
|
+
onKeyDown: Te,
|
|
302
|
+
resetSession: ke,
|
|
303
|
+
noteAtOpened: $e,
|
|
304
|
+
noteAtAccepted: be
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
x(qe, "usePromptAssist");
|
|
308
|
+
function Ne(o, v) {
|
|
309
|
+
const A = s(o), [T, k] = u(null);
|
|
310
|
+
return dt(() => {
|
|
311
|
+
A.current = o;
|
|
312
|
+
}, [o]), dt(() => {
|
|
313
|
+
function a() {
|
|
314
|
+
A.current();
|
|
315
|
+
}
|
|
316
|
+
if (x(a, "tick"), v !== null) {
|
|
317
|
+
const w = setInterval(a, v);
|
|
318
|
+
return k(w), () => {
|
|
319
|
+
clearInterval(w);
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}, [v]), T;
|
|
323
|
+
}
|
|
324
|
+
x(Ne, "useInterval");
|
|
325
|
+
function Fe(o, v, A = 0, T = 0) {
|
|
326
|
+
const [k, a] = u(A), [w, S] = u(T);
|
|
327
|
+
return dt(() => {
|
|
328
|
+
const O = o.current;
|
|
329
|
+
if (!O) return;
|
|
330
|
+
const K = new ResizeObserver((ft) => {
|
|
331
|
+
const j = ft[0];
|
|
332
|
+
j && (S(j.contentRect.height), a(j.contentRect.width));
|
|
333
|
+
});
|
|
334
|
+
return K.observe(O), a(O.getBoundingClientRect().width), () => K.disconnect();
|
|
335
|
+
}, [o, v]), [k, w];
|
|
336
|
+
}
|
|
337
|
+
x(Fe, "useContainerRectangle");
|
|
338
|
+
export {
|
|
339
|
+
Ne as a,
|
|
340
|
+
qe as b,
|
|
341
|
+
Fe as u
|
|
342
|
+
};
|
|
343
|
+
//# sourceMappingURL=useContainerWidth-DKSIf5HQ.js.map
|