@vanira/sdk 0.0.88 → 0.0.90

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.
@@ -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", o = {
64
64
  Form: "vanira_form",
65
65
  Calendar: "vanira_calendar",
66
66
  Navigate: "vanira_navigate",
@@ -87,8 +87,17 @@ 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) {
90
+ }, ne = Object.values(o), ae = new Set(ne), re = /* @__PURE__ */ new Set([
91
+ o.KycDocumentCapture,
92
+ o.KycSelfieCapture,
93
+ o.KycSignatureCapture
94
+ ]);
95
+ [
96
+ ...re,
97
+ o.Form,
98
+ o.Upload
99
+ ];
100
+ function B(n) {
92
101
  return !!n && ae.has(n);
93
102
  }
94
103
  function J(n) {
@@ -101,67 +110,67 @@ function J(n) {
101
110
  return n && typeof n == "object" ? n : {};
102
111
  }
103
112
  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
113
+ type_on_whiteboard: o.TypeText,
114
+ write_on_whiteboard: o.TypeText,
115
+ write_on_white_board: o.TypeText,
116
+ dom_typing_simulation: o.TypeText,
117
+ write_latex_text: o.WriteLatexText,
118
+ write_latex_on_board: o.WriteLatexText,
119
+ latex_on_whiteboard: o.WriteLatexText,
120
+ show_geogebra: o.GeoGebra,
121
+ geogebra_diagram: o.GeoGebra,
122
+ geogebra: o.GeoGebra,
123
+ erase_text: o.EraseText,
124
+ dom_erase: o.EraseText,
125
+ open_live_camera: o.LiveVision,
126
+ live_vision: o.LiveVision,
127
+ close_live_camera: o.CloseLiveCamera,
128
+ stop_live_camera: o.CloseLiveCamera,
129
+ open_live_screen: o.LiveScreen,
130
+ close_live_screen: o.CloseLiveScreen,
131
+ screen_vision: o.ScreenVision,
132
+ capture_screen_vision: o.ScreenVision,
133
+ capture_screen: o.ScreenVision,
134
+ tab_screenshot: o.ScreenVision,
135
+ capture_tab: o.ScreenVision,
136
+ capture_tab_screenshot: o.ScreenVision,
137
+ screenshot_tab: o.ScreenVision,
138
+ point_at: o.PointAt,
139
+ point_at_screen: o.PointAt,
140
+ draw_on_screen: o.DrawOnScreen,
141
+ screen_draw: o.DrawOnScreen,
142
+ clear_screen_draw: o.ClearScreenDraw,
143
+ clear_screen_annotations: o.ClearScreenDraw,
144
+ highlight_on_screen: o.HighlightOnScreen,
145
+ highlight_element_on_screen: o.HighlightOnScreen,
146
+ highlight_screen_element: o.HighlightOnScreen,
147
+ kyc_document_capture: o.KycDocumentCapture,
148
+ capture_id_document: o.KycDocumentCapture,
149
+ document_capture: o.KycDocumentCapture,
150
+ capture_kyc_document: o.KycDocumentCapture,
151
+ kyc_selfie_capture: o.KycSelfieCapture,
152
+ capture_selfie: o.KycSelfieCapture,
153
+ selfie_capture: o.KycSelfieCapture,
154
+ capture_kyc_selfie: o.KycSelfieCapture,
155
+ kyc_signature_capture: o.KycSignatureCapture,
156
+ capture_kyc_signature: o.KycSignatureCapture,
157
+ signature_capture: o.KycSignatureCapture
149
158
  }, 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
159
+ vanira_tab_screenshot: o.ScreenVision,
160
+ vanira_document_capture: o.KycDocumentCapture,
161
+ vanira_selfie_capture: o.KycSelfieCapture,
162
+ vanira_signature_capture: o.KycSignatureCapture,
163
+ vanira_kyc_signature: o.KycSignatureCapture
155
164
  };
156
- function re(n, e) {
165
+ function se(n, e) {
157
166
  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);
158
167
  return Array.isArray(t) ? t.some((i) => String(i).trim().length > 0) : typeof t == "string" && t.trim().length > 0;
159
168
  }
160
- function se(n, e) {
169
+ function oe(n, e) {
161
170
  const t = n.material_id ?? (e == null ? void 0 : e.material_id) ?? n.materialId ?? (e == null ? void 0 : e.materialId);
162
171
  return typeof t == "string" && t.trim().length > 0;
163
172
  }
164
- function oe(n, e) {
173
+ function ce(n, e) {
165
174
  const t = n.latex_text ?? (e == null ? void 0 : e.latex_text);
166
175
  return typeof t == "string" && t.trim().length > 0;
167
176
  }
@@ -169,42 +178,42 @@ function G(n, e) {
169
178
  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);
170
179
  return typeof t == "string" && t.trim().length > 0;
171
180
  }
172
- function ce(n, e) {
181
+ function le(n, e) {
173
182
  const t = n.fields ?? (e == null ? void 0 : e.fields);
174
183
  return Array.isArray(t) ? t.length > 0 : typeof t == "string" ? t.split(",").map((i) => i.trim()).filter(Boolean).length > 0 : !1;
175
184
  }
176
- function le(n, e) {
185
+ function de(n, e) {
177
186
  const t = n == null ? void 0 : n.preset_id;
178
187
  if (typeof t == "string") {
179
- if (K(t)) return t;
188
+ if (B(t)) return t;
180
189
  const r = j[t];
181
190
  if (r) return r;
182
191
  }
183
192
  const a = J(e).preset_id;
184
193
  if (typeof a == "string") {
185
- if (K(a)) return a;
194
+ if (B(a)) return a;
186
195
  const r = j[a];
187
196
  if (r) return r;
188
197
  }
189
198
  }
190
- function de(n, e, t) {
199
+ function he(n, e, t) {
191
200
  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;
201
+ let a = de(n, i);
202
+ if (a === o.Form && G(i, n) && !le(i, n))
203
+ return o.TypeText;
195
204
  if (a) return a;
196
205
  const r = String(t ?? "").trim().toLowerCase();
197
206
  if (r && $[r])
198
207
  return $[r];
199
- if (re(i, n) || se(i, n))
200
- return c.GeoGebra;
201
- if (oe(i, n))
202
- return c.WriteLatexText;
208
+ if (se(i, n) || oe(i, n))
209
+ return o.GeoGebra;
210
+ if (ce(i, n))
211
+ return o.WriteLatexText;
203
212
  if (G(i, n))
204
- return c.TypeText;
213
+ return o.TypeText;
205
214
  }
206
- const I = "vanira_latest_call_id", k = "vanira_prospect_id";
207
- function T(n) {
215
+ const T = "vanira_latest_call_id", k = "vanira_prospect_id";
216
+ function I(n) {
208
217
  return `vanira_latest_call_id_${n}`;
209
218
  }
210
219
  function b(n) {
@@ -240,19 +249,19 @@ function W(n) {
240
249
  prospectId: _ || void 0,
241
250
  updatedAt: s
242
251
  });
243
- }, a = S(window.localStorage, b(n)), r = S(window.sessionStorage, b(n)), o = S(window.localStorage, k);
252
+ }, a = S(window.localStorage, b(n)), r = S(window.sessionStorage, b(n)), c = S(window.localStorage, k);
244
253
  return i(
245
- S(window.localStorage, T(n)),
246
- a || o,
254
+ S(window.localStorage, I(n)),
255
+ a || c,
247
256
  2
248
257
  ), i(
249
- S(window.sessionStorage, T(n)),
250
- r || o,
258
+ S(window.sessionStorage, I(n)),
259
+ r || c,
251
260
  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;
261
+ ), 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
262
  }
254
- function he(n, e, t) {
255
- var a, r, o, h, _, s, u, l, p;
263
+ function ue(n, e, t) {
264
+ var a, r, c, h, _, s, u, l, p;
256
265
  if (typeof window > "u" || !n || !e) return;
257
266
  const i = {
258
267
  callId: e,
@@ -260,31 +269,31 @@ function he(n, e, t) {
260
269
  updatedAt: Date.now()
261
270
  };
262
271
  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));
272
+ (a = window.localStorage) == null || a.setItem(z(n), JSON.stringify(i)), (r = window.localStorage) == null || r.setItem(I(n), e), (c = window.sessionStorage) == null || c.setItem(I(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(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
273
  } catch {
265
274
  }
266
275
  }
267
- const ue = /* @__PURE__ */ new Set([
276
+ const pe = /* @__PURE__ */ new Set([
268
277
  "client_tool_call",
269
278
  "clearAudio",
270
279
  "client_tool_cancel"
271
280
  ]);
272
- function pe(n) {
281
+ function _e(n) {
273
282
  if (!n || typeof n != "object") return !1;
274
283
  const e = n.event;
275
- return typeof e == "string" && ue.has(e);
284
+ return typeof e == "string" && pe.has(e);
276
285
  }
277
- const x = 16 * 1024, _e = 256 * 1024;
286
+ const x = 16 * 1024, me = 256 * 1024;
278
287
  function E(n, e) {
279
288
  return (n == null ? void 0 : n.readyState) === "open" && (e == null ? void 0 : e.readyState) === "open";
280
289
  }
281
- function me(n, e) {
290
+ function fe(n, e) {
282
291
  return {
283
292
  control: (n == null ? void 0 : n.readyState) ?? "missing",
284
293
  mediaBytes: (e == null ? void 0 : e.readyState) ?? "missing"
285
294
  };
286
295
  }
287
- async function fe(n, e, t = 8e3) {
296
+ async function ye(n, e, t = 8e3) {
288
297
  if (E(n, e))
289
298
  return !0;
290
299
  const i = Date.now() + t;
@@ -296,17 +305,17 @@ async function fe(n, e, t = 8e3) {
296
305
  return E(n, e);
297
306
  }
298
307
  async function H(n) {
299
- for (; n.bufferedAmount > _e; )
308
+ for (; n.bufferedAmount > me; )
300
309
  await new Promise((e) => setTimeout(e, 10));
301
310
  }
302
- async function ye(n) {
311
+ async function Se(n) {
303
312
  const {
304
313
  bytes: e,
305
314
  filename: t,
306
315
  contentType: i,
307
316
  reason: a,
308
317
  message: r,
309
- callId: o,
318
+ callId: c,
310
319
  mediaBytesChannel: h,
311
320
  sendControlEvent: _,
312
321
  uploadId: s = crypto.randomUUID(),
@@ -315,7 +324,7 @@ async function ye(n) {
315
324
  _("client_media_upload_start", {
316
325
  data: {
317
326
  upload_id: s,
318
- call_id: o,
327
+ call_id: c,
319
328
  reason: a,
320
329
  message: r,
321
330
  filename: t,
@@ -334,7 +343,7 @@ async function ye(n) {
334
343
  return await H(h), _("client_media_upload_complete", {
335
344
  data: {
336
345
  upload_id: s,
337
- call_id: o,
346
+ call_id: c,
338
347
  reason: a,
339
348
  message: r,
340
349
  chunk_count: p,
@@ -342,14 +351,14 @@ async function ye(n) {
342
351
  }
343
352
  }), { media_id: s, url: "", content_type: i };
344
353
  }
345
- async function Se(n) {
354
+ async function we(n) {
346
355
  return typeof n.arrayBuffer == "function" ? n.arrayBuffer() : new Response(n).arrayBuffer();
347
356
  }
348
- const we = 15e3, R = "vanira-connect-stall-prompt";
357
+ const ge = 15e3, R = "vanira-connect-stall-prompt";
349
358
  let v = null;
350
- function ge(n = we) {
359
+ function ve(n = ge) {
351
360
  typeof window > "u" || (g(!1), v = setTimeout(() => {
352
- v = null, ve(), window.dispatchEvent(new CustomEvent("vanira:connect-stall"));
361
+ v = null, Ce(), window.dispatchEvent(new CustomEvent("vanira:connect-stall"));
353
362
  }, n));
354
363
  }
355
364
  function g(n = !0) {
@@ -359,7 +368,7 @@ function P() {
359
368
  var n;
360
369
  typeof document > "u" || (n = document.getElementById(R)) == null || n.remove();
361
370
  }
362
- function ve() {
371
+ function Ce() {
363
372
  var t, i;
364
373
  if (typeof document > "u" || document.getElementById(R)) return;
365
374
  const n = document.createElement("div");
@@ -403,7 +412,7 @@ function ve() {
403
412
  P(), window.location.reload();
404
413
  }), (i = e.querySelector("#vanira-stall-dismiss")) == null || i.addEventListener("click", () => P());
405
414
  }
406
- function Ce(n) {
415
+ function Te(n) {
407
416
  return null;
408
417
  }
409
418
  function C() {
@@ -454,15 +463,15 @@ class Ie {
454
463
  }
455
464
  }
456
465
  attachListeners() {
457
- const e = (r, o = 0) => {
466
+ const e = (r, c = 0) => {
458
467
  const h = () => {
459
468
  const _ = C();
460
469
  _ !== this.lastRoute && this.handleRouteChange(_, r);
461
470
  };
462
- o > 0 ? window.setTimeout(h, o) : queueMicrotask(h);
471
+ c > 0 ? window.setTimeout(h, c) : queueMicrotask(h);
463
472
  }, t = () => e("popstate"), i = () => e("hashchange"), a = (r) => {
464
- const o = r.detail;
465
- if ((o == null ? void 0 : o.initiated_by) === "agent") {
473
+ const c = r.detail;
474
+ if ((c == null ? void 0 : c.initiated_by) === "agent") {
466
475
  e("vanira_navigate_agent", 120);
467
476
  return;
468
477
  }
@@ -490,21 +499,21 @@ class Ie {
490
499
  this.scheduleInitialContextSend();
491
500
  return;
492
501
  }
493
- !this.isReady() || Ce() || this.sendRouteContext("route_changed", i, t, "user");
502
+ !this.isReady() || Te() || this.sendRouteContext("route_changed", i, t, "user");
494
503
  }
495
504
  sendRouteContext(e, t, i, a = "user") {
496
505
  const r = C();
497
506
  this.lastRoute = r;
498
- const o = {
507
+ const c = {
499
508
  ui_state: "page_navigation",
500
509
  navigation_led_by: a,
501
510
  current_route: r,
502
511
  current_page: r,
503
512
  user_action: e === "call_started" ? "call_started_on_page" : "user_navigated"
504
513
  };
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));
514
+ 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
515
  try {
507
- this.sendContext(o);
516
+ this.sendContext(c);
508
517
  } catch {
509
518
  }
510
519
  }
@@ -566,8 +575,8 @@ const y = class y {
566
575
  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);
567
576
  const r = typeof window < "u";
568
577
  this.prospectId = e.prospectId;
569
- const o = e.sessionBehavior === "continue";
570
- if (o && r && !e.callId) {
578
+ const c = e.sessionBehavior === "continue";
579
+ if (c && r && !e.callId) {
571
580
  const s = W(this.agentId);
572
581
  s && (e.callId || (this.callId = s.callId), !this.prospectId && s.prospectId && (this.prospectId = s.prospectId));
573
582
  }
@@ -577,7 +586,7 @@ const y = class y {
577
586
  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;
578
587
  } catch {
579
588
  }
580
- e.callId ? this.callId = e.callId : o || (this.callId = void 0);
589
+ e.callId ? this.callId = e.callId : c || (this.callId = void 0);
581
590
  const h = e.onSessionStarted;
582
591
  this.onSessionStarted = (s) => {
583
592
  h == null || h(s), this.emit("session_started", s);
@@ -636,7 +645,7 @@ const y = class y {
636
645
  */
637
646
  async connect() {
638
647
  var t;
639
- this._status = "connecting", this.connectStallTimeoutMs > 0 && ge(this.connectStallTimeoutMs);
648
+ this._status = "connecting", this.connectStallTimeoutMs > 0 && ve(this.connectStallTimeoutMs);
640
649
  const e = ++this.connectGeneration;
641
650
  if (await this.loadCallSession(), !this.isConnectCancelled(e)) {
642
651
  if (!this.serverUrl)
@@ -703,7 +712,7 @@ const y = class y {
703
712
  const p = new TextDecoder().decode(l.data);
704
713
  try {
705
714
  const m = JSON.parse(p);
706
- pe(m) && this.handleControlEvent(m);
715
+ _e(m) && this.handleControlEvent(m);
707
716
  } catch {
708
717
  }
709
718
  } catch {
@@ -725,14 +734,14 @@ const y = class y {
725
734
  }, this.onRemoteTrack(p, m)) : p.kind === "video" && this.onRemoteTrack(p, m);
726
735
  };
727
736
  const r = () => {
728
- var m, f, w, U, M, L, D, O, N, V, B;
737
+ var m, f, w, U, M, L, D, O, N, V, K;
729
738
  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());
739
+ ((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
740
  };
732
741
  this.pc.onconnectionstatechange = r, this.pc.oniceconnectionstatechange = r;
733
- const o = this.getIceTrickleUrl();
742
+ const c = this.getIceTrickleUrl();
734
743
  this.pc.onicecandidate = (l) => {
735
- l.candidate && this.sendRemoteIceCandidate(l.candidate, o);
744
+ l.candidate && this.sendRemoteIceCandidate(l.candidate, c);
736
745
  };
737
746
  const h = await this.pc.createOffer();
738
747
  if (this.isConnectCancelled(e) || (await this.pc.setLocalDescription(h), this.isConnectCancelled(e))) return;
@@ -752,7 +761,7 @@ const y = class y {
752
761
  }
753
762
  const { answer: u } = await s.json();
754
763
  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);
764
+ this.startRemoteIcePolling(c);
756
765
  } catch (i) {
757
766
  if (this.isConnectCancelled(e)) return;
758
767
  throw this.disconnect(), this.onError(i.message || i), i;
@@ -794,18 +803,18 @@ const y = class y {
794
803
  const r = await a.json();
795
804
  if (!r.call_id || !r.worker_url)
796
805
  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)
806
+ const c = y.normalizeIceServers(r.ice_servers);
807
+ if (!c.length)
799
808
  throw new Error("[VaniraClient] /calls/create response missing ice_servers");
800
809
  return {
801
810
  callId: r.call_id,
802
811
  prospectId: r.prospect_id || this.prospectId,
803
812
  serverUrl: r.worker_url.replace(/\/$/, ""),
804
- iceServers: o
813
+ iceServers: c
805
814
  };
806
815
  }
807
816
  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)
817
+ 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
818
  try {
810
819
  this.onSessionStarted({ prospectId: this.prospectId, callId: this.callId, serverUrl: this.serverUrl }), this.sessionStartedEmitted = !0;
811
820
  } catch {
@@ -826,8 +835,8 @@ const y = class y {
826
835
  r || (r = this.postCreateCall(e, i, t), y.inflightCreates.set(a, r), r.finally(() => {
827
836
  y.inflightCreates.get(a) === r && y.inflightCreates.delete(a);
828
837
  }));
829
- const o = await r;
830
- this.applyCreateCallSession(o);
838
+ const c = await r;
839
+ this.applyCreateCallSession(c);
831
840
  }
832
841
  getIceServers() {
833
842
  var e;
@@ -840,8 +849,8 @@ const y = class y {
840
849
  for (const i of e) {
841
850
  const a = i == null ? void 0 : i.urls, r = Array.isArray(a) ? a.filter(Boolean) : typeof a == "string" && a.trim() ? [a.trim()] : [];
842
851
  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);
852
+ const c = { urls: r.length === 1 ? r[0] : r }, h = i.username, _ = i.credential;
853
+ h && (c.username = h), _ && (c.credential = _), t.push(c);
845
854
  }
846
855
  return t;
847
856
  }
@@ -926,8 +935,8 @@ const y = class y {
926
935
  try {
927
936
  const r = await fetch(e, { method: "GET" });
928
937
  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;
938
+ const c = await r.json();
939
+ if (await this.applyServerIceCandidates(c.candidates), c.done && (!c.candidates || c.candidates.length === 0)) break;
931
940
  }
932
941
  } catch {
933
942
  }
@@ -954,7 +963,7 @@ const y = class y {
954
963
  for (; Date.now() < a; ) {
955
964
  if (((r = this.dataChannel) == null ? void 0 : r.readyState) === "open")
956
965
  return this.sendEvent(e, t), !0;
957
- await new Promise((o) => setTimeout(o, 50));
966
+ await new Promise((c) => setTimeout(c, 50));
958
967
  }
959
968
  return !1;
960
969
  }
@@ -969,7 +978,7 @@ const y = class y {
969
978
  name: "open_live_camera",
970
979
  tool_call_id: `lv_${crypto.randomUUID()}`,
971
980
  execution_mode: "fire_and_forget",
972
- client_fields: { preset_id: c.LiveVision },
981
+ client_fields: { preset_id: o.LiveVision },
973
982
  arguments: {
974
983
  mode: "live",
975
984
  scope: t,
@@ -997,15 +1006,15 @@ const y = class y {
997
1006
  this.dispatchBoardAbort(
998
1007
  "User interrupted while LaTeX was writing",
999
1008
  void 0,
1000
- c.WriteLatexText
1009
+ o.WriteLatexText
1001
1010
  );
1002
1011
  break;
1003
1012
  case "transcription":
1004
1013
  {
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(
1014
+ 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, c = r === void 0 ? !0 : r === !0 || r === "true", h = String(
1006
1015
  e.role ?? e.speaker ?? i.role ?? i.speaker ?? ""
1007
1016
  ).trim() || void 0;
1008
- a && this.onTranscription(a, o, h);
1017
+ a && this.onTranscription(a, c, h);
1009
1018
  }
1010
1019
  break;
1011
1020
  case "mark":
@@ -1021,7 +1030,7 @@ const y = class y {
1021
1030
  event: "client_tool_ack",
1022
1031
  data: { tool_call_id: a }
1023
1032
  }));
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);
1033
+ 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
1034
  if (h === "end_call") {
1026
1035
  a && this.sendToolResult(a, {
1027
1036
  status: "client_ack_end_call",
@@ -1169,7 +1178,7 @@ const y = class y {
1169
1178
  * @param message Optional user text message about the file
1170
1179
  */
1171
1180
  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));
1181
+ return await ye(this.dataChannel, this.mediaBytesChannel) ? this._uploadMediaViaDataChannel(e, t, i) : (fe(this.dataChannel, this.mediaBytesChannel), this._uploadMediaViaHTTP(e, t, i));
1173
1182
  }
1174
1183
  /**
1175
1184
  * Upload a live vision / screen frame — HTTP only for now, never sends client_media_update.
@@ -1179,19 +1188,19 @@ const y = class y {
1179
1188
  * the server adds client_media_upload_ready ack — use HTTP for frame JPEGs until then.
1180
1189
  */
1181
1190
  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)
1191
+ const a = i && !(e instanceof File) ? new File([e], i, { type: e.type || "image/jpeg" }) : e, { media_id: r, url: c, contentType: h } = await this._postMediaUpload(a, t, !0);
1192
+ if (!r || !c)
1184
1193
  throw new Error("Frame upload failed: server response missing media_id or url");
1185
- return { media_id: r, url: o, content_type: h };
1194
+ return { media_id: r, url: c, content_type: h };
1186
1195
  }
1187
1196
  /** WebRTC media-bytes path (control start/complete + binary chunks). */
1188
1197
  async _uploadBytesViaDataChannel(e, t, i, a, r) {
1189
1198
  if (!this.callId || !this.mediaBytesChannel)
1190
1199
  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({
1200
+ const c = r || (e instanceof File ? e.name : a === "frame" ? "frame.jpg" : "upload.bin"), h = e.type || (a === "frame" ? "image/jpeg" : "application/octet-stream"), _ = await we(e);
1201
+ return Se({
1193
1202
  bytes: _,
1194
- filename: o,
1203
+ filename: c,
1195
1204
  contentType: h,
1196
1205
  reason: t,
1197
1206
  message: i,
@@ -1207,11 +1216,11 @@ const y = class y {
1207
1216
  }
1208
1217
  /** HTTP fallback — original uploadMedia behavior (unchanged). */
1209
1218
  async _uploadMediaViaHTTP(e, t = "general", i = "") {
1210
- const { media_id: a, url: r, contentType: o } = await this._postMediaUpload(e, t, !0);
1219
+ const { media_id: a, url: r, contentType: c } = await this._postMediaUpload(e, t, !0);
1211
1220
  return this.sendMediaUpdate({
1212
1221
  media_id: a,
1213
1222
  media_url: r,
1214
- content_type: o,
1223
+ content_type: c,
1215
1224
  reason: t,
1216
1225
  message: i
1217
1226
  }), { media_id: a, url: r };
@@ -1226,11 +1235,11 @@ const y = class y {
1226
1235
  throw new Error(
1227
1236
  "Upload failed: worker_url is not set. Connect the call before uploading media."
1228
1237
  );
1229
- const r = `${a}/media/upload`, o = new FormData();
1230
- o.append("file", e), o.append("call_id", this.callId), o.append("reason", t);
1238
+ const r = `${a}/media/upload`, c = new FormData();
1239
+ c.append("file", e), c.append("call_id", this.callId), c.append("reason", t);
1231
1240
  const h = await fetch(r, {
1232
1241
  method: "POST",
1233
- body: o
1242
+ body: c
1234
1243
  });
1235
1244
  if (!h.ok) {
1236
1245
  let p = `HTTP ${h.status}`;
@@ -1293,7 +1302,7 @@ const y = class y {
1293
1302
  /** Dedupes concurrent POST /calls/create (e.g. React StrictMode double-mount). */
1294
1303
  d(y, "inflightCreates", /* @__PURE__ */ new Map());
1295
1304
  let A = y;
1296
- const Te = {
1305
+ const be = {
1297
1306
  supportsAudioEndedEvent: !1,
1298
1307
  supportsScreenShare: !1,
1299
1308
  supportsDom: !1,
@@ -1301,12 +1310,12 @@ const Te = {
1301
1310
  supportsCustomElements: !1,
1302
1311
  supportsLocalStorage: !1,
1303
1312
  supportsBroadcastChannel: !1
1304
- }, be = {
1313
+ }, xe = {
1305
1314
  name: "react-native",
1306
1315
  callType: "web",
1307
1316
  runtimeName: "react-native",
1308
1317
  callIdPrefix: "rn_",
1309
- capabilities: Te,
1318
+ capabilities: be,
1310
1319
  audio: new Q(),
1311
1320
  media: new F(),
1312
1321
  peer: new ee(),
@@ -1315,14 +1324,14 @@ const Te = {
1315
1324
  function Y(n) {
1316
1325
  return new A({
1317
1326
  ...n,
1318
- runtime: be
1327
+ runtime: xe
1319
1328
  });
1320
1329
  }
1321
- const ke = Y;
1322
- function xe(n) {
1330
+ const Re = Y;
1331
+ function Ee(n) {
1323
1332
  return Y(n);
1324
1333
  }
1325
- const Re = xe;
1334
+ const Pe = Ee;
1326
1335
  export {
1327
1336
  Q as RNAudioAdapter,
1328
1337
  te as RNDataChannelAdapter,
@@ -1331,10 +1340,10 @@ export {
1331
1340
  A as VaniraAI,
1332
1341
  A as VaniraClient,
1333
1342
  A as WebRTCClient,
1334
- ke as createReactNativeAI,
1343
+ Re as createReactNativeAI,
1335
1344
  Y as createReactNativeClient,
1336
- Re as createVaniraAI,
1337
- xe as createVaniraClient,
1338
- Te as reactNativeCapabilities,
1339
- be as reactNativeRuntime
1345
+ Pe as createVaniraAI,
1346
+ Ee as createVaniraClient,
1347
+ be as reactNativeCapabilities,
1348
+ xe as reactNativeRuntime
1340
1349
  };