@aintela/chat 0.4.2 → 0.4.4
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/{atMentions-BhAwZTm1.js → atMentions-DrCm42jN.js} +29 -29
- package/dist/{atMentions-BhAwZTm1.js.map → atMentions-DrCm42jN.js.map} +1 -1
- package/dist/components.js +2099 -2092
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.js +2 -2
- package/dist/src/components/v2/PromptGhostHint.d.ts +4 -1
- package/dist/src/components/v2/PromptV2.d.ts +7 -2
- package/dist/src/hooks/index.d.ts +1 -1
- package/dist/src/hooks/usePromptAssist.d.ts +12 -1
- package/dist/src/hooks/usePromptAssist.test.d.ts +1 -0
- package/dist/src/services/httpPromptAssistService.d.ts +9 -0
- package/dist/src/utils/atMentions.d.ts +14 -3
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/useContainerWidth-Sc_u2QxD.js +299 -0
- package/dist/useContainerWidth-Sc_u2QxD.js.map +1 -0
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/useContainerWidth-B40_i-NW.js +0 -295
- package/dist/useContainerWidth-B40_i-NW.js.map +0 -1
package/dist/hooks.js
CHANGED
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-BnNVSRID.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-
|
|
10
|
+
import { u as Zt, a as Yt, b as Qt } from "./useContainerWidth-Sc_u2QxD.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-
|
|
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-DrCm42jN.js";
|
|
14
14
|
import { u as Js } from "./useChatSessions-eMttJ-qI.js";
|
|
15
15
|
import { Score as js } from "./interfaces.js";
|
|
16
16
|
export {
|
|
@@ -5,7 +5,10 @@ export interface PromptGhostHintProps {
|
|
|
5
5
|
onAccept: () => void;
|
|
6
6
|
/** Phone-sized host — shorter labels ("@ local" / "@ pessoa") so the ghost fits a 375px line. */
|
|
7
7
|
compact?: boolean;
|
|
8
|
+
/** The caret is MID-SENTENCE (the user is editing an existing prompt). The phantom is an overlay at the caret,
|
|
9
|
+
* so a full label would paint over the words that follow — show just "@ …" + the badge. Wins over `compact`. */
|
|
10
|
+
midSentence?: boolean;
|
|
8
11
|
/** Match the host textarea's font size so the phantom sits on the text baseline. */
|
|
9
12
|
fontSize?: number;
|
|
10
13
|
}
|
|
11
|
-
export declare function PromptGhostHint({ kind, onAccept, compact, fontSize }: PromptGhostHintProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function PromptGhostHint({ kind, onAccept, compact, midSentence, fontSize }: PromptGhostHintProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { AtQueryContext } from '../../utils/atMentions';
|
|
2
3
|
import { PromptTriggerItem } from '../../utils/promptTriggers';
|
|
3
4
|
import { PromptAnalysis, PromptResolution, SuggestItem } from '../../services/httpPromptAssistService';
|
|
4
5
|
export type { PromptTriggerItem } from '../../utils/promptTriggers';
|
|
@@ -156,9 +157,13 @@ interface PromptV2Props {
|
|
|
156
157
|
* Sibling of `onSlashQuery` for the `@` trigger — typically used
|
|
157
158
|
* for mentions. Kept as a separate prop (rather than one
|
|
158
159
|
* trigger-aware callback) so hosts that only wire one of the two
|
|
159
|
-
* don't have to branch internally.
|
|
160
|
+
* don't have to branch internally. The optional `context` (issue #876)
|
|
161
|
+
* carries the search vertical from the server's hotel-intent head —
|
|
162
|
+
* 'hotel' means the location being typed is lodging, so the source
|
|
163
|
+
* should serve hotel places (POIs, addresses) instead of airports.
|
|
164
|
+
* Hosts that ignore it keep today's airports-only behavior.
|
|
160
165
|
*/
|
|
161
|
-
onAtQuery?: (query: string) => Promise<PromptTriggerItem[]>;
|
|
166
|
+
onAtQuery?: (query: string, context?: AtQueryContext) => Promise<PromptTriggerItem[]>;
|
|
162
167
|
/**
|
|
163
168
|
* Issue #112 — person/passenger source for the `@` trigger (e.g. a company-directory search). When wired, an
|
|
164
169
|
* active `@` fetches BOTH this and `onAtQuery` and shows a **sectioned** dropdown (Pessoas / Locais). The
|
|
@@ -3,4 +3,4 @@ export { useContainerRectangle } from './useContainerWidth';
|
|
|
3
3
|
export { useChatSessions } from './useChatSessions';
|
|
4
4
|
export type { UseChatSessionsOptions, UseChatSessionsResult, ChatSessionListItem, ChatSessionGroup, } from './useChatSessions';
|
|
5
5
|
export { usePromptAssist } from './usePromptAssist';
|
|
6
|
-
export type { PredictionItem, ResolvedDateItem, PromptAssistAdapter, PromptAssistFetchers, PromptAssistOptions, AssistOutcome, } from './usePromptAssist';
|
|
6
|
+
export type { PredictionItem, ResolvedDateItem, PromptAssistAdapter, PromptAssistFetchers, PromptAssistOptions, AssistOutcome, SearchVertical, } from './usePromptAssist';
|
|
@@ -26,6 +26,9 @@ export type AssistOutcome = {
|
|
|
26
26
|
maxLocationConfidence: number;
|
|
27
27
|
/** Highest person-intent confidence any analyze reported while composing. */
|
|
28
28
|
maxPersonConfidence: number;
|
|
29
|
+
/** Highest hotel-vertical confidence any analyze reported while composing (issue #876). Optional so an
|
|
30
|
+
* outcome built by an older client shape still satisfies the type. */
|
|
31
|
+
maxHotelConfidence?: number;
|
|
29
32
|
/** Location assist became VISIBLE at least once (dropdown, location ghost, or auto-`@`). */
|
|
30
33
|
locationGateFired: boolean;
|
|
31
34
|
/** The user accepted an item from the predictions dropdown. */
|
|
@@ -55,11 +58,16 @@ export interface PromptAssistAdapter {
|
|
|
55
58
|
/** Whether the `@` location fetcher is wired (else no auto-`@` / generic "Local…"). */
|
|
56
59
|
hasAtQuery: boolean;
|
|
57
60
|
}
|
|
61
|
+
/** Which vertical a location slot is searching (issue #876). Steers the source: airports vs hotel places. */
|
|
62
|
+
export type SearchVertical = 'air' | 'hotel';
|
|
58
63
|
export interface PromptAssistFetchers {
|
|
59
64
|
analyze?: (text: string, caret: number) => Promise<PromptAnalysis>;
|
|
60
65
|
resolveDates?: (text: string, sessionId?: string, signal?: AbortSignal) => Promise<PromptResolution>;
|
|
61
66
|
commitIntent?: (text: string, sessionId?: string, assist?: AssistOutcome) => void;
|
|
62
|
-
|
|
67
|
+
/** `vertical` (issue #876) says whether the location being searched is LODGING ('hotel') or a flight place
|
|
68
|
+
* ('air', the default) — sourced from the server's hotel-intent head, never re-decided client-side. Hosts that
|
|
69
|
+
* ignore the extra parameter keep today's airports-only behavior. */
|
|
70
|
+
suggest?: (q: string, kind: 'location' | 'date' | 'both', signal?: AbortSignal, exclude?: string[], vertical?: SearchVertical) => Promise<SuggestItem[]>;
|
|
63
71
|
}
|
|
64
72
|
export interface PromptAssistOptions {
|
|
65
73
|
enableHashDatePicker?: boolean;
|
|
@@ -83,12 +91,15 @@ export declare function usePromptAssist(adapter: PromptAssistAdapter, fetchers:
|
|
|
83
91
|
applyPrediction: (p: PredictionItem) => void;
|
|
84
92
|
clearPredictions: () => void;
|
|
85
93
|
hint: "location" | "person" | null;
|
|
94
|
+
hintMidSentence: boolean;
|
|
86
95
|
acceptHint: () => void;
|
|
87
96
|
resolvedLocations: string[];
|
|
88
97
|
resolvedDates: ResolvedDateItem[];
|
|
89
98
|
forceTooltipText: string;
|
|
90
99
|
personConfidence: number;
|
|
91
100
|
locationConfidence: number;
|
|
101
|
+
hotelExpected: boolean;
|
|
102
|
+
hotelConfidence: number;
|
|
92
103
|
scheduleAssist: (value: string, caret: number, isDeletion: boolean) => void;
|
|
93
104
|
commit: (finalText: string) => void;
|
|
94
105
|
onKeyDown: (e: KeyboardEvent<HTMLTextAreaElement>) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -40,6 +40,15 @@ export interface PromptAnalysis {
|
|
|
40
40
|
/** P(the prompt is a flight/place search) from the location-intent classifier. Drives the phantom "@ Localidade"
|
|
41
41
|
* cue and biases the `@` picker toward Locais when location outweighs person. Optional (older server → 0). */
|
|
42
42
|
locationConfidence?: number;
|
|
43
|
+
/** P(the token typed next is a DATE) from the server's date head (2026-09-02). Telemetry/awareness only — the
|
|
44
|
+
* server already applied its threshold to produce `dateExpected`/`category`. Optional (older server → absent). */
|
|
45
|
+
dateConfidence?: number;
|
|
46
|
+
/** Issue #876 — the search VERTICAL: is the place being sought LODGING (hotel-only or air+hotel)? It never gates
|
|
47
|
+
* the dropdown by itself — it steers the `@` / suggest source toward hotel places instead of airports.
|
|
48
|
+
* `hotelExpected` is the server's thresholded flag (the client does not re-decide); `hotelConfidence` ∈ [0,1].
|
|
49
|
+
* Both optional for back-compat with a server that predates the hotel head (absent → air, as before). */
|
|
50
|
+
hotelExpected?: boolean;
|
|
51
|
+
hotelConfidence?: number;
|
|
43
52
|
}
|
|
44
53
|
/** Slow-path resolved date — `start`/`length` anchor the chip; `display` is e.g. "quarta 8 de Jul". */
|
|
45
54
|
export interface ResolvedDate {
|
|
@@ -4,9 +4,18 @@ export type MentionGroup = 'person' | 'location';
|
|
|
4
4
|
export type AtMentionItem = PromptTriggerItem & {
|
|
5
5
|
group?: MentionGroup;
|
|
6
6
|
};
|
|
7
|
+
/** Which vertical the location source should search (issue #876): 'hotel' → hotel places (POIs, addresses,
|
|
8
|
+
* landmarks — TripApi /hotel/locations/search), 'air' → airports/cities as before. From the server's hotel-intent
|
|
9
|
+
* head via the analyze pass — never re-decided client-side. */
|
|
10
|
+
export type AtQueryVertical = 'air' | 'hotel';
|
|
11
|
+
/** Context handed to the location source alongside the query (issue #876). A second PARAMETER (not a second
|
|
12
|
+
* fetcher) so hosts that don't care keep compiling untouched — a function with fewer params is assignable. */
|
|
13
|
+
export interface AtQueryContext {
|
|
14
|
+
vertical: AtQueryVertical;
|
|
15
|
+
}
|
|
7
16
|
export interface AtMentionFetchers {
|
|
8
|
-
/** Location source (airports / cities). */
|
|
9
|
-
onAtQuery?: (query: string) => Promise<PromptTriggerItem[]>;
|
|
17
|
+
/** Location source (airports / cities — or hotel places when `context.vertical` says so, issue #876). */
|
|
18
|
+
onAtQuery?: (query: string, context?: AtQueryContext) => Promise<PromptTriggerItem[]>;
|
|
10
19
|
/** Person / passenger source (company directory). */
|
|
11
20
|
onAtPersonQuery?: (query: string) => Promise<PromptTriggerItem[]>;
|
|
12
21
|
}
|
|
@@ -18,6 +27,8 @@ export interface AtMentionOptions {
|
|
|
18
27
|
locationConfidence?: number;
|
|
19
28
|
/** Confidence at/above which the person section MAY lead (it still only wins if it also outweighs location). Default 0.5. */
|
|
20
29
|
personFirstThreshold?: number;
|
|
30
|
+
/** The search vertical for the location source (issue #876). Default 'air' — today's behavior. */
|
|
31
|
+
vertical?: AtQueryVertical;
|
|
21
32
|
}
|
|
22
33
|
/**
|
|
23
34
|
* Fetch `@` mention items from whichever sources are wired, as one flat list. When BOTH a location and a person
|
|
@@ -27,6 +38,6 @@ export interface AtMentionOptions {
|
|
|
27
38
|
* A single wired source returns an untagged flat list (unchanged behaviour). Each source is awaited in parallel and
|
|
28
39
|
* failures are isolated: one source erroring never sinks the other.
|
|
29
40
|
*/
|
|
30
|
-
export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold }?: AtMentionOptions): Promise<AtMentionItem[]>;
|
|
41
|
+
export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold, vertical }?: AtMentionOptions): Promise<AtMentionItem[]>;
|
|
31
42
|
/** True when `items[idx]` opens a new `@` section (its group differs from the previous item's). */
|
|
32
43
|
export declare function isSectionStart(items: AtMentionItem[], idx: number): boolean;
|
|
@@ -18,4 +18,4 @@ export { swallowNextClick } from './swallowNextClick';
|
|
|
18
18
|
export { detectTrigger, applyTriggerInsertion, findPlaceholder, placeholderAt, activatePlaceholder, advanceToPlaceholder, } from './promptTriggers';
|
|
19
19
|
export type { TriggerChar, ActiveTrigger, TriggerInsertion, TemplatePlaceholder } from './promptTriggers';
|
|
20
20
|
export { fetchAtMentions, isSectionStart } from './atMentions';
|
|
21
|
-
export type { AtMentionItem, MentionGroup, AtMentionFetchers, AtMentionOptions } from './atMentions';
|
|
21
|
+
export type { AtMentionItem, MentionGroup, AtMentionFetchers, AtMentionOptions, AtQueryContext, AtQueryVertical } from './atMentions';
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
var se = Object.defineProperty;
|
|
2
|
+
var b = (u, i) => se(u, "name", { value: i, configurable: !0 });
|
|
3
|
+
import { useState as h, useRef as r, useCallback as v, useEffect as nt } from "react";
|
|
4
|
+
const yt = /* @__PURE__ */ b(() => ({
|
|
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"), qt = /* @__PURE__ */ b(() => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`, "newSessionId"), Ot = /* @__PURE__ */ b((u, i, w) => {
|
|
16
|
+
var C;
|
|
17
|
+
const s = u.length;
|
|
18
|
+
let c = i;
|
|
19
|
+
for (let g = 0; g < s; g++)
|
|
20
|
+
if (c = (c + w + s) % s, !((C = u[c]) != null && C.disabled)) return c;
|
|
21
|
+
return i;
|
|
22
|
+
}, "nextEnabledIndex"), ie = /* @__PURE__ */ b((u) => {
|
|
23
|
+
const i = /* @__PURE__ */ new Date();
|
|
24
|
+
i.setDate(i.getDate() + u);
|
|
25
|
+
const w = String(i.getDate()).padStart(2, "0"), s = String(i.getMonth() + 1).padStart(2, "0");
|
|
26
|
+
return `${w}/${s}/${i.getFullYear()}`;
|
|
27
|
+
}, "plusDaysBR");
|
|
28
|
+
function fe(u, i, w = {}) {
|
|
29
|
+
const [s, c] = h(null), [C, g] = h(null), [O, F] = h(!1), [_, rt] = h(0), [M, Ft] = h(0), [Mt, zt] = h(!1), [Ut, Bt] = h(0), [Kt, ot] = h(!1), [ct, I] = h(0), [Gt, Ct] = h([]), [Nt, xt] = h([]), [Wt, st] = h(""), j = r(""), z = r(null), Q = r(u);
|
|
30
|
+
Q.current = u;
|
|
31
|
+
const L = r(i);
|
|
32
|
+
L.current = i;
|
|
33
|
+
const it = r(w);
|
|
34
|
+
it.current = w;
|
|
35
|
+
const U = r(null), B = r(null), Rt = r(0), wt = r(0), lt = r(null), X = r(""), K = r(null), at = r(null), ut = r(qt()), G = r(null);
|
|
36
|
+
G.current = s;
|
|
37
|
+
const Y = r(null);
|
|
38
|
+
Y.current = C;
|
|
39
|
+
const Z = r(0), J = r(null), V = r(!1), _t = 8, jt = 0.5, N = r(null), kt = r(""), bt = r(() => {
|
|
40
|
+
}), A = r(yt()), H = r(!1), Qt = v(() => c(null), []), Xt = v(() => {
|
|
41
|
+
Ct([]), xt([]), st(""), j.current = "", K.current = null, ut.current = qt(), A.current = yt(), H.current = !1, Z.current = 0, J.current = null, V.current = !1, g(null);
|
|
42
|
+
}, []), ft = v((t) => {
|
|
43
|
+
if (t.disabled) return;
|
|
44
|
+
A.current.suggestionAccepted = !0, t.kind === "location" && (H.current = !0), c(null);
|
|
45
|
+
const n = Q.current, f = n.getTextarea();
|
|
46
|
+
if (!f) return;
|
|
47
|
+
const p = f.selectionStart ?? f.value.length, m = f.value.slice(0, p), D = f.value.slice(p), T = t.kind === "namedLocation" || t.kind === "location";
|
|
48
|
+
let e;
|
|
49
|
+
if (T) {
|
|
50
|
+
const a = kt.current, R = m.replace(/\s+$/, "");
|
|
51
|
+
e = a && R.endsWith(a) ? R.slice(0, R.length - a.length) : m;
|
|
52
|
+
} else {
|
|
53
|
+
const a = m.search(/\S+$/);
|
|
54
|
+
e = a === -1 ? m : m.slice(0, a);
|
|
55
|
+
}
|
|
56
|
+
const d = e.length > 0 && !/\s$/.test(e);
|
|
57
|
+
if (t.kind === "date") {
|
|
58
|
+
const a = `${d ? " " : ""}${t.insert} `, R = `${e}${a}${D}`;
|
|
59
|
+
n.setDraft(R), n.focusCaret(e.length + a.length), X.current = R, K.current = null, bt.current();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (t.kind === "namedLocation" && t.insert) {
|
|
63
|
+
const a = `@${t.insert.replace(/ /g, " ")}`, R = `${d ? " " : ""}${a} `;
|
|
64
|
+
n.setDraft(`${e}${R}${D}`), n.focusCaret(e.length + R.length);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const l = t.kind === "location" ? "@" : "#", x = `${d ? " " : ""}${l}`;
|
|
68
|
+
n.setDraft(`${e}${x}${D}`), n.focusCaret(e.length + x.length), requestAnimationFrame(() => {
|
|
69
|
+
const a = n.getTextarea();
|
|
70
|
+
a && n.syncTrigger(a);
|
|
71
|
+
});
|
|
72
|
+
}, []), dt = v(async () => {
|
|
73
|
+
var m;
|
|
74
|
+
const t = L.current.resolveDates;
|
|
75
|
+
if (!t) return;
|
|
76
|
+
const n = X.current;
|
|
77
|
+
if (n.trim() === "") {
|
|
78
|
+
K.current = null;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (n === K.current || n.split(" ").length <= 2) return;
|
|
82
|
+
K.current = n, (m = at.current) == null || m.abort();
|
|
83
|
+
const p = new AbortController();
|
|
84
|
+
at.current = p;
|
|
85
|
+
try {
|
|
86
|
+
const { dates: D, locations: T } = await t(n, ut.current, p.signal);
|
|
87
|
+
if (X.current !== n) return;
|
|
88
|
+
const e = D.filter((l) => l.display).map((l) => ({ text: l.text, display: l.display }));
|
|
89
|
+
xt(e), Ct(T.map((l) => l.text).filter((l) => l.trim().length > 0));
|
|
90
|
+
const d = e.map((l) => `${l.text}=${l.display}`).join("|");
|
|
91
|
+
e.length > 0 && d !== j.current && (j.current = d, st(e[e.length - 1].text), z.current != null && window.clearTimeout(z.current), z.current = window.setTimeout(() => st(""), 2e3)), e.length === 0 && (j.current = "");
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
}, []);
|
|
95
|
+
bt.current = dt;
|
|
96
|
+
const Yt = v((t, n, f) => {
|
|
97
|
+
if (X.current = t, Y.current !== null && (Z.current += 1, Z.current >= _t && (V.current = !0, g(null))), t.split(" ").length <= 2) return;
|
|
98
|
+
const m = L.current.analyze;
|
|
99
|
+
m && (!f || G.current !== null || Y.current !== null) && (U.current != null && window.clearTimeout(U.current), U.current = window.setTimeout(async () => {
|
|
100
|
+
var T;
|
|
101
|
+
const D = ++Rt.current;
|
|
102
|
+
try {
|
|
103
|
+
const e = await m(t, n);
|
|
104
|
+
if (D !== Rt.current) return;
|
|
105
|
+
const d = Q.current, l = d.getTextarea();
|
|
106
|
+
if (!l || l.value !== t) return;
|
|
107
|
+
Ft(e.personConfidence ?? 0), rt(e.locationConfidence ?? 0), zt(e.hotelExpected ?? !1), Bt(e.hotelConfidence ?? 0);
|
|
108
|
+
const x = A.current;
|
|
109
|
+
x.maxPersonConfidence = Math.max(x.maxPersonConfidence, e.personConfidence ?? 0), x.maxLocationConfidence = Math.max(x.maxLocationConfidence, e.locationConfidence ?? 0), x.maxHotelConfidence = Math.max(x.maxHotelConfidence ?? 0, e.hotelConfidence ?? 0), g(null);
|
|
110
|
+
const a = l.selectionStart ?? n, R = a === t.length, vt = t.slice(0, a), ee = t.slice(a), Tt = !R && /\s$/.test(vt) && !/^\s*@/.test(ee), gt = R || Tt, St = d.hasAtQuery, At = d.isPickerOpen(), Dt = e.suggestions ?? [], { enableHashDatePicker: ne = !1, datePresets: re = ["amanhã de manhã", "quarta-feira à noite"] } = it.current;
|
|
111
|
+
let P = e.category === "location" ? "location" : e.category === "date" ? "date" : e.locationExpected ? "location" : e.dateExpected ? "date" : null;
|
|
112
|
+
if (P !== "location" && e.locationCount < 2 && L.current.suggest && G.current !== null && N.current === "location" && gt && /\s$/.test(vt) && (P = "location"), it.current.promptHint && gt && !At) {
|
|
113
|
+
const o = e.personConfidence ?? 0, S = e.locationConfidence ?? 0, W = P === "location" && !(e.locationCount >= 2 && e.locationPartialEmpty), k = o >= jt && o >= S ? "person" : W ? "location" : null;
|
|
114
|
+
if (k) {
|
|
115
|
+
V.current || (J.current = k, F(Tt), g(k), x.ghostShown = !0, k === "location" && (x.locationGateFired = !0)), c(null), N.current = null;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
J.current = null;
|
|
119
|
+
}
|
|
120
|
+
if (P === "location" && e.locationCount >= 2 && e.locationPartialEmpty) {
|
|
121
|
+
c(null), N.current = null;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (P === null || !(gt && !At && (P === "location" ? St : P === "date"))) {
|
|
125
|
+
c(null), N.current = null;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const $ = P;
|
|
129
|
+
N.current = $, $ === "location" && (x.locationGateFired = !0);
|
|
130
|
+
const pt = /* @__PURE__ */ b(() => $ === "date" && ne ? [{ key: "cal", label: `📅 no dia #${ie(2)}`, kind: "calendar" }] : [], "genericTail"), Pt = Dt.filter((o) => o.kind === "location"), Et = Dt.filter((o) => o.kind === "date").map((o) => o.value), E = [];
|
|
131
|
+
if ($ === "location") {
|
|
132
|
+
for (const o of Pt)
|
|
133
|
+
E.push({ key: `loc:${o.value}`, label: `📍 ${o.label}`, kind: "namedLocation", insert: o.value });
|
|
134
|
+
E.push(...pt());
|
|
135
|
+
} else {
|
|
136
|
+
for (const o of Et.length > 0 ? Et : re)
|
|
137
|
+
E.push({ key: `date:${o}`, label: `📅 ${o}`, kind: "date", insert: o });
|
|
138
|
+
E.push(...pt());
|
|
139
|
+
}
|
|
140
|
+
const tt = L.current.suggest, oe = $ === "location" ? Pt.length > 0 : !0;
|
|
141
|
+
if ($ === "location" && !oe && !tt) {
|
|
142
|
+
if (!f && e.locationExpected && e.locationPartialEmpty && e.locationCount < 2 && St && d.currentTriggerChar() !== "@") {
|
|
143
|
+
const o = l.selectionStart ?? t.length, S = t.slice(0, o), W = S.length > 0 && !/\s$/.test(S);
|
|
144
|
+
if (!S.endsWith("@")) {
|
|
145
|
+
const k = W ? " @" : "@";
|
|
146
|
+
H.current = !0, c(null), d.setDraft(`${S}${k}${t.slice(o)}`), d.focusCaret(o + k.length), requestAnimationFrame(() => {
|
|
147
|
+
const et = d.getTextarea();
|
|
148
|
+
et && d.syncTrigger(et);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
c(null);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (tt ? G.current === null && E.length > 0 && (I(0), ot(!0), c(E)) : E.length > 0 ? (I(0), ot(!0), c(E)) : c(null), tt) {
|
|
157
|
+
const o = t.slice(0, l.selectionStart ?? t.length), S = o.search(/[ \t\r\n](?=[^ \t\r\n]*$)/), W = S === -1 ? o : o.slice(S + 1), k = $ === "location" && e.locationPartial !== void 0 ? e.locationPartial : W;
|
|
158
|
+
$ === "location" && (kt.current = k);
|
|
159
|
+
const et = $ === "location" ? [...t.matchAll(/@\(([A-Za-z]{3})\)/g)].map((mt) => mt[1].toUpperCase()) : void 0, ce = ++wt.current;
|
|
160
|
+
(T = lt.current) == null || T.abort();
|
|
161
|
+
const Ht = new AbortController();
|
|
162
|
+
lt.current = Ht;
|
|
163
|
+
try {
|
|
164
|
+
const mt = $ === "location" && (e.hotelExpected ?? !1) ? "hotel" : "air", $t = await tt(k, $, Ht.signal, et, mt);
|
|
165
|
+
if (ce !== wt.current) return;
|
|
166
|
+
const It = d.getTextarea();
|
|
167
|
+
if (!It || It.value !== t || $ === "location" && $t.length === 0) return;
|
|
168
|
+
const q = [];
|
|
169
|
+
if ($ === "location")
|
|
170
|
+
for (const y of $t)
|
|
171
|
+
q.push({
|
|
172
|
+
key: `loc:${y.insert}`,
|
|
173
|
+
label: `📍 ${y.label}`,
|
|
174
|
+
kind: "namedLocation",
|
|
175
|
+
insert: y.insert,
|
|
176
|
+
hint: [y.iata, y.region, y.country].filter(Boolean).join(" · ") || void 0,
|
|
177
|
+
// parity with the `@` picker
|
|
178
|
+
disabled: y.disabled
|
|
179
|
+
// already in the prompt (same city) — greyed, not pickable
|
|
180
|
+
});
|
|
181
|
+
else
|
|
182
|
+
for (const y of $t)
|
|
183
|
+
q.push({ key: `date:${y.insert}`, label: `📅 ${y.label}`, kind: "date", insert: y.insert });
|
|
184
|
+
if (q.push(...pt()), q.length === 0) {
|
|
185
|
+
c(null);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const Lt = q.findIndex((y) => !y.disabled);
|
|
189
|
+
I(Lt < 0 ? 0 : Lt), ot(k.trim() === ""), c(q);
|
|
190
|
+
} catch {
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} catch {
|
|
194
|
+
}
|
|
195
|
+
}, 200)), B.current != null && window.clearTimeout(B.current), B.current = window.setTimeout(() => {
|
|
196
|
+
dt();
|
|
197
|
+
}, 300);
|
|
198
|
+
}, [dt]), Zt = v((t) => {
|
|
199
|
+
var f, p;
|
|
200
|
+
const n = t.trim();
|
|
201
|
+
n && ((p = (f = L.current).commitIntent) == null || p.call(f, n, ut.current, A.current)), A.current = yt(), H.current = !1;
|
|
202
|
+
}, []), Jt = v(() => {
|
|
203
|
+
const t = A.current;
|
|
204
|
+
t.atOpened = !0, H.current ? H.current = !1 : Y.current === null && G.current === null && (t.manualAt = !0);
|
|
205
|
+
}, []), Vt = v((t) => {
|
|
206
|
+
A.current.atAccepted = t ?? "location";
|
|
207
|
+
}, []), ht = v(() => {
|
|
208
|
+
A.current.ghostAccepted = !0, H.current = !0, Z.current = 0, J.current = null, g(null);
|
|
209
|
+
const t = Q.current, n = t.getTextarea();
|
|
210
|
+
if (!n) return;
|
|
211
|
+
const f = n.selectionStart ?? n.value.length, p = n.value.slice(0, f), m = n.value.slice(f), T = `${p.length > 0 && !/\s$/.test(p) ? " " : ""}@`;
|
|
212
|
+
t.setDraft(`${p}${T}${m}`), t.focusCaret(f + T.length), requestAnimationFrame(() => {
|
|
213
|
+
const e = t.getTextarea();
|
|
214
|
+
e && t.syncTrigger(e);
|
|
215
|
+
});
|
|
216
|
+
}, []), te = v((t) => {
|
|
217
|
+
if (C !== null && (!s || s.length === 0)) {
|
|
218
|
+
if (t.key === "Tab" || t.key === "ArrowRight" && !O)
|
|
219
|
+
return t.preventDefault(), ht(), !0;
|
|
220
|
+
if (t.key === "Escape")
|
|
221
|
+
return t.preventDefault(), V.current = !0, g(null), !0;
|
|
222
|
+
}
|
|
223
|
+
if (!s || s.length === 0) return !1;
|
|
224
|
+
if (t.key === "ArrowDown")
|
|
225
|
+
return t.preventDefault(), I((n) => Ot(s, n, 1)), !0;
|
|
226
|
+
if (t.key === "ArrowUp")
|
|
227
|
+
return t.preventDefault(), I((n) => Ot(s, n, -1)), !0;
|
|
228
|
+
if (t.key === "Enter" || t.key === "Tab") {
|
|
229
|
+
t.preventDefault();
|
|
230
|
+
const n = s[ct];
|
|
231
|
+
return n && !n.disabled && ft(n), !0;
|
|
232
|
+
}
|
|
233
|
+
return t.key === "Escape" ? (t.preventDefault(), c(null), !0) : !1;
|
|
234
|
+
}, [s, ct, ft, C, O, ht]);
|
|
235
|
+
return nt(() => () => {
|
|
236
|
+
var t, n;
|
|
237
|
+
U.current != null && window.clearTimeout(U.current), B.current != null && window.clearTimeout(B.current), z.current != null && window.clearTimeout(z.current), (t = at.current) == null || t.abort(), (n = lt.current) == null || n.abort();
|
|
238
|
+
}, []), {
|
|
239
|
+
predictions: s,
|
|
240
|
+
predictionsRecents: Kt,
|
|
241
|
+
predictionHighlight: ct,
|
|
242
|
+
setPredictionHighlight: I,
|
|
243
|
+
applyPrediction: ft,
|
|
244
|
+
clearPredictions: Qt,
|
|
245
|
+
hint: C,
|
|
246
|
+
hintMidSentence: O,
|
|
247
|
+
acceptHint: ht,
|
|
248
|
+
resolvedLocations: Gt,
|
|
249
|
+
resolvedDates: Nt,
|
|
250
|
+
forceTooltipText: Wt,
|
|
251
|
+
personConfidence: M,
|
|
252
|
+
locationConfidence: _,
|
|
253
|
+
hotelExpected: Mt,
|
|
254
|
+
hotelConfidence: Ut,
|
|
255
|
+
scheduleAssist: Yt,
|
|
256
|
+
commit: Zt,
|
|
257
|
+
onKeyDown: te,
|
|
258
|
+
resetSession: Xt,
|
|
259
|
+
noteAtOpened: Jt,
|
|
260
|
+
noteAtAccepted: Vt
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
b(fe, "usePromptAssist");
|
|
264
|
+
function de(u, i) {
|
|
265
|
+
const w = r(u), [s, c] = h(null);
|
|
266
|
+
return nt(() => {
|
|
267
|
+
w.current = u;
|
|
268
|
+
}, [u]), nt(() => {
|
|
269
|
+
function C() {
|
|
270
|
+
w.current();
|
|
271
|
+
}
|
|
272
|
+
if (b(C, "tick"), i !== null) {
|
|
273
|
+
const g = setInterval(C, i);
|
|
274
|
+
return c(g), () => {
|
|
275
|
+
clearInterval(g);
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}, [i]), s;
|
|
279
|
+
}
|
|
280
|
+
b(de, "useInterval");
|
|
281
|
+
function he(u, i, w = 0, s = 0) {
|
|
282
|
+
const [c, C] = h(w), [g, O] = h(s);
|
|
283
|
+
return nt(() => {
|
|
284
|
+
const F = u.current;
|
|
285
|
+
if (!F) return;
|
|
286
|
+
const _ = new ResizeObserver((rt) => {
|
|
287
|
+
const M = rt[0];
|
|
288
|
+
M && (O(M.contentRect.height), C(M.contentRect.width));
|
|
289
|
+
});
|
|
290
|
+
return _.observe(F), C(F.getBoundingClientRect().width), () => _.disconnect();
|
|
291
|
+
}, [u, i]), [c, g];
|
|
292
|
+
}
|
|
293
|
+
b(he, "useContainerRectangle");
|
|
294
|
+
export {
|
|
295
|
+
de as a,
|
|
296
|
+
fe as b,
|
|
297
|
+
he as u
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=useContainerWidth-Sc_u2QxD.js.map
|