@telnyx/ai-agent-lib 0.4.0 → 0.4.3

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.js CHANGED
@@ -1,5 +1,5 @@
1
- import _t, { useReducer as Gn, useEffect as ve, useDebugValue as Vn, useCallback as qn, useContext as on, createContext as rn, useState as Yn } from "react";
2
- function He(n, e) {
1
+ import yt, { useReducer as Vn, useEffect as ve, useDebugValue as qn, useCallback as Yn, useContext as rn, createContext as an, useState as Jn } from "react";
2
+ function We(n, e) {
3
3
  var t = {};
4
4
  for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
5
5
  if (n != null && typeof Object.getOwnPropertySymbols == "function") {
@@ -33,30 +33,30 @@ function O(n, e, t, i) {
33
33
  u((i = i.apply(n, [])).next());
34
34
  }));
35
35
  }
36
- var wt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), Jn = new Uint8Array(16);
37
- function Kn() {
38
- if (!wt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
39
- return wt(Jn);
36
+ var Et = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), Kn = new Uint8Array(16);
37
+ function Xn() {
38
+ if (!Et) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
39
+ return Et(Kn);
40
40
  }
41
- for (var an = [], Me = 0; Me < 256; ++Me) an[Me] = (Me + 256).toString(16).substr(1);
41
+ for (var cn = [], Me = 0; Me < 256; ++Me) cn[Me] = (Me + 256).toString(16).substr(1);
42
42
  function ye(n, e, t) {
43
43
  var i = e && t || 0;
44
44
  typeof n == "string" && (e = n === "binary" ? new Array(16) : null, n = null);
45
- var s = (n = n || {}).random || (n.rng || Kn)();
45
+ var s = (n = n || {}).random || (n.rng || Xn)();
46
46
  if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var o = 0; o < 16; ++o) e[i + o] = s[o];
47
47
  return e || (function(r, c) {
48
- var u = 0, l = an;
48
+ var u = 0, l = cn;
49
49
  return [l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]]].join("");
50
50
  })(s);
51
51
  }
52
- const zn = { SDP_CREATE_OFFER_FAILED: 40001, SDP_CREATE_ANSWER_FAILED: 40002, SDP_SET_LOCAL_DESCRIPTION_FAILED: 40003, SDP_SET_REMOTE_DESCRIPTION_FAILED: 40004, SDP_SEND_FAILED: 40005, MEDIA_MICROPHONE_PERMISSION_DENIED: 42001, MEDIA_DEVICE_NOT_FOUND: 42002, MEDIA_GET_USER_MEDIA_FAILED: 42003, HOLD_FAILED: 44001, INVALID_CALL_PARAMETERS: 44002, BYE_SEND_FAILED: 44003, SUBSCRIBE_FAILED: 44004, WEBSOCKET_CONNECTION_FAILED: 45001, WEBSOCKET_ERROR: 45002, RECONNECTION_EXHAUSTED: 45003, GATEWAY_FAILED: 45004, LOGIN_FAILED: 46001, INVALID_CREDENTIALS: 46002, AUTHENTICATION_REQUIRED: 46003, NETWORK_OFFLINE: 48001, UNEXPECTED_ERROR: 49001 }, Qn = { HIGH_RTT: 31001, HIGH_JITTER: 31002, HIGH_PACKET_LOSS: 31003, LOW_MOS: 31004, LOW_BYTES_RECEIVED: 32001, LOW_BYTES_SENT: 32002, ICE_CONNECTIVITY_LOST: 33001, ICE_GATHERING_TIMEOUT: 33002, ICE_GATHERING_EMPTY: 33003, PEER_CONNECTION_FAILED: 33004, ONLY_HOST_ICE_CANDIDATES: 33005, TOKEN_EXPIRING_SOON: 34001, SESSION_NOT_REATTACHED: 35001 }, { SDP_CREATE_OFFER_FAILED: Xn, SDP_CREATE_ANSWER_FAILED: Zn, SDP_SET_LOCAL_DESCRIPTION_FAILED: ei, SDP_SET_REMOTE_DESCRIPTION_FAILED: cn, SDP_SEND_FAILED: Et, MEDIA_MICROPHONE_PERMISSION_DENIED: ti, MEDIA_DEVICE_NOT_FOUND: ni, MEDIA_GET_USER_MEDIA_FAILED: ln, HOLD_FAILED: ii, INVALID_CALL_PARAMETERS: si, BYE_SEND_FAILED: oi, SUBSCRIBE_FAILED: ri, WEBSOCKET_CONNECTION_FAILED: ai, WEBSOCKET_ERROR: ci, RECONNECTION_EXHAUSTED: li, GATEWAY_FAILED: di, LOGIN_FAILED: dn, INVALID_CREDENTIALS: ui, AUTHENTICATION_REQUIRED: hi, NETWORK_OFFLINE: pi, UNEXPECTED_ERROR: It } = zn, { HIGH_RTT: fi, HIGH_JITTER: gi, HIGH_PACKET_LOSS: vi, LOW_MOS: Tt, LOW_BYTES_RECEIVED: mi, LOW_BYTES_SENT: _i, ICE_CONNECTIVITY_LOST: yi, ICE_GATHERING_TIMEOUT: Si, ICE_GATHERING_EMPTY: bi, PEER_CONNECTION_FAILED: Ci, ONLY_HOST_ICE_CANDIDATES: wi, TOKEN_EXPIRING_SOON: Ei, SESSION_NOT_REATTACHED: Ii } = Qn, Ti = /^a=candidate:.+typ (srflx|prflx|relay)/m, kt = "wss://rtc.telnyx.com", ki = 1006, un = { urls: "stun:stun.l.google.com:19302" }, Ri = [{ urls: "stun:stun.telnyx.com:3478" }, un, { urls: "turn:turn.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Ai = [{ urls: "stun:stundev.telnyx.com:3478" }, un, { urls: "turn:turndev.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
52
+ const zn = { SDP_CREATE_OFFER_FAILED: 40001, SDP_CREATE_ANSWER_FAILED: 40002, SDP_SET_LOCAL_DESCRIPTION_FAILED: 40003, SDP_SET_REMOTE_DESCRIPTION_FAILED: 40004, SDP_SEND_FAILED: 40005, MEDIA_MICROPHONE_PERMISSION_DENIED: 42001, MEDIA_DEVICE_NOT_FOUND: 42002, MEDIA_GET_USER_MEDIA_FAILED: 42003, HOLD_FAILED: 44001, INVALID_CALL_PARAMETERS: 44002, BYE_SEND_FAILED: 44003, SUBSCRIBE_FAILED: 44004, PEER_CLOSED_DURING_INIT: 44005, WEBSOCKET_CONNECTION_FAILED: 45001, WEBSOCKET_ERROR: 45002, RECONNECTION_EXHAUSTED: 45003, GATEWAY_FAILED: 45004, LOGIN_FAILED: 46001, INVALID_CREDENTIALS: 46002, AUTHENTICATION_REQUIRED: 46003, NETWORK_OFFLINE: 48001, UNEXPECTED_ERROR: 49001 }, Qn = { HIGH_RTT: 31001, HIGH_JITTER: 31002, HIGH_PACKET_LOSS: 31003, LOW_MOS: 31004, LOW_BYTES_RECEIVED: 32001, LOW_BYTES_SENT: 32002, ICE_CONNECTIVITY_LOST: 33001, ICE_GATHERING_TIMEOUT: 33002, ICE_GATHERING_EMPTY: 33003, PEER_CONNECTION_FAILED: 33004, ONLY_HOST_ICE_CANDIDATES: 33005, ANSWER_WHILE_PEER_ACTIVE: 33006, TOKEN_EXPIRING_SOON: 34001, SESSION_NOT_REATTACHED: 35001 }, { SDP_CREATE_OFFER_FAILED: Zn, SDP_CREATE_ANSWER_FAILED: ei, SDP_SET_LOCAL_DESCRIPTION_FAILED: ti, SDP_SET_REMOTE_DESCRIPTION_FAILED: ln, SDP_SEND_FAILED: It, MEDIA_MICROPHONE_PERMISSION_DENIED: ni, MEDIA_DEVICE_NOT_FOUND: ii, MEDIA_GET_USER_MEDIA_FAILED: dn, HOLD_FAILED: si, INVALID_CALL_PARAMETERS: oi, BYE_SEND_FAILED: ri, SUBSCRIBE_FAILED: ai, PEER_CLOSED_DURING_INIT: ot, WEBSOCKET_CONNECTION_FAILED: ci, WEBSOCKET_ERROR: li, RECONNECTION_EXHAUSTED: di, GATEWAY_FAILED: ui, LOGIN_FAILED: un, INVALID_CREDENTIALS: hi, AUTHENTICATION_REQUIRED: pi, NETWORK_OFFLINE: fi, UNEXPECTED_ERROR: Tt } = zn, { HIGH_RTT: gi, HIGH_JITTER: vi, HIGH_PACKET_LOSS: mi, LOW_MOS: kt, LOW_BYTES_RECEIVED: _i, LOW_BYTES_SENT: yi, ICE_CONNECTIVITY_LOST: Si, ICE_GATHERING_TIMEOUT: bi, ICE_GATHERING_EMPTY: Ci, PEER_CONNECTION_FAILED: wi, ONLY_HOST_ICE_CANDIDATES: Ei, ANSWER_WHILE_PEER_ACTIVE: Ii, TOKEN_EXPIRING_SOON: Ti, SESSION_NOT_REATTACHED: ki } = Qn, Ri = /^a=candidate:.+typ (srflx|prflx|relay)/m, Rt = "wss://rtc.telnyx.com", Ai = 1006, hn = { urls: "stun:stun.l.google.com:19302" }, Oi = [{ urls: "stun:stun.telnyx.com:3478" }, hn, { urls: "turn:turn.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Li = [{ urls: "stun:stundev.telnyx.com:3478" }, hn, { urls: "turn:turndev.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
53
53
  var T;
54
54
  (function(n) {
55
55
  n.SocketOpen = "telnyx.socket.open", n.SocketClose = "telnyx.socket.close", n.SocketError = "telnyx.socket.error", n.SocketMessage = "telnyx.socket.message", n.SpeedTest = "telnyx.internal.speedtest", n.Ready = "telnyx.ready", n.Error = "telnyx.error", n.Warning = "telnyx.warning", n.Notification = "telnyx.notification", n.StatsFrame = "telnyx.stats.frame", n.StatsReport = "telnyx.stats.report", n.Messages = "telnyx.messages", n.Calls = "telnyx.calls", n.MediaError = "telnyx.rtc.mediaError", n.PeerConnectionFailureError = "telnyx.rtc.peerConnectionFailureError", n.PeerConnectionSignalingStateClosed = "telnyx.rtc.peerConnectionSignalingStateClosed";
56
56
  })(T || (T = {}));
57
- const Oi = { 40001: { name: "SDP_CREATE_OFFER_FAILED", message: "Failed to create call offer", description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints.", causes: ["Browser WebRTC API error", "Missing or invalid media constraints"], solutions: ["Check getUserMedia permissions", "Verify ICE server configuration"] }, 40002: { name: "SDP_CREATE_ANSWER_FAILED", message: "Failed to answer the call", description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent.", causes: ["Browser WebRTC API error", "Invalid remote SDP offer"], solutions: ["Retry the call", "Check browser WebRTC compatibility"] }, 40003: { name: "SDP_SET_LOCAL_DESCRIPTION_FAILED", message: "Failed to apply local call settings", description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent.", causes: ["Malformed SDP", "Browser state inconsistency"], solutions: ["Retry the call"] }, 40004: { name: "SDP_SET_REMOTE_DESCRIPTION_FAILED", message: "Failed to apply remote call settings", description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs.", causes: ["Malformed remote SDP", "Browser codec mismatch"], solutions: ["Retry the call", "Check codec configuration"] }, 40005: { name: "SDP_SEND_FAILED", message: "Failed to send call data to server", description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost.", causes: ["WebSocket connection lost", "Server error"], solutions: ["Check network connectivity", "Retry the call"] }, 42001: { name: "MEDIA_MICROPHONE_PERMISSION_DENIED", message: "Microphone access denied", description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled.", causes: ["User denied browser permission prompt", "OS-level microphone access disabled"], solutions: ["Ask user to grant microphone permission in browser settings"] }, 42002: { name: "MEDIA_DEVICE_NOT_FOUND", message: "No microphone found", description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified.", causes: ["No microphone connected", "Device was disconnected", "Invalid deviceId"], solutions: ["Check that a microphone is connected", "Select a valid audio input device"] }, 42003: { name: "MEDIA_GET_USER_MEDIA_FAILED", message: "Failed to access microphone", description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error.", causes: ["Browser error", "Device in use by another application"], solutions: ["Close other applications using the microphone", "Retry"] }, 44001: { name: "HOLD_FAILED", message: "Failed to hold the call", description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation.", causes: ["Server error", "WebSocket connection lost during hold"], solutions: ["Retry the hold operation", "Check network connectivity"] }, 44002: { name: "INVALID_CALL_PARAMETERS", message: "Invalid call parameters", description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall().", causes: ["Missing destinationNumber in call options", "Invalid or empty call parameters"], solutions: ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"] }, 44003: { name: "BYE_SEND_FAILED", message: "Failed to hang up cleanly", description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware.", causes: ["WebSocket connection lost before BYE sent"], solutions: ["No action needed — call is terminated locally", "Check network connectivity"] }, 44004: { name: "SUBSCRIBE_FAILED", message: "Failed to subscribe to call events", description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server.", causes: ["WebSocket connection lost during subscribe", "Server rejected the subscription request"], solutions: ["Check network connectivity", "Retry the call"] }, 45001: { name: "WEBSOCKET_CONNECTION_FAILED", message: "Unable to connect to server", description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection.", causes: ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"], solutions: ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"] }, 45002: { name: "WEBSOCKET_ERROR", message: "Connection to server lost", description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure.", causes: ["Network interruption", "Server closed the connection", "Idle timeout"], solutions: ["Check network connectivity", "SDK will attempt automatic reconnection if configured"] }, 45003: { name: "RECONNECTION_EXHAUSTED", message: "Unable to reconnect to server", description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt.", causes: ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"], solutions: ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"] }, 45004: { name: "GATEWAY_FAILED", message: "Gateway connection failed", description: "The upstream gateway reported a FAILED or FAIL_WAIT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED.", causes: ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"], solutions: ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"] }, 46001: { name: "LOGIN_FAILED", message: "Authentication failed", description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended.", causes: ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"], solutions: ["Verify credentials", "Generate a new authentication token", "Check account status"] }, 46002: { name: "INVALID_CREDENTIALS", message: "Invalid credential parameters", description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made.", causes: ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"], solutions: ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"] }, 46003: { name: "AUTHENTICATION_REQUIRED", message: "Authentication required", description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason.", causes: ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"], solutions: ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"] }, 48001: { name: "NETWORK_OFFLINE", message: "Device is offline", description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored.", causes: ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"], solutions: ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"] }, 49001: { name: "UNEXPECTED_ERROR", message: "An unexpected error occurred", description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures.", causes: ["Unknown or unhandled error condition"], solutions: ["Check the originalError property for the underlying cause", "Report the issue if it persists"] } }, Li = { 31001: { name: "HIGH_RTT", message: "High network latency detected", description: "Round-trip time (RTT) exceeded the threshold for multiple consecutive samples. High latency causes perceptible audio delays.", causes: ["Poor network connection", "Geographic distance to media server", "Network congestion"], solutions: ["Check network connectivity", "Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications"] }, 31002: { name: "HIGH_JITTER", message: "High jitter detected", description: "Jitter (variability in packet arrival time) exceeded the threshold for multiple consecutive samples. High jitter causes crackling and choppy audio.", causes: ["Network congestion", "Unstable Wi-Fi connection", "Overloaded network equipment"], solutions: ["Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications", "Check network equipment"] }, 31003: { name: "HIGH_PACKET_LOSS", message: "High packet loss detected", description: "Packet loss exceeded the threshold for multiple consecutive samples. High packet loss causes choppy audio or dropped calls.", causes: ["Network congestion", "Unstable connection", "Firewall or QoS misconfiguration"], solutions: ["Check network connectivity", "Use a wired connection", "Contact network administrator"] }, 31004: { name: "LOW_MOS", message: "Low call quality score", description: "Mean Opinion Score (MOS) dropped below the acceptable threshold for multiple consecutive samples. This is a composite indicator of overall call quality.", causes: ["Combination of high latency, jitter, and/or packet loss", "Poor network conditions"], solutions: ["Check network connectivity", "Use a wired connection", "Close bandwidth-heavy applications"] }, 32001: { name: "LOW_BYTES_RECEIVED", message: "No audio data received", description: "No bytes have been received from the remote party for multiple consecutive seconds. This may indicate a network interruption or remote-side issue.", causes: ["Network interruption", "Remote party microphone issue", "Firewall blocking inbound media"], solutions: ["Check network connectivity", "Ask remote party to check their microphone", "Check firewall rules for media ports"] }, 32002: { name: "LOW_BYTES_SENT", message: "No audio data being sent", description: "No bytes have been sent for multiple consecutive seconds. This may indicate a local microphone issue or network interruption.", causes: ["Microphone muted or disconnected", "Network interruption", "Local media track ended"], solutions: ["Check that the microphone is not muted", "Verify the microphone is still connected", "Check network connectivity"] }, 33001: { name: "ICE_CONNECTIVITY_LOST", message: "Connection interrupted", description: "The ICE connection transitioned to the disconnected state. The previously selected connection path was lost and renegotiation may be required. The connection may recover automatically.", causes: ["Temporary network interruption", "Network interface change (e.g. Wi-Fi to cellular)", "NAT rebinding"], solutions: ["Wait for automatic recovery", "Check network connectivity"] }, 33002: { name: "ICE_GATHERING_TIMEOUT", message: "ICE gathering timed out", description: "ICE candidate gathering did not complete within the safety timeout. This is typically caused by network restrictions blocking STUN/TURN. The call may still succeed if candidates arrive late.", causes: ["Firewall blocking STUN/TURN", "Network unreachable", "STUN/TURN server not responding"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Try forceRelayCandidate option"] }, 33003: { name: "ICE_GATHERING_EMPTY", message: "No ICE candidates gathered", description: "No ICE candidates were gathered after sending the initial SDP. This may indicate a firewall blocking all STUN/TURN traffic or no available network interface.", causes: ["Firewall blocking all STUN/TURN traffic", "No network interface available", "VPN blocking UDP"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Use forceRelayCandidate option"] }, 33004: { name: "PEER_CONNECTION_FAILED", message: "Connection failed", description: "RTCPeerConnection entered the failed state. This is a recoverable condition — the SDK may attempt ICE restart or the connection may recover. If it does not recover, the call will eventually be terminated.", causes: ["ICE failure", "DTLS handshake failure", "Prolonged network interruption"], solutions: ["Wait for automatic recovery", "Check network connectivity", "Verify TURN server credentials"] }, 33005: { name: "ONLY_HOST_ICE_CANDIDATES", message: "Only local network candidates available", description: "ICE gathering completed but only host (local network) candidates were collected — no server-reflexive (srflx) or relay (turn) candidates were found. This typically means the STUN/TURN servers are unreachable, which will prevent connections outside the local network.", causes: ["STUN/TURN servers unreachable", "Firewall blocking UDP traffic to STUN/TURN servers", "Incorrect TURN server configuration or credentials", "Restrictive corporate network or VPN"], solutions: ["Verify STUN/TURN server URLs and credentials", "Ensure UDP traffic to STUN/TURN ports is not blocked", "Check firewall or VPN settings", "Try using TCP-based TURN as a fallback"] }, 34001: { name: "TOKEN_EXPIRING_SOON", message: "Authentication token expiring soon", description: "The authentication token is approaching its expiration time. If the token expires the connection will be lost and calls will fail. A new token should be generated before expiration.", causes: ["Token was issued with a limited lifetime"], solutions: ["Generate a new authentication token", "Reconnect with fresh credentials before the token expires"] }, 35001: { name: "SESSION_NOT_REATTACHED", message: "Active call lost after reconnect", description: "The WebSocket reconnected successfully but the server returned an empty reattached_sessions list while the SDK still has an active call. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST.", causes: ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"], solutions: ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"] } };
58
- function ue(n, e) {
59
- const t = Li[n];
57
+ const Ni = { 40001: { name: "SDP_CREATE_OFFER_FAILED", message: "Failed to create call offer", description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints.", causes: ["Browser WebRTC API error", "Missing or invalid media constraints"], solutions: ["Check getUserMedia permissions", "Verify ICE server configuration"] }, 40002: { name: "SDP_CREATE_ANSWER_FAILED", message: "Failed to answer the call", description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent.", causes: ["Browser WebRTC API error", "Invalid remote SDP offer"], solutions: ["Retry the call", "Check browser WebRTC compatibility"] }, 40003: { name: "SDP_SET_LOCAL_DESCRIPTION_FAILED", message: "Failed to apply local call settings", description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent.", causes: ["Malformed SDP", "Browser state inconsistency"], solutions: ["Retry the call"] }, 40004: { name: "SDP_SET_REMOTE_DESCRIPTION_FAILED", message: "Failed to apply remote call settings", description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs.", causes: ["Malformed remote SDP", "Browser codec mismatch"], solutions: ["Retry the call", "Check codec configuration"] }, 40005: { name: "SDP_SEND_FAILED", message: "Failed to send call data to server", description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost.", causes: ["WebSocket connection lost", "Server error"], solutions: ["Check network connectivity", "Retry the call"] }, 42001: { name: "MEDIA_MICROPHONE_PERMISSION_DENIED", message: "Microphone access denied", description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled.", causes: ["User denied browser permission prompt", "OS-level microphone access disabled"], solutions: ["Ask user to grant microphone permission in browser settings"] }, 42002: { name: "MEDIA_DEVICE_NOT_FOUND", message: "No microphone found", description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified.", causes: ["No microphone connected", "Device was disconnected", "Invalid deviceId"], solutions: ["Check that a microphone is connected", "Select a valid audio input device"] }, 42003: { name: "MEDIA_GET_USER_MEDIA_FAILED", message: "Failed to access microphone", description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error.", causes: ["Browser error", "Device in use by another application"], solutions: ["Close other applications using the microphone", "Retry"] }, 44005: { name: "PEER_CLOSED_DURING_INIT", message: "Call was closed during setup", description: "The PeerConnection was closed (e.g. by hangup()) while peer.init() was still running. This is a race condition: an async operation such as setRemoteDescription, getUserMedia, or the media recovery flow yielded control, and close() ran during that gap. The init() cannot continue because the underlying RTCPeerConnection has been destroyed.", causes: ["call.hangup() or call.close() was called while the call was still setting up", "A WebSocket Bye message arrived during getUserMedia prompt or SDP negotiation", "User clicked hangup/decline before media permissions were granted"], solutions: ["This is expected if the user intentionally hung up during setup — no action needed", "If this happens frequently without user action, check for automatic hangup triggers that may fire too early"] }, 44001: { name: "HOLD_FAILED", message: "Failed to hold the call", description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation.", causes: ["Server error", "WebSocket connection lost during hold"], solutions: ["Retry the hold operation", "Check network connectivity"] }, 44002: { name: "INVALID_CALL_PARAMETERS", message: "Invalid call parameters", description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall().", causes: ["Missing destinationNumber in call options", "Invalid or empty call parameters"], solutions: ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"] }, 44003: { name: "BYE_SEND_FAILED", message: "Failed to hang up cleanly", description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware.", causes: ["WebSocket connection lost before BYE sent"], solutions: ["No action needed — call is terminated locally", "Check network connectivity"] }, 44004: { name: "SUBSCRIBE_FAILED", message: "Failed to subscribe to call events", description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server.", causes: ["WebSocket connection lost during subscribe", "Server rejected the subscription request"], solutions: ["Check network connectivity", "Retry the call"] }, 45001: { name: "WEBSOCKET_CONNECTION_FAILED", message: "Unable to connect to server", description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection.", causes: ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"], solutions: ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"] }, 45002: { name: "WEBSOCKET_ERROR", message: "Connection to server lost", description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure.", causes: ["Network interruption", "Server closed the connection", "Idle timeout"], solutions: ["Check network connectivity", "SDK will attempt automatic reconnection if configured"] }, 45003: { name: "RECONNECTION_EXHAUSTED", message: "Unable to reconnect to server", description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt.", causes: ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"], solutions: ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"] }, 45004: { name: "GATEWAY_FAILED", message: "Gateway connection failed", description: "The upstream gateway reported a FAILED or FAIL_WAIT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED.", causes: ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"], solutions: ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"] }, 46001: { name: "LOGIN_FAILED", message: "Authentication failed", description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended.", causes: ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"], solutions: ["Verify credentials", "Generate a new authentication token", "Check account status"] }, 46002: { name: "INVALID_CREDENTIALS", message: "Invalid credential parameters", description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made.", causes: ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"], solutions: ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"] }, 46003: { name: "AUTHENTICATION_REQUIRED", message: "Authentication required", description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason.", causes: ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"], solutions: ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"] }, 48001: { name: "NETWORK_OFFLINE", message: "Device is offline", description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored.", causes: ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"], solutions: ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"] }, 49001: { name: "UNEXPECTED_ERROR", message: "An unexpected error occurred", description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures.", causes: ["Unknown or unhandled error condition"], solutions: ["Check the originalError property for the underlying cause", "Report the issue if it persists"] } }, xi = { 31001: { name: "HIGH_RTT", message: "High network latency detected", description: "Round-trip time (RTT) exceeded the threshold for multiple consecutive samples. High latency causes perceptible audio delays.", causes: ["Poor network connection", "Geographic distance to media server", "Network congestion"], solutions: ["Check network connectivity", "Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications"] }, 31002: { name: "HIGH_JITTER", message: "High jitter detected", description: "Jitter (variability in packet arrival time) exceeded the threshold for multiple consecutive samples. High jitter causes crackling and choppy audio.", causes: ["Network congestion", "Unstable Wi-Fi connection", "Overloaded network equipment"], solutions: ["Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications", "Check network equipment"] }, 31003: { name: "HIGH_PACKET_LOSS", message: "High packet loss detected", description: "Packet loss exceeded the threshold for multiple consecutive samples. High packet loss causes choppy audio or dropped calls.", causes: ["Network congestion", "Unstable connection", "Firewall or QoS misconfiguration"], solutions: ["Check network connectivity", "Use a wired connection", "Contact network administrator"] }, 31004: { name: "LOW_MOS", message: "Low call quality score", description: "Mean Opinion Score (MOS) dropped below the acceptable threshold for multiple consecutive samples. This is a composite indicator of overall call quality.", causes: ["Combination of high latency, jitter, and/or packet loss", "Poor network conditions"], solutions: ["Check network connectivity", "Use a wired connection", "Close bandwidth-heavy applications"] }, 32001: { name: "LOW_BYTES_RECEIVED", message: "No audio data received", description: "No bytes have been received from the remote party for multiple consecutive seconds. This may indicate a network interruption or remote-side issue.", causes: ["Network interruption", "Remote party microphone issue", "Firewall blocking inbound media"], solutions: ["Check network connectivity", "Ask remote party to check their microphone", "Check firewall rules for media ports"] }, 32002: { name: "LOW_BYTES_SENT", message: "No audio data being sent", description: "No bytes have been sent for multiple consecutive seconds. This may indicate a local microphone issue or network interruption.", causes: ["Microphone muted or disconnected", "Network interruption", "Local media track ended"], solutions: ["Check that the microphone is not muted", "Verify the microphone is still connected", "Check network connectivity"] }, 33001: { name: "ICE_CONNECTIVITY_LOST", message: "Connection interrupted", description: "The ICE connection transitioned to the disconnected state. The previously selected connection path was lost and renegotiation may be required. The connection may recover automatically.", causes: ["Temporary network interruption", "Network interface change (e.g. Wi-Fi to cellular)", "NAT rebinding"], solutions: ["Wait for automatic recovery", "Check network connectivity"] }, 33002: { name: "ICE_GATHERING_TIMEOUT", message: "ICE gathering timed out", description: "ICE candidate gathering did not complete within the safety timeout. This is typically caused by network restrictions blocking STUN/TURN. The call may still succeed if candidates arrive late.", causes: ["Firewall blocking STUN/TURN", "Network unreachable", "STUN/TURN server not responding"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Try forceRelayCandidate option"] }, 33003: { name: "ICE_GATHERING_EMPTY", message: "No ICE candidates gathered", description: "No ICE candidates were gathered after sending the initial SDP. This may indicate a firewall blocking all STUN/TURN traffic or no available network interface.", causes: ["Firewall blocking all STUN/TURN traffic", "No network interface available", "VPN blocking UDP"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Use forceRelayCandidate option"] }, 33004: { name: "PEER_CONNECTION_FAILED", message: "Connection failed", description: "RTCPeerConnection entered the failed state. This is a recoverable condition — the SDK may attempt ICE restart or the connection may recover. If it does not recover, the call will eventually be terminated.", causes: ["ICE failure", "DTLS handshake failure", "Prolonged network interruption"], solutions: ["Wait for automatic recovery", "Check network connectivity", "Verify TURN server credentials"] }, 33005: { name: "ONLY_HOST_ICE_CANDIDATES", message: "Only local network candidates available", description: "ICE gathering completed but only host (local network) candidates were collected — no server-reflexive (srflx) or relay (turn) candidates were found. This typically means the STUN/TURN servers are unreachable, which will prevent connections outside the local network.", causes: ["STUN/TURN servers unreachable", "Firewall blocking UDP traffic to STUN/TURN servers", "Incorrect TURN server configuration or credentials", "Restrictive corporate network or VPN"], solutions: ["Verify STUN/TURN server URLs and credentials", "Ensure UDP traffic to STUN/TURN ports is not blocked", "Check firewall or VPN settings", "Try using TCP-based TURN as a fallback"] }, 33006: { name: "ANSWER_WHILE_PEER_ACTIVE", message: "Call answer ignored because a peer connection is already active", description: "answer() was called on a call that already has an active or connecting peer connection. Creating a second peer connection for the same call would duplicate media negotiation, confuse the remote party, and break call reporting. This is typically caused by application code invoking answer() multiple times (e.g. from multiple event handlers).", causes: ["Application called answer() twice on the same call object", "Multiple click handlers or event listeners triggering answer()"], solutions: ["Ensure answer() is called only once per call", "Disable the answer button after the first click", "Check that answer() is not invoked from multiple event handlers"] }, 34001: { name: "TOKEN_EXPIRING_SOON", message: "Authentication token expiring soon", description: "The authentication token is approaching its expiration time. If the token expires the connection will be lost and calls will fail. A new token should be generated before expiration.", causes: ["Token was issued with a limited lifetime"], solutions: ["Generate a new authentication token", "Reconnect with fresh credentials before the token expires"] }, 35001: { name: "SESSION_NOT_REATTACHED", message: "Active call lost after reconnect", description: "The WebSocket reconnected successfully but the server returned an empty reattached_sessions list while the SDK still has an active call. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST.", causes: ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"], solutions: ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"] } };
58
+ function de(n, e) {
59
+ const t = xi[n];
60
60
  return { code: n, name: t.name, message: t.message, description: t.description, causes: [...t.causes], solutions: [...t.solutions] };
61
61
  }
62
62
  class Ae extends Error {
@@ -69,22 +69,22 @@ class Ae extends Error {
69
69
  }
70
70
  function Oe(n) {
71
71
  if (n instanceof DOMException) {
72
- if (n.name === "NotAllowedError") return ti;
73
- if (n.name === "NotFoundError" || n.name === "OverconstrainedError") return ni;
72
+ if (n.name === "NotAllowedError") return ni;
73
+ if (n.name === "NotFoundError" || n.name === "OverconstrainedError") return ii;
74
74
  }
75
- return ln;
75
+ return dn;
76
76
  }
77
- function W(n, e, t) {
78
- const i = Oi[n], s = e instanceof Error ? e : e !== void 0 ? new Error(String(e)) : void 0;
77
+ function H(n, e, t) {
78
+ const i = Ni[n], s = e instanceof Error ? e : e !== void 0 ? new Error(String(e)) : void 0;
79
79
  return new Ae({ code: n, name: i.name, description: i.description, message: t || i.message, causes: [...i.causes], solutions: [...i.solutions], originalError: s });
80
80
  }
81
- var Ni = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
82
- function hn(n, e) {
81
+ var Di = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
82
+ function pn(n, e) {
83
83
  return n(e = { exports: {} }, e.exports), e.exports;
84
84
  }
85
- var xi = hn((function(n) {
85
+ var Pi = pn((function(n) {
86
86
  var e, t;
87
- e = Ni, t = function() {
87
+ e = Di, t = function() {
88
88
  var i = function() {
89
89
  }, s = "undefined", o = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), r = ["trace", "debug", "info", "warn", "error"];
90
90
  function c(m, w) {
@@ -191,8 +191,8 @@ var xi = hn((function(n) {
191
191
  }, y.default = y, y;
192
192
  }, n.exports ? n.exports = t() : e.log = t();
193
193
  }));
194
- const Rt = { debug: 0, info: 1, warn: 2, error: 3 };
195
- class Di {
194
+ const At = { debug: 0, info: 1, warn: 2, error: 3 };
195
+ class Mi {
196
196
  constructor(e = {}) {
197
197
  var t, i, s;
198
198
  this.buffer = [], this.isCapturing = !1, this.options = { enabled: (t = e.enabled) !== null && t !== void 0 && t, level: (i = e.level) !== null && i !== void 0 ? i : "debug", maxEntries: (s = e.maxEntries) !== null && s !== void 0 ? s : 1e3 };
@@ -204,7 +204,7 @@ class Di {
204
204
  this.isCapturing = !1;
205
205
  }
206
206
  addEntry(e, t, i) {
207
- if (!this.isCapturing || !this.options.enabled || Rt[e] < Rt[this.options.level]) return;
207
+ if (!this.isCapturing || !this.options.enabled || At[e] < At[this.options.level]) return;
208
208
  const s = Object.assign({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: e, message: t }, i && Object.keys(i).length > 0 ? { context: i } : {});
209
209
  this.buffer.push(s), this.buffer.length > this.options.maxEntries && this.buffer.shift();
210
210
  }
@@ -228,10 +228,10 @@ class Di {
228
228
  return this.options.enabled;
229
229
  }
230
230
  }
231
- let pn = null;
232
- const g = xi.getLogger("telnyx"), We = { trace: 0, debug: 1, info: 2, warn: 3, error: 4 };
233
- let fn = We.info;
234
- function At(n) {
231
+ let fn = null;
232
+ const g = Pi.getLogger("telnyx"), He = { trace: 0, debug: 1, info: 2, warn: 3, error: 4 };
233
+ let gn = He.info;
234
+ function Ot(n) {
235
235
  if (n == null || typeof n != "object") return n;
236
236
  try {
237
237
  const t = JSON.stringify(n), i = JSON.parse(t);
@@ -252,20 +252,20 @@ function At(n) {
252
252
  }
253
253
  return Object.keys(e).length > 0 ? e : { value: String(n) };
254
254
  }
255
- const Pi = g.methodFactory;
255
+ const Ui = g.methodFactory;
256
256
  g.methodFactory = (n, e, t) => {
257
- const i = Pi(n, e, t);
257
+ const i = Ui(n, e, t);
258
258
  return function(...s) {
259
- if (We[n] >= fn) {
259
+ if (He[n] >= gn) {
260
260
  const r = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
261
261
  for (const c of s) r.push(c);
262
262
  i(...r);
263
263
  }
264
- const o = pn;
264
+ const o = fn;
265
265
  if (o?.isActive()) {
266
266
  const [r, ...c] = s, u = typeof r == "string" ? r : JSON.stringify(r);
267
267
  let l;
268
- c.length > 0 && (l = c.length === 1 && typeof c[0] == "object" && c[0] !== null ? At(c[0]) : { args: c.map(At) }), o.addEntry(n, u, l);
268
+ c.length > 0 && (l = c.length === 1 && typeof c[0] == "object" && c[0] !== null ? Ot(c[0]) : { args: c.map(Ot) }), o.addEntry(n, u, l);
269
269
  }
270
270
  };
271
271
  }, g.setLevel("debug", !1);
@@ -278,78 +278,78 @@ const Ue = (n) => {
278
278
  g.warn("Verto LA invalid media JSON string:", o);
279
279
  }
280
280
  return { participantId: Number(e), participantNumber: t, participantName: i, codec: s, media: c, participantData: r };
281
- }, gn = (n) => {
281
+ }, vn = (n) => {
282
282
  if (typeof n != "string") return n;
283
283
  try {
284
284
  return JSON.parse(n);
285
285
  } catch {
286
286
  return n;
287
287
  }
288
- }, Se = (n) => n instanceof Function || typeof n == "function", Ge = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null, Mi = /^(ws|wss):\/\//, vn = (n, e = null) => {
288
+ }, Se = (n) => n instanceof Function || typeof n == "function", Ge = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null, Fi = /^(ws|wss):\/\//, mn = (n, e = null) => {
289
289
  const { result: t = {}, error: i } = n;
290
290
  if (i) return { error: i };
291
291
  const { result: s = null } = t;
292
292
  if (s === null) return e !== null && (t.node_id = e), { result: t };
293
293
  const { code: o = null, node_id: r = null, result: c = null } = s;
294
- return o && o !== "200" ? { error: s } : c ? vn(c, r) : { result: s };
295
- }, mn = (n, e) => Math.floor(Math.random() * (e - n + 1) + n), Ve = ({ login: n, passwd: e, password: t, login_token: i }) => !!(n && (e || t) || i), ke = ({ anonymous_login: n }) => !!n && !!n.target_id && !!n.target_type, yt = (n) => {
294
+ return o && o !== "200" ? { error: s } : c ? mn(c, r) : { result: s };
295
+ }, _n = (n, e) => Math.floor(Math.random() * (e - n + 1) + n), Ve = ({ login: n, passwd: e, password: t, login_token: i }) => !!(n && (e || t) || i), ke = ({ anonymous_login: n }) => !!n && !!n.target_id && !!n.target_type, St = (n) => {
296
296
  var e, t, i, s, o, r;
297
297
  let c = "", u = "";
298
298
  return !((t = (e = n?.result) === null || e === void 0 ? void 0 : e.params) === null || t === void 0) && t.state && (c = (s = (i = n?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((o = n?.params) === null || o === void 0) && o.state && (u = (r = n?.params) === null || r === void 0 ? void 0 : r.state), c || u;
299
299
  };
300
- function Ot({ debounceTime: n }) {
300
+ function Lt({ debounceTime: n }) {
301
301
  let e, t;
302
302
  return { promise: new Promise(((i, s) => {
303
- e = n ? Ui(i, n) : i, t = s;
303
+ e = n ? ji(i, n) : i, t = s;
304
304
  })), resolve: e, reject: t };
305
305
  }
306
- const Ui = (n, e) => {
306
+ const ji = (n, e) => {
307
307
  let t;
308
308
  return (...i) => {
309
309
  clearTimeout(t), t = window.setTimeout((() => {
310
310
  n(...i);
311
311
  }), e);
312
312
  };
313
- }, St = "telnyx-voice-sdk-id";
313
+ }, bt = "telnyx-voice-sdk-id";
314
314
  function fe() {
315
- return sessionStorage.getItem(St);
315
+ return sessionStorage.getItem(bt);
316
316
  }
317
- function _n() {
318
- sessionStorage.removeItem(St);
317
+ function yn() {
318
+ sessionStorage.removeItem(bt);
319
319
  }
320
- var Q, ce, $;
320
+ var z, ce, $;
321
321
  typeof window < "u" && window.addEventListener("beforeunload", (() => {
322
- _n();
322
+ yn();
323
323
  })), (function(n) {
324
324
  n.Offer = "offer", n.Answer = "answer";
325
- })(Q || (Q = {})), (function(n) {
325
+ })(z || (z = {})), (function(n) {
326
326
  n.Inbound = "inbound", n.Outbound = "outbound";
327
327
  })(ce || (ce = {})), (function(n) {
328
328
  n.Invite = "telnyx_rtc.invite", n.Attach = "telnyx_rtc.attach", n.Answer = "telnyx_rtc.answer", n.Info = "telnyx_rtc.info", n.Candidate = "telnyx_rtc.candidate", n.EndOfCandidates = "telnyx_rtc.endOfCandidates", n.Display = "telnyx_rtc.display", n.Media = "telnyx_rtc.media", n.Event = "telnyx_rtc.event", n.Bye = "telnyx_rtc.bye", n.Punt = "telnyx_rtc.punt", n.Broadcast = "telnyx_rtc.broadcast", n.Subscribe = "telnyx_rtc.subscribe", n.Unsubscribe = "telnyx_rtc.unsubscribe", n.ClientReady = "telnyx_rtc.clientReady", n.Modify = "telnyx_rtc.modify", n.Ringing = "telnyx_rtc.ringing", n.GatewayState = "telnyx_rtc.gatewayState", n.Ping = "telnyx_rtc.ping", n.Pong = "telnyx_rtc.pong";
329
329
  })($ || ($ = {}));
330
- const re = { generic: "event", [$.Display]: "participantData", [$.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" }, Fi = { invalidCredentialsOptions: "InvalidCredentialsOptions" }, ji = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1, prefetchIceCandidates: !0 };
331
- var U, lt, oe, le, ne;
330
+ const re = { generic: "event", [$.Display]: "participantData", [$.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" }, Bi = { invalidCredentialsOptions: "InvalidCredentialsOptions" }, $i = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1, prefetchIceCandidates: !0 };
331
+ var U, dt, oe, le, ne;
332
332
  (function(n) {
333
333
  n[n.New = 0] = "New", n[n.Requesting = 1] = "Requesting", n[n.Trying = 2] = "Trying", n[n.Recovering = 3] = "Recovering", n[n.Ringing = 4] = "Ringing", n[n.Answering = 5] = "Answering", n[n.Early = 6] = "Early", n[n.Active = 7] = "Active", n[n.Held = 8] = "Held", n[n.Hangup = 9] = "Hangup", n[n.Destroy = 10] = "Destroy", n[n.Purge = 11] = "Purge";
334
334
  })(U || (U = {})), (function(n) {
335
335
  n.Participant = "participant", n.Moderator = "moderator";
336
- })(lt || (lt = {})), (function(n) {
336
+ })(dt || (dt = {})), (function(n) {
337
337
  n.Join = "join", n.Leave = "leave", n.Bootstrap = "bootstrap", n.Add = "add", n.Modify = "modify", n.Delete = "delete", n.Clear = "clear", n.ChatMessage = "chatMessage", n.LayerInfo = "layerInfo", n.LogoInfo = "logoInfo", n.LayoutInfo = "layoutInfo", n.LayoutList = "layoutList", n.ModCmdResponse = "modCommandResponse";
338
338
  })(oe || (oe = {})), (function(n) {
339
339
  n.Video = "videoinput", n.AudioIn = "audioinput", n.AudioOut = "audiooutput";
340
340
  })(le || (le = {})), (function(n) {
341
341
  n.REGED = "REGED", n.UNREGED = "UNREGED", n.NOREG = "NOREG", n.FAILED = "FAILED", n.FAIL_WAIT = "FAIL_WAIT", n.REGISTER = "REGISTER", n.TRYING = "TRYING", n.EXPIRED = "EXPIRED", n.UNREGISTER = "UNREGISTER";
342
342
  })(ne || (ne = {}));
343
- const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, yn = (n, e = be) => De(n, e) in se, he = (n, e, t = be) => {
343
+ const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, Sn = (n, e = be) => De(n, e) in se, he = (n, e, t = be) => {
344
344
  const i = De(n, t);
345
345
  i in se || (se[i] = []), se[i].push(e);
346
- }, Sn = (n, e, t = be) => {
346
+ }, bn = (n, e, t = be) => {
347
347
  const i = function(s) {
348
348
  pe(n, i, t), e(s);
349
349
  };
350
350
  return i.prototype.targetRef = e, he(n, i, t);
351
351
  }, pe = (n, e, t = be) => {
352
- if (!yn(n, t)) return !1;
352
+ if (!Sn(n, t)) return !1;
353
353
  const i = De(n, t);
354
354
  if (Se(e))
355
355
  for (let s = se[i].length - 1; s >= 0; s--) {
@@ -360,34 +360,34 @@ const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, yn = (n, e = be) => De
360
360
  return se[i].length === 0 && delete se[i], !0;
361
361
  }, L = (n, e, t = be, i = !0) => {
362
362
  const s = i && t !== be;
363
- if (!yn(n, t)) return s && L(n, e), !1;
363
+ if (!Sn(n, t)) return s && L(n, e), !1;
364
364
  const o = De(n, t), r = se[o].length;
365
365
  if (!r) return s && L(n, e), !1;
366
366
  for (let c = r - 1; c >= 0; c--) se[o][c](e);
367
367
  return s && L(n, e), !0;
368
- }, ot = (n) => {
368
+ }, rt = (n) => {
369
369
  const e = De(n, "");
370
370
  Object.keys(se).filter(((t) => t.indexOf(e) === 0)).forEach(((t) => delete se[t]));
371
371
  };
372
- let Bi = typeof WebSocket < "u" ? WebSocket : null;
373
- const $i = 0, Hi = 1, Wi = 2, Lt = 3;
374
- class Nt {
372
+ let Wi = typeof WebSocket < "u" ? WebSocket : null;
373
+ const Hi = 0, Gi = 1, Vi = 2, Nt = 3;
374
+ class xt {
375
375
  constructor(e) {
376
- this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = kt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this._safetyTimeoutId = null, this.upDur = null, this.downDur = null;
376
+ this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = Rt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this._safetyTimeoutId = null, this.upDur = null, this.downDur = null;
377
377
  const { host: t, env: i, region: s, useCanaryRtcServer: o } = e.options;
378
- i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : kt), t && (this._host = ((r) => `${Mi.test(r) ? "" : "wss://"}${r}`)(t)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), o && (this._useCanaryRtcServer = !0);
378
+ i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : Rt), t && (this._host = ((r) => `${Fi.test(r) ? "" : "wss://"}${r}`)(t)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), o && (this._useCanaryRtcServer = !0);
379
379
  }
380
380
  get connected() {
381
- return !!this._wsClient && this._wsClient.readyState === Hi;
381
+ return !!this._wsClient && this._wsClient.readyState === Gi;
382
382
  }
383
383
  get connecting() {
384
- return !!this._wsClient && this._wsClient.readyState === $i;
384
+ return !!this._wsClient && this._wsClient.readyState === Hi;
385
385
  }
386
386
  get closing() {
387
- return !!this._wsClient && this._wsClient.readyState === Wi;
387
+ return !!this._wsClient && this._wsClient.readyState === Vi;
388
388
  }
389
389
  get closed() {
390
- return !!this._wsClient && this._wsClient.readyState === Lt;
390
+ return !!this._wsClient && this._wsClient.readyState === Nt;
391
391
  }
392
392
  get isAlive() {
393
393
  return this.connecting || this.connected;
@@ -401,12 +401,12 @@ class Nt {
401
401
  connect() {
402
402
  const e = new URL(this._host);
403
403
  let t = fe();
404
- this.session.options.rtcIp && this.session.options.rtcPort && (t = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), t && e.searchParams.set("voice_sdk_id", t), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), t && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), g.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0);
404
+ this.session.options.rtcIp && this.session.options.rtcPort && (t = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), t && e.searchParams.set("voice_sdk_id", t), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), t && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), g.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0), this.session.options.skipLastVoiceSdkId && e.searchParams.has("voice_sdk_id") && e.searchParams.set("skip_last_voice_sdk_id", "true");
405
405
  try {
406
- this._wsClient = new Bi(e.toString()), this._registerSocketEvents(this._wsClient);
406
+ this._wsClient = new Wi(e.toString()), this._registerSocketEvents(this._wsClient);
407
407
  } catch (i) {
408
408
  g.error("WebSocket connection failed:", i);
409
- const s = W(ai, i);
409
+ const s = H(ci, i);
410
410
  L(T.Error, { error: s, sessionId: this.session.sessionid }, this.session.uuid);
411
411
  }
412
412
  }
@@ -418,8 +418,8 @@ class Nt {
418
418
  var t;
419
419
  const { request: i } = e, s = new Promise(((o, r) => {
420
420
  if (i.hasOwnProperty("result")) return o();
421
- Sn(i.id, ((c) => {
422
- const { result: u, error: l } = vn(c);
421
+ bn(i.id, ((c) => {
422
+ const { result: u, error: l } = mn(c);
423
423
  return l ? r(l) : o(u);
424
424
  }));
425
425
  }));
@@ -435,17 +435,17 @@ class Nt {
435
435
  _registerSocketEvents(e) {
436
436
  e.onopen = (t) => L(T.SocketOpen, t, this.session.uuid), e.onclose = (t) => (this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "close"), L(T.SocketClose, t, this.session.uuid)), e.onerror = (t) => {
437
437
  this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "error");
438
- const i = W(ci);
438
+ const i = H(li);
439
439
  return L(T.Error, { error: i, sessionId: this.session.sessionid }, this.session.uuid), L(T.SocketError, { error: t, sessionId: this.session.sessionid }, this.session.uuid);
440
440
  }, e.onmessage = (t) => {
441
441
  var i, s;
442
- const o = gn(t.data);
442
+ const o = vn(t.data);
443
443
  var r;
444
444
  if (typeof o != "string") {
445
- if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(St, r)), this._unsetTimer(o.id), g.debug(`RECV:
445
+ if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(bt, r)), this._unsetTimer(o.id), g.debug(`RECV:
446
446
  `, JSON.stringify(o, null, 2), `
447
447
  `), ne[`${(s = (i = o?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state}`] || !L(o.id, o)) {
448
- const c = yt(o);
448
+ const c = St(o);
449
449
  L(T.SocketMessage, o, this.session.uuid), c && (this.previousGatewayState = c);
450
450
  }
451
451
  } else this._handleStringResponse(o);
@@ -455,7 +455,7 @@ class Nt {
455
455
  e.onopen = null, e.onclose = null, e.onerror = null, e.onmessage = null;
456
456
  }
457
457
  _handleCloseTimeout(e) {
458
- this._safetyTimeoutId = null, e && e.readyState !== Lt ? (g.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || L(T.SocketClose, { code: ki, reason: "STUCK_WS_TIMEOUT: Socket got stuck in CLOSING state and was forcefully cleaned up by safety timeout", wasClean: !1 }, this.session.uuid)) : g.warn("Safety timeout fired but socket is already closed or cleaned up");
458
+ this._safetyTimeoutId = null, e && e.readyState !== Nt ? (g.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || L(T.SocketClose, { code: Ai, reason: "STUCK_WS_TIMEOUT: Socket got stuck in CLOSING state and was forcefully cleaned up by safety timeout", wasClean: !1 }, this.session.uuid)) : g.warn("Safety timeout fired but socket is already closed or cleaned up");
459
459
  }
460
460
  _clearSafetyTimeout() {
461
461
  this._safetyTimeoutId && (g.debug("Clearing safety timeout"), clearTimeout(this._safetyTimeoutId), this._safetyTimeoutId = null);
@@ -482,111 +482,111 @@ class Pe {
482
482
  this.request = Object.assign({ jsonrpc: "2.0", id: ye() }, e);
483
483
  }
484
484
  }
485
- const xt = { id: "callID", destinationNumber: "destination_number", remoteCallerName: "remote_caller_id_name", remoteCallerNumber: "remote_caller_id_number", callerName: "caller_id_name", callerNumber: "caller_id_number", customHeaders: "custom_headers" };
485
+ const Dt = { id: "callID", destinationNumber: "destination_number", remoteCallerName: "remote_caller_id_name", remoteCallerNumber: "remote_caller_id_number", callerName: "caller_id_name", callerNumber: "caller_id_number", customHeaders: "custom_headers" };
486
486
  class ee extends Pe {
487
487
  constructor(e = {}) {
488
488
  if (super(), e.hasOwnProperty("dialogParams")) {
489
- const t = He(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "localElement", "remoteElement", "onNotification", "camId", "micId", "speakerId"]);
490
- for (const i in xt) i && t.hasOwnProperty(i) && (t[xt[i]] = t[i], delete t[i]);
489
+ const t = We(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "localElement", "remoteElement", "onNotification", "camId", "micId", "speakerId"]);
490
+ for (const i in Dt) i && t.hasOwnProperty(i) && (t[Dt[i]] = t[i], delete t[i]);
491
491
  e.dialogParams = t;
492
492
  }
493
493
  this.buildRequest({ method: this.toString(), params: e });
494
494
  }
495
495
  }
496
- class bn extends ee {
496
+ class Cn extends ee {
497
497
  constructor(e) {
498
498
  super(), this.method = $.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
499
499
  }
500
500
  }
501
- class Gi {
501
+ class qi {
502
502
  constructor(e) {
503
503
  this.pendingRequestId = null, this.onSocketMessage = (t) => O(this, void 0, void 0, (function* () {
504
- t.id === this.pendingRequestId && this.gatewayStateTask.resolve(yt(t));
504
+ t.id === this.pendingRequestId && this.gatewayStateTask.resolve(St(t));
505
505
  })), this.getIsRegistered = () => O(this, void 0, void 0, (function* () {
506
- const t = new bn(fe());
507
- this.pendingRequestId = t.request.id, this.gatewayStateTask = Ot({}), this.session.execute(t);
506
+ const t = new Cn(fe());
507
+ this.pendingRequestId = t.request.id, this.gatewayStateTask = Lt({}), this.session.execute(t);
508
508
  const i = yield this.gatewayStateTask.promise;
509
509
  return !!i && [ne.REGISTER, ne.REGED].includes(i);
510
- })), this.session = e, this.gatewayStateTask = Ot({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
510
+ })), this.session = e, this.gatewayStateTask = Lt({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
511
511
  }
512
512
  }
513
- class Cn extends ee {
513
+ class wn extends ee {
514
514
  constructor(e) {
515
515
  super(), this.method = $.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
516
516
  }
517
517
  }
518
- var wn = "2.26.3", bt = wn;
519
- class Vi extends ee {
518
+ var En = "2.26.4", Ct = En;
519
+ class Yi extends ee {
520
520
  constructor(e, t, i, s, o = {}, r) {
521
521
  super(), this.method = "login";
522
- const c = { login: e, passwd: t, login_token: i, userVariables: o, reconnection: r, loginParams: {}, "User-Agent": { sdkVersion: bt, data: navigator.userAgent } };
522
+ const c = { login: e, passwd: t, login_token: i, userVariables: o, reconnection: r, loginParams: {}, "User-Agent": { sdkVersion: Ct, data: navigator.userAgent } };
523
523
  s && (c.sessid = s), this.buildRequest({ method: this.method, params: c });
524
524
  }
525
525
  }
526
- class qi extends ee {
526
+ class Ji extends ee {
527
527
  constructor(e, t) {
528
528
  super(), this.buildRequest({ id: e, result: { method: t } });
529
529
  }
530
530
  }
531
- class Dt extends ee {
531
+ class Pt extends ee {
532
532
  toString() {
533
533
  return $.Invite;
534
534
  }
535
535
  }
536
- class Pt extends ee {
536
+ class Mt extends ee {
537
537
  toString() {
538
538
  return $.Answer;
539
539
  }
540
540
  }
541
- class Mt extends ee {
541
+ class Ut extends ee {
542
542
  toString() {
543
543
  return $.Attach;
544
544
  }
545
545
  }
546
- class Yi extends ee {
546
+ class Ki extends ee {
547
547
  toString() {
548
548
  return $.Bye;
549
549
  }
550
550
  }
551
- class Ji extends ee {
551
+ class Xi extends ee {
552
552
  toString() {
553
553
  return $.Candidate;
554
554
  }
555
555
  }
556
- class Ki extends ee {
556
+ class zi extends ee {
557
557
  toString() {
558
558
  return $.EndOfCandidates;
559
559
  }
560
560
  }
561
- class rt extends ee {
561
+ class at extends ee {
562
562
  toString() {
563
563
  return $.Modify;
564
564
  }
565
565
  }
566
- class Ut extends ee {
566
+ class Ft extends ee {
567
567
  toString() {
568
568
  return $.Info;
569
569
  }
570
570
  }
571
- class zi extends ee {
571
+ class Qi extends ee {
572
572
  toString() {
573
573
  return $.Broadcast;
574
574
  }
575
575
  }
576
- class Qi extends ee {
576
+ class Zi extends ee {
577
577
  toString() {
578
578
  return $.Subscribe;
579
579
  }
580
580
  }
581
- class Xi extends ee {
581
+ class es extends ee {
582
582
  toString() {
583
583
  return $.Unsubscribe;
584
584
  }
585
585
  }
586
- class Zi extends ee {
586
+ class ts extends ee {
587
587
  constructor(e) {
588
588
  super(), this.method = "anonymous_login";
589
- const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: c, reconnection: u } = e, l = { target_type: t, target_id: i, userVariables: r, reconnection: u, "User-Agent": { sdkVersion: bt, data: navigator.userAgent } };
589
+ const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: c, reconnection: u } = e, l = { target_type: t, target_id: i, userVariables: r, reconnection: u, "User-Agent": { sdkVersion: Ct, data: navigator.userAgent } };
590
590
  c && (l.sessid = c), s && (l.target_version_id = s), o && (l.target_params = o), this.buildRequest({ method: this.method, params: l });
591
591
  }
592
592
  }
@@ -594,7 +594,7 @@ class Le {
594
594
  constructor(e) {
595
595
  if (this.options = e, this.uuid = ye(), this.sessionid = "", this.subscriptions = {}, this.signature = null, this.relayProtocol = null, this.contexts = [], this.timeoutErrorCode = -32e3, this.invalidMethodErrorCode = -32601, this.authenticationRequiredErrorCode = -32e3, this.callReportId = null, this.dc = null, this.region = null, this.connection = null, this._jwtAuth = !1, this._autoReconnect = !0, this._idle = !1, this._tokenExpiryTimeout = null, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
596
596
  var t, i;
597
- t = e.debug ? "debug" : "info", fn = (i = We[t]) !== null && i !== void 0 ? i : We.info, this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new Nt(this), this.registerAgent = new Gi(this);
597
+ t = e.debug ? "debug" : "info", gn = (i = He[t]) !== null && i !== void 0 ? i : He.info, this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new xt(this), this.registerAgent = new qi(this);
598
598
  }
599
599
  get __logger() {
600
600
  return g;
@@ -608,13 +608,13 @@ class Le {
608
608
  }));
609
609
  }
610
610
  get reconnectDelay() {
611
- return 1e3 * mn(2, 6);
611
+ return 1e3 * _n(2, 6);
612
612
  }
613
613
  execute(e) {
614
614
  return this._idle ? new Promise(((t) => this._executeQueue.push({ resolve: t, msg: e }))) : this.connected ? this.connection.send(e).catch(((t) => O(this, void 0, void 0, (function* () {
615
615
  if (t?.code === this.authenticationRequiredErrorCode) {
616
616
  if (!this._autoReconnect) {
617
- const i = W(hi, t);
617
+ const i = H(pi, t);
618
618
  L(T.Error, { error: i, sessionId: this.sessionid }, this.uuid);
619
619
  }
620
620
  yield this.login();
@@ -645,15 +645,15 @@ class Le {
645
645
  }
646
646
  connect() {
647
647
  return O(this, void 0, void 0, (function* () {
648
- this.connection || (g.debug("No existing connection found, creating a new one."), this.connection = new Nt(this)), this._attachListeners(), this._autoReconnect = !0, this.connection.isAlive || (g.debug("Initiating connection to the server..."), this.connection.connect()), g.debug("Connect method called. Connection initiated.");
648
+ this.connection || (g.debug("No existing connection found, creating a new one."), this.connection = new xt(this)), this._attachListeners(), this._autoReconnect = !0, this.connection.isAlive || (g.debug("Initiating connection to the server..."), this.connection.connect()), g.debug("Connect method called. Connection initiated.");
649
649
  }));
650
650
  }
651
651
  _handleLoginError(e) {
652
- const t = W(dn, e);
652
+ const t = H(un, e);
653
653
  L(T.Error, { error: t, sessionId: this.sessionid }, this.uuid);
654
654
  }
655
655
  clearReconnectToken() {
656
- _n();
656
+ yn();
657
657
  }
658
658
  _checkTokenExpiry() {
659
659
  this._clearTokenExpiryTimeout();
@@ -677,7 +677,7 @@ class Le {
677
677
  }
678
678
  }
679
679
  _emitTokenExpiryWarning() {
680
- const e = ue(Ei);
680
+ const e = de(Ti);
681
681
  L(T.Warning, { warning: e, sessionId: this.sessionid }, this.uuid);
682
682
  }
683
683
  _clearTokenExpiryTimeout() {
@@ -691,8 +691,8 @@ class Le {
691
691
  {
692
692
  const s = "Invalid login options provided for authentication.";
693
693
  g.error(s);
694
- const o = W(ui, void 0, s);
695
- return void L(T.Error, { error: o, type: Fi.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
694
+ const o = H(hi, void 0, s);
695
+ return void L(T.Error, { error: o, type: Bi.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
696
696
  }
697
697
  }
698
698
  }));
@@ -700,7 +700,7 @@ class Le {
700
700
  _login({ type: e, onSuccess: t, onError: i }) {
701
701
  return O(this, void 0, void 0, (function* () {
702
702
  let s;
703
- s = e === "login" ? new Vi(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!fe()) : new Zi({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, target_params: this.options.anonymous_login.target_params, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!fe() });
703
+ s = e === "login" ? new Yi(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!fe()) : new ts({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, target_params: this.options.anonymous_login.target_params, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!fe() });
704
704
  const o = yield this.execute(s).catch(((r) => {
705
705
  this._handleLoginError(r), i && i(r);
706
706
  }));
@@ -712,8 +712,8 @@ class Le {
712
712
  }));
713
713
  }
714
714
  onNetworkClose() {
715
- this.relayProtocol && ot(this.relayProtocol);
716
- for (const e in this.subscriptions) ot(e);
715
+ this.relayProtocol && rt(this.relayProtocol);
716
+ for (const e in this.subscriptions) rt(e);
717
717
  this.subscriptions = {}, this.contexts = [], clearTimeout(this._keepAliveTimeout), clearTimeout(this._reconnectTimeout), this.connection && (this.connection.previousGatewayState = ""), this._autoReconnect && (this._reconnectTimeout = setTimeout((() => {
718
718
  g.debug("Calling connect due to network close and auto-reconnect enabled."), this.connect();
719
719
  }), this.reconnectDelay));
@@ -721,7 +721,7 @@ class Le {
721
721
  _onSocketMessage(e) {
722
722
  }
723
723
  _removeSubscription(e, t) {
724
- this._existsSubscription(e, t) && (t ? (delete this.subscriptions[e][t], pe(e, null, t)) : (delete this.subscriptions[e], ot(e)));
724
+ this._existsSubscription(e, t) && (t ? (delete this.subscriptions[e][t], pe(e, null, t)) : (delete this.subscriptions[e], rt(e)));
725
725
  }
726
726
  _addSubscription(e, t = null, i) {
727
727
  this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, Se(t) && he(e, t, i));
@@ -744,7 +744,7 @@ class Le {
744
744
  this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
745
745
  }
746
746
  _resetKeepAlive() {
747
- this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new Cn(fe()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
747
+ this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new wn(fe()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
748
748
  }
749
749
  _triggerKeepAliveTimeoutCheck() {
750
750
  this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
@@ -772,7 +772,7 @@ Le.TOKEN_EXPIRY_WARNING_SECONDS = 120;
772
772
  const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n instanceof MediaStream, Re = (n, e) => {
773
773
  const t = Ge(n);
774
774
  t !== null && (t.getAttribute("autoplay") || t.setAttribute("autoplay", "autoplay"), t.getAttribute("playsinline") || t.setAttribute("playsinline", "playsinline"), t.srcObject = e);
775
- }, En = (n, e) => O(void 0, void 0, void 0, (function* () {
775
+ }, In = (n, e) => O(void 0, void 0, void 0, (function* () {
776
776
  const t = Ge(n);
777
777
  if (t === null) return g.info("No HTMLMediaElement to attach the speakerId"), !1;
778
778
  if (typeof e != "string") return g.info(`Invalid speaker deviceId: '${e}'`), !1;
@@ -781,10 +781,10 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
781
781
  } catch {
782
782
  return !1;
783
783
  }
784
- })), es = (n) => {
784
+ })), ns = (n) => {
785
785
  n && n.readyState === "live" && n.stop();
786
786
  }, Ne = (n) => {
787
- me(n) && n.getTracks().forEach(es), n = null;
787
+ me(n) && n.getTracks().forEach(ns), n = null;
788
788
  }, Ye = (n) => O(void 0, void 0, void 0, (function* () {
789
789
  g.info("RTCService.getUserMedia", n);
790
790
  const { audio: e, video: t } = n;
@@ -798,12 +798,12 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
798
798
  let u = !1, l = r, f = c;
799
799
  if (typeof r == "object" && r !== null && "deviceId" in r) {
800
800
  u = !0;
801
- const h = He(r, ["deviceId"]);
801
+ const h = We(r, ["deviceId"]);
802
802
  l = Object.keys(h).length === 0 || h;
803
803
  }
804
804
  if (typeof c == "object" && c !== null && "deviceId" in c) {
805
805
  u = !0;
806
- const h = He(c, ["deviceId"]);
806
+ const h = We(c, ["deviceId"]);
807
807
  f = Object.keys(h).length === 0 || h;
808
808
  }
809
809
  return u ? { audio: l, video: f } : null;
@@ -832,23 +832,23 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
832
832
  }));
833
833
  }
834
834
  return t;
835
- })), Ft = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], Je = (n, e, t) => O(void 0, void 0, void 0, (function* () {
835
+ })), jt = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], Je = (n, e, t) => O(void 0, void 0, void 0, (function* () {
836
836
  const i = yield Te(t, !0);
837
837
  for (let s = 0; s < i.length; s++) {
838
838
  const { deviceId: o, label: r } = i[s];
839
839
  if (n === o || e === r) return o;
840
840
  }
841
841
  return null;
842
- })), ts = (n) => {
842
+ })), is = (n) => {
843
843
  const e = navigator.mediaDevices.getSupportedConstraints();
844
844
  Object.keys(n).map(((t) => {
845
845
  e.hasOwnProperty(t) && n[t] !== null && n[t] !== void 0 || delete n[t];
846
846
  }));
847
- }, dt = (n, e) => {
847
+ }, ut = (n, e) => {
848
848
  if (!n) return !1;
849
- const { subscribed: t, alreadySubscribed: i } = ut(n);
849
+ const { subscribed: t, alreadySubscribed: i } = ht(n);
850
850
  return t.includes(e) || i.includes(e);
851
- }, ut = (n) => {
851
+ }, ht = (n) => {
852
852
  const e = { subscribed: [], alreadySubscribed: [], unauthorized: [], unsubscribed: [], notSubscribed: [] };
853
853
  return Object.keys(e).forEach(((t) => {
854
854
  e[t] = n[`${t}Channels`] || [];
@@ -880,13 +880,13 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
880
880
  s.enabled = !s.enabled;
881
881
  }
882
882
  }));
883
- }, jt = (n) => {
883
+ }, Bt = (n) => {
884
884
  _e(n, "audio", !0);
885
- }, ht = (n) => {
885
+ }, pt = (n) => {
886
886
  _e(n, "audio", !1);
887
- }, Bt = (n) => {
887
+ }, $t = (n) => {
888
888
  _e(n, "audio", null);
889
- }, ns = (n) => ((e, t = null) => {
889
+ }, ss = (n) => ((e, t = null) => {
890
890
  if (!me(e)) return null;
891
891
  let i = [];
892
892
  switch (t) {
@@ -901,7 +901,7 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
901
901
  }
902
902
  return i.some(((s) => s.enabled));
903
903
  })(n, "audio");
904
- function is() {
904
+ function os() {
905
905
  try {
906
906
  const { browserInfo: n, name: e, version: t, supportAudio: i, supportVideo: s } = (function() {
907
907
  if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
@@ -929,7 +929,7 @@ function is() {
929
929
  }
930
930
  }
931
931
  var Y;
932
- function $t(n, e) {
932
+ function Wt(n, e) {
933
933
  const t = document.getElementById(e);
934
934
  if (t) return t;
935
935
  if (n && e) {
@@ -945,7 +945,7 @@ function Ht(n) {
945
945
  g.error("playAudio", e), n._playFulfilled = !0;
946
946
  })));
947
947
  }
948
- function Wt(n) {
948
+ function Gt(n) {
949
949
  n && (n._playFulfilled ? (n.pause(), n.currentTime = 0) : n._promise && n._promise.then ? n._promise.then((() => {
950
950
  n.pause(), n.currentTime = 0;
951
951
  })) : setTimeout((() => {
@@ -955,14 +955,14 @@ function Wt(n) {
955
955
  (function(n) {
956
956
  n.not_supported = "not supported", n.full = "full", n.partial = "partial";
957
957
  })(Y || (Y = {}));
958
- const Gt = (n) => {
958
+ const Vt = (n) => {
959
959
  const e = [], t = [];
960
960
  return n && n.length !== 0 ? (n.forEach(((i) => {
961
961
  const s = i.mimeType.toLocaleLowerCase();
962
962
  s.startsWith("audio/") ? e.push(i) : s.startsWith("video/") && t.push(i);
963
963
  })), { audioCodecs: e, videoCodecs: t }) : { audioCodecs: e, videoCodecs: t };
964
964
  };
965
- class ss extends Pe {
965
+ class rs extends Pe {
966
966
  constructor(e, t) {
967
967
  super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: ye(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...t?.map(((i) => ({ type: "image_url", image_url: { url: i } })))] } } });
968
968
  }
@@ -971,8 +971,8 @@ class J {
971
971
  constructor(e, t) {
972
972
  var i;
973
973
  this.peerConnection = null, this.intervalId = null, this.statsBuffer = [], this.intervalStartTime = null, this.callEndTime = null, this.logCollector = null, this.intervalAudioLevels = { outbound: [], inbound: [] }, this.intervalJitters = [], this.intervalRTTs = [], this.intervalBitrates = { outbound: [], inbound: [] }, this.previousStats = {}, this.previousCandidatePairId = null, this.MAX_BUFFER_SIZE = 360, this.onFlushNeeded = null, this.onWarning = null, this._breachCounters = {}, this._activeWarnings = /* @__PURE__ */ new Set(), this._lastWarningEmitted = {}, this._prevPacketsReceived = null, this._prevPacketsLost = null, this._segmentIndex = 0, this._flushing = !1, this.options = e, this.logCollectorOptions = t || { enabled: !1, level: "debug", maxEntries: 1e3 }, this.callStartTime = /* @__PURE__ */ new Date(), this.logCollectorOptions.enabled && (this.logCollector = (function(s) {
974
- return new Di(s);
975
- })(this.logCollectorOptions), this.logCollector.start(), i = this.logCollector, pn = i);
974
+ return new Mi(s);
975
+ })(this.logCollectorOptions), this.logCollector.start(), i = this.logCollector, fn = i);
976
976
  }
977
977
  start(e) {
978
978
  var t, i;
@@ -1134,17 +1134,17 @@ class J {
1134
1134
  }
1135
1135
  this._prevPacketsReceived = F, this._prevPacketsLost = R;
1136
1136
  }
1137
- if (this._trackBreach(fi, P !== void 0 && P > J.THRESHOLD_RTT_MS), this._trackBreach(gi, M !== void 0 && M > J.THRESHOLD_JITTER_MS), this._trackBreach(vi, q !== void 0 && q > J.THRESHOLD_PACKET_LOSS_PCT), P !== void 0 && M !== void 0 && q !== void 0) {
1137
+ if (this._trackBreach(gi, P !== void 0 && P > J.THRESHOLD_RTT_MS), this._trackBreach(vi, M !== void 0 && M > J.THRESHOLD_JITTER_MS), this._trackBreach(mi, q !== void 0 && q > J.THRESHOLD_PACKET_LOSS_PCT), P !== void 0 && M !== void 0 && q !== void 0) {
1138
1138
  const F = 93.2 - 0.11 * M - 2.5 * q - 0.01 * (1e3 * P), R = Math.max(1, Math.min(4.5, 1 + 0.035 * F + F * (F - 60) * (100 - F) * 7e-6));
1139
- this._trackBreach(Tt, R < J.THRESHOLD_MOS);
1140
- } else this._trackBreach(Tt, !1);
1139
+ this._trackBreach(kt, R < J.THRESHOLD_MOS);
1140
+ } else this._trackBreach(kt, !1);
1141
1141
  if (((l = (u = e.audio) === null || u === void 0 ? void 0 : u.inbound) === null || l === void 0 ? void 0 : l.bytesReceived) !== void 0 && this.statsBuffer.length > 1) {
1142
1142
  const F = this.statsBuffer[this.statsBuffer.length - 2], R = (S = (h = (f = F?.audio) === null || f === void 0 ? void 0 : f.inbound) === null || h === void 0 ? void 0 : h.bytesReceived) !== null && S !== void 0 ? S : 0, a = (y = e.audio.inbound.bytesReceived) !== null && y !== void 0 ? y : 0;
1143
- this._trackBreach(mi, a - R == 0);
1143
+ this._trackBreach(_i, a - R == 0);
1144
1144
  }
1145
1145
  if (((E = (v = e.audio) === null || v === void 0 ? void 0 : v.outbound) === null || E === void 0 ? void 0 : E.bytesSent) !== void 0 && this.statsBuffer.length > 1) {
1146
1146
  const F = this.statsBuffer[this.statsBuffer.length - 2], R = (N = (w = (m = F?.audio) === null || m === void 0 ? void 0 : m.outbound) === null || w === void 0 ? void 0 : w.bytesSent) !== null && N !== void 0 ? N : 0, a = (A = e.audio.outbound.bytesSent) !== null && A !== void 0 ? A : 0;
1147
- this._trackBreach(_i, a - R == 0);
1147
+ this._trackBreach(yi, a - R == 0);
1148
1148
  }
1149
1149
  }
1150
1150
  _trackBreach(e, t) {
@@ -1156,7 +1156,7 @@ class J {
1156
1156
  if (r - ((s = this._lastWarningEmitted[e]) !== null && s !== void 0 ? s : 0) >= J.WARNING_THROTTLE_MS) {
1157
1157
  this._lastWarningEmitted[e] = r;
1158
1158
  try {
1159
- const c = ue(e);
1159
+ const c = de(e);
1160
1160
  g.warn(`CallReportCollector: warning ${c.code}: ${c.message}`), (o = this.onWarning) === null || o === void 0 || o.call(this, c);
1161
1161
  } catch (c) {
1162
1162
  g.error(`CallReportCollector: Failed to emit warning ${e}`, { error: c });
@@ -1218,7 +1218,7 @@ class J {
1218
1218
  }
1219
1219
  }
1220
1220
  J.STATS_FLUSH_THRESHOLD = 300, J.LOGS_FLUSH_THRESHOLD = 800, J.CONSECUTIVE_BREACHES_REQUIRED = 3, J.THRESHOLD_RTT_MS = 0.4, J.THRESHOLD_JITTER_MS = 30, J.THRESHOLD_PACKET_LOSS_PCT = 1, J.THRESHOLD_MOS = 3.5, J.WARNING_THROTTLE_MS = 15e3, J.RETRY_DELAY_MS = 500;
1221
- var Fe, In = hn((function(n, e) {
1221
+ var Fe, Tn = pn((function(n, e) {
1222
1222
  var t;
1223
1223
  function i() {
1224
1224
  }
@@ -1287,32 +1287,32 @@ var Fe, In = hn((function(n, e) {
1287
1287
  case 1:
1288
1288
  (function(G, C, D) {
1289
1289
  if (C) G.call(D);
1290
- else for (var j = G.length, H = l(G, j), K = 0; K < j; ++K) H[K].call(D);
1290
+ else for (var j = G.length, W = l(G, j), K = 0; K < j; ++K) W[K].call(D);
1291
1291
  })(p, ie, this);
1292
1292
  break;
1293
1293
  case 2:
1294
1294
  (function(G, C, D, j) {
1295
1295
  if (C) G.call(D, j);
1296
- else for (var H = G.length, K = l(G, H), X = 0; X < H; ++X) K[X].call(D, j);
1296
+ else for (var W = G.length, K = l(G, W), Q = 0; Q < W; ++Q) K[Q].call(D, j);
1297
1297
  })(p, ie, this, arguments[1]);
1298
1298
  break;
1299
1299
  case 3:
1300
- (function(G, C, D, j, H) {
1301
- if (C) G.call(D, j, H);
1302
- else for (var K = G.length, X = l(G, K), V = 0; V < K; ++V) X[V].call(D, j, H);
1300
+ (function(G, C, D, j, W) {
1301
+ if (C) G.call(D, j, W);
1302
+ else for (var K = G.length, Q = l(G, K), V = 0; V < K; ++V) Q[V].call(D, j, W);
1303
1303
  })(p, ie, this, arguments[1], arguments[2]);
1304
1304
  break;
1305
1305
  case 4:
1306
- (function(G, C, D, j, H, K) {
1307
- if (C) G.call(D, j, H, K);
1308
- else for (var X = G.length, V = l(G, X), ae = 0; ae < X; ++ae) V[ae].call(D, j, H, K);
1306
+ (function(G, C, D, j, W, K) {
1307
+ if (C) G.call(D, j, W, K);
1308
+ else for (var Q = G.length, V = l(G, Q), ae = 0; ae < Q; ++ae) V[ae].call(D, j, W, K);
1309
1309
  })(p, ie, this, arguments[1], arguments[2], arguments[3]);
1310
1310
  break;
1311
1311
  default:
1312
1312
  for (b = Array(_ - 1), k = 1; k < _; k++) b[k - 1] = arguments[k];
1313
1313
  (function(G, C, D, j) {
1314
1314
  if (C) G.apply(D, j);
1315
- else for (var H = G.length, K = l(G, H), X = 0; X < H; ++X) K[X].apply(D, j);
1315
+ else for (var W = G.length, K = l(G, W), Q = 0; Q < W; ++Q) K[Q].apply(D, j);
1316
1316
  })(p, ie, this, b);
1317
1317
  }
1318
1318
  return !0;
@@ -1792,9 +1792,9 @@ var Fe, In = hn((function(n, e) {
1792
1792
  }
1793
1793
  };
1794
1794
  }));
1795
- (Fe = In) && Fe.__esModule && Object.prototype.hasOwnProperty.call(Fe, "default") && Fe.default;
1796
- var os = In.WebRTCStats;
1797
- function rs(n) {
1795
+ (Fe = Tn) && Fe.__esModule && Object.prototype.hasOwnProperty.call(Fe, "default") && Fe.default;
1796
+ var as = Tn.WebRTCStats;
1797
+ function cs(n) {
1798
1798
  const { packetsLost: e, packetsReceived: t, jitter: i, rtt: s } = n, o = (function(l) {
1799
1799
  const { jitter: f, rtt: h } = l, S = f + h / 2;
1800
1800
  return 0.024 * S + 0.11 * (S - 177.3) * (S > 177.3 ? 1 : 0);
@@ -1804,44 +1804,44 @@ function rs(n) {
1804
1804
  })({ packetsLost: e, packetsReceived: t }), c = 93.2 - o - r + 0, u = 1 + 0.035 * c + 7e-6 * c * (c - 60) * (100 - c);
1805
1805
  return Math.min(Math.max(u, 1), 5);
1806
1806
  }
1807
- function as(n) {
1807
+ function ls(n) {
1808
1808
  return isNaN(n) ? null : n > 4.2 ? "excellent" : n >= 4.1 && n <= 4.2 ? "good" : n >= 3.7 && n <= 4 ? "fair" : n >= 3.1 && n <= 3.6 ? "poor" : "bad";
1809
1809
  }
1810
- class cs extends Pe {
1810
+ class ds extends Pe {
1811
1811
  constructor(e, t) {
1812
1812
  super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1, call_id: t });
1813
1813
  }
1814
1814
  }
1815
- class ls extends Pe {
1815
+ class us extends Pe {
1816
1816
  constructor(e, t) {
1817
1817
  super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1, call_id: t });
1818
1818
  }
1819
1819
  }
1820
- class ds extends Pe {
1820
+ class hs extends Pe {
1821
1821
  constructor(e, t) {
1822
1822
  super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: t });
1823
1823
  }
1824
1824
  }
1825
- function Vt(n, e) {
1825
+ function qt(n, e) {
1826
1826
  var t, i;
1827
1827
  return { errorCode: n.errorCode, errorText: n.errorText, url: n.url, address: n.address, port: n.port, connectionState: e.connectionState, iceConnectionState: e.iceConnectionState, iceGatheringState: e.iceGatheringState, signalingState: e.signalingState, localDescriptionType: (t = e.localDescription) === null || t === void 0 ? void 0 : t.type, remoteDescriptionType: (i = e.remoteDescription) === null || i === void 0 ? void 0 : i.type };
1828
1828
  }
1829
- function us(n, e) {
1829
+ function ps(n, e) {
1830
1830
  const t = ye();
1831
1831
  let i = !1;
1832
- const s = new os({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => O(this, void 0, void 0, (function* () {
1832
+ const s = new as({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => O(this, void 0, void 0, (function* () {
1833
1833
  r.event === "stats" && L(T.StatsFrame, (function({ data: c }) {
1834
1834
  var u, l, f, h, S, y, v, E;
1835
- const { audio: m, remote: w } = c, { audio: N } = w, A = (l = (u = N.inbound[0]) === null || u === void 0 ? void 0 : u.jitter) !== null && l !== void 0 ? l : 1 / 0, P = (h = (f = N.inbound[0]) === null || f === void 0 ? void 0 : f.roundTripTime) !== null && h !== void 0 ? h : 1 / 0, M = (y = (S = m.inbound[0]) === null || S === void 0 ? void 0 : S.packetsReceived) !== null && y !== void 0 ? y : -1, q = (E = (v = m.inbound[0]) === null || v === void 0 ? void 0 : v.packetsLost) !== null && E !== void 0 ? E : -1, F = rs({ jitter: 1e3 * A, rtt: 1e3 * P, packetsLost: q, packetsReceived: M });
1836
- return { jitter: A, rtt: P, mos: F, quality: as(F), inboundAudio: m.inbound[0], outboundAudio: m.outbound[0], remoteInboundAudio: N.inbound[0], remoteOutboundAudio: N.outbound[0] };
1837
- })(r), n.uuid), yield n.execute(new ds(t, r));
1835
+ const { audio: m, remote: w } = c, { audio: N } = w, A = (l = (u = N.inbound[0]) === null || u === void 0 ? void 0 : u.jitter) !== null && l !== void 0 ? l : 1 / 0, P = (h = (f = N.inbound[0]) === null || f === void 0 ? void 0 : f.roundTripTime) !== null && h !== void 0 ? h : 1 / 0, M = (y = (S = m.inbound[0]) === null || S === void 0 ? void 0 : S.packetsReceived) !== null && y !== void 0 ? y : -1, q = (E = (v = m.inbound[0]) === null || v === void 0 ? void 0 : v.packetsLost) !== null && E !== void 0 ? E : -1, F = cs({ jitter: 1e3 * A, rtt: 1e3 * P, packetsLost: q, packetsReceived: M });
1836
+ return { jitter: A, rtt: P, mos: F, quality: ls(F), inboundAudio: m.inbound[0], outboundAudio: m.outbound[0], remoteInboundAudio: N.inbound[0], remoteOutboundAudio: N.outbound[0] };
1837
+ })(r), n.uuid), yield n.execute(new hs(t, r));
1838
1838
  }));
1839
1839
  return { get isRunning() {
1840
1840
  return i;
1841
1841
  }, start: (r, c, u) => O(this, void 0, void 0, (function* () {
1842
1842
  if (i) g.debug(`[${e}] Stats reporter already running, skipping start`);
1843
1843
  else {
1844
- yield n.execute(new cs(t, e)), s.on("timeline", o);
1844
+ yield n.execute(new ds(t, e)), s.on("timeline", o);
1845
1845
  try {
1846
1846
  yield s.addConnection({ pc: r, peerId: c, connectionId: u }), i = !0;
1847
1847
  } catch (l) {
@@ -1853,7 +1853,7 @@ function us(n, e) {
1853
1853
  L(T.StatsReport, c, n.uuid), r === "file" && (function(u, l) {
1854
1854
  const f = new Blob([JSON.stringify(u)], { type: "application/json" }), h = URL.createObjectURL(f), S = document.createElement("a");
1855
1855
  S.href = h, S.download = `${l}.json`, S.click(), URL.revokeObjectURL(h);
1856
- })(c, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new ls(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
1856
+ })(c, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new us(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
1857
1857
  })), reportConnectionStateChange: (r) => {
1858
1858
  const c = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
1859
1859
  o(c);
@@ -1862,10 +1862,10 @@ function us(n, e) {
1862
1862
  o(c);
1863
1863
  } };
1864
1864
  }
1865
- const Tn = (n, e) => {
1865
+ const kn = (n, e) => {
1866
1866
  const { contentType: t, canvasType: i, callID: s, canvasInfo: o = null, currentLayerIdx: r = -1 } = e;
1867
1867
  o && i !== "mcu-personal-canvas" && delete o.memberID;
1868
- const c = { type: re.conferenceUpdate, call: n.calls[s], canvasInfo: hs(o), currentLayerIdx: r };
1868
+ const c = { type: re.conferenceUpdate, call: n.calls[s], canvasInfo: fs(o), currentLayerIdx: r };
1869
1869
  switch (t) {
1870
1870
  case "layer-info": {
1871
1871
  const u = Object.assign({ action: oe.LayerInfo }, c);
@@ -1878,11 +1878,11 @@ const Tn = (n, e) => {
1878
1878
  break;
1879
1879
  }
1880
1880
  }
1881
- }, hs = (n) => {
1881
+ }, fs = (n) => {
1882
1882
  const e = JSON.stringify(n).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
1883
- return gn(e);
1884
- }, qt = ["new-call-start", "new-peer", "get-user-media", "peer-creation-end", "start-negotiation", "create-offer", "create-answer", "set-local-description", "ice-gathering-started", "first-candidate", "first-non-host-candidate", "send-sdp", "ice-gathering-completed", "ringing", "telnyx-rtc-media", "first-remote-media-track", "set-remote-description", "telnyx-rtc-answer", "ice-connected", "dtls-connected", "call-active", "answer-called"], ps = { "new-call-start": "Call Start", "new-peer": "Peer object created", "get-user-media": "Media devices acquired", "peer-creation-end": "Peer setup complete", "start-negotiation": "SDP negotiation started", "create-offer": "SDP offer generated", "create-answer": "SDP answer generated", "set-local-description": "Local description applied", "ice-gathering-started": "ICE candidate gathering started", "first-candidate": "First ICE candidate found", "first-non-host-candidate": "First server-reflexive/relay candidate found", "send-sdp": "SDP sent to server", "ice-gathering-completed": "All ICE candidates gathered", ringing: "Remote side ringing", "telnyx-rtc-media": "Early media received from server", "first-remote-media-track": "First remote audio/video track received", "set-remote-description": "Remote description applied", "telnyx-rtc-answer": "Call answered by remote side", "ice-connected": "ICE connection established", "dtls-connected": "Secure media channel established (DTLS)", "call-active": "Call is active", "answer-called": "Answer delay (invite → call.answer)" };
1885
- function Yt(n) {
1883
+ return vn(e);
1884
+ }, Yt = ["new-call-start", "new-peer", "get-user-media", "peer-creation-end", "start-negotiation", "create-offer", "create-answer", "set-local-description", "ice-gathering-started", "first-candidate", "first-non-host-candidate", "send-sdp", "ice-gathering-completed", "ringing", "telnyx-rtc-media", "first-remote-media-track", "set-remote-description", "telnyx-rtc-answer", "ice-connected", "dtls-connected", "call-active", "answer-called"], gs = { "new-call-start": "Call Start", "new-peer": "Peer object created", "get-user-media": "Media devices acquired", "peer-creation-end": "Peer setup complete", "start-negotiation": "SDP negotiation started", "create-offer": "SDP offer generated", "create-answer": "SDP answer generated", "set-local-description": "Local description applied", "ice-gathering-started": "ICE candidate gathering started", "first-candidate": "First ICE candidate found", "first-non-host-candidate": "First server-reflexive/relay candidate found", "send-sdp": "SDP sent to server", "ice-gathering-completed": "All ICE candidates gathered", ringing: "Remote side ringing", "telnyx-rtc-media": "Early media received from server", "first-remote-media-track": "First remote audio/video track received", "set-remote-description": "Remote description applied", "telnyx-rtc-answer": "Call answered by remote side", "ice-connected": "ICE connection established", "dtls-connected": "Secure media channel established (DTLS)", "call-active": "Call is active", "answer-called": "Answer delay (invite → call.answer)" };
1885
+ function Jt(n) {
1886
1886
  try {
1887
1887
  const e = performance.getEntriesByName(n, "mark");
1888
1888
  return e.length > 0 ? e[0].startTime : void 0;
@@ -1925,11 +1925,11 @@ class xe {
1925
1925
  navigator.onLine ? c() : window.addEventListener("online", c);
1926
1926
  }
1927
1927
  if (r === "disconnected") {
1928
- const c = ue(yi);
1928
+ const c = de(Si);
1929
1929
  L(T.Warning, { warning: c, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
1930
1930
  }
1931
1931
  if (r === "failed") {
1932
- const c = ue(Ci);
1932
+ const c = de(wi);
1933
1933
  L(T.PeerConnectionFailureError, { warning: c, error: new Error(`Peer Connection failed. previous state: ${this._prevConnectionState}, current state: ${r}`), sessionId: this._session.sessionid }, this.options.id);
1934
1934
  }
1935
1935
  this._prevConnectionState = r, r === "connected" && (performance.mark("dtls-connected"), this.tryCollectTimings()), this._isTrickleIce() && (r === "connecting" && performance.mark("peer-connection-connecting"), r === "connected" && (this._clearIceGatheringSafetyTimeout(), performance.mark("peer-connection-connected")));
@@ -1944,10 +1944,10 @@ class xe {
1944
1944
  }, g.debug("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !!t.video }, this._sdpReady = this._sdpReady.bind(this), this.handleSignalingStateChangeEvent = this.handleSignalingStateChangeEvent.bind(this), this.handleNegotiationNeededEvent = this.handleNegotiationNeededEvent.bind(this), this.handleTrackEvent = this.handleTrackEvent.bind(this), this.createPeerConnection = this.createPeerConnection.bind(this), this._session = i, this._trickleIceSdpFn = s, this._registerPeerEvents = o;
1945
1945
  }
1946
1946
  get isOffer() {
1947
- return this.type === Q.Offer;
1947
+ return this.type === z.Offer;
1948
1948
  }
1949
1949
  get isAnswer() {
1950
- return this.type === Q.Answer;
1950
+ return this.type === z.Answer;
1951
1951
  }
1952
1952
  get isDebugEnabled() {
1953
1953
  return this.options.debug || this._session.options.debug;
@@ -1998,13 +1998,13 @@ class xe {
1998
1998
  if (this._timingsCollected || !(performance.getEntriesByName("call-active", "mark").length > 0) || this.instance.connectionState !== "connected") return;
1999
1999
  this._timingsCollected = !0;
2000
2000
  const e = (function(t, i) {
2001
- const s = Yt("new-call-start");
2001
+ const s = Jt("new-call-start");
2002
2002
  if (s === void 0) return { mode: t, direction: i, steps: [] };
2003
2003
  const o = [];
2004
- for (const u of qt) {
2004
+ for (const u of Yt) {
2005
2005
  if (u === "new-call-start") continue;
2006
- const l = Yt(u);
2007
- l !== void 0 && o.push({ label: ps[u] || u, fromStart: l - s });
2006
+ const l = Jt(u);
2007
+ l !== void 0 && o.push({ label: gs[u] || u, fromStart: l - s });
2008
2008
  }
2009
2009
  o.sort(((u, l) => u.fromStart - l.fromStart));
2010
2010
  const r = [];
@@ -2031,7 +2031,7 @@ class xe {
2031
2031
  }
2032
2032
  g.info(`${r} ${h}`);
2033
2033
  })(e), (function() {
2034
- for (const t of qt) try {
2034
+ for (const t of Yt) try {
2035
2035
  performance.clearMarks(t);
2036
2036
  } catch {
2037
2037
  g.warn("Clearing performance marks is failed");
@@ -2041,9 +2041,9 @@ class xe {
2041
2041
  createPeerConnection() {
2042
2042
  return O(this, void 0, void 0, (function* () {
2043
2043
  var e;
2044
- this.instance = (e = this._config(), new window.RTCPeerConnection(e)), this.instance.onsignalingstatechange = this.handleSignalingStateChangeEvent, this.instance.onnegotiationneeded = this.handleNegotiationNeededEvent, this.instance.ontrack = this.handleTrackEvent, this.instance.addEventListener("connectionstatechange", this.handleConnectionStateChange), this.instance.addEventListener("iceconnectionstatechange", this._handleIceConnectionStateChange), this.instance.addEventListener("icegatheringstatechange", this._handleIceGatheringStateChange), this.instance.addEventListener("addstream", ((s) => {
2044
+ if (this.instance = (e = this._config(), new window.RTCPeerConnection(e)), this.instance.onsignalingstatechange = this.handleSignalingStateChangeEvent, this.instance.onnegotiationneeded = this.handleNegotiationNeededEvent, this.instance.ontrack = this.handleTrackEvent, this.instance.addEventListener("connectionstatechange", this.handleConnectionStateChange), this.instance.addEventListener("iceconnectionstatechange", this._handleIceConnectionStateChange), this.instance.addEventListener("icegatheringstatechange", this._handleIceGatheringStateChange), this.instance.addEventListener("addstream", ((s) => {
2045
2045
  this.options.remoteStream = s.stream;
2046
- })), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: Q.Offer }), performance.mark("set-remote-description"));
2046
+ })), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer }), performance.mark("set-remote-description"), !this.instance)) throw H(ot);
2047
2047
  const t = !!this.options.receiveOnlyAudio && !this.options.audio;
2048
2048
  let i = null;
2049
2049
  if (this.options.localStream = yield this._retrieveLocalStream().catch(((s) => O(this, void 0, void 0, (function* () {
@@ -2051,7 +2051,7 @@ class xe {
2051
2051
  if (o?.enabled && this._isAnswer()) {
2052
2052
  let r = null, c = null;
2053
2053
  return yield new Promise(((u, l) => {
2054
- c = setTimeout((() => l(new Error("Media recovery flow timed out!"))), o.timeout), L(T.Error, { error: W(Oe(s), s), callId: this.options.id, sessionId: this._session.sessionid, recoverable: !0, retryDeadline: Date.now() + o.timeout, resume: () => {
2054
+ c = setTimeout((() => l(new Error("Media recovery flow timed out!"))), o.timeout), L(T.Error, { error: H(Oe(s), s), callId: this.options.id, sessionId: this._session.sessionid, recoverable: !0, retryDeadline: Date.now() + o.timeout, resume: () => {
2055
2055
  u();
2056
2056
  }, reject: () => {
2057
2057
  l(new Error("Call was rejected during media recovery flow!"));
@@ -2065,9 +2065,10 @@ class xe {
2065
2065
  })), r;
2066
2066
  }
2067
2067
  return i = s, null;
2068
- })))), !this.options.localStream && !t)
2069
- throw W(i ? Oe(i) : ln, i ?? void 0);
2070
- performance.mark("get-user-media"), this.options.mutedMicOnStart && me(this.options.localStream) && (g.info("Muting local audio tracks on start"), ht(this.options.localStream)), performance.mark("peer-creation-end");
2068
+ })))), !this.instance) throw H(ot);
2069
+ if (!this.options.localStream && !t)
2070
+ throw H(i ? Oe(i) : dn, i ?? void 0);
2071
+ performance.mark("get-user-media"), this.options.mutedMicOnStart && me(this.options.localStream) && (g.info("Muting local audio tracks on start"), pt(this.options.localStream)), performance.mark("peer-creation-end");
2071
2072
  }));
2072
2073
  }
2073
2074
  incrementGatheredCandidates() {
@@ -2077,10 +2078,10 @@ class xe {
2077
2078
  this._clearIceGatheringSafetyTimeout(), this._iceGatheringSafetyTimeout = setTimeout((() => {
2078
2079
  if (this.instance) {
2079
2080
  if (this._gatheredCandidatesCount === 0) {
2080
- const e = ue(bi);
2081
+ const e = de(Ci);
2081
2082
  L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
2082
2083
  } else if (this.instance.iceGatheringState !== "complete") {
2083
- const e = ue(Si);
2084
+ const e = de(bi);
2084
2085
  L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
2085
2086
  }
2086
2087
  }
@@ -2092,7 +2093,8 @@ class xe {
2092
2093
  init() {
2093
2094
  var e;
2094
2095
  return O(this, void 0, void 0, (function* () {
2095
- yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = us(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
2096
+ if (yield this.createPeerConnection(), !this.instance) throw H(ot);
2097
+ this.isDebugEnabled && (this.statsReporter = ps(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
2096
2098
  const { localElement: t, localStream: i = null, screenShare: s = !1 } = this.options;
2097
2099
  if (me(i)) {
2098
2100
  const o = i.getAudioTracks();
@@ -2105,7 +2107,7 @@ class xe {
2105
2107
  g.info("Local video tracks constraints: ", f.getConstraints());
2106
2108
  }));
2107
2109
  }
2108
- const { audioCodecs: c, videoCodecs: u } = Gt(this.options.preferred_codecs);
2110
+ const { audioCodecs: c, videoCodecs: u } = Vt(this.options.preferred_codecs);
2109
2111
  if (this.isOffer && typeof this.instance.addTransceiver == "function") {
2110
2112
  const l = { direction: "sendrecv", streams: [i] };
2111
2113
  r.forEach(((f) => {
@@ -2122,7 +2124,7 @@ class xe {
2122
2124
  } else if (this.options.receiveOnlyAudio && typeof this.instance.addTransceiver == "function") {
2123
2125
  const o = this.instance.addTransceiver("audio", { direction: "recvonly" });
2124
2126
  g.info("Added recvonly audio transceiver for receive-only mode", o);
2125
- const { audioCodecs: r } = Gt(this.options.preferred_codecs);
2127
+ const { audioCodecs: r } = Vt(this.options.preferred_codecs);
2126
2128
  r.length > 0 && this._setCodecs(o, r);
2127
2129
  }
2128
2130
  this.isOffer ? (this.options.negotiateAudio && this._checkMediaToNegotiate("audio"), this.options.negotiateVideo && this._checkMediaToNegotiate("video")) : this._isTrickleIce() || this.startNegotiation(), this._isTrickleIce() && this.startTrickleIceNegotiation(), this._logTransceivers();
@@ -2146,7 +2148,7 @@ class xe {
2146
2148
  return performance.mark("create-offer"), yield this._setLocalDescription(e), performance.mark("set-local-description"), performance.mark("ice-gathering-started"), this._isTrickleIce() || this._sdpReady(), e;
2147
2149
  } catch (e) {
2148
2150
  g.error("Peer _createOffer error:", e);
2149
- const t = W(Xn, e);
2151
+ const t = H(Zn, e);
2150
2152
  L(T.Error, { error: t, sessionId: this._session.sessionid }, this.options.id);
2151
2153
  }
2152
2154
  }
@@ -2159,7 +2161,7 @@ class xe {
2159
2161
  yield this.instance.setRemoteDescription(e);
2160
2162
  } catch (t) {
2161
2163
  g.error("Peer _setRemoteDescription error:", t);
2162
- const i = W(cn, t);
2164
+ const i = H(ln, t);
2163
2165
  throw L(T.Error, { error: i, sessionId: this._session.sessionid }, this.options.id), t;
2164
2166
  }
2165
2167
  }));
@@ -2167,14 +2169,14 @@ class xe {
2167
2169
  _createAnswer() {
2168
2170
  return O(this, void 0, void 0, (function* () {
2169
2171
  if (this._isAnswer()) {
2170
- if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return g.debug("Skipping negotiation, state:", this.instance.signalingState), g.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type: Q.Offer })]));
2172
+ if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return g.debug("Skipping negotiation, state:", this.instance.signalingState), g.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })]));
2171
2173
  this._logTransceivers();
2172
2174
  try {
2173
2175
  const e = yield this.instance.createAnswer();
2174
2176
  return performance.mark("create-answer"), yield this._setLocalDescription(e), performance.mark("set-local-description"), performance.mark("ice-gathering-started"), e;
2175
2177
  } catch (e) {
2176
2178
  g.error("Peer _createAnswer error:", e);
2177
- const t = W(Zn, e);
2179
+ const t = H(ei, e);
2178
2180
  L(T.Error, { error: t, sessionId: this._session.sessionid }, this.options.id);
2179
2181
  }
2180
2182
  }
@@ -2186,7 +2188,7 @@ class xe {
2186
2188
  yield this.instance.setLocalDescription(e);
2187
2189
  } catch (t) {
2188
2190
  g.error("Peer _setLocalDescription error:", t);
2189
- const i = W(ei, t);
2191
+ const i = H(ti, t);
2190
2192
  throw L(T.Error, { error: i, sessionId: this._session.sessionid }, this.options.id), t;
2191
2193
  }
2192
2194
  }));
@@ -2207,10 +2209,10 @@ class xe {
2207
2209
  }));
2208
2210
  }
2209
2211
  _isOffer() {
2210
- return this.type === Q.Offer;
2212
+ return this.type === z.Offer;
2211
2213
  }
2212
2214
  _isAnswer() {
2213
- return this.type === Q.Answer;
2215
+ return this.type === z.Answer;
2214
2216
  }
2215
2217
  _isTrickleIce() {
2216
2218
  return this.options.trickleIce === !0;
@@ -2231,10 +2233,10 @@ class xe {
2231
2233
  }
2232
2234
  }
2233
2235
  xe.ICE_GATHERING_SAFETY_TIMEOUT_MS = 15e3;
2234
- const je = bt;
2235
- class kn {
2236
+ const je = Ct;
2237
+ class Rn {
2236
2238
  constructor(e, t) {
2237
- this.session = e, this._callReportCollector = null, this.id = "", this.recoveredCallId = "", this.state = U[U.New], this.prevState = "", this.channels = [], this.role = lt.Participant, this.extension = null, this._state = U.New, this._prevState = U.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._signalingStateClosed = !1, this._creatingPeer = !1, this._firstCandidateSent = !1, this._firstNonHostCandidateSent = !1, this._isRecovering = !1, this._checkConferenceSerno = (m) => {
2239
+ this.session = e, this._callReportCollector = null, this.id = "", this.recoveredCallId = "", this.state = U[U.New], this.prevState = "", this.channels = [], this.role = dt.Participant, this.extension = null, this._state = U.New, this._prevState = U.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._signalingStateClosed = !1, this._creatingPeer = !1, this._firstCandidateSent = !1, this._firstNonHostCandidateSent = !1, this._isRecovering = !1, this._checkConferenceSerno = (m) => {
2238
2240
  const w = m < 0 || !this._lastSerno || this._lastSerno && m === this._lastSerno + 1;
2239
2241
  return w && m >= 0 && (this._lastSerno = m), w;
2240
2242
  }, this._doStats = () => {
@@ -2252,7 +2254,7 @@ class kn {
2252
2254
  }));
2253
2255
  };
2254
2256
  const { iceServers: i, speaker: s, micId: o, micLabel: r, camId: c, camLabel: u, localElement: l, remoteElement: f, options: h, mediaConstraints: { audio: S, video: y }, ringtoneFile: v, ringbackFile: E } = e;
2255
- this.options = Object.assign({}, ji, { audio: S, video: y, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : i, localElement: l, remoteElement: f, micId: o, micLabel: r, camId: c, camLabel: u, speakerId: s, ringtoneFile: v, ringbackFile: E, debug: h.debug, debugOutput: h.debugOutput, trickleIce: h.trickleIce, prefetchIceCandidates: h.prefetchIceCandidates, forceRelayCandidate: h.forceRelayCandidate, keepConnectionAliveOnSocketClose: h.keepConnectionAliveOnSocketClose, mutedMicOnStart: h.mutedMicOnStart }, t), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = $t(this.options.ringtoneFile, "_ringtone"), this._ringback = $t(this.options.ringbackFile, "_ringback"));
2257
+ this.options = Object.assign({}, $i, { audio: S, video: y, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : i, localElement: l, remoteElement: f, micId: o, micLabel: r, camId: c, camLabel: u, speakerId: s, ringtoneFile: v, ringbackFile: E, debug: h.debug, debugOutput: h.debugOutput, trickleIce: h.trickleIce, prefetchIceCandidates: h.prefetchIceCandidates, forceRelayCandidate: h.forceRelayCandidate, keepConnectionAliveOnSocketClose: h.keepConnectionAliveOnSocketClose, mutedMicOnStart: h.mutedMicOnStart }, t), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = Wt(this.options.ringtoneFile, "_ringtone"), this._ringback = Wt(this.options.ringbackFile, "_ringback"));
2256
2258
  }
2257
2259
  get creatingPeer() {
2258
2260
  return this._creatingPeer;
@@ -2282,31 +2284,35 @@ class kn {
2282
2284
  return `conference-member.${this.id}`;
2283
2285
  }
2284
2286
  get isAudioMuted() {
2285
- return !ns(this.options.localStream);
2287
+ return !ss(this.options.localStream);
2286
2288
  }
2287
2289
  invite() {
2288
2290
  return O(this, void 0, void 0, (function* () {
2289
- this._creatingPeer = !0, this.direction = ce.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(Q.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
2291
+ this._creatingPeer = !0, this.direction = ce.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(z.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
2290
2292
  try {
2291
2293
  yield this.peer.init();
2292
2294
  } catch (e) {
2293
2295
  g.error("Peer init failed, aborting call", e), this._creatingPeer = !1;
2294
- const t = e instanceof Ae ? e : W(It, e instanceof Error ? e : void 0);
2296
+ const t = e instanceof Ae ? e : H(Tt, e instanceof Error ? e : void 0);
2295
2297
  return L(T.Error, { error: t, callId: this.id, sessionId: this.session.sessionid, recoverable: !1 }, this.session.uuid), void this.hangup({}, !1);
2296
2298
  }
2297
2299
  this._creatingPeer = !1;
2298
2300
  }));
2299
2301
  }
2300
2302
  answer(e = {}) {
2301
- var t;
2303
+ var t, i;
2302
2304
  return O(this, void 0, void 0, (function* () {
2303
- performance.mark("answer-called"), this._creatingPeer = !0, this.stopRingtone(), this.direction = ce.Inbound, ((t = e?.customHeaders) === null || t === void 0 ? void 0 : t.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(Q.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
2305
+ if (!((t = this.peer) === null || t === void 0) && t.instance && this.peer.instance.signalingState !== "closed") {
2306
+ const s = de(Ii);
2307
+ return L(T.Warning, { warning: s, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid), void g.warn(`[${this.id}] answer() ignored: peer connection already exists (signalingState: ${this.peer.instance.signalingState})`);
2308
+ }
2309
+ performance.mark("answer-called"), this._creatingPeer = !0, this.stopRingtone(), this.direction = ce.Inbound, ((i = e?.customHeaders) === null || i === void 0 ? void 0 : i.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(z.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
2304
2310
  try {
2305
2311
  yield this.peer.init();
2306
- } catch (i) {
2307
- g.error("Peer init failed, aborting call", i), this._creatingPeer = !1;
2308
- const s = i instanceof Ae ? i : W(It, i instanceof Error ? i : void 0);
2309
- return L(T.Error, { error: s, callId: this.id, sessionId: this.session.sessionid, recoverable: !1 }, this.session.uuid), void (yield this.hangup());
2312
+ } catch (s) {
2313
+ g.error("Peer init failed, aborting call", s), this._creatingPeer = !1;
2314
+ const o = s instanceof Ae ? s : H(Tt, s instanceof Error ? s : void 0);
2315
+ return L(T.Error, { error: o, callId: this.id, sessionId: this.session.sessionid, recoverable: !1 }, this.session.uuid), void (yield this.hangup());
2310
2316
  }
2311
2317
  this._creatingPeer = !1;
2312
2318
  }));
@@ -2315,13 +2321,13 @@ class kn {
2315
2321
  Ht(this._ringtone);
2316
2322
  }
2317
2323
  stopRingtone() {
2318
- Wt(this._ringtone);
2324
+ Gt(this._ringtone);
2319
2325
  }
2320
2326
  playRingback() {
2321
2327
  Ht(this._ringback);
2322
2328
  }
2323
2329
  stopRingback() {
2324
- Wt(this._ringback);
2330
+ Gt(this._ringback);
2325
2331
  }
2326
2332
  hangup(e, t) {
2327
2333
  var i, s, o, r;
@@ -2329,12 +2335,12 @@ class kn {
2329
2335
  const c = e || {}, u = t !== !1, l = this._state < U.Active ? { cause: "USER_BUSY", causeCode: 17 } : { cause: "NORMAL_CLEARING", causeCode: 16 };
2330
2336
  if (this.cause = c.cause || l.cause, this.causeCode = c.causeCode || l.causeCode, this.sipCode = c.sipCode || null, this.sipReason = c.sipReason || null, this.sipCallId = c.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(o = (s = c?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && o !== void 0 ? o : []], c.isRecovering) return this._isRecovering = !0, this.setState(U.Recovering), void this._finalize();
2331
2337
  if (this.setState(U.Hangup), this.stopRingtone(), this.stopRingback(), u) {
2332
- const f = new Yi({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
2338
+ const f = new Ki({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
2333
2339
  try {
2334
2340
  yield this._execute(f);
2335
2341
  } catch (h) {
2336
2342
  g.error("telnyx_rtc.bye failed!", h);
2337
- const S = W(oi, h);
2343
+ const S = H(ri, h);
2338
2344
  L(T.Error, { error: S, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
2339
2345
  }
2340
2346
  }
@@ -2342,33 +2348,33 @@ class kn {
2342
2348
  }));
2343
2349
  }
2344
2350
  hold() {
2345
- const e = new rt({ sessid: this.session.sessionid, action: "hold", dialogParams: this.options });
2351
+ const e = new at({ sessid: this.session.sessionid, action: "hold", dialogParams: this.options });
2346
2352
  return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
2347
2353
  }
2348
2354
  unhold() {
2349
- const e = new rt({ sessid: this.session.sessionid, action: "unhold", dialogParams: this.options });
2355
+ const e = new at({ sessid: this.session.sessionid, action: "unhold", dialogParams: this.options });
2350
2356
  return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
2351
2357
  }
2352
2358
  toggleHold() {
2353
- const e = new rt({ sessid: this.session.sessionid, action: "toggleHold", dialogParams: this.options });
2359
+ const e = new at({ sessid: this.session.sessionid, action: "toggleHold", dialogParams: this.options });
2354
2360
  return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
2355
2361
  }
2356
2362
  dtmf(e) {
2357
- const t = new Ut({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
2363
+ const t = new Ft({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
2358
2364
  this._execute(t);
2359
2365
  }
2360
2366
  message(e, t) {
2361
- const i = { from: this.session.options.login, to: e, body: t }, s = new Ut({ sessid: this.session.sessionid, msg: i, dialogParams: this.options });
2367
+ const i = { from: this.session.options.login, to: e, body: t }, s = new Ft({ sessid: this.session.sessionid, msg: i, dialogParams: this.options });
2362
2368
  this._execute(s);
2363
2369
  }
2364
2370
  muteAudio() {
2365
- ht(this.options.localStream);
2371
+ pt(this.options.localStream);
2366
2372
  }
2367
2373
  unmuteAudio() {
2368
- jt(this.options.localStream);
2374
+ Bt(this.options.localStream);
2369
2375
  }
2370
2376
  toggleAudioMute() {
2371
- Bt(this.options.localStream);
2377
+ $t(this.options.localStream);
2372
2378
  }
2373
2379
  setAudioInDevice(e, t = this.options.mutedMicOnStart) {
2374
2380
  var i;
@@ -2379,7 +2385,7 @@ class kn {
2379
2385
  try {
2380
2386
  r = yield qe({ audio: { deviceId: { exact: e } } });
2381
2387
  } catch (l) {
2382
- const f = W(Oe(l), l);
2388
+ const f = H(Oe(l), l);
2383
2389
  return void L(T.MediaError, f, ((i = this.options) === null || i === void 0 ? void 0 : i.id) || this.id);
2384
2390
  }
2385
2391
  const c = r.getAudioTracks()[0];
@@ -2413,13 +2419,13 @@ class kn {
2413
2419
  }));
2414
2420
  }
2415
2421
  deaf() {
2416
- ht(this.options.remoteStream);
2422
+ pt(this.options.remoteStream);
2417
2423
  }
2418
2424
  undeaf() {
2419
- jt(this.options.remoteStream);
2425
+ Bt(this.options.remoteStream);
2420
2426
  }
2421
2427
  toggleDeaf() {
2422
- Bt(this.options.remoteStream);
2428
+ $t(this.options.remoteStream);
2423
2429
  }
2424
2430
  setBandwidthEncodingsMaxBps(e, t) {
2425
2431
  return O(this, void 0, void 0, (function* () {
@@ -2455,7 +2461,7 @@ class kn {
2455
2461
  case U.Active:
2456
2462
  performance.mark("call-active"), (t = this.peer) === null || t === void 0 || t.tryCollectTimings(), this._isRecovering && (this._isRecovering = !1, g.debug(`[${this.id}] Recovery complete, call is active`)), setTimeout((() => {
2457
2463
  const { remoteElement: s, speakerId: o } = this.options;
2458
- s && o && En(s, o);
2464
+ s && o && In(s, o);
2459
2465
  }), 0), this._callReportCollector && (!((i = this.peer) === null || i === void 0) && i.instance) && this.session.callReportId && this._callReportCollector.start(this.peer.instance);
2460
2466
  break;
2461
2467
  case U.Destroy:
@@ -2541,7 +2547,7 @@ class kn {
2541
2547
  } }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
2542
2548
  g.error("ConfChat subscription error:", s);
2543
2549
  }));
2544
- dt(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, o) => {
2550
+ ut(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, o) => {
2545
2551
  this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: s, type: o } });
2546
2552
  } } }));
2547
2553
  }));
@@ -2550,11 +2556,11 @@ class kn {
2550
2556
  return O(this, void 0, void 0, (function* () {
2551
2557
  const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
2552
2558
  const { eventData: o } = s;
2553
- o.contentType === "layout-info" ? (o.callID = this.id, Tn(this.session, o)) : g.error("Conference-Info unknown contentType", s);
2559
+ o.contentType === "layout-info" ? (o.callID = this.id, kn(this.session, o)) : g.error("Conference-Info unknown contentType", s);
2554
2560
  } }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
2555
2561
  g.error("ConfInfo subscription error:", s);
2556
2562
  }));
2557
- dt(i, e) && this._addChannel(e);
2563
+ ut(i, e) && this._addChannel(e);
2558
2564
  }));
2559
2565
  }
2560
2566
  _confControl(e, t = {}) {
@@ -2566,17 +2572,17 @@ class kn {
2566
2572
  }
2567
2573
  _handleChangeHoldStateError(e) {
2568
2574
  g.error(`Failed to ${e.action} on call ${this.id}`);
2569
- const t = W(ii, e);
2575
+ const t = H(si, e);
2570
2576
  return L(T.Error, { error: t, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid), !1;
2571
2577
  }
2572
2578
  _onRemoteSdp(e) {
2573
2579
  return O(this, void 0, void 0, (function* () {
2574
- const t = new RTCSessionDescription({ sdp: e, type: Q.Answer });
2580
+ const t = new RTCSessionDescription({ sdp: e, type: z.Answer });
2575
2581
  yield this.peer.instance.setRemoteDescription(t).then((() => {
2576
2582
  performance.mark("set-remote-description"), this.options.trickleIce && (this._isRemoteDescriptionSet = !0, this._flushPendingTrickleIceCandidates()), this.gotEarly && this.setState(U.Early), this.gotAnswer && this.setState(U.Active);
2577
2583
  })).catch(((i) => O(this, void 0, void 0, (function* () {
2578
2584
  g.error("Call setRemoteDescription Error: ", i);
2579
- const s = W(cn, i);
2585
+ const s = H(ln, i);
2580
2586
  L(T.Error, { error: s, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
2581
2587
  try {
2582
2588
  yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
@@ -2595,29 +2601,29 @@ class kn {
2595
2601
  const { sdp: s, type: o } = e;
2596
2602
  if (s.indexOf("candidate") === -1) return g.info(`No candidate - retry
2597
2603
  `), void this._requestAnotherLocalDescription();
2598
- if ((i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), !Ti.test(s)) {
2599
- const u = ue(wi);
2604
+ if ((i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), !Ri.test(s)) {
2605
+ const u = de(Ei);
2600
2606
  g.warn(`[${this.id}] Warning ${u.code}: ${u.message}`), L(T.Warning, { warning: u, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
2601
2607
  }
2602
2608
  performance.mark("ice-gathering-end");
2603
2609
  let r = null;
2604
2610
  const c = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${je}` };
2605
2611
  switch (o) {
2606
- case Q.Offer:
2607
- this.setState(U.Requesting), r = new Dt(c);
2612
+ case z.Offer:
2613
+ this.setState(U.Requesting), r = new Pt(c);
2608
2614
  break;
2609
- case Q.Answer:
2610
- this._isRecovering || this.setState(U.Answering), r = this.options.attach === !0 ? new Mt(c) : new Pt(c);
2615
+ case z.Answer:
2616
+ this._isRecovering || this.setState(U.Answering), r = this.options.attach === !0 ? new Ut(c) : new Mt(c);
2611
2617
  break;
2612
2618
  default:
2613
2619
  return g.error(`${this.id} - Unknown local SDP type:`, e), void this.hangup({}, !1);
2614
2620
  }
2615
2621
  performance.mark("send-sdp"), this._execute(r).then(((u) => {
2616
2622
  const { node_id: l = null } = u;
2617
- this._targetNodeId = l, o === Q.Offer ? this.setState(U.Trying) : this.setState(U.Active);
2623
+ this._targetNodeId = l, o === z.Offer ? this.setState(U.Trying) : this.setState(U.Active);
2618
2624
  })).catch(((u) => O(this, void 0, void 0, (function* () {
2619
2625
  g.error(`${this.id} - Sending ${o} error:`, u);
2620
- const l = W(Et, u);
2626
+ const l = H(It, u);
2621
2627
  L(T.Error, { error: l, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
2622
2628
  try {
2623
2629
  yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
@@ -2632,21 +2638,21 @@ class kn {
2632
2638
  let s = null;
2633
2639
  const o = { sessid: this.session.sessionid, sdp: t, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${je}` };
2634
2640
  switch (i) {
2635
- case Q.Offer:
2636
- this.setState(U.Requesting), s = new Dt(o);
2641
+ case z.Offer:
2642
+ this.setState(U.Requesting), s = new Pt(o);
2637
2643
  break;
2638
- case Q.Answer:
2639
- this._isRecovering || this.setState(U.Answering), s = this.options.attach === !0 ? new Mt(o) : new Pt(o);
2644
+ case z.Answer:
2645
+ this._isRecovering || this.setState(U.Answering), s = this.options.attach === !0 ? new Ut(o) : new Mt(o);
2640
2646
  break;
2641
2647
  default:
2642
2648
  return g.error(`${this.id} - Unknown local SDP type:`, e), void this.hangup({}, !1);
2643
2649
  }
2644
2650
  performance.mark("send-sdp"), this._execute(s).then(((r) => {
2645
2651
  const { node_id: c = null } = r;
2646
- this._targetNodeId = c, i === Q.Offer ? this.setState(U.Trying) : this.setState(U.Active);
2652
+ this._targetNodeId = c, i === z.Offer ? this.setState(U.Trying) : this.setState(U.Active);
2647
2653
  })).catch(((r) => O(this, void 0, void 0, (function* () {
2648
2654
  g.error(`${this.id} - Sending ${i} error:`, r);
2649
- const c = W(Et, r);
2655
+ const c = H(It, r);
2650
2656
  L(T.Error, { error: c, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
2651
2657
  try {
2652
2658
  yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
@@ -2669,7 +2675,7 @@ class kn {
2669
2675
  e.candidate && e.candidate.candidate ? (g.debug("RTCPeer Candidate:", e.candidate), (t = this.peer) === null || t === void 0 || t.incrementGatheredCandidates(), this._trackCandidateMarks(e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
2670
2676
  }
2671
2677
  _sendIceCandidate(e) {
2672
- const t = new Ji({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
2678
+ const t = new Xi({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
2673
2679
  this._execute(t);
2674
2680
  }
2675
2681
  _addIceCandidate(e) {
@@ -2685,7 +2691,7 @@ class kn {
2685
2691
  }));
2686
2692
  }
2687
2693
  _sendEndOfCandidates() {
2688
- const e = new Ki({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
2694
+ const e = new zi({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
2689
2695
  this._execute(e);
2690
2696
  }
2691
2697
  _trackCandidateMarks(e) {
@@ -2713,7 +2719,7 @@ class kn {
2713
2719
  }, e.onicecandidateerror = (t) => {
2714
2720
  var i;
2715
2721
  if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2716
- const s = Vt(t, e);
2722
+ const s = qt(t, e);
2717
2723
  this.peer.statsReporter.reportIceCandidateError(s);
2718
2724
  }
2719
2725
  }, e.addEventListener("addstream", ((t) => {
@@ -2732,7 +2738,7 @@ class kn {
2732
2738
  }, e.onicecandidateerror = (t) => {
2733
2739
  var i;
2734
2740
  if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2735
- const s = Vt(t, e);
2741
+ const s = qt(t, e);
2736
2742
  this.peer.statsReporter.reportIceCandidateError(s);
2737
2743
  }
2738
2744
  }, e.addEventListener("addstream", ((t) => {
@@ -2821,7 +2827,7 @@ class kn {
2821
2827
  this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), g.debug("Stats stopped");
2822
2828
  }
2823
2829
  }
2824
- kn.setStateTelnyx = (n) => {
2830
+ Rn.setStateTelnyx = (n) => {
2825
2831
  if (n) {
2826
2832
  switch (n._state) {
2827
2833
  case U.Recovering:
@@ -2851,9 +2857,9 @@ kn.setStateTelnyx = (n) => {
2851
2857
  return n;
2852
2858
  }
2853
2859
  };
2854
- class ge extends kn {
2860
+ class ge extends Rn {
2855
2861
  constructor() {
2856
- super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new ss(e, t));
2862
+ super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new rs(e, t));
2857
2863
  }
2858
2864
  hangup(e = {}, t = !0) {
2859
2865
  const i = Object.create(null, { hangup: { get: () => super.hangup } });
@@ -2883,7 +2889,7 @@ class ge extends kn {
2883
2889
  return O(this, void 0, void 0, (function* () {
2884
2890
  this.options.speakerId = e;
2885
2891
  const { remoteElement: t, speakerId: i } = this.options;
2886
- return !(!t || !i) && En(t, i);
2892
+ return !(!t || !i) && In(t, i);
2887
2893
  }));
2888
2894
  }
2889
2895
  _finalize() {
@@ -2906,7 +2912,7 @@ ${r.type}
2906
2912
  }))), 2e3);
2907
2913
  }
2908
2914
  }
2909
- class fs extends Le {
2915
+ class vs extends Le {
2910
2916
  constructor(e) {
2911
2917
  super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._previousAudioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this._onlineHandler = null, this._offlineHandler = null, this._wasOffline = !1, this._videoConstraints = e.video || !1, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile, this._setupNetworkListeners();
2912
2918
  }
@@ -2968,7 +2974,7 @@ class fs extends Le {
2968
2974
  }
2969
2975
  speedTest(e) {
2970
2976
  return new Promise(((t, i) => {
2971
- if (Sn(T.SpeedTest, ((r) => {
2977
+ if (bn(T.SpeedTest, ((r) => {
2972
2978
  const { upDur: c, downDur: u } = r, l = u ? 8 * e / (u / 1e3) / 1024 : 0;
2973
2979
  t({ upDur: c, downDur: u, upKps: (c ? 8 * e / (c / 1e3) / 1024 : 0).toFixed(0), downKps: l.toFixed(0) });
2974
2980
  }), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
@@ -2982,7 +2988,7 @@ class fs extends Le {
2982
2988
  }
2983
2989
  getDevices() {
2984
2990
  return Te().catch(((e) => {
2985
- const t = W(Oe(e), e);
2991
+ const t = H(Oe(e), e);
2986
2992
  return L(T.MediaError, t, this.uuid), [];
2987
2993
  }));
2988
2994
  }
@@ -2991,7 +2997,7 @@ class fs extends Le {
2991
2997
  }
2992
2998
  getAudioInDevices() {
2993
2999
  return Te(le.AudioIn).catch(((e) => {
2994
- const t = W(Oe(e), e);
3000
+ const t = H(Oe(e), e);
2995
3001
  return L(T.MediaError, t, this.uuid), [];
2996
3002
  }));
2997
3003
  }
@@ -3006,8 +3012,8 @@ class fs extends Le {
3006
3012
  try {
3007
3013
  return yield ((t) => O(void 0, void 0, void 0, (function* () {
3008
3014
  const i = [], s = yield Ye({ video: { deviceId: { exact: t } } }), o = s.getVideoTracks()[0];
3009
- for (let r = 0; r < Ft.length; r++) {
3010
- const [c, u] = Ft[r];
3015
+ for (let r = 0; r < jt.length; r++) {
3016
+ const [c, u] = jt[r];
3011
3017
  (yield o.applyConstraints({ width: { exact: c }, height: { exact: u } }).then((() => !0)).catch((() => !1))) && i.push({ resolution: `${c}x${u}`, width: c, height: u });
3012
3018
  }
3013
3019
  return Ne(s), i;
@@ -3023,8 +3029,8 @@ class fs extends Le {
3023
3029
  setAudioSettings(e) {
3024
3030
  return O(this, void 0, void 0, (function* () {
3025
3031
  if (!e) throw new Error("You need to provide the settings object");
3026
- const { micId: t, micLabel: i } = e, s = He(e, ["micId", "micLabel"]);
3027
- return ts(s), this._audioConstraints = yield ((o, r, c, u) => O(void 0, void 0, void 0, (function* () {
3032
+ const { micId: t, micLabel: i } = e, s = We(e, ["micId", "micLabel"]);
3033
+ return is(s), this._audioConstraints = yield ((o, r, c, u) => O(void 0, void 0, void 0, (function* () {
3028
3034
  const { deviceId: l } = u;
3029
3035
  if (l === void 0 && (o || r)) {
3030
3036
  const f = yield Je(o, r, c).catch(((h) => null));
@@ -3044,7 +3050,7 @@ class fs extends Le {
3044
3050
  if (e && Array.isArray(e)) this._iceServers = e;
3045
3051
  else {
3046
3052
  const t = this.options.env === "development";
3047
- this._iceServers = t ? Ai : Ri;
3053
+ this._iceServers = t ? Li : Oi;
3048
3054
  }
3049
3055
  }
3050
3056
  get iceServers() {
@@ -3070,24 +3076,24 @@ class fs extends Le {
3070
3076
  }
3071
3077
  vertoBroadcast({ nodeId: e, channel: t = "", data: i }) {
3072
3078
  if (!t) throw new Error(`Invalid channel for broadcast: ${t}`);
3073
- const s = new zi({ sessid: this.sessionid, eventChannel: t, data: i });
3079
+ const s = new Qi({ sessid: this.sessionid, eventChannel: t, data: i });
3074
3080
  e && (s.targetNodeId = e), this.execute(s).catch(((o) => o));
3075
3081
  }
3076
3082
  vertoSubscribe({ nodeId: e, channels: t = [], handler: i }) {
3077
3083
  return O(this, void 0, void 0, (function* () {
3078
3084
  if (!(t = t.filter(((u) => u && !this._existsSubscription(this.relayProtocol, u)))).length) return {};
3079
- const s = new Qi({ sessid: this.sessionid, eventChannel: t });
3085
+ const s = new Zi({ sessid: this.sessionid, eventChannel: t });
3080
3086
  e && (s.targetNodeId = e);
3081
- const o = yield this.execute(s), { unauthorized: r = [], subscribed: c = [] } = ut(o);
3087
+ const o = yield this.execute(s), { unauthorized: r = [], subscribed: c = [] } = ht(o);
3082
3088
  return r.length && r.forEach(((u) => this._removeSubscription(this.relayProtocol, u))), c.forEach(((u) => this._addSubscription(this.relayProtocol, i, u))), o;
3083
3089
  }));
3084
3090
  }
3085
3091
  vertoUnsubscribe({ nodeId: e, channels: t = [] }) {
3086
3092
  return O(this, void 0, void 0, (function* () {
3087
3093
  if (!(t = t.filter(((c) => c && this._existsSubscription(this.relayProtocol, c)))).length) return {};
3088
- const i = new Xi({ sessid: this.sessionid, eventChannel: t });
3094
+ const i = new es({ sessid: this.sessionid, eventChannel: t });
3089
3095
  e && (i.targetNodeId = e);
3090
- const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } = ut(s);
3096
+ const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } = ht(s);
3091
3097
  return o.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), r.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), s;
3092
3098
  }));
3093
3099
  }
@@ -3096,7 +3102,7 @@ class fs extends Le {
3096
3102
  this._wasOffline && (g.debug(`Network connectivity restored for session ${this.sessionid}. Reconnecting...`), this._wasOffline = !1, this._autoReconnect = !0, this.socketDisconnect());
3097
3103
  }, this._offlineHandler = () => {
3098
3104
  this._wasOffline = !0, g.debug(`Network connectivity lost for session ${this.sessionid}`);
3099
- const e = W(pi);
3105
+ const e = H(fi);
3100
3106
  L(T.Error, { error: e, sessionId: this.sessionid }, this.uuid);
3101
3107
  }, window.addEventListener("online", this._onlineHandler), window.addEventListener("offline", this._offlineHandler));
3102
3108
  }
@@ -3107,21 +3113,21 @@ class fs extends Le {
3107
3113
  return ge.setStateTelnyx(e);
3108
3114
  }
3109
3115
  }
3110
- class Jt {
3116
+ class Kt {
3111
3117
  constructor(e, t) {
3112
3118
  this.code = t, this.message = e;
3113
3119
  }
3114
3120
  }
3115
- class gs {
3121
+ class ms {
3116
3122
  constructor(e) {
3117
3123
  this.session = e, this.retriedConnect = 0, this.retriedRegister = 0;
3118
3124
  }
3119
3125
  _ack(e, t) {
3120
- const i = new qi(e, t);
3126
+ const i = new Ji(e, t);
3121
3127
  this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
3122
3128
  }
3123
3129
  reconnectDelay() {
3124
- return 1e3 * mn(2, 6);
3130
+ return 1e3 * _n(2, 6);
3125
3131
  }
3126
3132
  handleMessage(e) {
3127
3133
  var t, i, s, o, r, c, u, l, f;
@@ -3129,7 +3135,7 @@ class gs {
3129
3135
  h.setPingReceived();
3130
3136
  const { id: S, method: y, params: v = {}, voice_sdk_id: E } = e, m = v?.callID, w = v?.eventChannel, N = v?.eventType, A = h.calls[m], P = (t = A?.peer) === null || t === void 0 ? void 0 : t.isConnectionHealthy();
3131
3137
  if (Array.isArray(v?.reattached_sessions) && v.reattached_sessions.length === 0 && Object.keys(h.calls).length > 0) {
3132
- const R = ue(Ii);
3138
+ const R = de(ki);
3133
3139
  L(T.Warning, { warning: R, sessionId: h.sessionid }, h.uuid);
3134
3140
  }
3135
3141
  if (N === "channelPvtData") return this._handlePvtEvent(v.pvtData);
@@ -3139,7 +3145,7 @@ class gs {
3139
3145
  m && (I.id = m), v.telnyx_call_control_id && (I.telnyxCallControlId = v.telnyx_call_control_id), v.telnyx_session_id && (I.telnyxSessionId = v.telnyx_session_id), v.telnyx_leg_id && (I.telnyxLegId = v.telnyx_leg_id), v.client_state && (I.clientState = v.client_state), v.dialogParams && v.dialogParams.custom_headers && v.dialogParams.custom_headers.length && (I.customHeaders = v.dialogParams.custom_headers), R && (I.recoveredCallId = R), performance.mark("new-call-start");
3140
3146
  const x = new ge(h, I);
3141
3147
  return x.nodeId = this.nodeId, x;
3142
- }, q = new bn(E), F = new Cn(E);
3148
+ }, q = new Cn(E), F = new wn(E);
3143
3149
  switch (y) {
3144
3150
  case $.Answer:
3145
3151
  case $.Display:
@@ -3181,7 +3187,7 @@ class gs {
3181
3187
  this.session.execute(q);
3182
3188
  break;
3183
3189
  default: {
3184
- const d = yt(e);
3190
+ const d = St(e);
3185
3191
  if (d) {
3186
3192
  switch (d) {
3187
3193
  case ne.REGISTER:
@@ -3200,7 +3206,7 @@ class gs {
3200
3206
  case ne.NOREG:
3201
3207
  if (this.retriedRegister += 1, this.retriedRegister === 5) {
3202
3208
  this.retriedRegister = 0;
3203
- const p = new Jt("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), _ = W(dn, p);
3209
+ const p = new Kt("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), _ = H(un, p);
3204
3210
  L(T.Error, { error: _, sessionId: h.sessionid }, h.uuid);
3205
3211
  break;
3206
3212
  }
@@ -3211,16 +3217,16 @@ class gs {
3211
3217
  case ne.FAILED:
3212
3218
  case ne.FAIL_WAIT:
3213
3219
  if (h.connection.previousGatewayState !== ne.FAILED && h.connection.previousGatewayState !== ne.FAIL_WAIT) {
3214
- const p = W(di, new Error(`Gateway state: ${d}`));
3220
+ const p = H(ui, new Error(`Gateway state: ${d}`));
3215
3221
  if (L(T.Error, { error: p, sessionId: h.sessionid }, h.uuid), !this.session.hasAutoReconnect()) {
3216
3222
  this.retriedConnect = 0;
3217
- const _ = new Jt("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), b = W(li, _);
3223
+ const _ = new Kt("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), b = H(di, _);
3218
3224
  L(T.Error, { error: b, sessionId: h.sessionid }, h.uuid);
3219
3225
  break;
3220
3226
  }
3221
3227
  if (this.retriedConnect += 1, this.retriedConnect === 5) {
3222
3228
  this.retriedConnect = 0;
3223
- const _ = W(45003, new Error("Connection Retry Failed"));
3229
+ const _ = H(45003, new Error("Connection Retry Failed"));
3224
3230
  L(T.Error, { error: _, sessionId: h.sessionid }, h.uuid);
3225
3231
  break;
3226
3232
  }
@@ -3273,10 +3279,10 @@ class gs {
3273
3279
  }
3274
3280
  } }, E = yield t.vertoSubscribe(v).catch(((m) => {
3275
3281
  g.error("liveArray subscription error:", m);
3276
- const w = W(ri, m);
3282
+ const w = H(ai, m);
3277
3283
  L(T.Error, { error: w, sessionId: t.sessionid }, t.uuid);
3278
3284
  }));
3279
- dt(E, o) && y();
3285
+ ut(E, o) && y();
3280
3286
  break;
3281
3287
  }
3282
3288
  case "conference-liveArray-part": {
@@ -3303,7 +3309,7 @@ class gs {
3303
3309
  switch (e.contentType) {
3304
3310
  case "layout-info":
3305
3311
  case "layer-info":
3306
- Tn(this.session, e);
3312
+ kn(this.session, e);
3307
3313
  break;
3308
3314
  case "logo-info": {
3309
3315
  const t = { type: re.conferenceUpdate, action: oe.LogoInfo, logo: e.logoURL };
@@ -3313,7 +3319,7 @@ class gs {
3313
3319
  }
3314
3320
  }
3315
3321
  }
3316
- class vs extends fs {
3322
+ class _s extends vs {
3317
3323
  constructor(e) {
3318
3324
  super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
3319
3325
  this._idle = !1;
@@ -3323,7 +3329,7 @@ class vs extends fs {
3323
3329
  } });
3324
3330
  })), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
3325
3331
  this._idle = !1, yield this.login();
3326
- })), this._vertoHandler = new gs(this), window.addEventListener("beforeunload", ((t) => {
3332
+ })), this._vertoHandler = new ms(this), window.addEventListener("beforeunload", ((t) => {
3327
3333
  this.calls && Object.keys(this.calls).forEach(((i) => {
3328
3334
  this.calls[i] && (g.info(`Hanging up call due to window unload: ${i}`), this.calls[i].hangup({}, !0));
3329
3335
  }));
@@ -3334,7 +3340,7 @@ class vs extends fs {
3334
3340
  }
3335
3341
  newCall(e) {
3336
3342
  if (!this.validateCallOptions(e))
3337
- throw W(si, void 0, "Error: destinationNumber is required");
3343
+ throw H(oi, void 0, "Error: destinationNumber is required");
3338
3344
  const t = new ge(this, e);
3339
3345
  return performance.mark("new-call-start"), t.invite(), t;
3340
3346
  }
@@ -3359,26 +3365,26 @@ class vs extends fs {
3359
3365
  this._vertoHandler.handleMessage(e);
3360
3366
  }
3361
3367
  }
3362
- class ms extends vs {
3368
+ class ys extends _s {
3363
3369
  constructor(e) {
3364
- super(e), g.info(`SDK version: ${wn}`);
3370
+ super(e), g.info(`SDK version: ${En}`);
3365
3371
  }
3366
3372
  newCall(e) {
3367
3373
  return super.newCall(e);
3368
3374
  }
3369
3375
  static webRTCInfo() {
3370
- return is();
3376
+ return os();
3371
3377
  }
3372
3378
  static webRTCSupportedBrowserList() {
3373
3379
  return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: Y.not_supported }, { browserName: "Firefox", supported: Y.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: Y.full }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", features: ["video", "audio"], supported: Y.full }, { browserName: "Edge", features: ["audio"], supported: Y.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", features: ["audio"], supported: Y.partial }] }];
3374
3380
  }
3375
3381
  }
3376
- function Rn(n) {
3382
+ function An(n) {
3377
3383
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
3378
3384
  }
3379
- var at = { exports: {} }, Kt;
3380
- function _s() {
3381
- return Kt || (Kt = 1, (function(n) {
3385
+ var ct = { exports: {} }, Xt;
3386
+ function Ss() {
3387
+ return Xt || (Xt = 1, (function(n) {
3382
3388
  var e = Object.prototype.hasOwnProperty, t = "~";
3383
3389
  function i() {
3384
3390
  }
@@ -3481,16 +3487,16 @@ function _s() {
3481
3487
  var f;
3482
3488
  return l ? (f = t ? t + l : l, this._events[f] && r(this, f)) : (this._events = new i(), this._eventsCount = 0), this;
3483
3489
  }, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = t, c.EventEmitter = c, n.exports = c;
3484
- })(at)), at.exports;
3490
+ })(ct)), ct.exports;
3485
3491
  }
3486
- var ys = _s();
3487
- const Ct = /* @__PURE__ */ Rn(ys), Ke = new Ct();
3488
- var $e = { exports: {} }, Ss = $e.exports, zt;
3489
- function bs() {
3492
+ var bs = Ss();
3493
+ const wt = /* @__PURE__ */ An(bs), Ke = new wt();
3494
+ var $e = { exports: {} }, Cs = $e.exports, zt;
3495
+ function ws() {
3490
3496
  return zt || (zt = 1, (function(n) {
3491
3497
  (function(e, t) {
3492
3498
  n.exports ? n.exports = t() : e.log = t();
3493
- })(Ss, function() {
3499
+ })(Cs, function() {
3494
3500
  var e = function() {
3495
3501
  }, t = "undefined", i = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
3496
3502
  "trace",
@@ -3633,24 +3639,24 @@ function bs() {
3633
3639
  });
3634
3640
  })($e)), $e.exports;
3635
3641
  }
3636
- var Cs = bs();
3637
- const ws = /* @__PURE__ */ Rn(Cs), Es = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), z = ws.getLogger("telnyx-ai-agent"), Is = z.methodFactory;
3638
- z.methodFactory = (n, e, t) => {
3639
- const i = Is(n, e, t);
3642
+ var Es = ws();
3643
+ const Is = /* @__PURE__ */ An(Es), Ts = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), X = Is.getLogger("telnyx-ai-agent"), ks = X.methodFactory;
3644
+ X.methodFactory = (n, e, t) => {
3645
+ const i = ks(n, e, t);
3640
3646
  return function(...s) {
3641
- i(Es(), "-", ...s);
3647
+ i(Ts(), "-", ...s);
3642
3648
  };
3643
3649
  };
3644
- z.setLevel("info");
3645
- function Ts(n, e) {
3650
+ X.setLevel("info");
3651
+ function Rs(n, e) {
3646
3652
  let t = 0;
3647
3653
  return (...i) => {
3648
3654
  const s = Date.now();
3649
3655
  s - t >= e && (t = s, n(...i));
3650
3656
  };
3651
3657
  }
3652
- const ks = 10, Rs = 500, As = 100, Qt = 20;
3653
- class Os {
3658
+ const As = 10, Os = 500, Ls = 100, Qt = 20;
3659
+ class Ns {
3654
3660
  remoteIntervalId = null;
3655
3661
  localIntervalId = null;
3656
3662
  remoteStream = null;
@@ -3677,10 +3683,10 @@ class Os {
3677
3683
  minSpeechDurationMs;
3678
3684
  maxLatencyMs;
3679
3685
  constructor(e) {
3680
- this.volumeThreshold = e?.volumeThreshold ?? ks, this.silenceDurationMs = e?.silenceDurationMs ?? Rs, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? As, this.maxLatencyMs = e?.maxLatencyMs;
3686
+ this.volumeThreshold = e?.volumeThreshold ?? As, this.silenceDurationMs = e?.silenceDurationMs ?? Os, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ls, this.maxLatencyMs = e?.maxLatencyMs;
3681
3687
  }
3682
- updateAgentState = Ts((e) => {
3683
- z.debug("AudioStreamMonitor updateAgentState", e), z.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Ke.emit("conversation.agent.state", e));
3688
+ updateAgentState = Rs((e) => {
3689
+ X.debug("AudioStreamMonitor updateAgentState", e), X.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Ke.emit("conversation.agent.state", e));
3684
3690
  }, 100);
3685
3691
  /**
3686
3692
  * Set the remote audio stream (agent's voice) to monitor for speech detection
@@ -3720,11 +3726,11 @@ class Os {
3720
3726
  */
3721
3727
  startRemoteMonitor() {
3722
3728
  if (!this.remoteStream) {
3723
- z.debug("Remote monitor: no stream, skipping");
3729
+ X.debug("Remote monitor: no stream, skipping");
3724
3730
  return;
3725
3731
  }
3726
- this.monitorStartTime = performance.now(), this.remoteAudioContext = new AudioContext(), z.debug("Remote AudioContext state:", this.remoteAudioContext.state), this.remoteAudioContext.state === "suspended" && (z.debug("Resuming suspended AudioContext..."), this.remoteAudioContext.resume().then(() => {
3727
- z.debug("AudioContext resumed, state:", this.remoteAudioContext?.state);
3732
+ this.monitorStartTime = performance.now(), this.remoteAudioContext = new AudioContext(), X.debug("Remote AudioContext state:", this.remoteAudioContext.state), this.remoteAudioContext.state === "suspended" && (X.debug("Resuming suspended AudioContext..."), this.remoteAudioContext.resume().then(() => {
3733
+ X.debug("AudioContext resumed, state:", this.remoteAudioContext?.state);
3728
3734
  })), this.remoteSource = this.remoteAudioContext.createMediaStreamSource(
3729
3735
  this.remoteStream
3730
3736
  ), this.remoteAnalyser = this.remoteAudioContext.createAnalyser(), this.remoteSource.connect(this.remoteAnalyser);
@@ -3735,7 +3741,7 @@ class Os {
3735
3741
  const s = () => {
3736
3742
  this.remoteAnalyser?.getByteFrequencyData(t);
3737
3743
  const o = t.reduce((c, u) => c + u, 0) / t.length, r = o >= this.volumeThreshold;
3738
- if (Math.random() < 0.01 && z.debug("Remote audio volume:", o, "threshold:", this.volumeThreshold, "above:", r), r)
3744
+ if (Math.random() < 0.01 && X.debug("Remote audio volume:", o, "threshold:", this.volumeThreshold, "above:", r), r)
3739
3745
  if (i)
3740
3746
  this.updateAgentState({ state: "speaking" });
3741
3747
  else if (this.isFirstAgentSpeech && this.monitorStartTime !== null) {
@@ -3758,16 +3764,16 @@ class Os {
3758
3764
  */
3759
3765
  startLocalMonitor() {
3760
3766
  if (!this.localStream) {
3761
- z.debug("Local monitor: no stream, skipping");
3767
+ X.debug("Local monitor: no stream, skipping");
3762
3768
  return;
3763
3769
  }
3764
- this.localAudioContext = new AudioContext(), z.debug("Local AudioContext state:", this.localAudioContext.state), this.localAudioContext.state === "suspended" && (z.debug("Resuming suspended local AudioContext..."), this.localAudioContext.resume()), this.localSource = this.localAudioContext.createMediaStreamSource(
3770
+ this.localAudioContext = new AudioContext(), X.debug("Local AudioContext state:", this.localAudioContext.state), this.localAudioContext.state === "suspended" && (X.debug("Resuming suspended local AudioContext..."), this.localAudioContext.resume()), this.localSource = this.localAudioContext.createMediaStreamSource(
3765
3771
  this.localStream
3766
3772
  ), this.localAnalyser = this.localAudioContext.createAnalyser(), this.localSource.connect(this.localAnalyser), this.localAnalyser.fftSize = 512;
3767
3773
  const e = new Uint8Array(this.localAnalyser.frequencyBinCount), t = () => {
3768
3774
  this.localAnalyser?.getByteFrequencyData(e);
3769
3775
  const i = e.reduce((o, r) => o + r, 0) / e.length;
3770
- if (Math.random() < 0.02 && z.debug("Local audio volume:", i), i >= this.volumeThreshold)
3776
+ if (Math.random() < 0.02 && X.debug("Local audio volume:", i), i >= this.volumeThreshold)
3771
3777
  this.userIsSpeaking || (this.userIsSpeaking = !0, this.userSpeechStartTime = performance.now(), this.userSilenceStartTime = null), this.lastUserAudioTime = performance.now();
3772
3778
  else if (this.userIsSpeaking && this.lastUserAudioTime !== null && (this.lastUserAudioTime - (this.userSpeechStartTime || this.lastUserAudioTime) >= this.minSpeechDurationMs && this.userSilenceStartTime === null && (this.userSilenceStartTime = this.lastUserAudioTime), performance.now() - this.lastUserAudioTime > this.silenceDurationMs)) {
3773
3779
  this.userIsSpeaking = !1, this.userSpeechStartTime = null, this.thinkingStartTime = performance.now();
@@ -3781,40 +3787,40 @@ class Os {
3781
3787
  this.stopAudioStreamMonitor();
3782
3788
  }
3783
3789
  }
3784
- function Ls(n) {
3790
+ function xs(n) {
3785
3791
  if (!n || typeof n != "object")
3786
3792
  return !1;
3787
3793
  const e = n;
3788
3794
  return e.method === "ai_conversation" && typeof e.params == "object";
3789
3795
  }
3790
- function Ns(n) {
3796
+ function Ds(n) {
3791
3797
  if (!n || typeof n != "object")
3792
3798
  return !1;
3793
3799
  const e = n;
3794
3800
  return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
3795
3801
  }
3796
- function xs(n) {
3802
+ function Ps(n) {
3797
3803
  if (!n || typeof n != "object")
3798
3804
  return !1;
3799
3805
  const e = n;
3800
3806
  return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
3801
3807
  }
3802
- function Ds(n) {
3808
+ function Ms(n) {
3803
3809
  if (!n || typeof n != "object")
3804
3810
  return !1;
3805
3811
  const e = n;
3806
3812
  return e.params?.type !== "conversation.item.deleted" ? !1 : !!e.params.item_id;
3807
3813
  }
3808
- function Ps(n) {
3809
- return Ns(n) ? {
3814
+ function Us(n) {
3815
+ return Ds(n) ? {
3810
3816
  id: `${n.params.item_id}-${Date.now()}`,
3811
3817
  role: "assistant",
3812
3818
  content: n.params.delta,
3813
3819
  timestamp: /* @__PURE__ */ new Date()
3814
3820
  } : null;
3815
3821
  }
3816
- function Ms(n) {
3817
- if (!xs(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
3822
+ function Fs(n) {
3823
+ if (!Ps(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
3818
3824
  return null;
3819
3825
  let e = "", t = [];
3820
3826
  return Array.isArray(n.params.item.content) ? (e = n.params.item.content.reduce((i, s) => (s.type === "text" && (i += s.text), i), ""), t = n.params.item.content.reduce((i, s) => (s.type === "image_url" && s.image_url.url && i.push({ type: "image", url: s.image_url.url }), i), [])) : e = n.params.item.content, {
@@ -3825,29 +3831,29 @@ function Ms(n) {
3825
3831
  attachments: t
3826
3832
  };
3827
3833
  }
3828
- class Us extends Ct {
3834
+ class js extends wt {
3829
3835
  telnyxRTC;
3830
3836
  transcript = [];
3831
3837
  constructor(e) {
3832
3838
  super(), this.telnyxRTC = e, this.telnyxRTC.on(T.SocketMessage, this.onSocketMessage);
3833
3839
  }
3834
3840
  onSocketMessage = (e) => {
3835
- if (Ls(e))
3841
+ if (xs(e))
3836
3842
  switch (e.params.type) {
3837
3843
  case "response.text.delta": {
3838
- const t = Ps(e);
3844
+ const t = Us(e);
3839
3845
  t && (this.transcript.push(t), this.emit("transcript.item", t), Ke.emit("conversation.agent.state", { state: "listening" }));
3840
3846
  return;
3841
3847
  }
3842
3848
  case "conversation.item.deleted": {
3843
- if (Ds(e)) {
3849
+ if (Ms(e)) {
3844
3850
  const t = e.params.item_id, i = this.transcript.findIndex((s) => s.id === t);
3845
3851
  i !== -1 && this.transcript.splice(i, 1);
3846
3852
  }
3847
3853
  return;
3848
3854
  }
3849
3855
  case "conversation.item.created": {
3850
- const t = Ms(e);
3856
+ const t = Fs(e);
3851
3857
  if (t) {
3852
3858
  const i = this.transcript.findIndex(
3853
3859
  (s) => s.id === t.id
@@ -3859,7 +3865,7 @@ class Us extends Ct {
3859
3865
  }
3860
3866
  };
3861
3867
  }
3862
- class Xt extends Ct {
3868
+ class Zt extends wt {
3863
3869
  telnyxRTC;
3864
3870
  transcription;
3865
3871
  agentId;
@@ -3894,7 +3900,7 @@ class Xt extends Ct {
3894
3900
  */
3895
3901
  callReportId = null;
3896
3902
  constructor(e) {
3897
- super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.conversationId = e.conversationId, this.debug = e.debug || !1, this.chatMode = e.chatMode || !1, this.activeCall = null, z.setLevel(this.debug ? "debug" : "info");
3903
+ super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.conversationId = e.conversationId, this.debug = e.debug || !1, this.chatMode = e.chatMode || !1, this.activeCall = null, X.setLevel(this.debug ? "debug" : "info");
3898
3904
  const t = {
3899
3905
  target_id: e.agentId,
3900
3906
  target_type: "ai_assistant",
@@ -3902,16 +3908,17 @@ class Xt extends Ct {
3902
3908
  };
3903
3909
  e.conversationId && (t.target_params = {
3904
3910
  conversation_id: e.conversationId
3905
- }), this.telnyxRTC = new ms({
3911
+ }), this.telnyxRTC = new ys({
3906
3912
  env: e.environment || "production",
3907
3913
  anonymous_login: t,
3908
3914
  debug: e.debug || !1,
3909
3915
  trickleIce: e.trickleIce,
3910
- region: e.region
3911
- }), this.telnyxRTC.on(T.Ready, this.onClientReady), this.telnyxRTC.on(T.Error, this.onClientOrSocketError), this.telnyxRTC.on(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(T.Notification, this.onNotification), this.transcription = new Us(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ke.addListener(
3916
+ region: e.region,
3917
+ skipLastVoiceSdkId: e.skipLastVoiceSdkId ?? !0
3918
+ }), this.telnyxRTC.on(T.Ready, this.onClientReady), this.telnyxRTC.on(T.Error, this.onClientOrSocketError), this.telnyxRTC.on(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(T.Notification, this.onNotification), this.transcription = new js(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ke.addListener(
3912
3919
  "conversation.agent.state",
3913
3920
  this.onAgentStateChange
3914
- ), this.audioStreamMonitor = new Os(e.vad);
3921
+ ), this.audioStreamMonitor = new Ns(e.vad);
3915
3922
  }
3916
3923
  /**
3917
3924
  * Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
@@ -3929,7 +3936,7 @@ class Xt extends Ct {
3929
3936
  * retrying after a "Login Incorrect" error caused by RMQ propagation lag.
3930
3937
  */
3931
3938
  clearReconnectToken() {
3932
- this.telnyxRTC.clearReconnectToken?.();
3939
+ this.telnyxRTC.clearReconnectToken();
3933
3940
  }
3934
3941
  /**
3935
3942
  * Disconnects from the Telnyx WebRTC service and cleans up all event listeners.
@@ -3954,7 +3961,7 @@ class Xt extends Ct {
3954
3961
  */
3955
3962
  sendConversationMessage(e, t = []) {
3956
3963
  if (!this.activeCall) {
3957
- z.error("No active call to send message.");
3964
+ X.error("No active call to send message.");
3958
3965
  return;
3959
3966
  }
3960
3967
  this.activeCall.sendConversationMessage(e, t);
@@ -3993,7 +4000,7 @@ class Xt extends Ct {
3993
4000
  */
3994
4001
  async startConversation(e) {
3995
4002
  if (!this.telnyxRTC) {
3996
- z.error("Client is not initialized.");
4003
+ X.error("Client is not initialized.");
3997
4004
  return;
3998
4005
  }
3999
4006
  const i = RTCRtpReceiver.getCapabilities("audio")?.codecs?.find(
@@ -4039,14 +4046,13 @@ class Xt extends Ct {
4039
4046
  this.audioStreamMonitor.setRemoteStream(e);
4040
4047
  }
4041
4048
  onClientReady = () => {
4042
- const e = this.telnyxRTC;
4043
- this.dc = e.dc ?? null, this.region = e.region ?? null, this.callReportId = e.callReportId ?? null;
4044
- const t = {
4049
+ this.dc = this.telnyxRTC.dc ?? null, this.region = this.telnyxRTC.region ?? null, this.callReportId = this.telnyxRTC.callReportId ?? null;
4050
+ const e = {
4045
4051
  dc: this.dc,
4046
4052
  region: this.region,
4047
4053
  callReportId: this.callReportId
4048
4054
  };
4049
- this.emit("agent.connected", t);
4055
+ this.emit("agent.connected", e);
4050
4056
  };
4051
4057
  onClientOrSocketError = (e) => {
4052
4058
  this.emit("agent.error", e.error);
@@ -4062,10 +4068,10 @@ class Xt extends Ct {
4062
4068
  };
4063
4069
  }
4064
4070
  var Be = { exports: {} }, Ce = {};
4065
- var Zt;
4066
- function Fs() {
4067
- if (Zt) return Ce;
4068
- Zt = 1;
4071
+ var en;
4072
+ function Bs() {
4073
+ if (en) return Ce;
4074
+ en = 1;
4069
4075
  var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
4070
4076
  function t(i, s, o) {
4071
4077
  var r = null;
@@ -4085,9 +4091,9 @@ function Fs() {
4085
4091
  return Ce.Fragment = e, Ce.jsx = t, Ce.jsxs = t, Ce;
4086
4092
  }
4087
4093
  var we = {};
4088
- var en;
4089
- function js() {
4090
- return en || (en = 1, process.env.NODE_ENV !== "production" && (function() {
4094
+ var tn;
4095
+ function $s() {
4096
+ return tn || (tn = 1, process.env.NODE_ENV !== "production" && (function() {
4091
4097
  function n(C) {
4092
4098
  if (C == null) return null;
4093
4099
  if (typeof C == "function")
@@ -4143,11 +4149,11 @@ function js() {
4143
4149
  }
4144
4150
  if (D) {
4145
4151
  D = console;
4146
- var j = D.error, H = typeof Symbol == "function" && Symbol.toStringTag && C[Symbol.toStringTag] || C.constructor.name || "Object";
4152
+ var j = D.error, W = typeof Symbol == "function" && Symbol.toStringTag && C[Symbol.toStringTag] || C.constructor.name || "Object";
4147
4153
  return j.call(
4148
4154
  D,
4149
4155
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
4150
- H
4156
+ W
4151
4157
  ), e(C);
4152
4158
  }
4153
4159
  }
@@ -4194,14 +4200,14 @@ function js() {
4194
4200
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
4195
4201
  )), C = this.props.ref, C !== void 0 ? C : null;
4196
4202
  }
4197
- function l(C, D, j, H, K, X) {
4203
+ function l(C, D, j, W, K, Q) {
4198
4204
  var V = j.ref;
4199
4205
  return C = {
4200
4206
  $$typeof: v,
4201
4207
  type: C,
4202
4208
  key: D,
4203
4209
  props: j,
4204
- _owner: H
4210
+ _owner: W
4205
4211
  }, (V !== void 0 ? V : null) !== null ? Object.defineProperty(C, "ref", {
4206
4212
  enumerable: !1,
4207
4213
  get: u
@@ -4224,16 +4230,16 @@ function js() {
4224
4230
  configurable: !1,
4225
4231
  enumerable: !1,
4226
4232
  writable: !0,
4227
- value: X
4233
+ value: Q
4228
4234
  }), Object.freeze && (Object.freeze(C.props), Object.freeze(C)), C;
4229
4235
  }
4230
- function f(C, D, j, H, K, X) {
4236
+ function f(C, D, j, W, K, Q) {
4231
4237
  var V = D.children;
4232
4238
  if (V !== void 0)
4233
- if (H)
4239
+ if (W)
4234
4240
  if (k(V)) {
4235
- for (H = 0; H < V.length; H++)
4236
- h(V[H]);
4241
+ for (W = 0; W < V.length; W++)
4242
+ h(V[W]);
4237
4243
  Object.freeze && Object.freeze(V);
4238
4244
  } else
4239
4245
  console.error(
@@ -4242,21 +4248,21 @@ function js() {
4242
4248
  else h(V);
4243
4249
  if (b.call(D, "key")) {
4244
4250
  V = n(C);
4245
- var ae = Object.keys(D).filter(function(Wn) {
4246
- return Wn !== "key";
4251
+ var ae = Object.keys(D).filter(function(Gn) {
4252
+ return Gn !== "key";
4247
4253
  });
4248
- H = 0 < ae.length ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}", G[V + H] || (ae = 0 < ae.length ? "{" + ae.join(": ..., ") + ": ...}" : "{}", console.error(
4254
+ W = 0 < ae.length ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}", G[V + W] || (ae = 0 < ae.length ? "{" + ae.join(": ..., ") + ": ...}" : "{}", console.error(
4249
4255
  `A props object containing a "key" prop is being spread into JSX:
4250
4256
  let props = %s;
4251
4257
  <%s {...props} />
4252
4258
  React keys must be passed directly to JSX without using spread:
4253
4259
  let props = %s;
4254
4260
  <%s key={someKey} {...props} />`,
4255
- H,
4261
+ W,
4256
4262
  V,
4257
4263
  ae,
4258
4264
  V
4259
- ), G[V + H] = !0);
4265
+ ), G[V + W] = !0);
4260
4266
  }
4261
4267
  if (V = null, j !== void 0 && (t(j), V = "" + j), r(D) && (t(D.key), V = "" + D.key), "key" in D) {
4262
4268
  j = {};
@@ -4272,7 +4278,7 @@ React keys must be passed directly to JSX without using spread:
4272
4278
  j,
4273
4279
  s(),
4274
4280
  K,
4275
- X
4281
+ Q
4276
4282
  );
4277
4283
  }
4278
4284
  function h(C) {
@@ -4281,7 +4287,7 @@ React keys must be passed directly to JSX without using spread:
4281
4287
  function S(C) {
4282
4288
  return typeof C == "object" && C !== null && C.$$typeof === v;
4283
4289
  }
4284
- var y = _t, v = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), N = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), P = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), d = Symbol.for("react.activity"), p = Symbol.for("react.client.reference"), _ = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, b = Object.prototype.hasOwnProperty, k = Array.isArray, I = console.createTask ? console.createTask : function() {
4290
+ var y = yt, v = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), N = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), P = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), d = Symbol.for("react.activity"), p = Symbol.for("react.client.reference"), _ = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, b = Object.prototype.hasOwnProperty, k = Array.isArray, I = console.createTask ? console.createTask : function() {
4285
4291
  return null;
4286
4292
  };
4287
4293
  y = {
@@ -4294,63 +4300,63 @@ React keys must be passed directly to JSX without using spread:
4294
4300
  o
4295
4301
  )(), ie = I(i(o)), G = {};
4296
4302
  we.Fragment = m, we.jsx = function(C, D, j) {
4297
- var H = 1e4 > _.recentlyCreatedOwnerStacks++;
4303
+ var W = 1e4 > _.recentlyCreatedOwnerStacks++;
4298
4304
  return f(
4299
4305
  C,
4300
4306
  D,
4301
4307
  j,
4302
4308
  !1,
4303
- H ? Error("react-stack-top-frame") : te,
4304
- H ? I(i(C)) : ie
4309
+ W ? Error("react-stack-top-frame") : te,
4310
+ W ? I(i(C)) : ie
4305
4311
  );
4306
4312
  }, we.jsxs = function(C, D, j) {
4307
- var H = 1e4 > _.recentlyCreatedOwnerStacks++;
4313
+ var W = 1e4 > _.recentlyCreatedOwnerStacks++;
4308
4314
  return f(
4309
4315
  C,
4310
4316
  D,
4311
4317
  j,
4312
4318
  !0,
4313
- H ? Error("react-stack-top-frame") : te,
4314
- H ? I(i(C)) : ie
4319
+ W ? Error("react-stack-top-frame") : te,
4320
+ W ? I(i(C)) : ie
4315
4321
  );
4316
4322
  };
4317
4323
  })()), we;
4318
4324
  }
4319
- var tn;
4320
- function Bs() {
4321
- return tn || (tn = 1, process.env.NODE_ENV === "production" ? Be.exports = Fs() : Be.exports = js()), Be.exports;
4325
+ var nn;
4326
+ function Ws() {
4327
+ return nn || (nn = 1, process.env.NODE_ENV === "production" ? Be.exports = Bs() : Be.exports = $s()), Be.exports;
4322
4328
  }
4323
- var Ee = Bs();
4324
- const de = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
4325
- function An(n) {
4329
+ var Ee = Ws();
4330
+ const ue = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
4331
+ function On(n) {
4326
4332
  return "init" in n;
4327
4333
  }
4328
- function pt(n) {
4334
+ function ft(n) {
4329
4335
  return !!n.write;
4330
4336
  }
4331
- function nn(n) {
4337
+ function sn(n) {
4332
4338
  return "v" in n || "e" in n;
4333
4339
  }
4334
- function ze(n) {
4340
+ function Xe(n) {
4335
4341
  if ("e" in n)
4336
4342
  throw n.e;
4337
- if ((de ? "production" : void 0) !== "production" && !("v" in n))
4343
+ if ((ue ? "production" : void 0) !== "production" && !("v" in n))
4338
4344
  throw new Error("[Bug] atom state is not initialized");
4339
4345
  return n.v;
4340
4346
  }
4341
- const Qe = /* @__PURE__ */ new WeakMap();
4342
- function On(n) {
4347
+ const ze = /* @__PURE__ */ new WeakMap();
4348
+ function Ln(n) {
4343
4349
  var e;
4344
- return Xe(n) && !!((e = Qe.get(n)) != null && e[0]);
4350
+ return Qe(n) && !!((e = ze.get(n)) != null && e[0]);
4345
4351
  }
4346
- function $s(n) {
4347
- const e = Qe.get(n);
4352
+ function Hs(n) {
4353
+ const e = ze.get(n);
4348
4354
  e?.[0] && (e[0] = !1, e[1].forEach((t) => t()));
4349
4355
  }
4350
- function ft(n, e) {
4351
- let t = Qe.get(n);
4356
+ function gt(n, e) {
4357
+ let t = ze.get(n);
4352
4358
  if (!t) {
4353
- t = [!0, /* @__PURE__ */ new Set()], Qe.set(n, t);
4359
+ t = [!0, /* @__PURE__ */ new Set()], ze.set(n, t);
4354
4360
  const i = () => {
4355
4361
  t[0] = !1;
4356
4362
  };
@@ -4358,17 +4364,17 @@ function ft(n, e) {
4358
4364
  }
4359
4365
  t[1].add(e);
4360
4366
  }
4361
- function Xe(n) {
4367
+ function Qe(n) {
4362
4368
  return typeof n?.then == "function";
4363
4369
  }
4364
- function Ln(n, e, t) {
4370
+ function Nn(n, e, t) {
4365
4371
  if (!t.p.has(n)) {
4366
4372
  t.p.add(n);
4367
4373
  const i = () => t.p.delete(n);
4368
4374
  e.then(i, i);
4369
4375
  }
4370
4376
  }
4371
- function Nn(n, e, t) {
4377
+ function xn(n, e, t) {
4372
4378
  var i;
4373
4379
  const s = /* @__PURE__ */ new Set();
4374
4380
  for (const o of ((i = t.get(n)) == null ? void 0 : i.t) || [])
@@ -4377,24 +4383,24 @@ function Nn(n, e, t) {
4377
4383
  s.add(o);
4378
4384
  return s;
4379
4385
  }
4380
- const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs = (n, e) => {
4386
+ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs = (n, e) => {
4381
4387
  if (e.INTERNAL_onInit)
4382
4388
  return e.INTERNAL_onInit(n);
4383
4389
  if (e.unstable_onInit)
4384
4390
  return console.warn(
4385
4391
  "[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
4386
4392
  ), e.unstable_onInit(n);
4387
- }, Vs = (n, e, t) => {
4393
+ }, Ys = (n, e, t) => {
4388
4394
  var i;
4389
4395
  return (i = e.onMount) == null ? void 0 : i.call(e, t);
4390
- }, qs = (n, e) => {
4396
+ }, Js = (n, e) => {
4391
4397
  var t;
4392
4398
  const i = Z(n), s = i[0], o = i[6], r = i[9];
4393
- if ((de ? "production" : void 0) !== "production" && !e)
4399
+ if ((ue ? "production" : void 0) !== "production" && !e)
4394
4400
  throw new Error("Atom is undefined or null");
4395
4401
  let c = s.get(e);
4396
4402
  return c || (c = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, c), (t = o.i) == null || t.call(o, e), r?.(n, e)), c;
4397
- }, Ys = (n) => {
4403
+ }, Ks = (n) => {
4398
4404
  const e = Z(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], c = e[13], u = [], l = (f) => {
4399
4405
  try {
4400
4406
  f();
@@ -4412,7 +4418,7 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4412
4418
  } while (i.size || o.size || s.size);
4413
4419
  if (u.length)
4414
4420
  throw new AggregateError(u);
4415
- }, Js = (n) => {
4421
+ }, Xs = (n) => {
4416
4422
  const e = Z(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], c = e[17], u = [], l = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new WeakSet(), h = Array.from(s);
4417
4423
  for (; h.length; ) {
4418
4424
  const S = h[h.length - 1], y = o(n, S);
@@ -4423,13 +4429,13 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4423
4429
  if (l.has(S)) {
4424
4430
  if (i.get(S) === y.n)
4425
4431
  u.push([S, y]);
4426
- else if ((de ? "production" : void 0) !== "production" && i.has(S))
4432
+ else if ((ue ? "production" : void 0) !== "production" && i.has(S))
4427
4433
  throw new Error("[Bug] invalidated atom exists");
4428
4434
  f.add(S), h.pop();
4429
4435
  continue;
4430
4436
  }
4431
4437
  l.add(S);
4432
- for (const v of Nn(S, y, t))
4438
+ for (const v of xn(S, y, t))
4433
4439
  l.has(v) || h.push(v);
4434
4440
  }
4435
4441
  for (let S = u.length - 1; S >= 0; --S) {
@@ -4442,10 +4448,10 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4442
4448
  }
4443
4449
  E && (r(n, y), c(n, y)), i.delete(y);
4444
4450
  }
4445
- }, gt = /* @__PURE__ */ new WeakSet(), Ks = (n, e) => {
4451
+ }, vt = /* @__PURE__ */ new WeakSet(), zs = (n, e) => {
4446
4452
  var t, i;
4447
4453
  const s = Z(n), o = s[1], r = s[2], c = s[3], u = s[6], l = s[7], f = s[11], h = s[12], S = s[13], y = s[14], v = s[16], E = s[17], m = f(n, e);
4448
- if (nn(m)) {
4454
+ if (sn(m)) {
4449
4455
  if (o.has(e) && r.get(e) !== m.n)
4450
4456
  return m;
4451
4457
  let R = !1;
@@ -4466,18 +4472,18 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4466
4472
  var a;
4467
4473
  if (R === e) {
4468
4474
  const p = f(n, R);
4469
- if (!nn(p))
4470
- if (An(R))
4475
+ if (!sn(p))
4476
+ if (On(R))
4471
4477
  Ze(n, R, R.init);
4472
4478
  else
4473
4479
  throw new Error("no atom init");
4474
- return ze(p);
4480
+ return Xe(p);
4475
4481
  }
4476
4482
  const d = y(n, R);
4477
4483
  try {
4478
- return ze(d);
4484
+ return Xe(d);
4479
4485
  } finally {
4480
- m.d.set(R, d.n), On(m.v) && Ln(e, m.v, d), o.has(e) && ((a = o.get(R)) == null || a.t.add(e)), w || N();
4486
+ m.d.set(R, d.n), Ln(m.v) && Nn(e, m.v, d), o.has(e) && ((a = o.get(R)) == null || a.t.add(e)), w || N();
4481
4487
  }
4482
4488
  }
4483
4489
  let P, M;
@@ -4486,8 +4492,8 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4486
4492
  return P || (P = new AbortController()), P.signal;
4487
4493
  },
4488
4494
  get setSelf() {
4489
- return (de ? "production" : void 0) !== "production" && !pt(e) && console.warn("setSelf function cannot be used with read-only atom"), !M && pt(e) && (M = (...R) => {
4490
- if ((de ? "production" : void 0) !== "production" && w && console.warn("setSelf function cannot be called in sync"), !w)
4495
+ return (ue ? "production" : void 0) !== "production" && !ft(e) && console.warn("setSelf function cannot be used with read-only atom"), !M && ft(e) && (M = (...R) => {
4496
+ if ((ue ? "production" : void 0) !== "production" && w && console.warn("setSelf function cannot be called in sync"), !w)
4491
4497
  try {
4492
4498
  return v(n, e, ...R);
4493
4499
  } finally {
@@ -4497,41 +4503,41 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4497
4503
  }
4498
4504
  }, F = m.n;
4499
4505
  try {
4500
- (de ? "production" : void 0) !== "production" && gt.delete(n);
4506
+ (ue ? "production" : void 0) !== "production" && vt.delete(n);
4501
4507
  const R = l(n, e, A, q);
4502
- return (de ? "production" : void 0) !== "production" && gt.has(n) && console.warn(
4508
+ return (ue ? "production" : void 0) !== "production" && vt.has(n) && console.warn(
4503
4509
  "Detected store mutation during atom read. This is not supported."
4504
- ), Ze(n, e, R), Xe(R) && (ft(R, () => P?.abort()), R.then(N, N)), (t = u.r) == null || t.call(u, e), m;
4510
+ ), Ze(n, e, R), Qe(R) && (gt(R, () => P?.abort()), R.then(N, N)), (t = u.r) == null || t.call(u, e), m;
4505
4511
  } catch (R) {
4506
4512
  return delete m.v, m.e = R, ++m.n, m;
4507
4513
  } finally {
4508
4514
  w = !1, F !== m.n && r.get(e) === F && (r.set(e, m.n), c.add(e), (i = u.c) == null || i.call(u, e));
4509
4515
  }
4510
- }, zs = (n, e) => {
4516
+ }, Qs = (n, e) => {
4511
4517
  const t = Z(n), i = t[1], s = t[2], o = t[11], r = [e];
4512
4518
  for (; r.length; ) {
4513
4519
  const c = r.pop(), u = o(n, c);
4514
- for (const l of Nn(c, u, i)) {
4520
+ for (const l of xn(c, u, i)) {
4515
4521
  const f = o(n, l);
4516
4522
  s.set(l, f.n), r.push(l);
4517
4523
  }
4518
4524
  }
4519
- }, xn = (n, e, ...t) => {
4525
+ }, Dn = (n, e, ...t) => {
4520
4526
  const i = Z(n), s = i[3], o = i[6], r = i[8], c = i[11], u = i[12], l = i[13], f = i[14], h = i[15], S = i[17];
4521
4527
  let y = !0;
4522
- const v = (m) => ze(f(n, m)), E = (m, ...w) => {
4528
+ const v = (m) => Xe(f(n, m)), E = (m, ...w) => {
4523
4529
  var N;
4524
4530
  const A = c(n, m);
4525
4531
  try {
4526
4532
  if (m === e) {
4527
- if (!An(m))
4533
+ if (!On(m))
4528
4534
  throw new Error("atom not writable");
4529
- (de ? "production" : void 0) !== "production" && gt.add(n);
4535
+ (ue ? "production" : void 0) !== "production" && vt.add(n);
4530
4536
  const P = A.n, M = w[0];
4531
4537
  Ze(n, m, M), S(n, m), P !== A.n && (s.add(m), h(n, m), (N = o.c) == null || N.call(o, m));
4532
4538
  return;
4533
4539
  } else
4534
- return xn(n, m, ...w);
4540
+ return Dn(n, m, ...w);
4535
4541
  } finally {
4536
4542
  y || (l(n), u(n));
4537
4543
  }
@@ -4541,10 +4547,10 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4541
4547
  } finally {
4542
4548
  y = !1;
4543
4549
  }
4544
- }, Qs = (n, e) => {
4550
+ }, Zs = (n, e) => {
4545
4551
  var t;
4546
4552
  const i = Z(n), s = i[1], o = i[3], r = i[6], c = i[11], u = i[15], l = i[18], f = i[19], h = c(n, e), S = s.get(e);
4547
- if (S && !On(h.v)) {
4553
+ if (S && !Ln(h.v)) {
4548
4554
  for (const [y, v] of h.d)
4549
4555
  if (!S.d.has(y)) {
4550
4556
  const E = c(n, y);
@@ -4557,19 +4563,19 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4557
4563
  v?.t.delete(e);
4558
4564
  }
4559
4565
  }
4560
- }, Dn = (n, e) => {
4566
+ }, Pn = (n, e) => {
4561
4567
  var t;
4562
4568
  const i = Z(n), s = i[1], o = i[4], r = i[6], c = i[10], u = i[11], l = i[12], f = i[13], h = i[14], S = i[16], y = u(n, e);
4563
4569
  let v = s.get(e);
4564
4570
  if (!v) {
4565
4571
  h(n, e);
4566
4572
  for (const E of y.d.keys())
4567
- Dn(n, E).t.add(e);
4573
+ Pn(n, E).t.add(e);
4568
4574
  if (v = {
4569
4575
  l: /* @__PURE__ */ new Set(),
4570
4576
  d: new Set(y.d.keys()),
4571
4577
  t: /* @__PURE__ */ new Set()
4572
- }, s.set(e, v), pt(e)) {
4578
+ }, s.set(e, v), ft(e)) {
4573
4579
  const E = () => {
4574
4580
  let m = !0;
4575
4581
  const w = (...N) => {
@@ -4598,7 +4604,7 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4598
4604
  (t = r.m) == null || t.call(r, e);
4599
4605
  }
4600
4606
  return v;
4601
- }, Xs = (n, e) => {
4607
+ }, eo = (n, e) => {
4602
4608
  var t, i;
4603
4609
  const s = Z(n), o = s[1], r = s[5], c = s[6], u = s[11], l = s[19], f = u(n, e);
4604
4610
  let h = o.get(e);
@@ -4622,38 +4628,38 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
4622
4628
  return h;
4623
4629
  }, Ze = (n, e, t) => {
4624
4630
  const i = Z(n)[11], s = i(n, e), o = "v" in s, r = s.v;
4625
- if (Xe(t))
4631
+ if (Qe(t))
4626
4632
  for (const c of s.d.keys())
4627
- Ln(
4633
+ Nn(
4628
4634
  e,
4629
4635
  t,
4630
4636
  i(n, c)
4631
4637
  );
4632
- s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, Xe(r) && $s(r));
4633
- }, Zs = (n, e) => {
4638
+ s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, Qe(r) && Hs(r));
4639
+ }, to = (n, e) => {
4634
4640
  const t = Z(n)[14];
4635
- return ze(t(n, e));
4636
- }, eo = (n, e, ...t) => {
4641
+ return Xe(t(n, e));
4642
+ }, no = (n, e, ...t) => {
4637
4643
  const i = Z(n), s = i[12], o = i[13], r = i[16];
4638
4644
  try {
4639
4645
  return r(n, e, ...t);
4640
4646
  } finally {
4641
4647
  o(n), s(n);
4642
4648
  }
4643
- }, to = (n, e, t) => {
4649
+ }, io = (n, e, t) => {
4644
4650
  const i = Z(n), s = i[12], o = i[18], r = i[19], u = o(n, e).l;
4645
4651
  return u.add(t), s(n), () => {
4646
4652
  u.delete(t), r(n, e), s(n);
4647
4653
  };
4648
- }, Pn = /* @__PURE__ */ new WeakMap(), Z = (n) => {
4649
- const e = Pn.get(n);
4650
- if ((de ? "production" : void 0) !== "production" && !e)
4654
+ }, Mn = /* @__PURE__ */ new WeakMap(), Z = (n) => {
4655
+ const e = Mn.get(n);
4656
+ if ((ue ? "production" : void 0) !== "production" && !e)
4651
4657
  throw new Error(
4652
4658
  "Store must be created by buildStore to read its building blocks"
4653
4659
  );
4654
4660
  return e;
4655
4661
  };
4656
- function no(...n) {
4662
+ function so(...n) {
4657
4663
  const e = {
4658
4664
  get(i) {
4659
4665
  const s = Z(e)[21];
@@ -4684,63 +4690,63 @@ function no(...n) {
4684
4690
  {},
4685
4691
  // storeHooks
4686
4692
  // atom interceptors
4687
- Hs,
4688
- Ws,
4689
4693
  Gs,
4690
4694
  Vs,
4691
- // building-block functions
4692
4695
  qs,
4693
4696
  Ys,
4697
+ // building-block functions
4694
4698
  Js,
4695
4699
  Ks,
4700
+ Xs,
4696
4701
  zs,
4697
- xn,
4698
4702
  Qs,
4699
4703
  Dn,
4700
- Xs,
4701
- Ze,
4702
4704
  Zs,
4705
+ Pn,
4703
4706
  eo,
4707
+ Ze,
4704
4708
  to,
4709
+ no,
4710
+ io,
4705
4711
  void 0
4706
4712
  ].map((i, s) => n[s] || i);
4707
- return Pn.set(e, Object.freeze(t)), e;
4713
+ return Mn.set(e, Object.freeze(t)), e;
4708
4714
  }
4709
- const Mn = {};
4710
- let io = 0;
4715
+ const Un = {};
4716
+ let oo = 0;
4711
4717
  function et(n, e) {
4712
- const t = `atom${++io}`, i = {
4718
+ const t = `atom${++oo}`, i = {
4713
4719
  toString() {
4714
- return (Mn ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
4720
+ return (Un ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
4715
4721
  }
4716
4722
  };
4717
- return typeof n == "function" ? i.read = n : (i.init = n, i.read = so, i.write = oo), i;
4723
+ return typeof n == "function" ? i.read = n : (i.init = n, i.read = ro, i.write = ao), i;
4718
4724
  }
4719
- function so(n) {
4725
+ function ro(n) {
4720
4726
  return n(this);
4721
4727
  }
4722
- function oo(n, e, t) {
4728
+ function ao(n, e, t) {
4723
4729
  return e(
4724
4730
  this,
4725
4731
  typeof t == "function" ? t(n(this)) : t
4726
4732
  );
4727
4733
  }
4728
- function ro() {
4729
- return no();
4734
+ function co() {
4735
+ return so();
4730
4736
  }
4731
4737
  let Ie;
4732
- function ao() {
4733
- return Ie || (Ie = ro(), (Mn ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Ie), globalThis.__JOTAI_DEFAULT_STORE__ !== Ie && console.warn(
4738
+ function lo() {
4739
+ return Ie || (Ie = co(), (Un ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Ie), globalThis.__JOTAI_DEFAULT_STORE__ !== Ie && console.warn(
4734
4740
  "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
4735
4741
  ))), Ie;
4736
4742
  }
4737
- const co = {}, lo = rn(
4743
+ const uo = {}, ho = an(
4738
4744
  void 0
4739
4745
  );
4740
- function Un(n) {
4741
- return on(lo) || ao();
4746
+ function Fn(n) {
4747
+ return rn(ho) || lo();
4742
4748
  }
4743
- const vt = (n) => typeof n?.then == "function", mt = (n) => {
4749
+ const mt = (n) => typeof n?.then == "function", _t = (n) => {
4744
4750
  n.status || (n.status = "pending", n.then(
4745
4751
  (e) => {
4746
4752
  n.status = "fulfilled", n.value = e;
@@ -4749,15 +4755,15 @@ const vt = (n) => typeof n?.then == "function", mt = (n) => {
4749
4755
  n.status = "rejected", n.reason = e;
4750
4756
  }
4751
4757
  ));
4752
- }, uo = _t.use || // A shim for older React versions
4758
+ }, po = yt.use || // A shim for older React versions
4753
4759
  ((n) => {
4754
4760
  if (n.status === "pending")
4755
4761
  throw n;
4756
4762
  if (n.status === "fulfilled")
4757
4763
  return n.value;
4758
- throw n.status === "rejected" ? n.reason : (mt(n), n);
4759
- }), ct = /* @__PURE__ */ new WeakMap(), sn = (n, e) => {
4760
- let t = ct.get(n);
4764
+ throw n.status === "rejected" ? n.reason : (_t(n), n);
4765
+ }), lt = /* @__PURE__ */ new WeakMap(), on = (n, e) => {
4766
+ let t = lt.get(n);
4761
4767
  return t || (t = new Promise((i, s) => {
4762
4768
  let o = n;
4763
4769
  const r = (l) => (f) => {
@@ -4767,16 +4773,16 @@ const vt = (n) => typeof n?.then == "function", mt = (n) => {
4767
4773
  }, u = () => {
4768
4774
  try {
4769
4775
  const l = e();
4770
- vt(l) ? (ct.set(l, t), o = l, l.then(r(l), c(l)), ft(l, u)) : i(l);
4776
+ mt(l) ? (lt.set(l, t), o = l, l.then(r(l), c(l)), gt(l, u)) : i(l);
4771
4777
  } catch (l) {
4772
4778
  s(l);
4773
4779
  }
4774
4780
  };
4775
- n.then(r(n), c(n)), ft(n, u);
4776
- }), ct.set(n, t)), t;
4781
+ n.then(r(n), c(n)), gt(n, u);
4782
+ }), lt.set(n, t)), t;
4777
4783
  };
4778
4784
  function tt(n, e) {
4779
- const { delay: t, unstable_promiseStatus: i = !_t.use } = {}, s = Un(), [[o, r, c], u] = Gn(
4785
+ const { delay: t, unstable_promiseStatus: i = !yt.use } = {}, s = Fn(), [[o, r, c], u] = Vn(
4780
4786
  (f) => {
4781
4787
  const h = s.get(n);
4782
4788
  return Object.is(f[0], h) && f[1] === s && f[2] === n ? f : [h, s, n];
@@ -4790,8 +4796,8 @@ function tt(n, e) {
4790
4796
  if (i)
4791
4797
  try {
4792
4798
  const h = s.get(n);
4793
- vt(h) && mt(
4794
- sn(h, () => s.get(n))
4799
+ mt(h) && _t(
4800
+ on(h, () => s.get(n))
4795
4801
  );
4796
4802
  } catch {
4797
4803
  }
@@ -4802,38 +4808,38 @@ function tt(n, e) {
4802
4808
  u();
4803
4809
  });
4804
4810
  return u(), f;
4805
- }, [s, n, t, i]), Vn(l), vt(l)) {
4806
- const f = sn(l, () => s.get(n));
4807
- return i && mt(f), uo(f);
4811
+ }, [s, n, t, i]), qn(l), mt(l)) {
4812
+ const f = on(l, () => s.get(n));
4813
+ return i && _t(f), po(f);
4808
4814
  }
4809
4815
  return l;
4810
4816
  }
4811
4817
  function nt(n, e) {
4812
- const t = Un();
4813
- return qn(
4818
+ const t = Fn();
4819
+ return Yn(
4814
4820
  (...s) => {
4815
- if ((co ? "production" : void 0) !== "production" && !("write" in n))
4821
+ if ((uo ? "production" : void 0) !== "production" && !("write" in n))
4816
4822
  throw new Error("not writable atom");
4817
4823
  return t.set(n, ...s);
4818
4824
  },
4819
4825
  [t, n]
4820
4826
  );
4821
4827
  }
4822
- const Fn = et([]);
4823
- function bo() {
4824
- return tt(Fn);
4828
+ const jn = et([]);
4829
+ function wo() {
4830
+ return tt(jn);
4825
4831
  }
4826
- function ho() {
4827
- return nt(Fn);
4832
+ function fo() {
4833
+ return nt(jn);
4828
4834
  }
4829
4835
  const it = () => {
4830
- const n = on(Hn);
4836
+ const n = rn(Hn);
4831
4837
  if (!n)
4832
4838
  throw new Error("useClient must be used within a TelnyxAIAgentProvider");
4833
4839
  return n;
4834
4840
  };
4835
- function po() {
4836
- const n = it(), e = ho();
4841
+ function go() {
4842
+ const n = it(), e = fo();
4837
4843
  return ve(() => {
4838
4844
  const t = (i) => e((s) => [...s, i]);
4839
4845
  return n.addListener("transcript.item", t), () => {
@@ -4841,15 +4847,15 @@ function po() {
4841
4847
  };
4842
4848
  }, [n, e]), null;
4843
4849
  }
4844
- const jn = et("connecting");
4845
- function Co() {
4846
- return tt(jn);
4850
+ const Bn = et("connecting");
4851
+ function Eo() {
4852
+ return tt(Bn);
4847
4853
  }
4848
- function fo() {
4849
- return nt(jn);
4854
+ function vo() {
4855
+ return nt(Bn);
4850
4856
  }
4851
- function go() {
4852
- const n = it(), e = fo();
4857
+ function mo() {
4858
+ const n = it(), e = vo();
4853
4859
  return ve(() => {
4854
4860
  const t = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
4855
4861
  return n.addListener("agent.connected", t), n.addListener("agent.disconnected", i), n.addListener("agent.error", s), () => {
@@ -4857,15 +4863,15 @@ function go() {
4857
4863
  };
4858
4864
  }, [n, e]), null;
4859
4865
  }
4860
- const Bn = et(null);
4861
- function wo() {
4862
- return tt(Bn);
4866
+ const $n = et(null);
4867
+ function Io() {
4868
+ return tt($n);
4863
4869
  }
4864
- function vo() {
4865
- return nt(Bn);
4870
+ function _o() {
4871
+ return nt($n);
4866
4872
  }
4867
- const mo = () => {
4868
- const n = it(), e = vo();
4873
+ const yo = () => {
4874
+ const n = it(), e = _o();
4869
4875
  return ve(() => {
4870
4876
  const t = (i) => {
4871
4877
  e(i);
@@ -4874,15 +4880,15 @@ const mo = () => {
4874
4880
  n.removeListener("conversation.update", t);
4875
4881
  };
4876
4882
  }, [n, e]), null;
4877
- }, $n = et({ state: "listening" });
4878
- function Eo() {
4879
- return tt($n);
4883
+ }, Wn = et({ state: "listening" });
4884
+ function To() {
4885
+ return tt(Wn);
4880
4886
  }
4881
- function _o() {
4882
- return nt($n);
4887
+ function So() {
4888
+ return nt(Wn);
4883
4889
  }
4884
- function yo() {
4885
- const n = it(), e = _o();
4890
+ function bo() {
4891
+ const n = it(), e = So();
4886
4892
  return ve(() => {
4887
4893
  const t = (i) => {
4888
4894
  e(i);
@@ -4892,7 +4898,7 @@ function yo() {
4892
4898
  };
4893
4899
  }, [n, e]), null;
4894
4900
  }
4895
- const Hn = rn(null), Io = ({
4901
+ const Hn = an(null), ko = ({
4896
4902
  children: n,
4897
4903
  agentId: e,
4898
4904
  environment: t,
@@ -4900,10 +4906,10 @@ const Hn = rn(null), Io = ({
4900
4906
  debug: s,
4901
4907
  vad: o
4902
4908
  }) => {
4903
- const [r, c] = Yn(() => new Xt({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
4909
+ const [r, c] = Jn(() => new Zt({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
4904
4910
  return ve(() => {
4905
4911
  if (!r) {
4906
- const u = new Xt({ agentId: e, environment: t, versionId: i, vad: o });
4912
+ const u = new Zt({ agentId: e, environment: t, versionId: i, vad: o });
4907
4913
  return c(u), () => {
4908
4914
  u.disconnect();
4909
4915
  };
@@ -4911,25 +4917,25 @@ const Hn = rn(null), Io = ({
4911
4917
  }, [e, r, t, i, o]), ve(() => {
4912
4918
  r?.connect();
4913
4919
  }, [r]), /* @__PURE__ */ Ee.jsxs(Hn.Provider, { value: r, children: [
4914
- /* @__PURE__ */ Ee.jsx(po, {}),
4915
4920
  /* @__PURE__ */ Ee.jsx(go, {}),
4916
4921
  /* @__PURE__ */ Ee.jsx(mo, {}),
4917
4922
  /* @__PURE__ */ Ee.jsx(yo, {}),
4923
+ /* @__PURE__ */ Ee.jsx(bo, {}),
4918
4924
  n
4919
4925
  ] });
4920
4926
  };
4921
4927
  export {
4922
4928
  Hn as ClientContext,
4923
4929
  T as SwEvent,
4924
- Xt as TelnyxAIAgent,
4925
- Io as TelnyxAIAgentProvider,
4926
- Eo as useAgentState,
4930
+ Zt as TelnyxAIAgent,
4931
+ ko as TelnyxAIAgentProvider,
4932
+ To as useAgentState,
4927
4933
  it as useClient,
4928
- Co as useConnectionState,
4929
- wo as useConversation,
4930
- _o as useSetAgentState,
4931
- fo as useSetConnectionState,
4932
- vo as useSetConversation,
4933
- ho as useSetTranscript,
4934
- bo as useTranscript
4934
+ Eo as useConnectionState,
4935
+ Io as useConversation,
4936
+ So as useSetAgentState,
4937
+ vo as useSetConnectionState,
4938
+ _o as useSetConversation,
4939
+ fo as useSetTranscript,
4940
+ wo as useTranscript
4935
4941
  };