@opencx/widget-core 5.0.0-beta.6 → 5.0.0-beta.9
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/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1157 -977
- package/dist/index.js.map +1 -1
- package/dist/src/api/api-caller.d.ts +96 -1
- package/dist/src/api/api-caller.d.ts.map +1 -1
- package/dist/src/api/elicitation.d.ts +60 -0
- package/dist/src/api/elicitation.d.ts.map +1 -0
- package/dist/src/api/schema.d.ts +572 -52
- package/dist/src/api/schema.d.ts.map +1 -1
- package/dist/src/context/active-session-polling.ctx.d.ts +2 -0
- package/dist/src/context/active-session-polling.ctx.d.ts.map +1 -1
- package/dist/src/context/message.ctx.d.ts +4 -0
- package/dist/src/context/message.ctx.d.ts.map +1 -1
- package/dist/src/context/session.ctx.d.ts +5 -0
- package/dist/src/context/session.ctx.d.ts.map +1 -1
- package/dist/src/context/widget.ctx.d.ts +6 -1
- package/dist/src/context/widget.ctx.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types/messages.d.ts +2 -0
- package/dist/src/types/messages.d.ts.map +1 -1
- package/dist/src/types/widget-config.d.ts +2 -0
- package/dist/src/types/widget-config.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/src/__tests__/api/agent-stream-parts.spec.d.ts +0 -2
- package/dist/src/__tests__/api/agent-stream-parts.spec.d.ts.map +0 -1
- package/dist/src/__tests__/api/dictation-mint-cache.spec.d.ts +0 -2
- package/dist/src/__tests__/api/dictation-mint-cache.spec.d.ts.map +0 -1
- package/dist/src/__tests__/api/widget-api-wire.spec.d.ts +0 -2
- package/dist/src/__tests__/api/widget-api-wire.spec.d.ts.map +0 -1
- package/dist/src/__tests__/api-caller.mock.d.ts +0 -2
- package/dist/src/__tests__/api-caller.mock.d.ts.map +0 -1
- package/dist/src/__tests__/context/contact/auth/auto-create-unverified-anonymous.spec.d.ts +0 -1
- package/dist/src/__tests__/context/contact/auth/auto-create-unverified-anonymous.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/contact/auth/auto-create-unverified-with-user-data-provided-by-org.spec.d.ts +0 -1
- package/dist/src/__tests__/context/contact/auth/auto-create-unverified-with-user-data-provided-by-org.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/contact/auth/manually-create-unverified-with-user-data-provided-by-user.spec.d.ts +0 -1
- package/dist/src/__tests__/context/contact/auth/manually-create-unverified-with-user-data-provided-by-user.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/contact/auth/with-secure-token.spec.d.ts +0 -1
- package/dist/src/__tests__/context/contact/auth/with-secure-token.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/contact/should-collect-data.spec.d.ts +0 -1
- package/dist/src/__tests__/context/contact/should-collect-data.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/contact-ctx.create-failure.spec.d.ts +0 -2
- package/dist/src/__tests__/context/contact-ctx.create-failure.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/dictation-ctx.spec.d.ts +0 -1
- package/dist/src/__tests__/context/dictation-ctx.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message/merge-send-context.spec.d.ts +0 -2
- package/dist/src/__tests__/context/message/merge-send-context.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message/on-message-received-hook.spec.d.ts +0 -1
- package/dist/src/__tests__/context/message/on-message-received-hook.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message/pending-user-messages.spec.d.ts +0 -1
- package/dist/src/__tests__/context/message/pending-user-messages.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message/sent-text-history.spec.d.ts +0 -1
- package/dist/src/__tests__/context/message/sent-text-history.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message-ctx.agent-handlers.spec.d.ts +0 -2
- package/dist/src/__tests__/context/message-ctx.agent-handlers.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message-ctx.client-context.spec.d.ts +0 -2
- package/dist/src/__tests__/context/message-ctx.client-context.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message-ctx.mentions.spec.d.ts +0 -2
- package/dist/src/__tests__/context/message-ctx.mentions.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message-ctx.page-mark-chips.spec.d.ts +0 -2
- package/dist/src/__tests__/context/message-ctx.page-mark-chips.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message-ctx.send-acceptance.spec.d.ts +0 -2
- package/dist/src/__tests__/context/message-ctx.send-acceptance.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/message-ctx.send-features.spec.d.ts +0 -2
- package/dist/src/__tests__/context/message-ctx.send-features.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/reconcile-after-stream.spec.d.ts +0 -1
- package/dist/src/__tests__/context/reconcile-after-stream.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/resolve-client-presentation.spec.d.ts +0 -2
- package/dist/src/__tests__/context/resolve-client-presentation.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/restore-last-session.spec.d.ts +0 -2
- package/dist/src/__tests__/context/restore-last-session.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/session-ctx.stale-token-retry.spec.d.ts +0 -2
- package/dist/src/__tests__/context/session-ctx.stale-token-retry.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/storage-ctx.spec.d.ts +0 -2
- package/dist/src/__tests__/context/storage-ctx.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/streaming-engine.spec.d.ts +0 -1
- package/dist/src/__tests__/context/streaming-engine.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/upload.ctx.spec.d.ts +0 -2
- package/dist/src/__tests__/context/upload.ctx.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/widget-ctx.conversations.spec.d.ts +0 -1
- package/dist/src/__tests__/context/widget-ctx.conversations.spec.d.ts.map +0 -1
- package/dist/src/__tests__/context/widget-ctx.features.spec.d.ts +0 -1
- package/dist/src/__tests__/context/widget-ctx.features.spec.d.ts.map +0 -1
- package/dist/src/__tests__/dictation/dictation-commands.utils.spec.d.ts +0 -2
- package/dist/src/__tests__/dictation/dictation-commands.utils.spec.d.ts.map +0 -1
- package/dist/src/__tests__/test-utils.d.ts +0 -452
- package/dist/src/__tests__/test-utils.d.ts.map +0 -1
- package/dist/src/__tests__/translation.spec.d.ts +0 -2
- package/dist/src/__tests__/translation.spec.d.ts.map +0 -1
- package/dist/src/__tests__/utils/Poller.spec.d.ts +0 -2
- package/dist/src/__tests__/utils/Poller.spec.d.ts.map +0 -1
- package/dist/src/__tests__/utils/PrimitiveState.spec.d.ts +0 -2
- package/dist/src/__tests__/utils/PrimitiveState.spec.d.ts.map +0 -1
- package/dist/src/__tests__/utils/companion-layout.spec.d.ts +0 -2
- package/dist/src/__tests__/utils/companion-layout.spec.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,154 +1,295 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { z as h } from "zod";
|
|
2
|
+
import se from "openapi-fetch";
|
|
3
|
+
import oe from "lodash.isequal";
|
|
4
|
+
import { v4 as N } from "uuid";
|
|
5
|
+
const Ga = (n) => n.type === "data-keepalive", $a = (n) => n.type === "data-turn-steered", F = h.object({ const: h.string(), title: h.string().optional() }), ne = h.object({
|
|
6
|
+
type: h.enum(["string", "number", "integer", "boolean", "array"]),
|
|
7
|
+
title: h.string().optional(),
|
|
8
|
+
description: h.string().optional(),
|
|
9
|
+
default: h.union([h.string(), h.number(), h.boolean(), h.array(h.string())]).optional(),
|
|
10
|
+
enum: h.array(h.string()).optional(),
|
|
11
|
+
oneOf: h.array(F).optional(),
|
|
12
|
+
items: h.object({
|
|
13
|
+
enum: h.array(h.string()).optional(),
|
|
14
|
+
anyOf: h.array(F).optional()
|
|
15
|
+
}).optional(),
|
|
16
|
+
minItems: h.number().int().nonnegative().optional(),
|
|
17
|
+
maxItems: h.number().int().nonnegative().optional(),
|
|
18
|
+
minimum: h.number().optional(),
|
|
19
|
+
maximum: h.number().optional(),
|
|
20
|
+
minLength: h.number().optional(),
|
|
21
|
+
maxLength: h.number().optional(),
|
|
22
|
+
format: h.string().optional()
|
|
23
|
+
}), ie = h.array(
|
|
24
|
+
h.object({
|
|
25
|
+
id: h.string(),
|
|
26
|
+
serverId: h.string(),
|
|
27
|
+
serverName: h.string(),
|
|
28
|
+
expiresAt: h.number(),
|
|
29
|
+
approvalKey: h.string().optional(),
|
|
30
|
+
form: h.object({
|
|
31
|
+
message: h.string(),
|
|
32
|
+
requestedSchema: h.object({
|
|
33
|
+
properties: h.record(h.string(), ne),
|
|
34
|
+
required: h.array(h.string()).optional()
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
), re = h.array(
|
|
39
|
+
h.object({
|
|
40
|
+
key: h.string(),
|
|
41
|
+
serverId: h.string(),
|
|
42
|
+
serverName: h.string(),
|
|
43
|
+
message: h.string(),
|
|
44
|
+
toolName: h.string()
|
|
45
|
+
})
|
|
46
|
+
), O = "[opencx]", k = {
|
|
5
47
|
warn: (n, ...e) => {
|
|
6
|
-
console.warn(`${
|
|
48
|
+
console.warn(`${O} ${n}`, ...e);
|
|
7
49
|
},
|
|
8
50
|
error: (n, ...e) => {
|
|
9
|
-
console.error(`${
|
|
51
|
+
console.error(`${O} ${n}`, ...e);
|
|
10
52
|
}
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
const e =
|
|
53
|
+
}, _e = (n) => {
|
|
54
|
+
k.error("request failed", n.error);
|
|
55
|
+
}, le = (n) => {
|
|
56
|
+
const e = se({
|
|
15
57
|
baseUrl: n.baseUrl
|
|
16
|
-
}),
|
|
58
|
+
}), t = {
|
|
17
59
|
onRequest: n.onRequest,
|
|
18
60
|
onResponse: n.onResponse,
|
|
19
|
-
onError: n.onError ||
|
|
61
|
+
onError: n.onError || _e
|
|
20
62
|
};
|
|
21
|
-
return e.use(
|
|
22
|
-
}
|
|
23
|
-
class
|
|
63
|
+
return e.use(t), e;
|
|
64
|
+
};
|
|
65
|
+
class ce extends Error {
|
|
66
|
+
constructor() {
|
|
67
|
+
super("This connection request expired. Preparing a new request."), this.name = "ConnectionRequestExpiredError";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class pe extends Error {
|
|
71
|
+
constructor() {
|
|
72
|
+
super("This connection attempt is no longer available."), this.name = "ConnectionAttemptUnavailableError";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const de = "/backend/widget/v5/chat/stream", ue = "/backend/widget/v5/chat/{sessionId}/stream", U = (n, e, t) => `${n.replace(/\/$/, "")}${t ? e.replace("{sessionId}", encodeURIComponent(t)) : e}`;
|
|
76
|
+
class B {
|
|
24
77
|
constructor({ config: e }) {
|
|
25
|
-
var
|
|
26
|
-
this.userToken = null, this.constructClientOptions = (
|
|
27
|
-
const
|
|
78
|
+
var r, l;
|
|
79
|
+
this.userToken = null, this.constructClientOptions = (s) => {
|
|
80
|
+
const a = this.config.apiUrl || "https://api.open.cx", i = {
|
|
28
81
|
"X-Bot-Token": this.config.token,
|
|
29
82
|
"Content-Type": "application/json",
|
|
30
83
|
Accept: "application/json",
|
|
31
|
-
Authorization:
|
|
84
|
+
Authorization: s ? `Bearer ${s}` : void 0
|
|
32
85
|
};
|
|
33
|
-
return { baseUrl:
|
|
86
|
+
return { baseUrl: a, headers: i };
|
|
34
87
|
}, this.createOpenAPIClient = ({
|
|
35
|
-
baseUrl:
|
|
36
|
-
headers:
|
|
37
|
-
}) =>
|
|
38
|
-
baseUrl:
|
|
39
|
-
onRequest: ({ request:
|
|
40
|
-
Object.entries(
|
|
41
|
-
d &&
|
|
88
|
+
baseUrl: s,
|
|
89
|
+
headers: a
|
|
90
|
+
}) => le({
|
|
91
|
+
baseUrl: s,
|
|
92
|
+
onRequest: ({ request: i }) => {
|
|
93
|
+
Object.entries(a).forEach(([c, d]) => {
|
|
94
|
+
d && i.headers.set(c, d);
|
|
42
95
|
});
|
|
43
96
|
}
|
|
44
|
-
}), this.
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
97
|
+
}), this.listApprovalPreferences = async () => {
|
|
98
|
+
const { baseUrl: s, headers: a } = this.getStreamAuthContext(), i = await fetch(
|
|
99
|
+
`${s}/backend/widget/v5/connections/approval-preferences`,
|
|
100
|
+
{ headers: a }
|
|
101
|
+
);
|
|
102
|
+
if (!i.ok) throw new Error("Could not load permissions.");
|
|
103
|
+
return re.parse(await i.json());
|
|
104
|
+
}, this.revokeApprovalPreference = async (s, a) => {
|
|
105
|
+
const { baseUrl: i, headers: c } = this.getStreamAuthContext();
|
|
106
|
+
if (!(await fetch(
|
|
107
|
+
`${i}/backend/widget/v5/connections/${encodeURIComponent(s)}/approval-preferences/${encodeURIComponent(a)}`,
|
|
108
|
+
{ method: "DELETE", headers: c }
|
|
109
|
+
)).ok) throw new Error("Could not reset permission.");
|
|
110
|
+
}, this.listElicitations = async (s, a) => {
|
|
111
|
+
const { baseUrl: i, headers: c } = this.getStreamAuthContext(), d = await fetch(
|
|
112
|
+
`${i}/backend/widget/v5/connections/elicitation/${encodeURIComponent(s)}`,
|
|
113
|
+
{ headers: c, signal: a }
|
|
114
|
+
);
|
|
115
|
+
if (!d.ok) throw new Error("Could not load the request.");
|
|
116
|
+
return ie.parse(await d.json());
|
|
117
|
+
}, this.answerElicitation = async (s, a, i) => {
|
|
118
|
+
const { baseUrl: c, headers: d } = this.getStreamAuthContext(), _ = await fetch(
|
|
119
|
+
`${c}/backend/widget/v5/connections/elicitation/${encodeURIComponent(s)}/${encodeURIComponent(a)}`,
|
|
120
|
+
{
|
|
121
|
+
method: "POST",
|
|
122
|
+
headers: { ...d, "Content-Type": "application/json" },
|
|
123
|
+
body: JSON.stringify(i)
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
if (!_.ok)
|
|
127
|
+
throw new Error(
|
|
128
|
+
_.status === 400 ? "Check your answers and try again." : "This request has ended. Ask the agent to try again."
|
|
129
|
+
);
|
|
130
|
+
}, this.listConnections = async (s) => {
|
|
131
|
+
const { data: a, error: i } = await this.client.GET(
|
|
132
|
+
"/backend/widget/v5/connections",
|
|
133
|
+
{ signal: s }
|
|
134
|
+
);
|
|
135
|
+
if (i || !a)
|
|
136
|
+
throw new Error("Could not load connections. Sign in and try again.");
|
|
137
|
+
return a;
|
|
138
|
+
}, this.startConnection = async (s, a, i) => {
|
|
139
|
+
const { data: c, error: d, response: _ } = await this.client.POST(
|
|
140
|
+
"/backend/widget/v5/connections/{serverId}/start",
|
|
141
|
+
{
|
|
142
|
+
params: { path: { serverId: s } },
|
|
143
|
+
body: { request_id: a },
|
|
144
|
+
signal: i
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
if (_.status === 410) throw new ce();
|
|
148
|
+
if (_.status === 404)
|
|
149
|
+
throw new Error("This connection request is no longer available.");
|
|
150
|
+
if (d || !c)
|
|
151
|
+
throw new Error("Could not start this connection. Please try again.");
|
|
152
|
+
return c;
|
|
153
|
+
}, this.getConnectionAttempt = async (s, a, i) => {
|
|
154
|
+
const { data: c, error: d, response: _ } = await this.client.GET(
|
|
155
|
+
"/backend/widget/v5/connections/{serverId}/attempts/{attemptId}",
|
|
156
|
+
{
|
|
157
|
+
params: { path: { serverId: s, attemptId: a } },
|
|
158
|
+
signal: i
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
if ([401, 403, 404].includes(_.status))
|
|
162
|
+
throw new pe();
|
|
163
|
+
if (d || !c)
|
|
164
|
+
throw new Error(`Could not check the connection (${_.status}).`);
|
|
165
|
+
return c.status;
|
|
166
|
+
}, this.disconnectConnection = async (s) => {
|
|
167
|
+
const { error: a } = await this.client.DELETE(
|
|
168
|
+
"/backend/widget/v5/connections/{serverId}",
|
|
169
|
+
{
|
|
170
|
+
params: { path: { serverId: s } }
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
if (a) throw new Error("Could not disconnect. Please try again.");
|
|
174
|
+
}, this.setAuthToken = (s) => {
|
|
175
|
+
this.userToken = s;
|
|
176
|
+
const { baseUrl: a, headers: i } = this.constructClientOptions(s);
|
|
177
|
+
this.client = this.createOpenAPIClient({ baseUrl: a, headers: i });
|
|
48
178
|
}, this.getStreamAuthContext = () => {
|
|
49
|
-
const { baseUrl:
|
|
50
|
-
for (const [c, d] of Object.entries(
|
|
51
|
-
typeof d == "string" && (["content-type", "accept"].includes(c.toLowerCase()) || (
|
|
52
|
-
return { baseUrl:
|
|
179
|
+
const { baseUrl: s, headers: a } = this.constructClientOptions(this.userToken), i = {};
|
|
180
|
+
for (const [c, d] of Object.entries(a))
|
|
181
|
+
typeof d == "string" && (["content-type", "accept"].includes(c.toLowerCase()) || (i[c] = d));
|
|
182
|
+
return { baseUrl: s, headers: i };
|
|
53
183
|
}, this.getStreamTransportOptions = () => {
|
|
54
|
-
const { baseUrl:
|
|
184
|
+
const { baseUrl: s, headers: a } = this.getStreamAuthContext();
|
|
55
185
|
return {
|
|
56
|
-
api:
|
|
57
|
-
reconnectApi: (
|
|
58
|
-
headers:
|
|
186
|
+
api: U(s, de),
|
|
187
|
+
reconnectApi: (i) => U(s, ue, i),
|
|
188
|
+
headers: a
|
|
59
189
|
};
|
|
60
|
-
}, this.stopStream = async (
|
|
61
|
-
const { response:
|
|
190
|
+
}, this.stopStream = async (s) => {
|
|
191
|
+
const { response: a } = await this.client.POST(
|
|
62
192
|
"/backend/widget/v5/chat/{sessionId}/stop",
|
|
63
|
-
{ params: { path: { sessionId:
|
|
193
|
+
{ params: { path: { sessionId: s } } }
|
|
64
194
|
);
|
|
65
|
-
if (!
|
|
66
|
-
throw new Error(`Failed to stop stream: ${
|
|
67
|
-
}, this.
|
|
68
|
-
|
|
195
|
+
if (!a.ok)
|
|
196
|
+
throw new Error(`Failed to stop stream: ${a.status}`);
|
|
197
|
+
}, this.sendPageReply = async (s, a) => {
|
|
198
|
+
try {
|
|
199
|
+
await this.client.POST("/backend/widget/v5/chat/{sessionId}/page-reply", {
|
|
200
|
+
params: { path: { sessionId: s } },
|
|
201
|
+
body: a
|
|
202
|
+
});
|
|
203
|
+
} catch {
|
|
204
|
+
}
|
|
205
|
+
}, this.getAgentTurnMessages = async (s, a) => {
|
|
206
|
+
const { data: i, response: c } = await this.client.GET(
|
|
69
207
|
"/backend/widget/v5/chat/{sessionId}/messages",
|
|
70
208
|
{
|
|
71
209
|
params: {
|
|
72
|
-
path: { sessionId:
|
|
210
|
+
path: { sessionId: s },
|
|
73
211
|
query: {
|
|
74
|
-
toolActivity:
|
|
75
|
-
reasoning: (
|
|
212
|
+
toolActivity: a == null ? void 0 : a.toolActivity,
|
|
213
|
+
reasoning: (a == null ? void 0 : a.reasoning) === void 0 ? void 0 : a.reasoning ? "true" : "false"
|
|
76
214
|
}
|
|
77
215
|
}
|
|
78
216
|
}
|
|
79
217
|
);
|
|
80
|
-
return
|
|
218
|
+
return i ? {
|
|
219
|
+
...i,
|
|
220
|
+
handled_connection_request_ids: i.handled_connection_request_ids ?? []
|
|
221
|
+
} : (k.warn("agent turn messages fetch failed", c.status), null);
|
|
81
222
|
}, this.createDictationSession = async ({
|
|
82
|
-
language:
|
|
223
|
+
language: s
|
|
83
224
|
}) => {
|
|
84
|
-
const { data:
|
|
225
|
+
const { data: a, response: i } = await this.client.POST(
|
|
85
226
|
"/backend/widget/v5/dictation/sessions",
|
|
86
|
-
{ body:
|
|
227
|
+
{ body: s ? { language: s } : {} }
|
|
87
228
|
);
|
|
88
|
-
if (!
|
|
89
|
-
throw new Error(`Failed to start dictation: ${
|
|
90
|
-
return
|
|
229
|
+
if (!a)
|
|
230
|
+
throw new Error(`Failed to start dictation: ${i.status}`);
|
|
231
|
+
return a;
|
|
91
232
|
}, this.getExternalWidgetConfig = async () => await this.client.GET("/backend/widget/v2/config", {
|
|
92
233
|
params: {
|
|
93
234
|
header: { "x-bot-token": this.config.token }
|
|
94
235
|
}
|
|
95
|
-
}), this.sendMessage = async (
|
|
96
|
-
body:
|
|
97
|
-
signal:
|
|
98
|
-
}), this.createUnverifiedContact = async (
|
|
236
|
+
}), this.sendMessage = async (s, a) => await this.client.POST("/backend/widget/v2/chat/send", {
|
|
237
|
+
body: s,
|
|
238
|
+
signal: a
|
|
239
|
+
}), this.createUnverifiedContact = async (s) => await this.client.POST(
|
|
99
240
|
"/backend/widget/v2/contact/create-unverified",
|
|
100
241
|
{
|
|
101
242
|
params: { header: { "x-bot-token": this.config.token } },
|
|
102
|
-
body:
|
|
243
|
+
body: s
|
|
103
244
|
}
|
|
104
|
-
), this.createSession = async (
|
|
105
|
-
body:
|
|
106
|
-
signal:
|
|
245
|
+
), this.createSession = async (s, a) => await this.client.POST("/backend/widget/v2/create-session", {
|
|
246
|
+
body: s,
|
|
247
|
+
signal: a
|
|
107
248
|
}), this.pollSessionAndHistory = async ({
|
|
108
|
-
sessionId:
|
|
109
|
-
abortSignal:
|
|
249
|
+
sessionId: s,
|
|
250
|
+
abortSignal: a
|
|
110
251
|
}) => await this.client.GET("/backend/widget/v2/poll/{sessionId}", {
|
|
111
|
-
params: { path: { sessionId:
|
|
112
|
-
signal:
|
|
252
|
+
params: { path: { sessionId: s } },
|
|
253
|
+
signal: a
|
|
113
254
|
}), this.getSessions = async ({
|
|
114
|
-
cursor:
|
|
115
|
-
filters:
|
|
116
|
-
abortSignal:
|
|
255
|
+
cursor: s,
|
|
256
|
+
filters: a,
|
|
257
|
+
abortSignal: i
|
|
117
258
|
}) => await this.client.GET("/backend/widget/v2/sessions", {
|
|
118
259
|
params: {
|
|
119
260
|
query: {
|
|
120
|
-
offset:
|
|
121
|
-
filters: JSON.stringify(
|
|
261
|
+
offset: s,
|
|
262
|
+
filters: JSON.stringify(a)
|
|
122
263
|
}
|
|
123
264
|
},
|
|
124
|
-
signal:
|
|
265
|
+
signal: i
|
|
125
266
|
}), this.uploadFile = async ({
|
|
126
|
-
file:
|
|
127
|
-
abortSignal:
|
|
128
|
-
onProgress:
|
|
267
|
+
file: s,
|
|
268
|
+
abortSignal: a,
|
|
269
|
+
onProgress: i
|
|
129
270
|
}) => new Promise((c, d) => {
|
|
130
|
-
var
|
|
131
|
-
const
|
|
132
|
-
|
|
271
|
+
var f;
|
|
272
|
+
const _ = new FormData();
|
|
273
|
+
_.append("file", s);
|
|
133
274
|
const p = new XMLHttpRequest();
|
|
134
|
-
if (
|
|
275
|
+
if (a && (a.addEventListener("abort", () => {
|
|
135
276
|
p.abort(), d(new DOMException("Aborted", "AbortError"));
|
|
136
|
-
}),
|
|
277
|
+
}), a.aborted)) {
|
|
137
278
|
d(new DOMException("Aborted", "AbortError"));
|
|
138
279
|
return;
|
|
139
280
|
}
|
|
140
|
-
p.upload.addEventListener("progress", (
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
|
|
281
|
+
p.upload.addEventListener("progress", (b) => {
|
|
282
|
+
if (b.lengthComputable && i) {
|
|
283
|
+
const w = Math.round(b.loaded / b.total * 100);
|
|
284
|
+
i(w);
|
|
144
285
|
}
|
|
145
286
|
}), p.addEventListener("load", () => {
|
|
146
287
|
if (p.status >= 200 && p.status < 300)
|
|
147
288
|
try {
|
|
148
|
-
const
|
|
149
|
-
c(
|
|
150
|
-
} catch (
|
|
151
|
-
d(new Error(`Failed to parse response: ${
|
|
289
|
+
const b = JSON.parse(p.responseText);
|
|
290
|
+
c(b);
|
|
291
|
+
} catch (b) {
|
|
292
|
+
d(new Error(`Failed to parse response: ${b}`));
|
|
152
293
|
}
|
|
153
294
|
else
|
|
154
295
|
d(new Error(`Upload failed with status: ${p.status}`));
|
|
@@ -158,196 +299,207 @@ class O {
|
|
|
158
299
|
d(new Error("Upload timed out"));
|
|
159
300
|
});
|
|
160
301
|
const { baseUrl: u } = this.constructClientOptions(this.userToken), g = `${u}/backend/widget/v2/upload`;
|
|
161
|
-
p.open("POST", g), p.setRequestHeader("X-Bot-Token", this.config.token), this.userToken ?? ((
|
|
162
|
-
}), this.vote = async (
|
|
163
|
-
body:
|
|
164
|
-
signal:
|
|
165
|
-
}), this.createStateCheckpoint = async (
|
|
166
|
-
body:
|
|
167
|
-
}), this.submitCsat = async (
|
|
168
|
-
const { baseUrl:
|
|
169
|
-
(
|
|
302
|
+
p.open("POST", g), p.setRequestHeader("X-Bot-Token", this.config.token), this.userToken ?? ((f = this.config.user) == null ? void 0 : f.token) ? p.setRequestHeader("Authorization", `Bearer ${this.userToken}`) : k.error("user token not set"), p.send(_);
|
|
303
|
+
}), this.vote = async (s) => await this.client.POST("/backend/widget/v2/chat/vote", { body: s }), this.resolveSession = async (s, a) => await this.client.POST("/backend/widget/v2/session/resolve", {
|
|
304
|
+
body: s,
|
|
305
|
+
signal: a
|
|
306
|
+
}), this.createStateCheckpoint = async (s) => await this.client.POST("/backend/widget/v2/checkpoint", {
|
|
307
|
+
body: s
|
|
308
|
+
}), this.submitCsat = async (s) => await this.client.POST("/backend/widget/v2/submit-csat", { body: s }), this.config = e, this.userToken = ((r = e.user) == null ? void 0 : r.token) || null;
|
|
309
|
+
const { baseUrl: t, headers: o } = this.constructClientOptions(
|
|
310
|
+
(l = e.user) == null ? void 0 : l.token
|
|
170
311
|
);
|
|
171
|
-
this.client = this.createOpenAPIClient({ baseUrl:
|
|
312
|
+
this.client = this.createOpenAPIClient({ baseUrl: t, headers: o });
|
|
172
313
|
}
|
|
173
314
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
315
|
+
function me(n, e) {
|
|
316
|
+
k.error(`missing case for ${n} in ${e}`);
|
|
176
317
|
}
|
|
177
|
-
class
|
|
318
|
+
class S {
|
|
178
319
|
constructor(e) {
|
|
179
|
-
this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (
|
|
180
|
-
|
|
181
|
-
}, this.setPartial = (
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
this.set(
|
|
320
|
+
this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (t) => {
|
|
321
|
+
oe(this.state, t) || (this.state = t, this.notifySubscribers(t));
|
|
322
|
+
}, this.setPartial = (t) => {
|
|
323
|
+
if (t == null) return;
|
|
324
|
+
const o = { ...this.state, ...t };
|
|
325
|
+
this.set(o);
|
|
185
326
|
}, this.reset = () => {
|
|
186
327
|
this.set(this.initialState);
|
|
187
|
-
}, this.notifySubscribers = (
|
|
188
|
-
Array.from(this.subscribers).forEach((
|
|
328
|
+
}, this.notifySubscribers = (t) => {
|
|
329
|
+
Array.from(this.subscribers).forEach((r) => {
|
|
189
330
|
try {
|
|
190
|
-
|
|
191
|
-
} catch (
|
|
192
|
-
|
|
331
|
+
r(t);
|
|
332
|
+
} catch (l) {
|
|
333
|
+
k.error("state subscriber threw", l);
|
|
193
334
|
}
|
|
194
335
|
});
|
|
195
|
-
}, this.subscribe = (
|
|
196
|
-
this.subscribers.delete(
|
|
336
|
+
}, this.subscribe = (t) => (this.subscribers.add(t), () => {
|
|
337
|
+
this.subscribers.delete(t);
|
|
197
338
|
}), this.state = e, this.initialState = e;
|
|
198
339
|
}
|
|
199
340
|
}
|
|
200
|
-
class
|
|
341
|
+
class G {
|
|
201
342
|
constructor() {
|
|
202
|
-
this.state = new
|
|
343
|
+
this.state = new S({
|
|
203
344
|
isPolling: !1,
|
|
204
345
|
isError: !1
|
|
205
346
|
}), this.abortController = new AbortController(), this.reset = () => {
|
|
206
347
|
var e;
|
|
207
348
|
this.abortController.abort("Resetting poller"), (e = this.stopPolling) == null || e.call(this), this.stopPolling = null;
|
|
208
|
-
}, this.stopPolling = null, this.startPolling = (e,
|
|
349
|
+
}, this.stopPolling = null, this.startPolling = (e, t) => {
|
|
209
350
|
if (this.stopPolling) return;
|
|
210
|
-
const
|
|
351
|
+
const o = [], r = async () => {
|
|
211
352
|
this.abortController = new AbortController(), this.state.setPartial({ isPolling: !0 });
|
|
212
353
|
try {
|
|
213
354
|
await e(this.abortController.signal);
|
|
214
|
-
} catch (
|
|
355
|
+
} catch (l) {
|
|
215
356
|
if (this.abortController.signal.aborted)
|
|
216
357
|
return;
|
|
217
|
-
|
|
358
|
+
k.error("failed to poll", l), this.state.setPartial({ isError: !0 });
|
|
218
359
|
} finally {
|
|
219
360
|
this.state.setPartial({ isPolling: !1 });
|
|
220
361
|
}
|
|
221
|
-
this.abortController.signal.aborted ||
|
|
362
|
+
this.abortController.signal.aborted || o.push(setTimeout(r, t));
|
|
222
363
|
};
|
|
223
|
-
|
|
224
|
-
|
|
364
|
+
r(), this.stopPolling = () => {
|
|
365
|
+
o.forEach(clearTimeout), this.state.reset();
|
|
225
366
|
};
|
|
226
367
|
};
|
|
227
368
|
}
|
|
228
369
|
}
|
|
229
|
-
function
|
|
370
|
+
function $(n) {
|
|
230
371
|
try {
|
|
231
372
|
const e = n();
|
|
232
|
-
return e instanceof Promise ? e.then((
|
|
373
|
+
return e instanceof Promise ? e.then((t) => ({ data: t })).catch((t) => ({ error: t })) : { data: e };
|
|
233
374
|
} catch (e) {
|
|
234
375
|
return { error: e };
|
|
235
376
|
}
|
|
236
377
|
}
|
|
237
|
-
class
|
|
378
|
+
class he {
|
|
238
379
|
constructor({
|
|
239
380
|
api: e,
|
|
240
|
-
config:
|
|
241
|
-
sessionCtx:
|
|
242
|
-
messageCtx:
|
|
243
|
-
sessionPollingIntervalSeconds:
|
|
381
|
+
config: t,
|
|
382
|
+
sessionCtx: o,
|
|
383
|
+
messageCtx: r,
|
|
384
|
+
sessionPollingIntervalSeconds: l
|
|
244
385
|
}) {
|
|
245
|
-
this.poller = new
|
|
246
|
-
this.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
try {
|
|
253
|
-
this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.fetchSessionAndHistory({
|
|
254
|
-
sessionId: o.id,
|
|
255
|
-
abortSignal: this.fetchSessionAndFullHistoryAbortController.signal
|
|
386
|
+
this.poller = new G(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.reconcileAbortController = new AbortController(), this.subscriptions = [], this.reconcilingSessionId = null, this.registerPolling = () => {
|
|
387
|
+
this.subscriptions.push(
|
|
388
|
+
this.sessionCtx.sessionState.subscribe(({ session: s }) => {
|
|
389
|
+
s != null && s.id ? this.poller.startPolling(async (a) => {
|
|
390
|
+
this.fetchSessionAndHistory({
|
|
391
|
+
sessionId: s.id,
|
|
392
|
+
abortSignal: a
|
|
256
393
|
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
394
|
+
}, this.sessionPollingIntervalSeconds * 1e3) : this.poller.reset();
|
|
395
|
+
})
|
|
396
|
+
), this.subscriptions.push(
|
|
397
|
+
this.sessionCtx.sessionState.subscribe(({ session: s }) => {
|
|
398
|
+
if (s != null && s.id && !s.isOpened)
|
|
399
|
+
try {
|
|
400
|
+
this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.fetchSessionAndHistory({
|
|
401
|
+
sessionId: s.id,
|
|
402
|
+
abortSignal: this.fetchSessionAndFullHistoryAbortController.signal
|
|
403
|
+
});
|
|
404
|
+
} catch (a) {
|
|
405
|
+
this.fetchSessionAndFullHistoryAbortController.signal.aborted || k.error("failed to fetch session and full history", a);
|
|
406
|
+
}
|
|
407
|
+
else
|
|
408
|
+
this.fetchSessionAndFullHistoryAbortController.abort();
|
|
409
|
+
})
|
|
410
|
+
), this.subscriptions.push(
|
|
411
|
+
this.sessionCtx.sessionState.subscribe(({ session: s }) => {
|
|
412
|
+
this.reconcilingSessionId !== null && (s == null ? void 0 : s.id) !== this.reconcilingSessionId && this.reconcileAbortController.abort();
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
}, this.dispose = () => {
|
|
416
|
+
this.poller.reset(), this.fetchSessionAndFullHistoryAbortController.abort(), this.reconcileAbortController.abort(), this.reconcilingSessionId = null, this.subscriptions.forEach((s) => s()), this.subscriptions = [];
|
|
417
|
+
}, this.reconcileAfterStream = async (s) => {
|
|
266
418
|
this.reconcileAbortController.abort(), this.reconcileAbortController = new AbortController();
|
|
267
|
-
const { signal:
|
|
268
|
-
this.reconcilingSessionId =
|
|
419
|
+
const { signal: a } = this.reconcileAbortController;
|
|
420
|
+
this.reconcilingSessionId = s;
|
|
269
421
|
try {
|
|
270
|
-
await this.fetchSessionAndHistory({ sessionId:
|
|
271
|
-
} catch (
|
|
272
|
-
if (!
|
|
422
|
+
await this.fetchSessionAndHistory({ sessionId: s, abortSignal: a });
|
|
423
|
+
} catch (i) {
|
|
424
|
+
if (!a.aborted) throw i;
|
|
273
425
|
} finally {
|
|
274
|
-
this.reconcilingSessionId ===
|
|
426
|
+
this.reconcilingSessionId === s && (this.reconcilingSessionId = null);
|
|
275
427
|
}
|
|
276
428
|
}, this.fetchSessionAndHistory = async ({
|
|
277
|
-
sessionId:
|
|
278
|
-
abortSignal:
|
|
429
|
+
sessionId: s,
|
|
430
|
+
abortSignal: a
|
|
279
431
|
}) => {
|
|
280
|
-
const
|
|
281
|
-
|
|
432
|
+
const i = this.messageCtx.state.get().messages.length === 0;
|
|
433
|
+
i && this.messageCtx.state.setPartial({ isInitialFetchLoading: !0 });
|
|
282
434
|
const { data: c } = await this.api.pollSessionAndHistory({
|
|
283
|
-
sessionId:
|
|
284
|
-
abortSignal:
|
|
435
|
+
sessionId: s,
|
|
436
|
+
abortSignal: a
|
|
285
437
|
});
|
|
286
438
|
if (c != null && c.session && (this.sessionCtx.sessionState.setPartial({ session: c.session }), this.sessionCtx.setSessions([c.session])), c != null && c.history && c.history.length > 0) {
|
|
287
|
-
const d = this.messageCtx.state.get().messages,
|
|
439
|
+
const d = this.messageCtx.state.get().messages, _ = c.history.map(this.mapHistoryToMessage).filter((p) => p !== null).filter(
|
|
288
440
|
(p) => !d.some((u) => u.id === p.id)
|
|
289
441
|
);
|
|
290
|
-
if (
|
|
442
|
+
if (_.length > 0)
|
|
291
443
|
if (this.messageCtx.state.setPartial({
|
|
292
|
-
messages: [...d, ...
|
|
293
|
-
}),
|
|
444
|
+
messages: [...d, ..._]
|
|
445
|
+
}), i)
|
|
294
446
|
this.messageCtx.markAsDispatchedToOnMessageReceivedHook(
|
|
295
|
-
|
|
447
|
+
_.map((p) => p.id)
|
|
296
448
|
);
|
|
297
449
|
else
|
|
298
|
-
for (const p of
|
|
450
|
+
for (const p of _)
|
|
299
451
|
this.messageCtx.dispatchToOnMessageReceivedHook(p);
|
|
300
452
|
}
|
|
301
453
|
this.messageCtx.state.get().isInitialFetchLoading && this.messageCtx.state.setPartial({ isInitialFetchLoading: !1 });
|
|
302
|
-
}, this.mapHistoryToMessage = (
|
|
303
|
-
var
|
|
304
|
-
const
|
|
305
|
-
id:
|
|
306
|
-
timestamp:
|
|
307
|
-
attachments:
|
|
454
|
+
}, this.mapHistoryToMessage = (s) => {
|
|
455
|
+
var i;
|
|
456
|
+
const a = {
|
|
457
|
+
id: s.publicId,
|
|
458
|
+
timestamp: s.sentAt || "",
|
|
459
|
+
attachments: s.attachments || void 0
|
|
308
460
|
};
|
|
309
|
-
if (
|
|
461
|
+
if (s.sender.kind === "user")
|
|
310
462
|
return {
|
|
311
|
-
...
|
|
463
|
+
...a,
|
|
312
464
|
type: "USER",
|
|
313
|
-
content:
|
|
465
|
+
content: s.content.text || "",
|
|
314
466
|
// Backend field name (schema.ts) → widget vocabulary.
|
|
315
|
-
markedElements:
|
|
467
|
+
markedElements: s.pickedElements
|
|
316
468
|
};
|
|
317
|
-
if (
|
|
469
|
+
if (s.sender.kind === "agent")
|
|
318
470
|
return {
|
|
319
|
-
...
|
|
471
|
+
...a,
|
|
320
472
|
type: "AGENT",
|
|
321
473
|
component: "agent_message",
|
|
322
474
|
data: {
|
|
323
|
-
message:
|
|
475
|
+
message: s.content.text || ""
|
|
324
476
|
},
|
|
325
477
|
agent: {
|
|
326
|
-
name:
|
|
478
|
+
name: s.sender.name || "",
|
|
327
479
|
// Do not set avatarUrl from config here... let it be taken from the config at render time
|
|
328
480
|
// Only set avatar url from the backend's response
|
|
329
|
-
avatarUrl:
|
|
330
|
-
avatar:
|
|
481
|
+
avatarUrl: s.sender.avatar || null,
|
|
482
|
+
avatar: s.sender.avatar || null,
|
|
331
483
|
id: null,
|
|
332
484
|
isAi: !1
|
|
333
485
|
}
|
|
334
486
|
};
|
|
335
|
-
if (
|
|
336
|
-
const c =
|
|
487
|
+
if (s.sender.kind === "ai") {
|
|
488
|
+
const c = s.actionCalls && s.actionCalls.length > 0 ? s.actionCalls[s.actionCalls.length - 1] : void 0;
|
|
337
489
|
return {
|
|
338
|
-
...
|
|
490
|
+
...a,
|
|
339
491
|
type: "AI",
|
|
340
492
|
component: "bot_message",
|
|
341
493
|
agent: {
|
|
342
494
|
id: null,
|
|
343
|
-
name: ((
|
|
495
|
+
name: ((i = this.config.bot) == null ? void 0 : i.name) || "",
|
|
344
496
|
isAi: !0,
|
|
345
497
|
// Do not set avatarUrl from config here... let it be taken from the config at render time
|
|
346
498
|
avatarUrl: null,
|
|
347
499
|
avatar: null
|
|
348
500
|
},
|
|
349
501
|
data: {
|
|
350
|
-
message:
|
|
502
|
+
message: s.content.text || "",
|
|
351
503
|
action: c ? {
|
|
352
504
|
name: c.actionName,
|
|
353
505
|
data: this.extractActionResult(c)
|
|
@@ -355,136 +507,136 @@ class _e {
|
|
|
355
507
|
}
|
|
356
508
|
};
|
|
357
509
|
}
|
|
358
|
-
if (
|
|
359
|
-
const c = this.constructSystemMessage(
|
|
510
|
+
if (s.sender.kind === "system") {
|
|
511
|
+
const c = this.constructSystemMessage(s);
|
|
360
512
|
return c === null ? null : { ...c };
|
|
361
513
|
}
|
|
362
514
|
return null;
|
|
363
|
-
}, this.constructSystemMessage = (
|
|
364
|
-
if (!
|
|
365
|
-
switch (
|
|
515
|
+
}, this.constructSystemMessage = (s) => {
|
|
516
|
+
if (!s || !s.systemMessagePayload) return null;
|
|
517
|
+
switch (s.systemMessagePayload.type) {
|
|
366
518
|
case "state_checkpoint":
|
|
367
519
|
return {
|
|
368
|
-
id:
|
|
520
|
+
id: s.publicId,
|
|
369
521
|
type: "SYSTEM",
|
|
370
522
|
subtype: "state_checkpoint",
|
|
371
|
-
data: { payload:
|
|
372
|
-
timestamp:
|
|
523
|
+
data: { payload: s.systemMessagePayload.payload },
|
|
524
|
+
timestamp: s.sentAt || "",
|
|
373
525
|
attachments: void 0
|
|
374
526
|
};
|
|
375
527
|
case "csat_requested":
|
|
376
528
|
return {
|
|
377
|
-
id:
|
|
529
|
+
id: s.publicId,
|
|
378
530
|
type: "SYSTEM",
|
|
379
531
|
subtype: "csat_requested",
|
|
380
532
|
data: { payload: void 0 },
|
|
381
|
-
timestamp:
|
|
533
|
+
timestamp: s.sentAt || "",
|
|
382
534
|
attachments: void 0
|
|
383
535
|
};
|
|
384
536
|
case "csat_submitted":
|
|
385
537
|
return {
|
|
386
|
-
id:
|
|
538
|
+
id: s.publicId,
|
|
387
539
|
type: "SYSTEM",
|
|
388
540
|
subtype: "csat_submitted",
|
|
389
541
|
data: {
|
|
390
542
|
payload: {
|
|
391
|
-
score:
|
|
392
|
-
feedback:
|
|
543
|
+
score: s.systemMessagePayload.payload.score ?? void 0,
|
|
544
|
+
feedback: s.systemMessagePayload.payload.feedback ?? void 0
|
|
393
545
|
}
|
|
394
546
|
},
|
|
395
|
-
timestamp:
|
|
547
|
+
timestamp: s.sentAt || "",
|
|
396
548
|
attachments: void 0
|
|
397
549
|
};
|
|
398
550
|
case "none":
|
|
399
551
|
return null;
|
|
400
552
|
default:
|
|
401
|
-
return
|
|
402
|
-
|
|
553
|
+
return me(
|
|
554
|
+
s.systemMessagePayload,
|
|
403
555
|
this.constructSystemMessage.name
|
|
404
556
|
), null;
|
|
405
557
|
}
|
|
406
|
-
}, this.extractActionResult = (
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
if ("responseBodyText" in
|
|
410
|
-
const
|
|
558
|
+
}, this.extractActionResult = (s) => {
|
|
559
|
+
const a = s.result;
|
|
560
|
+
if (a === null || typeof a != "object") return a;
|
|
561
|
+
if ("responseBodyText" in a && typeof a.responseBodyText == "string") {
|
|
562
|
+
const i = a.responseBodyText, c = $(() => JSON.parse(i)).data;
|
|
411
563
|
if (c) return c;
|
|
412
564
|
}
|
|
413
|
-
return
|
|
414
|
-
}, this.api = e, this.config =
|
|
565
|
+
return s.result;
|
|
566
|
+
}, this.api = e, this.config = t, this.sessionCtx = o, this.messageCtx = r, this.sessionPollingIntervalSeconds = l, this.registerPolling();
|
|
415
567
|
}
|
|
416
568
|
}
|
|
417
|
-
class
|
|
569
|
+
class ge {
|
|
418
570
|
constructor({
|
|
419
571
|
config: e,
|
|
420
|
-
api:
|
|
421
|
-
storageCtx:
|
|
572
|
+
api: t,
|
|
573
|
+
storageCtx: o
|
|
422
574
|
}) {
|
|
423
|
-
var
|
|
575
|
+
var r;
|
|
424
576
|
this.shouldCollectData = () => {
|
|
425
|
-
var
|
|
426
|
-
return !!(!((
|
|
577
|
+
var l;
|
|
578
|
+
return !!(!((l = this.state.get().contact) != null && l.token) && this.config.collectUserData);
|
|
427
579
|
}, this.autoCreateUnverifiedUserIfNotExists = async () => {
|
|
428
|
-
var
|
|
429
|
-
if (!((
|
|
430
|
-
if (this.config.collectUserData && !((
|
|
431
|
-
if ((
|
|
580
|
+
var l, s, a, i, c, d, _, p, u, m, g, v, f, b;
|
|
581
|
+
if (!((l = this.config.user) != null && l.token)) {
|
|
582
|
+
if (this.config.collectUserData && !((a = (s = this.config.user) == null ? void 0 : s.data) != null && a.email)) {
|
|
583
|
+
if ((i = this.config.extraDataCollectionFields) != null && i.length)
|
|
432
584
|
return;
|
|
433
|
-
const
|
|
434
|
-
|
|
585
|
+
const w = await ((c = this.storageCtx) == null ? void 0 : c.getContactToken());
|
|
586
|
+
w && await this.setUnverifiedContact(w);
|
|
435
587
|
return;
|
|
436
588
|
}
|
|
437
|
-
if (!((
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
await this.setUnverifiedContact(
|
|
589
|
+
if (!((_ = (d = this.config.user) == null ? void 0 : d.data) != null && _.email)) {
|
|
590
|
+
const w = await ((p = this.storageCtx) == null ? void 0 : p.getContactToken());
|
|
591
|
+
if (w) {
|
|
592
|
+
await this.setUnverifiedContact(w);
|
|
441
593
|
return;
|
|
442
594
|
}
|
|
443
595
|
}
|
|
444
596
|
await this.createUnverifiedContact({
|
|
445
597
|
email: (m = (u = this.config.user) == null ? void 0 : u.data) == null ? void 0 : m.email,
|
|
446
|
-
non_verified_name: (
|
|
447
|
-
non_verified_custom_data: (
|
|
598
|
+
non_verified_name: (v = (g = this.config.user) == null ? void 0 : g.data) == null ? void 0 : v.name,
|
|
599
|
+
non_verified_custom_data: (b = (f = this.config.user) == null ? void 0 : f.data) == null ? void 0 : b.customData
|
|
448
600
|
});
|
|
449
601
|
}
|
|
450
|
-
}, this.createUnverifiedContact = async (
|
|
451
|
-
this.state.setPartial({ extraCollectedData:
|
|
602
|
+
}, this.createUnverifiedContact = async (l, s) => {
|
|
603
|
+
this.state.setPartial({ extraCollectedData: s });
|
|
452
604
|
try {
|
|
453
605
|
this.state.setPartial({
|
|
454
606
|
isCreatingUnverifiedContact: !0,
|
|
455
607
|
isErrorCreatingUnverifiedContact: !1
|
|
456
608
|
});
|
|
457
|
-
const { data:
|
|
458
|
-
|
|
459
|
-
} catch (
|
|
460
|
-
this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 }),
|
|
461
|
-
_e:
|
|
609
|
+
const { data: a } = await this.api.createUnverifiedContact(l);
|
|
610
|
+
a != null && a.token ? await this.setUnverifiedContact(a.token) : this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 });
|
|
611
|
+
} catch (a) {
|
|
612
|
+
this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 }), k.error("failed to create an unverified contact", {
|
|
613
|
+
_e: a instanceof Error ? a.message : String(a)
|
|
462
614
|
});
|
|
463
615
|
} finally {
|
|
464
616
|
this.state.setPartial({ isCreatingUnverifiedContact: !1 });
|
|
465
617
|
}
|
|
466
618
|
}, this.recoverFromStaleToken = async () => {
|
|
467
|
-
var
|
|
468
|
-
if ((
|
|
619
|
+
var l, s, a, i, c, d, _, p, u, m;
|
|
620
|
+
if ((l = this.config.user) != null && l.token) return !1;
|
|
469
621
|
this.api.setAuthToken(""), this.state.setPartial({ contact: null });
|
|
470
622
|
try {
|
|
471
|
-
await ((
|
|
623
|
+
await ((s = this.storageCtx) == null ? void 0 : s.clearContactToken()), await ((a = this.storageCtx) == null ? void 0 : a.clearActiveSessionId());
|
|
472
624
|
} catch (g) {
|
|
473
|
-
|
|
625
|
+
k.warn("failed to clear a stale contact token", {
|
|
474
626
|
error: g instanceof Error ? g.message : String(g)
|
|
475
627
|
});
|
|
476
628
|
}
|
|
477
629
|
return await this.createUnverifiedContact({
|
|
478
|
-
email: (c = (
|
|
479
|
-
non_verified_name: (
|
|
630
|
+
email: (c = (i = this.config.user) == null ? void 0 : i.data) == null ? void 0 : c.email,
|
|
631
|
+
non_verified_name: (_ = (d = this.config.user) == null ? void 0 : d.data) == null ? void 0 : _.name,
|
|
480
632
|
non_verified_custom_data: (u = (p = this.config.user) == null ? void 0 : p.data) == null ? void 0 : u.customData
|
|
481
633
|
}), !!((m = this.state.get().contact) != null && m.token);
|
|
482
|
-
}, this.setUnverifiedContact = async (
|
|
483
|
-
var
|
|
484
|
-
const
|
|
485
|
-
this.api.setAuthToken(
|
|
486
|
-
}, this.config = e, this.storageCtx =
|
|
487
|
-
contact: (
|
|
634
|
+
}, this.setUnverifiedContact = async (l) => {
|
|
635
|
+
var i, c, d, _;
|
|
636
|
+
const s = await ((i = this.storageCtx) == null ? void 0 : i.getExternalContactId()), a = ((c = this.config.user) == null ? void 0 : c.externalId) || s || N();
|
|
637
|
+
this.api.setAuthToken(l), await ((d = this.storageCtx) == null ? void 0 : d.setContactToken(l)), await ((_ = this.storageCtx) == null ? void 0 : _.setExternalContactId(a)), this.state.setPartial({ contact: { token: l, externalId: a } });
|
|
638
|
+
}, this.config = e, this.storageCtx = o, this.api = t, this.state = new S({
|
|
639
|
+
contact: (r = e.user) != null && r.token ? {
|
|
488
640
|
token: e.user.token,
|
|
489
641
|
// Set optional externalId from config... not local storage
|
|
490
642
|
externalId: e.user.externalId
|
|
@@ -495,49 +647,49 @@ class le {
|
|
|
495
647
|
}), this.autoCreateUnverifiedUserIfNotExists();
|
|
496
648
|
}
|
|
497
649
|
}
|
|
498
|
-
class
|
|
650
|
+
class ke {
|
|
499
651
|
constructor(e) {
|
|
500
|
-
this.api = e, this.state = new
|
|
501
|
-
const
|
|
502
|
-
(
|
|
503
|
-
file:
|
|
504
|
-
id:
|
|
652
|
+
this.api = e, this.state = new S([]), this.controllers = /* @__PURE__ */ new Map(), this.appendFiles = (t) => {
|
|
653
|
+
const o = t.map(
|
|
654
|
+
(r) => ({
|
|
655
|
+
file: r,
|
|
656
|
+
id: N(),
|
|
505
657
|
status: "pending",
|
|
506
658
|
progress: 0
|
|
507
659
|
})
|
|
508
660
|
);
|
|
509
|
-
this.state.set([...this.state.get(), ...
|
|
510
|
-
}, this.cancel = (
|
|
511
|
-
var
|
|
512
|
-
(
|
|
661
|
+
this.state.set([...this.state.get(), ...o]), o.forEach((r) => void this.upload(r));
|
|
662
|
+
}, this.cancel = (t) => {
|
|
663
|
+
var o;
|
|
664
|
+
(o = this.controllers.get(t)) == null || o.abort(), this.controllers.delete(t), this.state.set(this.state.get().filter((r) => r.id !== t));
|
|
513
665
|
}, this.reset = () => {
|
|
514
|
-
this.controllers.forEach((
|
|
666
|
+
this.controllers.forEach((t) => t.abort()), this.controllers.clear(), this.state.reset();
|
|
515
667
|
};
|
|
516
668
|
}
|
|
517
|
-
update(e,
|
|
669
|
+
update(e, t) {
|
|
518
670
|
this.state.set(
|
|
519
|
-
this.state.get().map((
|
|
671
|
+
this.state.get().map((o) => o.id === e ? { ...o, ...t } : o)
|
|
520
672
|
);
|
|
521
673
|
}
|
|
522
674
|
async upload(e) {
|
|
523
|
-
const
|
|
524
|
-
this.controllers.set(e.id,
|
|
675
|
+
const t = new AbortController();
|
|
676
|
+
this.controllers.set(e.id, t), this.update(e.id, { status: "uploading" });
|
|
525
677
|
try {
|
|
526
|
-
const
|
|
678
|
+
const o = await this.api.uploadFile({
|
|
527
679
|
file: e.file,
|
|
528
|
-
abortSignal:
|
|
529
|
-
onProgress: (
|
|
680
|
+
abortSignal: t.signal,
|
|
681
|
+
onProgress: (r) => this.update(e.id, { progress: r })
|
|
530
682
|
});
|
|
531
683
|
this.update(e.id, {
|
|
532
684
|
status: "success",
|
|
533
|
-
fileUrl:
|
|
685
|
+
fileUrl: o.fileUrl,
|
|
534
686
|
progress: 100
|
|
535
687
|
});
|
|
536
|
-
} catch (
|
|
537
|
-
|
|
688
|
+
} catch (o) {
|
|
689
|
+
t.signal.aborted || this.update(e.id, {
|
|
538
690
|
status: "error",
|
|
539
691
|
progress: 0,
|
|
540
|
-
error:
|
|
692
|
+
error: o instanceof Error ? o.message : "Upload failed"
|
|
541
693
|
});
|
|
542
694
|
} finally {
|
|
543
695
|
this.controllers.delete(e.id);
|
|
@@ -545,47 +697,47 @@ class ce {
|
|
|
545
697
|
}
|
|
546
698
|
}
|
|
547
699
|
function x() {
|
|
548
|
-
return
|
|
700
|
+
return N();
|
|
549
701
|
}
|
|
550
|
-
class
|
|
702
|
+
class be {
|
|
551
703
|
constructor({
|
|
552
704
|
api: e,
|
|
553
|
-
sessionCtx:
|
|
554
|
-
messageCtx:
|
|
705
|
+
sessionCtx: t,
|
|
706
|
+
messageCtx: o
|
|
555
707
|
}) {
|
|
556
|
-
this.submitCsat = async (
|
|
708
|
+
this.submitCsat = async (r) => {
|
|
557
709
|
var c;
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
710
|
+
const l = (c = this.sessionCtx.sessionState.get().session) == null ? void 0 : c.id;
|
|
711
|
+
if (!l)
|
|
560
712
|
return { data: null, error: "No session id found" };
|
|
561
|
-
const
|
|
713
|
+
const s = x();
|
|
562
714
|
this.messageCtx.state.setPartial({
|
|
563
715
|
messages: [
|
|
564
716
|
...this.messageCtx.state.get().messages,
|
|
565
717
|
{
|
|
566
|
-
id:
|
|
718
|
+
id: s,
|
|
567
719
|
type: "SYSTEM",
|
|
568
720
|
subtype: "csat_submitted",
|
|
569
721
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
570
722
|
data: {
|
|
571
723
|
payload: {
|
|
572
|
-
score:
|
|
573
|
-
feedback:
|
|
724
|
+
score: r.score,
|
|
725
|
+
feedback: r.feedback
|
|
574
726
|
}
|
|
575
727
|
}
|
|
576
728
|
}
|
|
577
729
|
]
|
|
578
730
|
});
|
|
579
|
-
const { data:
|
|
580
|
-
...
|
|
581
|
-
system_message_uuid:
|
|
582
|
-
session_id:
|
|
731
|
+
const { data: a, error: i } = await this.api.submitCsat({
|
|
732
|
+
...r,
|
|
733
|
+
system_message_uuid: s,
|
|
734
|
+
session_id: l
|
|
583
735
|
});
|
|
584
|
-
return { data:
|
|
585
|
-
}, this.api = e, this.sessionCtx =
|
|
736
|
+
return { data: a, error: i };
|
|
737
|
+
}, this.api = e, this.sessionCtx = t, this.messageCtx = o;
|
|
586
738
|
}
|
|
587
739
|
}
|
|
588
|
-
const
|
|
740
|
+
const ve = [
|
|
589
741
|
{
|
|
590
742
|
action: "newparagraph",
|
|
591
743
|
phrases: {
|
|
@@ -660,7 +812,7 @@ const de = [
|
|
|
660
812
|
it: ["invia messaggio"]
|
|
661
813
|
}
|
|
662
814
|
}
|
|
663
|
-
],
|
|
815
|
+
], fe = [
|
|
664
816
|
"en",
|
|
665
817
|
"es",
|
|
666
818
|
"fr",
|
|
@@ -668,104 +820,104 @@ const de = [
|
|
|
668
820
|
"pt",
|
|
669
821
|
"it"
|
|
670
822
|
];
|
|
671
|
-
function
|
|
672
|
-
return
|
|
823
|
+
function ye(n) {
|
|
824
|
+
return fe.includes(n);
|
|
673
825
|
}
|
|
674
|
-
function
|
|
826
|
+
function we(n) {
|
|
675
827
|
return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
676
828
|
}
|
|
677
|
-
function
|
|
678
|
-
const e =
|
|
679
|
-
(
|
|
680
|
-
(
|
|
829
|
+
function je(n) {
|
|
830
|
+
const e = ve.flatMap(
|
|
831
|
+
(r) => n.flatMap(
|
|
832
|
+
(l) => r.phrases[l].map((s) => ({ phrase: s, action: r.action }))
|
|
681
833
|
)
|
|
682
|
-
),
|
|
834
|
+
), t = e.map((r) => we(r.phrase)).sort((r, l) => l.length - r.length).join("|"), o = String.raw`(?<=^\s{0,3}|[.!?\n]\s{0,3})`;
|
|
683
835
|
return {
|
|
684
836
|
regex: new RegExp(
|
|
685
|
-
`${
|
|
837
|
+
`${o}(${t})` + String.raw`([.,!?;:])(?=\s|$)`,
|
|
686
838
|
"giu"
|
|
687
839
|
),
|
|
688
840
|
finalRegex: new RegExp(
|
|
689
|
-
`${
|
|
841
|
+
`${o}(${t})` + String.raw`([.,!?;:]?)(?=\s|$)`,
|
|
690
842
|
"giu"
|
|
691
843
|
),
|
|
692
844
|
phraseToAction: new Map(
|
|
693
|
-
e.map((
|
|
845
|
+
e.map((r) => [r.phrase.toLowerCase(), r.action])
|
|
694
846
|
),
|
|
695
|
-
longestPhrase: Math.max(...e.map((
|
|
847
|
+
longestPhrase: Math.max(...e.map((r) => r.phrase.length))
|
|
696
848
|
};
|
|
697
849
|
}
|
|
698
|
-
const
|
|
699
|
-
function
|
|
700
|
-
const e = n &&
|
|
701
|
-
let
|
|
702
|
-
return
|
|
850
|
+
const V = /* @__PURE__ */ new Map();
|
|
851
|
+
function I(n) {
|
|
852
|
+
const e = n && ye(n) && n !== "en" ? n : null, t = e ?? "en";
|
|
853
|
+
let o = V.get(t);
|
|
854
|
+
return o || (o = je(e ? ["en", e] : ["en"]), V.set(t, o)), o;
|
|
703
855
|
}
|
|
704
|
-
function
|
|
856
|
+
function Se(n) {
|
|
705
857
|
const e = n.replace(/\s+$/, "");
|
|
706
858
|
if (!e) return "";
|
|
707
|
-
const
|
|
708
|
-
let
|
|
709
|
-
for (let
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
859
|
+
const t = e.replace(/[.!?]+$/, "");
|
|
860
|
+
let o = -1;
|
|
861
|
+
for (let r = t.length - 1; r >= 0; r--) {
|
|
862
|
+
const l = t[r];
|
|
863
|
+
if (l === "." || l === "!" || l === "?" || l === `
|
|
712
864
|
`) {
|
|
713
|
-
|
|
865
|
+
o = r + 1;
|
|
714
866
|
break;
|
|
715
867
|
}
|
|
716
868
|
}
|
|
717
|
-
return
|
|
869
|
+
return o === -1 ? "" : `${t.slice(0, o)} `.replace(/\n $/, `
|
|
718
870
|
`);
|
|
719
871
|
}
|
|
720
|
-
const
|
|
872
|
+
const ze = new RegExp(
|
|
721
873
|
String.raw`(^- |\n(?:- )?)(\p{Ll})`,
|
|
722
874
|
"gu"
|
|
723
875
|
);
|
|
724
|
-
function
|
|
876
|
+
function Ce(n) {
|
|
725
877
|
return n.replace(
|
|
726
|
-
|
|
727
|
-
(e,
|
|
878
|
+
ze,
|
|
879
|
+
(e, t, o) => t + o.toUpperCase()
|
|
728
880
|
);
|
|
729
881
|
}
|
|
730
|
-
function
|
|
882
|
+
function xe(n) {
|
|
731
883
|
return n.length <= 3 && /^\s*$/.test(n) ? !0 : /[.!?\n]\s{0,3}$/.test(n.slice(-6));
|
|
732
884
|
}
|
|
733
|
-
class
|
|
885
|
+
class q {
|
|
734
886
|
/**
|
|
735
887
|
* Process the full raw transcript accumulated so far into insertable text.
|
|
736
888
|
* Pure and deterministic: always called with the entire raw string so the
|
|
737
889
|
* result never depends on delta chunking.
|
|
738
890
|
*/
|
|
739
|
-
static process(e,
|
|
740
|
-
const
|
|
741
|
-
let
|
|
742
|
-
for (const
|
|
743
|
-
const [, p = ""] =
|
|
891
|
+
static process(e, t) {
|
|
892
|
+
const o = I(t == null ? void 0 : t.language), r = t != null && t.final ? "" : q.commandPrefixTail(e, t == null ? void 0 : t.language), l = e.slice(0, e.length - r.length), s = t != null && t.final ? o.finalRegex : o.regex;
|
|
893
|
+
let a = "", i = null, c = 0;
|
|
894
|
+
for (const _ of Array.from(l.matchAll(s))) {
|
|
895
|
+
const [, p = ""] = _, u = o.phraseToAction.get(p.toLowerCase());
|
|
744
896
|
if (u)
|
|
745
|
-
if (
|
|
897
|
+
if (a += l.slice(c, _.index), c = _.index + _[0].length, u === "newline") a = `${a.replace(/[ \t]+$/, "")}
|
|
746
898
|
`;
|
|
747
899
|
else if (u === "newparagraph")
|
|
748
|
-
|
|
900
|
+
a = `${a.replace(/[ \t]+$/, "")}
|
|
749
901
|
|
|
750
902
|
`;
|
|
751
903
|
else if (u === "bullet") {
|
|
752
|
-
const m =
|
|
753
|
-
|
|
904
|
+
const m = a.replace(/[ \t]+$/, "");
|
|
905
|
+
a = m === "" || m.endsWith(`
|
|
754
906
|
`) ? `${m}- ` : `${m}
|
|
755
907
|
- `;
|
|
756
|
-
} else if (u === "scratch")
|
|
908
|
+
} else if (u === "scratch") a = Se(a);
|
|
757
909
|
else {
|
|
758
|
-
|
|
910
|
+
i = u === "send" ? "send" : "stop";
|
|
759
911
|
break;
|
|
760
912
|
}
|
|
761
913
|
}
|
|
762
|
-
return
|
|
763
|
-
|
|
914
|
+
return i === null && (a += l.slice(c)), { text: Ce(
|
|
915
|
+
a.replace(/^\s+/, "").replace(/[ \t]+\n/g, `
|
|
764
916
|
`).replace(/\n[ \t]+/g, `
|
|
765
917
|
`).replace(/(^|\n)- +/g, "$1- ").replace(/ {2,}/g, " ").replace(/\n{3,}/g, `
|
|
766
918
|
|
|
767
919
|
`)
|
|
768
|
-
), pendingTail:
|
|
920
|
+
), pendingTail: r, control: i };
|
|
769
921
|
}
|
|
770
922
|
/**
|
|
771
923
|
* Longest suffix of `raw` that could still become a command — a proper
|
|
@@ -776,16 +928,16 @@ class C {
|
|
|
776
928
|
* control command from an intermediate delta would stop or submit
|
|
777
929
|
* mid-sentence.
|
|
778
930
|
*/
|
|
779
|
-
static commandPrefixTail(e,
|
|
780
|
-
const
|
|
781
|
-
for (let
|
|
782
|
-
const
|
|
783
|
-
if (!
|
|
784
|
-
const
|
|
785
|
-
if (
|
|
786
|
-
for (const c of Array.from(
|
|
787
|
-
if (c.startsWith(
|
|
788
|
-
return e.slice(
|
|
931
|
+
static commandPrefixTail(e, t) {
|
|
932
|
+
const o = I(t), r = Math.min(e.length, o.longestPhrase + 2);
|
|
933
|
+
for (let l = r; l > 0; l--) {
|
|
934
|
+
const s = e.length - l;
|
|
935
|
+
if (!xe(e.slice(0, s))) continue;
|
|
936
|
+
const a = e.slice(s).toLowerCase(), i = a.replace(/^\s+/, "");
|
|
937
|
+
if (i) {
|
|
938
|
+
for (const c of Array.from(o.phraseToAction.keys()))
|
|
939
|
+
if (c.startsWith(i))
|
|
940
|
+
return e.slice(s + (a.length - i.length));
|
|
789
941
|
}
|
|
790
942
|
}
|
|
791
943
|
return "";
|
|
@@ -795,13 +947,13 @@ class C {
|
|
|
795
947
|
* prefix) — i.e. a silence pause would resolve it into a command. Used by
|
|
796
948
|
* the manager's silence timer.
|
|
797
949
|
*/
|
|
798
|
-
static pendingTailIsCompletePhrase(e,
|
|
799
|
-
const
|
|
800
|
-
return
|
|
950
|
+
static pendingTailIsCompletePhrase(e, t) {
|
|
951
|
+
const o = q.commandPrefixTail(e, t).trim().toLowerCase();
|
|
952
|
+
return o ? I(t).phraseToAction.has(o) : !1;
|
|
801
953
|
}
|
|
802
954
|
}
|
|
803
|
-
const
|
|
804
|
-
class
|
|
955
|
+
const qe = 55, Ee = 90;
|
|
956
|
+
class H {
|
|
805
957
|
/**
|
|
806
958
|
* Next paced step toward `processed`: normally one word per tick so text
|
|
807
959
|
* flows evenly instead of landing in bursty chunks; proportionally larger
|
|
@@ -810,28 +962,28 @@ class B {
|
|
|
810
962
|
*/
|
|
811
963
|
static nextDripText({
|
|
812
964
|
displayed: e,
|
|
813
|
-
processed:
|
|
965
|
+
processed: t
|
|
814
966
|
}) {
|
|
815
|
-
if (
|
|
816
|
-
const
|
|
817
|
-
if (
|
|
818
|
-
return
|
|
819
|
-
let
|
|
820
|
-
for (;
|
|
821
|
-
for (;
|
|
822
|
-
return
|
|
967
|
+
if (t.length <= e.length) return t;
|
|
968
|
+
const o = t.length - e.length;
|
|
969
|
+
if (o > Ee)
|
|
970
|
+
return t.slice(0, e.length + Math.ceil(o / 3));
|
|
971
|
+
let r = e.length;
|
|
972
|
+
for (; r < t.length && /\s/.test(t.charAt(r)); ) r++;
|
|
973
|
+
for (; r < t.length && !/\s/.test(t.charAt(r)); ) r++;
|
|
974
|
+
return r - e.length > 12 && (r = e.length + 6), t.slice(0, Math.max(r, e.length + 1));
|
|
823
975
|
}
|
|
824
976
|
/** Normalize a BCP-47 browser locale into the hint OpenAI accepts. */
|
|
825
977
|
static languageHint(e) {
|
|
826
978
|
if (!e) return;
|
|
827
|
-
const
|
|
828
|
-
if (/^zh-(cn|tw|hk)$/.test(
|
|
829
|
-
const
|
|
830
|
-
return
|
|
979
|
+
const t = e.toLowerCase();
|
|
980
|
+
if (/^zh-(cn|tw|hk)$/.test(t)) return t;
|
|
981
|
+
const o = t.split("-")[0];
|
|
982
|
+
return o && /^[a-z]{2,3}$/.test(o) ? o : void 0;
|
|
831
983
|
}
|
|
832
984
|
}
|
|
833
|
-
const
|
|
834
|
-
class
|
|
985
|
+
const Ae = 2e4;
|
|
986
|
+
class Pe {
|
|
835
987
|
constructor() {
|
|
836
988
|
this.cached = null, this.inflight = null;
|
|
837
989
|
}
|
|
@@ -839,15 +991,15 @@ class ze {
|
|
|
839
991
|
get() {
|
|
840
992
|
if (!this.cached) return null;
|
|
841
993
|
const e = Date.parse(this.cached.expiresAt);
|
|
842
|
-
return Number.isNaN(e) || e - Date.now() <
|
|
994
|
+
return Number.isNaN(e) || e - Date.now() < Ae ? (this.cached = null, null) : this.cached;
|
|
843
995
|
}
|
|
844
996
|
/**
|
|
845
997
|
* Resolve a mint, deduping concurrent requests (hover-prewarm racing a
|
|
846
998
|
* click reuses the same in-flight promise instead of double-minting).
|
|
847
999
|
*/
|
|
848
1000
|
async resolve(e) {
|
|
849
|
-
const
|
|
850
|
-
return
|
|
1001
|
+
const t = this.get();
|
|
1002
|
+
return t || (this.inflight || (this.inflight = e().then((o) => (this.cached = o, o)).finally(() => {
|
|
851
1003
|
this.inflight = null;
|
|
852
1004
|
})), this.inflight);
|
|
853
1005
|
}
|
|
@@ -856,89 +1008,89 @@ class ze {
|
|
|
856
1008
|
this.cached = null;
|
|
857
1009
|
}
|
|
858
1010
|
}
|
|
859
|
-
function
|
|
1011
|
+
function Z(n) {
|
|
860
1012
|
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
861
1013
|
}
|
|
862
|
-
function
|
|
863
|
-
if (!
|
|
864
|
-
const e =
|
|
1014
|
+
function Te(n) {
|
|
1015
|
+
if (!Z(n) || typeof n.type != "string") return null;
|
|
1016
|
+
const e = Z(n.error) ? n.error : null;
|
|
865
1017
|
return {
|
|
866
1018
|
type: n.type,
|
|
867
1019
|
delta: typeof n.delta == "string" ? n.delta : void 0,
|
|
868
1020
|
errorMessage: e && typeof e.message == "string" ? e.message : void 0
|
|
869
1021
|
};
|
|
870
1022
|
}
|
|
871
|
-
const
|
|
872
|
-
class
|
|
1023
|
+
const Ie = "https://api.openai.com/v1/realtime/calls", Me = 600 * 1e3, De = 15e3, Ne = 5e3;
|
|
1024
|
+
class P extends Error {
|
|
873
1025
|
}
|
|
874
|
-
class
|
|
1026
|
+
class Re {
|
|
875
1027
|
constructor({
|
|
876
1028
|
mintToken: e,
|
|
877
|
-
onDelta:
|
|
878
|
-
onState:
|
|
879
|
-
onError:
|
|
880
|
-
onLevel:
|
|
1029
|
+
onDelta: t,
|
|
1030
|
+
onState: o,
|
|
1031
|
+
onError: r,
|
|
1032
|
+
onLevel: l
|
|
881
1033
|
}) {
|
|
882
|
-
this.state = "idle", this.pc = null, this.dc = null, this.stream = null, this.audioContext = null, this.levelRaf = 0, this.timers = [], this.loggedParseFailure = !1, this.mintToken = e, this.onDelta =
|
|
1034
|
+
this.state = "idle", this.pc = null, this.dc = null, this.stream = null, this.audioContext = null, this.levelRaf = 0, this.timers = [], this.loggedParseFailure = !1, this.mintToken = e, this.onDelta = t, this.onState = o, this.onError = r, this.onLevel = l;
|
|
883
1035
|
}
|
|
884
1036
|
async start() {
|
|
885
1037
|
if (this.state === "idle") {
|
|
886
1038
|
this.setState("connecting"), this.timers.push(
|
|
887
1039
|
setTimeout(() => {
|
|
888
1040
|
this.state === "connecting" && this.fail("unavailable");
|
|
889
|
-
},
|
|
890
|
-
), this.timers.push(setTimeout(() => this.stop(),
|
|
1041
|
+
}, De)
|
|
1042
|
+
), this.timers.push(setTimeout(() => this.stop(), Me));
|
|
891
1043
|
try {
|
|
892
1044
|
const e = this.requestMicrophone();
|
|
893
1045
|
e.then((d) => {
|
|
894
|
-
(this.isTornDown() || this.stream && this.stream !== d) && d.getTracks().forEach((
|
|
1046
|
+
(this.isTornDown() || this.stream && this.stream !== d) && d.getTracks().forEach((_) => _.stop());
|
|
895
1047
|
}).catch(() => {
|
|
896
1048
|
});
|
|
897
|
-
const [
|
|
1049
|
+
const [t, o] = await Promise.all([e, this.mintToken()]);
|
|
898
1050
|
if (this.isTornDown()) {
|
|
899
|
-
|
|
1051
|
+
t.getTracks().forEach((d) => d.stop());
|
|
900
1052
|
return;
|
|
901
1053
|
}
|
|
902
|
-
this.stream =
|
|
903
|
-
const
|
|
904
|
-
this.pc =
|
|
905
|
-
const [
|
|
906
|
-
if (!
|
|
907
|
-
|
|
908
|
-
const
|
|
909
|
-
this.dc =
|
|
1054
|
+
this.stream = t, this.startLevelMeter(t);
|
|
1055
|
+
const r = new RTCPeerConnection();
|
|
1056
|
+
this.pc = r;
|
|
1057
|
+
const [l] = t.getAudioTracks();
|
|
1058
|
+
if (!l) throw new P("No audio track");
|
|
1059
|
+
r.addTrack(l, t);
|
|
1060
|
+
const s = r.createDataChannel("oai-events");
|
|
1061
|
+
this.dc = s, s.addEventListener(
|
|
910
1062
|
"message",
|
|
911
1063
|
(d) => this.handleServerEvent(d.data)
|
|
912
|
-
),
|
|
1064
|
+
), s.addEventListener("open", () => {
|
|
913
1065
|
this.state === "connecting" && this.setState("listening");
|
|
914
|
-
}),
|
|
915
|
-
if (
|
|
1066
|
+
}), r.addEventListener("connectionstatechange", () => {
|
|
1067
|
+
if (r.connectionState === "failed") {
|
|
916
1068
|
this.fail("unavailable");
|
|
917
1069
|
return;
|
|
918
1070
|
}
|
|
919
|
-
|
|
1071
|
+
r.connectionState === "disconnected" && this.timers.push(
|
|
920
1072
|
setTimeout(() => {
|
|
921
|
-
this.pc ===
|
|
922
|
-
},
|
|
1073
|
+
this.pc === r && r.connectionState !== "connected" && this.fail("unavailable");
|
|
1074
|
+
}, Ne)
|
|
923
1075
|
);
|
|
924
1076
|
});
|
|
925
|
-
const
|
|
926
|
-
await
|
|
927
|
-
const
|
|
1077
|
+
const a = await r.createOffer();
|
|
1078
|
+
await r.setLocalDescription(a);
|
|
1079
|
+
const i = await fetch(Ie, {
|
|
928
1080
|
method: "POST",
|
|
929
1081
|
headers: {
|
|
930
|
-
Authorization: `Bearer ${
|
|
1082
|
+
Authorization: `Bearer ${o.token}`,
|
|
931
1083
|
"Content-Type": "application/sdp"
|
|
932
1084
|
},
|
|
933
|
-
body:
|
|
1085
|
+
body: a.sdp
|
|
934
1086
|
});
|
|
935
|
-
if (!
|
|
936
|
-
throw new Error(`Realtime handshake failed (${
|
|
937
|
-
const c = await
|
|
1087
|
+
if (!i.ok)
|
|
1088
|
+
throw new Error(`Realtime handshake failed (${i.status})`);
|
|
1089
|
+
const c = await i.text();
|
|
938
1090
|
if (this.isTornDown()) return;
|
|
939
|
-
await
|
|
1091
|
+
await r.setRemoteDescription({ type: "answer", sdp: c });
|
|
940
1092
|
} catch (e) {
|
|
941
|
-
e instanceof
|
|
1093
|
+
e instanceof P ? this.fail("microphone") : (k.error("dictation session failed to start", {
|
|
942
1094
|
_e: e instanceof Error ? e.message : String(e)
|
|
943
1095
|
}), this.fail("unavailable"));
|
|
944
1096
|
}
|
|
@@ -950,7 +1102,7 @@ class Ee {
|
|
|
950
1102
|
async requestMicrophone() {
|
|
951
1103
|
var e;
|
|
952
1104
|
if (!((e = navigator.mediaDevices) != null && e.getUserMedia))
|
|
953
|
-
throw new
|
|
1105
|
+
throw new P("Microphone is not supported");
|
|
954
1106
|
try {
|
|
955
1107
|
return await navigator.mediaDevices.getUserMedia({
|
|
956
1108
|
audio: {
|
|
@@ -959,60 +1111,60 @@ class Ee {
|
|
|
959
1111
|
autoGainControl: !0
|
|
960
1112
|
}
|
|
961
1113
|
});
|
|
962
|
-
} catch (
|
|
963
|
-
throw new
|
|
964
|
-
|
|
1114
|
+
} catch (t) {
|
|
1115
|
+
throw new P(
|
|
1116
|
+
t instanceof DOMException ? t.name : "Could not access the microphone"
|
|
965
1117
|
);
|
|
966
1118
|
}
|
|
967
1119
|
}
|
|
968
1120
|
handleServerEvent(e) {
|
|
969
1121
|
if (typeof e != "string") return;
|
|
970
|
-
let
|
|
1122
|
+
let t;
|
|
971
1123
|
try {
|
|
972
|
-
|
|
1124
|
+
t = JSON.parse(e);
|
|
973
1125
|
} catch {
|
|
974
|
-
this.loggedParseFailure || (this.loggedParseFailure = !0,
|
|
1126
|
+
this.loggedParseFailure || (this.loggedParseFailure = !0, k.error("dictation server event was not valid JSON", {
|
|
975
1127
|
snippet: e.slice(0, 120)
|
|
976
1128
|
}));
|
|
977
1129
|
return;
|
|
978
1130
|
}
|
|
979
|
-
const
|
|
980
|
-
if (!
|
|
981
|
-
const { type:
|
|
982
|
-
if (
|
|
1131
|
+
const o = Te(t);
|
|
1132
|
+
if (!o) return;
|
|
1133
|
+
const { type: r, delta: l } = o;
|
|
1134
|
+
if (r === "session.created" || r === "transcription_session.created") {
|
|
983
1135
|
this.setState("listening");
|
|
984
1136
|
return;
|
|
985
1137
|
}
|
|
986
|
-
if (
|
|
987
|
-
this.state === "connecting" && this.setState("listening"), this.onDelta(
|
|
1138
|
+
if (r === "conversation.item.input_audio_transcription.delta" && l) {
|
|
1139
|
+
this.state === "connecting" && this.setState("listening"), this.onDelta(l);
|
|
988
1140
|
return;
|
|
989
1141
|
}
|
|
990
|
-
|
|
991
|
-
_e:
|
|
1142
|
+
r === "error" && (k.error("dictation server event error", {
|
|
1143
|
+
_e: o.errorMessage ?? "unknown"
|
|
992
1144
|
}), this.fail("unavailable"));
|
|
993
1145
|
}
|
|
994
1146
|
startLevelMeter(e) {
|
|
995
1147
|
if (this.onLevel)
|
|
996
1148
|
try {
|
|
997
|
-
const
|
|
998
|
-
this.audioContext =
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
const
|
|
1149
|
+
const t = new AudioContext();
|
|
1150
|
+
this.audioContext = t;
|
|
1151
|
+
const o = t.createMediaStreamSource(e), r = t.createAnalyser();
|
|
1152
|
+
r.fftSize = 512, o.connect(r);
|
|
1153
|
+
const l = new Uint8Array(r.frequencyBinCount), s = () => {
|
|
1002
1154
|
var c;
|
|
1003
|
-
|
|
1004
|
-
let
|
|
1005
|
-
for (let d = 0; d <
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1155
|
+
r.getByteTimeDomainData(l);
|
|
1156
|
+
let a = 0;
|
|
1157
|
+
for (let d = 0; d < l.length; d++) {
|
|
1158
|
+
const _ = ((l[d] ?? 128) - 128) / 128;
|
|
1159
|
+
a += _ * _;
|
|
1008
1160
|
}
|
|
1009
|
-
const
|
|
1010
|
-
(c = this.onLevel) == null || c.call(this, Math.min(1,
|
|
1161
|
+
const i = Math.sqrt(a / l.length);
|
|
1162
|
+
(c = this.onLevel) == null || c.call(this, Math.min(1, i * 4)), this.levelRaf = requestAnimationFrame(s);
|
|
1011
1163
|
};
|
|
1012
|
-
this.levelRaf = requestAnimationFrame(
|
|
1013
|
-
} catch (
|
|
1014
|
-
|
|
1015
|
-
_e:
|
|
1164
|
+
this.levelRaf = requestAnimationFrame(s);
|
|
1165
|
+
} catch (t) {
|
|
1166
|
+
k.error("dictation level meter unavailable", {
|
|
1167
|
+
_e: t instanceof Error ? t.message : String(t)
|
|
1016
1168
|
});
|
|
1017
1169
|
}
|
|
1018
1170
|
}
|
|
@@ -1023,10 +1175,10 @@ class Ee {
|
|
|
1023
1175
|
this.isTornDown() || (this.teardown(), this.setState("error"), this.onError(e));
|
|
1024
1176
|
}
|
|
1025
1177
|
teardown() {
|
|
1026
|
-
var e,
|
|
1027
|
-
this.timers.forEach((
|
|
1028
|
-
|
|
1029
|
-
_e: String(
|
|
1178
|
+
var e, t, o, r;
|
|
1179
|
+
this.timers.forEach((l) => clearTimeout(l)), this.timers = [], this.levelRaf && cancelAnimationFrame(this.levelRaf), this.levelRaf = 0, (e = this.dc) == null || e.close(), this.dc = null, (t = this.pc) == null || t.close(), this.pc = null, (o = this.stream) == null || o.getTracks().forEach((l) => l.stop()), this.stream = null, (r = this.audioContext) == null || r.close().catch((l) => {
|
|
1180
|
+
k.error("failed to close dictation audio context", {
|
|
1181
|
+
_e: String(l)
|
|
1030
1182
|
});
|
|
1031
1183
|
}), this.audioContext = null;
|
|
1032
1184
|
}
|
|
@@ -1034,76 +1186,76 @@ class Ee {
|
|
|
1034
1186
|
this.state !== e && (this.state = e, this.onState(e));
|
|
1035
1187
|
}
|
|
1036
1188
|
}
|
|
1037
|
-
const
|
|
1038
|
-
class
|
|
1039
|
-
constructor({ api: e, config:
|
|
1040
|
-
this.state = new
|
|
1041
|
-
this.mintToken().catch((
|
|
1042
|
-
this.mintCache.clear(),
|
|
1043
|
-
_e:
|
|
1189
|
+
const Ke = 1300, Le = { status: "idle", error: null };
|
|
1190
|
+
class Fe {
|
|
1191
|
+
constructor({ api: e, config: t }) {
|
|
1192
|
+
this.state = new S(Le), this.levelRef = { current: 0 }, this.mintCache = new Pe(), this.session = null, this.target = null, this.prefix = "", this.raw = "", this.processed = "", this.displayed = "", this.dripTimer = null, this.silenceTimer = null, this.isActive = () => this.session !== null, this.prewarm = () => {
|
|
1193
|
+
this.mintToken().catch((o) => {
|
|
1194
|
+
this.mintCache.clear(), k.error("dictation token prewarm failed", {
|
|
1195
|
+
_e: o instanceof Error ? o.message : String(o)
|
|
1044
1196
|
});
|
|
1045
1197
|
});
|
|
1046
|
-
}, this.start = (
|
|
1047
|
-
this.session && this.teardown(), this.target =
|
|
1198
|
+
}, this.start = (o) => {
|
|
1199
|
+
this.session && this.teardown(), this.target = o, this.language = H.languageHint(
|
|
1048
1200
|
this.config.language ?? navigator.language
|
|
1049
|
-
), this.prefix =
|
|
1050
|
-
const
|
|
1201
|
+
), this.prefix = o.getValue(), this.raw = "", this.processed = "", this.displayed = "";
|
|
1202
|
+
const r = new Re({
|
|
1051
1203
|
mintToken: this.mintToken,
|
|
1052
|
-
onLevel: (
|
|
1053
|
-
this.levelRef.current =
|
|
1204
|
+
onLevel: (l) => {
|
|
1205
|
+
this.levelRef.current = l;
|
|
1054
1206
|
},
|
|
1055
|
-
onState: (
|
|
1056
|
-
|
|
1207
|
+
onState: (l) => {
|
|
1208
|
+
r === this.session && (l === "connecting" && this.state.set({ status: "connecting", error: null }), l === "listening" && this.state.set({ status: "listening", error: null }), l === "stopped" && this.teardown());
|
|
1057
1209
|
},
|
|
1058
|
-
onError: (
|
|
1059
|
-
|
|
1210
|
+
onError: (l) => {
|
|
1211
|
+
r === this.session && (this.mintCache.clear(), this.teardown({ error: l, executeFinalCommand: !1 }));
|
|
1060
1212
|
},
|
|
1061
|
-
onDelta: (
|
|
1062
|
-
if (
|
|
1213
|
+
onDelta: (l) => {
|
|
1214
|
+
if (r !== this.session || !this.target) return;
|
|
1063
1215
|
if (!this.isConsistent()) {
|
|
1064
1216
|
this.teardown();
|
|
1065
1217
|
return;
|
|
1066
1218
|
}
|
|
1067
|
-
this.raw +=
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1219
|
+
this.raw += l;
|
|
1220
|
+
const s = this.ingest();
|
|
1221
|
+
if (s === "stop") {
|
|
1070
1222
|
this.teardown();
|
|
1071
1223
|
return;
|
|
1072
1224
|
}
|
|
1073
|
-
if (
|
|
1225
|
+
if (s === "send") {
|
|
1074
1226
|
this.teardown({ send: !0 });
|
|
1075
1227
|
return;
|
|
1076
1228
|
}
|
|
1077
|
-
this.stopSilenceTimer(),
|
|
1229
|
+
this.stopSilenceTimer(), q.pendingTailIsCompletePhrase(
|
|
1078
1230
|
this.raw,
|
|
1079
1231
|
this.language
|
|
1080
1232
|
) && (this.silenceTimer = setTimeout(() => {
|
|
1081
|
-
if (
|
|
1233
|
+
if (r !== this.session) return;
|
|
1082
1234
|
this.raw = `${this.raw}.`;
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
},
|
|
1235
|
+
const a = this.ingest();
|
|
1236
|
+
a === "stop" ? this.teardown() : a === "send" && this.teardown({ send: !0 });
|
|
1237
|
+
}, Ke));
|
|
1086
1238
|
}
|
|
1087
1239
|
});
|
|
1088
|
-
this.session =
|
|
1240
|
+
this.session = r, this.state.set({ status: "connecting", error: null }), this.dripTimer = setInterval(() => {
|
|
1089
1241
|
if (this.target && this.processed !== this.displayed) {
|
|
1090
1242
|
if (!this.isConsistent()) {
|
|
1091
1243
|
this.teardown();
|
|
1092
1244
|
return;
|
|
1093
1245
|
}
|
|
1094
1246
|
this.applyDisplayed(
|
|
1095
|
-
|
|
1247
|
+
H.nextDripText({
|
|
1096
1248
|
displayed: this.displayed,
|
|
1097
1249
|
processed: this.processed
|
|
1098
1250
|
})
|
|
1099
1251
|
);
|
|
1100
1252
|
}
|
|
1101
|
-
},
|
|
1253
|
+
}, qe), r.start();
|
|
1102
1254
|
}, this.stop = () => {
|
|
1103
1255
|
this.session && this.teardown();
|
|
1104
1256
|
}, this.mintToken = async () => this.mintCache.resolve(
|
|
1105
1257
|
() => this.api.createDictationSession({ language: this.language })
|
|
1106
|
-
), this.api = e, this.config =
|
|
1258
|
+
), this.api = e, this.config = t;
|
|
1107
1259
|
}
|
|
1108
1260
|
/** Applied text = prefix + dictated. A mismatch means the visitor edited. */
|
|
1109
1261
|
isConsistent() {
|
|
@@ -1115,28 +1267,28 @@ class Me {
|
|
|
1115
1267
|
/** Process the transcript and apply the outcome. Shared by the delta path,
|
|
1116
1268
|
* the silence timer, and (with `final`) teardown. Returns the control. */
|
|
1117
1269
|
ingest(e) {
|
|
1118
|
-
const
|
|
1270
|
+
const t = q.process(this.raw, {
|
|
1119
1271
|
language: this.language,
|
|
1120
1272
|
final: e == null ? void 0 : e.final
|
|
1121
1273
|
});
|
|
1122
|
-
return this.processed =
|
|
1274
|
+
return this.processed = t.text, t.text.startsWith(this.displayed) || this.applyDisplayed(t.text), t.control;
|
|
1123
1275
|
}
|
|
1124
1276
|
stopSilenceTimer() {
|
|
1125
1277
|
this.silenceTimer && clearTimeout(this.silenceTimer), this.silenceTimer = null;
|
|
1126
1278
|
}
|
|
1127
1279
|
teardown(e) {
|
|
1128
|
-
var
|
|
1129
|
-
const
|
|
1280
|
+
var l;
|
|
1281
|
+
const t = this.session, o = this.target;
|
|
1130
1282
|
this.dripTimer && clearInterval(this.dripTimer), this.dripTimer = null, this.stopSilenceTimer();
|
|
1131
|
-
let
|
|
1132
|
-
if (
|
|
1133
|
-
const
|
|
1134
|
-
(e == null ? void 0 : e.executeFinalCommand) !== !1 &&
|
|
1283
|
+
let r = (e == null ? void 0 : e.send) ?? !1;
|
|
1284
|
+
if (o && this.isConsistent()) {
|
|
1285
|
+
const s = this.ingest({ final: !0 });
|
|
1286
|
+
(e == null ? void 0 : e.executeFinalCommand) !== !1 && s === "send" && (r = !0), this.processed !== this.displayed && this.applyDisplayed(this.processed);
|
|
1135
1287
|
}
|
|
1136
|
-
this.session = null, this.target = null,
|
|
1288
|
+
this.session = null, this.target = null, t == null || t.stop(), this.levelRef.current = 0, this.state.set({ status: "idle", error: (e == null ? void 0 : e.error) ?? null }), r && ((l = o == null ? void 0 : o.onSend) == null || l.call(o));
|
|
1137
1289
|
}
|
|
1138
1290
|
}
|
|
1139
|
-
const
|
|
1291
|
+
const Oe = {
|
|
1140
1292
|
write_a_message_placeholder: "اكتب رسالة...",
|
|
1141
1293
|
your_issue_has_been_resolved: "تم حل مشكلتك!",
|
|
1142
1294
|
new_conversation: "محادثة جديدة",
|
|
@@ -1245,7 +1397,7 @@ const Ie = {
|
|
|
1245
1397
|
zoom_out: "تصغير",
|
|
1246
1398
|
reset_zoom: "إعادة تعيين التكبير",
|
|
1247
1399
|
support_chat_aria_label: "دردشة الدعم"
|
|
1248
|
-
},
|
|
1400
|
+
}, Ue = {
|
|
1249
1401
|
write_a_message_placeholder: "একটি বার্তা লিখুন...",
|
|
1250
1402
|
your_issue_has_been_resolved: "আপনার সমস্যা সমাধান হয়েছে!",
|
|
1251
1403
|
new_conversation: "নতুন কথোপকথন",
|
|
@@ -1342,7 +1494,7 @@ const Ie = {
|
|
|
1342
1494
|
zoom_out: "ছোট করুন",
|
|
1343
1495
|
reset_zoom: "জুম রিসেট করুন",
|
|
1344
1496
|
support_chat_aria_label: "সাপোর্ট চ্যাট"
|
|
1345
|
-
},
|
|
1497
|
+
}, Be = {
|
|
1346
1498
|
write_a_message_placeholder: "Напишете съобщение...",
|
|
1347
1499
|
your_issue_has_been_resolved: "Вашият проблем е разрешен!",
|
|
1348
1500
|
new_conversation: "Нов разговор",
|
|
@@ -1439,7 +1591,7 @@ const Ie = {
|
|
|
1439
1591
|
zoom_out: "Намаляване",
|
|
1440
1592
|
reset_zoom: "Нулиране на мащаба",
|
|
1441
1593
|
support_chat_aria_label: "Чат за поддръжка"
|
|
1442
|
-
},
|
|
1594
|
+
}, Ve = {
|
|
1443
1595
|
write_a_message_placeholder: "Napište zprávu...",
|
|
1444
1596
|
your_issue_has_been_resolved: "Váš problém byl vyřešen!",
|
|
1445
1597
|
new_conversation: "Nová konverzace",
|
|
@@ -1536,7 +1688,7 @@ const Ie = {
|
|
|
1536
1688
|
zoom_out: "Oddálit",
|
|
1537
1689
|
reset_zoom: "Obnovit přiblížení",
|
|
1538
1690
|
support_chat_aria_label: "Chat podpory"
|
|
1539
|
-
},
|
|
1691
|
+
}, He = {
|
|
1540
1692
|
write_a_message_placeholder: "Skriv en besked...",
|
|
1541
1693
|
your_issue_has_been_resolved: "Dit problem er løst!",
|
|
1542
1694
|
new_conversation: "Ny samtale",
|
|
@@ -1633,7 +1785,7 @@ const Ie = {
|
|
|
1633
1785
|
zoom_out: "Zoom ud",
|
|
1634
1786
|
reset_zoom: "Nulstil zoom",
|
|
1635
1787
|
support_chat_aria_label: "Supportchat"
|
|
1636
|
-
},
|
|
1788
|
+
}, Ze = {
|
|
1637
1789
|
write_a_message_placeholder: "Γράψτε ένα μήνυμα...",
|
|
1638
1790
|
your_issue_has_been_resolved: "Το πρόβλημά σας επιλύθηκε!",
|
|
1639
1791
|
new_conversation: "Νέα συνομιλία",
|
|
@@ -1730,7 +1882,7 @@ const Ie = {
|
|
|
1730
1882
|
zoom_out: "Σμίκρυνση",
|
|
1731
1883
|
reset_zoom: "Επαναφορά ζουμ",
|
|
1732
1884
|
support_chat_aria_label: "Συνομιλία υποστήριξης"
|
|
1733
|
-
},
|
|
1885
|
+
}, We = {
|
|
1734
1886
|
write_a_message_placeholder: "Nachricht schreiben...",
|
|
1735
1887
|
your_issue_has_been_resolved: "Ihr Problem wurde gelöst!",
|
|
1736
1888
|
new_conversation: "Neue Konversation",
|
|
@@ -1827,7 +1979,7 @@ const Ie = {
|
|
|
1827
1979
|
zoom_out: "Verkleinern",
|
|
1828
1980
|
reset_zoom: "Zoom zurücksetzen",
|
|
1829
1981
|
support_chat_aria_label: "Support-Chat"
|
|
1830
|
-
},
|
|
1982
|
+
}, J = {
|
|
1831
1983
|
write_a_message_placeholder: "Write a message...",
|
|
1832
1984
|
your_issue_has_been_resolved: "Your issue has been resolved!",
|
|
1833
1985
|
new_conversation: "New conversation",
|
|
@@ -1936,7 +2088,7 @@ const Ie = {
|
|
|
1936
2088
|
zoom_out: "Zoom out",
|
|
1937
2089
|
reset_zoom: "Reset zoom",
|
|
1938
2090
|
support_chat_aria_label: "Support chat"
|
|
1939
|
-
},
|
|
2091
|
+
}, Ge = {
|
|
1940
2092
|
write_a_message_placeholder: "Escribe un mensaje...",
|
|
1941
2093
|
your_issue_has_been_resolved: "¡Tu problema fue resuelto!",
|
|
1942
2094
|
new_conversation: "Nueva conversación",
|
|
@@ -2033,7 +2185,7 @@ const Ie = {
|
|
|
2033
2185
|
zoom_out: "Alejar",
|
|
2034
2186
|
reset_zoom: "Restablecer zoom",
|
|
2035
2187
|
support_chat_aria_label: "Chat de soporte"
|
|
2036
|
-
},
|
|
2188
|
+
}, $e = {
|
|
2037
2189
|
write_a_message_placeholder: "Magsulat ng mensahe...",
|
|
2038
2190
|
your_issue_has_been_resolved: "Nalutas na ang iyong isyu!",
|
|
2039
2191
|
new_conversation: "Bagong usapan",
|
|
@@ -2130,7 +2282,7 @@ const Ie = {
|
|
|
2130
2282
|
zoom_out: "Paliitin",
|
|
2131
2283
|
reset_zoom: "I-reset ang zoom",
|
|
2132
2284
|
support_chat_aria_label: "Chat ng suporta"
|
|
2133
|
-
},
|
|
2285
|
+
}, Je = {
|
|
2134
2286
|
write_a_message_placeholder: "Kirjoita viesti...",
|
|
2135
2287
|
your_issue_has_been_resolved: "Ongelmasi on ratkaistu!",
|
|
2136
2288
|
new_conversation: "Uusi keskustelu",
|
|
@@ -2227,7 +2379,7 @@ const Ie = {
|
|
|
2227
2379
|
zoom_out: "Loitonna",
|
|
2228
2380
|
reset_zoom: "Palauta zoomaus",
|
|
2229
2381
|
support_chat_aria_label: "Tukichat"
|
|
2230
|
-
},
|
|
2382
|
+
}, Ye = {
|
|
2231
2383
|
write_a_message_placeholder: "Écrivez un message...",
|
|
2232
2384
|
your_issue_has_been_resolved: "Votre problème a été résolu !",
|
|
2233
2385
|
new_conversation: "Nouvelle conversation",
|
|
@@ -2324,7 +2476,7 @@ const Ie = {
|
|
|
2324
2476
|
zoom_out: "Zoom arrière",
|
|
2325
2477
|
reset_zoom: "Réinitialiser le zoom",
|
|
2326
2478
|
support_chat_aria_label: "Chat de support"
|
|
2327
|
-
},
|
|
2479
|
+
}, Qe = {
|
|
2328
2480
|
write_a_message_placeholder: "एक संदेश लिखें...",
|
|
2329
2481
|
your_issue_has_been_resolved: "आपकी समस्या हल हो गई है!",
|
|
2330
2482
|
new_conversation: "नई बातचीत",
|
|
@@ -2421,7 +2573,7 @@ const Ie = {
|
|
|
2421
2573
|
zoom_out: "ज़ूम आउट",
|
|
2422
2574
|
reset_zoom: "ज़ूम रीसेट करें",
|
|
2423
2575
|
support_chat_aria_label: "सहायता चैट"
|
|
2424
|
-
},
|
|
2576
|
+
}, Xe = {
|
|
2425
2577
|
write_a_message_placeholder: "Scrivi un messaggio...",
|
|
2426
2578
|
your_issue_has_been_resolved: "Il tuo problema è stato risolto!",
|
|
2427
2579
|
new_conversation: "Nuova conversazione",
|
|
@@ -2518,7 +2670,7 @@ const Ie = {
|
|
|
2518
2670
|
zoom_out: "Riduci",
|
|
2519
2671
|
reset_zoom: "Reimposta zoom",
|
|
2520
2672
|
support_chat_aria_label: "Chat di supporto"
|
|
2521
|
-
},
|
|
2673
|
+
}, ea = {
|
|
2522
2674
|
write_a_message_placeholder: "メッセージを入力...",
|
|
2523
2675
|
your_issue_has_been_resolved: "問題が解決しました!",
|
|
2524
2676
|
new_conversation: "新しい会話",
|
|
@@ -2615,7 +2767,7 @@ const Ie = {
|
|
|
2615
2767
|
zoom_out: "縮小",
|
|
2616
2768
|
reset_zoom: "ズームをリセット",
|
|
2617
2769
|
support_chat_aria_label: "サポートチャット"
|
|
2618
|
-
},
|
|
2770
|
+
}, aa = {
|
|
2619
2771
|
write_a_message_placeholder: "메시지를 입력하세요...",
|
|
2620
2772
|
your_issue_has_been_resolved: "문제가 해결되었습니다!",
|
|
2621
2773
|
new_conversation: "새 대화",
|
|
@@ -2712,7 +2864,7 @@ const Ie = {
|
|
|
2712
2864
|
zoom_out: "축소",
|
|
2713
2865
|
reset_zoom: "확대/축소 초기화",
|
|
2714
2866
|
support_chat_aria_label: "고객 지원 채팅"
|
|
2715
|
-
},
|
|
2867
|
+
}, ta = {
|
|
2716
2868
|
write_a_message_placeholder: "Schrijf een bericht...",
|
|
2717
2869
|
your_issue_has_been_resolved: "Uw probleem is opgelost!",
|
|
2718
2870
|
new_conversation: "Nieuw gesprek",
|
|
@@ -2809,7 +2961,7 @@ const Ie = {
|
|
|
2809
2961
|
zoom_out: "Uitzoomen",
|
|
2810
2962
|
reset_zoom: "Zoom herstellen",
|
|
2811
2963
|
support_chat_aria_label: "Supportchat"
|
|
2812
|
-
},
|
|
2964
|
+
}, sa = {
|
|
2813
2965
|
write_a_message_placeholder: "Skriv en melding...",
|
|
2814
2966
|
your_issue_has_been_resolved: "Problemet ditt er løst!",
|
|
2815
2967
|
new_conversation: "Ny samtale",
|
|
@@ -2906,7 +3058,7 @@ const Ie = {
|
|
|
2906
3058
|
zoom_out: "Zoom ut",
|
|
2907
3059
|
reset_zoom: "Tilbakestill zoom",
|
|
2908
3060
|
support_chat_aria_label: "Support-chat"
|
|
2909
|
-
},
|
|
3061
|
+
}, oa = {
|
|
2910
3062
|
write_a_message_placeholder: "Napisz wiadomość...",
|
|
2911
3063
|
your_issue_has_been_resolved: "Twój problem został rozwiązany!",
|
|
2912
3064
|
new_conversation: "Nowa rozmowa",
|
|
@@ -3003,7 +3155,7 @@ const Ie = {
|
|
|
3003
3155
|
zoom_out: "Pomniejsz",
|
|
3004
3156
|
reset_zoom: "Resetuj powiększenie",
|
|
3005
3157
|
support_chat_aria_label: "Czat pomocy"
|
|
3006
|
-
},
|
|
3158
|
+
}, na = {
|
|
3007
3159
|
write_a_message_placeholder: "Escreva uma mensagem...",
|
|
3008
3160
|
your_issue_has_been_resolved: "Seu problema foi resolvido!",
|
|
3009
3161
|
new_conversation: "Nova conversa",
|
|
@@ -3100,7 +3252,7 @@ const Ie = {
|
|
|
3100
3252
|
zoom_out: "Reduzir",
|
|
3101
3253
|
reset_zoom: "Redefinir zoom",
|
|
3102
3254
|
support_chat_aria_label: "Chat de suporte"
|
|
3103
|
-
},
|
|
3255
|
+
}, ia = {
|
|
3104
3256
|
write_a_message_placeholder: "Scrie un mesaj...",
|
|
3105
3257
|
your_issue_has_been_resolved: "Problema ta a fost rezolvată!",
|
|
3106
3258
|
new_conversation: "Conversație nouă",
|
|
@@ -3197,7 +3349,7 @@ const Ie = {
|
|
|
3197
3349
|
zoom_out: "Micșorează",
|
|
3198
3350
|
reset_zoom: "Resetează zoomul",
|
|
3199
3351
|
support_chat_aria_label: "Chat de asistență"
|
|
3200
|
-
},
|
|
3352
|
+
}, ra = {
|
|
3201
3353
|
write_a_message_placeholder: "Skriv ett meddelande...",
|
|
3202
3354
|
your_issue_has_been_resolved: "Ditt problem har lösts!",
|
|
3203
3355
|
new_conversation: "Ny konversation",
|
|
@@ -3294,7 +3446,7 @@ const Ie = {
|
|
|
3294
3446
|
zoom_out: "Zooma ut",
|
|
3295
3447
|
reset_zoom: "Återställ zoom",
|
|
3296
3448
|
support_chat_aria_label: "Supportchatt"
|
|
3297
|
-
},
|
|
3449
|
+
}, _a = {
|
|
3298
3450
|
write_a_message_placeholder: "Напишите сообщение...",
|
|
3299
3451
|
your_issue_has_been_resolved: "Ваша проблема решена!",
|
|
3300
3452
|
new_conversation: "Новый разговор",
|
|
@@ -3391,7 +3543,7 @@ const Ie = {
|
|
|
3391
3543
|
zoom_out: "Уменьшить",
|
|
3392
3544
|
reset_zoom: "Сбросить масштаб",
|
|
3393
3545
|
support_chat_aria_label: "Чат поддержки"
|
|
3394
|
-
},
|
|
3546
|
+
}, la = {
|
|
3395
3547
|
write_a_message_placeholder: "เขียนข้อความ...",
|
|
3396
3548
|
your_issue_has_been_resolved: "ปัญหาของคุณได้รับการแก้ไขแล้ว!",
|
|
3397
3549
|
new_conversation: "การสนทนาใหม่",
|
|
@@ -3488,7 +3640,7 @@ const Ie = {
|
|
|
3488
3640
|
zoom_out: "ย่อ",
|
|
3489
3641
|
reset_zoom: "รีเซ็ตการซูม",
|
|
3490
3642
|
support_chat_aria_label: "แชทฝ่ายสนับสนุน"
|
|
3491
|
-
},
|
|
3643
|
+
}, ca = {
|
|
3492
3644
|
write_a_message_placeholder: "Bir mesaj yazın...",
|
|
3493
3645
|
your_issue_has_been_resolved: "Sorununuz çözüldü!",
|
|
3494
3646
|
new_conversation: "Yeni konuşma",
|
|
@@ -3585,7 +3737,7 @@ const Ie = {
|
|
|
3585
3737
|
zoom_out: "Uzaklaştır",
|
|
3586
3738
|
reset_zoom: "Yakınlaştırmayı sıfırla",
|
|
3587
3739
|
support_chat_aria_label: "Destek sohbeti"
|
|
3588
|
-
},
|
|
3740
|
+
}, pa = {
|
|
3589
3741
|
write_a_message_placeholder: "پیغام لکھیں...",
|
|
3590
3742
|
your_issue_has_been_resolved: "آپ کا مسئلہ حل ہو گیا ہے!",
|
|
3591
3743
|
new_conversation: "نئی گفتگو",
|
|
@@ -3682,7 +3834,7 @@ const Ie = {
|
|
|
3682
3834
|
zoom_out: "زوم آؤٹ",
|
|
3683
3835
|
reset_zoom: "زوم دوبارہ ترتیب دیں",
|
|
3684
3836
|
support_chat_aria_label: "سپورٹ چیٹ"
|
|
3685
|
-
},
|
|
3837
|
+
}, da = {
|
|
3686
3838
|
write_a_message_placeholder: "Viết tin nhắn...",
|
|
3687
3839
|
your_issue_has_been_resolved: "Vấn đề của bạn đã được giải quyết!",
|
|
3688
3840
|
new_conversation: "Cuộc trò chuyện mới",
|
|
@@ -3779,7 +3931,7 @@ const Ie = {
|
|
|
3779
3931
|
zoom_out: "Thu nhỏ",
|
|
3780
3932
|
reset_zoom: "Đặt lại thu phóng",
|
|
3781
3933
|
support_chat_aria_label: "Trò chuyện hỗ trợ"
|
|
3782
|
-
},
|
|
3934
|
+
}, ua = {
|
|
3783
3935
|
write_a_message_placeholder: "写一条消息...",
|
|
3784
3936
|
your_issue_has_been_resolved: "您的问题已解决!",
|
|
3785
3937
|
new_conversation: "新对话",
|
|
@@ -3876,7 +4028,7 @@ const Ie = {
|
|
|
3876
4028
|
zoom_out: "缩小",
|
|
3877
4029
|
reset_zoom: "重置缩放",
|
|
3878
4030
|
support_chat_aria_label: "支持对话"
|
|
3879
|
-
},
|
|
4031
|
+
}, ma = {
|
|
3880
4032
|
write_a_message_placeholder: "Napišite poruku...",
|
|
3881
4033
|
your_issue_has_been_resolved: "Vaš problem je riješen!",
|
|
3882
4034
|
new_conversation: "Novi razgovor",
|
|
@@ -3973,7 +4125,7 @@ const Ie = {
|
|
|
3973
4125
|
zoom_out: "Udalji",
|
|
3974
4126
|
reset_zoom: "Poništi zumiranje",
|
|
3975
4127
|
support_chat_aria_label: "Chat za podršku"
|
|
3976
|
-
},
|
|
4128
|
+
}, ha = {
|
|
3977
4129
|
write_a_message_placeholder: "Kirjuta sõnum...",
|
|
3978
4130
|
your_issue_has_been_resolved: "Teie probleem on lahendatud!",
|
|
3979
4131
|
new_conversation: "Uus vestlus",
|
|
@@ -4070,7 +4222,7 @@ const Ie = {
|
|
|
4070
4222
|
zoom_out: "Vähenda",
|
|
4071
4223
|
reset_zoom: "Lähtesta suurendus",
|
|
4072
4224
|
support_chat_aria_label: "Tugivestlus"
|
|
4073
|
-
},
|
|
4225
|
+
}, ga = {
|
|
4074
4226
|
write_a_message_placeholder: "Írjon üzenetet...",
|
|
4075
4227
|
your_issue_has_been_resolved: "A problémája megoldódott!",
|
|
4076
4228
|
new_conversation: "Új beszélgetés",
|
|
@@ -4167,7 +4319,7 @@ const Ie = {
|
|
|
4167
4319
|
zoom_out: "Kicsinyítés",
|
|
4168
4320
|
reset_zoom: "Nagyítás visszaállítása",
|
|
4169
4321
|
support_chat_aria_label: "Ügyfélszolgálati chat"
|
|
4170
|
-
},
|
|
4322
|
+
}, ka = {
|
|
4171
4323
|
write_a_message_placeholder: "Skrifaðu skilaboð...",
|
|
4172
4324
|
your_issue_has_been_resolved: "Málið þitt hefur verið leyst!",
|
|
4173
4325
|
new_conversation: "Nýtt samtal",
|
|
@@ -4264,7 +4416,7 @@ const Ie = {
|
|
|
4264
4416
|
zoom_out: "Minnka aðdrátt",
|
|
4265
4417
|
reset_zoom: "Endurstilla aðdrátt",
|
|
4266
4418
|
support_chat_aria_label: "Þjónustuspjall"
|
|
4267
|
-
},
|
|
4419
|
+
}, ba = {
|
|
4268
4420
|
write_a_message_placeholder: "Rakstiet ziņojumu...",
|
|
4269
4421
|
your_issue_has_been_resolved: "Jūsu problēma ir atrisināta!",
|
|
4270
4422
|
new_conversation: "Jauna saruna",
|
|
@@ -4361,7 +4513,7 @@ const Ie = {
|
|
|
4361
4513
|
zoom_out: "Attālināt",
|
|
4362
4514
|
reset_zoom: "Atiestatīt tālummaiņu",
|
|
4363
4515
|
support_chat_aria_label: "Atbalsta tērzēšana"
|
|
4364
|
-
},
|
|
4516
|
+
}, va = {
|
|
4365
4517
|
write_a_message_placeholder: "Parašykite žinutę...",
|
|
4366
4518
|
your_issue_has_been_resolved: "Jūsų problema išspręsta!",
|
|
4367
4519
|
new_conversation: "Naujas pokalbis",
|
|
@@ -4458,7 +4610,7 @@ const Ie = {
|
|
|
4458
4610
|
zoom_out: "Nutolinti",
|
|
4459
4611
|
reset_zoom: "Atstatyti mastelį",
|
|
4460
4612
|
support_chat_aria_label: "Pagalbos pokalbis"
|
|
4461
|
-
},
|
|
4613
|
+
}, fa = {
|
|
4462
4614
|
write_a_message_placeholder: "Schreift eng Noriicht...",
|
|
4463
4615
|
your_issue_has_been_resolved: "Äert Problem gouf geléist!",
|
|
4464
4616
|
new_conversation: "Nei Konversatioun",
|
|
@@ -4555,7 +4707,7 @@ const Ie = {
|
|
|
4555
4707
|
zoom_out: "Erauszoomen",
|
|
4556
4708
|
reset_zoom: "Zoom zrécksetzen",
|
|
4557
4709
|
support_chat_aria_label: "Support-Chat"
|
|
4558
|
-
},
|
|
4710
|
+
}, ya = {
|
|
4559
4711
|
write_a_message_placeholder: "Ikteb messaġġ...",
|
|
4560
4712
|
your_issue_has_been_resolved: "Il-problema tiegħek ġiet riżolta!",
|
|
4561
4713
|
new_conversation: "Konversazzjoni ġdida",
|
|
@@ -4652,7 +4804,7 @@ const Ie = {
|
|
|
4652
4804
|
zoom_out: "Ċekken",
|
|
4653
4805
|
reset_zoom: "Irrisettja ż-zoom",
|
|
4654
4806
|
support_chat_aria_label: "Chat ta’ appoġġ"
|
|
4655
|
-
},
|
|
4807
|
+
}, wa = {
|
|
4656
4808
|
write_a_message_placeholder: "Skriv en melding...",
|
|
4657
4809
|
your_issue_has_been_resolved: "Saken din er løst!",
|
|
4658
4810
|
new_conversation: "Ny samtale",
|
|
@@ -4749,7 +4901,7 @@ const Ie = {
|
|
|
4749
4901
|
zoom_out: "Zoom ut",
|
|
4750
4902
|
reset_zoom: "Tilbakestill zoom",
|
|
4751
4903
|
support_chat_aria_label: "Support-chat"
|
|
4752
|
-
},
|
|
4904
|
+
}, ja = {
|
|
4753
4905
|
write_a_message_placeholder: "Napíšte správu...",
|
|
4754
4906
|
your_issue_has_been_resolved: "Váš problém bol vyriešený!",
|
|
4755
4907
|
new_conversation: "Nová konverzácia",
|
|
@@ -4846,86 +4998,86 @@ const Ie = {
|
|
|
4846
4998
|
zoom_out: "Oddialiť",
|
|
4847
4999
|
reset_zoom: "Obnoviť priblíženie",
|
|
4848
5000
|
support_chat_aria_label: "Chat podpory"
|
|
4849
|
-
},
|
|
4850
|
-
ar:
|
|
4851
|
-
bn:
|
|
4852
|
-
bg:
|
|
4853
|
-
cs:
|
|
4854
|
-
da:
|
|
4855
|
-
de:
|
|
4856
|
-
el:
|
|
4857
|
-
en:
|
|
4858
|
-
es:
|
|
4859
|
-
et:
|
|
4860
|
-
fi:
|
|
4861
|
-
fil:
|
|
4862
|
-
fr:
|
|
4863
|
-
hi:
|
|
4864
|
-
hr:
|
|
4865
|
-
hu:
|
|
4866
|
-
is:
|
|
4867
|
-
it:
|
|
4868
|
-
ja:
|
|
4869
|
-
ko:
|
|
4870
|
-
lb:
|
|
4871
|
-
lt:
|
|
4872
|
-
lv:
|
|
4873
|
-
mt:
|
|
4874
|
-
nb:
|
|
4875
|
-
nl:
|
|
4876
|
-
no:
|
|
4877
|
-
pl:
|
|
4878
|
-
pt:
|
|
4879
|
-
ro:
|
|
4880
|
-
ru:
|
|
4881
|
-
sk:
|
|
4882
|
-
sv:
|
|
4883
|
-
th:
|
|
4884
|
-
tr:
|
|
4885
|
-
ur:
|
|
4886
|
-
vi:
|
|
4887
|
-
"zh-cn":
|
|
4888
|
-
},
|
|
4889
|
-
function
|
|
4890
|
-
return
|
|
5001
|
+
}, Y = {
|
|
5002
|
+
ar: Oe,
|
|
5003
|
+
bn: Ue,
|
|
5004
|
+
bg: Be,
|
|
5005
|
+
cs: Ve,
|
|
5006
|
+
da: He,
|
|
5007
|
+
de: We,
|
|
5008
|
+
el: Ze,
|
|
5009
|
+
en: J,
|
|
5010
|
+
es: Ge,
|
|
5011
|
+
et: ha,
|
|
5012
|
+
fi: Je,
|
|
5013
|
+
fil: $e,
|
|
5014
|
+
fr: Ye,
|
|
5015
|
+
hi: Qe,
|
|
5016
|
+
hr: ma,
|
|
5017
|
+
hu: ga,
|
|
5018
|
+
is: ka,
|
|
5019
|
+
it: Xe,
|
|
5020
|
+
ja: ea,
|
|
5021
|
+
ko: aa,
|
|
5022
|
+
lb: fa,
|
|
5023
|
+
lt: va,
|
|
5024
|
+
lv: ba,
|
|
5025
|
+
mt: ya,
|
|
5026
|
+
nb: wa,
|
|
5027
|
+
nl: ta,
|
|
5028
|
+
no: sa,
|
|
5029
|
+
pl: oa,
|
|
5030
|
+
pt: na,
|
|
5031
|
+
ro: ia,
|
|
5032
|
+
ru: _a,
|
|
5033
|
+
sk: ja,
|
|
5034
|
+
sv: ra,
|
|
5035
|
+
th: la,
|
|
5036
|
+
tr: ca,
|
|
5037
|
+
ur: pa,
|
|
5038
|
+
vi: da,
|
|
5039
|
+
"zh-cn": ua
|
|
5040
|
+
}, Sa = Object.keys(Y);
|
|
5041
|
+
function za(n) {
|
|
5042
|
+
return Sa.includes(n);
|
|
4891
5043
|
}
|
|
4892
|
-
const
|
|
4893
|
-
function
|
|
4894
|
-
return
|
|
5044
|
+
const Ca = /* @__PURE__ */ new Set(["ar", "ur"]);
|
|
5045
|
+
function Ja(n) {
|
|
5046
|
+
return Ca.has(n);
|
|
4895
5047
|
}
|
|
4896
|
-
function
|
|
4897
|
-
return
|
|
5048
|
+
function xa(n) {
|
|
5049
|
+
return za(n) ? n : "en";
|
|
4898
5050
|
}
|
|
4899
|
-
function
|
|
4900
|
-
var
|
|
4901
|
-
const
|
|
4902
|
-
return
|
|
5051
|
+
function qa(n, e, t, o) {
|
|
5052
|
+
var l;
|
|
5053
|
+
const r = ((l = t == null ? void 0 : t[e]) == null ? void 0 : l[n]) || Y[e][n] || J[n] || n;
|
|
5054
|
+
return o ? r.replace(
|
|
4903
5055
|
/\{(\w+)\}/g,
|
|
4904
|
-
(
|
|
4905
|
-
) :
|
|
5056
|
+
(s, a) => a in o ? String(o[a]) : s
|
|
5057
|
+
) : r;
|
|
4906
5058
|
}
|
|
4907
|
-
function
|
|
4908
|
-
return
|
|
5059
|
+
function Ea(n, e, t) {
|
|
5060
|
+
return qa(
|
|
4909
5061
|
e,
|
|
4910
|
-
|
|
5062
|
+
xa(n.language),
|
|
4911
5063
|
n.translationOverrides,
|
|
4912
|
-
|
|
5064
|
+
t
|
|
4913
5065
|
);
|
|
4914
5066
|
}
|
|
4915
|
-
class
|
|
5067
|
+
class Aa {
|
|
4916
5068
|
constructor({
|
|
4917
5069
|
config: e,
|
|
4918
|
-
api:
|
|
4919
|
-
contactCtx:
|
|
4920
|
-
storageCtx:
|
|
4921
|
-
sessionsPollingIntervalSeconds:
|
|
4922
|
-
sharedSessions:
|
|
5070
|
+
api: t,
|
|
5071
|
+
contactCtx: o,
|
|
5072
|
+
storageCtx: r,
|
|
5073
|
+
sessionsPollingIntervalSeconds: l,
|
|
5074
|
+
sharedSessions: s
|
|
4923
5075
|
}) {
|
|
4924
|
-
this.sessionsRefresher = new
|
|
5076
|
+
this.sessionsRefresher = new G(), this.persistedSessionId = null, this.sessionAbortController = new AbortController(), this.sessionState = new S({
|
|
4925
5077
|
session: null,
|
|
4926
5078
|
isCreatingSession: !1,
|
|
4927
5079
|
isResolvingSession: !1
|
|
4928
|
-
}), this.sessionsState = new
|
|
5080
|
+
}), this.sessionsState = new S({
|
|
4929
5081
|
data: [],
|
|
4930
5082
|
cursor: void 0,
|
|
4931
5083
|
isLastPage: !1,
|
|
@@ -4939,21 +5091,21 @@ class ja {
|
|
|
4939
5091
|
this.persistSession
|
|
4940
5092
|
));
|
|
4941
5093
|
}, this.restoreActiveSessionTracking = () => {
|
|
4942
|
-
var
|
|
4943
|
-
(
|
|
4944
|
-
}, this.trackActiveSession = (
|
|
4945
|
-
var
|
|
4946
|
-
(
|
|
5094
|
+
var a;
|
|
5095
|
+
(a = this.stopPersistingSession) == null || a.call(this), this.stopPersistingSession = void 0, this.registerActiveSessionPersistence();
|
|
5096
|
+
}, this.trackActiveSession = (a) => {
|
|
5097
|
+
var i;
|
|
5098
|
+
(i = this.stopPersistingSession) == null || i.call(this), this.stopPersistingSession = a.sessionState.subscribe(
|
|
4947
5099
|
this.persistSession
|
|
4948
|
-
), this.persistSession(
|
|
4949
|
-
}, this.persistSession = ({ session:
|
|
4950
|
-
const
|
|
4951
|
-
if (!
|
|
4952
|
-
const c =
|
|
5100
|
+
), this.persistSession(a.sessionState.get());
|
|
5101
|
+
}, this.persistSession = ({ session: a }) => {
|
|
5102
|
+
const i = this.storageCtx;
|
|
5103
|
+
if (!i) return;
|
|
5104
|
+
const c = a != null && a.isOpened ? a.id : null;
|
|
4953
5105
|
if (c === this.persistedSessionId || !c && this.persistedSessionId === null) return;
|
|
4954
|
-
this.persistedSessionId = c, (c ?
|
|
4955
|
-
|
|
4956
|
-
error:
|
|
5106
|
+
this.persistedSessionId = c, (c ? i.setActiveSessionId(c) : i.clearActiveSessionId()).catch((_) => {
|
|
5107
|
+
k.warn("failed to persist the active session", {
|
|
5108
|
+
error: _ instanceof Error ? _.message : String(_)
|
|
4957
5109
|
});
|
|
4958
5110
|
});
|
|
4959
5111
|
}, this.getLastActiveSessionId = async () => {
|
|
@@ -4966,231 +5118,246 @@ class ja {
|
|
|
4966
5118
|
}, this.reset = async () => {
|
|
4967
5119
|
this.sessionAbortController.abort(), this.sessionAbortController = new AbortController(), this.sessionState.reset();
|
|
4968
5120
|
}, this.registerSessionsRefresherWrapper = () => {
|
|
4969
|
-
var
|
|
5121
|
+
var a;
|
|
4970
5122
|
// If the widget config was initially provided with a contact token, no state change would be triggered, so we just fetch
|
|
4971
|
-
(
|
|
4972
|
-
|
|
4973
|
-
|
|
5123
|
+
(a = this.contactCtx.state.get().contact) != null && a.token && !this.sessionsState.get().didStartInitialFetch ? this.registerSessionsRefresher() : this.stopWaitingForContact = this.contactCtx.state.subscribe(
|
|
5124
|
+
({ contact: i }) => {
|
|
5125
|
+
i != null && i.token && !this.sessionsState.get().didStartInitialFetch && this.registerSessionsRefresher();
|
|
5126
|
+
}
|
|
5127
|
+
);
|
|
4974
5128
|
}, this.registerSessionsRefresher = () => {
|
|
4975
5129
|
this.sessionsRefresher.startPolling(async () => {
|
|
4976
5130
|
this.sessionsState.get().didStartInitialFetch === !1 && this.sessionsState.setPartial({ didStartInitialFetch: !0 }), await this.refreshSessions(), this.sessionsState.get().isInitialFetchLoading === !0 && this.sessionsState.setPartial({ isInitialFetchLoading: !1 });
|
|
4977
5131
|
}, this.sessionsPollingIntervalSeconds * 1e3);
|
|
5132
|
+
}, this.dispose = ({ clearActiveSession: a = !1 } = {}) => {
|
|
5133
|
+
var i, c;
|
|
5134
|
+
if (this.sessionsRefresher.reset(), this.sessionAbortController.abort(), (i = this.stopPersistingSession) == null || i.call(this), this.stopPersistingSession = void 0, (c = this.stopWaitingForContact) == null || c.call(this), this.stopWaitingForContact = void 0, this.sessionState.reset(), a && this.storageCtx)
|
|
5135
|
+
return this.persistedSessionId = null, this.storageCtx.clearActiveSessionId().catch((d) => {
|
|
5136
|
+
k.warn("failed to clear the replaced session", {
|
|
5137
|
+
error: d instanceof Error ? d.message : String(d)
|
|
5138
|
+
});
|
|
5139
|
+
});
|
|
4978
5140
|
}, this.getParsedCustomData = () => Object.fromEntries(
|
|
4979
5141
|
Object.entries(this.config.sessionCustomData || {}).map(
|
|
4980
|
-
([
|
|
5142
|
+
([a, i]) => {
|
|
4981
5143
|
var c;
|
|
4982
|
-
return typeof
|
|
5144
|
+
return typeof i == "string" ? [a, i] : typeof i == "boolean" ? [a, i] : typeof i == "number" ? [a, i] : [a, ((c = $(() => JSON.stringify(i))) == null ? void 0 : c.data) || ""];
|
|
4983
5145
|
}
|
|
4984
5146
|
)
|
|
4985
5147
|
), this.createSession = async () => {
|
|
4986
|
-
const { signal:
|
|
5148
|
+
const { signal: a } = this.sessionAbortController;
|
|
4987
5149
|
this.sessionState.setPartial({ session: null, isCreatingSession: !0 });
|
|
4988
5150
|
try {
|
|
4989
|
-
const
|
|
4990
|
-
if (
|
|
4991
|
-
if (
|
|
4992
|
-
if (
|
|
4993
|
-
if (
|
|
4994
|
-
const c = await this.requestSession(
|
|
4995
|
-
return
|
|
5151
|
+
const i = await this.requestSession(a);
|
|
5152
|
+
if (a.aborted) return null;
|
|
5153
|
+
if (i.session) return i.session;
|
|
5154
|
+
if (i.status === 401 && await this.contactCtx.recoverFromStaleToken()) {
|
|
5155
|
+
if (a.aborted) return null;
|
|
5156
|
+
const c = await this.requestSession(a);
|
|
5157
|
+
return a.aborted ? null : c.session ? c.session : (k.error("failed to create session", c.error), null);
|
|
4996
5158
|
}
|
|
4997
|
-
return
|
|
4998
|
-
} catch (
|
|
4999
|
-
return
|
|
5159
|
+
return k.error("failed to create session", i.error), null;
|
|
5160
|
+
} catch (i) {
|
|
5161
|
+
return a.aborted || k.error("failed to create session", i), null;
|
|
5000
5162
|
} finally {
|
|
5001
|
-
|
|
5163
|
+
a.aborted || this.sessionState.setPartial({ isCreatingSession: !1 });
|
|
5002
5164
|
}
|
|
5003
|
-
}, this.requestSession = async (
|
|
5165
|
+
}, this.requestSession = async (a) => {
|
|
5004
5166
|
var u, m, g;
|
|
5005
|
-
const
|
|
5167
|
+
const i = (u = this.contactCtx.state.get().contact) == null ? void 0 : u.externalId, c = {
|
|
5006
5168
|
...this.getParsedCustomData(),
|
|
5007
|
-
...
|
|
5169
|
+
...i ? { external_id: i } : {}
|
|
5008
5170
|
}, {
|
|
5009
5171
|
data: d,
|
|
5010
|
-
error:
|
|
5172
|
+
error: _,
|
|
5011
5173
|
response: p
|
|
5012
5174
|
} = await this.api.createSession(
|
|
5013
5175
|
{
|
|
5014
5176
|
customData: Object.keys(c).length > 0 ? c : void 0
|
|
5015
5177
|
},
|
|
5016
|
-
|
|
5178
|
+
a
|
|
5017
5179
|
);
|
|
5018
|
-
if (
|
|
5019
|
-
return { session: null, status: p == null ? void 0 : p.status, error:
|
|
5180
|
+
if (a.aborted || !d)
|
|
5181
|
+
return { session: null, status: p == null ? void 0 : p.status, error: _ };
|
|
5020
5182
|
this.sessionState.setPartial({ session: d });
|
|
5021
5183
|
try {
|
|
5022
5184
|
(g = (m = this.config.hooks) == null ? void 0 : m.onSessionCreated) == null || g.call(m, { session: d });
|
|
5023
|
-
} catch (
|
|
5024
|
-
|
|
5185
|
+
} catch (v) {
|
|
5186
|
+
k.error("onSessionCreated hook failed", v);
|
|
5025
5187
|
}
|
|
5026
5188
|
return { session: d, status: p.status, error: void 0 };
|
|
5027
5189
|
}, this.loadMoreSessions = async () => {
|
|
5028
5190
|
if (this.sessionsState.get().isLastPage) return;
|
|
5029
|
-
const { data:
|
|
5191
|
+
const { data: a } = await this.getSessions({
|
|
5030
5192
|
cursor: this.sessionsState.get().cursor
|
|
5031
5193
|
});
|
|
5032
|
-
if (
|
|
5033
|
-
const c = [...this.sessionsState.get().data, ...
|
|
5034
|
-
(d,
|
|
5194
|
+
if (a) {
|
|
5195
|
+
const c = [...this.sessionsState.get().data, ...a.items].filter(
|
|
5196
|
+
(d, _, p) => _ === p.findIndex((u) => d.id === u.id)
|
|
5035
5197
|
);
|
|
5036
5198
|
this.sessionsState.setPartial({
|
|
5037
5199
|
data: c,
|
|
5038
|
-
cursor:
|
|
5039
|
-
isLastPage:
|
|
5200
|
+
cursor: a.next || void 0,
|
|
5201
|
+
isLastPage: a.next === null
|
|
5040
5202
|
});
|
|
5041
5203
|
}
|
|
5042
|
-
}, this.getSessions = async ({ cursor:
|
|
5204
|
+
}, this.getSessions = async ({ cursor: a }) => {
|
|
5043
5205
|
var c, d;
|
|
5044
5206
|
if (!((c = this.contactCtx.state.get().contact) != null && c.token)) return { data: null };
|
|
5045
|
-
const
|
|
5207
|
+
const i = (d = this.contactCtx.state.get().contact) == null ? void 0 : d.externalId;
|
|
5046
5208
|
return await this.api.getSessions({
|
|
5047
|
-
cursor:
|
|
5048
|
-
filters:
|
|
5049
|
-
external_id:
|
|
5209
|
+
cursor: a,
|
|
5210
|
+
filters: i ? {
|
|
5211
|
+
external_id: i
|
|
5050
5212
|
} : {}
|
|
5051
5213
|
});
|
|
5052
|
-
}, this.setSessions = (
|
|
5053
|
-
const
|
|
5054
|
-
(c, d,
|
|
5214
|
+
}, this.setSessions = (a) => {
|
|
5215
|
+
const i = [...a, ...this.sessionsState.get().data].filter(
|
|
5216
|
+
(c, d, _) => d === _.findIndex((p) => c.id === p.id)
|
|
5055
5217
|
);
|
|
5056
|
-
this.sessionsState.setPartial({ data:
|
|
5218
|
+
this.sessionsState.setPartial({ data: i });
|
|
5057
5219
|
}, this.refreshSessions = async () => {
|
|
5058
|
-
const { data:
|
|
5059
|
-
|
|
5220
|
+
const { data: a } = await this.getSessions({ cursor: void 0 });
|
|
5221
|
+
a && this.setSessions(a.items);
|
|
5060
5222
|
}, this.resolveSession = async () => {
|
|
5061
|
-
const
|
|
5062
|
-
if (!
|
|
5223
|
+
const a = this.sessionState.get().session;
|
|
5224
|
+
if (!a || !a.isOpened)
|
|
5063
5225
|
return { success: !1, error: "Session is not opened" };
|
|
5064
5226
|
this.sessionState.setPartial({ isResolvingSession: !0 });
|
|
5065
|
-
const { signal:
|
|
5066
|
-
if (
|
|
5227
|
+
const { signal: i } = this.sessionAbortController, c = await this.api.resolveSession({ session_id: a.id }, i).catch((p) => {
|
|
5228
|
+
if (i.aborted) return null;
|
|
5067
5229
|
throw p;
|
|
5068
5230
|
});
|
|
5069
|
-
if (!c ||
|
|
5231
|
+
if (!c || i.aborted)
|
|
5070
5232
|
return { success: !1, error: "Session was reset" };
|
|
5071
|
-
const { data: d, error:
|
|
5072
|
-
return d ? (this.sessionState.setPartial({ session: d, isResolvingSession: !1 }), { success: !0, data: d }) : (this.sessionState.setPartial({ isResolvingSession: !1 }), { success: !1, error:
|
|
5073
|
-
}, this.createStateCheckpoint = async (
|
|
5233
|
+
const { data: d, error: _ } = c;
|
|
5234
|
+
return d ? (this.sessionState.setPartial({ session: d, isResolvingSession: !1 }), { success: !0, data: d }) : (this.sessionState.setPartial({ isResolvingSession: !1 }), { success: !1, error: _ });
|
|
5235
|
+
}, this.createStateCheckpoint = async (a) => {
|
|
5074
5236
|
var d;
|
|
5075
|
-
const
|
|
5076
|
-
if (!
|
|
5237
|
+
const i = (d = this.sessionState.get().session) == null ? void 0 : d.id;
|
|
5238
|
+
if (!i) return;
|
|
5077
5239
|
const { data: c } = await this.api.createStateCheckpoint({
|
|
5078
|
-
session_id:
|
|
5079
|
-
payload:
|
|
5240
|
+
session_id: i,
|
|
5241
|
+
payload: a
|
|
5080
5242
|
});
|
|
5081
5243
|
return c != null && c.success ? { success: !0 } : { success: !1 };
|
|
5082
|
-
}, this.config = e, this.api =
|
|
5244
|
+
}, this.config = e, this.api = t, this.contactCtx = o, this.storageCtx = r, this.sessionsPollingIntervalSeconds = l, s ? this.sessionsState = s : this.registerSessionsRefresherWrapper(), this.registerActiveSessionPersistence();
|
|
5083
5245
|
}
|
|
5084
5246
|
}
|
|
5085
|
-
const
|
|
5086
|
-
const
|
|
5247
|
+
const Pa = (n, e, { sendsPageContext: t }) => {
|
|
5248
|
+
const o = Ma(n), r = t && e.mentions && e.mentions.length > 0 ? { mentions: e.mentions.map(Ta) } : void 0, l = t && (e.clientContext || r) ? { ...o, ...e.clientContext, ...r } : o, s = e.connectionRequestId ? {
|
|
5249
|
+
...l,
|
|
5250
|
+
opencx__connection_request_id: e.connectionRequestId
|
|
5251
|
+
} : l, a = e.withPageEntity === !1 && s && "entity" in s ? Ia(s, "entity") : s;
|
|
5087
5252
|
return {
|
|
5088
|
-
clientContext: e.
|
|
5253
|
+
clientContext: e.background ? { ...a, opencx__background: !0 } : a,
|
|
5089
5254
|
custom_data: {
|
|
5090
5255
|
...n.messageCustomData || {},
|
|
5091
5256
|
...e.customData || {}
|
|
5092
5257
|
}
|
|
5093
5258
|
};
|
|
5094
|
-
},
|
|
5259
|
+
}, Ta = ({ type: n, id: e, title: t, meta: o }) => ({
|
|
5095
5260
|
type: n,
|
|
5096
5261
|
id: e,
|
|
5097
|
-
title:
|
|
5098
|
-
...
|
|
5099
|
-
}),
|
|
5100
|
-
const { [e]:
|
|
5101
|
-
return Object.keys(
|
|
5102
|
-
},
|
|
5262
|
+
title: t,
|
|
5263
|
+
...o ? { meta: o } : {}
|
|
5264
|
+
}), Ia = (n, e) => {
|
|
5265
|
+
const { [e]: t, ...o } = n;
|
|
5266
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
5267
|
+
}, Ma = (n) => {
|
|
5103
5268
|
if (typeof n.context != "function") return n.context;
|
|
5104
5269
|
try {
|
|
5105
5270
|
return n.context();
|
|
5106
5271
|
} catch (e) {
|
|
5107
|
-
|
|
5272
|
+
k.error("context getter threw; sending without context", e);
|
|
5108
5273
|
return;
|
|
5109
5274
|
}
|
|
5110
|
-
},
|
|
5275
|
+
}, Da = (n) => {
|
|
5111
5276
|
const e = n.features;
|
|
5112
5277
|
if (!e) return;
|
|
5113
|
-
const
|
|
5114
|
-
return e.preamble !== void 0 && (
|
|
5115
|
-
},
|
|
5278
|
+
const t = {};
|
|
5279
|
+
return e.preamble !== void 0 && (t.preamble = e.preamble), e.inlineUi !== void 0 && (t.inline_ui = e.inlineUi), e.pageContext !== void 0 && (t.page_context = e.pageContext), e.clientTools !== void 0 && (t.client_tools = e.clientTools), Object.keys(t).length > 0 ? t : void 0;
|
|
5280
|
+
}, Na = ({
|
|
5116
5281
|
config: n,
|
|
5117
5282
|
input: e,
|
|
5118
|
-
uuid:
|
|
5119
|
-
sessionId:
|
|
5120
|
-
content:
|
|
5121
|
-
initialMessages:
|
|
5122
|
-
sendsPageContext:
|
|
5283
|
+
uuid: t,
|
|
5284
|
+
sessionId: o,
|
|
5285
|
+
content: r,
|
|
5286
|
+
initialMessages: l,
|
|
5287
|
+
sendsPageContext: s
|
|
5123
5288
|
}) => {
|
|
5124
|
-
var
|
|
5289
|
+
var a, i, c, d, _, p, u, m;
|
|
5125
5290
|
return {
|
|
5126
|
-
uuid:
|
|
5291
|
+
uuid: t,
|
|
5127
5292
|
bot_token: n.token,
|
|
5128
5293
|
headers: n.headers,
|
|
5129
5294
|
query_params: n.queryParams,
|
|
5130
5295
|
body_properties: n.bodyProperties,
|
|
5131
|
-
session_id:
|
|
5132
|
-
content:
|
|
5296
|
+
session_id: o,
|
|
5297
|
+
content: r,
|
|
5133
5298
|
attachments: e.attachments,
|
|
5134
|
-
...
|
|
5299
|
+
...Pa(n, e, { sendsPageContext: s }),
|
|
5135
5300
|
language: n.language,
|
|
5136
|
-
features:
|
|
5301
|
+
features: Da(n),
|
|
5137
5302
|
presentation: n.presentation,
|
|
5138
5303
|
capabilities: [
|
|
5139
|
-
(
|
|
5140
|
-
(
|
|
5141
|
-
(c = n.capabilities) == null ? void 0 : c.
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5304
|
+
(a = n.capabilities) == null ? void 0 : a.connections,
|
|
5305
|
+
(i = n.capabilities) == null ? void 0 : i.structuredQuestions,
|
|
5306
|
+
(c = n.capabilities) == null ? void 0 : c.richReplies,
|
|
5307
|
+
(d = n.capabilities) == null ? void 0 : d.pageEffects
|
|
5308
|
+
].some((g) => g !== void 0) ? {
|
|
5309
|
+
connections: (_ = n.capabilities) == null ? void 0 : _.connections,
|
|
5310
|
+
structured_questions: (p = n.capabilities) == null ? void 0 : p.structuredQuestions,
|
|
5311
|
+
rich_replies: (u = n.capabilities) == null ? void 0 : u.richReplies,
|
|
5312
|
+
page_effects: (m = n.capabilities) == null ? void 0 : m.pageEffects
|
|
5146
5313
|
} : void 0,
|
|
5147
5314
|
exit_mode_prompt: e.exitModePrompt,
|
|
5148
|
-
initial_messages:
|
|
5315
|
+
initial_messages: l.length > 0 ? l.map((g) => ({ uuid: g.id, content: g.data.message })) : void 0
|
|
5149
5316
|
};
|
|
5150
|
-
},
|
|
5317
|
+
}, C = class C {
|
|
5151
5318
|
constructor({
|
|
5152
5319
|
config: e,
|
|
5153
|
-
api:
|
|
5154
|
-
sessionCtx:
|
|
5155
|
-
contactCtx:
|
|
5156
|
-
streaming:
|
|
5157
|
-
sendsPageContext:
|
|
5158
|
-
getClientCapabilities:
|
|
5159
|
-
getRequestConfig:
|
|
5320
|
+
api: t,
|
|
5321
|
+
sessionCtx: o,
|
|
5322
|
+
contactCtx: r,
|
|
5323
|
+
streaming: l,
|
|
5324
|
+
sendsPageContext: s,
|
|
5325
|
+
getClientCapabilities: a,
|
|
5326
|
+
getRequestConfig: i,
|
|
5160
5327
|
isStreaming: c,
|
|
5161
5328
|
getSendsPageContext: d
|
|
5162
5329
|
}) {
|
|
5163
|
-
this.state = new
|
|
5330
|
+
this.state = new S({
|
|
5164
5331
|
messages: [],
|
|
5165
5332
|
isSendingMessage: !1,
|
|
5166
5333
|
isSendingMessageToAI: !1,
|
|
5167
5334
|
settledAgentUserMessageId: null,
|
|
5168
5335
|
lastAIResMightSolveUserIssue: !1,
|
|
5169
5336
|
isInitialFetchLoading: !1
|
|
5170
|
-
}), this.draftState = new
|
|
5337
|
+
}), this.draftState = new S({
|
|
5171
5338
|
text: "",
|
|
5172
5339
|
mentions: []
|
|
5173
5340
|
}), this.agentHandlers = null, this.bufferedAgentSends = [], this.sendMessageAbortController = new AbortController(), this.messageIdsDispatchedToOnMessageReceivedHook = /* @__PURE__ */ new Set(), this.sentTextHistory = [], this.reset = () => {
|
|
5174
5341
|
this.sendMessageAbortController.abort("Resetting chat"), this.bufferedAgentSends = [], this.state.reset(), this.messageIdsDispatchedToOnMessageReceivedHook.clear(), this.sentTextHistory = [], this.draftState.reset();
|
|
5175
|
-
}, this.rememberSentText = (
|
|
5176
|
-
const p =
|
|
5177
|
-
!p || this.sentTextHistory.at(-1) === p || (this.sentTextHistory.push(p), this.sentTextHistory.length >
|
|
5178
|
-
}, this.getSentTextHistory = () => this.sentTextHistory, this.registerAgentHandlers = (
|
|
5179
|
-
this.agentHandlers =
|
|
5342
|
+
}, this.rememberSentText = (_) => {
|
|
5343
|
+
const p = _.trim();
|
|
5344
|
+
!p || this.sentTextHistory.at(-1) === p || (this.sentTextHistory.push(p), this.sentTextHistory.length > C.SENT_TEXT_HISTORY_MAX && this.sentTextHistory.shift());
|
|
5345
|
+
}, this.getSentTextHistory = () => this.sentTextHistory, this.registerAgentHandlers = (_) => {
|
|
5346
|
+
this.agentHandlers = _;
|
|
5180
5347
|
const p = this.bufferedAgentSends;
|
|
5181
5348
|
this.bufferedAgentSends = [], p.forEach((u) => {
|
|
5182
|
-
|
|
5349
|
+
C.dispatchToEngine(_, u);
|
|
5183
5350
|
});
|
|
5184
|
-
}, this.unregisterAgentHandlers = (
|
|
5185
|
-
this.agentHandlers ===
|
|
5186
|
-
}, this.dispatchToOnMessageReceivedHook = (
|
|
5351
|
+
}, this.unregisterAgentHandlers = (_) => {
|
|
5352
|
+
this.agentHandlers === _ && (this.agentHandlers = null);
|
|
5353
|
+
}, this.dispatchToOnMessageReceivedHook = (_) => {
|
|
5187
5354
|
var u, m;
|
|
5188
|
-
if (
|
|
5355
|
+
if (_.type === "USER" || this.messageIdsDispatchedToOnMessageReceivedHook.has(_.id))
|
|
5189
5356
|
return;
|
|
5190
5357
|
const p = this.sessionCtx.sessionState.get().session;
|
|
5191
|
-
p && (this.messageIdsDispatchedToOnMessageReceivedHook.add(
|
|
5192
|
-
}, this.markAsDispatchedToOnMessageReceivedHook = (
|
|
5193
|
-
|
|
5358
|
+
p && (this.messageIdsDispatchedToOnMessageReceivedHook.add(_.id), (m = (u = this.config.hooks) == null ? void 0 : u.onMessageReceived) == null || m.call(u, { message: _, session: p }));
|
|
5359
|
+
}, this.markAsDispatchedToOnMessageReceivedHook = (_) => {
|
|
5360
|
+
_.forEach(
|
|
5194
5361
|
(p) => this.messageIdsDispatchedToOnMessageReceivedHook.add(p)
|
|
5195
5362
|
);
|
|
5196
5363
|
}, this.buildPersistentInitialMessages = () => {
|
|
@@ -5206,60 +5373,68 @@ const za = (n, e, { sendsPageContext: a }) => {
|
|
|
5206
5373
|
})
|
|
5207
5374
|
) : [];
|
|
5208
5375
|
}, this.ensureSessionId = async () => {
|
|
5209
|
-
var
|
|
5210
|
-
if (!((
|
|
5376
|
+
var _, p;
|
|
5377
|
+
if (!((_ = this.sessionCtx.sessionState.get().session) != null && _.id)) {
|
|
5211
5378
|
if (!await this.sessionCtx.createSession()) return null;
|
|
5212
5379
|
this.sessionCtx.refreshSessions();
|
|
5213
5380
|
}
|
|
5214
5381
|
return ((p = this.sessionCtx.sessionState.get().session) == null ? void 0 : p.id) ?? null;
|
|
5215
|
-
}, this.rollbackOptimisticMessages = (
|
|
5216
|
-
if (
|
|
5217
|
-
const p = new Set(
|
|
5382
|
+
}, this.rollbackOptimisticMessages = (_) => {
|
|
5383
|
+
if (_.length === 0) return;
|
|
5384
|
+
const p = new Set(_), u = this.state.get().messages, m = u.filter((g) => !p.has(g.id));
|
|
5218
5385
|
m.length !== u.length && this.state.setPartial({ messages: m });
|
|
5219
|
-
}, this.notifySendAccepted = (
|
|
5386
|
+
}, this.notifySendAccepted = (_) => {
|
|
5220
5387
|
var p;
|
|
5221
5388
|
try {
|
|
5222
|
-
(p =
|
|
5389
|
+
(p = _.onAccepted) == null || p.call(_);
|
|
5223
5390
|
} catch (u) {
|
|
5224
|
-
|
|
5391
|
+
k.error("send acceptance callback failed", u);
|
|
5225
5392
|
}
|
|
5226
|
-
}, this.stageUserTurn = async (
|
|
5227
|
-
const u = this.buildUserMessage(
|
|
5393
|
+
}, this.stageUserTurn = async (_, { pending: p }) => {
|
|
5394
|
+
const u = this.buildUserMessage(_);
|
|
5228
5395
|
if (!u) return null;
|
|
5229
|
-
const m = p ? { ...u, pending: !0 } : u, g = this.buildPersistentInitialMessages(),
|
|
5230
|
-
...g.map((
|
|
5396
|
+
const m = p ? { ...u, pending: !0 } : u, g = this.buildPersistentInitialMessages(), v = [
|
|
5397
|
+
...g.map((b) => b.id),
|
|
5231
5398
|
m.id
|
|
5232
5399
|
];
|
|
5233
5400
|
this.state.setPartial({
|
|
5234
|
-
messages: [
|
|
5401
|
+
messages: [
|
|
5402
|
+
...g,
|
|
5403
|
+
...this.state.get().messages,
|
|
5404
|
+
...m.background ? [] : [m]
|
|
5405
|
+
]
|
|
5235
5406
|
});
|
|
5236
|
-
let
|
|
5407
|
+
let f;
|
|
5237
5408
|
try {
|
|
5238
|
-
|
|
5239
|
-
} catch (
|
|
5240
|
-
throw this.rollbackOptimisticMessages(
|
|
5409
|
+
f = await this.ensureSessionId();
|
|
5410
|
+
} catch (b) {
|
|
5411
|
+
throw this.rollbackOptimisticMessages(v), b;
|
|
5241
5412
|
}
|
|
5242
|
-
return
|
|
5243
|
-
}, this.buildQueuedUserMessage = (
|
|
5413
|
+
return f ? { sessionId: f, userMessage: m, initialMessages: g } : (this.rollbackOptimisticMessages(v), null);
|
|
5414
|
+
}, this.buildQueuedUserMessage = (_) => {
|
|
5244
5415
|
var m;
|
|
5245
|
-
const p = this.buildUserMessage(
|
|
5416
|
+
const p = this.buildUserMessage(_);
|
|
5246
5417
|
if (!p) return null;
|
|
5247
5418
|
const u = (m = this.sessionCtx.sessionState.get().session) == null ? void 0 : m.id;
|
|
5248
5419
|
return u ? { sessionId: u, userMessage: { ...p, pending: !0 } } : null;
|
|
5249
|
-
}, this.buildUserMessage = (
|
|
5420
|
+
}, this.buildUserMessage = (_) => {
|
|
5250
5421
|
var p;
|
|
5251
|
-
return !
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5422
|
+
return !_.content.trim() && (!_.attachments || _.attachments.length === 0) ? (k.warn("cannot send an empty message of no content or attachments"), null) : {
|
|
5423
|
+
...this.toUserMessage(
|
|
5424
|
+
_.content.trim(),
|
|
5425
|
+
_.attachments || void 0,
|
|
5426
|
+
this.sendsPageContext ? C.markedElementNames(_.clientContext) : void 0,
|
|
5427
|
+
this.sendsPageContext && ((p = _.mentions) != null && p.length) ? _.mentions : void 0
|
|
5428
|
+
),
|
|
5429
|
+
..._.background ? { background: !0 } : {}
|
|
5430
|
+
};
|
|
5431
|
+
}, this.appendUserMessageIfAbsent = (_) => {
|
|
5432
|
+
if (_.background) return;
|
|
5258
5433
|
const p = this.state.get().messages;
|
|
5259
|
-
p.some((u) => u.id ===
|
|
5260
|
-
}, this.markUserMessageDelivered = (
|
|
5434
|
+
p.some((u) => u.id === _.id) || this.state.setPartial({ messages: [...p, _] });
|
|
5435
|
+
}, this.markUserMessageDelivered = (_) => {
|
|
5261
5436
|
const p = this.state.get().messages, u = p.findIndex(
|
|
5262
|
-
(
|
|
5437
|
+
(v) => v.id === _ && v.type === "USER" && v.pending
|
|
5263
5438
|
);
|
|
5264
5439
|
if (u === -1) return;
|
|
5265
5440
|
const m = p[u];
|
|
@@ -5268,89 +5443,89 @@ const za = (n, e, { sendsPageContext: a }) => {
|
|
|
5268
5443
|
g[u] = { ...m, pending: !1 }, this.state.setPartial({
|
|
5269
5444
|
messages: g
|
|
5270
5445
|
});
|
|
5271
|
-
}, this.sendMessage = async (
|
|
5272
|
-
var u, m, g,
|
|
5446
|
+
}, this.sendMessage = async (_) => {
|
|
5447
|
+
var u, m, g, v, f;
|
|
5273
5448
|
if (this.streaming) {
|
|
5274
5449
|
if (!this.agentHandlers) {
|
|
5275
|
-
this.bufferedAgentSends.push(
|
|
5450
|
+
this.bufferedAgentSends.push(_);
|
|
5276
5451
|
return;
|
|
5277
5452
|
}
|
|
5278
|
-
await this.agentHandlers.send(
|
|
5453
|
+
await this.agentHandlers.send(_);
|
|
5279
5454
|
return;
|
|
5280
5455
|
}
|
|
5281
5456
|
let p;
|
|
5282
5457
|
try {
|
|
5283
|
-
const
|
|
5284
|
-
if (this.blocksSendWhileAwaitingReply && (
|
|
5285
|
-
|
|
5286
|
-
|
|
5458
|
+
const b = this.sessionCtx.sessionState.get().session, R = (b == null ? void 0 : b.assignee.kind) === "ai", X = this.state.get().isSendingMessageToAI, E = this.state.get().messages.at(-1);
|
|
5459
|
+
if (this.blocksSendWhileAwaitingReply && (X || // If last message is from user, then bot response did not arrive yet
|
|
5460
|
+
R && (E == null ? void 0 : E.type) === "USER" && E.id !== this.state.get().settledAgentUserMessageId)) {
|
|
5461
|
+
k.warn("cannot send messages while awaiting AI response");
|
|
5287
5462
|
return;
|
|
5288
5463
|
}
|
|
5289
5464
|
this.sendMessageAbortController.abort("Superseded by a newer message"), this.sendMessageAbortController = new AbortController(), p = this.sendMessageAbortController, this.state.setPartial({
|
|
5290
5465
|
lastAIResMightSolveUserIssue: !1,
|
|
5291
5466
|
isSendingMessage: !0,
|
|
5292
|
-
isSendingMessageToAI: !!
|
|
5467
|
+
isSendingMessageToAI: !!R || !b
|
|
5293
5468
|
});
|
|
5294
|
-
const
|
|
5295
|
-
if (!
|
|
5296
|
-
const { sessionId:
|
|
5297
|
-
this.notifySendAccepted(
|
|
5298
|
-
const { data:
|
|
5299
|
-
|
|
5469
|
+
const K = await this.stageUserTurn(_, { pending: !1 });
|
|
5470
|
+
if (!K) return;
|
|
5471
|
+
const { sessionId: ee, userMessage: L, initialMessages: ae } = K;
|
|
5472
|
+
this.notifySendAccepted(_);
|
|
5473
|
+
const { data: y } = await this.api.sendMessage(
|
|
5474
|
+
Na({
|
|
5300
5475
|
config: {
|
|
5301
5476
|
...this.getRequestConfig(),
|
|
5302
5477
|
capabilities: this.getClientCapabilities()
|
|
5303
5478
|
},
|
|
5304
|
-
input:
|
|
5305
|
-
uuid:
|
|
5306
|
-
sessionId:
|
|
5307
|
-
content:
|
|
5308
|
-
initialMessages:
|
|
5479
|
+
input: _,
|
|
5480
|
+
uuid: L.id,
|
|
5481
|
+
sessionId: ee,
|
|
5482
|
+
content: L.content,
|
|
5483
|
+
initialMessages: ae,
|
|
5309
5484
|
sendsPageContext: this.sendsPageContext
|
|
5310
5485
|
}),
|
|
5311
5486
|
p.signal
|
|
5312
5487
|
);
|
|
5313
|
-
if (
|
|
5314
|
-
const z = this.toBotMessage(
|
|
5488
|
+
if (y != null && y.success) {
|
|
5489
|
+
const z = this.toBotMessage(y);
|
|
5315
5490
|
if (z) {
|
|
5316
5491
|
const A = this.state.get().messages;
|
|
5317
5492
|
if (!!A.some(
|
|
5318
|
-
(
|
|
5493
|
+
(te) => te.id === z.id
|
|
5319
5494
|
)) {
|
|
5320
5495
|
this.state.setPartial({
|
|
5321
|
-
lastAIResMightSolveUserIssue: ((u =
|
|
5496
|
+
lastAIResMightSolveUserIssue: ((u = y.autopilotResponse) == null ? void 0 : u.mightSolveUserIssue) || ((m = y.uiResponse) == null ? void 0 : m.mightSolveUserIssue)
|
|
5322
5497
|
});
|
|
5323
5498
|
return;
|
|
5324
5499
|
}
|
|
5325
5500
|
this.state.setPartial({
|
|
5326
5501
|
messages: [...A, z],
|
|
5327
|
-
lastAIResMightSolveUserIssue: ((g =
|
|
5502
|
+
lastAIResMightSolveUserIssue: ((g = y.autopilotResponse) == null ? void 0 : g.mightSolveUserIssue) || ((v = y.uiResponse) == null ? void 0 : v.mightSolveUserIssue)
|
|
5328
5503
|
}), this.dispatchToOnMessageReceivedHook(z);
|
|
5329
5504
|
}
|
|
5330
|
-
|
|
5505
|
+
y.session && this.sessionCtx.sessionState.setPartial({ session: y.session });
|
|
5331
5506
|
} else {
|
|
5332
5507
|
const z = this.toBotErrorMessage(
|
|
5333
|
-
((
|
|
5508
|
+
((f = y == null ? void 0 : y.error) == null ? void 0 : f.message) || Ea(this.config, "turn_failed_message")
|
|
5334
5509
|
), A = this.state.get().messages;
|
|
5335
5510
|
this.state.setPartial({
|
|
5336
5511
|
messages: [...A, z]
|
|
5337
5512
|
});
|
|
5338
5513
|
}
|
|
5339
|
-
} catch (
|
|
5340
|
-
p != null && p.signal.aborted ||
|
|
5514
|
+
} catch (b) {
|
|
5515
|
+
p != null && p.signal.aborted || k.error("failed to send message", b);
|
|
5341
5516
|
} finally {
|
|
5342
5517
|
p != null && p.signal.aborted || this.state.setPartial({
|
|
5343
5518
|
isSendingMessage: !1,
|
|
5344
5519
|
isSendingMessageToAI: !1
|
|
5345
5520
|
});
|
|
5346
5521
|
}
|
|
5347
|
-
}, this.toUserMessage = (
|
|
5522
|
+
}, this.toUserMessage = (_, p, u, m) => {
|
|
5348
5523
|
const g = (() => {
|
|
5349
|
-
const
|
|
5350
|
-
return this.state.get().messages.length === 0 &&
|
|
5524
|
+
const v = this.contactCtx.state.get().extraCollectedData;
|
|
5525
|
+
return this.state.get().messages.length === 0 && v && Object.keys(v).length > 0 ? `${Object.entries(v).filter(([b, w]) => !!w).map(([b, w]) => `${b}: ${w}`).join(`
|
|
5351
5526
|
`)}
|
|
5352
5527
|
|
|
5353
|
-
${
|
|
5528
|
+
${_}` : _;
|
|
5354
5529
|
})();
|
|
5355
5530
|
return {
|
|
5356
5531
|
id: x(),
|
|
@@ -5361,11 +5536,11 @@ ${l}` : l;
|
|
|
5361
5536
|
mentions: m,
|
|
5362
5537
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
5363
5538
|
};
|
|
5364
|
-
}, this.toBotMessage = (
|
|
5539
|
+
}, this.toBotMessage = (_) => {
|
|
5365
5540
|
var p;
|
|
5366
|
-
return
|
|
5541
|
+
return _.success && _.autopilotResponse ? {
|
|
5367
5542
|
type: "AI",
|
|
5368
|
-
id:
|
|
5543
|
+
id: _.autopilotResponse.id || x(),
|
|
5369
5544
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5370
5545
|
component: "bot_message",
|
|
5371
5546
|
agent: this.config.bot ? {
|
|
@@ -5377,24 +5552,24 @@ ${l}` : l;
|
|
|
5377
5552
|
id: null
|
|
5378
5553
|
} : void 0,
|
|
5379
5554
|
data: {
|
|
5380
|
-
message:
|
|
5381
|
-
action: (p =
|
|
5382
|
-
name:
|
|
5383
|
-
data:
|
|
5555
|
+
message: _.autopilotResponse.value.content,
|
|
5556
|
+
action: (p = _.uiResponse) != null && p.value.name ? {
|
|
5557
|
+
name: _.uiResponse.value.name,
|
|
5558
|
+
data: _.uiResponse.value.request_response
|
|
5384
5559
|
} : void 0
|
|
5385
5560
|
}
|
|
5386
5561
|
} : null;
|
|
5387
|
-
}, this.toBotErrorMessage = (
|
|
5562
|
+
}, this.toBotErrorMessage = (_) => ({
|
|
5388
5563
|
type: "AI",
|
|
5389
5564
|
id: x(),
|
|
5390
5565
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5391
5566
|
component: "bot_message",
|
|
5392
5567
|
data: {
|
|
5393
|
-
message:
|
|
5568
|
+
message: _,
|
|
5394
5569
|
variant: "error",
|
|
5395
5570
|
action: void 0
|
|
5396
5571
|
}
|
|
5397
|
-
}), this.config = e, this.getClientCapabilities =
|
|
5572
|
+
}), this.config = e, this.getClientCapabilities = a ?? (() => this.getRequestConfig().capabilities), this.api = t, this.sessionCtx = o, this.contactCtx = r, this.isStreaming = c ?? (() => l), this.getRequestConfig = i ?? (() => this.config), this.getSendsPageContext = d ?? (() => s);
|
|
5398
5573
|
}
|
|
5399
5574
|
/**
|
|
5400
5575
|
* Current transport choice. The org or this embed may request polling
|
|
@@ -5407,18 +5582,18 @@ ${l}` : l;
|
|
|
5407
5582
|
return this.getSendsPageContext();
|
|
5408
5583
|
}
|
|
5409
5584
|
/** Hand a send to the streaming engine; its failure can never propagate. */
|
|
5410
|
-
static dispatchToEngine(e,
|
|
5585
|
+
static dispatchToEngine(e, t) {
|
|
5411
5586
|
try {
|
|
5412
|
-
Promise.resolve(e.send(
|
|
5413
|
-
|
|
5587
|
+
Promise.resolve(e.send(t)).catch((o) => {
|
|
5588
|
+
k.error("streaming send failed", o);
|
|
5414
5589
|
});
|
|
5415
|
-
} catch (
|
|
5416
|
-
|
|
5590
|
+
} catch (o) {
|
|
5591
|
+
k.error("streaming send failed", o);
|
|
5417
5592
|
}
|
|
5418
5593
|
}
|
|
5419
5594
|
get hasPendingAgentWork() {
|
|
5420
|
-
var e,
|
|
5421
|
-
return this.bufferedAgentSends.length > 0 || (((
|
|
5595
|
+
var e, t;
|
|
5596
|
+
return this.bufferedAgentSends.length > 0 || (((t = (e = this.agentHandlers) == null ? void 0 : e.hasPendingWork) == null ? void 0 : t.call(e)) ?? !1);
|
|
5422
5597
|
}
|
|
5423
5598
|
/**
|
|
5424
5599
|
* Defensive read of `clientContext.page_marks` → the user bubble's context
|
|
@@ -5428,23 +5603,23 @@ ${l}` : l;
|
|
|
5428
5603
|
* without a usable name are dropped.
|
|
5429
5604
|
*/
|
|
5430
5605
|
static markedElementNames(e) {
|
|
5431
|
-
const
|
|
5432
|
-
if (!Array.isArray(
|
|
5433
|
-
const
|
|
5434
|
-
if (typeof
|
|
5435
|
-
const
|
|
5436
|
-
if (typeof
|
|
5437
|
-
const
|
|
5606
|
+
const t = e == null ? void 0 : e.page_marks;
|
|
5607
|
+
if (!Array.isArray(t)) return;
|
|
5608
|
+
const o = t.flatMap((r) => {
|
|
5609
|
+
if (typeof r != "object" || r === null) return [];
|
|
5610
|
+
const l = r.elements, s = Array.isArray(l) ? l[0] : void 0, a = typeof s == "object" && s !== null && "name" in s ? s.name : void 0;
|
|
5611
|
+
if (typeof a != "string" || a.length === 0) return [];
|
|
5612
|
+
const i = r.note, c = r.snapshotUrl;
|
|
5438
5613
|
return [
|
|
5439
5614
|
{
|
|
5440
|
-
name:
|
|
5441
|
-
...typeof
|
|
5615
|
+
name: a,
|
|
5616
|
+
...typeof i == "string" && i.length > 0 ? { note: i } : {},
|
|
5442
5617
|
...typeof c == "string" && c.length > 0 ? { snapshotUrl: c } : {},
|
|
5443
|
-
mark:
|
|
5618
|
+
mark: r
|
|
5444
5619
|
}
|
|
5445
5620
|
];
|
|
5446
5621
|
});
|
|
5447
|
-
return
|
|
5622
|
+
return o.length > 0 ? o : void 0;
|
|
5448
5623
|
}
|
|
5449
5624
|
/**
|
|
5450
5625
|
* The blocking engine refuses a send while the AI reply is pending unless
|
|
@@ -5454,124 +5629,124 @@ ${l}` : l;
|
|
|
5454
5629
|
return !this.streaming && this.config.disableSendingWhenAwaitingAIReply !== !1;
|
|
5455
5630
|
}
|
|
5456
5631
|
};
|
|
5457
|
-
|
|
5458
|
-
let
|
|
5459
|
-
class
|
|
5632
|
+
C.SENT_TEXT_HISTORY_MAX = 50;
|
|
5633
|
+
let D = C;
|
|
5634
|
+
class Ra {
|
|
5460
5635
|
constructor(e) {
|
|
5461
|
-
var
|
|
5636
|
+
var t, o;
|
|
5462
5637
|
this.widget = e, this.subscriptions = [], this.disposed = !1, this.restorableSessionId = null, this.didReadStoredSession = !1, this.readStoredSession = () => {
|
|
5463
5638
|
if (!this.shouldRestoreLastSession) {
|
|
5464
5639
|
this.didReadStoredSession = !0;
|
|
5465
5640
|
return;
|
|
5466
5641
|
}
|
|
5467
|
-
this.sessionCtx.getLastActiveSessionId().then((
|
|
5468
|
-
this.restorableSessionId =
|
|
5642
|
+
this.sessionCtx.getLastActiveSessionId().then((r) => {
|
|
5643
|
+
this.restorableSessionId = r;
|
|
5469
5644
|
}).finally(() => {
|
|
5470
5645
|
this.didReadStoredSession = !0, this.routeFromSessions(this.sessionCtx.sessionsState.get());
|
|
5471
5646
|
});
|
|
5472
5647
|
}, this.registerRoutingListener = () => {
|
|
5473
5648
|
this.subscriptions.push(
|
|
5474
|
-
this.contactCtx.state.subscribe(({ contact:
|
|
5475
|
-
var
|
|
5476
|
-
|
|
5477
|
-
screen: (
|
|
5649
|
+
this.contactCtx.state.subscribe(({ contact: r }) => {
|
|
5650
|
+
var l;
|
|
5651
|
+
r != null && r.token && this.state.get().screen === "welcome" && this.state.setPartial({
|
|
5652
|
+
screen: (l = this.config.router) != null && l.chatScreenOnly ? "chat" : "sessions"
|
|
5478
5653
|
});
|
|
5479
5654
|
})
|
|
5480
5655
|
), this.subscriptions.push(
|
|
5481
5656
|
this.sessionCtx.sessionsState.subscribe(this.routeFromSessions)
|
|
5482
5657
|
);
|
|
5483
5658
|
}, this.routeFromSessions = ({
|
|
5484
|
-
isInitialFetchLoading:
|
|
5485
|
-
data:
|
|
5659
|
+
isInitialFetchLoading: r,
|
|
5660
|
+
data: l
|
|
5486
5661
|
}) => {
|
|
5487
|
-
var
|
|
5662
|
+
var s, a, i, c, d;
|
|
5488
5663
|
if (!(this.disposed || !this.didReadStoredSession)) {
|
|
5489
|
-
if (this.restorableSessionId && !((
|
|
5490
|
-
const
|
|
5664
|
+
if (this.restorableSessionId && !((s = this.sessionCtx.sessionState.get().session) != null && s.id)) {
|
|
5665
|
+
const _ = l.find(
|
|
5491
5666
|
(p) => p.id === this.restorableSessionId && p.isOpened
|
|
5492
5667
|
);
|
|
5493
|
-
if (
|
|
5494
|
-
this.restorableSessionId = null, this.toChatScreen(
|
|
5668
|
+
if (_) {
|
|
5669
|
+
this.restorableSessionId = null, this.toChatScreen(_.id);
|
|
5495
5670
|
return;
|
|
5496
5671
|
}
|
|
5497
|
-
if (
|
|
5672
|
+
if (r) return;
|
|
5498
5673
|
this.restorableSessionId = null;
|
|
5499
5674
|
}
|
|
5500
|
-
if ((
|
|
5675
|
+
if ((a = this.config.router) != null && a.chatScreenOnly && // Do not route to a chat if we are currently inside one already
|
|
5501
5676
|
// This also applies to newly created sessions; the new session will be in `sessionState` before it is refreshed and included in `sessionsState`
|
|
5502
|
-
!((
|
|
5503
|
-
const
|
|
5504
|
-
return
|
|
5677
|
+
!((i = this.sessionCtx.sessionState.get().session) != null && i.id)) {
|
|
5678
|
+
const _ = (c = l.find((p) => p.isOpened)) == null ? void 0 : c.id;
|
|
5679
|
+
return _ ? this.toChatScreen(_) : void 0;
|
|
5505
5680
|
}
|
|
5506
|
-
|
|
5681
|
+
l.length || ((d = this.config.router) == null ? void 0 : d.goToChatIfNoSessions) !== !1 && !r && this.state.get().screen !== "chat" && this.toChatScreen();
|
|
5507
5682
|
}
|
|
5508
5683
|
}, this.dispose = () => {
|
|
5509
|
-
this.disposed = !0, this.subscriptions.forEach((
|
|
5684
|
+
this.disposed = !0, this.subscriptions.forEach((r) => r()), this.subscriptions = [], this.navigateConversation = void 0;
|
|
5510
5685
|
}, this.toSessionsScreen = () => {
|
|
5511
5686
|
this.navigateConversation || this.resetChat(), this.state.setPartial({ screen: "sessions" });
|
|
5512
|
-
}, this.toChatScreen = (
|
|
5513
|
-
var
|
|
5514
|
-
if (this.navigateConversation) return this.navigateConversation(
|
|
5687
|
+
}, this.toChatScreen = (r) => {
|
|
5688
|
+
var s, a;
|
|
5689
|
+
if (this.navigateConversation) return this.navigateConversation(r);
|
|
5515
5690
|
this.resetChat();
|
|
5516
|
-
let
|
|
5517
|
-
if (
|
|
5518
|
-
if (
|
|
5519
|
-
this.sessionCtx.sessionState.setPartial({ session:
|
|
5691
|
+
let l;
|
|
5692
|
+
if (r) {
|
|
5693
|
+
if (l = this.sessionCtx.sessionsState.get().data.find((i) => i.id === r), !l) return;
|
|
5694
|
+
this.sessionCtx.sessionState.setPartial({ session: l });
|
|
5520
5695
|
}
|
|
5521
|
-
return this.state.setPartial({ screen: "chat" }), (
|
|
5522
|
-
}, this.config = e.config, this.contactCtx = e.contactCtx, this.sessionCtx = e.sessionCtx, this.resetChat = e.resetChat, this.state = new
|
|
5523
|
-
screen: this.contactCtx.shouldCollectData() ? "welcome" : (
|
|
5524
|
-
}), this.shouldRestoreLastSession = ((
|
|
5696
|
+
return this.state.setPartial({ screen: "chat" }), (a = (s = this.config.hooks) == null ? void 0 : s.onNavigateToChat) == null || a.call(s, { session: l }), this.widget;
|
|
5697
|
+
}, this.config = e.config, this.contactCtx = e.contactCtx, this.sessionCtx = e.sessionCtx, this.resetChat = e.resetChat, this.state = new S({
|
|
5698
|
+
screen: this.contactCtx.shouldCollectData() ? "welcome" : (t = this.config.router) != null && t.chatScreenOnly ? "chat" : "sessions"
|
|
5699
|
+
}), this.shouldRestoreLastSession = ((o = this.config.router) == null ? void 0 : o.restoreLastSession) ?? !1, this.readStoredSession(), this.registerRoutingListener();
|
|
5525
5700
|
}
|
|
5526
5701
|
}
|
|
5527
|
-
class
|
|
5702
|
+
class Ka {
|
|
5528
5703
|
constructor({
|
|
5529
5704
|
storage: e,
|
|
5530
|
-
config:
|
|
5705
|
+
config: t
|
|
5531
5706
|
}) {
|
|
5532
5707
|
this.KEYS = {
|
|
5533
|
-
contactToken: (
|
|
5534
|
-
externalContactId: (
|
|
5535
|
-
companionPreference: (
|
|
5536
|
-
activeSession: (
|
|
5537
|
-
}, this.setContactToken = async (
|
|
5538
|
-
await this.storage.set(this.KEYS.contactToken(this.config.token),
|
|
5708
|
+
contactToken: (o) => `opencx-widget:org-token-${o}:contact-token`,
|
|
5709
|
+
externalContactId: (o) => `opencx-widget:org-token-${o}:external-contact-id`,
|
|
5710
|
+
companionPreference: (o, r) => `opencx-widget:org-token-${o}:companion-${r}`,
|
|
5711
|
+
activeSession: (o) => `opencx-widget:org-token-${o}:active-session`
|
|
5712
|
+
}, this.setContactToken = async (o) => {
|
|
5713
|
+
await this.storage.set(this.KEYS.contactToken(this.config.token), o);
|
|
5539
5714
|
}, this.getContactToken = async () => this.storage.get(this.KEYS.contactToken(this.config.token)), this.clearContactToken = async () => {
|
|
5540
5715
|
await this.storage.remove(this.KEYS.contactToken(this.config.token));
|
|
5541
|
-
}, this.activeSessionKey = () => this.KEYS.activeSession(this.config.token), this.getActiveSessionId = async () => this.storage.get(this.activeSessionKey()), this.setActiveSessionId = async (
|
|
5542
|
-
await this.storage.set(this.activeSessionKey(),
|
|
5716
|
+
}, this.activeSessionKey = () => this.KEYS.activeSession(this.config.token), this.getActiveSessionId = async () => this.storage.get(this.activeSessionKey()), this.setActiveSessionId = async (o) => {
|
|
5717
|
+
await this.storage.set(this.activeSessionKey(), o);
|
|
5543
5718
|
}, this.clearActiveSessionId = async () => {
|
|
5544
5719
|
await this.storage.remove(this.activeSessionKey());
|
|
5545
|
-
}, this.setExternalContactId = async (
|
|
5546
|
-
await this.storage.set(this.KEYS.externalContactId(this.config.token),
|
|
5547
|
-
}, this.getExternalContactId = async () => this.storage.get(this.KEYS.externalContactId(this.config.token)), this.companionKey = (
|
|
5548
|
-
const
|
|
5549
|
-
if (
|
|
5550
|
-
const
|
|
5551
|
-
return Number.isFinite(
|
|
5552
|
-
}, this.getCompanionPillOffsetX = async () => this.getFiniteNumber(this.companionKey("pill-offset-x")), this.setCompanionPillOffsetX = async (
|
|
5553
|
-
Number.isFinite(
|
|
5554
|
-
}, this.getCompanionSidebarWidth = async () => this.getFiniteNumber(this.companionKey("sidebar-width")), this.setCompanionSidebarWidth = async (
|
|
5555
|
-
Number.isFinite(
|
|
5720
|
+
}, this.setExternalContactId = async (o) => {
|
|
5721
|
+
await this.storage.set(this.KEYS.externalContactId(this.config.token), o);
|
|
5722
|
+
}, this.getExternalContactId = async () => this.storage.get(this.KEYS.externalContactId(this.config.token)), this.companionKey = (o) => this.KEYS.companionPreference(this.config.token, o), this.getFiniteNumber = async (o) => {
|
|
5723
|
+
const r = await this.storage.get(o);
|
|
5724
|
+
if (r === null) return null;
|
|
5725
|
+
const l = Number(r);
|
|
5726
|
+
return Number.isFinite(l) ? l : null;
|
|
5727
|
+
}, this.getCompanionPillOffsetX = async () => this.getFiniteNumber(this.companionKey("pill-offset-x")), this.setCompanionPillOffsetX = async (o) => {
|
|
5728
|
+
Number.isFinite(o) && await this.storage.set(this.companionKey("pill-offset-x"), String(o));
|
|
5729
|
+
}, this.getCompanionSidebarWidth = async () => this.getFiniteNumber(this.companionKey("sidebar-width")), this.setCompanionSidebarWidth = async (o) => {
|
|
5730
|
+
Number.isFinite(o) && await this.storage.set(this.companionKey("sidebar-width"), String(o));
|
|
5556
5731
|
}, this.getCompanionSidebarSide = async () => {
|
|
5557
|
-
const
|
|
5558
|
-
return
|
|
5559
|
-
}, this.setCompanionSidebarSide = async (
|
|
5560
|
-
await this.storage.set(this.companionKey("sidebar-side"),
|
|
5732
|
+
const o = await this.storage.get(this.companionKey("sidebar-side"));
|
|
5733
|
+
return o === "left" || o === "right" ? o : null;
|
|
5734
|
+
}, this.setCompanionSidebarSide = async (o) => {
|
|
5735
|
+
await this.storage.set(this.companionKey("sidebar-side"), o);
|
|
5561
5736
|
}, this.getCompanionLayout = async () => {
|
|
5562
|
-
const
|
|
5563
|
-
return
|
|
5564
|
-
}, this.setCompanionLayout = async (
|
|
5565
|
-
await this.storage.set(this.companionKey("layout"),
|
|
5737
|
+
const o = await this.storage.get(this.companionKey("layout"));
|
|
5738
|
+
return o === "compact" || o === "sidebar" ? o : null;
|
|
5739
|
+
}, this.setCompanionLayout = async (o) => {
|
|
5740
|
+
await this.storage.set(this.companionKey("layout"), o);
|
|
5566
5741
|
}, this.getCompanionSidebarMode = async () => {
|
|
5567
|
-
const
|
|
5568
|
-
return
|
|
5569
|
-
}, this.setCompanionSidebarMode = async (
|
|
5570
|
-
await this.storage.set(this.companionKey("sidebar-mode"),
|
|
5571
|
-
}, this.storage = e, this.config =
|
|
5742
|
+
const o = await this.storage.get(this.companionKey("sidebar-mode"));
|
|
5743
|
+
return o === "docked" || o === "floating" ? o : null;
|
|
5744
|
+
}, this.setCompanionSidebarMode = async (o) => {
|
|
5745
|
+
await this.storage.set(this.companionKey("sidebar-mode"), o);
|
|
5746
|
+
}, this.storage = e, this.config = t;
|
|
5572
5747
|
}
|
|
5573
5748
|
}
|
|
5574
|
-
function
|
|
5749
|
+
function La({
|
|
5575
5750
|
org: n,
|
|
5576
5751
|
agent: e
|
|
5577
5752
|
}) {
|
|
@@ -5601,39 +5776,39 @@ function Ta({
|
|
|
5601
5776
|
function M(n, e) {
|
|
5602
5777
|
return n && e !== !1;
|
|
5603
5778
|
}
|
|
5604
|
-
function
|
|
5605
|
-
const
|
|
5779
|
+
function Fa(n, e) {
|
|
5780
|
+
const t = e.features;
|
|
5606
5781
|
return {
|
|
5607
|
-
dictation: M(n.features.dictation,
|
|
5782
|
+
dictation: M(n.features.dictation, t == null ? void 0 : t.dictation),
|
|
5608
5783
|
attachments: n.features.attachments,
|
|
5609
5784
|
pageContext: M(
|
|
5610
5785
|
n.features.pageContext,
|
|
5611
|
-
|
|
5786
|
+
t == null ? void 0 : t.pageContext
|
|
5612
5787
|
),
|
|
5613
5788
|
clientTools: M(
|
|
5614
5789
|
n.features.clientTools,
|
|
5615
|
-
|
|
5790
|
+
t == null ? void 0 : t.clientTools
|
|
5616
5791
|
)
|
|
5617
5792
|
};
|
|
5618
5793
|
}
|
|
5619
|
-
class
|
|
5620
|
-
constructor(e,
|
|
5621
|
-
super(
|
|
5794
|
+
class Oa extends Error {
|
|
5795
|
+
constructor(e, t, o) {
|
|
5796
|
+
super(t), this.name = "WidgetInitializationError", this.code = e, this.details = o;
|
|
5622
5797
|
}
|
|
5623
5798
|
}
|
|
5624
|
-
const
|
|
5799
|
+
const j = class j {
|
|
5625
5800
|
constructor({
|
|
5626
5801
|
config: e,
|
|
5627
|
-
storage:
|
|
5628
|
-
getClientCapabilities:
|
|
5629
|
-
getRequestConfig:
|
|
5630
|
-
modes:
|
|
5631
|
-
org:
|
|
5632
|
-
agent:
|
|
5633
|
-
parent:
|
|
5802
|
+
storage: t,
|
|
5803
|
+
getClientCapabilities: o,
|
|
5804
|
+
getRequestConfig: r,
|
|
5805
|
+
modes: l,
|
|
5806
|
+
org: s,
|
|
5807
|
+
agent: a,
|
|
5808
|
+
parent: i
|
|
5634
5809
|
}) {
|
|
5635
|
-
if (this.modes = [], this.createConversation = () => {
|
|
5636
|
-
const c = new
|
|
5810
|
+
if (this.modes = [], this.disposed = !1, this.createConversation = () => {
|
|
5811
|
+
const c = new j({
|
|
5637
5812
|
config: {
|
|
5638
5813
|
...this.config,
|
|
5639
5814
|
router: {
|
|
@@ -5653,27 +5828,30 @@ const w = class w {
|
|
|
5653
5828
|
return c.routerCtx.state.setPartial({
|
|
5654
5829
|
screen: this.contactCtx.shouldCollectData() ? "welcome" : "chat"
|
|
5655
5830
|
}), c;
|
|
5656
|
-
}, this.releaseConversation = () => {
|
|
5657
|
-
this.
|
|
5831
|
+
}, this.releaseConversation = () => this.dispose(), this.dispose = ({ clearActiveSession: c = !1 } = {}) => {
|
|
5832
|
+
if (this.disposed) return;
|
|
5833
|
+
this.disposed = !0, this.routerCtx.dispose(), this.activeSessionPollingCtx.dispose();
|
|
5834
|
+
const d = this.sessionCtx.dispose({ clearActiveSession: c });
|
|
5835
|
+
return this.messageCtx.reset(), this.uploadCtx.reset(), this.dictationCtx.stop(), d;
|
|
5658
5836
|
}, this.resetChat = () => {
|
|
5659
5837
|
this.sessionCtx.reset(), this.messageCtx.reset(), this.uploadCtx.reset();
|
|
5660
|
-
}, this.reconcileAfterStream = (c) => this.activeSessionPollingCtx.reconcileAfterStream(c), !
|
|
5838
|
+
}, this.reconcileAfterStream = (c) => this.activeSessionPollingCtx.reconcileAfterStream(c), !j.pollingIntervalsSeconds)
|
|
5661
5839
|
throw Error(
|
|
5662
5840
|
"Widget polling values are not defined, did you call WidgetCtx.initialize()"
|
|
5663
5841
|
);
|
|
5664
|
-
this.config = e, this.getRequestConfig =
|
|
5842
|
+
this.config = e, this.getRequestConfig = r ?? (() => this.config), this.getClientCapabilities = o, this.org = s, this.agent = a, this.api = (i == null ? void 0 : i.api) ?? new B({ config: e }), this.storageCtx = (i == null ? void 0 : i.storageCtx) ?? (t ? new Ka({ storage: t, config: e }) : void 0), this.modes = l, this.contactCtx = (i == null ? void 0 : i.contactCtx) ?? new ge({
|
|
5665
5843
|
api: this.api,
|
|
5666
5844
|
config: this.config,
|
|
5667
5845
|
storageCtx: this.storageCtx
|
|
5668
|
-
}), this.sessionCtx = new
|
|
5846
|
+
}), this.sessionCtx = new Aa({
|
|
5669
5847
|
config: this.config,
|
|
5670
5848
|
api: this.api,
|
|
5671
5849
|
contactCtx: this.contactCtx,
|
|
5672
5850
|
// Remembers the open conversation so a reload can return to it.
|
|
5673
|
-
storageCtx:
|
|
5674
|
-
sharedSessions:
|
|
5675
|
-
sessionsPollingIntervalSeconds:
|
|
5676
|
-
}), this.messageCtx = new
|
|
5851
|
+
storageCtx: i ? void 0 : this.storageCtx,
|
|
5852
|
+
sharedSessions: i == null ? void 0 : i.sessionCtx.sessionsState,
|
|
5853
|
+
sessionsPollingIntervalSeconds: j.pollingIntervalsSeconds.sessions
|
|
5854
|
+
}), this.messageCtx = new D({
|
|
5677
5855
|
config: this.config,
|
|
5678
5856
|
api: this.api,
|
|
5679
5857
|
sessionCtx: this.sessionCtx,
|
|
@@ -5684,78 +5862,78 @@ const w = class w {
|
|
|
5684
5862
|
isStreaming: () => this.streaming,
|
|
5685
5863
|
sendsPageContext: this.features.pageContext,
|
|
5686
5864
|
getSendsPageContext: () => this.features.pageContext,
|
|
5687
|
-
getClientCapabilities:
|
|
5688
|
-
getRequestConfig:
|
|
5689
|
-
}), this.uploadCtx = new
|
|
5865
|
+
getClientCapabilities: o,
|
|
5866
|
+
getRequestConfig: r
|
|
5867
|
+
}), this.uploadCtx = new ke(this.api), this.csatCtx = new be({
|
|
5690
5868
|
api: this.api,
|
|
5691
5869
|
sessionCtx: this.sessionCtx,
|
|
5692
5870
|
messageCtx: this.messageCtx
|
|
5693
|
-
}), this.dictationCtx = new
|
|
5871
|
+
}), this.dictationCtx = new Fe({
|
|
5694
5872
|
api: this.api,
|
|
5695
5873
|
config: this.config
|
|
5696
|
-
}), this.activeSessionPollingCtx = new
|
|
5874
|
+
}), this.activeSessionPollingCtx = new he({
|
|
5697
5875
|
api: this.api,
|
|
5698
5876
|
config: this.config,
|
|
5699
5877
|
sessionCtx: this.sessionCtx,
|
|
5700
5878
|
messageCtx: this.messageCtx,
|
|
5701
|
-
sessionPollingIntervalSeconds:
|
|
5702
|
-
}), this.routerCtx = new
|
|
5879
|
+
sessionPollingIntervalSeconds: j.pollingIntervalsSeconds.session
|
|
5880
|
+
}), this.routerCtx = new Ra(this);
|
|
5703
5881
|
}
|
|
5704
5882
|
get streaming() {
|
|
5705
|
-
var e,
|
|
5706
|
-
return (e = this.messageCtx) != null && e.hasPendingAgentWork ? !0 : (
|
|
5883
|
+
var e, t;
|
|
5884
|
+
return (e = this.messageCtx) != null && e.hasPendingAgentWork ? !0 : (t = this.messageCtx) != null && t.state.get().isSendingMessage ? !1 : this.agent.streaming && this.getRequestConfig().streaming !== !1;
|
|
5707
5885
|
}
|
|
5708
5886
|
/**
|
|
5709
5887
|
* The org's features narrowed by this embed's `config.features` — the
|
|
5710
5888
|
* answers the UI asks for, resolved against the current options.
|
|
5711
5889
|
*/
|
|
5712
5890
|
get features() {
|
|
5713
|
-
return
|
|
5891
|
+
return Fa(this.agent, this.getRequestConfig());
|
|
5714
5892
|
}
|
|
5715
5893
|
};
|
|
5716
|
-
|
|
5894
|
+
j.pollingIntervalsSeconds = null, j.initialize = async ({
|
|
5717
5895
|
config: e,
|
|
5718
|
-
storage:
|
|
5719
|
-
getClientCapabilities:
|
|
5720
|
-
getRequestConfig:
|
|
5896
|
+
storage: t,
|
|
5897
|
+
getClientCapabilities: o,
|
|
5898
|
+
getRequestConfig: r
|
|
5721
5899
|
}) => {
|
|
5722
|
-
var
|
|
5723
|
-
const
|
|
5900
|
+
var s, a;
|
|
5901
|
+
const l = await new B({
|
|
5724
5902
|
config: e
|
|
5725
5903
|
}).getExternalWidgetConfig();
|
|
5726
|
-
if (!
|
|
5727
|
-
throw
|
|
5904
|
+
if (!l.data)
|
|
5905
|
+
throw k.error("widget config fetch failed", l.error), new Oa(
|
|
5728
5906
|
"config-fetch-failed",
|
|
5729
5907
|
"Failed to fetch widget config",
|
|
5730
|
-
|
|
5908
|
+
l.error
|
|
5731
5909
|
);
|
|
5732
|
-
return
|
|
5733
|
-
session: ((
|
|
5734
|
-
sessions: ((
|
|
5735
|
-
}, new
|
|
5910
|
+
return j.pollingIntervalsSeconds = {
|
|
5911
|
+
session: ((s = l.data) == null ? void 0 : s.sessionPollingIntervalSeconds) || 10,
|
|
5912
|
+
sessions: ((a = l.data) == null ? void 0 : a.sessionsPollingIntervalSeconds) || 60
|
|
5913
|
+
}, new j({
|
|
5736
5914
|
config: e,
|
|
5737
|
-
storage:
|
|
5738
|
-
getClientCapabilities:
|
|
5739
|
-
getRequestConfig:
|
|
5740
|
-
modes:
|
|
5915
|
+
storage: t,
|
|
5916
|
+
getClientCapabilities: o,
|
|
5917
|
+
getRequestConfig: r,
|
|
5918
|
+
modes: l.data.modes || [],
|
|
5741
5919
|
org: {
|
|
5742
|
-
id:
|
|
5743
|
-
name:
|
|
5920
|
+
id: l.data.org.id,
|
|
5921
|
+
name: l.data.org.name
|
|
5744
5922
|
},
|
|
5745
|
-
agent:
|
|
5923
|
+
agent: La(l.data)
|
|
5746
5924
|
});
|
|
5747
5925
|
};
|
|
5748
|
-
let
|
|
5749
|
-
function
|
|
5926
|
+
let W = j;
|
|
5927
|
+
function Ya(n, e) {
|
|
5750
5928
|
return n ? {
|
|
5751
5929
|
streaming: n.streaming && (e == null ? void 0 : e.streaming) !== !1,
|
|
5752
5930
|
toolActivity: n.toolActivity === "hidden" || (e == null ? void 0 : e.toolActivity) === "hidden" ? "hidden" : n.toolActivity === "status" || (e == null ? void 0 : e.toolActivity) === "status" ? "status" : "details",
|
|
5753
5931
|
reasoning: n.reasoning && (e == null ? void 0 : e.reasoning) !== !1
|
|
5754
5932
|
} : e;
|
|
5755
5933
|
}
|
|
5756
|
-
class
|
|
5757
|
-
constructor({ attack: e, release:
|
|
5758
|
-
this.value = 0, this.attack = e, this.release =
|
|
5934
|
+
class Qa {
|
|
5935
|
+
constructor({ attack: e, release: t }) {
|
|
5936
|
+
this.value = 0, this.attack = e, this.release = t;
|
|
5759
5937
|
}
|
|
5760
5938
|
next(e) {
|
|
5761
5939
|
return this.value += (e - this.value) * (e > this.value ? this.attack : this.release), this.value;
|
|
@@ -5764,54 +5942,56 @@ class Va {
|
|
|
5764
5942
|
return this.value;
|
|
5765
5943
|
}
|
|
5766
5944
|
}
|
|
5767
|
-
const
|
|
5945
|
+
const T = [
|
|
5768
5946
|
"compact",
|
|
5769
5947
|
"sidebar",
|
|
5770
5948
|
"fullscreen"
|
|
5771
|
-
],
|
|
5772
|
-
|
|
5949
|
+
], Ua = new Set(
|
|
5950
|
+
T
|
|
5773
5951
|
);
|
|
5774
|
-
function
|
|
5775
|
-
return
|
|
5952
|
+
function Q(n) {
|
|
5953
|
+
return Ua.has(n);
|
|
5776
5954
|
}
|
|
5777
|
-
function
|
|
5778
|
-
if (!Array.isArray(n)) return
|
|
5779
|
-
const e = [],
|
|
5780
|
-
for (const
|
|
5781
|
-
|
|
5782
|
-
return e.length > 0 ? e :
|
|
5955
|
+
function Xa(n) {
|
|
5956
|
+
if (!Array.isArray(n)) return T;
|
|
5957
|
+
const e = [], t = /* @__PURE__ */ new Set();
|
|
5958
|
+
for (const o of n)
|
|
5959
|
+
!Q(o) || t.has(o) || (t.add(o), e.push(o));
|
|
5960
|
+
return e.length > 0 ? e : T;
|
|
5783
5961
|
}
|
|
5784
|
-
function
|
|
5785
|
-
return
|
|
5962
|
+
function et(n, e) {
|
|
5963
|
+
return Q(n) && e.includes(n) ? n : e[0] ?? T[0];
|
|
5786
5964
|
}
|
|
5787
|
-
function
|
|
5965
|
+
function at(n, e) {
|
|
5788
5966
|
return n === "left" || n === "right" ? n : e === "rtl" ? "left" : "right";
|
|
5789
5967
|
}
|
|
5790
|
-
function
|
|
5968
|
+
function tt(n) {
|
|
5791
5969
|
return n === "docked" ? "docked" : "floating";
|
|
5792
5970
|
}
|
|
5793
5971
|
export {
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5972
|
+
pe as ConnectionAttemptUnavailableError,
|
|
5973
|
+
ce as ConnectionRequestExpiredError,
|
|
5974
|
+
Qa as DictationLevelSmoother,
|
|
5975
|
+
S as PrimitiveState,
|
|
5976
|
+
W as WidgetCtx,
|
|
5977
|
+
Oa as WidgetInitializationError,
|
|
5978
|
+
Na as buildSendMessageBody,
|
|
5799
5979
|
x as genUuid,
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5980
|
+
qa as getTranslation,
|
|
5981
|
+
Ga as isAgentStreamKeepalive,
|
|
5982
|
+
me as isExhaustive,
|
|
5983
|
+
Z as isRecord,
|
|
5984
|
+
Ja as isRtlLanguage,
|
|
5985
|
+
za as isSupportedLanguage,
|
|
5986
|
+
$a as isTurnSteeredPart,
|
|
5987
|
+
k as log,
|
|
5988
|
+
Xa as normalizeCompanionLayouts,
|
|
5989
|
+
Ya as resolveClientPresentation,
|
|
5990
|
+
et as resolveCompanionDefaultLayout,
|
|
5991
|
+
Ma as resolveConfigContext,
|
|
5992
|
+
xa as resolveLanguage,
|
|
5993
|
+
tt as resolveSidebarMode,
|
|
5994
|
+
at as resolveSidebarSide,
|
|
5995
|
+
Ea as translate
|
|
5816
5996
|
};
|
|
5817
5997
|
//# sourceMappingURL=index.js.map
|