@aintela/chat 0.4.14 → 0.4.15

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/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { u as a, a as t, b as o } from "./useContainerWidth-BGY88fRY.js";
1
+ import { u as a, a as t, b as o } from "./useContainerWidth-RyWSI8nV.js";
2
2
  import { u } from "./useChatSessions-BzgPYfyj.js";
3
3
  export {
4
4
  u as useChatSessions,
package/dist/index.js CHANGED
@@ -7,10 +7,10 @@ import { A as Y, a as Q, E as $, H as ee, I as ae, L as te, W as se } from "./ht
7
7
  import { A as oe } from "./artifactHtmlHandler-CMQJf1cX.js";
8
8
  import { H as ie, d as ce, r as le } from "./httpSessionService-B3CxFtl1.js";
9
9
  import { APPBAR_HEIGHT as pe, APPBAR_HEIGHT as ge, ASK_USER_CANCELLED as Se, AgentActivity as Ce, AgentActivity as Ie, AiChat as he, AiChatDrawer as de, AiChatFloating as Pe, AiChatFloating as ue, AiChatPane as Ee, AiChatProvider as ve, AiChatServiceContext as Te, AiChatPane as me, AppBar as Le, AppBar as Re, AppRail as xe, AppRail as Me, AppShell as ye, AppShell as fe, ArtifactRender as De, AskUserDialog as Ue, AskUserSheet as _e, AttachmentPreviewModal as ke, BoxedPart as Be, BrainIcon as Ve, ChartIcon as be, ChatIcon as Fe, ChatPane as He, ChatsHistory as Ne, ChatsHistory as Ge, CheckIcon as Oe, ChevronIcon as we, ChevronRightIcon as We, CloseIcon as ze, CodeIcon as Je, ComposerIcon as Ke, CurrentMessage as je, DEFAULT_PART_RENDERERS as qe, DashboardIcon as Xe, DataExplorerIcon as Ze, DelayTextComponent as Ye, EnvironmentProvider as Qe, FileIcon as $e, FunctionPart as ea, GlobeIcon as aa, HistoryIcon as ta, IDLE_TIMEOUT as sa, InertEnvironmentProvider as na, JsxErrorBoundary as oa, LIVE_TSX_DEFAULT_MAX_CHARS_FOR_FULL as ra, LastPrompts as ia, LastPrompts as ca, LinearBackgroundProgress as la, LinearProgressBarWithMarkers as Aa, ListCheckIcon as pa, LiveJsxBlock as ga, LiveTsxConfigProvider as Sa, LlmResponseRender as Ca, LoadingDots as Ia, LockClosedIcon as ha, LockOpenIcon as da, MOBILE_NAV_DEFAULT as Pa, MarkdownExtended as ua, MentionPickerPanel as Ea, MenuIcon as va, Message as Ta, MobileDrawer as ma, MobileDrawer as La, PanelIcon as Ra, PaperclipIcon as xa, PauseIcon as Ma, PenIcon as ya, PinIcon as fa, PlusIcon as Da, Prompt as Ua, PromptDateMarkers as _a, PromptGhostHint as ka, Prompt as Ba, RotateIcon as Va, RunProgressPanel as ba, RunProgressPanel as Fa, RunProgressStrip as Ha, RunProgressStrip as Na, SearchIcon as Ga, SendIcon as Oa, SessionStateManagerService as wa, SessionUsage as Wa, SessionUsage as za, SparkleIcon as Ja, Sparkline as Ka, StopIcon as ja, Stopwatch as qa, SubAgentBox as Xa, SubAgentBox as Za, SuspendedPart as Ya, TableIcon as Qa, TaskList as $a, TaskList as et, TerminalIcon as at, TextPart as tt, ThoughtPart as st, ToolIcon as nt, TrashIcon as ot, TriggerDropdown as rt, TurnAwareButton as it, UiToolDispatcher as ct, UndoIcon as lt, UsersIcon as At, V2_CHART_PALETTE as pt, WARNING_THRESHOLD as gt, WaitingPart as St, ZoomInIcon as Ct, ZoomOutIcon as It, classifyPart as ht, configureFriendlyMapping as dt, createAiChatEngine as Pt, createAiChatSessionStore as ut, createAiChatSessionStore as Et, createUiToolRegistry as vt, disposeSharedAiChatEngine as Tt, engineKeyFor as mt, extendDefaultScope as Lt, extendModuleRegistry as Rt, getDefaultJsxScope as xt, getFriendlyLabel as Mt, getSharedAiChatEngine as yt, parseClientOutput as ft, parseContentBlocks as Dt, parseUiArgs as Ut, useAgentEngine as _t, useAiChatServices as kt, useAiChatSessionStore as Bt, useCoarsePointer as Vt, useEnvironment as bt, useEnvironmentOptional as Ft, useLiveTsxMaxCharsForFull as Ht, useParkedAskUser as Nt, useResponsiveLayout as Gt, useTurnOpen as Ot, useVisualViewport as wt, v2Card as Wt, v2Chip as zt, v2IconBtn as Jt, v2MonoMeta as Kt, v2SectionLabel as jt, v2Theme as qt } from "./components.js";
10
- import { u as Zt, a as Yt, b as Qt } from "./useContainerWidth-BGY88fRY.js";
10
+ import { u as Zt, a as Yt, b as Qt } from "./useContainerWidth-RyWSI8nV.js";
11
11
  import { A as es, D as as, g as ts, b as ss, c as ns, d as os, e as rs, f as is, i as cs, r as ls } from "./environmentUtils-VZNTCzEE.js";
12
12
  import { ALLOWED_DOMAINS as ps, ALLOWED_EMAILS as gs, AUTH_CONFIG as Ss, GOOGLE_CLIENT_ID as Cs, getAgentBaseUrl as Is, getArtifactsBaseUrl as hs, getDotNetBaseUrl as ds, getIconByName as Ps, iconCategories as us, materialIcons as Es, searchIcons as vs, setEbiContextData as Ts, setEbiContextSessionId as ms } from "./utils.js";
13
- import { S as Rs, a as xs, b as Ms, c as ys, d as fs, e as Ds, f as Us, g as _s, h as ks, i as Bs, j as Vs, k as bs, l as Fs, p as Hs, m as Ns, s as Gs, o as Os, q as ws, t as Ws } from "./atMentions-DbE21rGt.js";
13
+ import { S as Rs, a as xs, b as Ms, c as ys, d as fs, e as Ds, f as Us, g as _s, h as ks, i as Bs, j as Vs, k as bs, l as Fs, p as Hs, m as Ns, s as Gs, o as Os, q as ws, t as Ws } from "./atMentions-uRBrCgLL.js";
14
14
  import { u as Js } from "./useChatSessions-BzgPYfyj.js";
15
15
  import { Score as js } from "./interfaces.js";
16
16
  export {
@@ -16,6 +16,7 @@ export interface MentionPickerPanelProps {
16
16
  onSelect: (item: AtMentionItem) => void;
17
17
  personLabel?: string;
18
18
  locationLabel?: string;
19
+ hotelLabel?: string;
19
20
  /** Shown while the list is empty and nothing is in flight. */
20
21
  emptyLabel?: string;
21
22
  /**
@@ -31,4 +32,4 @@ export interface MentionPickerPanelProps {
31
32
  */
32
33
  bottomInset?: number;
33
34
  }
34
- export declare function MentionPickerPanel({ open, anchorEl, startAtTopOfEl, items, loading, onSelect, personLabel, locationLabel, emptyLabel, maxHeightVh, bottomInset, }: MentionPickerPanelProps): import("react/jsx-runtime").JSX.Element | null;
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;
@@ -210,6 +210,8 @@ interface PromptV2Props {
210
210
  /** Section labels for the sectioned `@` dropdown (issue #112). Defaults to pt-BR ("Pessoas" / "Locais"). */
211
211
  atPersonLabel?: string;
212
212
  atLocationLabel?: string;
213
+ /** Section caption over the hotel-NAME rows of the `@` dropdown (Issue 1139). Default "Hotéis". */
214
+ atHotelLabel?: string;
213
215
  /** Sibling of `slashColor` for `#`-led tokens (rendered after the
214
216
  * user picks a date — `#YYYY-MM-DD` by default). */
215
217
  hashColor?: string;
@@ -8,9 +8,10 @@ export interface TriggerDropdownProps {
8
8
  onSelect: (item: AtMentionItem) => void;
9
9
  /** Show the "Carregando…" row while the first fetch is in flight. */
10
10
  loading?: boolean;
11
- /** Section labels for the sectioned `@` dropdown (issue #112). */
11
+ /** Section labels for the sectioned `@` dropdown (issue #112; the hotel-name section is Issue 1139). */
12
12
  personLabel?: string;
13
13
  locationLabel?: string;
14
+ hotelLabel?: string;
14
15
  /**
15
16
  * Touch metrics: 48px rows, 15px labels, a hairline between them. The caret-anchored popover stays compact
16
17
  * (a mouse can hit a 26px row and screen space next to the caret is scarce); a finger cannot.
@@ -36,4 +37,4 @@ export interface TriggerDropdownProps {
36
37
  * the browser fires `pointercancel` the moment it claims the gesture for scrolling, which is the authoritative
37
38
  * "this was a scroll, not a tap" signal. The slop check is a belt-and-braces for a shaky finger.
38
39
  */
39
- export declare function TriggerDropdown({ items, highlight, onHighlight, onSelect, loading, personLabel, locationLabel, touch, emptyLabel, sx, }: TriggerDropdownProps): import("react/jsx-runtime").JSX.Element;
40
+ export declare function TriggerDropdown({ items, highlight, onHighlight, onSelect, loading, personLabel, locationLabel, hotelLabel, touch, emptyLabel, sx, }: TriggerDropdownProps): import("react/jsx-runtime").JSX.Element;
@@ -40,8 +40,8 @@ export type AssistOutcome = {
40
40
  ghostAccepted: boolean;
41
41
  /** The `@` picker was opened at least once (host reports via noteAtOpened). */
42
42
  atOpened: boolean;
43
- /** Section of the last accepted `@` mention (host reports via noteAtAccepted). */
44
- atAccepted: 'person' | 'location' | null;
43
+ /** Section of the last accepted `@` mention (host reports via noteAtAccepted); 'hotel' = a hotel NAME row (Issue 1139). */
44
+ atAccepted: 'person' | 'location' | 'hotel' | null;
45
45
  /** The user typed `@` themselves while nothing assist-y was showing — a recall miss signal. */
46
46
  manualAt: boolean;
47
47
  };
@@ -99,7 +99,7 @@ export declare function usePromptAssist(adapter: PromptAssistAdapter, fetchers:
99
99
  setPredictionHighlight: import('react').Dispatch<import('react').SetStateAction<number>>;
100
100
  applyPrediction: (p: PredictionItem) => void;
101
101
  clearPredictions: () => void;
102
- hint: "location" | "person" | null;
102
+ hint: "person" | "location" | null;
103
103
  hintMidSentence: boolean;
104
104
  acceptHint: () => void;
105
105
  resolvedLocations: string[];
@@ -110,10 +110,12 @@ export declare function usePromptAssist(adapter: PromptAssistAdapter, fetchers:
110
110
  hotelExpected: boolean;
111
111
  hotelConfidence: number;
112
112
  vertical: SearchVertical;
113
+ hotelNameExpected: boolean;
114
+ hotelNameConfidence: number;
113
115
  scheduleAssist: (value: string, caret: number, isDeletion: boolean) => void;
114
116
  commit: (finalText: string) => void;
115
117
  onKeyDown: (e: KeyboardEvent<HTMLTextAreaElement>) => boolean;
116
118
  resetSession: () => void;
117
119
  noteAtOpened: () => void;
118
- noteAtAccepted: (group?: "person" | "location") => void;
120
+ noteAtAccepted: (group?: "person" | "location" | "hotel") => void;
119
121
  };
@@ -63,6 +63,17 @@ export interface PromptAnalysis {
63
63
  * PROMPT-level answer; this is the SLOT's — "vou sair de |" in a hotel prompt is air, "voo e hotel para o rio"
64
64
  * is both. Optional: an older server → derived from `hotelExpected` as before. */
65
65
  vertical?: 'air' | 'hotel' | 'both';
66
+ /** Issue 1139 — the lodging-PLACES head under its own name (it was `hotelExpected`/`hotelConfidence` above, which
67
+ * the server keeps sending with the SAME values for one release). New code reads these; absent on an older
68
+ * server → fall back to the hotel* pair. */
69
+ placesExpected?: boolean;
70
+ placesConfidence?: number;
71
+ /** Issue 1139 — the HOTEL-NAME head: P(the traveller is naming a specific hotel — "reserve o hotel |",
72
+ * "hospedagem no estabelecimento |") and the server's thresholded flag (0.5). Prompt-level like places, never a
73
+ * gate: when on, the `@` picker LEADS with catalog hotel names (TripApi `GET /hotel/names/search`), places and
74
+ * airports below. Absent on an older server → 0 / false. */
75
+ hotelNameExpected?: boolean;
76
+ hotelNameConfidence?: number;
66
77
  }
67
78
  /** Slow-path resolved date — `start`/`length` anchor the chip; `display` is e.g. "quarta 8 de Jul". */
68
79
  export interface ResolvedDate {
@@ -1,5 +1,8 @@
1
1
  import { PromptTriggerItem } from '../components/v2/PromptV2';
2
- export type MentionGroup = 'person' | 'location';
2
+ /** `'hotel'` (Issue 1139): rows the location source tagged `kind: 'hotel'` — catalog hotels by NAME — get their own
3
+ * section ("Hotéis") instead of hiding under "Locais", because they come from a different source (TripApi
4
+ * `GET /hotel/names/search`) and lead the list when the server's hotel-name head fires. */
5
+ export type MentionGroup = 'person' | 'location' | 'hotel';
3
6
  /** A trigger item tagged with the `@` section it belongs to. Undefined `group` ⇒ render flat (single source). */
4
7
  export type AtMentionItem = PromptTriggerItem & {
5
8
  group?: MentionGroup;
@@ -17,6 +20,10 @@ export interface AtQueryContext {
17
20
  * cut is where "weakest place outranks strongest airport" flips on one hundredth of a point. Undefined only
18
21
  * when the host predates this field. */
19
22
  hotelConfidence?: number;
23
+ /** The hotel-NAME head's score (Issue 1139): P(the traveller is naming a specific hotel — "reserve o hotel |").
24
+ * At or above the server's 0.5 the location source leads with catalog hotel names (`kind: 'hotel'` rows) and
25
+ * keeps places and airports below. Undefined when the host or the server predates the head. */
26
+ hotelNameConfidence?: number;
20
27
  }
21
28
  export interface AtMentionFetchers {
22
29
  /** Location source (airports / cities — or hotel places when `context.vertical` says so, issue #876). */
@@ -37,6 +44,8 @@ export interface AtMentionOptions {
37
44
  /** Hotel-intent confidence from the analyze pass, handed to the location source alongside `vertical` so it can
38
45
  * order its own two result sets by a score rather than by a verdict someone else thresholded. Default 0. */
39
46
  hotelConfidence?: number;
47
+ /** Hotel-NAME confidence from the analyze pass (Issue 1139), handed to the location source the same way. Default 0. */
48
+ hotelNameConfidence?: number;
40
49
  }
41
50
  /**
42
51
  * Fetch `@` mention items from whichever sources are wired, as one flat list. When BOTH a location and a person
@@ -46,6 +55,6 @@ export interface AtMentionOptions {
46
55
  * A single wired source returns an untagged flat list (unchanged behaviour). Each source is awaited in parallel and
47
56
  * failures are isolated: one source erroring never sinks the other.
48
57
  */
49
- export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold, vertical, hotelConfidence }?: AtMentionOptions): Promise<AtMentionItem[]>;
58
+ export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold, vertical, hotelConfidence, hotelNameConfidence }?: AtMentionOptions): Promise<AtMentionItem[]>;
50
59
  /** True when `items[idx]` opens a new `@` section (its group differs from the previous item's). */
51
60
  export declare function isSectionStart(items: AtMentionItem[], idx: number): boolean;
@@ -16,6 +16,6 @@ export type { HighlightToken } from './promptHighlight';
16
16
  export { placeCaret } from './placeCaret';
17
17
  export { swallowNextClick } from './swallowNextClick';
18
18
  export { detectTrigger, applyTriggerInsertion, findPlaceholder, placeholderAt, activatePlaceholder, advanceToPlaceholder, } from './promptTriggers';
19
- export type { TriggerChar, ActiveTrigger, TriggerInsertion, TemplatePlaceholder } from './promptTriggers';
19
+ export type { TriggerChar, ActiveTrigger, TriggerInsertion, TemplatePlaceholder, MentionKind } from './promptTriggers';
20
20
  export { fetchAtMentions, isSectionStart } from './atMentions';
21
21
  export type { AtMentionItem, MentionGroup, AtMentionFetchers, AtMentionOptions, AtQueryContext, AtQueryVertical } from './atMentions';
@@ -9,11 +9,23 @@ export type TriggerChar = '/' | '@' | '#';
9
9
  * - a `[bracketed placeholder]` is left SELECTED so the next keystroke overwrites it;
10
10
  * - a value ENDING in `@` / `#` re-opens that picker instead of appending a trailing space.
11
11
  */
12
+ /**
13
+ * What a `@` row IS (Issue 1139) — the dropdown draws one icon per kind so a traveller can tell an airport from a
14
+ * neighbourhood from a hotel from a colleague at a glance, now that one list mixes all four. Set by the SOURCE that
15
+ * produced the row (it knows); undefined renders the row as before, without an icon.
16
+ * 'airport' — an airport or a metro/city code from the air index ("(GRU) Guarulhos");
17
+ * 'place' — a lodging place: city, neighbourhood, avenue, landmark (the places typeahead);
18
+ * 'hotel' — a specific hotel from the catalog, by name (the hotel-name typeahead);
19
+ * 'person' — a traveller / colleague from the directory.
20
+ */
21
+ export type MentionKind = 'airport' | 'place' | 'hotel' | 'person';
12
22
  export type PromptTriggerItem = {
13
23
  id: string;
14
24
  label: string;
15
25
  value: string;
16
26
  hint?: string;
27
+ /** See {@link MentionKind}. Optional — a source that predates it renders without an icon. */
28
+ kind?: MentionKind;
17
29
  };
18
30
  /** The trigger token currently under the caret. `startIdx` is the index of the trigger char itself. */
19
31
  export type ActiveTrigger = {
@@ -0,0 +1,310 @@
1
+ var xe = Object.defineProperty;
2
+ var y = (r, C) => xe(r, "name", { value: C, configurable: !0 });
3
+ import { useState as f, useRef as o, useCallback as T, useEffect as ct } from "react";
4
+ const Ft = /* @__PURE__ */ y((r) => r.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), "foldForCompare"), Kt = /* @__PURE__ */ y((r) => r.vertical ?? (Gt(r) ? "hotel" : "air"), "verticalOf"), Gt = /* @__PURE__ */ y((r) => r.placesExpected ?? r.hotelExpected ?? !1, "lodgingOf"), zt = /* @__PURE__ */ y((r) => r.placesConfidence ?? r.hotelConfidence ?? 0, "lodgingScoreOf"), $e = /* @__PURE__ */ y((r) => r === "hotel" ? "Hotéis e locais" : r === "air" ? "Aeroportos" : void 0, "sectionLabel"), vt = /* @__PURE__ */ y(() => ({
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"), Mt = /* @__PURE__ */ y(() => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`, "newSessionId"), Ut = /* @__PURE__ */ y((r, C, b) => {
16
+ var s;
17
+ const R = r.length;
18
+ let i = C;
19
+ for (let x = 0; x < R; x++)
20
+ if (i = (i + b + R) % R, !((s = r[i]) != null && s.disabled)) return i;
21
+ return C;
22
+ }, "nextEnabledIndex");
23
+ function we(r, C, b = {}) {
24
+ const { debugGhostKey: R } = b, [i, s] = f(null), [x, A] = f(null), [I, K] = f(!1), [st, z] = f(0), [Wt, Bt] = f(0), [_t, jt] = f(!1), [Qt, Vt] = f("air"), [Xt, Zt] = f(0), [Jt, Yt] = f(!1), [te, ee] = f(0), [ne, it] = f(!1), [lt, N] = f(0), [re, Rt] = f([]), [oe, kt] = f([]), [ce, at] = f(""), Z = o(""), M = o(null), U = o(r);
25
+ U.current = r;
26
+ const q = o(C);
27
+ q.current = C;
28
+ const ut = o(b);
29
+ ut.current = b;
30
+ const G = o(null), W = o(null), wt = o(0), bt = o(0), ft = o(null), J = o(""), B = o(null), dt = o(null), ht = o(Mt()), _ = o(null);
31
+ _.current = i;
32
+ const Y = o(null);
33
+ Y.current = x;
34
+ const j = o(0), tt = o(null), Q = o(!1), se = 8, ie = 0.5, V = o(null), Tt = o(""), At = o(() => {
35
+ }), P = o(vt()), L = o(!1), le = T(() => s(null), []), ae = T(() => {
36
+ Rt([]), kt([]), at(""), Z.current = "", B.current = null, ht.current = Mt(), P.current = vt(), L.current = !1, j.current = 0, tt.current = null, Q.current = !1, A(null);
37
+ }, []), gt = T((t) => {
38
+ if (t.disabled) return;
39
+ P.current.suggestionAccepted = !0, t.kind === "location" && (L.current = !0), s(null);
40
+ const n = U.current, u = n.getTextarea();
41
+ if (!u) return;
42
+ const g = u.selectionStart ?? u.value.length, p = u.value.slice(0, g), D = u.value.slice(g), S = t.kind === "namedLocation" || t.kind === "location";
43
+ let e;
44
+ if (S) {
45
+ const a = Tt.current, h = p.replace(/\s+$/, "");
46
+ e = a && h.endsWith(a) ? h.slice(0, h.length - a.length) : p;
47
+ } else {
48
+ const a = p.search(/\S+$/), h = a === -1 ? "" : p.slice(a);
49
+ e = h.length > 0 && (t.kind === "date" && t.insert ? Ft(t.insert).startsWith(Ft(h)) : /^[\d./-]+$/.test(h)) ? p.slice(0, a) : p;
50
+ }
51
+ const d = e.length > 0 && !/\s$/.test(e);
52
+ if (t.kind === "date") {
53
+ const a = `${d ? " " : ""}${t.insert} `, h = `${e}${a}${D}`;
54
+ n.setDraft(h), n.focusCaret(e.length + a.length), J.current = h, B.current = null, At.current();
55
+ return;
56
+ }
57
+ if (t.kind === "namedLocation" && t.insert) {
58
+ const a = `@${t.insert.replace(/ /g, " ")}`, h = `${d ? " " : ""}${a} `;
59
+ n.setDraft(`${e}${h}${D}`), n.focusCaret(e.length + h.length);
60
+ return;
61
+ }
62
+ const l = t.kind === "location" ? "@" : "#", v = `${d ? " " : ""}${l}`;
63
+ n.setDraft(`${e}${v}${D}`), n.focusCaret(e.length + v.length), requestAnimationFrame(() => {
64
+ const a = n.getTextarea();
65
+ a && n.syncTrigger(a);
66
+ });
67
+ }, []), pt = T(async () => {
68
+ var p;
69
+ const t = q.current.resolveDates;
70
+ if (!t) return;
71
+ const n = J.current;
72
+ if (n.trim() === "") {
73
+ B.current = null;
74
+ return;
75
+ }
76
+ if (n === B.current || n.split(" ").length <= 2) return;
77
+ B.current = n, (p = dt.current) == null || p.abort();
78
+ const g = new AbortController();
79
+ dt.current = g;
80
+ try {
81
+ const { dates: D, locations: S } = await t(n, ht.current, g.signal);
82
+ if (J.current !== n) return;
83
+ const e = D.filter((l) => l.display).map((l) => ({ text: l.text, display: l.display }));
84
+ kt(e), Rt(S.map((l) => l.text).filter((l) => l.trim().length > 0));
85
+ const d = e.map((l) => `${l.text}=${l.display}`).join("|");
86
+ e.length > 0 && d !== Z.current && (Z.current = d, at(e[e.length - 1].text), M.current != null && window.clearTimeout(M.current), M.current = window.setTimeout(() => at(""), 2e3)), e.length === 0 && (Z.current = "");
87
+ } catch {
88
+ }
89
+ }, []);
90
+ At.current = pt;
91
+ const ue = T((t, n, u) => {
92
+ if (J.current = t, Y.current !== null && (j.current += 1, j.current >= se && (Q.current = !0, A(null))), t.split(" ").length <= 2) return;
93
+ const p = q.current.analyze;
94
+ p && (!u || _.current !== null || Y.current !== null) && (G.current != null && window.clearTimeout(G.current), G.current = window.setTimeout(async () => {
95
+ var S;
96
+ const D = ++wt.current;
97
+ try {
98
+ const e = await p(t, n);
99
+ if (D !== wt.current) return;
100
+ const d = U.current, l = d.getTextarea();
101
+ if (!l || l.value !== t) return;
102
+ Bt(e.personConfidence ?? 0), z(e.locationConfidence ?? 0), jt(Gt(e)), Vt(Kt(e)), Zt(zt(e)), Yt(e.hotelNameExpected ?? !1), ee(e.hotelNameConfidence ?? 0);
103
+ const v = P.current;
104
+ v.maxPersonConfidence = Math.max(v.maxPersonConfidence, e.personConfidence ?? 0), v.maxLocationConfidence = Math.max(v.maxLocationConfidence, e.locationConfidence ?? 0), v.maxHotelConfidence = Math.max(v.maxHotelConfidence ?? 0, zt(e)), A(null);
105
+ const a = l.selectionStart ?? n, h = a === t.length, yt = t.slice(0, a), pe = t.slice(a), St = !h && /\s$/.test(yt) && !/^\s*@/.test(pe), Ct = h || St, xt = d.hasAtQuery, Et = d.isPickerOpen(), Pt = e.suggestions ?? [], { enableHashDatePicker: Dt = !1, datePresets: me = ["amanhã de manhã", "quarta-feira à noite"] } = ut.current;
106
+ let k = e.category === "location" ? "location" : e.category === "date" ? "date" : e.locationExpected ? "location" : e.dateExpected ? "date" : null;
107
+ k !== "location" && e.locationCount < 2 && q.current.suggest && _.current !== null && V.current === "location" && Ct && /\s$/.test(yt) && (k = "location");
108
+ const Ht = e.secondary ?? "";
109
+ let F = Dt && xt && (k === "location" && Ht === "date" || k === "date" && Ht === "location");
110
+ if (F && e.locationCount >= 2 && e.locationPartialEmpty && (F = !1, k = "date"), ut.current.promptHint && Ct && !Et) {
111
+ const c = e.personConfidence ?? 0, E = e.locationConfidence ?? 0, X = k === "location" && !F && !(e.locationCount >= 2 && e.locationPartialEmpty), w = c >= ie && c >= E ? "person" : X ? "location" : null;
112
+ if (w) {
113
+ Q.current || (tt.current = w, K(St), A(w), v.ghostShown = !0, w === "location" && (v.locationGateFired = !0)), s(null), V.current = null;
114
+ return;
115
+ }
116
+ tt.current = null;
117
+ }
118
+ if (k === "location" && e.locationCount >= 2 && e.locationPartialEmpty) {
119
+ s(null), V.current = null;
120
+ return;
121
+ }
122
+ if (k === null || !(Ct && !Et && (k === "location" ? xt : k === "date"))) {
123
+ s(null), V.current = null;
124
+ return;
125
+ }
126
+ const $ = F ? "location" : k;
127
+ V.current = $, $ === "location" && (v.locationGateFired = !0);
128
+ const et = /* @__PURE__ */ y(() => ($ === "date" || F) && Dt ? [{ key: "cal", label: "# [Selecione...]", kind: "calendar" }] : [], "datePickerHead"), It = Pt.filter((c) => c.kind === "location"), Lt = Pt.filter((c) => c.kind === "date").map((c) => c.value), H = [];
129
+ if ($ === "location") {
130
+ H.push(...et());
131
+ for (const c of It)
132
+ H.push({ key: `loc:${c.value}`, label: `📍 ${c.label}`, kind: "namedLocation", insert: c.value });
133
+ } else {
134
+ H.push(...et());
135
+ for (const c of Lt.length > 0 ? Lt : me)
136
+ H.push({ key: `date:${c}`, label: `📅 ${c}`, kind: "date", insert: c });
137
+ }
138
+ const nt = q.current.suggest, ye = $ === "location" ? It.length > 0 : !0;
139
+ if ($ === "location" && !ye && !nt && !F) {
140
+ if (!u && e.locationExpected && e.locationPartialEmpty && e.locationCount < 2 && xt && d.currentTriggerChar() !== "@") {
141
+ const c = l.selectionStart ?? t.length, E = t.slice(0, c), X = E.length > 0 && !/\s$/.test(E);
142
+ if (!E.endsWith("@")) {
143
+ const w = X ? " @" : "@";
144
+ L.current = !0, s(null), d.setDraft(`${E}${w}${t.slice(c)}`), d.focusCaret(c + w.length), requestAnimationFrame(() => {
145
+ const rt = d.getTextarea();
146
+ rt && d.syncTrigger(rt);
147
+ });
148
+ }
149
+ return;
150
+ }
151
+ s(null);
152
+ return;
153
+ }
154
+ if (nt ? _.current === null && H.length > 0 && (N(0), it(!0), s(H)) : H.length > 0 ? (N(0), it(!0), s(H)) : s(null), nt) {
155
+ const c = t.slice(0, l.selectionStart ?? t.length), E = c.search(/[ \t\r\n](?=[^ \t\r\n]*$)/), X = E === -1 ? c : c.slice(E + 1), w = $ === "location" && e.locationPartial !== void 0 ? e.locationPartial : X;
156
+ $ === "location" && (Tt.current = w);
157
+ const rt = $ === "location" ? [...t.matchAll(/@\(([A-Za-z]{3})\)/g)].map((ot) => ot[1].toUpperCase()) : void 0, Ce = ++bt.current;
158
+ (S = ft.current) == null || S.abort();
159
+ const Ot = new AbortController();
160
+ ft.current = Ot;
161
+ try {
162
+ const ot = $ === "location" ? Kt(e) : "air", $t = await nt(w, $, Ot.signal, rt, ot);
163
+ if (Ce !== bt.current) return;
164
+ const Nt = d.getTextarea();
165
+ if (!Nt || Nt.value !== t || $ === "location" && $t.length === 0) return;
166
+ const O = [];
167
+ if ($ === "location") {
168
+ O.push(...et());
169
+ for (const m of $t)
170
+ O.push({
171
+ key: `loc:${m.insert}`,
172
+ label: `📍 ${m.label}`,
173
+ kind: "namedLocation",
174
+ insert: m.insert,
175
+ hint: [m.iata, m.region, m.country].filter(Boolean).join(" · ") || void 0,
176
+ // parity with the `@` picker
177
+ disabled: m.disabled,
178
+ // already in the prompt (same city) — greyed, not pickable
179
+ section: ot === "both" ? $e(m.source) : void 0
180
+ // 'both' → sectioned list
181
+ });
182
+ } else {
183
+ O.push(...et());
184
+ for (const m of $t)
185
+ O.push({ key: `date:${m.insert}`, label: `📅 ${m.label}`, kind: "date", insert: m.insert });
186
+ }
187
+ if (O.length === 0) {
188
+ s(null);
189
+ return;
190
+ }
191
+ const qt = O.findIndex((m) => !m.disabled);
192
+ N(qt < 0 ? 0 : qt), it(w.trim() === ""), s(O);
193
+ } catch {
194
+ }
195
+ }
196
+ } catch {
197
+ }
198
+ }, 200)), W.current != null && window.clearTimeout(W.current), W.current = window.setTimeout(() => {
199
+ pt();
200
+ }, 300);
201
+ }, [pt]), fe = T((t) => {
202
+ var u, g;
203
+ const n = t.trim();
204
+ n && ((g = (u = q.current).commitIntent) == null || g.call(u, n, ht.current, P.current)), P.current = vt(), L.current = !1;
205
+ }, []), de = T(() => {
206
+ const t = P.current;
207
+ t.atOpened = !0, L.current ? L.current = !1 : Y.current === null && _.current === null && (t.manualAt = !0);
208
+ }, []), he = T((t) => {
209
+ P.current.atAccepted = t ?? "location";
210
+ }, []), mt = T(() => {
211
+ P.current.ghostAccepted = !0, L.current = !0, j.current = 0, tt.current = null, A(null);
212
+ const t = U.current, n = t.getTextarea();
213
+ if (!n) return;
214
+ const u = n.selectionStart ?? n.value.length, g = n.value.slice(0, u), p = n.value.slice(u), S = `${g.length > 0 && !/\s$/.test(g) ? " " : ""}@`;
215
+ t.setDraft(`${g}${S}${p}`), t.focusCaret(u + S.length), requestAnimationFrame(() => {
216
+ const e = t.getTextarea();
217
+ e && t.syncTrigger(e);
218
+ });
219
+ }, []), ge = T((t) => {
220
+ if (R && t.key === R && !t.ctrlKey && !t.metaKey && !t.altKey) {
221
+ t.preventDefault();
222
+ const n = U.current.getTextarea(), u = (n == null ? void 0 : n.selectionStart) ?? (n == null ? void 0 : n.value.length) ?? 0, g = n ? n.value.slice(u) : "";
223
+ return Q.current = !1, j.current = 0, K(g.trim().length > 0), A(x === "location" ? "person" : "location"), !0;
224
+ }
225
+ if (x !== null && (!i || i.length === 0)) {
226
+ if (t.key === "Tab" || t.key === "ArrowRight" && !I)
227
+ return t.preventDefault(), mt(), !0;
228
+ if (t.key === "Escape")
229
+ return t.preventDefault(), Q.current = !0, A(null), !0;
230
+ }
231
+ if (!i || i.length === 0) return !1;
232
+ if (t.key === "ArrowDown")
233
+ return t.preventDefault(), N((n) => Ut(i, n, 1)), !0;
234
+ if (t.key === "ArrowUp")
235
+ return t.preventDefault(), N((n) => Ut(i, n, -1)), !0;
236
+ if (t.key === "Enter" || t.key === "Tab") {
237
+ t.preventDefault();
238
+ const n = i[lt];
239
+ return n && !n.disabled && gt(n), !0;
240
+ }
241
+ return t.key === "Escape" ? (t.preventDefault(), s(null), !0) : !1;
242
+ }, [i, lt, gt, x, I, mt, R]);
243
+ return ct(() => () => {
244
+ var t, n;
245
+ G.current != null && window.clearTimeout(G.current), W.current != null && window.clearTimeout(W.current), M.current != null && window.clearTimeout(M.current), (t = dt.current) == null || t.abort(), (n = ft.current) == null || n.abort();
246
+ }, []), {
247
+ predictions: i,
248
+ predictionsRecents: ne,
249
+ predictionHighlight: lt,
250
+ setPredictionHighlight: N,
251
+ applyPrediction: gt,
252
+ clearPredictions: le,
253
+ hint: x,
254
+ hintMidSentence: I,
255
+ acceptHint: mt,
256
+ resolvedLocations: re,
257
+ resolvedDates: oe,
258
+ forceTooltipText: ce,
259
+ personConfidence: Wt,
260
+ locationConfidence: st,
261
+ hotelExpected: _t,
262
+ hotelConfidence: Xt,
263
+ vertical: Qt,
264
+ hotelNameExpected: Jt,
265
+ hotelNameConfidence: te,
266
+ scheduleAssist: ue,
267
+ commit: fe,
268
+ onKeyDown: ge,
269
+ resetSession: ae,
270
+ noteAtOpened: de,
271
+ noteAtAccepted: he
272
+ };
273
+ }
274
+ y(we, "usePromptAssist");
275
+ function be(r, C) {
276
+ const b = o(r), [R, i] = f(null);
277
+ return ct(() => {
278
+ b.current = r;
279
+ }, [r]), ct(() => {
280
+ function s() {
281
+ b.current();
282
+ }
283
+ if (y(s, "tick"), C !== null) {
284
+ const x = setInterval(s, C);
285
+ return i(x), () => {
286
+ clearInterval(x);
287
+ };
288
+ }
289
+ }, [C]), R;
290
+ }
291
+ y(be, "useInterval");
292
+ function Te(r, C, b = 0, R = 0) {
293
+ const [i, s] = f(b), [x, A] = f(R);
294
+ return ct(() => {
295
+ const I = r.current;
296
+ if (!I) return;
297
+ const K = new ResizeObserver((st) => {
298
+ const z = st[0];
299
+ z && (A(z.contentRect.height), s(z.contentRect.width));
300
+ });
301
+ return K.observe(I), s(I.getBoundingClientRect().width), () => K.disconnect();
302
+ }, [r, C]), [i, x];
303
+ }
304
+ y(Te, "useContainerRectangle");
305
+ export {
306
+ be as a,
307
+ we as b,
308
+ Te as u
309
+ };
310
+ //# sourceMappingURL=useContainerWidth-RyWSI8nV.js.map