@vanira/sdk 0.0.88 → 0.0.91

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.
@@ -1,6 +1,6 @@
1
1
  var q = Object.defineProperty;
2
- var X = (n, e, t) => e in n ? q(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var d = (n, e, t) => X(n, typeof e != "symbol" ? e + "" : e, t);
2
+ var X = (a, e, t) => e in a ? q(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var d = (a, e, t) => X(a, typeof e != "symbol" ? e + "" : e, t);
4
4
  class Z {
5
5
  pause() {
6
6
  }
@@ -41,8 +41,8 @@ class te {
41
41
  }
42
42
  if (i.data instanceof ArrayBuffer) {
43
43
  try {
44
- const a = new TextDecoder().decode(i.data), r = JSON.parse(a);
45
- (r == null ? void 0 : r.event) === "client_tool_call" && t.onMessage({ text: a });
44
+ const n = new TextDecoder().decode(i.data), r = JSON.parse(n);
45
+ (r == null ? void 0 : r.event) === "client_tool_call" && t.onMessage({ text: n });
46
46
  } catch {
47
47
  }
48
48
  return;
@@ -60,7 +60,7 @@ class te {
60
60
  };
61
61
  }
62
62
  }
63
- const ie = "https://api.vanira.io", c = {
63
+ const ie = "https://api.vanira.io", s = {
64
64
  Form: "vanira_form",
65
65
  Calendar: "vanira_calendar",
66
66
  Navigate: "vanira_navigate",
@@ -87,143 +87,156 @@ const ie = "https://api.vanira.io", c = {
87
87
  KycDocumentCapture: "vanira_kyc_document_capture",
88
88
  KycSelfieCapture: "vanira_kyc_selfie_capture",
89
89
  KycSignatureCapture: "vanira_kyc_signature_capture"
90
- }, ne = Object.values(c), ae = new Set(ne);
91
- function K(n) {
92
- return !!n && ae.has(n);
90
+ }, ae = Object.values(s), ne = new Set(ae), re = /* @__PURE__ */ new Set([
91
+ s.KycDocumentCapture,
92
+ s.KycSelfieCapture,
93
+ s.KycSignatureCapture
94
+ ]);
95
+ [
96
+ ...re,
97
+ s.Form,
98
+ s.Upload,
99
+ s.Camera,
100
+ s.ClipRegion,
101
+ s.ScreenVision,
102
+ s.Navigate
103
+ ];
104
+ function B(a) {
105
+ return !!a && ne.has(a);
93
106
  }
94
- function J(n) {
95
- if (typeof n == "string")
107
+ function J(a) {
108
+ if (typeof a == "string")
96
109
  try {
97
- return JSON.parse(n);
110
+ return JSON.parse(a);
98
111
  } catch {
99
112
  return {};
100
113
  }
101
- return n && typeof n == "object" ? n : {};
114
+ return a && typeof a == "object" ? a : {};
102
115
  }
103
116
  const $ = {
104
- type_on_whiteboard: c.TypeText,
105
- write_on_whiteboard: c.TypeText,
106
- write_on_white_board: c.TypeText,
107
- dom_typing_simulation: c.TypeText,
108
- write_latex_text: c.WriteLatexText,
109
- write_latex_on_board: c.WriteLatexText,
110
- latex_on_whiteboard: c.WriteLatexText,
111
- show_geogebra: c.GeoGebra,
112
- geogebra_diagram: c.GeoGebra,
113
- geogebra: c.GeoGebra,
114
- erase_text: c.EraseText,
115
- dom_erase: c.EraseText,
116
- open_live_camera: c.LiveVision,
117
- live_vision: c.LiveVision,
118
- close_live_camera: c.CloseLiveCamera,
119
- stop_live_camera: c.CloseLiveCamera,
120
- open_live_screen: c.LiveScreen,
121
- close_live_screen: c.CloseLiveScreen,
122
- screen_vision: c.ScreenVision,
123
- capture_screen_vision: c.ScreenVision,
124
- capture_screen: c.ScreenVision,
125
- tab_screenshot: c.ScreenVision,
126
- capture_tab: c.ScreenVision,
127
- capture_tab_screenshot: c.ScreenVision,
128
- screenshot_tab: c.ScreenVision,
129
- point_at: c.PointAt,
130
- point_at_screen: c.PointAt,
131
- draw_on_screen: c.DrawOnScreen,
132
- screen_draw: c.DrawOnScreen,
133
- clear_screen_draw: c.ClearScreenDraw,
134
- clear_screen_annotations: c.ClearScreenDraw,
135
- highlight_on_screen: c.HighlightOnScreen,
136
- highlight_element_on_screen: c.HighlightOnScreen,
137
- highlight_screen_element: c.HighlightOnScreen,
138
- kyc_document_capture: c.KycDocumentCapture,
139
- capture_id_document: c.KycDocumentCapture,
140
- document_capture: c.KycDocumentCapture,
141
- capture_kyc_document: c.KycDocumentCapture,
142
- kyc_selfie_capture: c.KycSelfieCapture,
143
- capture_selfie: c.KycSelfieCapture,
144
- selfie_capture: c.KycSelfieCapture,
145
- capture_kyc_selfie: c.KycSelfieCapture,
146
- kyc_signature_capture: c.KycSignatureCapture,
147
- capture_kyc_signature: c.KycSignatureCapture,
148
- signature_capture: c.KycSignatureCapture
117
+ type_on_whiteboard: s.TypeText,
118
+ write_on_whiteboard: s.TypeText,
119
+ write_on_white_board: s.TypeText,
120
+ dom_typing_simulation: s.TypeText,
121
+ write_latex_text: s.WriteLatexText,
122
+ write_latex_on_board: s.WriteLatexText,
123
+ latex_on_whiteboard: s.WriteLatexText,
124
+ show_geogebra: s.GeoGebra,
125
+ geogebra_diagram: s.GeoGebra,
126
+ geogebra: s.GeoGebra,
127
+ erase_text: s.EraseText,
128
+ dom_erase: s.EraseText,
129
+ open_live_camera: s.LiveVision,
130
+ live_vision: s.LiveVision,
131
+ close_live_camera: s.CloseLiveCamera,
132
+ stop_live_camera: s.CloseLiveCamera,
133
+ open_live_screen: s.LiveScreen,
134
+ close_live_screen: s.CloseLiveScreen,
135
+ screen_vision: s.ScreenVision,
136
+ capture_screen_vision: s.ScreenVision,
137
+ capture_screen: s.ScreenVision,
138
+ tab_screenshot: s.ScreenVision,
139
+ capture_tab: s.ScreenVision,
140
+ capture_tab_screenshot: s.ScreenVision,
141
+ screenshot_tab: s.ScreenVision,
142
+ point_at: s.PointAt,
143
+ point_at_screen: s.PointAt,
144
+ draw_on_screen: s.DrawOnScreen,
145
+ screen_draw: s.DrawOnScreen,
146
+ clear_screen_draw: s.ClearScreenDraw,
147
+ clear_screen_annotations: s.ClearScreenDraw,
148
+ highlight_on_screen: s.HighlightOnScreen,
149
+ highlight_element_on_screen: s.HighlightOnScreen,
150
+ highlight_screen_element: s.HighlightOnScreen,
151
+ kyc_document_capture: s.KycDocumentCapture,
152
+ capture_id_document: s.KycDocumentCapture,
153
+ document_capture: s.KycDocumentCapture,
154
+ capture_kyc_document: s.KycDocumentCapture,
155
+ kyc_selfie_capture: s.KycSelfieCapture,
156
+ capture_selfie: s.KycSelfieCapture,
157
+ selfie_capture: s.KycSelfieCapture,
158
+ capture_kyc_selfie: s.KycSelfieCapture,
159
+ kyc_signature_capture: s.KycSignatureCapture,
160
+ capture_kyc_signature: s.KycSignatureCapture,
161
+ signature_capture: s.KycSignatureCapture
149
162
  }, j = {
150
- vanira_tab_screenshot: c.ScreenVision,
151
- vanira_document_capture: c.KycDocumentCapture,
152
- vanira_selfie_capture: c.KycSelfieCapture,
153
- vanira_signature_capture: c.KycSignatureCapture,
154
- vanira_kyc_signature: c.KycSignatureCapture
163
+ vanira_tab_screenshot: s.ScreenVision,
164
+ vanira_document_capture: s.KycDocumentCapture,
165
+ vanira_selfie_capture: s.KycSelfieCapture,
166
+ vanira_signature_capture: s.KycSignatureCapture,
167
+ vanira_kyc_signature: s.KycSignatureCapture
155
168
  };
156
- function re(n, e) {
157
- const t = n.commands ?? (e == null ? void 0 : e.commands) ?? n.construction ?? (e == null ? void 0 : e.construction) ?? n.geogebra_commands ?? (e == null ? void 0 : e.geogebra_commands) ?? n.script ?? (e == null ? void 0 : e.script);
169
+ function se(a, e) {
170
+ const t = a.commands ?? (e == null ? void 0 : e.commands) ?? a.construction ?? (e == null ? void 0 : e.construction) ?? a.geogebra_commands ?? (e == null ? void 0 : e.geogebra_commands) ?? a.script ?? (e == null ? void 0 : e.script);
158
171
  return Array.isArray(t) ? t.some((i) => String(i).trim().length > 0) : typeof t == "string" && t.trim().length > 0;
159
172
  }
160
- function se(n, e) {
161
- const t = n.material_id ?? (e == null ? void 0 : e.material_id) ?? n.materialId ?? (e == null ? void 0 : e.materialId);
173
+ function oe(a, e) {
174
+ const t = a.material_id ?? (e == null ? void 0 : e.material_id) ?? a.materialId ?? (e == null ? void 0 : e.materialId);
162
175
  return typeof t == "string" && t.trim().length > 0;
163
176
  }
164
- function oe(n, e) {
165
- const t = n.latex_text ?? (e == null ? void 0 : e.latex_text);
177
+ function ce(a, e) {
178
+ const t = a.latex_text ?? (e == null ? void 0 : e.latex_text);
166
179
  return typeof t == "string" && t.trim().length > 0;
167
180
  }
168
- function G(n, e) {
169
- const t = n.text_to_type ?? (e == null ? void 0 : e.text_to_type) ?? n.text ?? (e == null ? void 0 : e.text) ?? n.value ?? (e == null ? void 0 : e.value);
181
+ function G(a, e) {
182
+ const t = a.text_to_type ?? (e == null ? void 0 : e.text_to_type) ?? a.text ?? (e == null ? void 0 : e.text) ?? a.value ?? (e == null ? void 0 : e.value);
170
183
  return typeof t == "string" && t.trim().length > 0;
171
184
  }
172
- function ce(n, e) {
173
- const t = n.fields ?? (e == null ? void 0 : e.fields);
185
+ function le(a, e) {
186
+ const t = a.fields ?? (e == null ? void 0 : e.fields);
174
187
  return Array.isArray(t) ? t.length > 0 : typeof t == "string" ? t.split(",").map((i) => i.trim()).filter(Boolean).length > 0 : !1;
175
188
  }
176
- function le(n, e) {
177
- const t = n == null ? void 0 : n.preset_id;
189
+ function de(a, e) {
190
+ const t = a == null ? void 0 : a.preset_id;
178
191
  if (typeof t == "string") {
179
- if (K(t)) return t;
192
+ if (B(t)) return t;
180
193
  const r = j[t];
181
194
  if (r) return r;
182
195
  }
183
- const a = J(e).preset_id;
184
- if (typeof a == "string") {
185
- if (K(a)) return a;
186
- const r = j[a];
196
+ const n = J(e).preset_id;
197
+ if (typeof n == "string") {
198
+ if (B(n)) return n;
199
+ const r = j[n];
187
200
  if (r) return r;
188
201
  }
189
202
  }
190
- function de(n, e, t) {
203
+ function he(a, e, t) {
191
204
  const i = J(e);
192
- let a = le(n, i);
193
- if (a === c.Form && G(i, n) && !ce(i, n))
194
- return c.TypeText;
195
- if (a) return a;
205
+ let n = de(a, i);
206
+ if (n === s.Form && G(i, a) && !le(i, a))
207
+ return s.TypeText;
208
+ if (n) return n;
196
209
  const r = String(t ?? "").trim().toLowerCase();
197
210
  if (r && $[r])
198
211
  return $[r];
199
- if (re(i, n) || se(i, n))
200
- return c.GeoGebra;
201
- if (oe(i, n))
202
- return c.WriteLatexText;
203
- if (G(i, n))
204
- return c.TypeText;
212
+ if (se(i, a) || oe(i, a))
213
+ return s.GeoGebra;
214
+ if (ce(i, a))
215
+ return s.WriteLatexText;
216
+ if (G(i, a))
217
+ return s.TypeText;
205
218
  }
206
- const I = "vanira_latest_call_id", k = "vanira_prospect_id";
207
- function T(n) {
208
- return `vanira_latest_call_id_${n}`;
219
+ const T = "vanira_latest_call_id", k = "vanira_prospect_id";
220
+ function I(a) {
221
+ return `vanira_latest_call_id_${a}`;
209
222
  }
210
- function b(n) {
211
- return `vanira_prospect_id_${n}`;
223
+ function b(a) {
224
+ return `vanira_prospect_id_${a}`;
212
225
  }
213
- function z(n) {
214
- return `vanira_call_meta_${n}`;
226
+ function z(a) {
227
+ return `vanira_call_meta_${a}`;
215
228
  }
216
- function S(n, e) {
217
- if (!n) return null;
229
+ function S(a, e) {
230
+ if (!a) return null;
218
231
  try {
219
- return n.getItem(e);
232
+ return a.getItem(e);
220
233
  } catch {
221
234
  return null;
222
235
  }
223
236
  }
224
- function W(n) {
225
- if (typeof window > "u" || !n) return null;
226
- const e = [], t = S(window.localStorage, z(n));
237
+ function W(a) {
238
+ if (typeof window > "u" || !a) return null;
239
+ const e = [], t = S(window.localStorage, z(a));
227
240
  if (t)
228
241
  try {
229
242
  const h = JSON.parse(t);
@@ -234,89 +247,89 @@ function W(n) {
234
247
  });
235
248
  } catch {
236
249
  }
237
- const i = (h, _, s) => {
250
+ const i = (h, _, o) => {
238
251
  h && e.push({
239
252
  callId: h,
240
253
  prospectId: _ || void 0,
241
- updatedAt: s
254
+ updatedAt: o
242
255
  });
243
- }, a = S(window.localStorage, b(n)), r = S(window.sessionStorage, b(n)), o = S(window.localStorage, k);
256
+ }, n = S(window.localStorage, b(a)), r = S(window.sessionStorage, b(a)), c = S(window.localStorage, k);
244
257
  return i(
245
- S(window.localStorage, T(n)),
246
- a || o,
258
+ S(window.localStorage, I(a)),
259
+ n || c,
247
260
  2
248
261
  ), i(
249
- S(window.sessionStorage, T(n)),
250
- r || o,
262
+ S(window.sessionStorage, I(a)),
263
+ r || c,
251
264
  1
252
- ), i(S(window.localStorage, I), o, 0), i(S(window.sessionStorage, I), o, 0), e.length ? (e.sort((h, _) => _.updatedAt - h.updatedAt), e[0]) : null;
265
+ ), i(S(window.localStorage, T), c, 0), i(S(window.sessionStorage, T), c, 0), e.length ? (e.sort((h, _) => _.updatedAt - h.updatedAt), e[0]) : null;
253
266
  }
254
- function he(n, e, t) {
255
- var a, r, o, h, _, s, u, l, p;
256
- if (typeof window > "u" || !n || !e) return;
267
+ function ue(a, e, t) {
268
+ var n, r, c, h, _, o, u, l, p;
269
+ if (typeof window > "u" || !a || !e) return;
257
270
  const i = {
258
271
  callId: e,
259
272
  prospectId: t,
260
273
  updatedAt: Date.now()
261
274
  };
262
275
  try {
263
- (a = window.localStorage) == null || a.setItem(z(n), JSON.stringify(i)), (r = window.localStorage) == null || r.setItem(T(n), e), (o = window.sessionStorage) == null || o.setItem(T(n), e), t && ((h = window.localStorage) == null || h.setItem(b(n), t), (_ = window.sessionStorage) == null || _.setItem(b(n), t)), (s = window.localStorage) == null || s.setItem(I, e), (u = window.sessionStorage) == null || u.setItem(I, e), t && ((l = window.localStorage) == null || l.setItem(k, t), (p = window.sessionStorage) == null || p.setItem(k, t));
276
+ (n = window.localStorage) == null || n.setItem(z(a), JSON.stringify(i)), (r = window.localStorage) == null || r.setItem(I(a), e), (c = window.sessionStorage) == null || c.setItem(I(a), e), t && ((h = window.localStorage) == null || h.setItem(b(a), t), (_ = window.sessionStorage) == null || _.setItem(b(a), t)), (o = window.localStorage) == null || o.setItem(T, e), (u = window.sessionStorage) == null || u.setItem(T, e), t && ((l = window.localStorage) == null || l.setItem(k, t), (p = window.sessionStorage) == null || p.setItem(k, t));
264
277
  } catch {
265
278
  }
266
279
  }
267
- const ue = /* @__PURE__ */ new Set([
280
+ const pe = /* @__PURE__ */ new Set([
268
281
  "client_tool_call",
269
282
  "clearAudio",
270
283
  "client_tool_cancel"
271
284
  ]);
272
- function pe(n) {
273
- if (!n || typeof n != "object") return !1;
274
- const e = n.event;
275
- return typeof e == "string" && ue.has(e);
285
+ function _e(a) {
286
+ if (!a || typeof a != "object") return !1;
287
+ const e = a.event;
288
+ return typeof e == "string" && pe.has(e);
276
289
  }
277
- const x = 16 * 1024, _e = 256 * 1024;
278
- function E(n, e) {
279
- return (n == null ? void 0 : n.readyState) === "open" && (e == null ? void 0 : e.readyState) === "open";
290
+ const x = 16 * 1024, me = 256 * 1024;
291
+ function E(a, e) {
292
+ return (a == null ? void 0 : a.readyState) === "open" && (e == null ? void 0 : e.readyState) === "open";
280
293
  }
281
- function me(n, e) {
294
+ function fe(a, e) {
282
295
  return {
283
- control: (n == null ? void 0 : n.readyState) ?? "missing",
296
+ control: (a == null ? void 0 : a.readyState) ?? "missing",
284
297
  mediaBytes: (e == null ? void 0 : e.readyState) ?? "missing"
285
298
  };
286
299
  }
287
- async function fe(n, e, t = 8e3) {
288
- if (E(n, e))
300
+ async function ye(a, e, t = 8e3) {
301
+ if (E(a, e))
289
302
  return !0;
290
303
  const i = Date.now() + t;
291
304
  for (; Date.now() < i; ) {
292
- if (E(n, e))
305
+ if (E(a, e))
293
306
  return !0;
294
- await new Promise((a) => setTimeout(a, 50));
307
+ await new Promise((n) => setTimeout(n, 50));
295
308
  }
296
- return E(n, e);
309
+ return E(a, e);
297
310
  }
298
- async function H(n) {
299
- for (; n.bufferedAmount > _e; )
311
+ async function H(a) {
312
+ for (; a.bufferedAmount > me; )
300
313
  await new Promise((e) => setTimeout(e, 10));
301
314
  }
302
- async function ye(n) {
315
+ async function Se(a) {
303
316
  const {
304
317
  bytes: e,
305
318
  filename: t,
306
319
  contentType: i,
307
- reason: a,
320
+ reason: n,
308
321
  message: r,
309
- callId: o,
322
+ callId: c,
310
323
  mediaBytesChannel: h,
311
324
  sendControlEvent: _,
312
- uploadId: s = crypto.randomUUID(),
325
+ uploadId: o = crypto.randomUUID(),
313
326
  uploadKind: u = "media"
314
- } = n, l = e.byteLength, p = l === 0 ? 0 : Math.ceil(l / x);
327
+ } = a, l = e.byteLength, p = l === 0 ? 0 : Math.ceil(l / x);
315
328
  _("client_media_upload_start", {
316
329
  data: {
317
- upload_id: s,
318
- call_id: o,
319
- reason: a,
330
+ upload_id: o,
331
+ call_id: c,
332
+ reason: n,
320
333
  message: r,
321
334
  filename: t,
322
335
  content_type: i,
@@ -333,37 +346,37 @@ async function ye(n) {
333
346
  }
334
347
  return await H(h), _("client_media_upload_complete", {
335
348
  data: {
336
- upload_id: s,
337
- call_id: o,
338
- reason: a,
349
+ upload_id: o,
350
+ call_id: c,
351
+ reason: n,
339
352
  message: r,
340
353
  chunk_count: p,
341
354
  upload_kind: u
342
355
  }
343
- }), { media_id: s, url: "", content_type: i };
356
+ }), { media_id: o, url: "", content_type: i };
344
357
  }
345
- async function Se(n) {
346
- return typeof n.arrayBuffer == "function" ? n.arrayBuffer() : new Response(n).arrayBuffer();
358
+ async function we(a) {
359
+ return typeof a.arrayBuffer == "function" ? a.arrayBuffer() : new Response(a).arrayBuffer();
347
360
  }
348
- const we = 15e3, R = "vanira-connect-stall-prompt";
361
+ const ge = 15e3, R = "vanira-connect-stall-prompt";
349
362
  let v = null;
350
- function ge(n = we) {
363
+ function ve(a = ge) {
351
364
  typeof window > "u" || (g(!1), v = setTimeout(() => {
352
- v = null, ve(), window.dispatchEvent(new CustomEvent("vanira:connect-stall"));
353
- }, n));
365
+ v = null, Ce(), window.dispatchEvent(new CustomEvent("vanira:connect-stall"));
366
+ }, a));
354
367
  }
355
- function g(n = !0) {
356
- v !== null && (clearTimeout(v), v = null), n && P();
368
+ function g(a = !0) {
369
+ v !== null && (clearTimeout(v), v = null), a && P();
357
370
  }
358
371
  function P() {
359
- var n;
360
- typeof document > "u" || (n = document.getElementById(R)) == null || n.remove();
372
+ var a;
373
+ typeof document > "u" || (a = document.getElementById(R)) == null || a.remove();
361
374
  }
362
- function ve() {
375
+ function Ce() {
363
376
  var t, i;
364
377
  if (typeof document > "u" || document.getElementById(R)) return;
365
- const n = document.createElement("div");
366
- n.id = R, n.setAttribute("role", "alertdialog"), n.setAttribute("aria-modal", "true"), n.setAttribute("aria-labelledby", "vanira-stall-title"), n.style.cssText = [
378
+ const a = document.createElement("div");
379
+ a.id = R, a.setAttribute("role", "alertdialog"), a.setAttribute("aria-modal", "true"), a.setAttribute("aria-labelledby", "vanira-stall-title"), a.style.cssText = [
367
380
  "position:fixed",
368
381
  "inset:0",
369
382
  "z-index:2147483646",
@@ -399,11 +412,11 @@ function ve() {
399
412
  <p style="margin:12px 0 0;font-size:12px;color:#888">
400
413
  Tip: Ctrl+Shift+R (Windows) or Cmd+Shift+R (Mac)
401
414
  </p>
402
- `, n.appendChild(e), document.body.appendChild(n), (t = e.querySelector("#vanira-stall-refresh")) == null || t.addEventListener("click", () => {
415
+ `, a.appendChild(e), document.body.appendChild(a), (t = e.querySelector("#vanira-stall-refresh")) == null || t.addEventListener("click", () => {
403
416
  P(), window.location.reload();
404
417
  }), (i = e.querySelector("#vanira-stall-dismiss")) == null || i.addEventListener("click", () => P());
405
418
  }
406
- function Ce(n) {
419
+ function Te(a) {
407
420
  return null;
408
421
  }
409
422
  function C() {
@@ -454,24 +467,24 @@ class Ie {
454
467
  }
455
468
  }
456
469
  attachListeners() {
457
- const e = (r, o = 0) => {
470
+ const e = (r, c = 0) => {
458
471
  const h = () => {
459
472
  const _ = C();
460
473
  _ !== this.lastRoute && this.handleRouteChange(_, r);
461
474
  };
462
- o > 0 ? window.setTimeout(h, o) : queueMicrotask(h);
463
- }, t = () => e("popstate"), i = () => e("hashchange"), a = (r) => {
464
- const o = r.detail;
465
- if ((o == null ? void 0 : o.initiated_by) === "agent") {
475
+ c > 0 ? window.setTimeout(h, c) : queueMicrotask(h);
476
+ }, t = () => e("popstate"), i = () => e("hashchange"), n = (r) => {
477
+ const c = r.detail;
478
+ if ((c == null ? void 0 : c.initiated_by) === "agent") {
466
479
  e("vanira_navigate_agent", 120);
467
480
  return;
468
481
  }
469
482
  e("vanira_navigate", 120);
470
483
  };
471
- window.addEventListener("popstate", t), window.addEventListener("hashchange", i), window.addEventListener("vanira:navigate", a), this.cleanupFns.push(
484
+ window.addEventListener("popstate", t), window.addEventListener("hashchange", i), window.addEventListener("vanira:navigate", n), this.cleanupFns.push(
472
485
  () => window.removeEventListener("popstate", t),
473
486
  () => window.removeEventListener("hashchange", i),
474
- () => window.removeEventListener("vanira:navigate", a)
487
+ () => window.removeEventListener("vanira:navigate", n)
475
488
  ), this.originalPushState = history.pushState.bind(history), this.originalReplaceState = history.replaceState.bind(history), history.pushState = (...r) => {
476
489
  this.originalPushState(...r), e("pushState");
477
490
  }, history.replaceState = (...r) => {
@@ -490,21 +503,21 @@ class Ie {
490
503
  this.scheduleInitialContextSend();
491
504
  return;
492
505
  }
493
- !this.isReady() || Ce() || this.sendRouteContext("route_changed", i, t, "user");
506
+ !this.isReady() || Te() || this.sendRouteContext("route_changed", i, t, "user");
494
507
  }
495
- sendRouteContext(e, t, i, a = "user") {
508
+ sendRouteContext(e, t, i, n = "user") {
496
509
  const r = C();
497
510
  this.lastRoute = r;
498
- const o = {
511
+ const c = {
499
512
  ui_state: "page_navigation",
500
- navigation_led_by: a,
513
+ navigation_led_by: n,
501
514
  current_route: r,
502
515
  current_page: r,
503
516
  user_action: e === "call_started" ? "call_started_on_page" : "user_navigated"
504
517
  };
505
- e === "call_started" ? o.message = `User started the call while viewing ${r}.` : (o.previous_route = t ?? "", o.message = `User navigated from ${t || "(unknown)"} to ${r}.`, i && (o.navigation_source = i));
518
+ e === "call_started" ? c.message = `User started the call while viewing ${r}.` : (c.previous_route = t ?? "", c.message = `User navigated from ${t || "(unknown)"} to ${r}.`, i && (c.navigation_source = i));
506
519
  try {
507
- this.sendContext(o);
520
+ this.sendContext(c);
508
521
  } catch {
509
522
  }
510
523
  }
@@ -556,53 +569,53 @@ const y = class y {
556
569
  d(this, "connectStallTimeoutMs");
557
570
  var _;
558
571
  if (!e.agentId) throw new Error("agentId is required");
559
- const t = !!(e.apiKey || e.token), i = !!(e.serverUrl && e.callId), a = y.normalizeIceServers(
572
+ const t = !!(e.apiKey || e.token), i = !!(e.serverUrl && e.callId), n = y.normalizeIceServers(
560
573
  e.iceServers
561
574
  );
562
575
  if (!t && !i)
563
576
  throw new Error(
564
577
  "apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create"
565
578
  );
566
- this.agentId = e.agentId, this.sessionBehavior = e.sessionBehavior, this.serverUrl = (e.serverUrl || "").replace(/\/$/, ""), this.apiKey = e.apiKey, this.token = e.token, this.prospectName = e.prospectName, this.welcomeMessage = ((_ = e.welcomeMessage) == null ? void 0 : _.trim()) || void 0, this.extraDetails = e.extraDetails, this.backendUrl = (e.backendUrl || ie).replace(/\/$/, ""), a.length && (this.iceServers = a), i && (this.callSessionLoaded = !0);
579
+ this.agentId = e.agentId, this.sessionBehavior = e.sessionBehavior, this.serverUrl = (e.serverUrl || "").replace(/\/$/, ""), this.apiKey = e.apiKey, this.token = e.token, this.prospectName = e.prospectName, this.welcomeMessage = ((_ = e.welcomeMessage) == null ? void 0 : _.trim()) || void 0, this.extraDetails = e.extraDetails, this.backendUrl = (e.backendUrl || ie).replace(/\/$/, ""), n.length && (this.iceServers = n), i && (this.callSessionLoaded = !0);
567
580
  const r = typeof window < "u";
568
581
  this.prospectId = e.prospectId;
569
- const o = e.sessionBehavior === "continue";
570
- if (o && r && !e.callId) {
571
- const s = W(this.agentId);
572
- s && (e.callId || (this.callId = s.callId), !this.prospectId && s.prospectId && (this.prospectId = s.prospectId));
582
+ const c = e.sessionBehavior === "continue";
583
+ if (c && r && !e.callId) {
584
+ const o = W(this.agentId);
585
+ o && (e.callId || (this.callId = o.callId), !this.prospectId && o.prospectId && (this.prospectId = o.prospectId));
573
586
  }
574
587
  if (!this.prospectId && r)
575
588
  try {
576
- const s = W(this.agentId);
577
- this.prospectId = (s == null ? void 0 : s.prospectId) || window.sessionStorage && window.sessionStorage.getItem("vanira_prospect_id") || window.localStorage && window.localStorage.getItem("vanira_prospect_id") || void 0;
589
+ const o = W(this.agentId);
590
+ this.prospectId = (o == null ? void 0 : o.prospectId) || window.sessionStorage && window.sessionStorage.getItem("vanira_prospect_id") || window.localStorage && window.localStorage.getItem("vanira_prospect_id") || void 0;
578
591
  } catch {
579
592
  }
580
- e.callId ? this.callId = e.callId : o || (this.callId = void 0);
593
+ e.callId ? this.callId = e.callId : c || (this.callId = void 0);
581
594
  const h = e.onSessionStarted;
582
- this.onSessionStarted = (s) => {
583
- h == null || h(s), this.emit("session_started", s);
595
+ this.onSessionStarted = (o) => {
596
+ h == null || h(o), this.emit("session_started", o);
584
597
  }, this.liveVision = e.liveVision, this.connectStallTimeoutMs = e.connectStallTimeoutMs ?? 15e3, this.onConnected = () => {
585
- var s;
586
- g(), this._status = "connected", (s = e.onConnected) == null || s.call(e), this.emit("connected"), this.maybeAutoStartLiveCamera();
598
+ var o;
599
+ g(), this._status = "connected", (o = e.onConnected) == null || o.call(e), this.emit("connected"), this.maybeAutoStartLiveCamera();
587
600
  }, this.onDisconnected = () => {
588
- var s;
589
- g(), this._status = "disconnected", (s = e.onDisconnected) == null || s.call(e), this.emit("disconnected");
590
- }, this.onError = (s) => {
601
+ var o;
602
+ g(), this._status = "disconnected", (o = e.onDisconnected) == null || o.call(e), this.emit("disconnected");
603
+ }, this.onError = (o) => {
591
604
  var l;
592
605
  g(), this._status = "error";
593
- const u = typeof s == "string" ? s : (s == null ? void 0 : s.message) || "Connection error";
594
- (l = e.onError) == null || l.call(e, s), this.emit("error", u);
595
- }, this.onTranscription = (s, u, l) => {
606
+ const u = typeof o == "string" ? o : (o == null ? void 0 : o.message) || "Connection error";
607
+ (l = e.onError) == null || l.call(e, o), this.emit("error", u);
608
+ }, this.onTranscription = (o, u, l) => {
596
609
  var p;
597
- (p = e.onTranscription) == null || p.call(e, s, u), this.emit("transcription", { text: s, isFinal: u, role: l });
610
+ (p = e.onTranscription) == null || p.call(e, o, u), this.emit("transcription", { text: o, isFinal: u, role: l });
598
611
  }, this.onLocalStream = e.onLocalStream || (() => {
599
- }), this.onRemoteTrack = (s, u) => {
612
+ }), this.onRemoteTrack = (o, u) => {
600
613
  var l;
601
- (l = e.onRemoteTrack) == null || l.call(e, s, u), this.emit("track", { track: s, stream: u });
602
- }, this.onClientToolCall = (s) => {
614
+ (l = e.onRemoteTrack) == null || l.call(e, o, u), this.emit("track", { track: o, stream: u });
615
+ }, this.onClientToolCall = (o) => {
603
616
  var p;
604
- (p = e.onClientToolCall) == null || p.call(e, s);
605
- const u = (s == null ? void 0 : s.data) || s, l = {
617
+ (p = e.onClientToolCall) == null || p.call(e, o);
618
+ const u = (o == null ? void 0 : o.data) || o, l = {
606
619
  name: String(u.name || u.tool_name || ""),
607
620
  arguments: u.arguments || u.args || {},
608
621
  tool_call_id: String(u.tool_call_id || u.call_id || ""),
@@ -611,10 +624,10 @@ const y = class y {
611
624
  };
612
625
  l.name && l.tool_call_id && this.emit("tool_call", l);
613
626
  }, this.runtime = e.runtime, typeof window < "u" && e.trackRouteContext !== !1 && (this.routeTracker = new Ie({
614
- sendContext: (s) => this.sendContextUpdate(s),
627
+ sendContext: (o) => this.sendContextUpdate(o),
615
628
  isReady: () => {
616
- var s;
617
- return ((s = this.dataChannel) == null ? void 0 : s.readyState) === "open";
629
+ var o;
630
+ return ((o = this.dataChannel) == null ? void 0 : o.readyState) === "open";
618
631
  }
619
632
  }));
620
633
  }
@@ -636,7 +649,7 @@ const y = class y {
636
649
  */
637
650
  async connect() {
638
651
  var t;
639
- this._status = "connecting", this.connectStallTimeoutMs > 0 && ge(this.connectStallTimeoutMs);
652
+ this._status = "connecting", this.connectStallTimeoutMs > 0 && ve(this.connectStallTimeoutMs);
640
653
  const e = ++this.connectGeneration;
641
654
  if (await this.loadCallSession(), !this.isConnectCancelled(e)) {
642
655
  if (!this.serverUrl)
@@ -655,9 +668,9 @@ const y = class y {
655
668
  iceServers: i,
656
669
  iceTransportPolicy: "all"
657
670
  });
658
- let a;
671
+ let n;
659
672
  try {
660
- a = await navigator.mediaDevices.getUserMedia({
673
+ n = await navigator.mediaDevices.getUserMedia({
661
674
  audio: {
662
675
  echoCancellation: !0,
663
676
  noiseSuppression: !0,
@@ -677,16 +690,16 @@ const y = class y {
677
690
  throw l;
678
691
  }
679
692
  if (this.isConnectCancelled(e)) {
680
- a.getTracks().forEach((l) => l.stop());
693
+ n.getTracks().forEach((l) => l.stop());
681
694
  return;
682
695
  }
683
- if (this.localStream = a, !this.pc || this.isConnectCancelled(e)) {
684
- a.getTracks().forEach((l) => l.stop());
696
+ if (this.localStream = n, !this.pc || this.isConnectCancelled(e)) {
697
+ n.getTracks().forEach((l) => l.stop());
685
698
  return;
686
699
  }
687
- if (this.onLocalStream(a), a.getTracks().forEach((l) => {
700
+ if (this.onLocalStream(n), n.getTracks().forEach((l) => {
688
701
  var p;
689
- (p = this.pc) == null || p.addTrack(l, a);
702
+ (p = this.pc) == null || p.addTrack(l, n);
690
703
  }), !this.pc)
691
704
  throw new Error("RTCPeerConnection was closed unexpectedly");
692
705
  this.dataChannel = this.pc.createDataChannel("control"), this.dataChannel.onopen = () => {
@@ -703,7 +716,7 @@ const y = class y {
703
716
  const p = new TextDecoder().decode(l.data);
704
717
  try {
705
718
  const m = JSON.parse(p);
706
- pe(m) && this.handleControlEvent(m);
719
+ _e(m) && this.handleControlEvent(m);
707
720
  } catch {
708
721
  }
709
722
  } catch {
@@ -725,18 +738,18 @@ const y = class y {
725
738
  }, this.onRemoteTrack(p, m)) : p.kind === "video" && this.onRemoteTrack(p, m);
726
739
  };
727
740
  const r = () => {
728
- var m, f, w, U, M, L, D, O, N, V, B;
741
+ var m, f, w, U, M, L, D, O, N, V, K;
729
742
  const l = ((m = this.pc) == null ? void 0 : m.connectionState) === "connected" || ((f = this.pc) == null ? void 0 : f.iceConnectionState) === "connected" || ((w = this.pc) == null ? void 0 : w.iceConnectionState) === "completed", p = ((U = this.pc) == null ? void 0 : U.connectionState) === "failed" || ((M = this.pc) == null ? void 0 : M.iceConnectionState) === "failed" || ((L = this.pc) == null ? void 0 : L.connectionState) === "closed" || ((D = this.pc) == null ? void 0 : D.iceConnectionState) === "closed" || ((O = this.pc) == null ? void 0 : O.connectionState) === "disconnected" || ((N = this.pc) == null ? void 0 : N.iceConnectionState) === "disconnected";
730
- ((V = this.pc) == null ? void 0 : V.connectionState) === "connected" && this.stopRemoteIcePolling(), l && !this.connected ? (this.connected = !0, (B = this.routeTracker) == null || B.start(), this.onConnected()) : p && this.connected && (this.connected = !1, this.liveVisionAutoStarted = !1, this.onDisconnected());
743
+ ((V = this.pc) == null ? void 0 : V.connectionState) === "connected" && this.stopRemoteIcePolling(), l && !this.connected ? (this.connected = !0, (K = this.routeTracker) == null || K.start(), this.onConnected()) : p && this.connected && (this.connected = !1, this.liveVisionAutoStarted = !1, this.onDisconnected());
731
744
  };
732
745
  this.pc.onconnectionstatechange = r, this.pc.oniceconnectionstatechange = r;
733
- const o = this.getIceTrickleUrl();
746
+ const c = this.getIceTrickleUrl();
734
747
  this.pc.onicecandidate = (l) => {
735
- l.candidate && this.sendRemoteIceCandidate(l.candidate, o);
748
+ l.candidate && this.sendRemoteIceCandidate(l.candidate, c);
736
749
  };
737
750
  const h = await this.pc.createOffer();
738
751
  if (this.isConnectCancelled(e) || (await this.pc.setLocalDescription(h), this.isConnectCancelled(e))) return;
739
- const _ = this.serverUrl.includes("?") ? this.serverUrl : `${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`, s = await fetch(_, {
752
+ const _ = this.serverUrl.includes("?") ? this.serverUrl : `${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`, o = await fetch(_, {
740
753
  method: "POST",
741
754
  headers: { "Content-Type": "application/json" },
742
755
  body: JSON.stringify({
@@ -746,13 +759,13 @@ const y = class y {
746
759
  })
747
760
  });
748
761
  if (this.isConnectCancelled(e)) return;
749
- if (!s.ok) {
750
- const l = await s.json();
751
- throw new Error(l.error || `HTTP ${s.status}`);
762
+ if (!o.ok) {
763
+ const l = await o.json();
764
+ throw new Error(l.error || `HTTP ${o.status}`);
752
765
  }
753
- const { answer: u } = await s.json();
766
+ const { answer: u } = await o.json();
754
767
  if (this.isConnectCancelled(e) || !this.pc || (await this.pc.setRemoteDescription(u), this.isConnectCancelled(e)) || (this.remoteDescSet = !0, await this.flushPendingServerIce(), this.isConnectCancelled(e))) return;
755
- this.startRemoteIcePolling(o);
768
+ this.startRemoteIcePolling(c);
756
769
  } catch (i) {
757
770
  if (this.isConnectCancelled(e)) return;
758
771
  throw this.disconnect(), this.onError(i.message || i), i;
@@ -771,8 +784,8 @@ const y = class y {
771
784
  ].join("|");
772
785
  }
773
786
  async postCreateCall(e, t, i) {
774
- var h, _, s;
775
- const a = await fetch(`${this.backendUrl}/calls/create`, {
787
+ var h, _, o;
788
+ const n = await fetch(`${this.backendUrl}/calls/create`, {
776
789
  method: "POST",
777
790
  headers: e,
778
791
  body: JSON.stringify({
@@ -787,25 +800,25 @@ const y = class y {
787
800
  ...i ? { call_id: i } : {}
788
801
  })
789
802
  });
790
- if (!a.ok) {
791
- const u = await a.json().catch(() => ({}));
792
- throw new Error(`[VaniraClient] createCall failed (${a.status}): ${((s = u == null ? void 0 : u.detail) == null ? void 0 : s.message) || (u == null ? void 0 : u.message) || a.statusText}`);
803
+ if (!n.ok) {
804
+ const u = await n.json().catch(() => ({}));
805
+ throw new Error(`[VaniraClient] createCall failed (${n.status}): ${((o = u == null ? void 0 : u.detail) == null ? void 0 : o.message) || (u == null ? void 0 : u.message) || n.statusText}`);
793
806
  }
794
- const r = await a.json();
807
+ const r = await n.json();
795
808
  if (!r.call_id || !r.worker_url)
796
809
  throw new Error("[VaniraClient] /calls/create response missing call_id or worker_url");
797
- const o = y.normalizeIceServers(r.ice_servers);
798
- if (!o.length)
810
+ const c = y.normalizeIceServers(r.ice_servers);
811
+ if (!c.length)
799
812
  throw new Error("[VaniraClient] /calls/create response missing ice_servers");
800
813
  return {
801
814
  callId: r.call_id,
802
815
  prospectId: r.prospect_id || this.prospectId,
803
816
  serverUrl: r.worker_url.replace(/\/$/, ""),
804
- iceServers: o
817
+ iceServers: c
805
818
  };
806
819
  }
807
820
  applyCreateCallSession(e) {
808
- if (this.callId = e.callId, this.prospectId = e.prospectId || this.prospectId, this.serverUrl = e.serverUrl, this.iceServers = e.iceServers, this.callSessionLoaded = !0, he(this.agentId, this.callId || "", this.prospectId), this.onSessionStarted && this.prospectId && this.callId && !this.sessionStartedEmitted)
821
+ if (this.callId = e.callId, this.prospectId = e.prospectId || this.prospectId, this.serverUrl = e.serverUrl, this.iceServers = e.iceServers, this.callSessionLoaded = !0, ue(this.agentId, this.callId || "", this.prospectId), this.onSessionStarted && this.prospectId && this.callId && !this.sessionStartedEmitted)
809
822
  try {
810
823
  this.onSessionStarted({ prospectId: this.prospectId, callId: this.callId, serverUrl: this.serverUrl }), this.sessionStartedEmitted = !0;
811
824
  } catch {
@@ -821,13 +834,13 @@ const y = class y {
821
834
  throw new Error("[VaniraClient] apiKey or token is required to create a call session");
822
835
  const e = { "Content-Type": "application/json" };
823
836
  this.apiKey ? e["X-API-Key"] = this.apiKey : this.token && (e.Authorization = this.token.startsWith("Bearer ") ? this.token : `Bearer ${this.token}`);
824
- const t = this.sessionBehavior === "continue" ? this.callId : void 0, i = this.sessionBehavior === "continue" ? "continue" : "new", a = this.createCallCacheKey(i, t);
825
- let r = y.inflightCreates.get(a);
826
- r || (r = this.postCreateCall(e, i, t), y.inflightCreates.set(a, r), r.finally(() => {
827
- y.inflightCreates.get(a) === r && y.inflightCreates.delete(a);
837
+ const t = this.sessionBehavior === "continue" ? this.callId : void 0, i = this.sessionBehavior === "continue" ? "continue" : "new", n = this.createCallCacheKey(i, t);
838
+ let r = y.inflightCreates.get(n);
839
+ r || (r = this.postCreateCall(e, i, t), y.inflightCreates.set(n, r), r.finally(() => {
840
+ y.inflightCreates.get(n) === r && y.inflightCreates.delete(n);
828
841
  }));
829
- const o = await r;
830
- this.applyCreateCallSession(o);
842
+ const c = await r;
843
+ this.applyCreateCallSession(c);
831
844
  }
832
845
  getIceServers() {
833
846
  var e;
@@ -838,10 +851,10 @@ const y = class y {
838
851
  if (!Array.isArray(e)) return [];
839
852
  const t = [];
840
853
  for (const i of e) {
841
- const a = i == null ? void 0 : i.urls, r = Array.isArray(a) ? a.filter(Boolean) : typeof a == "string" && a.trim() ? [a.trim()] : [];
854
+ const n = i == null ? void 0 : i.urls, r = Array.isArray(n) ? n.filter(Boolean) : typeof n == "string" && n.trim() ? [n.trim()] : [];
842
855
  if (!r.length) continue;
843
- const o = { urls: r.length === 1 ? r[0] : r }, h = i.username, _ = i.credential;
844
- h && (o.username = h), _ && (o.credential = _), t.push(o);
856
+ const c = { urls: r.length === 1 ? r[0] : r }, h = i.username, _ = i.credential;
857
+ h && (c.username = h), _ && (c.credential = _), t.push(c);
845
858
  }
846
859
  return t;
847
860
  }
@@ -874,8 +887,8 @@ const y = class y {
874
887
  body: JSON.stringify({ candidate: e.toJSON() })
875
888
  });
876
889
  if (i.ok) {
877
- const a = await i.json();
878
- await this.applyServerIceCandidates(a.candidates);
890
+ const n = await i.json();
891
+ await this.applyServerIceCandidates(n.candidates);
879
892
  }
880
893
  } catch {
881
894
  }
@@ -921,13 +934,13 @@ const y = class y {
921
934
  var i;
922
935
  const t = Date.now() + 15e3;
923
936
  for (; !this.icePollStop && Date.now() < t; ) {
924
- const a = (i = this.pc) == null ? void 0 : i.connectionState;
925
- if (a === "connected" || a === "failed" || a === "closed") break;
937
+ const n = (i = this.pc) == null ? void 0 : i.connectionState;
938
+ if (n === "connected" || n === "failed" || n === "closed") break;
926
939
  try {
927
940
  const r = await fetch(e, { method: "GET" });
928
941
  if (r.ok) {
929
- const o = await r.json();
930
- if (await this.applyServerIceCandidates(o.candidates), o.done && (!o.candidates || o.candidates.length === 0)) break;
942
+ const c = await r.json();
943
+ if (await this.applyServerIceCandidates(c.candidates), c.done && (!c.candidates || c.candidates.length === 0)) break;
931
944
  }
932
945
  } catch {
933
946
  }
@@ -943,18 +956,18 @@ const y = class y {
943
956
  sendEvent(e, t = {}) {
944
957
  var i;
945
958
  if (((i = this.dataChannel) == null ? void 0 : i.readyState) === "open") {
946
- const a = { event: e, ...t };
947
- this.dataChannel.send(JSON.stringify(a));
959
+ const n = { event: e, ...t };
960
+ this.dataChannel.send(JSON.stringify(n));
948
961
  }
949
962
  }
950
963
  /** Wait for control DataChannel, then send (live vision lifecycle events). */
951
964
  async sendEventWhenReady(e, t = {}, i = 1e4) {
952
965
  var r;
953
- const a = Date.now() + i;
954
- for (; Date.now() < a; ) {
966
+ const n = Date.now() + i;
967
+ for (; Date.now() < n; ) {
955
968
  if (((r = this.dataChannel) == null ? void 0 : r.readyState) === "open")
956
969
  return this.sendEvent(e, t), !0;
957
- await new Promise((o) => setTimeout(o, 50));
970
+ await new Promise((c) => setTimeout(c, 50));
958
971
  }
959
972
  return !1;
960
973
  }
@@ -969,7 +982,7 @@ const y = class y {
969
982
  name: "open_live_camera",
970
983
  tool_call_id: `lv_${crypto.randomUUID()}`,
971
984
  execution_mode: "fire_and_forget",
972
- client_fields: { preset_id: c.LiveVision },
985
+ client_fields: { preset_id: s.LiveVision },
973
986
  arguments: {
974
987
  mode: "live",
975
988
  scope: t,
@@ -997,33 +1010,33 @@ const y = class y {
997
1010
  this.dispatchBoardAbort(
998
1011
  "User interrupted while LaTeX was writing",
999
1012
  void 0,
1000
- c.WriteLatexText
1013
+ s.WriteLatexText
1001
1014
  );
1002
1015
  break;
1003
1016
  case "transcription":
1004
1017
  {
1005
- const i = e.data && typeof e.data == "object" ? e.data : {}, a = String(e.text ?? i.text ?? "").trim(), r = e.isFinal ?? e.is_final ?? i.isFinal ?? i.is_final, o = r === void 0 ? !0 : r === !0 || r === "true", h = String(
1018
+ const i = e.data && typeof e.data == "object" ? e.data : {}, n = String(e.text ?? i.text ?? "").trim(), r = e.isFinal ?? e.is_final ?? i.isFinal ?? i.is_final, c = r === void 0 ? !0 : r === !0 || r === "true", h = String(
1006
1019
  e.role ?? e.speaker ?? i.role ?? i.speaker ?? ""
1007
1020
  ).trim() || void 0;
1008
- a && this.onTranscription(a, o, h);
1021
+ n && this.onTranscription(n, c, h);
1009
1022
  }
1010
1023
  break;
1011
1024
  case "mark":
1012
1025
  break;
1013
1026
  case "client_tool_cancel": {
1014
- const a = (e.data || e).tool_call_id || e.tool_call_id;
1015
- this.dispatchBoardAbort("Tool cancelled by server", a);
1027
+ const n = (e.data || e).tool_call_id || e.tool_call_id;
1028
+ this.dispatchBoardAbort("Tool cancelled by server", n);
1016
1029
  break;
1017
1030
  }
1018
1031
  case "client_tool_call": {
1019
- const i = e.tool_call || e.data || e, a = (i == null ? void 0 : i.tool_call_id) || (i == null ? void 0 : i.call_id) || e.tool_call_id || "";
1020
- a && ((t = this.dataChannel) == null ? void 0 : t.readyState) === "open" && this.dataChannel.send(JSON.stringify({
1032
+ const i = e.tool_call || e.data || e, n = (i == null ? void 0 : i.tool_call_id) || (i == null ? void 0 : i.call_id) || e.tool_call_id || "";
1033
+ n && ((t = this.dataChannel) == null ? void 0 : t.readyState) === "open" && this.dataChannel.send(JSON.stringify({
1021
1034
  event: "client_tool_ack",
1022
- data: { tool_call_id: a }
1035
+ data: { tool_call_id: n }
1023
1036
  }));
1024
- const r = (i == null ? void 0 : i.arguments) || (i == null ? void 0 : i.args) || {}, o = (i == null ? void 0 : i.client_fields) || {}, h = (i == null ? void 0 : i.name) || (i == null ? void 0 : i.tool_name) || "", _ = de(o, r, h);
1037
+ const r = (i == null ? void 0 : i.arguments) || (i == null ? void 0 : i.args) || {}, c = (i == null ? void 0 : i.client_fields) || {}, h = (i == null ? void 0 : i.name) || (i == null ? void 0 : i.tool_name) || "", _ = he(c, r, h);
1025
1038
  if (h === "end_call") {
1026
- a && this.sendToolResult(a, {
1039
+ n && this.sendToolResult(n, {
1027
1040
  status: "client_ack_end_call",
1028
1041
  message: "Ending call."
1029
1042
  }), window.setTimeout(() => this.disconnect(), 120);
@@ -1060,11 +1073,11 @@ const y = class y {
1060
1073
  */
1061
1074
  setMicrophoneMuted(e) {
1062
1075
  var t, i;
1063
- this.micMuted = e, (t = this.localStream) == null || t.getAudioTracks().forEach((a) => {
1064
- a.enabled = !e;
1065
- }), (i = this.pc) == null || i.getSenders().forEach((a) => {
1076
+ this.micMuted = e, (t = this.localStream) == null || t.getAudioTracks().forEach((n) => {
1077
+ n.enabled = !e;
1078
+ }), (i = this.pc) == null || i.getSenders().forEach((n) => {
1066
1079
  var r;
1067
- ((r = a.track) == null ? void 0 : r.kind) === "audio" && (a.track.enabled = !e);
1080
+ ((r = n.track) == null ? void 0 : r.kind) === "audio" && (n.track.enabled = !e);
1068
1081
  });
1069
1082
  }
1070
1083
  isMicrophoneMuted() {
@@ -1169,7 +1182,7 @@ const y = class y {
1169
1182
  * @param message Optional user text message about the file
1170
1183
  */
1171
1184
  async uploadMedia(e, t = "general", i = "") {
1172
- return await fe(this.dataChannel, this.mediaBytesChannel) ? this._uploadMediaViaDataChannel(e, t, i) : (me(this.dataChannel, this.mediaBytesChannel), this._uploadMediaViaHTTP(e, t, i));
1185
+ return await ye(this.dataChannel, this.mediaBytesChannel) ? this._uploadMediaViaDataChannel(e, t, i) : (fe(this.dataChannel, this.mediaBytesChannel), this._uploadMediaViaHTTP(e, t, i));
1173
1186
  }
1174
1187
  /**
1175
1188
  * Upload a live vision / screen frame — HTTP only for now, never sends client_media_update.
@@ -1179,58 +1192,58 @@ const y = class y {
1179
1192
  * the server adds client_media_upload_ready ack — use HTTP for frame JPEGs until then.
1180
1193
  */
1181
1194
  async uploadMediaFrame(e, t = "camera_capture", i) {
1182
- const a = i && !(e instanceof File) ? new File([e], i, { type: e.type || "image/jpeg" }) : e, { media_id: r, url: o, contentType: h } = await this._postMediaUpload(a, t, !0);
1183
- if (!r || !o)
1195
+ const n = i && !(e instanceof File) ? new File([e], i, { type: e.type || "image/jpeg" }) : e, { media_id: r, url: c, contentType: h } = await this._postMediaUpload(n, t, !0);
1196
+ if (!r || !c)
1184
1197
  throw new Error("Frame upload failed: server response missing media_id or url");
1185
- return { media_id: r, url: o, content_type: h };
1198
+ return { media_id: r, url: c, content_type: h };
1186
1199
  }
1187
1200
  /** WebRTC media-bytes path (control start/complete + binary chunks). */
1188
- async _uploadBytesViaDataChannel(e, t, i, a, r) {
1201
+ async _uploadBytesViaDataChannel(e, t, i, n, r) {
1189
1202
  if (!this.callId || !this.mediaBytesChannel)
1190
1203
  throw new Error("Upload failed: call not ready for WebRTC media upload.");
1191
- const o = r || (e instanceof File ? e.name : a === "frame" ? "frame.jpg" : "upload.bin"), h = e.type || (a === "frame" ? "image/jpeg" : "application/octet-stream"), _ = await Se(e);
1192
- return ye({
1204
+ const c = r || (e instanceof File ? e.name : n === "frame" ? "frame.jpg" : "upload.bin"), h = e.type || (n === "frame" ? "image/jpeg" : "application/octet-stream"), _ = await we(e);
1205
+ return Se({
1193
1206
  bytes: _,
1194
- filename: o,
1207
+ filename: c,
1195
1208
  contentType: h,
1196
1209
  reason: t,
1197
1210
  message: i,
1198
1211
  callId: this.callId,
1199
1212
  mediaBytesChannel: this.mediaBytesChannel,
1200
- sendControlEvent: (s, u) => this.sendEvent(s, u),
1201
- uploadKind: a
1213
+ sendControlEvent: (o, u) => this.sendEvent(o, u),
1214
+ uploadKind: n
1202
1215
  });
1203
1216
  }
1204
1217
  async _uploadMediaViaDataChannel(e, t, i) {
1205
- const a = await this._uploadBytesViaDataChannel(e, t, i, "media");
1206
- return { media_id: a.media_id, url: a.url };
1218
+ const n = await this._uploadBytesViaDataChannel(e, t, i, "media");
1219
+ return { media_id: n.media_id, url: n.url };
1207
1220
  }
1208
1221
  /** HTTP fallback — original uploadMedia behavior (unchanged). */
1209
1222
  async _uploadMediaViaHTTP(e, t = "general", i = "") {
1210
- const { media_id: a, url: r, contentType: o } = await this._postMediaUpload(e, t, !0);
1223
+ const { media_id: n, url: r, contentType: c } = await this._postMediaUpload(e, t, !0);
1211
1224
  return this.sendMediaUpdate({
1212
- media_id: a,
1225
+ media_id: n,
1213
1226
  media_url: r,
1214
- content_type: o,
1227
+ content_type: c,
1215
1228
  reason: t,
1216
1229
  message: i
1217
- }), { media_id: a, url: r };
1230
+ }), { media_id: n, url: r };
1218
1231
  }
1219
1232
  async _postMediaUpload(e, t, i = !1) {
1220
1233
  if (!this.serverUrl)
1221
1234
  throw new Error("Upload failed: serverUrl is not set. Connect the VaniraClient first.");
1222
1235
  if (!this.callId)
1223
1236
  throw new Error("Upload failed: callId is missing.");
1224
- const a = this.getWorkerOrigin();
1225
- if (!a)
1237
+ const n = this.getWorkerOrigin();
1238
+ if (!n)
1226
1239
  throw new Error(
1227
1240
  "Upload failed: worker_url is not set. Connect the call before uploading media."
1228
1241
  );
1229
- const r = `${a}/media/upload`, o = new FormData();
1230
- o.append("file", e), o.append("call_id", this.callId), o.append("reason", t);
1242
+ const r = `${n}/media/upload`, c = new FormData();
1243
+ c.append("file", e), c.append("call_id", this.callId), c.append("reason", t);
1231
1244
  const h = await fetch(r, {
1232
1245
  method: "POST",
1233
- body: o
1246
+ body: c
1234
1247
  });
1235
1248
  if (!h.ok) {
1236
1249
  let p = `HTTP ${h.status}`;
@@ -1240,10 +1253,10 @@ const y = class y {
1240
1253
  }
1241
1254
  throw new Error(`Upload failed: ${p}`);
1242
1255
  }
1243
- const _ = await h.json(), s = _.media_id, u = _.url, l = _.content_type || e.type;
1244
- if (!s || !u)
1256
+ const _ = await h.json(), o = _.media_id, u = _.url, l = _.content_type || e.type;
1257
+ if (!o || !u)
1245
1258
  throw new Error("Upload failed: server response missing media_id or url");
1246
- return i ? { media_id: s, url: u, contentType: l } : { media_id: s, url: u, contentType: l };
1259
+ return i ? { media_id: o, url: u, contentType: l } : { media_id: o, url: u, contentType: l };
1247
1260
  }
1248
1261
  // ─── Event emitter (replaces retired VaniraAI) ───────────────────────────
1249
1262
  get status() {
@@ -1261,7 +1274,7 @@ const y = class y {
1261
1274
  }
1262
1275
  emit(e, t) {
1263
1276
  var i;
1264
- (i = this.listeners.get(e)) == null || i.forEach((a) => a(t));
1277
+ (i = this.listeners.get(e)) == null || i.forEach((n) => n(t));
1265
1278
  }
1266
1279
  /** Alias for connect() — VaniraAI compatibility */
1267
1280
  async start() {
@@ -1293,7 +1306,7 @@ const y = class y {
1293
1306
  /** Dedupes concurrent POST /calls/create (e.g. React StrictMode double-mount). */
1294
1307
  d(y, "inflightCreates", /* @__PURE__ */ new Map());
1295
1308
  let A = y;
1296
- const Te = {
1309
+ const be = {
1297
1310
  supportsAudioEndedEvent: !1,
1298
1311
  supportsScreenShare: !1,
1299
1312
  supportsDom: !1,
@@ -1301,28 +1314,28 @@ const Te = {
1301
1314
  supportsCustomElements: !1,
1302
1315
  supportsLocalStorage: !1,
1303
1316
  supportsBroadcastChannel: !1
1304
- }, be = {
1317
+ }, xe = {
1305
1318
  name: "react-native",
1306
1319
  callType: "web",
1307
1320
  runtimeName: "react-native",
1308
1321
  callIdPrefix: "rn_",
1309
- capabilities: Te,
1322
+ capabilities: be,
1310
1323
  audio: new Q(),
1311
1324
  media: new F(),
1312
1325
  peer: new ee(),
1313
1326
  dataChannel: new te()
1314
1327
  };
1315
- function Y(n) {
1328
+ function Y(a) {
1316
1329
  return new A({
1317
- ...n,
1318
- runtime: be
1330
+ ...a,
1331
+ runtime: xe
1319
1332
  });
1320
1333
  }
1321
- const ke = Y;
1322
- function xe(n) {
1323
- return Y(n);
1334
+ const Re = Y;
1335
+ function Ee(a) {
1336
+ return Y(a);
1324
1337
  }
1325
- const Re = xe;
1338
+ const Pe = Ee;
1326
1339
  export {
1327
1340
  Q as RNAudioAdapter,
1328
1341
  te as RNDataChannelAdapter,
@@ -1331,10 +1344,10 @@ export {
1331
1344
  A as VaniraAI,
1332
1345
  A as VaniraClient,
1333
1346
  A as WebRTCClient,
1334
- ke as createReactNativeAI,
1347
+ Re as createReactNativeAI,
1335
1348
  Y as createReactNativeClient,
1336
- Re as createVaniraAI,
1337
- xe as createVaniraClient,
1338
- Te as reactNativeCapabilities,
1339
- be as reactNativeRuntime
1349
+ Pe as createVaniraAI,
1350
+ Ee as createVaniraClient,
1351
+ be as reactNativeCapabilities,
1352
+ xe as reactNativeRuntime
1340
1353
  };