@opencx/widget-core 5.0.0-beta.5 → 5.0.0-beta.7
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 +1577 -1062
- package/dist/index.js.map +1 -1
- package/dist/src/api/api-caller.d.ts +67 -0
- 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 +517 -56
- 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/resolve-client-presentation.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/translation/ar.d.ts.map +1 -1
- package/dist/src/translation/bg.d.ts.map +1 -1
- package/dist/src/translation/bn.d.ts.map +1 -1
- package/dist/src/translation/cs.d.ts.map +1 -1
- package/dist/src/translation/da.d.ts.map +1 -1
- package/dist/src/translation/de.d.ts.map +1 -1
- package/dist/src/translation/el.d.ts.map +1 -1
- package/dist/src/translation/en.d.ts.map +1 -1
- package/dist/src/translation/es.d.ts.map +1 -1
- package/dist/src/translation/et.d.ts.map +1 -1
- package/dist/src/translation/fi.d.ts.map +1 -1
- package/dist/src/translation/fil.d.ts.map +1 -1
- package/dist/src/translation/fr.d.ts.map +1 -1
- package/dist/src/translation/hi.d.ts.map +1 -1
- package/dist/src/translation/hr.d.ts.map +1 -1
- package/dist/src/translation/hu.d.ts.map +1 -1
- package/dist/src/translation/index.d.ts +12 -0
- package/dist/src/translation/index.d.ts.map +1 -1
- package/dist/src/translation/is.d.ts.map +1 -1
- package/dist/src/translation/it.d.ts.map +1 -1
- package/dist/src/translation/ja.d.ts.map +1 -1
- package/dist/src/translation/ko.d.ts.map +1 -1
- package/dist/src/translation/lb.d.ts.map +1 -1
- package/dist/src/translation/lt.d.ts.map +1 -1
- package/dist/src/translation/lv.d.ts.map +1 -1
- package/dist/src/translation/mt.d.ts.map +1 -1
- package/dist/src/translation/nb.d.ts.map +1 -1
- package/dist/src/translation/nl.d.ts.map +1 -1
- package/dist/src/translation/no.d.ts.map +1 -1
- package/dist/src/translation/pl.d.ts.map +1 -1
- package/dist/src/translation/pt.d.ts.map +1 -1
- package/dist/src/translation/ro.d.ts.map +1 -1
- package/dist/src/translation/ru.d.ts.map +1 -1
- package/dist/src/translation/sk.d.ts.map +1 -1
- package/dist/src/translation/sv.d.ts.map +1 -1
- package/dist/src/translation/th.d.ts.map +1 -1
- package/dist/src/translation/tr.d.ts.map +1 -1
- package/dist/src/translation/ur.d.ts.map +1 -1
- package/dist/src/translation/vi.d.ts.map +1 -1
- package/dist/src/translation/zh-cn.d.ts.map +1 -1
- package/dist/src/types/component-name.d.ts +1 -1
- package/dist/src/types/component-name.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 +4 -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,287 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 = {
|
|
47
|
+
warn: (n, ...e) => {
|
|
48
|
+
console.warn(`${O} ${n}`, ...e);
|
|
7
49
|
},
|
|
8
|
-
error: (
|
|
9
|
-
console.error(`${
|
|
50
|
+
error: (n, ...e) => {
|
|
51
|
+
console.error(`${O} ${n}`, ...e);
|
|
10
52
|
}
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
const e =
|
|
15
|
-
baseUrl:
|
|
16
|
-
}),
|
|
17
|
-
onRequest:
|
|
18
|
-
onResponse:
|
|
19
|
-
onError:
|
|
53
|
+
}, _e = (n) => {
|
|
54
|
+
k.error("request failed", n.error);
|
|
55
|
+
}, le = (n) => {
|
|
56
|
+
const e = se({
|
|
57
|
+
baseUrl: n.baseUrl
|
|
58
|
+
}), t = {
|
|
59
|
+
onRequest: n.onRequest,
|
|
60
|
+
onResponse: n.onResponse,
|
|
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.getAgentTurnMessages = async (
|
|
68
|
-
const { data:
|
|
195
|
+
if (!a.ok)
|
|
196
|
+
throw new Error(`Failed to stop stream: ${a.status}`);
|
|
197
|
+
}, this.getAgentTurnMessages = async (s, a) => {
|
|
198
|
+
const { data: i, response: c } = await this.client.GET(
|
|
69
199
|
"/backend/widget/v5/chat/{sessionId}/messages",
|
|
70
200
|
{
|
|
71
201
|
params: {
|
|
72
|
-
path: { sessionId:
|
|
202
|
+
path: { sessionId: s },
|
|
73
203
|
query: {
|
|
74
|
-
toolActivity:
|
|
75
|
-
reasoning: (
|
|
204
|
+
toolActivity: a == null ? void 0 : a.toolActivity,
|
|
205
|
+
reasoning: (a == null ? void 0 : a.reasoning) === void 0 ? void 0 : a.reasoning ? "true" : "false"
|
|
76
206
|
}
|
|
77
207
|
}
|
|
78
208
|
}
|
|
79
209
|
);
|
|
80
|
-
return
|
|
210
|
+
return i ? {
|
|
211
|
+
...i,
|
|
212
|
+
handled_connection_request_ids: i.handled_connection_request_ids ?? []
|
|
213
|
+
} : (k.warn("agent turn messages fetch failed", c.status), null);
|
|
81
214
|
}, this.createDictationSession = async ({
|
|
82
|
-
language:
|
|
215
|
+
language: s
|
|
83
216
|
}) => {
|
|
84
|
-
const { data:
|
|
217
|
+
const { data: a, response: i } = await this.client.POST(
|
|
85
218
|
"/backend/widget/v5/dictation/sessions",
|
|
86
|
-
{ body:
|
|
219
|
+
{ body: s ? { language: s } : {} }
|
|
87
220
|
);
|
|
88
|
-
if (!
|
|
89
|
-
throw new Error(`Failed to start dictation: ${
|
|
90
|
-
return
|
|
221
|
+
if (!a)
|
|
222
|
+
throw new Error(`Failed to start dictation: ${i.status}`);
|
|
223
|
+
return a;
|
|
91
224
|
}, this.getExternalWidgetConfig = async () => await this.client.GET("/backend/widget/v2/config", {
|
|
92
225
|
params: {
|
|
93
226
|
header: { "x-bot-token": this.config.token }
|
|
94
227
|
}
|
|
95
|
-
}), this.sendMessage = async (
|
|
96
|
-
body:
|
|
97
|
-
signal:
|
|
98
|
-
}), this.createUnverifiedContact = async (
|
|
228
|
+
}), this.sendMessage = async (s, a) => await this.client.POST("/backend/widget/v2/chat/send", {
|
|
229
|
+
body: s,
|
|
230
|
+
signal: a
|
|
231
|
+
}), this.createUnverifiedContact = async (s) => await this.client.POST(
|
|
99
232
|
"/backend/widget/v2/contact/create-unverified",
|
|
100
233
|
{
|
|
101
234
|
params: { header: { "x-bot-token": this.config.token } },
|
|
102
|
-
body:
|
|
235
|
+
body: s
|
|
103
236
|
}
|
|
104
|
-
), this.createSession = async (
|
|
105
|
-
body:
|
|
106
|
-
signal:
|
|
237
|
+
), this.createSession = async (s, a) => await this.client.POST("/backend/widget/v2/create-session", {
|
|
238
|
+
body: s,
|
|
239
|
+
signal: a
|
|
107
240
|
}), this.pollSessionAndHistory = async ({
|
|
108
|
-
sessionId:
|
|
109
|
-
abortSignal:
|
|
241
|
+
sessionId: s,
|
|
242
|
+
abortSignal: a
|
|
110
243
|
}) => await this.client.GET("/backend/widget/v2/poll/{sessionId}", {
|
|
111
|
-
params: { path: { sessionId:
|
|
112
|
-
signal:
|
|
244
|
+
params: { path: { sessionId: s } },
|
|
245
|
+
signal: a
|
|
113
246
|
}), this.getSessions = async ({
|
|
114
|
-
cursor:
|
|
115
|
-
filters:
|
|
116
|
-
abortSignal:
|
|
247
|
+
cursor: s,
|
|
248
|
+
filters: a,
|
|
249
|
+
abortSignal: i
|
|
117
250
|
}) => await this.client.GET("/backend/widget/v2/sessions", {
|
|
118
251
|
params: {
|
|
119
252
|
query: {
|
|
120
|
-
offset:
|
|
121
|
-
filters: JSON.stringify(
|
|
253
|
+
offset: s,
|
|
254
|
+
filters: JSON.stringify(a)
|
|
122
255
|
}
|
|
123
256
|
},
|
|
124
|
-
signal:
|
|
257
|
+
signal: i
|
|
125
258
|
}), this.uploadFile = async ({
|
|
126
|
-
file:
|
|
127
|
-
abortSignal:
|
|
128
|
-
onProgress:
|
|
259
|
+
file: s,
|
|
260
|
+
abortSignal: a,
|
|
261
|
+
onProgress: i
|
|
129
262
|
}) => new Promise((c, d) => {
|
|
130
263
|
var f;
|
|
131
|
-
const
|
|
132
|
-
|
|
264
|
+
const _ = new FormData();
|
|
265
|
+
_.append("file", s);
|
|
133
266
|
const p = new XMLHttpRequest();
|
|
134
|
-
if (
|
|
267
|
+
if (a && (a.addEventListener("abort", () => {
|
|
135
268
|
p.abort(), d(new DOMException("Aborted", "AbortError"));
|
|
136
|
-
}),
|
|
269
|
+
}), a.aborted)) {
|
|
137
270
|
d(new DOMException("Aborted", "AbortError"));
|
|
138
271
|
return;
|
|
139
272
|
}
|
|
140
|
-
p.upload.addEventListener("progress", (
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
|
|
273
|
+
p.upload.addEventListener("progress", (b) => {
|
|
274
|
+
if (b.lengthComputable && i) {
|
|
275
|
+
const w = Math.round(b.loaded / b.total * 100);
|
|
276
|
+
i(w);
|
|
144
277
|
}
|
|
145
278
|
}), p.addEventListener("load", () => {
|
|
146
279
|
if (p.status >= 200 && p.status < 300)
|
|
147
280
|
try {
|
|
148
|
-
const
|
|
149
|
-
c(
|
|
150
|
-
} catch (
|
|
151
|
-
d(new Error(`Failed to parse response: ${
|
|
281
|
+
const b = JSON.parse(p.responseText);
|
|
282
|
+
c(b);
|
|
283
|
+
} catch (b) {
|
|
284
|
+
d(new Error(`Failed to parse response: ${b}`));
|
|
152
285
|
}
|
|
153
286
|
else
|
|
154
287
|
d(new Error(`Upload failed with status: ${p.status}`));
|
|
@@ -158,196 +291,207 @@ class O {
|
|
|
158
291
|
d(new Error("Upload timed out"));
|
|
159
292
|
});
|
|
160
293
|
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 ?? ((f = this.config.user) == null ? void 0 : f.token) ? p.setRequestHeader("Authorization", `Bearer ${this.userToken}`) :
|
|
162
|
-
}), this.vote = async (
|
|
163
|
-
body:
|
|
164
|
-
signal:
|
|
165
|
-
}), this.createStateCheckpoint = async (
|
|
166
|
-
body:
|
|
167
|
-
}), this.submitCsat = async (
|
|
168
|
-
const { baseUrl:
|
|
169
|
-
(
|
|
294
|
+
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(_);
|
|
295
|
+
}), 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", {
|
|
296
|
+
body: s,
|
|
297
|
+
signal: a
|
|
298
|
+
}), this.createStateCheckpoint = async (s) => await this.client.POST("/backend/widget/v2/checkpoint", {
|
|
299
|
+
body: s
|
|
300
|
+
}), 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;
|
|
301
|
+
const { baseUrl: t, headers: o } = this.constructClientOptions(
|
|
302
|
+
(l = e.user) == null ? void 0 : l.token
|
|
170
303
|
);
|
|
171
|
-
this.client = this.createOpenAPIClient({ baseUrl:
|
|
304
|
+
this.client = this.createOpenAPIClient({ baseUrl: t, headers: o });
|
|
172
305
|
}
|
|
173
306
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
307
|
+
function me(n, e) {
|
|
308
|
+
k.error(`missing case for ${n} in ${e}`);
|
|
176
309
|
}
|
|
177
|
-
class
|
|
310
|
+
class S {
|
|
178
311
|
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(
|
|
312
|
+
this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (t) => {
|
|
313
|
+
oe(this.state, t) || (this.state = t, this.notifySubscribers(t));
|
|
314
|
+
}, this.setPartial = (t) => {
|
|
315
|
+
if (t == null) return;
|
|
316
|
+
const o = { ...this.state, ...t };
|
|
317
|
+
this.set(o);
|
|
185
318
|
}, this.reset = () => {
|
|
186
319
|
this.set(this.initialState);
|
|
187
|
-
}, this.notifySubscribers = (
|
|
188
|
-
Array.from(this.subscribers).forEach((
|
|
320
|
+
}, this.notifySubscribers = (t) => {
|
|
321
|
+
Array.from(this.subscribers).forEach((r) => {
|
|
189
322
|
try {
|
|
190
|
-
|
|
191
|
-
} catch (
|
|
192
|
-
|
|
323
|
+
r(t);
|
|
324
|
+
} catch (l) {
|
|
325
|
+
k.error("state subscriber threw", l);
|
|
193
326
|
}
|
|
194
327
|
});
|
|
195
|
-
}, this.subscribe = (
|
|
196
|
-
this.subscribers.delete(
|
|
328
|
+
}, this.subscribe = (t) => (this.subscribers.add(t), () => {
|
|
329
|
+
this.subscribers.delete(t);
|
|
197
330
|
}), this.state = e, this.initialState = e;
|
|
198
331
|
}
|
|
199
332
|
}
|
|
200
333
|
class G {
|
|
201
334
|
constructor() {
|
|
202
|
-
this.state = new
|
|
335
|
+
this.state = new S({
|
|
203
336
|
isPolling: !1,
|
|
204
337
|
isError: !1
|
|
205
338
|
}), this.abortController = new AbortController(), this.reset = () => {
|
|
206
339
|
var e;
|
|
207
340
|
this.abortController.abort("Resetting poller"), (e = this.stopPolling) == null || e.call(this), this.stopPolling = null;
|
|
208
|
-
}, this.stopPolling = null, this.startPolling = (e,
|
|
341
|
+
}, this.stopPolling = null, this.startPolling = (e, t) => {
|
|
209
342
|
if (this.stopPolling) return;
|
|
210
|
-
const
|
|
343
|
+
const o = [], r = async () => {
|
|
211
344
|
this.abortController = new AbortController(), this.state.setPartial({ isPolling: !0 });
|
|
212
345
|
try {
|
|
213
346
|
await e(this.abortController.signal);
|
|
214
|
-
} catch (
|
|
347
|
+
} catch (l) {
|
|
215
348
|
if (this.abortController.signal.aborted)
|
|
216
349
|
return;
|
|
217
|
-
|
|
350
|
+
k.error("failed to poll", l), this.state.setPartial({ isError: !0 });
|
|
218
351
|
} finally {
|
|
219
352
|
this.state.setPartial({ isPolling: !1 });
|
|
220
353
|
}
|
|
221
|
-
this.abortController.signal.aborted ||
|
|
354
|
+
this.abortController.signal.aborted || o.push(setTimeout(r, t));
|
|
222
355
|
};
|
|
223
|
-
|
|
224
|
-
|
|
356
|
+
r(), this.stopPolling = () => {
|
|
357
|
+
o.forEach(clearTimeout), this.state.reset();
|
|
225
358
|
};
|
|
226
359
|
};
|
|
227
360
|
}
|
|
228
361
|
}
|
|
229
|
-
function
|
|
362
|
+
function $(n) {
|
|
230
363
|
try {
|
|
231
|
-
const e =
|
|
232
|
-
return e instanceof Promise ? e.then((
|
|
364
|
+
const e = n();
|
|
365
|
+
return e instanceof Promise ? e.then((t) => ({ data: t })).catch((t) => ({ error: t })) : { data: e };
|
|
233
366
|
} catch (e) {
|
|
234
367
|
return { error: e };
|
|
235
368
|
}
|
|
236
369
|
}
|
|
237
|
-
class
|
|
370
|
+
class he {
|
|
238
371
|
constructor({
|
|
239
372
|
api: e,
|
|
240
|
-
config:
|
|
241
|
-
sessionCtx:
|
|
242
|
-
messageCtx:
|
|
243
|
-
sessionPollingIntervalSeconds:
|
|
373
|
+
config: t,
|
|
374
|
+
sessionCtx: o,
|
|
375
|
+
messageCtx: r,
|
|
376
|
+
sessionPollingIntervalSeconds: l
|
|
244
377
|
}) {
|
|
245
|
-
this.poller = new G(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.reconcileAbortController = new AbortController(), this.reconcilingSessionId = null, this.registerPolling = () => {
|
|
246
|
-
this.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
try {
|
|
253
|
-
this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.fetchSessionAndHistory({
|
|
254
|
-
sessionId: n.id,
|
|
255
|
-
abortSignal: this.fetchSessionAndFullHistoryAbortController.signal
|
|
378
|
+
this.poller = new G(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.reconcileAbortController = new AbortController(), this.subscriptions = [], this.reconcilingSessionId = null, this.registerPolling = () => {
|
|
379
|
+
this.subscriptions.push(
|
|
380
|
+
this.sessionCtx.sessionState.subscribe(({ session: s }) => {
|
|
381
|
+
s != null && s.id ? this.poller.startPolling(async (a) => {
|
|
382
|
+
this.fetchSessionAndHistory({
|
|
383
|
+
sessionId: s.id,
|
|
384
|
+
abortSignal: a
|
|
256
385
|
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
386
|
+
}, this.sessionPollingIntervalSeconds * 1e3) : this.poller.reset();
|
|
387
|
+
})
|
|
388
|
+
), this.subscriptions.push(
|
|
389
|
+
this.sessionCtx.sessionState.subscribe(({ session: s }) => {
|
|
390
|
+
if (s != null && s.id && !s.isOpened)
|
|
391
|
+
try {
|
|
392
|
+
this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.fetchSessionAndHistory({
|
|
393
|
+
sessionId: s.id,
|
|
394
|
+
abortSignal: this.fetchSessionAndFullHistoryAbortController.signal
|
|
395
|
+
});
|
|
396
|
+
} catch (a) {
|
|
397
|
+
this.fetchSessionAndFullHistoryAbortController.signal.aborted || k.error("failed to fetch session and full history", a);
|
|
398
|
+
}
|
|
399
|
+
else
|
|
400
|
+
this.fetchSessionAndFullHistoryAbortController.abort();
|
|
401
|
+
})
|
|
402
|
+
), this.subscriptions.push(
|
|
403
|
+
this.sessionCtx.sessionState.subscribe(({ session: s }) => {
|
|
404
|
+
this.reconcilingSessionId !== null && (s == null ? void 0 : s.id) !== this.reconcilingSessionId && this.reconcileAbortController.abort();
|
|
405
|
+
})
|
|
406
|
+
);
|
|
407
|
+
}, this.dispose = () => {
|
|
408
|
+
this.poller.reset(), this.fetchSessionAndFullHistoryAbortController.abort(), this.reconcileAbortController.abort(), this.reconcilingSessionId = null, this.subscriptions.forEach((s) => s()), this.subscriptions = [];
|
|
409
|
+
}, this.reconcileAfterStream = async (s) => {
|
|
266
410
|
this.reconcileAbortController.abort(), this.reconcileAbortController = new AbortController();
|
|
267
|
-
const { signal:
|
|
268
|
-
this.reconcilingSessionId =
|
|
411
|
+
const { signal: a } = this.reconcileAbortController;
|
|
412
|
+
this.reconcilingSessionId = s;
|
|
269
413
|
try {
|
|
270
|
-
await this.fetchSessionAndHistory({ sessionId:
|
|
271
|
-
} catch (
|
|
272
|
-
if (!
|
|
414
|
+
await this.fetchSessionAndHistory({ sessionId: s, abortSignal: a });
|
|
415
|
+
} catch (i) {
|
|
416
|
+
if (!a.aborted) throw i;
|
|
273
417
|
} finally {
|
|
274
|
-
this.reconcilingSessionId ===
|
|
418
|
+
this.reconcilingSessionId === s && (this.reconcilingSessionId = null);
|
|
275
419
|
}
|
|
276
420
|
}, this.fetchSessionAndHistory = async ({
|
|
277
|
-
sessionId:
|
|
278
|
-
abortSignal:
|
|
421
|
+
sessionId: s,
|
|
422
|
+
abortSignal: a
|
|
279
423
|
}) => {
|
|
280
|
-
const
|
|
281
|
-
|
|
424
|
+
const i = this.messageCtx.state.get().messages.length === 0;
|
|
425
|
+
i && this.messageCtx.state.setPartial({ isInitialFetchLoading: !0 });
|
|
282
426
|
const { data: c } = await this.api.pollSessionAndHistory({
|
|
283
|
-
sessionId:
|
|
284
|
-
abortSignal:
|
|
427
|
+
sessionId: s,
|
|
428
|
+
abortSignal: a
|
|
285
429
|
});
|
|
286
430
|
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,
|
|
431
|
+
const d = this.messageCtx.state.get().messages, _ = c.history.map(this.mapHistoryToMessage).filter((p) => p !== null).filter(
|
|
288
432
|
(p) => !d.some((u) => u.id === p.id)
|
|
289
433
|
);
|
|
290
|
-
if (
|
|
434
|
+
if (_.length > 0)
|
|
291
435
|
if (this.messageCtx.state.setPartial({
|
|
292
|
-
messages: [...d, ...
|
|
293
|
-
}),
|
|
436
|
+
messages: [...d, ..._]
|
|
437
|
+
}), i)
|
|
294
438
|
this.messageCtx.markAsDispatchedToOnMessageReceivedHook(
|
|
295
|
-
|
|
439
|
+
_.map((p) => p.id)
|
|
296
440
|
);
|
|
297
441
|
else
|
|
298
|
-
for (const p of
|
|
442
|
+
for (const p of _)
|
|
299
443
|
this.messageCtx.dispatchToOnMessageReceivedHook(p);
|
|
300
444
|
}
|
|
301
445
|
this.messageCtx.state.get().isInitialFetchLoading && this.messageCtx.state.setPartial({ isInitialFetchLoading: !1 });
|
|
302
|
-
}, this.mapHistoryToMessage = (
|
|
303
|
-
var
|
|
304
|
-
const
|
|
305
|
-
id:
|
|
306
|
-
timestamp:
|
|
307
|
-
attachments:
|
|
446
|
+
}, this.mapHistoryToMessage = (s) => {
|
|
447
|
+
var i;
|
|
448
|
+
const a = {
|
|
449
|
+
id: s.publicId,
|
|
450
|
+
timestamp: s.sentAt || "",
|
|
451
|
+
attachments: s.attachments || void 0
|
|
308
452
|
};
|
|
309
|
-
if (
|
|
453
|
+
if (s.sender.kind === "user")
|
|
310
454
|
return {
|
|
311
|
-
...
|
|
455
|
+
...a,
|
|
312
456
|
type: "USER",
|
|
313
|
-
content:
|
|
457
|
+
content: s.content.text || "",
|
|
314
458
|
// Backend field name (schema.ts) → widget vocabulary.
|
|
315
|
-
markedElements:
|
|
459
|
+
markedElements: s.pickedElements
|
|
316
460
|
};
|
|
317
|
-
if (
|
|
461
|
+
if (s.sender.kind === "agent")
|
|
318
462
|
return {
|
|
319
|
-
...
|
|
463
|
+
...a,
|
|
320
464
|
type: "AGENT",
|
|
321
465
|
component: "agent_message",
|
|
322
466
|
data: {
|
|
323
|
-
message:
|
|
467
|
+
message: s.content.text || ""
|
|
324
468
|
},
|
|
325
469
|
agent: {
|
|
326
|
-
name:
|
|
470
|
+
name: s.sender.name || "",
|
|
327
471
|
// Do not set avatarUrl from config here... let it be taken from the config at render time
|
|
328
472
|
// Only set avatar url from the backend's response
|
|
329
|
-
avatarUrl:
|
|
330
|
-
avatar:
|
|
473
|
+
avatarUrl: s.sender.avatar || null,
|
|
474
|
+
avatar: s.sender.avatar || null,
|
|
331
475
|
id: null,
|
|
332
476
|
isAi: !1
|
|
333
477
|
}
|
|
334
478
|
};
|
|
335
|
-
if (
|
|
336
|
-
const c =
|
|
479
|
+
if (s.sender.kind === "ai") {
|
|
480
|
+
const c = s.actionCalls && s.actionCalls.length > 0 ? s.actionCalls[s.actionCalls.length - 1] : void 0;
|
|
337
481
|
return {
|
|
338
|
-
...
|
|
482
|
+
...a,
|
|
339
483
|
type: "AI",
|
|
340
484
|
component: "bot_message",
|
|
341
485
|
agent: {
|
|
342
486
|
id: null,
|
|
343
|
-
name: ((
|
|
487
|
+
name: ((i = this.config.bot) == null ? void 0 : i.name) || "",
|
|
344
488
|
isAi: !0,
|
|
345
489
|
// Do not set avatarUrl from config here... let it be taken from the config at render time
|
|
346
490
|
avatarUrl: null,
|
|
347
491
|
avatar: null
|
|
348
492
|
},
|
|
349
493
|
data: {
|
|
350
|
-
message:
|
|
494
|
+
message: s.content.text || "",
|
|
351
495
|
action: c ? {
|
|
352
496
|
name: c.actionName,
|
|
353
497
|
data: this.extractActionResult(c)
|
|
@@ -355,136 +499,136 @@ class _e {
|
|
|
355
499
|
}
|
|
356
500
|
};
|
|
357
501
|
}
|
|
358
|
-
if (
|
|
359
|
-
const c = this.constructSystemMessage(
|
|
502
|
+
if (s.sender.kind === "system") {
|
|
503
|
+
const c = this.constructSystemMessage(s);
|
|
360
504
|
return c === null ? null : { ...c };
|
|
361
505
|
}
|
|
362
506
|
return null;
|
|
363
|
-
}, this.constructSystemMessage = (
|
|
364
|
-
if (!
|
|
365
|
-
switch (
|
|
507
|
+
}, this.constructSystemMessage = (s) => {
|
|
508
|
+
if (!s || !s.systemMessagePayload) return null;
|
|
509
|
+
switch (s.systemMessagePayload.type) {
|
|
366
510
|
case "state_checkpoint":
|
|
367
511
|
return {
|
|
368
|
-
id:
|
|
512
|
+
id: s.publicId,
|
|
369
513
|
type: "SYSTEM",
|
|
370
514
|
subtype: "state_checkpoint",
|
|
371
|
-
data: { payload:
|
|
372
|
-
timestamp:
|
|
515
|
+
data: { payload: s.systemMessagePayload.payload },
|
|
516
|
+
timestamp: s.sentAt || "",
|
|
373
517
|
attachments: void 0
|
|
374
518
|
};
|
|
375
519
|
case "csat_requested":
|
|
376
520
|
return {
|
|
377
|
-
id:
|
|
521
|
+
id: s.publicId,
|
|
378
522
|
type: "SYSTEM",
|
|
379
523
|
subtype: "csat_requested",
|
|
380
524
|
data: { payload: void 0 },
|
|
381
|
-
timestamp:
|
|
525
|
+
timestamp: s.sentAt || "",
|
|
382
526
|
attachments: void 0
|
|
383
527
|
};
|
|
384
528
|
case "csat_submitted":
|
|
385
529
|
return {
|
|
386
|
-
id:
|
|
530
|
+
id: s.publicId,
|
|
387
531
|
type: "SYSTEM",
|
|
388
532
|
subtype: "csat_submitted",
|
|
389
533
|
data: {
|
|
390
534
|
payload: {
|
|
391
|
-
score:
|
|
392
|
-
feedback:
|
|
535
|
+
score: s.systemMessagePayload.payload.score ?? void 0,
|
|
536
|
+
feedback: s.systemMessagePayload.payload.feedback ?? void 0
|
|
393
537
|
}
|
|
394
538
|
},
|
|
395
|
-
timestamp:
|
|
539
|
+
timestamp: s.sentAt || "",
|
|
396
540
|
attachments: void 0
|
|
397
541
|
};
|
|
398
542
|
case "none":
|
|
399
543
|
return null;
|
|
400
544
|
default:
|
|
401
|
-
return
|
|
402
|
-
|
|
545
|
+
return me(
|
|
546
|
+
s.systemMessagePayload,
|
|
403
547
|
this.constructSystemMessage.name
|
|
404
548
|
), null;
|
|
405
549
|
}
|
|
406
|
-
}, this.extractActionResult = (
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
if ("responseBodyText" in
|
|
410
|
-
const
|
|
550
|
+
}, this.extractActionResult = (s) => {
|
|
551
|
+
const a = s.result;
|
|
552
|
+
if (a === null || typeof a != "object") return a;
|
|
553
|
+
if ("responseBodyText" in a && typeof a.responseBodyText == "string") {
|
|
554
|
+
const i = a.responseBodyText, c = $(() => JSON.parse(i)).data;
|
|
411
555
|
if (c) return c;
|
|
412
556
|
}
|
|
413
|
-
return
|
|
414
|
-
}, this.api = e, this.config =
|
|
557
|
+
return s.result;
|
|
558
|
+
}, this.api = e, this.config = t, this.sessionCtx = o, this.messageCtx = r, this.sessionPollingIntervalSeconds = l, this.registerPolling();
|
|
415
559
|
}
|
|
416
560
|
}
|
|
417
|
-
class
|
|
561
|
+
class ge {
|
|
418
562
|
constructor({
|
|
419
563
|
config: e,
|
|
420
|
-
api:
|
|
421
|
-
storageCtx:
|
|
564
|
+
api: t,
|
|
565
|
+
storageCtx: o
|
|
422
566
|
}) {
|
|
423
|
-
var
|
|
567
|
+
var r;
|
|
424
568
|
this.shouldCollectData = () => {
|
|
425
|
-
var
|
|
426
|
-
return !!(!((
|
|
569
|
+
var l;
|
|
570
|
+
return !!(!((l = this.state.get().contact) != null && l.token) && this.config.collectUserData);
|
|
427
571
|
}, this.autoCreateUnverifiedUserIfNotExists = async () => {
|
|
428
|
-
var
|
|
429
|
-
if (!((
|
|
430
|
-
if (this.config.collectUserData && !((
|
|
431
|
-
if ((
|
|
572
|
+
var l, s, a, i, c, d, _, p, u, m, g, v, f, b;
|
|
573
|
+
if (!((l = this.config.user) != null && l.token)) {
|
|
574
|
+
if (this.config.collectUserData && !((a = (s = this.config.user) == null ? void 0 : s.data) != null && a.email)) {
|
|
575
|
+
if ((i = this.config.extraDataCollectionFields) != null && i.length)
|
|
432
576
|
return;
|
|
433
|
-
const
|
|
434
|
-
|
|
577
|
+
const w = await ((c = this.storageCtx) == null ? void 0 : c.getContactToken());
|
|
578
|
+
w && await this.setUnverifiedContact(w);
|
|
435
579
|
return;
|
|
436
580
|
}
|
|
437
|
-
if (!((
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
await this.setUnverifiedContact(
|
|
581
|
+
if (!((_ = (d = this.config.user) == null ? void 0 : d.data) != null && _.email)) {
|
|
582
|
+
const w = await ((p = this.storageCtx) == null ? void 0 : p.getContactToken());
|
|
583
|
+
if (w) {
|
|
584
|
+
await this.setUnverifiedContact(w);
|
|
441
585
|
return;
|
|
442
586
|
}
|
|
443
587
|
}
|
|
444
588
|
await this.createUnverifiedContact({
|
|
445
589
|
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: (
|
|
590
|
+
non_verified_name: (v = (g = this.config.user) == null ? void 0 : g.data) == null ? void 0 : v.name,
|
|
591
|
+
non_verified_custom_data: (b = (f = this.config.user) == null ? void 0 : f.data) == null ? void 0 : b.customData
|
|
448
592
|
});
|
|
449
593
|
}
|
|
450
|
-
}, this.createUnverifiedContact = async (
|
|
451
|
-
this.state.setPartial({ extraCollectedData:
|
|
594
|
+
}, this.createUnverifiedContact = async (l, s) => {
|
|
595
|
+
this.state.setPartial({ extraCollectedData: s });
|
|
452
596
|
try {
|
|
453
597
|
this.state.setPartial({
|
|
454
598
|
isCreatingUnverifiedContact: !0,
|
|
455
599
|
isErrorCreatingUnverifiedContact: !1
|
|
456
600
|
});
|
|
457
|
-
const { data:
|
|
458
|
-
|
|
459
|
-
} catch (
|
|
460
|
-
this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 }),
|
|
461
|
-
_e:
|
|
601
|
+
const { data: a } = await this.api.createUnverifiedContact(l);
|
|
602
|
+
a != null && a.token ? await this.setUnverifiedContact(a.token) : this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 });
|
|
603
|
+
} catch (a) {
|
|
604
|
+
this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 }), k.error("failed to create an unverified contact", {
|
|
605
|
+
_e: a instanceof Error ? a.message : String(a)
|
|
462
606
|
});
|
|
463
607
|
} finally {
|
|
464
608
|
this.state.setPartial({ isCreatingUnverifiedContact: !1 });
|
|
465
609
|
}
|
|
466
610
|
}, this.recoverFromStaleToken = async () => {
|
|
467
|
-
var
|
|
468
|
-
if ((
|
|
611
|
+
var l, s, a, i, c, d, _, p, u, m;
|
|
612
|
+
if ((l = this.config.user) != null && l.token) return !1;
|
|
469
613
|
this.api.setAuthToken(""), this.state.setPartial({ contact: null });
|
|
470
614
|
try {
|
|
471
|
-
await ((
|
|
615
|
+
await ((s = this.storageCtx) == null ? void 0 : s.clearContactToken()), await ((a = this.storageCtx) == null ? void 0 : a.clearActiveSessionId());
|
|
472
616
|
} catch (g) {
|
|
473
|
-
|
|
617
|
+
k.warn("failed to clear a stale contact token", {
|
|
474
618
|
error: g instanceof Error ? g.message : String(g)
|
|
475
619
|
});
|
|
476
620
|
}
|
|
477
621
|
return await this.createUnverifiedContact({
|
|
478
|
-
email: (c = (
|
|
479
|
-
non_verified_name: (
|
|
622
|
+
email: (c = (i = this.config.user) == null ? void 0 : i.data) == null ? void 0 : c.email,
|
|
623
|
+
non_verified_name: (_ = (d = this.config.user) == null ? void 0 : d.data) == null ? void 0 : _.name,
|
|
480
624
|
non_verified_custom_data: (u = (p = this.config.user) == null ? void 0 : p.data) == null ? void 0 : u.customData
|
|
481
625
|
}), !!((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: (
|
|
626
|
+
}, this.setUnverifiedContact = async (l) => {
|
|
627
|
+
var i, c, d, _;
|
|
628
|
+
const s = await ((i = this.storageCtx) == null ? void 0 : i.getExternalContactId()), a = ((c = this.config.user) == null ? void 0 : c.externalId) || s || N();
|
|
629
|
+
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 } });
|
|
630
|
+
}, this.config = e, this.storageCtx = o, this.api = t, this.state = new S({
|
|
631
|
+
contact: (r = e.user) != null && r.token ? {
|
|
488
632
|
token: e.user.token,
|
|
489
633
|
// Set optional externalId from config... not local storage
|
|
490
634
|
externalId: e.user.externalId
|
|
@@ -495,97 +639,97 @@ class le {
|
|
|
495
639
|
}), this.autoCreateUnverifiedUserIfNotExists();
|
|
496
640
|
}
|
|
497
641
|
}
|
|
498
|
-
class
|
|
642
|
+
class ke {
|
|
499
643
|
constructor(e) {
|
|
500
|
-
this.api = e, this.state = new
|
|
501
|
-
const
|
|
502
|
-
(
|
|
503
|
-
file:
|
|
504
|
-
id:
|
|
644
|
+
this.api = e, this.state = new S([]), this.controllers = /* @__PURE__ */ new Map(), this.appendFiles = (t) => {
|
|
645
|
+
const o = t.map(
|
|
646
|
+
(r) => ({
|
|
647
|
+
file: r,
|
|
648
|
+
id: N(),
|
|
505
649
|
status: "pending",
|
|
506
650
|
progress: 0
|
|
507
651
|
})
|
|
508
652
|
);
|
|
509
|
-
this.state.set([...this.state.get(), ...
|
|
510
|
-
}, this.cancel = (
|
|
511
|
-
var
|
|
512
|
-
(
|
|
653
|
+
this.state.set([...this.state.get(), ...o]), o.forEach((r) => void this.upload(r));
|
|
654
|
+
}, this.cancel = (t) => {
|
|
655
|
+
var o;
|
|
656
|
+
(o = this.controllers.get(t)) == null || o.abort(), this.controllers.delete(t), this.state.set(this.state.get().filter((r) => r.id !== t));
|
|
513
657
|
}, this.reset = () => {
|
|
514
|
-
this.controllers.forEach((
|
|
658
|
+
this.controllers.forEach((t) => t.abort()), this.controllers.clear(), this.state.reset();
|
|
515
659
|
};
|
|
516
660
|
}
|
|
517
|
-
update(e,
|
|
661
|
+
update(e, t) {
|
|
518
662
|
this.state.set(
|
|
519
|
-
this.state.get().map((
|
|
663
|
+
this.state.get().map((o) => o.id === e ? { ...o, ...t } : o)
|
|
520
664
|
);
|
|
521
665
|
}
|
|
522
666
|
async upload(e) {
|
|
523
|
-
const
|
|
524
|
-
this.controllers.set(e.id,
|
|
667
|
+
const t = new AbortController();
|
|
668
|
+
this.controllers.set(e.id, t), this.update(e.id, { status: "uploading" });
|
|
525
669
|
try {
|
|
526
|
-
const
|
|
670
|
+
const o = await this.api.uploadFile({
|
|
527
671
|
file: e.file,
|
|
528
|
-
abortSignal:
|
|
529
|
-
onProgress: (
|
|
672
|
+
abortSignal: t.signal,
|
|
673
|
+
onProgress: (r) => this.update(e.id, { progress: r })
|
|
530
674
|
});
|
|
531
675
|
this.update(e.id, {
|
|
532
676
|
status: "success",
|
|
533
|
-
fileUrl:
|
|
677
|
+
fileUrl: o.fileUrl,
|
|
534
678
|
progress: 100
|
|
535
679
|
});
|
|
536
|
-
} catch (
|
|
537
|
-
|
|
680
|
+
} catch (o) {
|
|
681
|
+
t.signal.aborted || this.update(e.id, {
|
|
538
682
|
status: "error",
|
|
539
683
|
progress: 0,
|
|
540
|
-
error:
|
|
684
|
+
error: o instanceof Error ? o.message : "Upload failed"
|
|
541
685
|
});
|
|
542
686
|
} finally {
|
|
543
687
|
this.controllers.delete(e.id);
|
|
544
688
|
}
|
|
545
689
|
}
|
|
546
690
|
}
|
|
547
|
-
function
|
|
548
|
-
return
|
|
691
|
+
function x() {
|
|
692
|
+
return N();
|
|
549
693
|
}
|
|
550
|
-
class
|
|
694
|
+
class be {
|
|
551
695
|
constructor({
|
|
552
696
|
api: e,
|
|
553
|
-
sessionCtx:
|
|
554
|
-
messageCtx:
|
|
697
|
+
sessionCtx: t,
|
|
698
|
+
messageCtx: o
|
|
555
699
|
}) {
|
|
556
|
-
this.submitCsat = async (
|
|
700
|
+
this.submitCsat = async (r) => {
|
|
557
701
|
var c;
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
702
|
+
const l = (c = this.sessionCtx.sessionState.get().session) == null ? void 0 : c.id;
|
|
703
|
+
if (!l)
|
|
560
704
|
return { data: null, error: "No session id found" };
|
|
561
|
-
const
|
|
705
|
+
const s = x();
|
|
562
706
|
this.messageCtx.state.setPartial({
|
|
563
707
|
messages: [
|
|
564
708
|
...this.messageCtx.state.get().messages,
|
|
565
709
|
{
|
|
566
|
-
id:
|
|
710
|
+
id: s,
|
|
567
711
|
type: "SYSTEM",
|
|
568
712
|
subtype: "csat_submitted",
|
|
569
713
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
570
714
|
data: {
|
|
571
715
|
payload: {
|
|
572
|
-
score:
|
|
573
|
-
feedback:
|
|
716
|
+
score: r.score,
|
|
717
|
+
feedback: r.feedback
|
|
574
718
|
}
|
|
575
719
|
}
|
|
576
720
|
}
|
|
577
721
|
]
|
|
578
722
|
});
|
|
579
|
-
const { data:
|
|
580
|
-
...
|
|
581
|
-
system_message_uuid:
|
|
582
|
-
session_id:
|
|
723
|
+
const { data: a, error: i } = await this.api.submitCsat({
|
|
724
|
+
...r,
|
|
725
|
+
system_message_uuid: s,
|
|
726
|
+
session_id: l
|
|
583
727
|
});
|
|
584
|
-
return { data:
|
|
585
|
-
}, this.api = e, this.sessionCtx =
|
|
728
|
+
return { data: a, error: i };
|
|
729
|
+
}, this.api = e, this.sessionCtx = t, this.messageCtx = o;
|
|
586
730
|
}
|
|
587
731
|
}
|
|
588
|
-
const
|
|
732
|
+
const ve = [
|
|
589
733
|
{
|
|
590
734
|
action: "newparagraph",
|
|
591
735
|
phrases: {
|
|
@@ -660,7 +804,7 @@ const de = [
|
|
|
660
804
|
it: ["invia messaggio"]
|
|
661
805
|
}
|
|
662
806
|
}
|
|
663
|
-
],
|
|
807
|
+
], fe = [
|
|
664
808
|
"en",
|
|
665
809
|
"es",
|
|
666
810
|
"fr",
|
|
@@ -668,104 +812,104 @@ const de = [
|
|
|
668
812
|
"pt",
|
|
669
813
|
"it"
|
|
670
814
|
];
|
|
671
|
-
function
|
|
672
|
-
return
|
|
815
|
+
function ye(n) {
|
|
816
|
+
return fe.includes(n);
|
|
673
817
|
}
|
|
674
|
-
function
|
|
675
|
-
return
|
|
818
|
+
function we(n) {
|
|
819
|
+
return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
676
820
|
}
|
|
677
|
-
function
|
|
678
|
-
const e =
|
|
679
|
-
(
|
|
680
|
-
(
|
|
821
|
+
function je(n) {
|
|
822
|
+
const e = ve.flatMap(
|
|
823
|
+
(r) => n.flatMap(
|
|
824
|
+
(l) => r.phrases[l].map((s) => ({ phrase: s, action: r.action }))
|
|
681
825
|
)
|
|
682
|
-
),
|
|
826
|
+
), 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
827
|
return {
|
|
684
828
|
regex: new RegExp(
|
|
685
|
-
`${
|
|
829
|
+
`${o}(${t})` + String.raw`([.,!?;:])(?=\s|$)`,
|
|
686
830
|
"giu"
|
|
687
831
|
),
|
|
688
832
|
finalRegex: new RegExp(
|
|
689
|
-
`${
|
|
833
|
+
`${o}(${t})` + String.raw`([.,!?;:]?)(?=\s|$)`,
|
|
690
834
|
"giu"
|
|
691
835
|
),
|
|
692
836
|
phraseToAction: new Map(
|
|
693
|
-
e.map((
|
|
837
|
+
e.map((r) => [r.phrase.toLowerCase(), r.action])
|
|
694
838
|
),
|
|
695
|
-
longestPhrase: Math.max(...e.map((
|
|
839
|
+
longestPhrase: Math.max(...e.map((r) => r.phrase.length))
|
|
696
840
|
};
|
|
697
841
|
}
|
|
698
|
-
const
|
|
699
|
-
function
|
|
700
|
-
const e =
|
|
701
|
-
let
|
|
702
|
-
return
|
|
842
|
+
const V = /* @__PURE__ */ new Map();
|
|
843
|
+
function I(n) {
|
|
844
|
+
const e = n && ye(n) && n !== "en" ? n : null, t = e ?? "en";
|
|
845
|
+
let o = V.get(t);
|
|
846
|
+
return o || (o = je(e ? ["en", e] : ["en"]), V.set(t, o)), o;
|
|
703
847
|
}
|
|
704
|
-
function
|
|
705
|
-
const e =
|
|
848
|
+
function Se(n) {
|
|
849
|
+
const e = n.replace(/\s+$/, "");
|
|
706
850
|
if (!e) return "";
|
|
707
|
-
const
|
|
708
|
-
let
|
|
709
|
-
for (let
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
851
|
+
const t = e.replace(/[.!?]+$/, "");
|
|
852
|
+
let o = -1;
|
|
853
|
+
for (let r = t.length - 1; r >= 0; r--) {
|
|
854
|
+
const l = t[r];
|
|
855
|
+
if (l === "." || l === "!" || l === "?" || l === `
|
|
712
856
|
`) {
|
|
713
|
-
|
|
857
|
+
o = r + 1;
|
|
714
858
|
break;
|
|
715
859
|
}
|
|
716
860
|
}
|
|
717
|
-
return
|
|
861
|
+
return o === -1 ? "" : `${t.slice(0, o)} `.replace(/\n $/, `
|
|
718
862
|
`);
|
|
719
863
|
}
|
|
720
|
-
const
|
|
864
|
+
const ze = new RegExp(
|
|
721
865
|
String.raw`(^- |\n(?:- )?)(\p{Ll})`,
|
|
722
866
|
"gu"
|
|
723
867
|
);
|
|
724
|
-
function
|
|
725
|
-
return
|
|
726
|
-
|
|
727
|
-
(e,
|
|
868
|
+
function Ce(n) {
|
|
869
|
+
return n.replace(
|
|
870
|
+
ze,
|
|
871
|
+
(e, t, o) => t + o.toUpperCase()
|
|
728
872
|
);
|
|
729
873
|
}
|
|
730
|
-
function
|
|
731
|
-
return
|
|
874
|
+
function xe(n) {
|
|
875
|
+
return n.length <= 3 && /^\s*$/.test(n) ? !0 : /[.!?\n]\s{0,3}$/.test(n.slice(-6));
|
|
732
876
|
}
|
|
733
|
-
class
|
|
877
|
+
class q {
|
|
734
878
|
/**
|
|
735
879
|
* Process the full raw transcript accumulated so far into insertable text.
|
|
736
880
|
* Pure and deterministic: always called with the entire raw string so the
|
|
737
881
|
* result never depends on delta chunking.
|
|
738
882
|
*/
|
|
739
|
-
static process(e,
|
|
740
|
-
const
|
|
741
|
-
let
|
|
742
|
-
for (const
|
|
743
|
-
const [, p = ""] =
|
|
883
|
+
static process(e, t) {
|
|
884
|
+
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;
|
|
885
|
+
let a = "", i = null, c = 0;
|
|
886
|
+
for (const _ of Array.from(l.matchAll(s))) {
|
|
887
|
+
const [, p = ""] = _, u = o.phraseToAction.get(p.toLowerCase());
|
|
744
888
|
if (u)
|
|
745
|
-
if (
|
|
889
|
+
if (a += l.slice(c, _.index), c = _.index + _[0].length, u === "newline") a = `${a.replace(/[ \t]+$/, "")}
|
|
746
890
|
`;
|
|
747
891
|
else if (u === "newparagraph")
|
|
748
|
-
|
|
892
|
+
a = `${a.replace(/[ \t]+$/, "")}
|
|
749
893
|
|
|
750
894
|
`;
|
|
751
895
|
else if (u === "bullet") {
|
|
752
|
-
const m =
|
|
753
|
-
|
|
896
|
+
const m = a.replace(/[ \t]+$/, "");
|
|
897
|
+
a = m === "" || m.endsWith(`
|
|
754
898
|
`) ? `${m}- ` : `${m}
|
|
755
899
|
- `;
|
|
756
|
-
} else if (u === "scratch")
|
|
900
|
+
} else if (u === "scratch") a = Se(a);
|
|
757
901
|
else {
|
|
758
|
-
|
|
902
|
+
i = u === "send" ? "send" : "stop";
|
|
759
903
|
break;
|
|
760
904
|
}
|
|
761
905
|
}
|
|
762
|
-
return
|
|
763
|
-
|
|
906
|
+
return i === null && (a += l.slice(c)), { text: Ce(
|
|
907
|
+
a.replace(/^\s+/, "").replace(/[ \t]+\n/g, `
|
|
764
908
|
`).replace(/\n[ \t]+/g, `
|
|
765
909
|
`).replace(/(^|\n)- +/g, "$1- ").replace(/ {2,}/g, " ").replace(/\n{3,}/g, `
|
|
766
910
|
|
|
767
911
|
`)
|
|
768
|
-
), pendingTail:
|
|
912
|
+
), pendingTail: r, control: i };
|
|
769
913
|
}
|
|
770
914
|
/**
|
|
771
915
|
* Longest suffix of `raw` that could still become a command — a proper
|
|
@@ -776,16 +920,16 @@ class C {
|
|
|
776
920
|
* control command from an intermediate delta would stop or submit
|
|
777
921
|
* mid-sentence.
|
|
778
922
|
*/
|
|
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(
|
|
923
|
+
static commandPrefixTail(e, t) {
|
|
924
|
+
const o = I(t), r = Math.min(e.length, o.longestPhrase + 2);
|
|
925
|
+
for (let l = r; l > 0; l--) {
|
|
926
|
+
const s = e.length - l;
|
|
927
|
+
if (!xe(e.slice(0, s))) continue;
|
|
928
|
+
const a = e.slice(s).toLowerCase(), i = a.replace(/^\s+/, "");
|
|
929
|
+
if (i) {
|
|
930
|
+
for (const c of Array.from(o.phraseToAction.keys()))
|
|
931
|
+
if (c.startsWith(i))
|
|
932
|
+
return e.slice(s + (a.length - i.length));
|
|
789
933
|
}
|
|
790
934
|
}
|
|
791
935
|
return "";
|
|
@@ -795,13 +939,13 @@ class C {
|
|
|
795
939
|
* prefix) — i.e. a silence pause would resolve it into a command. Used by
|
|
796
940
|
* the manager's silence timer.
|
|
797
941
|
*/
|
|
798
|
-
static pendingTailIsCompletePhrase(e,
|
|
799
|
-
const
|
|
800
|
-
return
|
|
942
|
+
static pendingTailIsCompletePhrase(e, t) {
|
|
943
|
+
const o = q.commandPrefixTail(e, t).trim().toLowerCase();
|
|
944
|
+
return o ? I(t).phraseToAction.has(o) : !1;
|
|
801
945
|
}
|
|
802
946
|
}
|
|
803
|
-
const
|
|
804
|
-
class
|
|
947
|
+
const qe = 55, Ee = 90;
|
|
948
|
+
class H {
|
|
805
949
|
/**
|
|
806
950
|
* Next paced step toward `processed`: normally one word per tick so text
|
|
807
951
|
* flows evenly instead of landing in bursty chunks; proportionally larger
|
|
@@ -810,28 +954,28 @@ class B {
|
|
|
810
954
|
*/
|
|
811
955
|
static nextDripText({
|
|
812
956
|
displayed: e,
|
|
813
|
-
processed:
|
|
957
|
+
processed: t
|
|
814
958
|
}) {
|
|
815
|
-
if (
|
|
816
|
-
const
|
|
817
|
-
if (
|
|
818
|
-
return
|
|
819
|
-
let
|
|
820
|
-
for (;
|
|
821
|
-
for (;
|
|
822
|
-
return
|
|
959
|
+
if (t.length <= e.length) return t;
|
|
960
|
+
const o = t.length - e.length;
|
|
961
|
+
if (o > Ee)
|
|
962
|
+
return t.slice(0, e.length + Math.ceil(o / 3));
|
|
963
|
+
let r = e.length;
|
|
964
|
+
for (; r < t.length && /\s/.test(t.charAt(r)); ) r++;
|
|
965
|
+
for (; r < t.length && !/\s/.test(t.charAt(r)); ) r++;
|
|
966
|
+
return r - e.length > 12 && (r = e.length + 6), t.slice(0, Math.max(r, e.length + 1));
|
|
823
967
|
}
|
|
824
968
|
/** Normalize a BCP-47 browser locale into the hint OpenAI accepts. */
|
|
825
969
|
static languageHint(e) {
|
|
826
970
|
if (!e) return;
|
|
827
|
-
const
|
|
828
|
-
if (/^zh-(cn|tw|hk)$/.test(
|
|
829
|
-
const
|
|
830
|
-
return
|
|
971
|
+
const t = e.toLowerCase();
|
|
972
|
+
if (/^zh-(cn|tw|hk)$/.test(t)) return t;
|
|
973
|
+
const o = t.split("-")[0];
|
|
974
|
+
return o && /^[a-z]{2,3}$/.test(o) ? o : void 0;
|
|
831
975
|
}
|
|
832
976
|
}
|
|
833
|
-
const
|
|
834
|
-
class
|
|
977
|
+
const Ae = 2e4;
|
|
978
|
+
class Pe {
|
|
835
979
|
constructor() {
|
|
836
980
|
this.cached = null, this.inflight = null;
|
|
837
981
|
}
|
|
@@ -839,15 +983,15 @@ class Se {
|
|
|
839
983
|
get() {
|
|
840
984
|
if (!this.cached) return null;
|
|
841
985
|
const e = Date.parse(this.cached.expiresAt);
|
|
842
|
-
return Number.isNaN(e) || e - Date.now() <
|
|
986
|
+
return Number.isNaN(e) || e - Date.now() < Ae ? (this.cached = null, null) : this.cached;
|
|
843
987
|
}
|
|
844
988
|
/**
|
|
845
989
|
* Resolve a mint, deduping concurrent requests (hover-prewarm racing a
|
|
846
990
|
* click reuses the same in-flight promise instead of double-minting).
|
|
847
991
|
*/
|
|
848
992
|
async resolve(e) {
|
|
849
|
-
const
|
|
850
|
-
return
|
|
993
|
+
const t = this.get();
|
|
994
|
+
return t || (this.inflight || (this.inflight = e().then((o) => (this.cached = o, o)).finally(() => {
|
|
851
995
|
this.inflight = null;
|
|
852
996
|
})), this.inflight);
|
|
853
997
|
}
|
|
@@ -856,89 +1000,89 @@ class Se {
|
|
|
856
1000
|
this.cached = null;
|
|
857
1001
|
}
|
|
858
1002
|
}
|
|
859
|
-
function
|
|
860
|
-
return typeof
|
|
1003
|
+
function Z(n) {
|
|
1004
|
+
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
861
1005
|
}
|
|
862
|
-
function
|
|
863
|
-
if (!
|
|
864
|
-
const e =
|
|
1006
|
+
function Te(n) {
|
|
1007
|
+
if (!Z(n) || typeof n.type != "string") return null;
|
|
1008
|
+
const e = Z(n.error) ? n.error : null;
|
|
865
1009
|
return {
|
|
866
|
-
type:
|
|
867
|
-
delta: typeof
|
|
1010
|
+
type: n.type,
|
|
1011
|
+
delta: typeof n.delta == "string" ? n.delta : void 0,
|
|
868
1012
|
errorMessage: e && typeof e.message == "string" ? e.message : void 0
|
|
869
1013
|
};
|
|
870
1014
|
}
|
|
871
|
-
const
|
|
872
|
-
class
|
|
1015
|
+
const Ie = "https://api.openai.com/v1/realtime/calls", Me = 600 * 1e3, De = 15e3, Ne = 5e3;
|
|
1016
|
+
class P extends Error {
|
|
873
1017
|
}
|
|
874
|
-
class
|
|
1018
|
+
class Re {
|
|
875
1019
|
constructor({
|
|
876
1020
|
mintToken: e,
|
|
877
|
-
onDelta:
|
|
878
|
-
onState:
|
|
879
|
-
onError:
|
|
880
|
-
onLevel:
|
|
1021
|
+
onDelta: t,
|
|
1022
|
+
onState: o,
|
|
1023
|
+
onError: r,
|
|
1024
|
+
onLevel: l
|
|
881
1025
|
}) {
|
|
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 =
|
|
1026
|
+
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
1027
|
}
|
|
884
1028
|
async start() {
|
|
885
1029
|
if (this.state === "idle") {
|
|
886
1030
|
this.setState("connecting"), this.timers.push(
|
|
887
1031
|
setTimeout(() => {
|
|
888
1032
|
this.state === "connecting" && this.fail("unavailable");
|
|
889
|
-
},
|
|
890
|
-
), this.timers.push(setTimeout(() => this.stop(),
|
|
1033
|
+
}, De)
|
|
1034
|
+
), this.timers.push(setTimeout(() => this.stop(), Me));
|
|
891
1035
|
try {
|
|
892
1036
|
const e = this.requestMicrophone();
|
|
893
1037
|
e.then((d) => {
|
|
894
|
-
(this.isTornDown() || this.stream && this.stream !== d) && d.getTracks().forEach((
|
|
1038
|
+
(this.isTornDown() || this.stream && this.stream !== d) && d.getTracks().forEach((_) => _.stop());
|
|
895
1039
|
}).catch(() => {
|
|
896
1040
|
});
|
|
897
|
-
const [
|
|
1041
|
+
const [t, o] = await Promise.all([e, this.mintToken()]);
|
|
898
1042
|
if (this.isTornDown()) {
|
|
899
|
-
|
|
1043
|
+
t.getTracks().forEach((d) => d.stop());
|
|
900
1044
|
return;
|
|
901
1045
|
}
|
|
902
|
-
this.stream =
|
|
903
|
-
const
|
|
904
|
-
this.pc =
|
|
905
|
-
const [
|
|
906
|
-
if (!
|
|
907
|
-
|
|
908
|
-
const
|
|
909
|
-
this.dc =
|
|
1046
|
+
this.stream = t, this.startLevelMeter(t);
|
|
1047
|
+
const r = new RTCPeerConnection();
|
|
1048
|
+
this.pc = r;
|
|
1049
|
+
const [l] = t.getAudioTracks();
|
|
1050
|
+
if (!l) throw new P("No audio track");
|
|
1051
|
+
r.addTrack(l, t);
|
|
1052
|
+
const s = r.createDataChannel("oai-events");
|
|
1053
|
+
this.dc = s, s.addEventListener(
|
|
910
1054
|
"message",
|
|
911
1055
|
(d) => this.handleServerEvent(d.data)
|
|
912
|
-
),
|
|
1056
|
+
), s.addEventListener("open", () => {
|
|
913
1057
|
this.state === "connecting" && this.setState("listening");
|
|
914
|
-
}),
|
|
915
|
-
if (
|
|
1058
|
+
}), r.addEventListener("connectionstatechange", () => {
|
|
1059
|
+
if (r.connectionState === "failed") {
|
|
916
1060
|
this.fail("unavailable");
|
|
917
1061
|
return;
|
|
918
1062
|
}
|
|
919
|
-
|
|
1063
|
+
r.connectionState === "disconnected" && this.timers.push(
|
|
920
1064
|
setTimeout(() => {
|
|
921
|
-
this.pc ===
|
|
922
|
-
},
|
|
1065
|
+
this.pc === r && r.connectionState !== "connected" && this.fail("unavailable");
|
|
1066
|
+
}, Ne)
|
|
923
1067
|
);
|
|
924
1068
|
});
|
|
925
|
-
const
|
|
926
|
-
await
|
|
927
|
-
const
|
|
1069
|
+
const a = await r.createOffer();
|
|
1070
|
+
await r.setLocalDescription(a);
|
|
1071
|
+
const i = await fetch(Ie, {
|
|
928
1072
|
method: "POST",
|
|
929
1073
|
headers: {
|
|
930
|
-
Authorization: `Bearer ${
|
|
1074
|
+
Authorization: `Bearer ${o.token}`,
|
|
931
1075
|
"Content-Type": "application/sdp"
|
|
932
1076
|
},
|
|
933
|
-
body:
|
|
1077
|
+
body: a.sdp
|
|
934
1078
|
});
|
|
935
|
-
if (!
|
|
936
|
-
throw new Error(`Realtime handshake failed (${
|
|
937
|
-
const c = await
|
|
1079
|
+
if (!i.ok)
|
|
1080
|
+
throw new Error(`Realtime handshake failed (${i.status})`);
|
|
1081
|
+
const c = await i.text();
|
|
938
1082
|
if (this.isTornDown()) return;
|
|
939
|
-
await
|
|
1083
|
+
await r.setRemoteDescription({ type: "answer", sdp: c });
|
|
940
1084
|
} catch (e) {
|
|
941
|
-
e instanceof
|
|
1085
|
+
e instanceof P ? this.fail("microphone") : (k.error("dictation session failed to start", {
|
|
942
1086
|
_e: e instanceof Error ? e.message : String(e)
|
|
943
1087
|
}), this.fail("unavailable"));
|
|
944
1088
|
}
|
|
@@ -950,7 +1094,7 @@ class Ae {
|
|
|
950
1094
|
async requestMicrophone() {
|
|
951
1095
|
var e;
|
|
952
1096
|
if (!((e = navigator.mediaDevices) != null && e.getUserMedia))
|
|
953
|
-
throw new
|
|
1097
|
+
throw new P("Microphone is not supported");
|
|
954
1098
|
try {
|
|
955
1099
|
return await navigator.mediaDevices.getUserMedia({
|
|
956
1100
|
audio: {
|
|
@@ -959,60 +1103,60 @@ class Ae {
|
|
|
959
1103
|
autoGainControl: !0
|
|
960
1104
|
}
|
|
961
1105
|
});
|
|
962
|
-
} catch (
|
|
963
|
-
throw new
|
|
964
|
-
|
|
1106
|
+
} catch (t) {
|
|
1107
|
+
throw new P(
|
|
1108
|
+
t instanceof DOMException ? t.name : "Could not access the microphone"
|
|
965
1109
|
);
|
|
966
1110
|
}
|
|
967
1111
|
}
|
|
968
1112
|
handleServerEvent(e) {
|
|
969
1113
|
if (typeof e != "string") return;
|
|
970
|
-
let
|
|
1114
|
+
let t;
|
|
971
1115
|
try {
|
|
972
|
-
|
|
1116
|
+
t = JSON.parse(e);
|
|
973
1117
|
} catch {
|
|
974
|
-
this.loggedParseFailure || (this.loggedParseFailure = !0,
|
|
1118
|
+
this.loggedParseFailure || (this.loggedParseFailure = !0, k.error("dictation server event was not valid JSON", {
|
|
975
1119
|
snippet: e.slice(0, 120)
|
|
976
1120
|
}));
|
|
977
1121
|
return;
|
|
978
1122
|
}
|
|
979
|
-
const
|
|
980
|
-
if (!
|
|
981
|
-
const { type:
|
|
982
|
-
if (
|
|
1123
|
+
const o = Te(t);
|
|
1124
|
+
if (!o) return;
|
|
1125
|
+
const { type: r, delta: l } = o;
|
|
1126
|
+
if (r === "session.created" || r === "transcription_session.created") {
|
|
983
1127
|
this.setState("listening");
|
|
984
1128
|
return;
|
|
985
1129
|
}
|
|
986
|
-
if (
|
|
987
|
-
this.state === "connecting" && this.setState("listening"), this.onDelta(
|
|
1130
|
+
if (r === "conversation.item.input_audio_transcription.delta" && l) {
|
|
1131
|
+
this.state === "connecting" && this.setState("listening"), this.onDelta(l);
|
|
988
1132
|
return;
|
|
989
1133
|
}
|
|
990
|
-
|
|
991
|
-
_e:
|
|
1134
|
+
r === "error" && (k.error("dictation server event error", {
|
|
1135
|
+
_e: o.errorMessage ?? "unknown"
|
|
992
1136
|
}), this.fail("unavailable"));
|
|
993
1137
|
}
|
|
994
1138
|
startLevelMeter(e) {
|
|
995
1139
|
if (this.onLevel)
|
|
996
1140
|
try {
|
|
997
|
-
const
|
|
998
|
-
this.audioContext =
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
const
|
|
1141
|
+
const t = new AudioContext();
|
|
1142
|
+
this.audioContext = t;
|
|
1143
|
+
const o = t.createMediaStreamSource(e), r = t.createAnalyser();
|
|
1144
|
+
r.fftSize = 512, o.connect(r);
|
|
1145
|
+
const l = new Uint8Array(r.frequencyBinCount), s = () => {
|
|
1002
1146
|
var c;
|
|
1003
|
-
|
|
1004
|
-
let
|
|
1005
|
-
for (let d = 0; d <
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1147
|
+
r.getByteTimeDomainData(l);
|
|
1148
|
+
let a = 0;
|
|
1149
|
+
for (let d = 0; d < l.length; d++) {
|
|
1150
|
+
const _ = ((l[d] ?? 128) - 128) / 128;
|
|
1151
|
+
a += _ * _;
|
|
1008
1152
|
}
|
|
1009
|
-
const
|
|
1010
|
-
(c = this.onLevel) == null || c.call(this, Math.min(1,
|
|
1153
|
+
const i = Math.sqrt(a / l.length);
|
|
1154
|
+
(c = this.onLevel) == null || c.call(this, Math.min(1, i * 4)), this.levelRaf = requestAnimationFrame(s);
|
|
1011
1155
|
};
|
|
1012
|
-
this.levelRaf = requestAnimationFrame(
|
|
1013
|
-
} catch (
|
|
1014
|
-
|
|
1015
|
-
_e:
|
|
1156
|
+
this.levelRaf = requestAnimationFrame(s);
|
|
1157
|
+
} catch (t) {
|
|
1158
|
+
k.error("dictation level meter unavailable", {
|
|
1159
|
+
_e: t instanceof Error ? t.message : String(t)
|
|
1016
1160
|
});
|
|
1017
1161
|
}
|
|
1018
1162
|
}
|
|
@@ -1023,10 +1167,10 @@ class Ae {
|
|
|
1023
1167
|
this.isTornDown() || (this.teardown(), this.setState("error"), this.onError(e));
|
|
1024
1168
|
}
|
|
1025
1169
|
teardown() {
|
|
1026
|
-
var e,
|
|
1027
|
-
this.timers.forEach((
|
|
1028
|
-
|
|
1029
|
-
_e: String(
|
|
1170
|
+
var e, t, o, r;
|
|
1171
|
+
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) => {
|
|
1172
|
+
k.error("failed to close dictation audio context", {
|
|
1173
|
+
_e: String(l)
|
|
1030
1174
|
});
|
|
1031
1175
|
}), this.audioContext = null;
|
|
1032
1176
|
}
|
|
@@ -1034,76 +1178,76 @@ class Ae {
|
|
|
1034
1178
|
this.state !== e && (this.state = e, this.onState(e));
|
|
1035
1179
|
}
|
|
1036
1180
|
}
|
|
1037
|
-
const
|
|
1038
|
-
class
|
|
1039
|
-
constructor({ api: e, config:
|
|
1040
|
-
this.state = new
|
|
1041
|
-
this.mintToken().catch((
|
|
1042
|
-
this.mintCache.clear(),
|
|
1043
|
-
_e:
|
|
1181
|
+
const Ke = 1300, Le = { status: "idle", error: null };
|
|
1182
|
+
class Fe {
|
|
1183
|
+
constructor({ api: e, config: t }) {
|
|
1184
|
+
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 = () => {
|
|
1185
|
+
this.mintToken().catch((o) => {
|
|
1186
|
+
this.mintCache.clear(), k.error("dictation token prewarm failed", {
|
|
1187
|
+
_e: o instanceof Error ? o.message : String(o)
|
|
1044
1188
|
});
|
|
1045
1189
|
});
|
|
1046
|
-
}, this.start = (
|
|
1047
|
-
this.session && this.teardown(), this.target =
|
|
1190
|
+
}, this.start = (o) => {
|
|
1191
|
+
this.session && this.teardown(), this.target = o, this.language = H.languageHint(
|
|
1048
1192
|
this.config.language ?? navigator.language
|
|
1049
|
-
), this.prefix =
|
|
1050
|
-
const
|
|
1193
|
+
), this.prefix = o.getValue(), this.raw = "", this.processed = "", this.displayed = "";
|
|
1194
|
+
const r = new Re({
|
|
1051
1195
|
mintToken: this.mintToken,
|
|
1052
|
-
onLevel: (
|
|
1053
|
-
this.levelRef.current =
|
|
1196
|
+
onLevel: (l) => {
|
|
1197
|
+
this.levelRef.current = l;
|
|
1054
1198
|
},
|
|
1055
|
-
onState: (
|
|
1056
|
-
|
|
1199
|
+
onState: (l) => {
|
|
1200
|
+
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
1201
|
},
|
|
1058
|
-
onError: (
|
|
1059
|
-
|
|
1202
|
+
onError: (l) => {
|
|
1203
|
+
r === this.session && (this.mintCache.clear(), this.teardown({ error: l, executeFinalCommand: !1 }));
|
|
1060
1204
|
},
|
|
1061
|
-
onDelta: (
|
|
1062
|
-
if (
|
|
1205
|
+
onDelta: (l) => {
|
|
1206
|
+
if (r !== this.session || !this.target) return;
|
|
1063
1207
|
if (!this.isConsistent()) {
|
|
1064
1208
|
this.teardown();
|
|
1065
1209
|
return;
|
|
1066
1210
|
}
|
|
1067
|
-
this.raw +=
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1211
|
+
this.raw += l;
|
|
1212
|
+
const s = this.ingest();
|
|
1213
|
+
if (s === "stop") {
|
|
1070
1214
|
this.teardown();
|
|
1071
1215
|
return;
|
|
1072
1216
|
}
|
|
1073
|
-
if (
|
|
1217
|
+
if (s === "send") {
|
|
1074
1218
|
this.teardown({ send: !0 });
|
|
1075
1219
|
return;
|
|
1076
1220
|
}
|
|
1077
|
-
this.stopSilenceTimer(),
|
|
1221
|
+
this.stopSilenceTimer(), q.pendingTailIsCompletePhrase(
|
|
1078
1222
|
this.raw,
|
|
1079
1223
|
this.language
|
|
1080
1224
|
) && (this.silenceTimer = setTimeout(() => {
|
|
1081
|
-
if (
|
|
1225
|
+
if (r !== this.session) return;
|
|
1082
1226
|
this.raw = `${this.raw}.`;
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
},
|
|
1227
|
+
const a = this.ingest();
|
|
1228
|
+
a === "stop" ? this.teardown() : a === "send" && this.teardown({ send: !0 });
|
|
1229
|
+
}, Ke));
|
|
1086
1230
|
}
|
|
1087
1231
|
});
|
|
1088
|
-
this.session =
|
|
1232
|
+
this.session = r, this.state.set({ status: "connecting", error: null }), this.dripTimer = setInterval(() => {
|
|
1089
1233
|
if (this.target && this.processed !== this.displayed) {
|
|
1090
1234
|
if (!this.isConsistent()) {
|
|
1091
1235
|
this.teardown();
|
|
1092
1236
|
return;
|
|
1093
1237
|
}
|
|
1094
1238
|
this.applyDisplayed(
|
|
1095
|
-
|
|
1239
|
+
H.nextDripText({
|
|
1096
1240
|
displayed: this.displayed,
|
|
1097
1241
|
processed: this.processed
|
|
1098
1242
|
})
|
|
1099
1243
|
);
|
|
1100
1244
|
}
|
|
1101
|
-
},
|
|
1245
|
+
}, qe), r.start();
|
|
1102
1246
|
}, this.stop = () => {
|
|
1103
1247
|
this.session && this.teardown();
|
|
1104
1248
|
}, this.mintToken = async () => this.mintCache.resolve(
|
|
1105
1249
|
() => this.api.createDictationSession({ language: this.language })
|
|
1106
|
-
), this.api = e, this.config =
|
|
1250
|
+
), this.api = e, this.config = t;
|
|
1107
1251
|
}
|
|
1108
1252
|
/** Applied text = prefix + dictated. A mismatch means the visitor edited. */
|
|
1109
1253
|
isConsistent() {
|
|
@@ -1115,28 +1259,28 @@ class Me {
|
|
|
1115
1259
|
/** Process the transcript and apply the outcome. Shared by the delta path,
|
|
1116
1260
|
* the silence timer, and (with `final`) teardown. Returns the control. */
|
|
1117
1261
|
ingest(e) {
|
|
1118
|
-
const
|
|
1262
|
+
const t = q.process(this.raw, {
|
|
1119
1263
|
language: this.language,
|
|
1120
1264
|
final: e == null ? void 0 : e.final
|
|
1121
1265
|
});
|
|
1122
|
-
return this.processed =
|
|
1266
|
+
return this.processed = t.text, t.text.startsWith(this.displayed) || this.applyDisplayed(t.text), t.control;
|
|
1123
1267
|
}
|
|
1124
1268
|
stopSilenceTimer() {
|
|
1125
1269
|
this.silenceTimer && clearTimeout(this.silenceTimer), this.silenceTimer = null;
|
|
1126
1270
|
}
|
|
1127
1271
|
teardown(e) {
|
|
1128
|
-
var
|
|
1129
|
-
const
|
|
1272
|
+
var l;
|
|
1273
|
+
const t = this.session, o = this.target;
|
|
1130
1274
|
this.dripTimer && clearInterval(this.dripTimer), this.dripTimer = null, this.stopSilenceTimer();
|
|
1131
|
-
let
|
|
1132
|
-
if (
|
|
1133
|
-
const
|
|
1134
|
-
(e == null ? void 0 : e.executeFinalCommand) !== !1 &&
|
|
1275
|
+
let r = (e == null ? void 0 : e.send) ?? !1;
|
|
1276
|
+
if (o && this.isConsistent()) {
|
|
1277
|
+
const s = this.ingest({ final: !0 });
|
|
1278
|
+
(e == null ? void 0 : e.executeFinalCommand) !== !1 && s === "send" && (r = !0), this.processed !== this.displayed && this.applyDisplayed(this.processed);
|
|
1135
1279
|
}
|
|
1136
|
-
this.session = null, this.target = null,
|
|
1280
|
+
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
1281
|
}
|
|
1138
1282
|
}
|
|
1139
|
-
const
|
|
1283
|
+
const Oe = {
|
|
1140
1284
|
write_a_message_placeholder: "اكتب رسالة...",
|
|
1141
1285
|
your_issue_has_been_resolved: "تم حل مشكلتك!",
|
|
1142
1286
|
new_conversation: "محادثة جديدة",
|
|
@@ -1235,8 +1379,17 @@ const Ie = {
|
|
|
1235
1379
|
questions_next: "التالي",
|
|
1236
1380
|
questions_send: "إرسال",
|
|
1237
1381
|
questions_type_answer: "سأكتبها بنفسي",
|
|
1238
|
-
questions_answer_placeholder: "اكتب إجابتك…"
|
|
1239
|
-
|
|
1382
|
+
questions_answer_placeholder: "اكتب إجابتك…",
|
|
1383
|
+
close_conversation_title: "إغلاق المحادثة",
|
|
1384
|
+
close_conversation_description: "هل أنت متأكد أنك تريد إغلاق هذه المحادثة؟",
|
|
1385
|
+
close_conversation_cancel: "لا",
|
|
1386
|
+
close_conversation_confirm: "نعم",
|
|
1387
|
+
dialog_close: "إغلاق",
|
|
1388
|
+
zoom_in: "تكبير",
|
|
1389
|
+
zoom_out: "تصغير",
|
|
1390
|
+
reset_zoom: "إعادة تعيين التكبير",
|
|
1391
|
+
support_chat_aria_label: "دردشة الدعم"
|
|
1392
|
+
}, Ue = {
|
|
1240
1393
|
write_a_message_placeholder: "একটি বার্তা লিখুন...",
|
|
1241
1394
|
your_issue_has_been_resolved: "আপনার সমস্যা সমাধান হয়েছে!",
|
|
1242
1395
|
new_conversation: "নতুন কথোপকথন",
|
|
@@ -1323,8 +1476,17 @@ const Ie = {
|
|
|
1323
1476
|
questions_next: "পরবর্তী",
|
|
1324
1477
|
questions_send: "পাঠান",
|
|
1325
1478
|
questions_type_answer: "আমি লিখে দিচ্ছি",
|
|
1326
|
-
questions_answer_placeholder: "আপনার উত্তর লিখুন…"
|
|
1327
|
-
|
|
1479
|
+
questions_answer_placeholder: "আপনার উত্তর লিখুন…",
|
|
1480
|
+
close_conversation_title: "কথোপকথন বন্ধ করুন",
|
|
1481
|
+
close_conversation_description: "আপনি কি নিশ্চিত যে আপনি এই কথোপকথনটি বন্ধ করতে চান?",
|
|
1482
|
+
close_conversation_cancel: "না",
|
|
1483
|
+
close_conversation_confirm: "হ্যাঁ",
|
|
1484
|
+
dialog_close: "বন্ধ করুন",
|
|
1485
|
+
zoom_in: "বড় করুন",
|
|
1486
|
+
zoom_out: "ছোট করুন",
|
|
1487
|
+
reset_zoom: "জুম রিসেট করুন",
|
|
1488
|
+
support_chat_aria_label: "সাপোর্ট চ্যাট"
|
|
1489
|
+
}, Be = {
|
|
1328
1490
|
write_a_message_placeholder: "Напишете съобщение...",
|
|
1329
1491
|
your_issue_has_been_resolved: "Вашият проблем е разрешен!",
|
|
1330
1492
|
new_conversation: "Нов разговор",
|
|
@@ -1411,8 +1573,17 @@ const Ie = {
|
|
|
1411
1573
|
questions_next: "Напред",
|
|
1412
1574
|
questions_send: "Изпрати",
|
|
1413
1575
|
questions_type_answer: "Ще напиша сам",
|
|
1414
|
-
questions_answer_placeholder: "Напишете отговора си…"
|
|
1415
|
-
|
|
1576
|
+
questions_answer_placeholder: "Напишете отговора си…",
|
|
1577
|
+
close_conversation_title: "Затваряне на разговора",
|
|
1578
|
+
close_conversation_description: "Сигурни ли сте, че искате да затворите този разговор?",
|
|
1579
|
+
close_conversation_cancel: "Не",
|
|
1580
|
+
close_conversation_confirm: "Да",
|
|
1581
|
+
dialog_close: "Затваряне",
|
|
1582
|
+
zoom_in: "Увеличаване",
|
|
1583
|
+
zoom_out: "Намаляване",
|
|
1584
|
+
reset_zoom: "Нулиране на мащаба",
|
|
1585
|
+
support_chat_aria_label: "Чат за поддръжка"
|
|
1586
|
+
}, Ve = {
|
|
1416
1587
|
write_a_message_placeholder: "Napište zprávu...",
|
|
1417
1588
|
your_issue_has_been_resolved: "Váš problém byl vyřešen!",
|
|
1418
1589
|
new_conversation: "Nová konverzace",
|
|
@@ -1499,8 +1670,17 @@ const Ie = {
|
|
|
1499
1670
|
questions_next: "Další",
|
|
1500
1671
|
questions_send: "Odeslat",
|
|
1501
1672
|
questions_type_answer: "Napíšu to sám",
|
|
1502
|
-
questions_answer_placeholder: "Napište svou odpověď…"
|
|
1503
|
-
|
|
1673
|
+
questions_answer_placeholder: "Napište svou odpověď…",
|
|
1674
|
+
close_conversation_title: "Uzavřít konverzaci",
|
|
1675
|
+
close_conversation_description: "Opravdu chcete tuto konverzaci uzavřít?",
|
|
1676
|
+
close_conversation_cancel: "Ne",
|
|
1677
|
+
close_conversation_confirm: "Ano",
|
|
1678
|
+
dialog_close: "Zavřít",
|
|
1679
|
+
zoom_in: "Přiblížit",
|
|
1680
|
+
zoom_out: "Oddálit",
|
|
1681
|
+
reset_zoom: "Obnovit přiblížení",
|
|
1682
|
+
support_chat_aria_label: "Chat podpory"
|
|
1683
|
+
}, He = {
|
|
1504
1684
|
write_a_message_placeholder: "Skriv en besked...",
|
|
1505
1685
|
your_issue_has_been_resolved: "Dit problem er løst!",
|
|
1506
1686
|
new_conversation: "Ny samtale",
|
|
@@ -1587,8 +1767,17 @@ const Ie = {
|
|
|
1587
1767
|
questions_next: "Næste",
|
|
1588
1768
|
questions_send: "Send",
|
|
1589
1769
|
questions_type_answer: "Jeg skriver det selv",
|
|
1590
|
-
questions_answer_placeholder: "Skriv dit svar…"
|
|
1591
|
-
|
|
1770
|
+
questions_answer_placeholder: "Skriv dit svar…",
|
|
1771
|
+
close_conversation_title: "Luk samtale",
|
|
1772
|
+
close_conversation_description: "Er du sikker på, at du vil lukke denne samtale?",
|
|
1773
|
+
close_conversation_cancel: "Nej",
|
|
1774
|
+
close_conversation_confirm: "Ja",
|
|
1775
|
+
dialog_close: "Luk",
|
|
1776
|
+
zoom_in: "Zoom ind",
|
|
1777
|
+
zoom_out: "Zoom ud",
|
|
1778
|
+
reset_zoom: "Nulstil zoom",
|
|
1779
|
+
support_chat_aria_label: "Supportchat"
|
|
1780
|
+
}, Ze = {
|
|
1592
1781
|
write_a_message_placeholder: "Γράψτε ένα μήνυμα...",
|
|
1593
1782
|
your_issue_has_been_resolved: "Το πρόβλημά σας επιλύθηκε!",
|
|
1594
1783
|
new_conversation: "Νέα συνομιλία",
|
|
@@ -1675,8 +1864,17 @@ const Ie = {
|
|
|
1675
1864
|
questions_next: "Επόμενο",
|
|
1676
1865
|
questions_send: "Αποστολή",
|
|
1677
1866
|
questions_type_answer: "Θα το γράψω",
|
|
1678
|
-
questions_answer_placeholder: "Γράψτε την απάντησή σας…"
|
|
1679
|
-
|
|
1867
|
+
questions_answer_placeholder: "Γράψτε την απάντησή σας…",
|
|
1868
|
+
close_conversation_title: "Κλείσιμο συνομιλίας",
|
|
1869
|
+
close_conversation_description: "Είστε βέβαιοι ότι θέλετε να κλείσετε αυτήν τη συνομιλία;",
|
|
1870
|
+
close_conversation_cancel: "Όχι",
|
|
1871
|
+
close_conversation_confirm: "Ναι",
|
|
1872
|
+
dialog_close: "Κλείσιμο",
|
|
1873
|
+
zoom_in: "Μεγέθυνση",
|
|
1874
|
+
zoom_out: "Σμίκρυνση",
|
|
1875
|
+
reset_zoom: "Επαναφορά ζουμ",
|
|
1876
|
+
support_chat_aria_label: "Συνομιλία υποστήριξης"
|
|
1877
|
+
}, We = {
|
|
1680
1878
|
write_a_message_placeholder: "Nachricht schreiben...",
|
|
1681
1879
|
your_issue_has_been_resolved: "Ihr Problem wurde gelöst!",
|
|
1682
1880
|
new_conversation: "Neue Konversation",
|
|
@@ -1763,8 +1961,17 @@ const Ie = {
|
|
|
1763
1961
|
questions_next: "Weiter",
|
|
1764
1962
|
questions_send: "Senden",
|
|
1765
1963
|
questions_type_answer: "Ich schreibe es selbst",
|
|
1766
|
-
questions_answer_placeholder: "Antwort eingeben…"
|
|
1767
|
-
|
|
1964
|
+
questions_answer_placeholder: "Antwort eingeben…",
|
|
1965
|
+
close_conversation_title: "Konversation schließen",
|
|
1966
|
+
close_conversation_description: "Möchten Sie diese Konversation wirklich schließen?",
|
|
1967
|
+
close_conversation_cancel: "Nein",
|
|
1968
|
+
close_conversation_confirm: "Ja",
|
|
1969
|
+
dialog_close: "Schließen",
|
|
1970
|
+
zoom_in: "Vergrößern",
|
|
1971
|
+
zoom_out: "Verkleinern",
|
|
1972
|
+
reset_zoom: "Zoom zurücksetzen",
|
|
1973
|
+
support_chat_aria_label: "Support-Chat"
|
|
1974
|
+
}, J = {
|
|
1768
1975
|
write_a_message_placeholder: "Write a message...",
|
|
1769
1976
|
your_issue_has_been_resolved: "Your issue has been resolved!",
|
|
1770
1977
|
new_conversation: "New conversation",
|
|
@@ -1863,8 +2070,17 @@ const Ie = {
|
|
|
1863
2070
|
questions_next: "Next",
|
|
1864
2071
|
questions_send: "Send",
|
|
1865
2072
|
questions_type_answer: "I'll type it",
|
|
1866
|
-
questions_answer_placeholder: "Type your answer…"
|
|
1867
|
-
|
|
2073
|
+
questions_answer_placeholder: "Type your answer…",
|
|
2074
|
+
close_conversation_title: "Close conversation",
|
|
2075
|
+
close_conversation_description: "Are you sure you want to close this conversation?",
|
|
2076
|
+
close_conversation_cancel: "No",
|
|
2077
|
+
close_conversation_confirm: "Yes",
|
|
2078
|
+
dialog_close: "Close",
|
|
2079
|
+
zoom_in: "Zoom in",
|
|
2080
|
+
zoom_out: "Zoom out",
|
|
2081
|
+
reset_zoom: "Reset zoom",
|
|
2082
|
+
support_chat_aria_label: "Support chat"
|
|
2083
|
+
}, Ge = {
|
|
1868
2084
|
write_a_message_placeholder: "Escribe un mensaje...",
|
|
1869
2085
|
your_issue_has_been_resolved: "¡Tu problema fue resuelto!",
|
|
1870
2086
|
new_conversation: "Nueva conversación",
|
|
@@ -1951,8 +2167,17 @@ const Ie = {
|
|
|
1951
2167
|
questions_next: "Siguiente",
|
|
1952
2168
|
questions_send: "Enviar",
|
|
1953
2169
|
questions_type_answer: "Lo escribo yo",
|
|
1954
|
-
questions_answer_placeholder: "Escribe tu respuesta…"
|
|
1955
|
-
|
|
2170
|
+
questions_answer_placeholder: "Escribe tu respuesta…",
|
|
2171
|
+
close_conversation_title: "Cerrar conversación",
|
|
2172
|
+
close_conversation_description: "¿Seguro que quieres cerrar esta conversación?",
|
|
2173
|
+
close_conversation_cancel: "No",
|
|
2174
|
+
close_conversation_confirm: "Sí",
|
|
2175
|
+
dialog_close: "Cerrar",
|
|
2176
|
+
zoom_in: "Acercar",
|
|
2177
|
+
zoom_out: "Alejar",
|
|
2178
|
+
reset_zoom: "Restablecer zoom",
|
|
2179
|
+
support_chat_aria_label: "Chat de soporte"
|
|
2180
|
+
}, $e = {
|
|
1956
2181
|
write_a_message_placeholder: "Magsulat ng mensahe...",
|
|
1957
2182
|
your_issue_has_been_resolved: "Nalutas na ang iyong isyu!",
|
|
1958
2183
|
new_conversation: "Bagong usapan",
|
|
@@ -2039,8 +2264,17 @@ const Ie = {
|
|
|
2039
2264
|
questions_next: "Susunod",
|
|
2040
2265
|
questions_send: "Ipadala",
|
|
2041
2266
|
questions_type_answer: "Ako na ang magta-type",
|
|
2042
|
-
questions_answer_placeholder: "I-type ang iyong sagot…"
|
|
2043
|
-
|
|
2267
|
+
questions_answer_placeholder: "I-type ang iyong sagot…",
|
|
2268
|
+
close_conversation_title: "Isara ang usapan",
|
|
2269
|
+
close_conversation_description: "Sigurado ka bang gusto mong isara ang usapang ito?",
|
|
2270
|
+
close_conversation_cancel: "Hindi",
|
|
2271
|
+
close_conversation_confirm: "Oo",
|
|
2272
|
+
dialog_close: "Isara",
|
|
2273
|
+
zoom_in: "Palakihin",
|
|
2274
|
+
zoom_out: "Paliitin",
|
|
2275
|
+
reset_zoom: "I-reset ang zoom",
|
|
2276
|
+
support_chat_aria_label: "Chat ng suporta"
|
|
2277
|
+
}, Je = {
|
|
2044
2278
|
write_a_message_placeholder: "Kirjoita viesti...",
|
|
2045
2279
|
your_issue_has_been_resolved: "Ongelmasi on ratkaistu!",
|
|
2046
2280
|
new_conversation: "Uusi keskustelu",
|
|
@@ -2127,8 +2361,17 @@ const Ie = {
|
|
|
2127
2361
|
questions_next: "Seuraava",
|
|
2128
2362
|
questions_send: "Lähetä",
|
|
2129
2363
|
questions_type_answer: "Kirjoitan itse",
|
|
2130
|
-
questions_answer_placeholder: "Kirjoita vastauksesi…"
|
|
2131
|
-
|
|
2364
|
+
questions_answer_placeholder: "Kirjoita vastauksesi…",
|
|
2365
|
+
close_conversation_title: "Sulje keskustelu",
|
|
2366
|
+
close_conversation_description: "Haluatko varmasti sulkea tämän keskustelun?",
|
|
2367
|
+
close_conversation_cancel: "Ei",
|
|
2368
|
+
close_conversation_confirm: "Kyllä",
|
|
2369
|
+
dialog_close: "Sulje",
|
|
2370
|
+
zoom_in: "Lähennä",
|
|
2371
|
+
zoom_out: "Loitonna",
|
|
2372
|
+
reset_zoom: "Palauta zoomaus",
|
|
2373
|
+
support_chat_aria_label: "Tukichat"
|
|
2374
|
+
}, Ye = {
|
|
2132
2375
|
write_a_message_placeholder: "Écrivez un message...",
|
|
2133
2376
|
your_issue_has_been_resolved: "Votre problème a été résolu !",
|
|
2134
2377
|
new_conversation: "Nouvelle conversation",
|
|
@@ -2215,8 +2458,17 @@ const Ie = {
|
|
|
2215
2458
|
questions_next: "Suivant",
|
|
2216
2459
|
questions_send: "Envoyer",
|
|
2217
2460
|
questions_type_answer: "Je préfère écrire",
|
|
2218
|
-
questions_answer_placeholder: "Écrivez votre réponse…"
|
|
2219
|
-
|
|
2461
|
+
questions_answer_placeholder: "Écrivez votre réponse…",
|
|
2462
|
+
close_conversation_title: "Fermer la conversation",
|
|
2463
|
+
close_conversation_description: "Voulez-vous vraiment fermer cette conversation ?",
|
|
2464
|
+
close_conversation_cancel: "Non",
|
|
2465
|
+
close_conversation_confirm: "Oui",
|
|
2466
|
+
dialog_close: "Fermer",
|
|
2467
|
+
zoom_in: "Zoom avant",
|
|
2468
|
+
zoom_out: "Zoom arrière",
|
|
2469
|
+
reset_zoom: "Réinitialiser le zoom",
|
|
2470
|
+
support_chat_aria_label: "Chat de support"
|
|
2471
|
+
}, Qe = {
|
|
2220
2472
|
write_a_message_placeholder: "एक संदेश लिखें...",
|
|
2221
2473
|
your_issue_has_been_resolved: "आपकी समस्या हल हो गई है!",
|
|
2222
2474
|
new_conversation: "नई बातचीत",
|
|
@@ -2303,8 +2555,17 @@ const Ie = {
|
|
|
2303
2555
|
questions_next: "आगे",
|
|
2304
2556
|
questions_send: "भेजें",
|
|
2305
2557
|
questions_type_answer: "मैं खुद लिखूंगा",
|
|
2306
|
-
questions_answer_placeholder: "अपना उत्तर लिखें…"
|
|
2307
|
-
|
|
2558
|
+
questions_answer_placeholder: "अपना उत्तर लिखें…",
|
|
2559
|
+
close_conversation_title: "बातचीत बंद करें",
|
|
2560
|
+
close_conversation_description: "क्या आप वाकई इस बातचीत को बंद करना चाहते हैं?",
|
|
2561
|
+
close_conversation_cancel: "नहीं",
|
|
2562
|
+
close_conversation_confirm: "हाँ",
|
|
2563
|
+
dialog_close: "बंद करें",
|
|
2564
|
+
zoom_in: "ज़ूम इन",
|
|
2565
|
+
zoom_out: "ज़ूम आउट",
|
|
2566
|
+
reset_zoom: "ज़ूम रीसेट करें",
|
|
2567
|
+
support_chat_aria_label: "सहायता चैट"
|
|
2568
|
+
}, Xe = {
|
|
2308
2569
|
write_a_message_placeholder: "Scrivi un messaggio...",
|
|
2309
2570
|
your_issue_has_been_resolved: "Il tuo problema è stato risolto!",
|
|
2310
2571
|
new_conversation: "Nuova conversazione",
|
|
@@ -2391,8 +2652,17 @@ const Ie = {
|
|
|
2391
2652
|
questions_next: "Avanti",
|
|
2392
2653
|
questions_send: "Invia",
|
|
2393
2654
|
questions_type_answer: "Lo scrivo io",
|
|
2394
|
-
questions_answer_placeholder: "Scrivi la tua risposta…"
|
|
2395
|
-
|
|
2655
|
+
questions_answer_placeholder: "Scrivi la tua risposta…",
|
|
2656
|
+
close_conversation_title: "Chiudi conversazione",
|
|
2657
|
+
close_conversation_description: "Vuoi davvero chiudere questa conversazione?",
|
|
2658
|
+
close_conversation_cancel: "No",
|
|
2659
|
+
close_conversation_confirm: "Sì",
|
|
2660
|
+
dialog_close: "Chiudi",
|
|
2661
|
+
zoom_in: "Ingrandisci",
|
|
2662
|
+
zoom_out: "Riduci",
|
|
2663
|
+
reset_zoom: "Reimposta zoom",
|
|
2664
|
+
support_chat_aria_label: "Chat di supporto"
|
|
2665
|
+
}, ea = {
|
|
2396
2666
|
write_a_message_placeholder: "メッセージを入力...",
|
|
2397
2667
|
your_issue_has_been_resolved: "問題が解決しました!",
|
|
2398
2668
|
new_conversation: "新しい会話",
|
|
@@ -2479,8 +2749,17 @@ const Ie = {
|
|
|
2479
2749
|
questions_next: "次へ",
|
|
2480
2750
|
questions_send: "送信",
|
|
2481
2751
|
questions_type_answer: "自分で入力する",
|
|
2482
|
-
questions_answer_placeholder: "回答を入力してください…"
|
|
2483
|
-
|
|
2752
|
+
questions_answer_placeholder: "回答を入力してください…",
|
|
2753
|
+
close_conversation_title: "会話を終了",
|
|
2754
|
+
close_conversation_description: "この会話を終了してもよろしいですか?",
|
|
2755
|
+
close_conversation_cancel: "いいえ",
|
|
2756
|
+
close_conversation_confirm: "はい",
|
|
2757
|
+
dialog_close: "閉じる",
|
|
2758
|
+
zoom_in: "拡大",
|
|
2759
|
+
zoom_out: "縮小",
|
|
2760
|
+
reset_zoom: "ズームをリセット",
|
|
2761
|
+
support_chat_aria_label: "サポートチャット"
|
|
2762
|
+
}, aa = {
|
|
2484
2763
|
write_a_message_placeholder: "메시지를 입력하세요...",
|
|
2485
2764
|
your_issue_has_been_resolved: "문제가 해결되었습니다!",
|
|
2486
2765
|
new_conversation: "새 대화",
|
|
@@ -2567,8 +2846,17 @@ const Ie = {
|
|
|
2567
2846
|
questions_next: "다음",
|
|
2568
2847
|
questions_send: "보내기",
|
|
2569
2848
|
questions_type_answer: "직접 입력할게요",
|
|
2570
|
-
questions_answer_placeholder: "답변을 입력하세요…"
|
|
2571
|
-
|
|
2849
|
+
questions_answer_placeholder: "답변을 입력하세요…",
|
|
2850
|
+
close_conversation_title: "대화 종료",
|
|
2851
|
+
close_conversation_description: "이 대화를 종료하시겠습니까?",
|
|
2852
|
+
close_conversation_cancel: "아니요",
|
|
2853
|
+
close_conversation_confirm: "예",
|
|
2854
|
+
dialog_close: "닫기",
|
|
2855
|
+
zoom_in: "확대",
|
|
2856
|
+
zoom_out: "축소",
|
|
2857
|
+
reset_zoom: "확대/축소 초기화",
|
|
2858
|
+
support_chat_aria_label: "고객 지원 채팅"
|
|
2859
|
+
}, ta = {
|
|
2572
2860
|
write_a_message_placeholder: "Schrijf een bericht...",
|
|
2573
2861
|
your_issue_has_been_resolved: "Uw probleem is opgelost!",
|
|
2574
2862
|
new_conversation: "Nieuw gesprek",
|
|
@@ -2655,8 +2943,17 @@ const Ie = {
|
|
|
2655
2943
|
questions_next: "Volgende",
|
|
2656
2944
|
questions_send: "Verzenden",
|
|
2657
2945
|
questions_type_answer: "Ik typ het zelf",
|
|
2658
|
-
questions_answer_placeholder: "Typ je antwoord…"
|
|
2659
|
-
|
|
2946
|
+
questions_answer_placeholder: "Typ je antwoord…",
|
|
2947
|
+
close_conversation_title: "Gesprek sluiten",
|
|
2948
|
+
close_conversation_description: "Weet je zeker dat je dit gesprek wilt sluiten?",
|
|
2949
|
+
close_conversation_cancel: "Nee",
|
|
2950
|
+
close_conversation_confirm: "Ja",
|
|
2951
|
+
dialog_close: "Sluiten",
|
|
2952
|
+
zoom_in: "Inzoomen",
|
|
2953
|
+
zoom_out: "Uitzoomen",
|
|
2954
|
+
reset_zoom: "Zoom herstellen",
|
|
2955
|
+
support_chat_aria_label: "Supportchat"
|
|
2956
|
+
}, sa = {
|
|
2660
2957
|
write_a_message_placeholder: "Skriv en melding...",
|
|
2661
2958
|
your_issue_has_been_resolved: "Problemet ditt er løst!",
|
|
2662
2959
|
new_conversation: "Ny samtale",
|
|
@@ -2743,8 +3040,17 @@ const Ie = {
|
|
|
2743
3040
|
questions_next: "Neste",
|
|
2744
3041
|
questions_send: "Send",
|
|
2745
3042
|
questions_type_answer: "Jeg skriver det selv",
|
|
2746
|
-
questions_answer_placeholder: "Skriv svaret ditt…"
|
|
2747
|
-
|
|
3043
|
+
questions_answer_placeholder: "Skriv svaret ditt…",
|
|
3044
|
+
close_conversation_title: "Lukk samtale",
|
|
3045
|
+
close_conversation_description: "Er du sikker på at du vil lukke denne samtalen?",
|
|
3046
|
+
close_conversation_cancel: "Nei",
|
|
3047
|
+
close_conversation_confirm: "Ja",
|
|
3048
|
+
dialog_close: "Lukk",
|
|
3049
|
+
zoom_in: "Zoom inn",
|
|
3050
|
+
zoom_out: "Zoom ut",
|
|
3051
|
+
reset_zoom: "Tilbakestill zoom",
|
|
3052
|
+
support_chat_aria_label: "Support-chat"
|
|
3053
|
+
}, oa = {
|
|
2748
3054
|
write_a_message_placeholder: "Napisz wiadomość...",
|
|
2749
3055
|
your_issue_has_been_resolved: "Twój problem został rozwiązany!",
|
|
2750
3056
|
new_conversation: "Nowa rozmowa",
|
|
@@ -2831,8 +3137,17 @@ const Ie = {
|
|
|
2831
3137
|
questions_next: "Dalej",
|
|
2832
3138
|
questions_send: "Wyślij",
|
|
2833
3139
|
questions_type_answer: "Napiszę sam",
|
|
2834
|
-
questions_answer_placeholder: "Wpisz swoją odpowiedź…"
|
|
2835
|
-
|
|
3140
|
+
questions_answer_placeholder: "Wpisz swoją odpowiedź…",
|
|
3141
|
+
close_conversation_title: "Zamknij rozmowę",
|
|
3142
|
+
close_conversation_description: "Czy na pewno chcesz zamknąć tę rozmowę?",
|
|
3143
|
+
close_conversation_cancel: "Nie",
|
|
3144
|
+
close_conversation_confirm: "Tak",
|
|
3145
|
+
dialog_close: "Zamknij",
|
|
3146
|
+
zoom_in: "Powiększ",
|
|
3147
|
+
zoom_out: "Pomniejsz",
|
|
3148
|
+
reset_zoom: "Resetuj powiększenie",
|
|
3149
|
+
support_chat_aria_label: "Czat pomocy"
|
|
3150
|
+
}, na = {
|
|
2836
3151
|
write_a_message_placeholder: "Escreva uma mensagem...",
|
|
2837
3152
|
your_issue_has_been_resolved: "Seu problema foi resolvido!",
|
|
2838
3153
|
new_conversation: "Nova conversa",
|
|
@@ -2919,8 +3234,17 @@ const Ie = {
|
|
|
2919
3234
|
questions_next: "Seguinte",
|
|
2920
3235
|
questions_send: "Enviar",
|
|
2921
3236
|
questions_type_answer: "Prefiro escrever",
|
|
2922
|
-
questions_answer_placeholder: "Escreva a sua resposta…"
|
|
2923
|
-
|
|
3237
|
+
questions_answer_placeholder: "Escreva a sua resposta…",
|
|
3238
|
+
close_conversation_title: "Encerrar conversa",
|
|
3239
|
+
close_conversation_description: "Tem certeza de que deseja encerrar esta conversa?",
|
|
3240
|
+
close_conversation_cancel: "Não",
|
|
3241
|
+
close_conversation_confirm: "Sim",
|
|
3242
|
+
dialog_close: "Fechar",
|
|
3243
|
+
zoom_in: "Ampliar",
|
|
3244
|
+
zoom_out: "Reduzir",
|
|
3245
|
+
reset_zoom: "Redefinir zoom",
|
|
3246
|
+
support_chat_aria_label: "Chat de suporte"
|
|
3247
|
+
}, ia = {
|
|
2924
3248
|
write_a_message_placeholder: "Scrie un mesaj...",
|
|
2925
3249
|
your_issue_has_been_resolved: "Problema ta a fost rezolvată!",
|
|
2926
3250
|
new_conversation: "Conversație nouă",
|
|
@@ -3007,8 +3331,17 @@ const Ie = {
|
|
|
3007
3331
|
questions_next: "Înainte",
|
|
3008
3332
|
questions_send: "Trimite",
|
|
3009
3333
|
questions_type_answer: "Scriu eu",
|
|
3010
|
-
questions_answer_placeholder: "Scrieți răspunsul dvs.…"
|
|
3011
|
-
|
|
3334
|
+
questions_answer_placeholder: "Scrieți răspunsul dvs.…",
|
|
3335
|
+
close_conversation_title: "Închide conversația",
|
|
3336
|
+
close_conversation_description: "Sigur vrei să închizi această conversație?",
|
|
3337
|
+
close_conversation_cancel: "Nu",
|
|
3338
|
+
close_conversation_confirm: "Da",
|
|
3339
|
+
dialog_close: "Închide",
|
|
3340
|
+
zoom_in: "Mărește",
|
|
3341
|
+
zoom_out: "Micșorează",
|
|
3342
|
+
reset_zoom: "Resetează zoomul",
|
|
3343
|
+
support_chat_aria_label: "Chat de asistență"
|
|
3344
|
+
}, ra = {
|
|
3012
3345
|
write_a_message_placeholder: "Skriv ett meddelande...",
|
|
3013
3346
|
your_issue_has_been_resolved: "Ditt problem har lösts!",
|
|
3014
3347
|
new_conversation: "Ny konversation",
|
|
@@ -3095,8 +3428,17 @@ const Ie = {
|
|
|
3095
3428
|
questions_next: "Nästa",
|
|
3096
3429
|
questions_send: "Skicka",
|
|
3097
3430
|
questions_type_answer: "Jag skriver själv",
|
|
3098
|
-
questions_answer_placeholder: "Skriv ditt svar…"
|
|
3099
|
-
|
|
3431
|
+
questions_answer_placeholder: "Skriv ditt svar…",
|
|
3432
|
+
close_conversation_title: "Avsluta konversation",
|
|
3433
|
+
close_conversation_description: "Är du säker på att du vill avsluta den här konversationen?",
|
|
3434
|
+
close_conversation_cancel: "Nej",
|
|
3435
|
+
close_conversation_confirm: "Ja",
|
|
3436
|
+
dialog_close: "Stäng",
|
|
3437
|
+
zoom_in: "Zooma in",
|
|
3438
|
+
zoom_out: "Zooma ut",
|
|
3439
|
+
reset_zoom: "Återställ zoom",
|
|
3440
|
+
support_chat_aria_label: "Supportchatt"
|
|
3441
|
+
}, _a = {
|
|
3100
3442
|
write_a_message_placeholder: "Напишите сообщение...",
|
|
3101
3443
|
your_issue_has_been_resolved: "Ваша проблема решена!",
|
|
3102
3444
|
new_conversation: "Новый разговор",
|
|
@@ -3183,8 +3525,17 @@ const Ie = {
|
|
|
3183
3525
|
questions_next: "Далее",
|
|
3184
3526
|
questions_send: "Отправить",
|
|
3185
3527
|
questions_type_answer: "Напишу сам",
|
|
3186
|
-
questions_answer_placeholder: "Напишите ваш ответ…"
|
|
3187
|
-
|
|
3528
|
+
questions_answer_placeholder: "Напишите ваш ответ…",
|
|
3529
|
+
close_conversation_title: "Закрыть разговор",
|
|
3530
|
+
close_conversation_description: "Вы уверены, что хотите закрыть этот разговор?",
|
|
3531
|
+
close_conversation_cancel: "Нет",
|
|
3532
|
+
close_conversation_confirm: "Да",
|
|
3533
|
+
dialog_close: "Закрыть",
|
|
3534
|
+
zoom_in: "Увеличить",
|
|
3535
|
+
zoom_out: "Уменьшить",
|
|
3536
|
+
reset_zoom: "Сбросить масштаб",
|
|
3537
|
+
support_chat_aria_label: "Чат поддержки"
|
|
3538
|
+
}, la = {
|
|
3188
3539
|
write_a_message_placeholder: "เขียนข้อความ...",
|
|
3189
3540
|
your_issue_has_been_resolved: "ปัญหาของคุณได้รับการแก้ไขแล้ว!",
|
|
3190
3541
|
new_conversation: "การสนทนาใหม่",
|
|
@@ -3271,8 +3622,17 @@ const Ie = {
|
|
|
3271
3622
|
questions_next: "ถัดไป",
|
|
3272
3623
|
questions_send: "ส่ง",
|
|
3273
3624
|
questions_type_answer: "ขอพิมพ์เอง",
|
|
3274
|
-
questions_answer_placeholder: "พิมพ์คำตอบของคุณ…"
|
|
3275
|
-
|
|
3625
|
+
questions_answer_placeholder: "พิมพ์คำตอบของคุณ…",
|
|
3626
|
+
close_conversation_title: "ปิดการสนทนา",
|
|
3627
|
+
close_conversation_description: "คุณแน่ใจหรือไม่ว่าต้องการปิดการสนทนานี้?",
|
|
3628
|
+
close_conversation_cancel: "ไม่",
|
|
3629
|
+
close_conversation_confirm: "ใช่",
|
|
3630
|
+
dialog_close: "ปิด",
|
|
3631
|
+
zoom_in: "ขยาย",
|
|
3632
|
+
zoom_out: "ย่อ",
|
|
3633
|
+
reset_zoom: "รีเซ็ตการซูม",
|
|
3634
|
+
support_chat_aria_label: "แชทฝ่ายสนับสนุน"
|
|
3635
|
+
}, ca = {
|
|
3276
3636
|
write_a_message_placeholder: "Bir mesaj yazın...",
|
|
3277
3637
|
your_issue_has_been_resolved: "Sorununuz çözüldü!",
|
|
3278
3638
|
new_conversation: "Yeni konuşma",
|
|
@@ -3359,8 +3719,17 @@ const Ie = {
|
|
|
3359
3719
|
questions_next: "İleri",
|
|
3360
3720
|
questions_send: "Gönder",
|
|
3361
3721
|
questions_type_answer: "Kendim yazayım",
|
|
3362
|
-
questions_answer_placeholder: "Yanıtınızı yazın…"
|
|
3363
|
-
|
|
3722
|
+
questions_answer_placeholder: "Yanıtınızı yazın…",
|
|
3723
|
+
close_conversation_title: "Görüşmeyi kapat",
|
|
3724
|
+
close_conversation_description: "Bu görüşmeyi kapatmak istediğinizden emin misiniz?",
|
|
3725
|
+
close_conversation_cancel: "Hayır",
|
|
3726
|
+
close_conversation_confirm: "Evet",
|
|
3727
|
+
dialog_close: "Kapat",
|
|
3728
|
+
zoom_in: "Yakınlaştır",
|
|
3729
|
+
zoom_out: "Uzaklaştır",
|
|
3730
|
+
reset_zoom: "Yakınlaştırmayı sıfırla",
|
|
3731
|
+
support_chat_aria_label: "Destek sohbeti"
|
|
3732
|
+
}, pa = {
|
|
3364
3733
|
write_a_message_placeholder: "پیغام لکھیں...",
|
|
3365
3734
|
your_issue_has_been_resolved: "آپ کا مسئلہ حل ہو گیا ہے!",
|
|
3366
3735
|
new_conversation: "نئی گفتگو",
|
|
@@ -3447,8 +3816,17 @@ const Ie = {
|
|
|
3447
3816
|
questions_next: "اگلا",
|
|
3448
3817
|
questions_send: "بھیجیں",
|
|
3449
3818
|
questions_type_answer: "میں خود لکھوں گا",
|
|
3450
|
-
questions_answer_placeholder: "اپنا جواب لکھیں…"
|
|
3451
|
-
|
|
3819
|
+
questions_answer_placeholder: "اپنا جواب لکھیں…",
|
|
3820
|
+
close_conversation_title: "گفتگو بند کریں",
|
|
3821
|
+
close_conversation_description: "کیا آپ واقعی یہ گفتگو بند کرنا چاہتے ہیں؟",
|
|
3822
|
+
close_conversation_cancel: "نہیں",
|
|
3823
|
+
close_conversation_confirm: "ہاں",
|
|
3824
|
+
dialog_close: "بند کریں",
|
|
3825
|
+
zoom_in: "زوم اِن",
|
|
3826
|
+
zoom_out: "زوم آؤٹ",
|
|
3827
|
+
reset_zoom: "زوم دوبارہ ترتیب دیں",
|
|
3828
|
+
support_chat_aria_label: "سپورٹ چیٹ"
|
|
3829
|
+
}, da = {
|
|
3452
3830
|
write_a_message_placeholder: "Viết tin nhắn...",
|
|
3453
3831
|
your_issue_has_been_resolved: "Vấn đề của bạn đã được giải quyết!",
|
|
3454
3832
|
new_conversation: "Cuộc trò chuyện mới",
|
|
@@ -3535,8 +3913,17 @@ const Ie = {
|
|
|
3535
3913
|
questions_next: "Tiếp theo",
|
|
3536
3914
|
questions_send: "Gửi",
|
|
3537
3915
|
questions_type_answer: "Tôi sẽ tự nhập",
|
|
3538
|
-
questions_answer_placeholder: "Nhập câu trả lời của bạn…"
|
|
3539
|
-
|
|
3916
|
+
questions_answer_placeholder: "Nhập câu trả lời của bạn…",
|
|
3917
|
+
close_conversation_title: "Đóng cuộc trò chuyện",
|
|
3918
|
+
close_conversation_description: "Bạn có chắc muốn đóng cuộc trò chuyện này không?",
|
|
3919
|
+
close_conversation_cancel: "Không",
|
|
3920
|
+
close_conversation_confirm: "Có",
|
|
3921
|
+
dialog_close: "Đóng",
|
|
3922
|
+
zoom_in: "Phóng to",
|
|
3923
|
+
zoom_out: "Thu nhỏ",
|
|
3924
|
+
reset_zoom: "Đặt lại thu phóng",
|
|
3925
|
+
support_chat_aria_label: "Trò chuyện hỗ trợ"
|
|
3926
|
+
}, ua = {
|
|
3540
3927
|
write_a_message_placeholder: "写一条消息...",
|
|
3541
3928
|
your_issue_has_been_resolved: "您的问题已解决!",
|
|
3542
3929
|
new_conversation: "新对话",
|
|
@@ -3623,8 +4010,17 @@ const Ie = {
|
|
|
3623
4010
|
questions_next: "下一步",
|
|
3624
4011
|
questions_send: "发送",
|
|
3625
4012
|
questions_type_answer: "我自己输入",
|
|
3626
|
-
questions_answer_placeholder: "输入你的回答…"
|
|
3627
|
-
|
|
4013
|
+
questions_answer_placeholder: "输入你的回答…",
|
|
4014
|
+
close_conversation_title: "结束对话",
|
|
4015
|
+
close_conversation_description: "确定要结束此对话吗?",
|
|
4016
|
+
close_conversation_cancel: "否",
|
|
4017
|
+
close_conversation_confirm: "是",
|
|
4018
|
+
dialog_close: "关闭",
|
|
4019
|
+
zoom_in: "放大",
|
|
4020
|
+
zoom_out: "缩小",
|
|
4021
|
+
reset_zoom: "重置缩放",
|
|
4022
|
+
support_chat_aria_label: "支持对话"
|
|
4023
|
+
}, ma = {
|
|
3628
4024
|
write_a_message_placeholder: "Napišite poruku...",
|
|
3629
4025
|
your_issue_has_been_resolved: "Vaš problem je riješen!",
|
|
3630
4026
|
new_conversation: "Novi razgovor",
|
|
@@ -3711,8 +4107,17 @@ const Ie = {
|
|
|
3711
4107
|
questions_next: "Dalje",
|
|
3712
4108
|
questions_send: "Pošalji",
|
|
3713
4109
|
questions_type_answer: "Napisat ću sam",
|
|
3714
|
-
questions_answer_placeholder: "Napišite svoj odgovor…"
|
|
3715
|
-
|
|
4110
|
+
questions_answer_placeholder: "Napišite svoj odgovor…",
|
|
4111
|
+
close_conversation_title: "Zatvori razgovor",
|
|
4112
|
+
close_conversation_description: "Jeste li sigurni da želite zatvoriti ovaj razgovor?",
|
|
4113
|
+
close_conversation_cancel: "Ne",
|
|
4114
|
+
close_conversation_confirm: "Da",
|
|
4115
|
+
dialog_close: "Zatvori",
|
|
4116
|
+
zoom_in: "Približi",
|
|
4117
|
+
zoom_out: "Udalji",
|
|
4118
|
+
reset_zoom: "Poništi zumiranje",
|
|
4119
|
+
support_chat_aria_label: "Chat za podršku"
|
|
4120
|
+
}, ha = {
|
|
3716
4121
|
write_a_message_placeholder: "Kirjuta sõnum...",
|
|
3717
4122
|
your_issue_has_been_resolved: "Teie probleem on lahendatud!",
|
|
3718
4123
|
new_conversation: "Uus vestlus",
|
|
@@ -3799,8 +4204,17 @@ const Ie = {
|
|
|
3799
4204
|
questions_next: "Edasi",
|
|
3800
4205
|
questions_send: "Saada",
|
|
3801
4206
|
questions_type_answer: "Kirjutan ise",
|
|
3802
|
-
questions_answer_placeholder: "Kirjutage oma vastus…"
|
|
3803
|
-
|
|
4207
|
+
questions_answer_placeholder: "Kirjutage oma vastus…",
|
|
4208
|
+
close_conversation_title: "Sulge vestlus",
|
|
4209
|
+
close_conversation_description: "Kas soovite kindlasti selle vestluse sulgeda?",
|
|
4210
|
+
close_conversation_cancel: "Ei",
|
|
4211
|
+
close_conversation_confirm: "Jah",
|
|
4212
|
+
dialog_close: "Sulge",
|
|
4213
|
+
zoom_in: "Suurenda",
|
|
4214
|
+
zoom_out: "Vähenda",
|
|
4215
|
+
reset_zoom: "Lähtesta suurendus",
|
|
4216
|
+
support_chat_aria_label: "Tugivestlus"
|
|
4217
|
+
}, ga = {
|
|
3804
4218
|
write_a_message_placeholder: "Írjon üzenetet...",
|
|
3805
4219
|
your_issue_has_been_resolved: "A problémája megoldódott!",
|
|
3806
4220
|
new_conversation: "Új beszélgetés",
|
|
@@ -3887,8 +4301,17 @@ const Ie = {
|
|
|
3887
4301
|
questions_next: "Tovább",
|
|
3888
4302
|
questions_send: "Küldés",
|
|
3889
4303
|
questions_type_answer: "Inkább leírom",
|
|
3890
|
-
questions_answer_placeholder: "Írja le a válaszát…"
|
|
3891
|
-
|
|
4304
|
+
questions_answer_placeholder: "Írja le a válaszát…",
|
|
4305
|
+
close_conversation_title: "Beszélgetés lezárása",
|
|
4306
|
+
close_conversation_description: "Biztosan lezárja ezt a beszélgetést?",
|
|
4307
|
+
close_conversation_cancel: "Nem",
|
|
4308
|
+
close_conversation_confirm: "Igen",
|
|
4309
|
+
dialog_close: "Bezárás",
|
|
4310
|
+
zoom_in: "Nagyítás",
|
|
4311
|
+
zoom_out: "Kicsinyítés",
|
|
4312
|
+
reset_zoom: "Nagyítás visszaállítása",
|
|
4313
|
+
support_chat_aria_label: "Ügyfélszolgálati chat"
|
|
4314
|
+
}, ka = {
|
|
3892
4315
|
write_a_message_placeholder: "Skrifaðu skilaboð...",
|
|
3893
4316
|
your_issue_has_been_resolved: "Málið þitt hefur verið leyst!",
|
|
3894
4317
|
new_conversation: "Nýtt samtal",
|
|
@@ -3975,8 +4398,17 @@ const Ie = {
|
|
|
3975
4398
|
questions_next: "Áfram",
|
|
3976
4399
|
questions_send: "Senda",
|
|
3977
4400
|
questions_type_answer: "Ég skrifa það",
|
|
3978
|
-
questions_answer_placeholder: "Skrifaðu svarið þitt…"
|
|
3979
|
-
|
|
4401
|
+
questions_answer_placeholder: "Skrifaðu svarið þitt…",
|
|
4402
|
+
close_conversation_title: "Loka samtali",
|
|
4403
|
+
close_conversation_description: "Ertu viss um að þú viljir loka þessu samtali?",
|
|
4404
|
+
close_conversation_cancel: "Nei",
|
|
4405
|
+
close_conversation_confirm: "Já",
|
|
4406
|
+
dialog_close: "Loka",
|
|
4407
|
+
zoom_in: "Auka aðdrátt",
|
|
4408
|
+
zoom_out: "Minnka aðdrátt",
|
|
4409
|
+
reset_zoom: "Endurstilla aðdrátt",
|
|
4410
|
+
support_chat_aria_label: "Þjónustuspjall"
|
|
4411
|
+
}, ba = {
|
|
3980
4412
|
write_a_message_placeholder: "Rakstiet ziņojumu...",
|
|
3981
4413
|
your_issue_has_been_resolved: "Jūsu problēma ir atrisināta!",
|
|
3982
4414
|
new_conversation: "Jauna saruna",
|
|
@@ -4063,8 +4495,17 @@ const Ie = {
|
|
|
4063
4495
|
questions_next: "Tālāk",
|
|
4064
4496
|
questions_send: "Sūtīt",
|
|
4065
4497
|
questions_type_answer: "Rakstīšu pats",
|
|
4066
|
-
questions_answer_placeholder: "Ierakstiet savu atbildi…"
|
|
4067
|
-
|
|
4498
|
+
questions_answer_placeholder: "Ierakstiet savu atbildi…",
|
|
4499
|
+
close_conversation_title: "Aizvērt sarunu",
|
|
4500
|
+
close_conversation_description: "Vai tiešām vēlaties aizvērt šo sarunu?",
|
|
4501
|
+
close_conversation_cancel: "Nē",
|
|
4502
|
+
close_conversation_confirm: "Jā",
|
|
4503
|
+
dialog_close: "Aizvērt",
|
|
4504
|
+
zoom_in: "Pietuvināt",
|
|
4505
|
+
zoom_out: "Attālināt",
|
|
4506
|
+
reset_zoom: "Atiestatīt tālummaiņu",
|
|
4507
|
+
support_chat_aria_label: "Atbalsta tērzēšana"
|
|
4508
|
+
}, va = {
|
|
4068
4509
|
write_a_message_placeholder: "Parašykite žinutę...",
|
|
4069
4510
|
your_issue_has_been_resolved: "Jūsų problema išspręsta!",
|
|
4070
4511
|
new_conversation: "Naujas pokalbis",
|
|
@@ -4151,8 +4592,17 @@ const Ie = {
|
|
|
4151
4592
|
questions_next: "Toliau",
|
|
4152
4593
|
questions_send: "Siųsti",
|
|
4153
4594
|
questions_type_answer: "Parašysiu pats",
|
|
4154
|
-
questions_answer_placeholder: "Parašykite savo atsakymą…"
|
|
4155
|
-
|
|
4595
|
+
questions_answer_placeholder: "Parašykite savo atsakymą…",
|
|
4596
|
+
close_conversation_title: "Uždaryti pokalbį",
|
|
4597
|
+
close_conversation_description: "Ar tikrai norite uždaryti šį pokalbį?",
|
|
4598
|
+
close_conversation_cancel: "Ne",
|
|
4599
|
+
close_conversation_confirm: "Taip",
|
|
4600
|
+
dialog_close: "Uždaryti",
|
|
4601
|
+
zoom_in: "Priartinti",
|
|
4602
|
+
zoom_out: "Nutolinti",
|
|
4603
|
+
reset_zoom: "Atstatyti mastelį",
|
|
4604
|
+
support_chat_aria_label: "Pagalbos pokalbis"
|
|
4605
|
+
}, fa = {
|
|
4156
4606
|
write_a_message_placeholder: "Schreift eng Noriicht...",
|
|
4157
4607
|
your_issue_has_been_resolved: "Äert Problem gouf geléist!",
|
|
4158
4608
|
new_conversation: "Nei Konversatioun",
|
|
@@ -4239,8 +4689,17 @@ const Ie = {
|
|
|
4239
4689
|
questions_next: "Weider",
|
|
4240
4690
|
questions_send: "Schécken",
|
|
4241
4691
|
questions_type_answer: "Ech schreiwen et selwer",
|
|
4242
|
-
questions_answer_placeholder: "Schreift Är Äntwert…"
|
|
4243
|
-
|
|
4692
|
+
questions_answer_placeholder: "Schreift Är Äntwert…",
|
|
4693
|
+
close_conversation_title: "Konversatioun zoumaachen",
|
|
4694
|
+
close_conversation_description: "Wëllt Dir dës Konversatioun wierklech zoumaachen?",
|
|
4695
|
+
close_conversation_cancel: "Nee",
|
|
4696
|
+
close_conversation_confirm: "Jo",
|
|
4697
|
+
dialog_close: "Zoumaachen",
|
|
4698
|
+
zoom_in: "Erazoomen",
|
|
4699
|
+
zoom_out: "Erauszoomen",
|
|
4700
|
+
reset_zoom: "Zoom zrécksetzen",
|
|
4701
|
+
support_chat_aria_label: "Support-Chat"
|
|
4702
|
+
}, ya = {
|
|
4244
4703
|
write_a_message_placeholder: "Ikteb messaġġ...",
|
|
4245
4704
|
your_issue_has_been_resolved: "Il-problema tiegħek ġiet riżolta!",
|
|
4246
4705
|
new_conversation: "Konversazzjoni ġdida",
|
|
@@ -4327,8 +4786,17 @@ const Ie = {
|
|
|
4327
4786
|
questions_next: "Li jmiss",
|
|
4328
4787
|
questions_send: "Ibgħat",
|
|
4329
4788
|
questions_type_answer: "Nikteb jien",
|
|
4330
|
-
questions_answer_placeholder: "Ikteb it-tweġiba tiegħek…"
|
|
4331
|
-
|
|
4789
|
+
questions_answer_placeholder: "Ikteb it-tweġiba tiegħek…",
|
|
4790
|
+
close_conversation_title: "Agħlaq il-konversazzjoni",
|
|
4791
|
+
close_conversation_description: "Żgur li trid tagħlaq din il-konversazzjoni?",
|
|
4792
|
+
close_conversation_cancel: "Le",
|
|
4793
|
+
close_conversation_confirm: "Iva",
|
|
4794
|
+
dialog_close: "Agħlaq",
|
|
4795
|
+
zoom_in: "Kabbar",
|
|
4796
|
+
zoom_out: "Ċekken",
|
|
4797
|
+
reset_zoom: "Irrisettja ż-zoom",
|
|
4798
|
+
support_chat_aria_label: "Chat ta’ appoġġ"
|
|
4799
|
+
}, wa = {
|
|
4332
4800
|
write_a_message_placeholder: "Skriv en melding...",
|
|
4333
4801
|
your_issue_has_been_resolved: "Saken din er løst!",
|
|
4334
4802
|
new_conversation: "Ny samtale",
|
|
@@ -4415,8 +4883,17 @@ const Ie = {
|
|
|
4415
4883
|
questions_next: "Neste",
|
|
4416
4884
|
questions_send: "Send",
|
|
4417
4885
|
questions_type_answer: "Jeg skriver det selv",
|
|
4418
|
-
questions_answer_placeholder: "Skriv svaret ditt…"
|
|
4419
|
-
|
|
4886
|
+
questions_answer_placeholder: "Skriv svaret ditt…",
|
|
4887
|
+
close_conversation_title: "Lukk samtale",
|
|
4888
|
+
close_conversation_description: "Er du sikker på at du vil lukke denne samtalen?",
|
|
4889
|
+
close_conversation_cancel: "Nei",
|
|
4890
|
+
close_conversation_confirm: "Ja",
|
|
4891
|
+
dialog_close: "Lukk",
|
|
4892
|
+
zoom_in: "Zoom inn",
|
|
4893
|
+
zoom_out: "Zoom ut",
|
|
4894
|
+
reset_zoom: "Tilbakestill zoom",
|
|
4895
|
+
support_chat_aria_label: "Support-chat"
|
|
4896
|
+
}, ja = {
|
|
4420
4897
|
write_a_message_placeholder: "Napíšte správu...",
|
|
4421
4898
|
your_issue_has_been_resolved: "Váš problém bol vyriešený!",
|
|
4422
4899
|
new_conversation: "Nová konverzácia",
|
|
@@ -4503,87 +4980,96 @@ const Ie = {
|
|
|
4503
4980
|
questions_next: "Ďalej",
|
|
4504
4981
|
questions_send: "Odoslať",
|
|
4505
4982
|
questions_type_answer: "Napíšem to sám",
|
|
4506
|
-
questions_answer_placeholder: "Napíšte svoju odpoveď…"
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4983
|
+
questions_answer_placeholder: "Napíšte svoju odpoveď…",
|
|
4984
|
+
close_conversation_title: "Uzavrieť konverzáciu",
|
|
4985
|
+
close_conversation_description: "Naozaj chcete túto konverzáciu uzavrieť?",
|
|
4986
|
+
close_conversation_cancel: "Nie",
|
|
4987
|
+
close_conversation_confirm: "Áno",
|
|
4988
|
+
dialog_close: "Zavrieť",
|
|
4989
|
+
zoom_in: "Priblížiť",
|
|
4990
|
+
zoom_out: "Oddialiť",
|
|
4991
|
+
reset_zoom: "Obnoviť priblíženie",
|
|
4992
|
+
support_chat_aria_label: "Chat podpory"
|
|
4993
|
+
}, Y = {
|
|
4994
|
+
ar: Oe,
|
|
4995
|
+
bn: Ue,
|
|
4996
|
+
bg: Be,
|
|
4997
|
+
cs: Ve,
|
|
4998
|
+
da: He,
|
|
4999
|
+
de: We,
|
|
5000
|
+
el: Ze,
|
|
5001
|
+
en: J,
|
|
5002
|
+
es: Ge,
|
|
5003
|
+
et: ha,
|
|
5004
|
+
fi: Je,
|
|
5005
|
+
fil: $e,
|
|
5006
|
+
fr: Ye,
|
|
5007
|
+
hi: Qe,
|
|
5008
|
+
hr: ma,
|
|
5009
|
+
hu: ga,
|
|
5010
|
+
is: ka,
|
|
5011
|
+
it: Xe,
|
|
5012
|
+
ja: ea,
|
|
5013
|
+
ko: aa,
|
|
5014
|
+
lb: fa,
|
|
5015
|
+
lt: va,
|
|
5016
|
+
lv: ba,
|
|
5017
|
+
mt: ya,
|
|
5018
|
+
nb: wa,
|
|
5019
|
+
nl: ta,
|
|
5020
|
+
no: sa,
|
|
5021
|
+
pl: oa,
|
|
5022
|
+
pt: na,
|
|
5023
|
+
ro: ia,
|
|
5024
|
+
ru: _a,
|
|
5025
|
+
sk: ja,
|
|
5026
|
+
sv: ra,
|
|
5027
|
+
th: la,
|
|
5028
|
+
tr: ca,
|
|
5029
|
+
ur: pa,
|
|
5030
|
+
vi: da,
|
|
5031
|
+
"zh-cn": ua
|
|
5032
|
+
}, Sa = Object.keys(Y);
|
|
5033
|
+
function za(n) {
|
|
5034
|
+
return Sa.includes(n);
|
|
4549
5035
|
}
|
|
4550
|
-
const
|
|
4551
|
-
function
|
|
4552
|
-
return
|
|
5036
|
+
const Ca = /* @__PURE__ */ new Set(["ar", "ur"]);
|
|
5037
|
+
function Ja(n) {
|
|
5038
|
+
return Ca.has(n);
|
|
4553
5039
|
}
|
|
4554
|
-
function
|
|
4555
|
-
return
|
|
5040
|
+
function xa(n) {
|
|
5041
|
+
return za(n) ? n : "en";
|
|
4556
5042
|
}
|
|
4557
|
-
function
|
|
4558
|
-
var
|
|
4559
|
-
const
|
|
4560
|
-
return
|
|
5043
|
+
function qa(n, e, t, o) {
|
|
5044
|
+
var l;
|
|
5045
|
+
const r = ((l = t == null ? void 0 : t[e]) == null ? void 0 : l[n]) || Y[e][n] || J[n] || n;
|
|
5046
|
+
return o ? r.replace(
|
|
4561
5047
|
/\{(\w+)\}/g,
|
|
4562
|
-
(
|
|
4563
|
-
) :
|
|
5048
|
+
(s, a) => a in o ? String(o[a]) : s
|
|
5049
|
+
) : r;
|
|
4564
5050
|
}
|
|
4565
|
-
function
|
|
4566
|
-
return
|
|
5051
|
+
function Ea(n, e, t) {
|
|
5052
|
+
return qa(
|
|
4567
5053
|
e,
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
5054
|
+
xa(n.language),
|
|
5055
|
+
n.translationOverrides,
|
|
5056
|
+
t
|
|
4571
5057
|
);
|
|
4572
5058
|
}
|
|
4573
|
-
class
|
|
5059
|
+
class Aa {
|
|
4574
5060
|
constructor({
|
|
4575
5061
|
config: e,
|
|
4576
|
-
api:
|
|
4577
|
-
contactCtx:
|
|
4578
|
-
storageCtx:
|
|
4579
|
-
sessionsPollingIntervalSeconds:
|
|
4580
|
-
sharedSessions:
|
|
5062
|
+
api: t,
|
|
5063
|
+
contactCtx: o,
|
|
5064
|
+
storageCtx: r,
|
|
5065
|
+
sessionsPollingIntervalSeconds: l,
|
|
5066
|
+
sharedSessions: s
|
|
4581
5067
|
}) {
|
|
4582
|
-
this.sessionsRefresher = new G(), this.persistedSessionId = null, this.sessionAbortController = new AbortController(), this.sessionState = new
|
|
5068
|
+
this.sessionsRefresher = new G(), this.persistedSessionId = null, this.sessionAbortController = new AbortController(), this.sessionState = new S({
|
|
4583
5069
|
session: null,
|
|
4584
5070
|
isCreatingSession: !1,
|
|
4585
5071
|
isResolvingSession: !1
|
|
4586
|
-
}), this.sessionsState = new
|
|
5072
|
+
}), this.sessionsState = new S({
|
|
4587
5073
|
data: [],
|
|
4588
5074
|
cursor: void 0,
|
|
4589
5075
|
isLastPage: !1,
|
|
@@ -4597,21 +5083,21 @@ class ja {
|
|
|
4597
5083
|
this.persistSession
|
|
4598
5084
|
));
|
|
4599
5085
|
}, this.restoreActiveSessionTracking = () => {
|
|
4600
|
-
var
|
|
4601
|
-
(
|
|
4602
|
-
}, this.trackActiveSession = (
|
|
4603
|
-
var
|
|
4604
|
-
(
|
|
5086
|
+
var a;
|
|
5087
|
+
(a = this.stopPersistingSession) == null || a.call(this), this.stopPersistingSession = void 0, this.registerActiveSessionPersistence();
|
|
5088
|
+
}, this.trackActiveSession = (a) => {
|
|
5089
|
+
var i;
|
|
5090
|
+
(i = this.stopPersistingSession) == null || i.call(this), this.stopPersistingSession = a.sessionState.subscribe(
|
|
4605
5091
|
this.persistSession
|
|
4606
|
-
), this.persistSession(
|
|
4607
|
-
}, this.persistSession = ({ session:
|
|
4608
|
-
const
|
|
4609
|
-
if (!
|
|
4610
|
-
const c =
|
|
5092
|
+
), this.persistSession(a.sessionState.get());
|
|
5093
|
+
}, this.persistSession = ({ session: a }) => {
|
|
5094
|
+
const i = this.storageCtx;
|
|
5095
|
+
if (!i) return;
|
|
5096
|
+
const c = a != null && a.isOpened ? a.id : null;
|
|
4611
5097
|
if (c === this.persistedSessionId || !c && this.persistedSessionId === null) return;
|
|
4612
|
-
this.persistedSessionId = c, (c ?
|
|
4613
|
-
|
|
4614
|
-
error:
|
|
5098
|
+
this.persistedSessionId = c, (c ? i.setActiveSessionId(c) : i.clearActiveSessionId()).catch((_) => {
|
|
5099
|
+
k.warn("failed to persist the active session", {
|
|
5100
|
+
error: _ instanceof Error ? _.message : String(_)
|
|
4615
5101
|
});
|
|
4616
5102
|
});
|
|
4617
5103
|
}, this.getLastActiveSessionId = async () => {
|
|
@@ -4624,238 +5110,253 @@ class ja {
|
|
|
4624
5110
|
}, this.reset = async () => {
|
|
4625
5111
|
this.sessionAbortController.abort(), this.sessionAbortController = new AbortController(), this.sessionState.reset();
|
|
4626
5112
|
}, this.registerSessionsRefresherWrapper = () => {
|
|
4627
|
-
var
|
|
5113
|
+
var a;
|
|
4628
5114
|
// If the widget config was initially provided with a contact token, no state change would be triggered, so we just fetch
|
|
4629
|
-
(
|
|
4630
|
-
|
|
4631
|
-
|
|
5115
|
+
(a = this.contactCtx.state.get().contact) != null && a.token && !this.sessionsState.get().didStartInitialFetch ? this.registerSessionsRefresher() : this.stopWaitingForContact = this.contactCtx.state.subscribe(
|
|
5116
|
+
({ contact: i }) => {
|
|
5117
|
+
i != null && i.token && !this.sessionsState.get().didStartInitialFetch && this.registerSessionsRefresher();
|
|
5118
|
+
}
|
|
5119
|
+
);
|
|
4632
5120
|
}, this.registerSessionsRefresher = () => {
|
|
4633
5121
|
this.sessionsRefresher.startPolling(async () => {
|
|
4634
5122
|
this.sessionsState.get().didStartInitialFetch === !1 && this.sessionsState.setPartial({ didStartInitialFetch: !0 }), await this.refreshSessions(), this.sessionsState.get().isInitialFetchLoading === !0 && this.sessionsState.setPartial({ isInitialFetchLoading: !1 });
|
|
4635
5123
|
}, this.sessionsPollingIntervalSeconds * 1e3);
|
|
5124
|
+
}, this.dispose = ({ clearActiveSession: a = !1 } = {}) => {
|
|
5125
|
+
var i, c;
|
|
5126
|
+
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)
|
|
5127
|
+
return this.persistedSessionId = null, this.storageCtx.clearActiveSessionId().catch((d) => {
|
|
5128
|
+
k.warn("failed to clear the replaced session", {
|
|
5129
|
+
error: d instanceof Error ? d.message : String(d)
|
|
5130
|
+
});
|
|
5131
|
+
});
|
|
4636
5132
|
}, this.getParsedCustomData = () => Object.fromEntries(
|
|
4637
5133
|
Object.entries(this.config.sessionCustomData || {}).map(
|
|
4638
|
-
([
|
|
5134
|
+
([a, i]) => {
|
|
4639
5135
|
var c;
|
|
4640
|
-
return typeof
|
|
5136
|
+
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) || ""];
|
|
4641
5137
|
}
|
|
4642
5138
|
)
|
|
4643
5139
|
), this.createSession = async () => {
|
|
4644
|
-
const { signal:
|
|
5140
|
+
const { signal: a } = this.sessionAbortController;
|
|
4645
5141
|
this.sessionState.setPartial({ session: null, isCreatingSession: !0 });
|
|
4646
5142
|
try {
|
|
4647
|
-
const
|
|
4648
|
-
if (
|
|
4649
|
-
if (
|
|
4650
|
-
if (
|
|
4651
|
-
if (
|
|
4652
|
-
const c = await this.requestSession(
|
|
4653
|
-
return
|
|
5143
|
+
const i = await this.requestSession(a);
|
|
5144
|
+
if (a.aborted) return null;
|
|
5145
|
+
if (i.session) return i.session;
|
|
5146
|
+
if (i.status === 401 && await this.contactCtx.recoverFromStaleToken()) {
|
|
5147
|
+
if (a.aborted) return null;
|
|
5148
|
+
const c = await this.requestSession(a);
|
|
5149
|
+
return a.aborted ? null : c.session ? c.session : (k.error("failed to create session", c.error), null);
|
|
4654
5150
|
}
|
|
4655
|
-
return
|
|
4656
|
-
} catch (
|
|
4657
|
-
return
|
|
5151
|
+
return k.error("failed to create session", i.error), null;
|
|
5152
|
+
} catch (i) {
|
|
5153
|
+
return a.aborted || k.error("failed to create session", i), null;
|
|
4658
5154
|
} finally {
|
|
4659
|
-
|
|
5155
|
+
a.aborted || this.sessionState.setPartial({ isCreatingSession: !1 });
|
|
4660
5156
|
}
|
|
4661
|
-
}, this.requestSession = async (
|
|
5157
|
+
}, this.requestSession = async (a) => {
|
|
4662
5158
|
var u, m, g;
|
|
4663
|
-
const
|
|
5159
|
+
const i = (u = this.contactCtx.state.get().contact) == null ? void 0 : u.externalId, c = {
|
|
4664
5160
|
...this.getParsedCustomData(),
|
|
4665
|
-
...
|
|
5161
|
+
...i ? { external_id: i } : {}
|
|
4666
5162
|
}, {
|
|
4667
5163
|
data: d,
|
|
4668
|
-
error:
|
|
5164
|
+
error: _,
|
|
4669
5165
|
response: p
|
|
4670
5166
|
} = await this.api.createSession(
|
|
4671
5167
|
{
|
|
4672
5168
|
customData: Object.keys(c).length > 0 ? c : void 0
|
|
4673
5169
|
},
|
|
4674
|
-
|
|
5170
|
+
a
|
|
4675
5171
|
);
|
|
4676
|
-
if (
|
|
4677
|
-
return { session: null, status: p == null ? void 0 : p.status, error:
|
|
5172
|
+
if (a.aborted || !d)
|
|
5173
|
+
return { session: null, status: p == null ? void 0 : p.status, error: _ };
|
|
4678
5174
|
this.sessionState.setPartial({ session: d });
|
|
4679
5175
|
try {
|
|
4680
5176
|
(g = (m = this.config.hooks) == null ? void 0 : m.onSessionCreated) == null || g.call(m, { session: d });
|
|
4681
|
-
} catch (
|
|
4682
|
-
|
|
5177
|
+
} catch (v) {
|
|
5178
|
+
k.error("onSessionCreated hook failed", v);
|
|
4683
5179
|
}
|
|
4684
5180
|
return { session: d, status: p.status, error: void 0 };
|
|
4685
5181
|
}, this.loadMoreSessions = async () => {
|
|
4686
5182
|
if (this.sessionsState.get().isLastPage) return;
|
|
4687
|
-
const { data:
|
|
5183
|
+
const { data: a } = await this.getSessions({
|
|
4688
5184
|
cursor: this.sessionsState.get().cursor
|
|
4689
5185
|
});
|
|
4690
|
-
if (
|
|
4691
|
-
const c = [...this.sessionsState.get().data, ...
|
|
4692
|
-
(d,
|
|
5186
|
+
if (a) {
|
|
5187
|
+
const c = [...this.sessionsState.get().data, ...a.items].filter(
|
|
5188
|
+
(d, _, p) => _ === p.findIndex((u) => d.id === u.id)
|
|
4693
5189
|
);
|
|
4694
5190
|
this.sessionsState.setPartial({
|
|
4695
5191
|
data: c,
|
|
4696
|
-
cursor:
|
|
4697
|
-
isLastPage:
|
|
5192
|
+
cursor: a.next || void 0,
|
|
5193
|
+
isLastPage: a.next === null
|
|
4698
5194
|
});
|
|
4699
5195
|
}
|
|
4700
|
-
}, this.getSessions = async ({ cursor:
|
|
5196
|
+
}, this.getSessions = async ({ cursor: a }) => {
|
|
4701
5197
|
var c, d;
|
|
4702
5198
|
if (!((c = this.contactCtx.state.get().contact) != null && c.token)) return { data: null };
|
|
4703
|
-
const
|
|
5199
|
+
const i = (d = this.contactCtx.state.get().contact) == null ? void 0 : d.externalId;
|
|
4704
5200
|
return await this.api.getSessions({
|
|
4705
|
-
cursor:
|
|
4706
|
-
filters:
|
|
4707
|
-
external_id:
|
|
5201
|
+
cursor: a,
|
|
5202
|
+
filters: i ? {
|
|
5203
|
+
external_id: i
|
|
4708
5204
|
} : {}
|
|
4709
5205
|
});
|
|
4710
|
-
}, this.setSessions = (
|
|
4711
|
-
const
|
|
4712
|
-
(c, d,
|
|
5206
|
+
}, this.setSessions = (a) => {
|
|
5207
|
+
const i = [...a, ...this.sessionsState.get().data].filter(
|
|
5208
|
+
(c, d, _) => d === _.findIndex((p) => c.id === p.id)
|
|
4713
5209
|
);
|
|
4714
|
-
this.sessionsState.setPartial({ data:
|
|
5210
|
+
this.sessionsState.setPartial({ data: i });
|
|
4715
5211
|
}, this.refreshSessions = async () => {
|
|
4716
|
-
const { data:
|
|
4717
|
-
|
|
5212
|
+
const { data: a } = await this.getSessions({ cursor: void 0 });
|
|
5213
|
+
a && this.setSessions(a.items);
|
|
4718
5214
|
}, this.resolveSession = async () => {
|
|
4719
|
-
const
|
|
4720
|
-
if (!
|
|
5215
|
+
const a = this.sessionState.get().session;
|
|
5216
|
+
if (!a || !a.isOpened)
|
|
4721
5217
|
return { success: !1, error: "Session is not opened" };
|
|
4722
5218
|
this.sessionState.setPartial({ isResolvingSession: !0 });
|
|
4723
|
-
const { signal:
|
|
4724
|
-
if (
|
|
5219
|
+
const { signal: i } = this.sessionAbortController, c = await this.api.resolveSession({ session_id: a.id }, i).catch((p) => {
|
|
5220
|
+
if (i.aborted) return null;
|
|
4725
5221
|
throw p;
|
|
4726
5222
|
});
|
|
4727
|
-
if (!c ||
|
|
5223
|
+
if (!c || i.aborted)
|
|
4728
5224
|
return { success: !1, error: "Session was reset" };
|
|
4729
|
-
const { data: d, error:
|
|
4730
|
-
return d ? (this.sessionState.setPartial({ session: d, isResolvingSession: !1 }), { success: !0, data: d }) : (this.sessionState.setPartial({ isResolvingSession: !1 }), { success: !1, error:
|
|
4731
|
-
}, this.createStateCheckpoint = async (
|
|
5225
|
+
const { data: d, error: _ } = c;
|
|
5226
|
+
return d ? (this.sessionState.setPartial({ session: d, isResolvingSession: !1 }), { success: !0, data: d }) : (this.sessionState.setPartial({ isResolvingSession: !1 }), { success: !1, error: _ });
|
|
5227
|
+
}, this.createStateCheckpoint = async (a) => {
|
|
4732
5228
|
var d;
|
|
4733
|
-
const
|
|
4734
|
-
if (!
|
|
5229
|
+
const i = (d = this.sessionState.get().session) == null ? void 0 : d.id;
|
|
5230
|
+
if (!i) return;
|
|
4735
5231
|
const { data: c } = await this.api.createStateCheckpoint({
|
|
4736
|
-
session_id:
|
|
4737
|
-
payload:
|
|
5232
|
+
session_id: i,
|
|
5233
|
+
payload: a
|
|
4738
5234
|
});
|
|
4739
5235
|
return c != null && c.success ? { success: !0 } : { success: !1 };
|
|
4740
|
-
}, this.config = e, this.api =
|
|
5236
|
+
}, this.config = e, this.api = t, this.contactCtx = o, this.storageCtx = r, this.sessionsPollingIntervalSeconds = l, s ? this.sessionsState = s : this.registerSessionsRefresherWrapper(), this.registerActiveSessionPersistence();
|
|
4741
5237
|
}
|
|
4742
5238
|
}
|
|
4743
|
-
const
|
|
4744
|
-
const
|
|
5239
|
+
const Pa = (n, e, { sendsPageContext: t }) => {
|
|
5240
|
+
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 ? {
|
|
5241
|
+
...l,
|
|
5242
|
+
opencx__connection_request_id: e.connectionRequestId
|
|
5243
|
+
} : l, a = e.withPageEntity === !1 && s && "entity" in s ? Ia(s, "entity") : s;
|
|
4745
5244
|
return {
|
|
4746
|
-
clientContext: e.
|
|
5245
|
+
clientContext: e.background ? { ...a, opencx__background: !0 } : a,
|
|
4747
5246
|
custom_data: {
|
|
4748
|
-
...
|
|
5247
|
+
...n.messageCustomData || {},
|
|
4749
5248
|
...e.customData || {}
|
|
4750
5249
|
}
|
|
4751
5250
|
};
|
|
4752
|
-
},
|
|
4753
|
-
type:
|
|
5251
|
+
}, Ta = ({ type: n, id: e, title: t, meta: o }) => ({
|
|
5252
|
+
type: n,
|
|
4754
5253
|
id: e,
|
|
4755
|
-
title:
|
|
4756
|
-
...
|
|
4757
|
-
}),
|
|
4758
|
-
const { [e]:
|
|
4759
|
-
return Object.keys(
|
|
4760
|
-
},
|
|
4761
|
-
if (typeof
|
|
5254
|
+
title: t,
|
|
5255
|
+
...o ? { meta: o } : {}
|
|
5256
|
+
}), Ia = (n, e) => {
|
|
5257
|
+
const { [e]: t, ...o } = n;
|
|
5258
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
5259
|
+
}, Ma = (n) => {
|
|
5260
|
+
if (typeof n.context != "function") return n.context;
|
|
4762
5261
|
try {
|
|
4763
|
-
return
|
|
5262
|
+
return n.context();
|
|
4764
5263
|
} catch (e) {
|
|
4765
|
-
|
|
5264
|
+
k.error("context getter threw; sending without context", e);
|
|
4766
5265
|
return;
|
|
4767
5266
|
}
|
|
4768
|
-
},
|
|
4769
|
-
const e =
|
|
5267
|
+
}, Da = (n) => {
|
|
5268
|
+
const e = n.features;
|
|
4770
5269
|
if (!e) return;
|
|
4771
|
-
const
|
|
4772
|
-
return e.preamble !== void 0 && (
|
|
4773
|
-
},
|
|
4774
|
-
config:
|
|
5270
|
+
const t = {};
|
|
5271
|
+
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;
|
|
5272
|
+
}, Na = ({
|
|
5273
|
+
config: n,
|
|
4775
5274
|
input: e,
|
|
4776
|
-
uuid:
|
|
4777
|
-
sessionId:
|
|
4778
|
-
content:
|
|
4779
|
-
initialMessages:
|
|
4780
|
-
sendsPageContext:
|
|
5275
|
+
uuid: t,
|
|
5276
|
+
sessionId: o,
|
|
5277
|
+
content: r,
|
|
5278
|
+
initialMessages: l,
|
|
5279
|
+
sendsPageContext: s
|
|
4781
5280
|
}) => {
|
|
4782
|
-
var
|
|
5281
|
+
var a, i, c, d, _, p, u, m;
|
|
4783
5282
|
return {
|
|
4784
|
-
uuid:
|
|
4785
|
-
bot_token:
|
|
4786
|
-
headers:
|
|
4787
|
-
query_params:
|
|
4788
|
-
body_properties:
|
|
4789
|
-
session_id:
|
|
4790
|
-
content:
|
|
5283
|
+
uuid: t,
|
|
5284
|
+
bot_token: n.token,
|
|
5285
|
+
headers: n.headers,
|
|
5286
|
+
query_params: n.queryParams,
|
|
5287
|
+
body_properties: n.bodyProperties,
|
|
5288
|
+
session_id: o,
|
|
5289
|
+
content: r,
|
|
4791
5290
|
attachments: e.attachments,
|
|
4792
|
-
...
|
|
4793
|
-
language:
|
|
4794
|
-
features:
|
|
4795
|
-
presentation:
|
|
5291
|
+
...Pa(n, e, { sendsPageContext: s }),
|
|
5292
|
+
language: n.language,
|
|
5293
|
+
features: Da(n),
|
|
5294
|
+
presentation: n.presentation,
|
|
4796
5295
|
capabilities: [
|
|
4797
|
-
(
|
|
4798
|
-
(
|
|
4799
|
-
(c =
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
5296
|
+
(a = n.capabilities) == null ? void 0 : a.connections,
|
|
5297
|
+
(i = n.capabilities) == null ? void 0 : i.structuredQuestions,
|
|
5298
|
+
(c = n.capabilities) == null ? void 0 : c.richReplies,
|
|
5299
|
+
(d = n.capabilities) == null ? void 0 : d.pageEffects
|
|
5300
|
+
].some((g) => g !== void 0) ? {
|
|
5301
|
+
connections: (_ = n.capabilities) == null ? void 0 : _.connections,
|
|
5302
|
+
structured_questions: (p = n.capabilities) == null ? void 0 : p.structuredQuestions,
|
|
5303
|
+
rich_replies: (u = n.capabilities) == null ? void 0 : u.richReplies,
|
|
5304
|
+
page_effects: (m = n.capabilities) == null ? void 0 : m.pageEffects
|
|
4804
5305
|
} : void 0,
|
|
4805
5306
|
exit_mode_prompt: e.exitModePrompt,
|
|
4806
|
-
initial_messages:
|
|
5307
|
+
initial_messages: l.length > 0 ? l.map((g) => ({ uuid: g.id, content: g.data.message })) : void 0
|
|
4807
5308
|
};
|
|
4808
|
-
},
|
|
5309
|
+
}, C = class C {
|
|
4809
5310
|
constructor({
|
|
4810
5311
|
config: e,
|
|
4811
|
-
api:
|
|
4812
|
-
sessionCtx:
|
|
4813
|
-
contactCtx:
|
|
4814
|
-
streaming:
|
|
4815
|
-
sendsPageContext:
|
|
4816
|
-
getClientCapabilities:
|
|
4817
|
-
getRequestConfig:
|
|
5312
|
+
api: t,
|
|
5313
|
+
sessionCtx: o,
|
|
5314
|
+
contactCtx: r,
|
|
5315
|
+
streaming: l,
|
|
5316
|
+
sendsPageContext: s,
|
|
5317
|
+
getClientCapabilities: a,
|
|
5318
|
+
getRequestConfig: i,
|
|
4818
5319
|
isStreaming: c,
|
|
4819
5320
|
getSendsPageContext: d
|
|
4820
5321
|
}) {
|
|
4821
|
-
this.state = new
|
|
5322
|
+
this.state = new S({
|
|
4822
5323
|
messages: [],
|
|
4823
5324
|
isSendingMessage: !1,
|
|
4824
5325
|
isSendingMessageToAI: !1,
|
|
4825
5326
|
settledAgentUserMessageId: null,
|
|
4826
5327
|
lastAIResMightSolveUserIssue: !1,
|
|
4827
5328
|
isInitialFetchLoading: !1
|
|
4828
|
-
}), this.draftState = new
|
|
5329
|
+
}), this.draftState = new S({
|
|
4829
5330
|
text: "",
|
|
4830
5331
|
mentions: []
|
|
4831
5332
|
}), this.agentHandlers = null, this.bufferedAgentSends = [], this.sendMessageAbortController = new AbortController(), this.messageIdsDispatchedToOnMessageReceivedHook = /* @__PURE__ */ new Set(), this.sentTextHistory = [], this.reset = () => {
|
|
4832
5333
|
this.sendMessageAbortController.abort("Resetting chat"), this.bufferedAgentSends = [], this.state.reset(), this.messageIdsDispatchedToOnMessageReceivedHook.clear(), this.sentTextHistory = [], this.draftState.reset();
|
|
4833
|
-
}, this.rememberSentText = (
|
|
4834
|
-
const p =
|
|
4835
|
-
!p || this.sentTextHistory.at(-1) === p || (this.sentTextHistory.push(p), this.sentTextHistory.length >
|
|
4836
|
-
}, this.getSentTextHistory = () => this.sentTextHistory, this.registerAgentHandlers = (
|
|
4837
|
-
this.agentHandlers =
|
|
5334
|
+
}, this.rememberSentText = (_) => {
|
|
5335
|
+
const p = _.trim();
|
|
5336
|
+
!p || this.sentTextHistory.at(-1) === p || (this.sentTextHistory.push(p), this.sentTextHistory.length > C.SENT_TEXT_HISTORY_MAX && this.sentTextHistory.shift());
|
|
5337
|
+
}, this.getSentTextHistory = () => this.sentTextHistory, this.registerAgentHandlers = (_) => {
|
|
5338
|
+
this.agentHandlers = _;
|
|
4838
5339
|
const p = this.bufferedAgentSends;
|
|
4839
5340
|
this.bufferedAgentSends = [], p.forEach((u) => {
|
|
4840
|
-
|
|
5341
|
+
C.dispatchToEngine(_, u);
|
|
4841
5342
|
});
|
|
4842
|
-
}, this.unregisterAgentHandlers = (
|
|
4843
|
-
this.agentHandlers ===
|
|
4844
|
-
}, this.dispatchToOnMessageReceivedHook = (
|
|
5343
|
+
}, this.unregisterAgentHandlers = (_) => {
|
|
5344
|
+
this.agentHandlers === _ && (this.agentHandlers = null);
|
|
5345
|
+
}, this.dispatchToOnMessageReceivedHook = (_) => {
|
|
4845
5346
|
var u, m;
|
|
4846
|
-
if (
|
|
5347
|
+
if (_.type === "USER" || this.messageIdsDispatchedToOnMessageReceivedHook.has(_.id))
|
|
4847
5348
|
return;
|
|
4848
5349
|
const p = this.sessionCtx.sessionState.get().session;
|
|
4849
|
-
p && (this.messageIdsDispatchedToOnMessageReceivedHook.add(
|
|
4850
|
-
}, this.markAsDispatchedToOnMessageReceivedHook = (
|
|
4851
|
-
|
|
5350
|
+
p && (this.messageIdsDispatchedToOnMessageReceivedHook.add(_.id), (m = (u = this.config.hooks) == null ? void 0 : u.onMessageReceived) == null || m.call(u, { message: _, session: p }));
|
|
5351
|
+
}, this.markAsDispatchedToOnMessageReceivedHook = (_) => {
|
|
5352
|
+
_.forEach(
|
|
4852
5353
|
(p) => this.messageIdsDispatchedToOnMessageReceivedHook.add(p)
|
|
4853
5354
|
);
|
|
4854
5355
|
}, this.buildPersistentInitialMessages = () => {
|
|
4855
5356
|
var p, u;
|
|
4856
5357
|
return !((p = this.sessionCtx.sessionState.get().session) != null && p.id) && this.state.get().messages.length === 0 && ((u = this.config.advancedInitialMessages) == null ? void 0 : u.some((m) => m.persistent)) ? (this.config.advancedInitialMessages || []).filter((m) => m.persistent).map(
|
|
4857
5358
|
(m) => ({
|
|
4858
|
-
id:
|
|
5359
|
+
id: x(),
|
|
4859
5360
|
component: "bot_message",
|
|
4860
5361
|
type: "AI",
|
|
4861
5362
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -4864,60 +5365,68 @@ const Sa = (o, e, { sendsPageContext: a }) => {
|
|
|
4864
5365
|
})
|
|
4865
5366
|
) : [];
|
|
4866
5367
|
}, this.ensureSessionId = async () => {
|
|
4867
|
-
var
|
|
4868
|
-
if (!((
|
|
5368
|
+
var _, p;
|
|
5369
|
+
if (!((_ = this.sessionCtx.sessionState.get().session) != null && _.id)) {
|
|
4869
5370
|
if (!await this.sessionCtx.createSession()) return null;
|
|
4870
5371
|
this.sessionCtx.refreshSessions();
|
|
4871
5372
|
}
|
|
4872
5373
|
return ((p = this.sessionCtx.sessionState.get().session) == null ? void 0 : p.id) ?? null;
|
|
4873
|
-
}, this.rollbackOptimisticMessages = (
|
|
4874
|
-
if (
|
|
4875
|
-
const p = new Set(
|
|
5374
|
+
}, this.rollbackOptimisticMessages = (_) => {
|
|
5375
|
+
if (_.length === 0) return;
|
|
5376
|
+
const p = new Set(_), u = this.state.get().messages, m = u.filter((g) => !p.has(g.id));
|
|
4876
5377
|
m.length !== u.length && this.state.setPartial({ messages: m });
|
|
4877
|
-
}, this.notifySendAccepted = (
|
|
5378
|
+
}, this.notifySendAccepted = (_) => {
|
|
4878
5379
|
var p;
|
|
4879
5380
|
try {
|
|
4880
|
-
(p =
|
|
5381
|
+
(p = _.onAccepted) == null || p.call(_);
|
|
4881
5382
|
} catch (u) {
|
|
4882
|
-
|
|
5383
|
+
k.error("send acceptance callback failed", u);
|
|
4883
5384
|
}
|
|
4884
|
-
}, this.stageUserTurn = async (
|
|
4885
|
-
const u = this.buildUserMessage(
|
|
5385
|
+
}, this.stageUserTurn = async (_, { pending: p }) => {
|
|
5386
|
+
const u = this.buildUserMessage(_);
|
|
4886
5387
|
if (!u) return null;
|
|
4887
|
-
const m = p ? { ...u, pending: !0 } : u, g = this.buildPersistentInitialMessages(),
|
|
4888
|
-
...g.map((
|
|
5388
|
+
const m = p ? { ...u, pending: !0 } : u, g = this.buildPersistentInitialMessages(), v = [
|
|
5389
|
+
...g.map((b) => b.id),
|
|
4889
5390
|
m.id
|
|
4890
5391
|
];
|
|
4891
5392
|
this.state.setPartial({
|
|
4892
|
-
messages: [
|
|
5393
|
+
messages: [
|
|
5394
|
+
...g,
|
|
5395
|
+
...this.state.get().messages,
|
|
5396
|
+
...m.background ? [] : [m]
|
|
5397
|
+
]
|
|
4893
5398
|
});
|
|
4894
5399
|
let f;
|
|
4895
5400
|
try {
|
|
4896
5401
|
f = await this.ensureSessionId();
|
|
4897
|
-
} catch (
|
|
4898
|
-
throw this.rollbackOptimisticMessages(
|
|
5402
|
+
} catch (b) {
|
|
5403
|
+
throw this.rollbackOptimisticMessages(v), b;
|
|
4899
5404
|
}
|
|
4900
|
-
return f ? { sessionId: f, userMessage: m, initialMessages: g } : (this.rollbackOptimisticMessages(
|
|
4901
|
-
}, this.buildQueuedUserMessage = (
|
|
5405
|
+
return f ? { sessionId: f, userMessage: m, initialMessages: g } : (this.rollbackOptimisticMessages(v), null);
|
|
5406
|
+
}, this.buildQueuedUserMessage = (_) => {
|
|
4902
5407
|
var m;
|
|
4903
|
-
const p = this.buildUserMessage(
|
|
5408
|
+
const p = this.buildUserMessage(_);
|
|
4904
5409
|
if (!p) return null;
|
|
4905
5410
|
const u = (m = this.sessionCtx.sessionState.get().session) == null ? void 0 : m.id;
|
|
4906
5411
|
return u ? { sessionId: u, userMessage: { ...p, pending: !0 } } : null;
|
|
4907
|
-
}, this.buildUserMessage = (
|
|
5412
|
+
}, this.buildUserMessage = (_) => {
|
|
4908
5413
|
var p;
|
|
4909
|
-
return !
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
5414
|
+
return !_.content.trim() && (!_.attachments || _.attachments.length === 0) ? (k.warn("cannot send an empty message of no content or attachments"), null) : {
|
|
5415
|
+
...this.toUserMessage(
|
|
5416
|
+
_.content.trim(),
|
|
5417
|
+
_.attachments || void 0,
|
|
5418
|
+
this.sendsPageContext ? C.markedElementNames(_.clientContext) : void 0,
|
|
5419
|
+
this.sendsPageContext && ((p = _.mentions) != null && p.length) ? _.mentions : void 0
|
|
5420
|
+
),
|
|
5421
|
+
..._.background ? { background: !0 } : {}
|
|
5422
|
+
};
|
|
5423
|
+
}, this.appendUserMessageIfAbsent = (_) => {
|
|
5424
|
+
if (_.background) return;
|
|
4916
5425
|
const p = this.state.get().messages;
|
|
4917
|
-
p.some((u) => u.id ===
|
|
4918
|
-
}, this.markUserMessageDelivered = (
|
|
5426
|
+
p.some((u) => u.id === _.id) || this.state.setPartial({ messages: [...p, _] });
|
|
5427
|
+
}, this.markUserMessageDelivered = (_) => {
|
|
4919
5428
|
const p = this.state.get().messages, u = p.findIndex(
|
|
4920
|
-
(
|
|
5429
|
+
(v) => v.id === _ && v.type === "USER" && v.pending
|
|
4921
5430
|
);
|
|
4922
5431
|
if (u === -1) return;
|
|
4923
5432
|
const m = p[u];
|
|
@@ -4926,92 +5435,92 @@ const Sa = (o, e, { sendsPageContext: a }) => {
|
|
|
4926
5435
|
g[u] = { ...m, pending: !1 }, this.state.setPartial({
|
|
4927
5436
|
messages: g
|
|
4928
5437
|
});
|
|
4929
|
-
}, this.sendMessage = async (
|
|
4930
|
-
var u, m, g,
|
|
5438
|
+
}, this.sendMessage = async (_) => {
|
|
5439
|
+
var u, m, g, v, f;
|
|
4931
5440
|
if (this.streaming) {
|
|
4932
5441
|
if (!this.agentHandlers) {
|
|
4933
|
-
this.bufferedAgentSends.push(
|
|
5442
|
+
this.bufferedAgentSends.push(_);
|
|
4934
5443
|
return;
|
|
4935
5444
|
}
|
|
4936
|
-
await this.agentHandlers.send(
|
|
5445
|
+
await this.agentHandlers.send(_);
|
|
4937
5446
|
return;
|
|
4938
5447
|
}
|
|
4939
5448
|
let p;
|
|
4940
5449
|
try {
|
|
4941
|
-
const
|
|
4942
|
-
if (this.blocksSendWhileAwaitingReply && (
|
|
4943
|
-
|
|
4944
|
-
|
|
5450
|
+
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);
|
|
5451
|
+
if (this.blocksSendWhileAwaitingReply && (X || // If last message is from user, then bot response did not arrive yet
|
|
5452
|
+
R && (E == null ? void 0 : E.type) === "USER" && E.id !== this.state.get().settledAgentUserMessageId)) {
|
|
5453
|
+
k.warn("cannot send messages while awaiting AI response");
|
|
4945
5454
|
return;
|
|
4946
5455
|
}
|
|
4947
5456
|
this.sendMessageAbortController.abort("Superseded by a newer message"), this.sendMessageAbortController = new AbortController(), p = this.sendMessageAbortController, this.state.setPartial({
|
|
4948
5457
|
lastAIResMightSolveUserIssue: !1,
|
|
4949
5458
|
isSendingMessage: !0,
|
|
4950
|
-
isSendingMessageToAI: !!
|
|
5459
|
+
isSendingMessageToAI: !!R || !b
|
|
4951
5460
|
});
|
|
4952
|
-
const
|
|
4953
|
-
if (!
|
|
4954
|
-
const { sessionId:
|
|
4955
|
-
this.notifySendAccepted(
|
|
4956
|
-
const { data:
|
|
4957
|
-
|
|
5461
|
+
const K = await this.stageUserTurn(_, { pending: !1 });
|
|
5462
|
+
if (!K) return;
|
|
5463
|
+
const { sessionId: ee, userMessage: L, initialMessages: ae } = K;
|
|
5464
|
+
this.notifySendAccepted(_);
|
|
5465
|
+
const { data: y } = await this.api.sendMessage(
|
|
5466
|
+
Na({
|
|
4958
5467
|
config: {
|
|
4959
5468
|
...this.getRequestConfig(),
|
|
4960
5469
|
capabilities: this.getClientCapabilities()
|
|
4961
5470
|
},
|
|
4962
|
-
input:
|
|
4963
|
-
uuid:
|
|
4964
|
-
sessionId:
|
|
4965
|
-
content:
|
|
4966
|
-
initialMessages:
|
|
5471
|
+
input: _,
|
|
5472
|
+
uuid: L.id,
|
|
5473
|
+
sessionId: ee,
|
|
5474
|
+
content: L.content,
|
|
5475
|
+
initialMessages: ae,
|
|
4967
5476
|
sendsPageContext: this.sendsPageContext
|
|
4968
5477
|
}),
|
|
4969
5478
|
p.signal
|
|
4970
5479
|
);
|
|
4971
|
-
if (
|
|
4972
|
-
const
|
|
4973
|
-
if (
|
|
4974
|
-
const
|
|
4975
|
-
if (!!
|
|
4976
|
-
(
|
|
5480
|
+
if (y != null && y.success) {
|
|
5481
|
+
const z = this.toBotMessage(y);
|
|
5482
|
+
if (z) {
|
|
5483
|
+
const A = this.state.get().messages;
|
|
5484
|
+
if (!!A.some(
|
|
5485
|
+
(te) => te.id === z.id
|
|
4977
5486
|
)) {
|
|
4978
5487
|
this.state.setPartial({
|
|
4979
|
-
lastAIResMightSolveUserIssue: ((u =
|
|
5488
|
+
lastAIResMightSolveUserIssue: ((u = y.autopilotResponse) == null ? void 0 : u.mightSolveUserIssue) || ((m = y.uiResponse) == null ? void 0 : m.mightSolveUserIssue)
|
|
4980
5489
|
});
|
|
4981
5490
|
return;
|
|
4982
5491
|
}
|
|
4983
5492
|
this.state.setPartial({
|
|
4984
|
-
messages: [...
|
|
4985
|
-
lastAIResMightSolveUserIssue: ((g =
|
|
4986
|
-
}), this.dispatchToOnMessageReceivedHook(
|
|
5493
|
+
messages: [...A, z],
|
|
5494
|
+
lastAIResMightSolveUserIssue: ((g = y.autopilotResponse) == null ? void 0 : g.mightSolveUserIssue) || ((v = y.uiResponse) == null ? void 0 : v.mightSolveUserIssue)
|
|
5495
|
+
}), this.dispatchToOnMessageReceivedHook(z);
|
|
4987
5496
|
}
|
|
4988
|
-
|
|
5497
|
+
y.session && this.sessionCtx.sessionState.setPartial({ session: y.session });
|
|
4989
5498
|
} else {
|
|
4990
|
-
const
|
|
4991
|
-
((f =
|
|
4992
|
-
),
|
|
5499
|
+
const z = this.toBotErrorMessage(
|
|
5500
|
+
((f = y == null ? void 0 : y.error) == null ? void 0 : f.message) || Ea(this.config, "turn_failed_message")
|
|
5501
|
+
), A = this.state.get().messages;
|
|
4993
5502
|
this.state.setPartial({
|
|
4994
|
-
messages: [...
|
|
5503
|
+
messages: [...A, z]
|
|
4995
5504
|
});
|
|
4996
5505
|
}
|
|
4997
|
-
} catch (
|
|
4998
|
-
p != null && p.signal.aborted ||
|
|
5506
|
+
} catch (b) {
|
|
5507
|
+
p != null && p.signal.aborted || k.error("failed to send message", b);
|
|
4999
5508
|
} finally {
|
|
5000
5509
|
p != null && p.signal.aborted || this.state.setPartial({
|
|
5001
5510
|
isSendingMessage: !1,
|
|
5002
5511
|
isSendingMessageToAI: !1
|
|
5003
5512
|
});
|
|
5004
5513
|
}
|
|
5005
|
-
}, this.toUserMessage = (
|
|
5514
|
+
}, this.toUserMessage = (_, p, u, m) => {
|
|
5006
5515
|
const g = (() => {
|
|
5007
|
-
const
|
|
5008
|
-
return this.state.get().messages.length === 0 &&
|
|
5516
|
+
const v = this.contactCtx.state.get().extraCollectedData;
|
|
5517
|
+
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(`
|
|
5009
5518
|
`)}
|
|
5010
5519
|
|
|
5011
|
-
${
|
|
5520
|
+
${_}` : _;
|
|
5012
5521
|
})();
|
|
5013
5522
|
return {
|
|
5014
|
-
id:
|
|
5523
|
+
id: x(),
|
|
5015
5524
|
type: "USER",
|
|
5016
5525
|
content: g,
|
|
5017
5526
|
attachments: p,
|
|
@@ -5019,11 +5528,11 @@ ${l}` : l;
|
|
|
5019
5528
|
mentions: m,
|
|
5020
5529
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
5021
5530
|
};
|
|
5022
|
-
}, this.toBotMessage = (
|
|
5531
|
+
}, this.toBotMessage = (_) => {
|
|
5023
5532
|
var p;
|
|
5024
|
-
return
|
|
5533
|
+
return _.success && _.autopilotResponse ? {
|
|
5025
5534
|
type: "AI",
|
|
5026
|
-
id:
|
|
5535
|
+
id: _.autopilotResponse.id || x(),
|
|
5027
5536
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5028
5537
|
component: "bot_message",
|
|
5029
5538
|
agent: this.config.bot ? {
|
|
@@ -5035,24 +5544,24 @@ ${l}` : l;
|
|
|
5035
5544
|
id: null
|
|
5036
5545
|
} : void 0,
|
|
5037
5546
|
data: {
|
|
5038
|
-
message:
|
|
5039
|
-
action: (p =
|
|
5040
|
-
name:
|
|
5041
|
-
data:
|
|
5547
|
+
message: _.autopilotResponse.value.content,
|
|
5548
|
+
action: (p = _.uiResponse) != null && p.value.name ? {
|
|
5549
|
+
name: _.uiResponse.value.name,
|
|
5550
|
+
data: _.uiResponse.value.request_response
|
|
5042
5551
|
} : void 0
|
|
5043
5552
|
}
|
|
5044
5553
|
} : null;
|
|
5045
|
-
}, this.toBotErrorMessage = (
|
|
5554
|
+
}, this.toBotErrorMessage = (_) => ({
|
|
5046
5555
|
type: "AI",
|
|
5047
|
-
id:
|
|
5556
|
+
id: x(),
|
|
5048
5557
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5049
5558
|
component: "bot_message",
|
|
5050
5559
|
data: {
|
|
5051
|
-
message:
|
|
5560
|
+
message: _,
|
|
5052
5561
|
variant: "error",
|
|
5053
5562
|
action: void 0
|
|
5054
5563
|
}
|
|
5055
|
-
}), this.config = e, this.getClientCapabilities =
|
|
5564
|
+
}), 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);
|
|
5056
5565
|
}
|
|
5057
5566
|
/**
|
|
5058
5567
|
* Current transport choice. The org or this embed may request polling
|
|
@@ -5065,18 +5574,18 @@ ${l}` : l;
|
|
|
5065
5574
|
return this.getSendsPageContext();
|
|
5066
5575
|
}
|
|
5067
5576
|
/** Hand a send to the streaming engine; its failure can never propagate. */
|
|
5068
|
-
static dispatchToEngine(e,
|
|
5577
|
+
static dispatchToEngine(e, t) {
|
|
5069
5578
|
try {
|
|
5070
|
-
Promise.resolve(e.send(
|
|
5071
|
-
|
|
5579
|
+
Promise.resolve(e.send(t)).catch((o) => {
|
|
5580
|
+
k.error("streaming send failed", o);
|
|
5072
5581
|
});
|
|
5073
|
-
} catch (
|
|
5074
|
-
|
|
5582
|
+
} catch (o) {
|
|
5583
|
+
k.error("streaming send failed", o);
|
|
5075
5584
|
}
|
|
5076
5585
|
}
|
|
5077
5586
|
get hasPendingAgentWork() {
|
|
5078
|
-
var e,
|
|
5079
|
-
return this.bufferedAgentSends.length > 0 || (((
|
|
5587
|
+
var e, t;
|
|
5588
|
+
return this.bufferedAgentSends.length > 0 || (((t = (e = this.agentHandlers) == null ? void 0 : e.hasPendingWork) == null ? void 0 : t.call(e)) ?? !1);
|
|
5080
5589
|
}
|
|
5081
5590
|
/**
|
|
5082
5591
|
* Defensive read of `clientContext.page_marks` → the user bubble's context
|
|
@@ -5086,23 +5595,23 @@ ${l}` : l;
|
|
|
5086
5595
|
* without a usable name are dropped.
|
|
5087
5596
|
*/
|
|
5088
5597
|
static markedElementNames(e) {
|
|
5089
|
-
const
|
|
5090
|
-
if (!Array.isArray(
|
|
5091
|
-
const
|
|
5092
|
-
if (typeof
|
|
5093
|
-
const
|
|
5094
|
-
if (typeof
|
|
5095
|
-
const
|
|
5598
|
+
const t = e == null ? void 0 : e.page_marks;
|
|
5599
|
+
if (!Array.isArray(t)) return;
|
|
5600
|
+
const o = t.flatMap((r) => {
|
|
5601
|
+
if (typeof r != "object" || r === null) return [];
|
|
5602
|
+
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;
|
|
5603
|
+
if (typeof a != "string" || a.length === 0) return [];
|
|
5604
|
+
const i = r.note, c = r.snapshotUrl;
|
|
5096
5605
|
return [
|
|
5097
5606
|
{
|
|
5098
|
-
name:
|
|
5099
|
-
...typeof
|
|
5607
|
+
name: a,
|
|
5608
|
+
...typeof i == "string" && i.length > 0 ? { note: i } : {},
|
|
5100
5609
|
...typeof c == "string" && c.length > 0 ? { snapshotUrl: c } : {},
|
|
5101
|
-
mark:
|
|
5610
|
+
mark: r
|
|
5102
5611
|
}
|
|
5103
5612
|
];
|
|
5104
5613
|
});
|
|
5105
|
-
return
|
|
5614
|
+
return o.length > 0 ? o : void 0;
|
|
5106
5615
|
}
|
|
5107
5616
|
/**
|
|
5108
5617
|
* The blocking engine refuses a send while the AI reply is pending unless
|
|
@@ -5112,125 +5621,125 @@ ${l}` : l;
|
|
|
5112
5621
|
return !this.streaming && this.config.disableSendingWhenAwaitingAIReply !== !1;
|
|
5113
5622
|
}
|
|
5114
5623
|
};
|
|
5115
|
-
|
|
5116
|
-
let
|
|
5117
|
-
class
|
|
5624
|
+
C.SENT_TEXT_HISTORY_MAX = 50;
|
|
5625
|
+
let D = C;
|
|
5626
|
+
class Ra {
|
|
5118
5627
|
constructor(e) {
|
|
5119
|
-
var
|
|
5628
|
+
var t, o;
|
|
5120
5629
|
this.widget = e, this.subscriptions = [], this.disposed = !1, this.restorableSessionId = null, this.didReadStoredSession = !1, this.readStoredSession = () => {
|
|
5121
5630
|
if (!this.shouldRestoreLastSession) {
|
|
5122
5631
|
this.didReadStoredSession = !0;
|
|
5123
5632
|
return;
|
|
5124
5633
|
}
|
|
5125
|
-
this.sessionCtx.getLastActiveSessionId().then((
|
|
5126
|
-
this.restorableSessionId =
|
|
5634
|
+
this.sessionCtx.getLastActiveSessionId().then((r) => {
|
|
5635
|
+
this.restorableSessionId = r;
|
|
5127
5636
|
}).finally(() => {
|
|
5128
5637
|
this.didReadStoredSession = !0, this.routeFromSessions(this.sessionCtx.sessionsState.get());
|
|
5129
5638
|
});
|
|
5130
5639
|
}, this.registerRoutingListener = () => {
|
|
5131
5640
|
this.subscriptions.push(
|
|
5132
|
-
this.contactCtx.state.subscribe(({ contact:
|
|
5133
|
-
var
|
|
5134
|
-
|
|
5135
|
-
screen: (
|
|
5641
|
+
this.contactCtx.state.subscribe(({ contact: r }) => {
|
|
5642
|
+
var l;
|
|
5643
|
+
r != null && r.token && this.state.get().screen === "welcome" && this.state.setPartial({
|
|
5644
|
+
screen: (l = this.config.router) != null && l.chatScreenOnly ? "chat" : "sessions"
|
|
5136
5645
|
});
|
|
5137
5646
|
})
|
|
5138
5647
|
), this.subscriptions.push(
|
|
5139
5648
|
this.sessionCtx.sessionsState.subscribe(this.routeFromSessions)
|
|
5140
5649
|
);
|
|
5141
5650
|
}, this.routeFromSessions = ({
|
|
5142
|
-
isInitialFetchLoading:
|
|
5143
|
-
data:
|
|
5651
|
+
isInitialFetchLoading: r,
|
|
5652
|
+
data: l
|
|
5144
5653
|
}) => {
|
|
5145
|
-
var
|
|
5654
|
+
var s, a, i, c, d;
|
|
5146
5655
|
if (!(this.disposed || !this.didReadStoredSession)) {
|
|
5147
|
-
if (this.restorableSessionId && !((
|
|
5148
|
-
const
|
|
5656
|
+
if (this.restorableSessionId && !((s = this.sessionCtx.sessionState.get().session) != null && s.id)) {
|
|
5657
|
+
const _ = l.find(
|
|
5149
5658
|
(p) => p.id === this.restorableSessionId && p.isOpened
|
|
5150
5659
|
);
|
|
5151
|
-
if (
|
|
5152
|
-
this.restorableSessionId = null, this.toChatScreen(
|
|
5660
|
+
if (_) {
|
|
5661
|
+
this.restorableSessionId = null, this.toChatScreen(_.id);
|
|
5153
5662
|
return;
|
|
5154
5663
|
}
|
|
5155
|
-
if (
|
|
5664
|
+
if (r) return;
|
|
5156
5665
|
this.restorableSessionId = null;
|
|
5157
5666
|
}
|
|
5158
|
-
if ((
|
|
5667
|
+
if ((a = this.config.router) != null && a.chatScreenOnly && // Do not route to a chat if we are currently inside one already
|
|
5159
5668
|
// This also applies to newly created sessions; the new session will be in `sessionState` before it is refreshed and included in `sessionsState`
|
|
5160
|
-
!((
|
|
5161
|
-
const
|
|
5162
|
-
return
|
|
5669
|
+
!((i = this.sessionCtx.sessionState.get().session) != null && i.id)) {
|
|
5670
|
+
const _ = (c = l.find((p) => p.isOpened)) == null ? void 0 : c.id;
|
|
5671
|
+
return _ ? this.toChatScreen(_) : void 0;
|
|
5163
5672
|
}
|
|
5164
|
-
|
|
5673
|
+
l.length || ((d = this.config.router) == null ? void 0 : d.goToChatIfNoSessions) !== !1 && !r && this.state.get().screen !== "chat" && this.toChatScreen();
|
|
5165
5674
|
}
|
|
5166
5675
|
}, this.dispose = () => {
|
|
5167
|
-
this.disposed = !0, this.subscriptions.forEach((
|
|
5676
|
+
this.disposed = !0, this.subscriptions.forEach((r) => r()), this.subscriptions = [], this.navigateConversation = void 0;
|
|
5168
5677
|
}, this.toSessionsScreen = () => {
|
|
5169
5678
|
this.navigateConversation || this.resetChat(), this.state.setPartial({ screen: "sessions" });
|
|
5170
|
-
}, this.toChatScreen = (
|
|
5171
|
-
var
|
|
5172
|
-
if (this.navigateConversation) return this.navigateConversation(
|
|
5679
|
+
}, this.toChatScreen = (r) => {
|
|
5680
|
+
var s, a;
|
|
5681
|
+
if (this.navigateConversation) return this.navigateConversation(r);
|
|
5173
5682
|
this.resetChat();
|
|
5174
|
-
let
|
|
5175
|
-
if (
|
|
5176
|
-
if (
|
|
5177
|
-
this.sessionCtx.sessionState.setPartial({ session:
|
|
5683
|
+
let l;
|
|
5684
|
+
if (r) {
|
|
5685
|
+
if (l = this.sessionCtx.sessionsState.get().data.find((i) => i.id === r), !l) return;
|
|
5686
|
+
this.sessionCtx.sessionState.setPartial({ session: l });
|
|
5178
5687
|
}
|
|
5179
|
-
return this.state.setPartial({ screen: "chat" }), (
|
|
5180
|
-
}, this.config = e.config, this.contactCtx = e.contactCtx, this.sessionCtx = e.sessionCtx, this.resetChat = e.resetChat, this.state = new
|
|
5181
|
-
screen: this.contactCtx.shouldCollectData() ? "welcome" : (
|
|
5182
|
-
}), this.shouldRestoreLastSession = ((
|
|
5688
|
+
return this.state.setPartial({ screen: "chat" }), (a = (s = this.config.hooks) == null ? void 0 : s.onNavigateToChat) == null || a.call(s, { session: l }), this.widget;
|
|
5689
|
+
}, this.config = e.config, this.contactCtx = e.contactCtx, this.sessionCtx = e.sessionCtx, this.resetChat = e.resetChat, this.state = new S({
|
|
5690
|
+
screen: this.contactCtx.shouldCollectData() ? "welcome" : (t = this.config.router) != null && t.chatScreenOnly ? "chat" : "sessions"
|
|
5691
|
+
}), this.shouldRestoreLastSession = ((o = this.config.router) == null ? void 0 : o.restoreLastSession) ?? !1, this.readStoredSession(), this.registerRoutingListener();
|
|
5183
5692
|
}
|
|
5184
5693
|
}
|
|
5185
|
-
class
|
|
5694
|
+
class Ka {
|
|
5186
5695
|
constructor({
|
|
5187
5696
|
storage: e,
|
|
5188
|
-
config:
|
|
5697
|
+
config: t
|
|
5189
5698
|
}) {
|
|
5190
5699
|
this.KEYS = {
|
|
5191
|
-
contactToken: (
|
|
5192
|
-
externalContactId: (
|
|
5193
|
-
companionPreference: (
|
|
5194
|
-
activeSession: (
|
|
5195
|
-
}, this.setContactToken = async (
|
|
5196
|
-
await this.storage.set(this.KEYS.contactToken(this.config.token),
|
|
5700
|
+
contactToken: (o) => `opencx-widget:org-token-${o}:contact-token`,
|
|
5701
|
+
externalContactId: (o) => `opencx-widget:org-token-${o}:external-contact-id`,
|
|
5702
|
+
companionPreference: (o, r) => `opencx-widget:org-token-${o}:companion-${r}`,
|
|
5703
|
+
activeSession: (o) => `opencx-widget:org-token-${o}:active-session`
|
|
5704
|
+
}, this.setContactToken = async (o) => {
|
|
5705
|
+
await this.storage.set(this.KEYS.contactToken(this.config.token), o);
|
|
5197
5706
|
}, this.getContactToken = async () => this.storage.get(this.KEYS.contactToken(this.config.token)), this.clearContactToken = async () => {
|
|
5198
5707
|
await this.storage.remove(this.KEYS.contactToken(this.config.token));
|
|
5199
|
-
}, this.activeSessionKey = () => this.KEYS.activeSession(this.config.token), this.getActiveSessionId = async () => this.storage.get(this.activeSessionKey()), this.setActiveSessionId = async (
|
|
5200
|
-
await this.storage.set(this.activeSessionKey(),
|
|
5708
|
+
}, this.activeSessionKey = () => this.KEYS.activeSession(this.config.token), this.getActiveSessionId = async () => this.storage.get(this.activeSessionKey()), this.setActiveSessionId = async (o) => {
|
|
5709
|
+
await this.storage.set(this.activeSessionKey(), o);
|
|
5201
5710
|
}, this.clearActiveSessionId = async () => {
|
|
5202
5711
|
await this.storage.remove(this.activeSessionKey());
|
|
5203
|
-
}, this.setExternalContactId = async (
|
|
5204
|
-
await this.storage.set(this.KEYS.externalContactId(this.config.token),
|
|
5205
|
-
}, this.getExternalContactId = async () => this.storage.get(this.KEYS.externalContactId(this.config.token)), this.companionKey = (
|
|
5206
|
-
const
|
|
5207
|
-
if (
|
|
5208
|
-
const
|
|
5209
|
-
return Number.isFinite(
|
|
5210
|
-
}, this.getCompanionPillOffsetX = async () => this.getFiniteNumber(this.companionKey("pill-offset-x")), this.setCompanionPillOffsetX = async (
|
|
5211
|
-
Number.isFinite(
|
|
5212
|
-
}, this.getCompanionSidebarWidth = async () => this.getFiniteNumber(this.companionKey("sidebar-width")), this.setCompanionSidebarWidth = async (
|
|
5213
|
-
Number.isFinite(
|
|
5712
|
+
}, this.setExternalContactId = async (o) => {
|
|
5713
|
+
await this.storage.set(this.KEYS.externalContactId(this.config.token), o);
|
|
5714
|
+
}, 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) => {
|
|
5715
|
+
const r = await this.storage.get(o);
|
|
5716
|
+
if (r === null) return null;
|
|
5717
|
+
const l = Number(r);
|
|
5718
|
+
return Number.isFinite(l) ? l : null;
|
|
5719
|
+
}, this.getCompanionPillOffsetX = async () => this.getFiniteNumber(this.companionKey("pill-offset-x")), this.setCompanionPillOffsetX = async (o) => {
|
|
5720
|
+
Number.isFinite(o) && await this.storage.set(this.companionKey("pill-offset-x"), String(o));
|
|
5721
|
+
}, this.getCompanionSidebarWidth = async () => this.getFiniteNumber(this.companionKey("sidebar-width")), this.setCompanionSidebarWidth = async (o) => {
|
|
5722
|
+
Number.isFinite(o) && await this.storage.set(this.companionKey("sidebar-width"), String(o));
|
|
5214
5723
|
}, this.getCompanionSidebarSide = async () => {
|
|
5215
|
-
const
|
|
5216
|
-
return
|
|
5217
|
-
}, this.setCompanionSidebarSide = async (
|
|
5218
|
-
await this.storage.set(this.companionKey("sidebar-side"),
|
|
5724
|
+
const o = await this.storage.get(this.companionKey("sidebar-side"));
|
|
5725
|
+
return o === "left" || o === "right" ? o : null;
|
|
5726
|
+
}, this.setCompanionSidebarSide = async (o) => {
|
|
5727
|
+
await this.storage.set(this.companionKey("sidebar-side"), o);
|
|
5219
5728
|
}, this.getCompanionLayout = async () => {
|
|
5220
|
-
const
|
|
5221
|
-
return
|
|
5222
|
-
}, this.setCompanionLayout = async (
|
|
5223
|
-
await this.storage.set(this.companionKey("layout"),
|
|
5729
|
+
const o = await this.storage.get(this.companionKey("layout"));
|
|
5730
|
+
return o === "compact" || o === "sidebar" ? o : null;
|
|
5731
|
+
}, this.setCompanionLayout = async (o) => {
|
|
5732
|
+
await this.storage.set(this.companionKey("layout"), o);
|
|
5224
5733
|
}, this.getCompanionSidebarMode = async () => {
|
|
5225
|
-
const
|
|
5226
|
-
return
|
|
5227
|
-
}, this.setCompanionSidebarMode = async (
|
|
5228
|
-
await this.storage.set(this.companionKey("sidebar-mode"),
|
|
5229
|
-
}, this.storage = e, this.config =
|
|
5734
|
+
const o = await this.storage.get(this.companionKey("sidebar-mode"));
|
|
5735
|
+
return o === "docked" || o === "floating" ? o : null;
|
|
5736
|
+
}, this.setCompanionSidebarMode = async (o) => {
|
|
5737
|
+
await this.storage.set(this.companionKey("sidebar-mode"), o);
|
|
5738
|
+
}, this.storage = e, this.config = t;
|
|
5230
5739
|
}
|
|
5231
5740
|
}
|
|
5232
|
-
function
|
|
5233
|
-
org:
|
|
5741
|
+
function La({
|
|
5742
|
+
org: n,
|
|
5234
5743
|
agent: e
|
|
5235
5744
|
}) {
|
|
5236
5745
|
return e ? {
|
|
@@ -5245,7 +5754,7 @@ function Ta({
|
|
|
5245
5754
|
clientTools: e.features.client_tools
|
|
5246
5755
|
}
|
|
5247
5756
|
} : {
|
|
5248
|
-
name:
|
|
5757
|
+
name: n.name,
|
|
5249
5758
|
avatarUrl: null,
|
|
5250
5759
|
streaming: !1,
|
|
5251
5760
|
features: {
|
|
@@ -5256,42 +5765,42 @@ function Ta({
|
|
|
5256
5765
|
}
|
|
5257
5766
|
};
|
|
5258
5767
|
}
|
|
5259
|
-
function M(
|
|
5260
|
-
return
|
|
5768
|
+
function M(n, e) {
|
|
5769
|
+
return n && e !== !1;
|
|
5261
5770
|
}
|
|
5262
|
-
function
|
|
5263
|
-
const
|
|
5771
|
+
function Fa(n, e) {
|
|
5772
|
+
const t = e.features;
|
|
5264
5773
|
return {
|
|
5265
|
-
dictation: M(
|
|
5266
|
-
attachments:
|
|
5774
|
+
dictation: M(n.features.dictation, t == null ? void 0 : t.dictation),
|
|
5775
|
+
attachments: n.features.attachments,
|
|
5267
5776
|
pageContext: M(
|
|
5268
|
-
|
|
5269
|
-
|
|
5777
|
+
n.features.pageContext,
|
|
5778
|
+
t == null ? void 0 : t.pageContext
|
|
5270
5779
|
),
|
|
5271
5780
|
clientTools: M(
|
|
5272
|
-
|
|
5273
|
-
|
|
5781
|
+
n.features.clientTools,
|
|
5782
|
+
t == null ? void 0 : t.clientTools
|
|
5274
5783
|
)
|
|
5275
5784
|
};
|
|
5276
5785
|
}
|
|
5277
|
-
class
|
|
5278
|
-
constructor(e,
|
|
5279
|
-
super(
|
|
5786
|
+
class Oa extends Error {
|
|
5787
|
+
constructor(e, t, o) {
|
|
5788
|
+
super(t), this.name = "WidgetInitializationError", this.code = e, this.details = o;
|
|
5280
5789
|
}
|
|
5281
5790
|
}
|
|
5282
|
-
const
|
|
5791
|
+
const j = class j {
|
|
5283
5792
|
constructor({
|
|
5284
5793
|
config: e,
|
|
5285
|
-
storage:
|
|
5286
|
-
getClientCapabilities:
|
|
5287
|
-
getRequestConfig:
|
|
5288
|
-
modes:
|
|
5289
|
-
org:
|
|
5290
|
-
agent:
|
|
5291
|
-
parent:
|
|
5794
|
+
storage: t,
|
|
5795
|
+
getClientCapabilities: o,
|
|
5796
|
+
getRequestConfig: r,
|
|
5797
|
+
modes: l,
|
|
5798
|
+
org: s,
|
|
5799
|
+
agent: a,
|
|
5800
|
+
parent: i
|
|
5292
5801
|
}) {
|
|
5293
|
-
if (this.modes = [], this.createConversation = () => {
|
|
5294
|
-
const c = new
|
|
5802
|
+
if (this.modes = [], this.disposed = !1, this.createConversation = () => {
|
|
5803
|
+
const c = new j({
|
|
5295
5804
|
config: {
|
|
5296
5805
|
...this.config,
|
|
5297
5806
|
router: {
|
|
@@ -5311,27 +5820,30 @@ const w = class w {
|
|
|
5311
5820
|
return c.routerCtx.state.setPartial({
|
|
5312
5821
|
screen: this.contactCtx.shouldCollectData() ? "welcome" : "chat"
|
|
5313
5822
|
}), c;
|
|
5314
|
-
}, this.releaseConversation = () => {
|
|
5315
|
-
this.
|
|
5823
|
+
}, this.releaseConversation = () => this.dispose(), this.dispose = ({ clearActiveSession: c = !1 } = {}) => {
|
|
5824
|
+
if (this.disposed) return;
|
|
5825
|
+
this.disposed = !0, this.routerCtx.dispose(), this.activeSessionPollingCtx.dispose();
|
|
5826
|
+
const d = this.sessionCtx.dispose({ clearActiveSession: c });
|
|
5827
|
+
return this.messageCtx.reset(), this.uploadCtx.reset(), this.dictationCtx.stop(), d;
|
|
5316
5828
|
}, this.resetChat = () => {
|
|
5317
5829
|
this.sessionCtx.reset(), this.messageCtx.reset(), this.uploadCtx.reset();
|
|
5318
|
-
}, this.reconcileAfterStream = (c) => this.activeSessionPollingCtx.reconcileAfterStream(c), !
|
|
5830
|
+
}, this.reconcileAfterStream = (c) => this.activeSessionPollingCtx.reconcileAfterStream(c), !j.pollingIntervalsSeconds)
|
|
5319
5831
|
throw Error(
|
|
5320
5832
|
"Widget polling values are not defined, did you call WidgetCtx.initialize()"
|
|
5321
5833
|
);
|
|
5322
|
-
this.config = e, this.getRequestConfig =
|
|
5834
|
+
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({
|
|
5323
5835
|
api: this.api,
|
|
5324
5836
|
config: this.config,
|
|
5325
5837
|
storageCtx: this.storageCtx
|
|
5326
|
-
}), this.sessionCtx = new
|
|
5838
|
+
}), this.sessionCtx = new Aa({
|
|
5327
5839
|
config: this.config,
|
|
5328
5840
|
api: this.api,
|
|
5329
5841
|
contactCtx: this.contactCtx,
|
|
5330
5842
|
// Remembers the open conversation so a reload can return to it.
|
|
5331
|
-
storageCtx:
|
|
5332
|
-
sharedSessions:
|
|
5333
|
-
sessionsPollingIntervalSeconds:
|
|
5334
|
-
}), this.messageCtx = new
|
|
5843
|
+
storageCtx: i ? void 0 : this.storageCtx,
|
|
5844
|
+
sharedSessions: i == null ? void 0 : i.sessionCtx.sessionsState,
|
|
5845
|
+
sessionsPollingIntervalSeconds: j.pollingIntervalsSeconds.sessions
|
|
5846
|
+
}), this.messageCtx = new D({
|
|
5335
5847
|
config: this.config,
|
|
5336
5848
|
api: this.api,
|
|
5337
5849
|
sessionCtx: this.sessionCtx,
|
|
@@ -5342,77 +5854,78 @@ const w = class w {
|
|
|
5342
5854
|
isStreaming: () => this.streaming,
|
|
5343
5855
|
sendsPageContext: this.features.pageContext,
|
|
5344
5856
|
getSendsPageContext: () => this.features.pageContext,
|
|
5345
|
-
getClientCapabilities:
|
|
5346
|
-
getRequestConfig:
|
|
5347
|
-
}), this.uploadCtx = new
|
|
5857
|
+
getClientCapabilities: o,
|
|
5858
|
+
getRequestConfig: r
|
|
5859
|
+
}), this.uploadCtx = new ke(this.api), this.csatCtx = new be({
|
|
5348
5860
|
api: this.api,
|
|
5349
5861
|
sessionCtx: this.sessionCtx,
|
|
5350
5862
|
messageCtx: this.messageCtx
|
|
5351
|
-
}), this.dictationCtx = new
|
|
5863
|
+
}), this.dictationCtx = new Fe({
|
|
5352
5864
|
api: this.api,
|
|
5353
5865
|
config: this.config
|
|
5354
|
-
}), this.activeSessionPollingCtx = new
|
|
5866
|
+
}), this.activeSessionPollingCtx = new he({
|
|
5355
5867
|
api: this.api,
|
|
5356
5868
|
config: this.config,
|
|
5357
5869
|
sessionCtx: this.sessionCtx,
|
|
5358
5870
|
messageCtx: this.messageCtx,
|
|
5359
|
-
sessionPollingIntervalSeconds:
|
|
5360
|
-
}), this.routerCtx = new
|
|
5871
|
+
sessionPollingIntervalSeconds: j.pollingIntervalsSeconds.session
|
|
5872
|
+
}), this.routerCtx = new Ra(this);
|
|
5361
5873
|
}
|
|
5362
5874
|
get streaming() {
|
|
5363
|
-
var e,
|
|
5364
|
-
return (e = this.messageCtx) != null && e.hasPendingAgentWork ? !0 : (
|
|
5875
|
+
var e, t;
|
|
5876
|
+
return (e = this.messageCtx) != null && e.hasPendingAgentWork ? !0 : (t = this.messageCtx) != null && t.state.get().isSendingMessage ? !1 : this.agent.streaming && this.getRequestConfig().streaming !== !1;
|
|
5365
5877
|
}
|
|
5366
5878
|
/**
|
|
5367
5879
|
* The org's features narrowed by this embed's `config.features` — the
|
|
5368
5880
|
* answers the UI asks for, resolved against the current options.
|
|
5369
5881
|
*/
|
|
5370
5882
|
get features() {
|
|
5371
|
-
return
|
|
5883
|
+
return Fa(this.agent, this.getRequestConfig());
|
|
5372
5884
|
}
|
|
5373
5885
|
};
|
|
5374
|
-
|
|
5886
|
+
j.pollingIntervalsSeconds = null, j.initialize = async ({
|
|
5375
5887
|
config: e,
|
|
5376
|
-
storage:
|
|
5377
|
-
getClientCapabilities:
|
|
5378
|
-
getRequestConfig:
|
|
5888
|
+
storage: t,
|
|
5889
|
+
getClientCapabilities: o,
|
|
5890
|
+
getRequestConfig: r
|
|
5379
5891
|
}) => {
|
|
5380
|
-
var
|
|
5381
|
-
const
|
|
5892
|
+
var s, a;
|
|
5893
|
+
const l = await new B({
|
|
5382
5894
|
config: e
|
|
5383
5895
|
}).getExternalWidgetConfig();
|
|
5384
|
-
if (!
|
|
5385
|
-
throw
|
|
5896
|
+
if (!l.data)
|
|
5897
|
+
throw k.error("widget config fetch failed", l.error), new Oa(
|
|
5386
5898
|
"config-fetch-failed",
|
|
5387
5899
|
"Failed to fetch widget config",
|
|
5388
|
-
|
|
5900
|
+
l.error
|
|
5389
5901
|
);
|
|
5390
|
-
return
|
|
5391
|
-
session: ((
|
|
5392
|
-
sessions: ((
|
|
5393
|
-
}, new
|
|
5902
|
+
return j.pollingIntervalsSeconds = {
|
|
5903
|
+
session: ((s = l.data) == null ? void 0 : s.sessionPollingIntervalSeconds) || 10,
|
|
5904
|
+
sessions: ((a = l.data) == null ? void 0 : a.sessionsPollingIntervalSeconds) || 60
|
|
5905
|
+
}, new j({
|
|
5394
5906
|
config: e,
|
|
5395
|
-
storage:
|
|
5396
|
-
getClientCapabilities:
|
|
5397
|
-
getRequestConfig:
|
|
5398
|
-
modes:
|
|
5907
|
+
storage: t,
|
|
5908
|
+
getClientCapabilities: o,
|
|
5909
|
+
getRequestConfig: r,
|
|
5910
|
+
modes: l.data.modes || [],
|
|
5399
5911
|
org: {
|
|
5400
|
-
id:
|
|
5401
|
-
name:
|
|
5912
|
+
id: l.data.org.id,
|
|
5913
|
+
name: l.data.org.name
|
|
5402
5914
|
},
|
|
5403
|
-
agent:
|
|
5915
|
+
agent: La(l.data)
|
|
5404
5916
|
});
|
|
5405
5917
|
};
|
|
5406
|
-
let
|
|
5407
|
-
function
|
|
5408
|
-
return
|
|
5409
|
-
|
|
5410
|
-
|
|
5918
|
+
let W = j;
|
|
5919
|
+
function Ya(n, e) {
|
|
5920
|
+
return n ? {
|
|
5921
|
+
streaming: n.streaming && (e == null ? void 0 : e.streaming) !== !1,
|
|
5922
|
+
toolActivity: n.toolActivity === "hidden" || (e == null ? void 0 : e.toolActivity) === "hidden" ? "hidden" : n.toolActivity === "status" || (e == null ? void 0 : e.toolActivity) === "status" ? "status" : "details",
|
|
5923
|
+
reasoning: n.reasoning && (e == null ? void 0 : e.reasoning) !== !1
|
|
5411
5924
|
} : e;
|
|
5412
5925
|
}
|
|
5413
|
-
class
|
|
5414
|
-
constructor({ attack: e, release:
|
|
5415
|
-
this.value = 0, this.attack = e, this.release =
|
|
5926
|
+
class Qa {
|
|
5927
|
+
constructor({ attack: e, release: t }) {
|
|
5928
|
+
this.value = 0, this.attack = e, this.release = t;
|
|
5416
5929
|
}
|
|
5417
5930
|
next(e) {
|
|
5418
5931
|
return this.value += (e - this.value) * (e > this.value ? this.attack : this.release), this.value;
|
|
@@ -5421,54 +5934,56 @@ class Va {
|
|
|
5421
5934
|
return this.value;
|
|
5422
5935
|
}
|
|
5423
5936
|
}
|
|
5424
|
-
const
|
|
5937
|
+
const T = [
|
|
5425
5938
|
"compact",
|
|
5426
5939
|
"sidebar",
|
|
5427
5940
|
"fullscreen"
|
|
5428
|
-
],
|
|
5429
|
-
|
|
5941
|
+
], Ua = new Set(
|
|
5942
|
+
T
|
|
5430
5943
|
);
|
|
5431
|
-
function
|
|
5432
|
-
return
|
|
5944
|
+
function Q(n) {
|
|
5945
|
+
return Ua.has(n);
|
|
5433
5946
|
}
|
|
5434
|
-
function
|
|
5435
|
-
if (!Array.isArray(
|
|
5436
|
-
const e = [],
|
|
5437
|
-
for (const
|
|
5438
|
-
!
|
|
5439
|
-
return e.length > 0 ? e :
|
|
5947
|
+
function Xa(n) {
|
|
5948
|
+
if (!Array.isArray(n)) return T;
|
|
5949
|
+
const e = [], t = /* @__PURE__ */ new Set();
|
|
5950
|
+
for (const o of n)
|
|
5951
|
+
!Q(o) || t.has(o) || (t.add(o), e.push(o));
|
|
5952
|
+
return e.length > 0 ? e : T;
|
|
5440
5953
|
}
|
|
5441
|
-
function
|
|
5442
|
-
return
|
|
5954
|
+
function et(n, e) {
|
|
5955
|
+
return Q(n) && e.includes(n) ? n : e[0] ?? T[0];
|
|
5443
5956
|
}
|
|
5444
|
-
function
|
|
5445
|
-
return
|
|
5957
|
+
function at(n, e) {
|
|
5958
|
+
return n === "left" || n === "right" ? n : e === "rtl" ? "left" : "right";
|
|
5446
5959
|
}
|
|
5447
|
-
function
|
|
5448
|
-
return
|
|
5960
|
+
function tt(n) {
|
|
5961
|
+
return n === "docked" ? "docked" : "floating";
|
|
5449
5962
|
}
|
|
5450
5963
|
export {
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5964
|
+
pe as ConnectionAttemptUnavailableError,
|
|
5965
|
+
ce as ConnectionRequestExpiredError,
|
|
5966
|
+
Qa as DictationLevelSmoother,
|
|
5967
|
+
S as PrimitiveState,
|
|
5968
|
+
W as WidgetCtx,
|
|
5969
|
+
Oa as WidgetInitializationError,
|
|
5970
|
+
Na as buildSendMessageBody,
|
|
5971
|
+
x as genUuid,
|
|
5972
|
+
qa as getTranslation,
|
|
5973
|
+
Ga as isAgentStreamKeepalive,
|
|
5974
|
+
me as isExhaustive,
|
|
5975
|
+
Z as isRecord,
|
|
5976
|
+
Ja as isRtlLanguage,
|
|
5977
|
+
za as isSupportedLanguage,
|
|
5978
|
+
$a as isTurnSteeredPart,
|
|
5979
|
+
k as log,
|
|
5980
|
+
Xa as normalizeCompanionLayouts,
|
|
5981
|
+
Ya as resolveClientPresentation,
|
|
5982
|
+
et as resolveCompanionDefaultLayout,
|
|
5983
|
+
Ma as resolveConfigContext,
|
|
5984
|
+
xa as resolveLanguage,
|
|
5985
|
+
tt as resolveSidebarMode,
|
|
5986
|
+
at as resolveSidebarSide,
|
|
5987
|
+
Ea as translate
|
|
5473
5988
|
};
|
|
5474
5989
|
//# sourceMappingURL=index.js.map
|