@aintela/chat 0.2.28 → 0.2.30
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/{promptHighlight-BHSQkdFs.js → atMentions-DqhG_vde.js} +37 -17
- package/dist/atMentions-DqhG_vde.js.map +1 -0
- package/dist/{auth-GFZAFz7L.js → auth-BN22f1HF.js} +2 -2
- package/dist/{auth-GFZAFz7L.js.map → auth-BN22f1HF.js.map} +1 -1
- package/dist/components.js +3039 -2995
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +2 -2
- package/dist/{httpArtifactService-B668XBHO.js → httpArtifactService-COu1QCBJ.js} +137 -136
- package/dist/{httpArtifactService-B668XBHO.js.map → httpArtifactService-COu1QCBJ.js.map} +1 -1
- package/dist/{httpSessionService-BuT5FlDc.js → httpSessionService-B_G3Ej2C.js} +2 -2
- package/dist/{httpSessionService-BuT5FlDc.js.map → httpSessionService-B_G3Ej2C.js.map} +1 -1
- package/dist/index.js +55 -53
- package/dist/models.js +1 -1
- package/dist/{serializer-BPina6fX.js → serializer-BZjKrhXT.js} +118 -117
- package/dist/{serializer-BPina6fX.js.map → serializer-BZjKrhXT.js.map} +1 -1
- package/dist/services.js +2 -2
- package/dist/src/ErrorBondary.d.ts +1 -1
- package/dist/src/components/v2/PromptV2.d.ts +11 -0
- package/dist/src/hooks/usePromptAssist.d.ts +1 -0
- package/dist/src/models/semanticKernelModel/serializer.test.d.ts +1 -0
- package/dist/src/services/httpPromptAssistService.d.ts +5 -0
- package/dist/src/utils/atMentions.d.ts +28 -0
- package/dist/src/utils/atMentions.test.d.ts +1 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/{useChatSessions-DsHPo0GV.js → useChatSessions-D5y5kCID.js} +2 -2
- package/dist/{useChatSessions-DsHPo0GV.js.map → useChatSessions-D5y5kCID.js.map} +1 -1
- package/dist/useContainerWidth-D0CQQqZ2.js +262 -0
- package/dist/useContainerWidth-D0CQQqZ2.js.map +1 -0
- package/dist/utils.js +28 -26
- package/package.json +1 -1
- package/dist/promptHighlight-BHSQkdFs.js.map +0 -1
- package/dist/useContainerWidth-0EA-kdzl.js +0 -260
- package/dist/useContainerWidth-0EA-kdzl.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var L = Object.defineProperty;
|
|
2
2
|
var d = (e, t) => L(e, "name", { value: t, configurable: !0 });
|
|
3
3
|
import { useMemo as h, useState as v, useCallback as g, useEffect as C } from "react";
|
|
4
|
-
import { H } from "./httpSessionService-
|
|
4
|
+
import { H } from "./httpSessionService-B_G3Ej2C.js";
|
|
5
5
|
const w = 6e4, y = 60 * w, l = 24 * y;
|
|
6
6
|
function k(e) {
|
|
7
7
|
if (!e) return;
|
|
@@ -104,4 +104,4 @@ d(Y, "useChatSessions");
|
|
|
104
104
|
export {
|
|
105
105
|
Y as u
|
|
106
106
|
};
|
|
107
|
-
//# sourceMappingURL=useChatSessions-
|
|
107
|
+
//# sourceMappingURL=useChatSessions-D5y5kCID.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatSessions-DsHPo0GV.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title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AASnB,EAAQ,MAAMlB,EAAYC,CAAK,GAAG,CAACA,CAAK,CAAC,GAElDqC,IAASR,EAAY,OAAOS,GAAYC,MAAkB;AAC5D,IAAAjB;AAAA,MAAY,CAAAkB,MACRA,EAAQ,IAAI,CAAAN,MAAMA,EAAE,OAAOI,IAAK,EAAE,GAAGJ,GAAG,UAAUK,EAAA,IAAUL,CAAE;AAAA,IAAA;AAElE,QAAI;AACA,YAAMf,EAAe,aAAamB,GAAI,EAAE,UAAUC,GAAO;AAAA,IAC7D,SAAST,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC,GAEtBa,IAASZ,EAAY,OAAOS,MAAe;AAC7C,IAAAhB,EAAY,OAAWkB,EAAQ,OAAO,OAAKN,EAAE,OAAOI,CAAE,CAAC;AACvD,QAAI;AACA,YAAMnB,EAAe,cAAcmB,CAAE;AAAA,IACzC,SAASR,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC;AAE5B,SAAO,EAAE,UAAUI,GAAQ,QAAAI,GAAQ,WAAAZ,GAAW,OAAAE,GAAO,SAAAE,GAAS,QAAAS,GAAQ,QAAAI,EAAA;AAC1E;AAtEgB/C,EAAAoB,GAAA;"}
|
|
1
|
+
{"version":3,"file":"useChatSessions-D5y5kCID.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title","current","remove"],"mappings":";;;;AAkEA,MAAMA,IAAY,KACZC,IAAU,KAAKD,GACfE,IAAS,KAAKD;AAEpB,SAASE,EAAOC,GAA2D;AACvE,MAAI,CAACA,EAAO;AACZ,MAAIA,aAAiB,KAAM,QAAOA;AAClC,QAAMC,IAAI,IAAI,KAAKD,CAAK;AACxB,SAAO,OAAO,MAAMC,EAAE,QAAA,CAAS,IAAI,SAAYA;AACnD;AALSC,EAAAH,GAAA;AAOT,SAASI,EAAgBC,GAAgC;AACrD,MAAI,CAACA,EAAM,QAAO;AAClB,QAAMC,IAAO,KAAK,IAAA,IAAQD,EAAK,QAAA;AAC/B,SAAIC,IAAOT,IAAkB,QACzBS,IAAOR,IAAgB,GAAG,KAAK,MAAMQ,IAAOT,CAAS,CAAC,MACtDS,IAAOP,IAAe,GAAG,KAAK,MAAMO,IAAOR,CAAO,CAAC,MACnDQ,IAAO,IAAIP,IAAe,GAAG,KAAK,MAAMO,IAAOP,CAAM,CAAC,MACnDM,EAAK,mBAAmB,QAAW,EAAE,OAAO,SAAS,KAAK,WAAW;AAChF;AARSF,EAAAC,GAAA;AAUT,SAASG,IAAqB;AAC1B,QAAML,wBAAQ,KAAA;AACd,SAAAA,EAAE,SAAS,GAAG,GAAG,GAAG,CAAC,GACdA;AACX;AAJSC,EAAAI,GAAA;AAMT,SAASC,EAAYC,GAAkD;AACnE,QAAMC,IAAQH,EAAA,GACRI,IAAY,IAAI,KAAKD,EAAM,QAAA,IAAYX,CAAM,GAC7Ca,IAAU,IAAI,KAAKF,EAAM,QAAA,IAAY,IAAIX,CAAM,GAC/Cc,IAAW,IAAI,KAAKH,EAAM,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Ac,EAAKF,CAAG,IAAIb,GACLe;AAAA,EACX,GAAG,CAACd,GAAUD,CAAW,CAAC,GAEpBpB,IAAQiB;AAAA,IACV,MAAMe,EAAO,IAAI,OAAKtB,EAAUwB,GAAGtB,CAAQ,CAAC;AAAA,IAC5C,CAACoB,GAAQpB,CAAQ;AAAA,EAAA,GAGfwB,IAASnB,EAAQ,MAAMlB,EAAYC,CAAK,GAAG,CAACA,CAAK,CAAC,GAElDqC,IAASR,EAAY,OAAOS,GAAYC,MAAkB;AAC5D,IAAAjB;AAAA,MAAY,CAAAkB,MACRA,EAAQ,IAAI,CAAAN,MAAMA,EAAE,OAAOI,IAAK,EAAE,GAAGJ,GAAG,UAAUK,EAAA,IAAUL,CAAE;AAAA,IAAA;AAElE,QAAI;AACA,YAAMf,EAAe,aAAamB,GAAI,EAAE,UAAUC,GAAO;AAAA,IAC7D,SAAST,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC,GAEtBa,IAASZ,EAAY,OAAOS,MAAe;AAC7C,IAAAhB,EAAY,OAAWkB,EAAQ,OAAO,OAAKN,EAAE,OAAOI,CAAE,CAAC;AACvD,QAAI;AACA,YAAMnB,EAAe,cAAcmB,CAAE;AAAA,IACzC,SAASR,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC;AAE5B,SAAO,EAAE,UAAUI,GAAQ,QAAAI,GAAQ,WAAAZ,GAAW,OAAAE,GAAO,SAAAE,GAAS,QAAAS,GAAQ,QAAAI,EAAA;AAC1E;AAtEgB/C,EAAAoB,GAAA;"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
var At = Object.defineProperty;
|
|
2
|
+
var v = (a, c) => At(a, "name", { value: c, configurable: !0 });
|
|
3
|
+
import { useState as b, useRef as u, useCallback as P, useEffect as K } from "react";
|
|
4
|
+
const wt = /* @__PURE__ */ v(() => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`, "newSessionId"), $t = /* @__PURE__ */ v((a, c, g) => {
|
|
5
|
+
var h;
|
|
6
|
+
const l = a.length;
|
|
7
|
+
let n = c;
|
|
8
|
+
for (let p = 0; p < l; p++)
|
|
9
|
+
if (n = (n + g + l) % l, !((h = a[n]) != null && h.disabled)) return n;
|
|
10
|
+
return c;
|
|
11
|
+
}, "nextEnabledIndex"), It = /* @__PURE__ */ v((a) => {
|
|
12
|
+
const c = /* @__PURE__ */ new Date();
|
|
13
|
+
c.setDate(c.getDate() + a);
|
|
14
|
+
const g = String(c.getDate()).padStart(2, "0"), l = String(c.getMonth() + 1).padStart(2, "0");
|
|
15
|
+
return `${g}/${l}/${c.getFullYear()}`;
|
|
16
|
+
}, "plusDaysBR");
|
|
17
|
+
function zt(a, c, g = {}) {
|
|
18
|
+
const [l, n] = b(null), [h, p] = b(0), [q, R] = b(!1), [A, T] = b(0), [z, ct] = b([]), [yt, st] = b([]), [bt, J] = b(""), j = u(""), B = u(null), V = u(a);
|
|
19
|
+
V.current = a;
|
|
20
|
+
const I = u(c);
|
|
21
|
+
I.current = c;
|
|
22
|
+
const it = u(g);
|
|
23
|
+
it.current = g;
|
|
24
|
+
const U = u(null), W = u(null), lt = u(0), at = u(0), X = u(null), M = u(""), F = u(null), _ = u(null), tt = u(wt()), N = u(null);
|
|
25
|
+
N.current = l;
|
|
26
|
+
const Q = u(null), ut = u(""), dt = u(() => {
|
|
27
|
+
}), Rt = P(() => n(null), []), vt = P(() => {
|
|
28
|
+
ct([]), st([]), J(""), j.current = "", F.current = null, tt.current = wt();
|
|
29
|
+
}, []), et = P((t) => {
|
|
30
|
+
if (t.disabled) return;
|
|
31
|
+
n(null);
|
|
32
|
+
const e = V.current, f = e.getTextarea();
|
|
33
|
+
if (!f) return;
|
|
34
|
+
const $ = f.selectionStart ?? f.value.length, k = f.value.slice(0, $), x = f.value.slice($), r = t.kind === "namedLocation" || t.kind === "location";
|
|
35
|
+
let o;
|
|
36
|
+
if (r) {
|
|
37
|
+
const d = ut.current, w = k.replace(/\s+$/, "");
|
|
38
|
+
o = d && w.endsWith(d) ? w.slice(0, w.length - d.length) : k;
|
|
39
|
+
} else {
|
|
40
|
+
const d = k.search(/\S+$/);
|
|
41
|
+
o = d === -1 ? k : k.slice(0, d);
|
|
42
|
+
}
|
|
43
|
+
const s = o.length > 0 && !/\s$/.test(o);
|
|
44
|
+
if (t.kind === "date") {
|
|
45
|
+
const d = `${s ? " " : ""}${t.insert} `, w = `${o}${d}${x}`;
|
|
46
|
+
e.setDraft(w), e.focusCaret(o.length + d.length), M.current = w, F.current = null, dt.current();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (t.kind === "namedLocation" && t.insert) {
|
|
50
|
+
const d = `@${t.insert.replace(/ /g, " ")}`, w = `${s ? " " : ""}${d} `;
|
|
51
|
+
e.setDraft(`${o}${w}${x}`), e.focusCaret(o.length + w.length);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const Y = t.kind === "location" ? "@" : "#", H = `${s ? " " : ""}${Y}`;
|
|
55
|
+
e.setDraft(`${o}${H}${x}`), e.focusCaret(o.length + H.length), requestAnimationFrame(() => {
|
|
56
|
+
const d = e.getTextarea();
|
|
57
|
+
d && e.syncTrigger(d);
|
|
58
|
+
});
|
|
59
|
+
}, []), nt = P(async () => {
|
|
60
|
+
var $;
|
|
61
|
+
const t = I.current.resolveDates;
|
|
62
|
+
if (!t) return;
|
|
63
|
+
const e = M.current;
|
|
64
|
+
if (e.trim() === "") {
|
|
65
|
+
F.current = null;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (e === F.current) return;
|
|
69
|
+
F.current = e, ($ = _.current) == null || $.abort();
|
|
70
|
+
const f = new AbortController();
|
|
71
|
+
_.current = f;
|
|
72
|
+
try {
|
|
73
|
+
const { dates: k, locations: x } = await t(e, tt.current, f.signal);
|
|
74
|
+
if (M.current !== e) return;
|
|
75
|
+
const r = k.filter((s) => s.display).map((s) => ({ text: s.text, display: s.display }));
|
|
76
|
+
st(r), ct(x.map((s) => s.text).filter((s) => s.trim().length > 0));
|
|
77
|
+
const o = r.map((s) => `${s.text}=${s.display}`).join("|");
|
|
78
|
+
r.length > 0 && o !== j.current && (j.current = o, J(r[r.length - 1].text), B.current != null && window.clearTimeout(B.current), B.current = window.setTimeout(() => J(""), 2e3)), r.length === 0 && (j.current = "");
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
}, []);
|
|
82
|
+
dt.current = nt;
|
|
83
|
+
const kt = P((t, e, f) => {
|
|
84
|
+
M.current = t;
|
|
85
|
+
const $ = I.current.analyze;
|
|
86
|
+
$ && (!f || N.current !== null) && (U.current != null && window.clearTimeout(U.current), U.current = window.setTimeout(async () => {
|
|
87
|
+
var x;
|
|
88
|
+
const k = ++lt.current;
|
|
89
|
+
try {
|
|
90
|
+
const r = await $(t, e);
|
|
91
|
+
if (k !== lt.current) return;
|
|
92
|
+
const o = V.current, s = o.getTextarea();
|
|
93
|
+
if (!s || s.value !== t) return;
|
|
94
|
+
p(r.personConfidence ?? 0);
|
|
95
|
+
const Y = (s.selectionStart ?? e) === t.length, H = o.hasAtQuery, d = o.isPickerOpen(), w = r.suggestions ?? [], { enableHashDatePicker: Ct = !1, datePresets: Dt = ["amanhã de manhã", "quarta-feira à noite"] } = it.current;
|
|
96
|
+
let D = r.category === "location" ? "location" : r.category === "date" ? "date" : r.locationExpected ? "location" : r.dateExpected ? "date" : null;
|
|
97
|
+
if (D !== "location" && r.locationCount < 2 && I.current.suggest && N.current !== null && Q.current === "location" && Y && /\s$/.test(t) && (D = "location"), D === "location" && r.locationCount >= 2 && r.locationPartialEmpty) {
|
|
98
|
+
n(null), Q.current = null;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (D === null || !(Y && !d && (D === "location" ? H : D === "date"))) {
|
|
102
|
+
n(null), Q.current = null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const y = D;
|
|
106
|
+
Q.current = y;
|
|
107
|
+
const rt = /* @__PURE__ */ v(() => y === "date" && Ct ? [{ key: "cal", label: `📅 no dia #${It(2)}`, kind: "calendar" }] : [], "genericTail"), ft = w.filter((i) => i.kind === "location"), gt = w.filter((i) => i.kind === "date").map((i) => i.value), C = [];
|
|
108
|
+
if (y === "location") {
|
|
109
|
+
for (const i of ft)
|
|
110
|
+
C.push({ key: `loc:${i.value}`, label: `📍 ${i.label}`, kind: "namedLocation", insert: i.value });
|
|
111
|
+
C.push(...rt());
|
|
112
|
+
} else {
|
|
113
|
+
for (const i of gt.length > 0 ? gt : Dt)
|
|
114
|
+
C.push({ key: `date:${i}`, label: `📅 ${i}`, kind: "date", insert: i });
|
|
115
|
+
C.push(...rt());
|
|
116
|
+
}
|
|
117
|
+
const Z = I.current.suggest, St = y === "location" ? ft.length > 0 : !0;
|
|
118
|
+
if (y === "location" && !St && !Z) {
|
|
119
|
+
if (!f && r.locationExpected && r.locationPartialEmpty && r.locationCount < 2 && H && o.currentTriggerChar() !== "@") {
|
|
120
|
+
const i = s.selectionStart ?? t.length, S = t.slice(0, i), ot = S.length > 0 && !/\s$/.test(S);
|
|
121
|
+
if (!S.endsWith("@")) {
|
|
122
|
+
const E = ot ? " @" : "@";
|
|
123
|
+
n(null), o.setDraft(`${S}${E}${t.slice(i)}`), o.focusCaret(i + E.length), requestAnimationFrame(() => {
|
|
124
|
+
const G = o.getTextarea();
|
|
125
|
+
G && o.syncTrigger(G);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
n(null);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (Z ? N.current === null && C.length > 0 && (T(0), R(!0), n(C)) : C.length > 0 ? (T(0), R(!0), n(C)) : n(null), Z) {
|
|
134
|
+
const i = t.slice(0, s.selectionStart ?? t.length), S = i.search(/[ \t\r\n](?=[^ \t\r\n]*$)/), ot = S === -1 ? i : i.slice(S + 1), E = y === "location" && r.locationPartial !== void 0 ? r.locationPartial : ot;
|
|
135
|
+
y === "location" && (ut.current = E);
|
|
136
|
+
const G = y === "location" ? [...t.matchAll(/@\(([A-Za-z]{3})\)/g)].map((O) => O[1].toUpperCase()) : void 0, Pt = ++at.current;
|
|
137
|
+
(x = X.current) == null || x.abort();
|
|
138
|
+
const ht = new AbortController();
|
|
139
|
+
X.current = ht;
|
|
140
|
+
try {
|
|
141
|
+
const O = await Z(E, y, ht.signal, G);
|
|
142
|
+
if (Pt !== at.current) return;
|
|
143
|
+
const mt = o.getTextarea();
|
|
144
|
+
if (!mt || mt.value !== t || y === "location" && O.length === 0) return;
|
|
145
|
+
const L = [];
|
|
146
|
+
if (y === "location")
|
|
147
|
+
for (const m of O)
|
|
148
|
+
L.push({
|
|
149
|
+
key: `loc:${m.insert}`,
|
|
150
|
+
label: `📍 ${m.label}`,
|
|
151
|
+
kind: "namedLocation",
|
|
152
|
+
insert: m.insert,
|
|
153
|
+
hint: [m.iata, m.region, m.country].filter(Boolean).join(" · ") || void 0,
|
|
154
|
+
// parity with the `@` picker
|
|
155
|
+
disabled: m.disabled
|
|
156
|
+
// already in the prompt (same city) — greyed, not pickable
|
|
157
|
+
});
|
|
158
|
+
else
|
|
159
|
+
for (const m of O)
|
|
160
|
+
L.push({ key: `date:${m.insert}`, label: `📅 ${m.label}`, kind: "date", insert: m.insert });
|
|
161
|
+
if (L.push(...rt()), L.length === 0) {
|
|
162
|
+
n(null);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const pt = L.findIndex((m) => !m.disabled);
|
|
166
|
+
T(pt < 0 ? 0 : pt), R(E.trim() === ""), n(L);
|
|
167
|
+
} catch {
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} catch {
|
|
171
|
+
}
|
|
172
|
+
}, 200)), W.current != null && window.clearTimeout(W.current), W.current = window.setTimeout(() => {
|
|
173
|
+
nt();
|
|
174
|
+
}, 300);
|
|
175
|
+
}, [nt]), Tt = P((t) => {
|
|
176
|
+
var f, $;
|
|
177
|
+
const e = t.trim();
|
|
178
|
+
e && (($ = (f = I.current).commitIntent) == null || $.call(f, e, tt.current));
|
|
179
|
+
}, []), xt = P((t) => {
|
|
180
|
+
if (!l || l.length === 0) return !1;
|
|
181
|
+
if (t.key === "ArrowDown")
|
|
182
|
+
return t.preventDefault(), T((e) => $t(l, e, 1)), !0;
|
|
183
|
+
if (t.key === "ArrowUp")
|
|
184
|
+
return t.preventDefault(), T((e) => $t(l, e, -1)), !0;
|
|
185
|
+
if (t.key === "Enter" || t.key === "Tab") {
|
|
186
|
+
t.preventDefault();
|
|
187
|
+
const e = l[A];
|
|
188
|
+
return e && !e.disabled && et(e), !0;
|
|
189
|
+
}
|
|
190
|
+
return t.key === "Escape" ? (t.preventDefault(), n(null), !0) : !1;
|
|
191
|
+
}, [l, A, et]);
|
|
192
|
+
return K(() => () => {
|
|
193
|
+
var t, e;
|
|
194
|
+
U.current != null && window.clearTimeout(U.current), W.current != null && window.clearTimeout(W.current), B.current != null && window.clearTimeout(B.current), (t = _.current) == null || t.abort(), (e = X.current) == null || e.abort();
|
|
195
|
+
}, []), {
|
|
196
|
+
predictions: l,
|
|
197
|
+
predictionsRecents: q,
|
|
198
|
+
predictionHighlight: A,
|
|
199
|
+
setPredictionHighlight: T,
|
|
200
|
+
applyPrediction: et,
|
|
201
|
+
clearPredictions: Rt,
|
|
202
|
+
resolvedLocations: z,
|
|
203
|
+
resolvedDates: yt,
|
|
204
|
+
forceTooltipText: bt,
|
|
205
|
+
personConfidence: h,
|
|
206
|
+
scheduleAssist: kt,
|
|
207
|
+
commit: Tt,
|
|
208
|
+
onKeyDown: xt,
|
|
209
|
+
resetSession: vt
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
v(zt, "usePromptAssist");
|
|
213
|
+
function Bt(a, c) {
|
|
214
|
+
const g = u(a), [l, n] = b(null);
|
|
215
|
+
return K(() => {
|
|
216
|
+
g.current = a;
|
|
217
|
+
}, [a]), K(() => {
|
|
218
|
+
function h() {
|
|
219
|
+
g.current();
|
|
220
|
+
}
|
|
221
|
+
if (v(h, "tick"), c !== null) {
|
|
222
|
+
const p = setInterval(h, c);
|
|
223
|
+
return n(p), () => {
|
|
224
|
+
clearInterval(p);
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}, [c]), l;
|
|
228
|
+
}
|
|
229
|
+
v(Bt, "useInterval");
|
|
230
|
+
function Ut(a, c, g = 0) {
|
|
231
|
+
const [l, n] = b(g);
|
|
232
|
+
return K(() => {
|
|
233
|
+
const h = a.current;
|
|
234
|
+
if (!h) return;
|
|
235
|
+
const p = new ResizeObserver((q) => {
|
|
236
|
+
const R = q[0];
|
|
237
|
+
R && n(R.contentRect.width);
|
|
238
|
+
});
|
|
239
|
+
return p.observe(h), n(h.getBoundingClientRect().width), () => p.disconnect();
|
|
240
|
+
}, [a, c]), l;
|
|
241
|
+
}
|
|
242
|
+
v(Ut, "useContainerWidth");
|
|
243
|
+
function Wt(a, c, g = 0, l = 0) {
|
|
244
|
+
const [n, h] = b(g), [p, q] = b(l);
|
|
245
|
+
return K(() => {
|
|
246
|
+
const R = a.current;
|
|
247
|
+
if (!R) return;
|
|
248
|
+
const A = new ResizeObserver((T) => {
|
|
249
|
+
const z = T[0];
|
|
250
|
+
z && (q(z.contentRect.height), h(z.contentRect.width));
|
|
251
|
+
});
|
|
252
|
+
return A.observe(R), h(R.getBoundingClientRect().width), () => A.disconnect();
|
|
253
|
+
}, [a, c]), [n, p];
|
|
254
|
+
}
|
|
255
|
+
v(Wt, "useContainerRectangle");
|
|
256
|
+
export {
|
|
257
|
+
Ut as a,
|
|
258
|
+
Bt as b,
|
|
259
|
+
zt as c,
|
|
260
|
+
Wt as u
|
|
261
|
+
};
|
|
262
|
+
//# sourceMappingURL=useContainerWidth-D0CQQqZ2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContainerWidth-D0CQQqZ2.js","sources":["../src/hooks/usePromptAssist.ts","../src/hooks/useIntervalHook.ts","../src/hooks/useContainerWidth.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type KeyboardEvent } from 'react';\nimport type { PromptAnalysis, PromptResolution, SuggestItem } from '../services/httpPromptAssistService';\n\n/** A dropdown item. `namedLocation` inserts `@Name` directly; `location`/`calendar` insert `@`/`#` and open the picker. */\nexport type PredictionItem = {\n key: string;\n label: string;\n kind: 'location' | 'namedLocation' | 'date' | 'calendar';\n insert?: string;\n /** Secondary line (e.g. \"GRU · SP · Brasil\") — parity with the `@` picker's hint. Optional. */\n hint?: string;\n /** Non-pickable (already in the prompt, same place/city) — rendered greyed and skipped by nav/apply. */\n disabled?: boolean;\n};\n\nexport type ResolvedDateItem = { text: string; display: string };\n\n/** The DOM operations the hook needs from its host composer — so the same logic drives PromptV2 and PromptComposer. */\nexport interface PromptAssistAdapter {\n getTextarea: () => HTMLTextAreaElement | null;\n /** Replace the draft value (host owns the React state). */\n setDraft: (next: string) => void;\n /** After a programmatic edit, focus the textarea and place the caret (host defers a frame if needed). */\n focusCaret: (pos: number) => void;\n /** Re-detect the `@`/`#` trigger at the caret and open the matching picker (host's existing flow). */\n syncTrigger: (ta: HTMLTextAreaElement) => void;\n /** Is a location/date picker already open? (suppresses the predictions dropdown / auto-`@`) */\n isPickerOpen: () => boolean;\n /** The trigger char of any open picker, or null — used to avoid re-inserting `@`. */\n currentTriggerChar: () => string | null;\n /** Whether the `@` location fetcher is wired (else no auto-`@` / generic \"Local…\"). */\n hasAtQuery: boolean;\n}\n\nexport interface PromptAssistFetchers {\n analyze?: (text: string, caret: number) => Promise<PromptAnalysis>;\n resolveDates?: (text: string, sessionId?: string, signal?: AbortSignal) => Promise<PromptResolution>;\n commitIntent?: (text: string, sessionId?: string) => void;\n suggest?: (q: string, kind: 'location' | 'date' | 'both', signal?: AbortSignal, exclude?: string[]) => Promise<SuggestItem[]>;\n}\n\nexport interface PromptAssistOptions {\n enableHashDatePicker?: boolean;\n datePresets?: string[];\n}\n\nconst newSessionId = () =>\n typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`;\n\n/** Next selectable (non-disabled) index from `from` moving `dir` (±1), wrapping. Stays put if all are disabled. */\nconst nextEnabledIndex = (items: PredictionItem[], from: number, dir: 1 | -1): number => {\n const n = items.length;\n let idx = from;\n for (let step = 0; step < n; step++) {\n idx = (idx + dir + n) % n;\n if (!items[idx]?.disabled) return idx;\n }\n return from;\n};\n\n/** Today + n days, formatted DD/MM/YYYY — the default shown on the \"no dia #…\" date-picker suggestion. */\nconst plusDaysBR = (n: number) => {\n const d = new Date();\n d.setDate(d.getDate() + n);\n const dd = String(d.getDate()).padStart(2, '0');\n const mm = String(d.getMonth() + 1).padStart(2, '0');\n return `${dd}/${mm}/${d.getFullYear()}`;\n};\n\n/**\n * Headless prompt-assist logic shared by the chat composer (PromptV2) and the home composer (obtapp PromptComposer):\n * the analyze quick pass (auto-`@` + combined predictions dropdown), the resolve slow pass (date resolution +\n * mapped-location chips), commit-on-send learning, and keyboard nav — all with NO rendering/anchoring assumptions.\n * The host provides its DOM ops via {@link PromptAssistAdapter} and renders the returned `predictions` however it wants.\n */\nexport function usePromptAssist(\n adapter: PromptAssistAdapter,\n fetchers: PromptAssistFetchers,\n options: PromptAssistOptions = {},\n) {\n const [predictions, setPredictions] = useState<PredictionItem[] | null>(null);\n // Issue #112 — the latest analyze's person-intent signal (P the user is referring to a PERSON/passenger). Hosts\n // use this to order/section the `@` picker's sources (people vs places). Updated on every analyze; 0 when the\n // feature is off server-side or the text is empty.\n const [personConfidence, setPersonConfidence] = useState(0);\n // True when the current predictions are the \"recents\" set (analyze pre-fill or an empty-query suggest) rather\n // than results for a typed query — lets the host label it \"recentes\" + hint that typing surfaces more.\n const [predictionsRecents, setPredictionsRecents] = useState(false);\n const [predictionHighlight, setPredictionHighlight] = useState(0);\n const [resolvedLocations, setResolvedLocations] = useState<string[]>([]);\n const [resolvedDates, setResolvedDates] = useState<ResolvedDateItem[]>([]);\n // The date text whose marker tooltip should auto-open (set on a NEW resolution, cleared after 2s) — identical\n // to PromptV2's behavior so both composers surface a freshly-resolved date the same way.\n const [forceTooltipText, setForceTooltipText] = useState('');\n const lastResolvedKeyRef = useRef('');\n const tooltipTimerRef = useRef<number | null>(null);\n\n // Latest adapter/fetchers/options via refs — the debounced callbacks must not capture stale closures.\n const adapterRef = useRef(adapter); adapterRef.current = adapter;\n const fetchersRef = useRef(fetchers); fetchersRef.current = fetchers;\n const optionsRef = useRef(options); optionsRef.current = options;\n\n const analyzeTimerRef = useRef<number | null>(null);\n const resolveTimerRef = useRef<number | null>(null);\n const analyzeSeqRef = useRef(0);\n const suggestSeqRef = useRef(0);\n const suggestAbortRef = useRef<AbortController | null>(null);\n const draftRef = useRef('');\n const lastResolveTextRef = useRef<string | null>(null);\n const resolveAbortRef = useRef<AbortController | null>(null);\n const sessionIdRef = useRef<string>(newSessionId());\n // Current predictions (mirror of state) so the debounced analyze can tell if the dropdown is already open —\n // lets us pre-fill only on FIRST open instead of re-flashing the tenant list on every keystroke.\n const predictionsRef = useRef<PredictionItem[] | null>(null);\n predictionsRef.current = predictions;\n // The kind the open dropdown is currently showing (null when closed) — lets a trailing space keep an open\n // location dropdown alive (as recents) instead of collapsing it.\n const lastKindRef = useRef<'location' | 'date' | null>(null);\n // The server-parsed location partial the open dropdown filtered on (\"belo\", \"São Paulo\", or \"\" for recents).\n // applyPrediction strips exactly this — including across a trailing space — so a pick REPLACES the partial\n // instead of appending after it, and never eats a completed \"@\" mention (empty partial → append).\n const locationPartialRef = useRef('');\n // Stable pointer to runResolve so applyPrediction (defined earlier) can force a resolve after a date pick.\n const runResolveRef = useRef<() => void>(() => {});\n\n const clearPredictions = useCallback(() => setPredictions(null), []);\n\n /** Call when the draft empties (send / reseed): clear mapped data and start a fresh learning session. */\n const resetSession = useCallback(() => {\n setResolvedLocations([]);\n setResolvedDates([]);\n setForceTooltipText('');\n lastResolvedKeyRef.current = '';\n lastResolveTextRef.current = null;\n sessionIdRef.current = newSessionId();\n }, []);\n\n const applyPrediction = useCallback((p: PredictionItem) => {\n if (p.disabled) return; // already in the prompt (same city) — not selectable; keep the dropdown open\n setPredictions(null);\n const ad = adapterRef.current;\n const ta = ad.getTextarea();\n if (!ta) return;\n const caret = ta.selectionStart ?? ta.value.length;\n const rawBefore = ta.value.slice(0, caret);\n const after = ta.value.slice(caret);\n // A pick must REPLACE what the dropdown filtered on, not append after it (\"sao @São Paulo\" bug).\n // LOCATIONS: strip exactly the server-parsed partial (locationPartialRef) — this spans a trailing space\n // (\"de belo \" → \"belo\") and is \"\" for a recents/mention pick, so we append instead of eating a finished\n // \"@\" mention. DATES: strip the trailing word as before.\n const isLocationPick = p.kind === 'namedLocation' || p.kind === 'location';\n let before: string;\n if (isLocationPick) {\n const partial = locationPartialRef.current;\n const trimmedEnd = rawBefore.replace(/\\s+$/, '');\n before = partial && trimmedEnd.endsWith(partial) ? trimmedEnd.slice(0, trimmedEnd.length - partial.length) : rawBefore;\n } else {\n const wordStart = rawBefore.search(/\\S+$/);\n before = wordStart === -1 ? rawBefore : rawBefore.slice(0, wordStart);\n }\n const needsSpace = before.length > 0 && !/\\s$/.test(before);\n\n if (p.kind === 'date') {\n const ins = `${needsSpace ? ' ' : ''}${p.insert} `;\n const next = `${before}${ins}${after}`;\n ad.setDraft(next);\n ad.focusCaret(before.length + ins.length);\n // A programmatic setDraft doesn't fire onChange, so force a resolve now → the picked date resolves\n // into its chip/marker immediately instead of waiting for the next keystroke.\n draftRef.current = next;\n lastResolveTextRef.current = null;\n runResolveRef.current();\n return;\n }\n if (p.kind === 'namedLocation' && p.insert) {\n // A specific place → finished \"@\" mention (NBSP-joined so a multi-word name stays one chip / one mention).\n const mention = `@${p.insert.replace(/ /g, String.fromCharCode(0xA0))}`;\n const ins = `${needsSpace ? ' ' : ''}${mention} `;\n ad.setDraft(`${before}${ins}${after}`);\n ad.focusCaret(before.length + ins.length);\n return;\n }\n // Generic location / calendar → insert the trigger char and open the host's picker.\n const chr = p.kind === 'location' ? '@' : '#';\n const ins = `${needsSpace ? ' ' : ''}${chr}`;\n ad.setDraft(`${before}${ins}${after}`);\n ad.focusCaret(before.length + ins.length);\n requestAnimationFrame(() => { const t = ad.getTextarea(); if (t) ad.syncTrigger(t); });\n }, []);\n\n const runResolve = useCallback(async () => {\n const resolve = fetchersRef.current.resolveDates;\n if (!resolve) return;\n const text = draftRef.current;\n if (text.trim() === '') { lastResolveTextRef.current = null; return; }\n if (text === lastResolveTextRef.current) return; // unchanged since last call\n lastResolveTextRef.current = text;\n resolveAbortRef.current?.abort();\n const ac = new AbortController();\n resolveAbortRef.current = ac;\n try {\n const { dates, locations } = await resolve(text, sessionIdRef.current, ac.signal);\n if (draftRef.current !== text) return; // moved on while in flight\n const resolved = dates.filter((d) => d.display).map((d) => ({ text: d.text, display: d.display }));\n setResolvedDates(resolved);\n setResolvedLocations(locations.map((l) => l.text).filter((t) => t.trim().length > 0));\n // Auto-open the newest date's tooltip for 2s (only when the resolution set actually changed).\n const key = resolved.map((r) => `${r.text}=${r.display}`).join('|');\n if (resolved.length > 0 && key !== lastResolvedKeyRef.current) {\n lastResolvedKeyRef.current = key;\n setForceTooltipText(resolved[resolved.length - 1].text);\n if (tooltipTimerRef.current != null) window.clearTimeout(tooltipTimerRef.current);\n tooltipTimerRef.current = window.setTimeout(() => setForceTooltipText(''), 2000);\n }\n if (resolved.length === 0) lastResolvedKeyRef.current = '';\n } catch { /* ignore — includes AbortError from a superseded call */ }\n }, []);\n runResolveRef.current = runResolve;\n\n /** Call from the textarea's onChange. Runs the debounced analyze (200ms) + resolve (300ms) passes. */\n const scheduleAssist = useCallback((value: string, caret: number, isDeletion: boolean) => {\n draftRef.current = value;\n const analyze = fetchersRef.current.analyze;\n // Run analyze on typing, AND on deletion WHILE the dropdown is open — so backspacing re-filters the list\n // (shorter query) and closes it once the context ends. When nothing's open, deletion still skips analyze\n // (no auto-'@' / churn while correcting text elsewhere).\n if (analyze && (!isDeletion || predictionsRef.current !== null)) {\n if (analyzeTimerRef.current != null) window.clearTimeout(analyzeTimerRef.current);\n analyzeTimerRef.current = window.setTimeout(async () => {\n const seq = ++analyzeSeqRef.current;\n try {\n const a = await analyze(value, caret);\n if (seq !== analyzeSeqRef.current) return;\n const ad = adapterRef.current;\n const live = ad.getTextarea();\n if (!live || live.value !== value) return;\n\n // Person-intent (issue #112) — surfaced regardless of the loc/date dropdown decision below, so the\n // host's `@` picker can consult it whether or not a predictions dropdown is currently open.\n setPersonConfidence(a.personConfidence ?? 0);\n\n const caretEnd = (live.selectionStart ?? caret) === value.length;\n const canLoc = ad.hasAtQuery;\n const pickerOpen = ad.isPickerOpen();\n const named = a.suggestions ?? [];\n const { enableHashDatePicker = false, datePresets = ['amanhã de manhã', 'quarta-feira à noite'] } = optionsRef.current;\n\n // Single-winner dropdown kind: prefer a.category, else fall back to the (at-most-one) expected flags.\n let decided: 'location' | 'date' | null =\n a.category === 'location' ? 'location'\n : a.category === 'date' ? 'date'\n : a.locationExpected ? 'location'\n : a.dateExpected ? 'date'\n : null;\n // Grace: a bare trailing space shouldn't collapse — OR flip to dates — an already-open location\n // dropdown. After the space the server may report \"done\" (null) OR predict a date (a learned\n // \"de [loc] \" → date template), but the user just hit space and is likely still on the location —\n // keep it open as the LOCATION recents list (empty query → suggest returns recents). Overrides\n // null AND date. Only when it was a location dropdown, suggest is wired, the caret's at the end,\n // and the text ends in a space. Typing an actual date WORD (no trailing space) still switches.\n // Not when 2 locations are already present — then the natural next slot is a DATE, so let it through.\n if (decided !== 'location' && a.locationCount < 2 && Boolean(fetchersRef.current.suggest)\n && predictionsRef.current !== null && lastKindRef.current === 'location' && caretEnd && /\\s$/.test(value)) {\n decided = 'location';\n }\n\n // 2-location safeguard: with origin + destination already present, a merely PREDICTED (not-being-\n // typed) 3rd location — typically just the model guessing — shouldn't open a dropdown. Actively\n // typing a 3rd location (partial non-empty) still shows.\n if (decided === 'location' && a.locationCount >= 2 && a.locationPartialEmpty) {\n setPredictions(null); lastKindRef.current = null; return;\n }\n\n // A location dropdown needs the `@` fetcher wired to be useful.\n const kindActive = decided === 'location' ? canLoc : decided === 'date';\n\n // Gating: caret at end, no picker open.\n if (decided === null || !(caretEnd && !pickerOpen && kindActive)) { setPredictions(null); lastKindRef.current = null; return; }\n const kind: 'location' | 'date' = decided;\n lastKindRef.current = kind;\n\n // Generic affordances appended after the named items. The location \"Local…\" entry is gone —\n // free-form typing now searches directly, so it's redundant. The date picker entry stays.\n const genericTail = (): PredictionItem[] =>\n kind === 'date' && enableHashDatePicker\n ? [{ key: 'cal', label: `📅 no dia #${plusDaysBR(2)}`, kind: 'calendar' } as PredictionItem]\n : [];\n\n const namedLocs = named.filter((s) => s.kind === 'location');\n const namedDates = named.filter((s) => s.kind === 'date').map((s) => s.value);\n\n // Pre-fill immediately (no await) from analyze's suggestions so the user sees something instantly.\n const prefill: PredictionItem[] = [];\n if (kind === 'location') {\n for (const s of namedLocs)\n prefill.push({ key: `loc:${s.value}`, label: `📍 ${s.label}`, kind: 'namedLocation', insert: s.value });\n prefill.push(...genericTail());\n } else {\n for (const d of (namedDates.length > 0 ? namedDates : datePresets))\n prefill.push({ key: `date:${d}`, label: `📅 ${d}`, kind: 'date', insert: d });\n prefill.push(...genericTail());\n }\n\n const suggest = fetchersRef.current.suggest;\n const hasNamed = kind === 'location' ? namedLocs.length > 0 : true;\n\n // If the dropdown would be empty AND there's no suggest fetcher to fill it, fall back to auto-'@'.\n if (kind === 'location' && !hasNamed && !suggest) {\n if (!isDeletion && a.locationExpected && a.locationPartialEmpty && a.locationCount < 2\n && canLoc && ad.currentTriggerChar() !== '@') {\n const c = live.selectionStart ?? value.length;\n const before = value.slice(0, c);\n const needsSpace = before.length > 0 && !/\\s$/.test(before);\n if (!before.endsWith('@')) {\n const insert = needsSpace ? ' @' : '@';\n setPredictions(null);\n ad.setDraft(`${before}${insert}${value.slice(c)}`);\n ad.focusCaret(c + insert.length);\n requestAnimationFrame(() => { const t = ad.getTextarea(); if (t) ad.syncTrigger(t); });\n }\n return;\n }\n setPredictions(null);\n return;\n }\n\n // Show the pre-filled list. With a suggest fetcher wired, only pre-fill on FIRST open (when the\n // dropdown was closed) — re-setting it every keystroke re-flashes the tenant list under the\n // incoming search results. Once open, keep the current list and let suggest refine it below.\n // Without a suggest fetcher, the pre-fill IS the content, so keep updating it each keystroke.\n if (!suggest) {\n if (prefill.length > 0) { setPredictionHighlight(0); setPredictionsRecents(true); setPredictions(prefill); }\n else setPredictions(null);\n } else if (predictionsRef.current === null && prefill.length > 0) {\n setPredictionHighlight(0);\n setPredictionsRecents(true); // pre-fill = the user's history = recents\n setPredictions(prefill);\n }\n\n // Then refine via the host-provided unified suggest source (search-as-you-type).\n if (suggest) {\n // Query = what the user is typing for the current slot. For LOCATIONS the server owns the\n // parse (a.locationPartial: \"@\"-mentions stripped, so \"@São Paulo \" → \"\" → recents and\n // \"de belo \" → \"belo\" → filter) — no client-side whitespace guessing, which can't tell a\n // partial from a cue or a finished mention. Falls back to the trailing word for dates, or if\n // an older server didn't send the field.\n const beforeCaret = value.slice(0, live.selectionStart ?? value.length);\n const wsIdx = beforeCaret.search(/[ \\t\\r\\n](?=[^ \\t\\r\\n]*$)/);\n const trailingWord = wsIdx === -1 ? beforeCaret : beforeCaret.slice(wsIdx + 1);\n const q = kind === 'location' && a.locationPartial !== undefined ? a.locationPartial : trailingWord;\n // Remember what a location pick should replace (server partial, or the trailing word fallback).\n if (kind === 'location') locationPartialRef.current = q;\n\n // Locations already picked in the prompt (the \"@(IATA) …\" mentions) — the suggest source\n // drops them AND anything in the same city, so it never offers an impossible SAO→SAO / GRU→CGH.\n const exclude = kind === 'location'\n ? [...value.matchAll(/@\\(([A-Za-z]{3})\\)/g)].map((m) => m[1].toUpperCase())\n : undefined;\n\n const sseq = ++suggestSeqRef.current;\n suggestAbortRef.current?.abort();\n const ac = new AbortController();\n suggestAbortRef.current = ac;\n try {\n const items = await suggest(q, kind, ac.signal, exclude);\n if (sseq !== suggestSeqRef.current) return; // overtaken\n const live2 = ad.getTextarea();\n if (!live2 || live2.value !== value) return; // text changed while in flight\n // Keep the useful pre-filled list on an empty result — the \"user is ignoring the dropdown\"\n // case is handled by the server's word cap (partial > 3 plain words → not a location).\n if (kind === 'location' && items.length === 0) return;\n\n const refined: PredictionItem[] = [];\n if (kind === 'location') {\n for (const it of items)\n refined.push({\n key: `loc:${it.insert}`, label: `📍 ${it.label}`, kind: 'namedLocation', insert: it.insert,\n hint: [it.iata, it.region, it.country].filter(Boolean).join(' · ') || undefined, // parity with the `@` picker\n disabled: it.disabled, // already in the prompt (same city) — greyed, not pickable\n });\n } else {\n for (const it of items)\n refined.push({ key: `date:${it.insert}`, label: `📅 ${it.label}`, kind: 'date', insert: it.insert });\n }\n refined.push(...genericTail());\n if (refined.length === 0) { setPredictions(null); return; } // nothing to show\n const firstEnabled = refined.findIndex((p) => !p.disabled); // don't land the highlight on a disabled item\n setPredictionHighlight(firstEnabled < 0 ? 0 : firstEnabled);\n setPredictionsRecents(q.trim() === ''); // empty query → recents; typed query → search results\n setPredictions(refined);\n } catch { /* ignore — includes AbortError from a superseded call */ }\n }\n } catch { /* transient — ignore */ }\n }, 200);\n }\n\n if (resolveTimerRef.current != null) window.clearTimeout(resolveTimerRef.current);\n resolveTimerRef.current = window.setTimeout(() => { void runResolve(); }, 300);\n }, [runResolve]);\n\n /** Call on send with the FINAL text (NBSP-preserving) so the server learns the committed intent. */\n const commit = useCallback((finalText: string) => {\n const t = finalText.trim();\n if (t) fetchersRef.current.commitIntent?.(t, sessionIdRef.current);\n }, []);\n\n /** Wire to the textarea's onKeyDown; returns true if it handled the key (host should then stop). */\n const onKeyDown = useCallback((e: KeyboardEvent<HTMLTextAreaElement>): boolean => {\n if (!predictions || predictions.length === 0) return false;\n if (e.key === 'ArrowDown') { e.preventDefault(); setPredictionHighlight((i) => nextEnabledIndex(predictions, i, 1)); return true; }\n if (e.key === 'ArrowUp') { e.preventDefault(); setPredictionHighlight((i) => nextEnabledIndex(predictions, i, -1)); return true; }\n if (e.key === 'Enter' || e.key === 'Tab') { e.preventDefault(); const it = predictions[predictionHighlight]; if (it && !it.disabled) applyPrediction(it); return true; }\n if (e.key === 'Escape') { e.preventDefault(); setPredictions(null); return true; }\n return false;\n }, [predictions, predictionHighlight, applyPrediction]);\n\n useEffect(() => () => {\n if (analyzeTimerRef.current != null) window.clearTimeout(analyzeTimerRef.current);\n if (resolveTimerRef.current != null) window.clearTimeout(resolveTimerRef.current);\n if (tooltipTimerRef.current != null) window.clearTimeout(tooltipTimerRef.current);\n resolveAbortRef.current?.abort();\n suggestAbortRef.current?.abort();\n }, []);\n\n return {\n predictions, predictionsRecents, predictionHighlight, setPredictionHighlight,\n applyPrediction, clearPredictions,\n resolvedLocations, resolvedDates, forceTooltipText,\n personConfidence,\n scheduleAssist, commit, onKeyDown, resetSession,\n };\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n// Custom useInterval hook\nfunction useInterval(callback: () => void, delay: number) {\n const savedCallback = useRef(callback);\n const [intervalId, setIntervalId] = useState<NodeJS.Timeout | null>(null)\n\n // Remember the latest callback.\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n // Set up the interval.\n useEffect(() => {\n function tick() {\n savedCallback.current();\n }\n if (delay !== null) {\n const id = setInterval(tick, delay);\n setIntervalId(id)\n return () => {\n\n clearInterval(id); // Cleanup function\n }\n }\n }, [delay]);\n\n return intervalId;\n}\n\nexport default useInterval","import { useState, useEffect } from \"react\";\n\nexport function useContainerWidth(ref: React.RefObject<HTMLElement | null>, renderId: string, initialWidth = 0) {\n const [width, setWidth] = useState(initialWidth);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) setWidth(entry.contentRect.width);\n });\n\n observer.observe(el);\n setWidth(el.getBoundingClientRect().width);\n\n return () => observer.disconnect();\n }, [ref, renderId]);\n\n return width;\n}\n\nexport function useContainerRectangle(ref: React.RefObject<HTMLElement | null>, renderId: string, initialWidth = 0, initialHeight = 0) {\n const [width, setWidth] = useState(initialWidth);\n const [height, setHeight] = useState(initialHeight);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) {\n setHeight(entry.contentRect.height);\n setWidth(entry.contentRect.width);\n }\n });\n\n observer.observe(el);\n setWidth(el.getBoundingClientRect().width);\n\n return () => observer.disconnect();\n }, [ref, renderId]);\n\n return [width, height];\n}"],"names":["newSessionId","__name","nextEnabledIndex","items","from","dir","n","idx","step","_a","plusDaysBR","d","dd","mm","usePromptAssist","adapter","fetchers","options","predictions","setPredictions","useState","personConfidence","setPersonConfidence","predictionsRecents","setPredictionsRecents","predictionHighlight","setPredictionHighlight","resolvedLocations","setResolvedLocations","resolvedDates","setResolvedDates","forceTooltipText","setForceTooltipText","lastResolvedKeyRef","useRef","tooltipTimerRef","adapterRef","fetchersRef","optionsRef","analyzeTimerRef","resolveTimerRef","analyzeSeqRef","suggestSeqRef","suggestAbortRef","draftRef","lastResolveTextRef","resolveAbortRef","sessionIdRef","predictionsRef","lastKindRef","locationPartialRef","runResolveRef","clearPredictions","useCallback","resetSession","applyPrediction","p","ad","ta","caret","rawBefore","after","isLocationPick","before","partial","trimmedEnd","wordStart","needsSpace","ins","next","mention","chr","t","runResolve","resolve","text","ac","dates","locations","resolved","l","key","r","scheduleAssist","value","isDeletion","analyze","seq","a","live","caretEnd","canLoc","pickerOpen","named","enableHashDatePicker","datePresets","decided","kind","genericTail","namedLocs","s","namedDates","prefill","suggest","hasNamed","c","insert","beforeCaret","wsIdx","trailingWord","q","exclude","m","sseq","live2","refined","it","firstEnabled","commit","finalText","_b","onKeyDown","e","i","useEffect","useInterval","callback","delay","savedCallback","intervalId","setIntervalId","tick","id","useContainerWidth","ref","renderId","initialWidth","width","setWidth","el","observer","entries","entry","useContainerRectangle","initialHeight","height","setHeight"],"mappings":";;;AA8CA,MAAMA,KAAe,gBAAAC,EAAA,MACjB,OAAO,SAAW,OAAe,OAAO,aAAa,OAAO,WAAA,IAAe,KAAK,KAAK,IAAA,CAAK,IAAI,KAAK,QAAQ,IAD1F,iBAIfC,KAAmB,gBAAAD,EAAA,CAACE,GAAyBC,GAAcC,MAAwB;;AACrF,QAAMC,IAAIH,EAAM;AAChB,MAAII,IAAMH;AACV,WAASI,IAAO,GAAGA,IAAOF,GAAGE;AAEzB,QADAD,KAAOA,IAAMF,IAAMC,KAAKA,GACpB,GAACG,IAAAN,EAAMI,CAAG,MAAT,QAAAE,EAAY,UAAU,QAAOF;AAEtC,SAAOH;AACX,GARyB,qBAWnBM,KAAa,gBAAAT,EAAA,CAACK,MAAc;AAC9B,QAAMK,wBAAQ,KAAA;AACd,EAAAA,EAAE,QAAQA,EAAE,QAAA,IAAYL,CAAC;AACzB,QAAMM,IAAK,OAAOD,EAAE,QAAA,CAAS,EAAE,SAAS,GAAG,GAAG,GACxCE,IAAK,OAAOF,EAAE,SAAA,IAAa,CAAC,EAAE,SAAS,GAAG,GAAG;AACnD,SAAO,GAAGC,CAAE,IAAIC,CAAE,IAAIF,EAAE,aAAa;AACzC,GANmB;AAcZ,SAASG,GACZC,GACAC,GACAC,IAA+B,CAAA,GACjC;AACE,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAkC,IAAI,GAItE,CAACC,GAAkBC,CAAmB,IAAIF,EAAS,CAAC,GAGpD,CAACG,GAAoBC,CAAqB,IAAIJ,EAAS,EAAK,GAC5D,CAACK,GAAqBC,CAAsB,IAAIN,EAAS,CAAC,GAC1D,CAACO,GAAmBC,EAAoB,IAAIR,EAAmB,CAAA,CAAE,GACjE,CAACS,IAAeC,EAAgB,IAAIV,EAA6B,CAAA,CAAE,GAGnE,CAACW,IAAkBC,CAAmB,IAAIZ,EAAS,E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 +1,53 @@
|
|
|
1
|
-
import { A as e, D as t, l as r, n as i, o, q as n, r as c, s as d, t as
|
|
2
|
-
import { A as g, a as U, b as E, G as
|
|
3
|
-
import { S as
|
|
1
|
+
import { A as e, D as t, l as r, n as i, o, q as n, r as c, s as d, t as A, u as l } from "./environmentUtils-CUVZ6Dq1.js";
|
|
2
|
+
import { A as g, a as U, b as E, G as S, d as p, c as m, e as B, f as L, g as f, h, i as v, j as N, k as D, l as _, m as C, n as b, o as x, p as O, q as G, r as V, s as k, t as F, u as T, v as u } from "./auth-BN22f1HF.js";
|
|
3
|
+
import { S as R, c as W, a as y, e as q, b as H, f as P, i as j, d as w, p as z, g as J, s as K, k as Y, t as Q } from "./atMentions-DqhG_vde.js";
|
|
4
4
|
export {
|
|
5
5
|
g as ALLOWED_DOMAINS,
|
|
6
6
|
U as ALLOWED_EMAILS,
|
|
7
7
|
e as ANALYTICS_AGENT_NAME,
|
|
8
8
|
E as AUTH_CONFIG,
|
|
9
9
|
t as DEV_SERVER_CONFIG,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
S as GOOGLE_CLIENT_ID,
|
|
11
|
+
R as SortableTable,
|
|
12
|
+
W as chipLocations,
|
|
13
|
+
y as chunkArray,
|
|
14
|
+
p as dateReviver,
|
|
15
|
+
m as decodeBase64,
|
|
16
16
|
B as decodeUri,
|
|
17
17
|
L as decodeUriFromPython,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
f as encodeBase64,
|
|
19
|
+
h as encodeUri,
|
|
20
20
|
q as extractInteractionId,
|
|
21
21
|
H as extractLinkAction,
|
|
22
|
-
|
|
22
|
+
P as fetchAtMentions,
|
|
23
|
+
v as getAgentBaseUrl,
|
|
23
24
|
r as getAgentServerBaseUrl,
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
N as getArtifactsBaseUrl,
|
|
26
|
+
D as getDotNetBaseUrl,
|
|
26
27
|
i as getEnvVar,
|
|
27
28
|
o as getEnvironmentInfo,
|
|
28
|
-
|
|
29
|
+
_ as getIconByName,
|
|
29
30
|
n as getRandomUUID,
|
|
30
31
|
c as getServerBaseUrl,
|
|
31
32
|
d as getServerClientBaseUrl,
|
|
32
33
|
C as iconCategories,
|
|
33
34
|
b as isBase64Encoded,
|
|
34
|
-
|
|
35
|
+
j as isSectionStart,
|
|
36
|
+
A as isServer,
|
|
35
37
|
x as isUriEncoded,
|
|
36
|
-
|
|
38
|
+
w as isValidInteractionId,
|
|
37
39
|
O as isValidUri,
|
|
38
40
|
G as materialIcons,
|
|
39
|
-
|
|
41
|
+
z as parseAndValidateArtifactUrl,
|
|
40
42
|
V as parseArtifactFromJson,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
J as parseKnownNumbers,
|
|
44
|
+
k as parseUriParams,
|
|
45
|
+
l as resolveApiUrl,
|
|
46
|
+
F as searchIcons,
|
|
47
|
+
T as setEbiContextData,
|
|
46
48
|
u as setEbiContextSessionId,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
K as splitBigLinesWithSpaces,
|
|
50
|
+
Y as startsWithInteractionId,
|
|
51
|
+
Q as tokenizeForHighlight
|
|
50
52
|
};
|
|
51
53
|
//# sourceMappingURL=utils.js.map
|