call-control-sdk 6.5.5-uat.3 → 6.5.5-uat.5

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
@@ -1137,7 +1137,7 @@ var styles_default = useStyles;
1137
1137
 
1138
1138
  // call-control-sdk/lib/components/dialog.tsx
1139
1139
  var import_jsx_runtime2 = require("react/jsx-runtime");
1140
- var ConferenceTableRow = ({ each }) => {
1140
+ var ConferenceTableRow = ({ each, isLineDialing }) => {
1141
1141
  var _a2, _b, _c, _d, _e, _f;
1142
1142
  const state = useSDKState();
1143
1143
  const theme = (0, import_material3.useTheme)();
@@ -1327,7 +1327,7 @@ var ConferenceTableRow = ({ each }) => {
1327
1327
  placeholder: "Phone Number",
1328
1328
  fullWidth: true,
1329
1329
  value: (each == null ? void 0 : each.phone) || "",
1330
- disabled: (each == null ? void 0 : each.line) === 1 || ["ONCALL" /* ONCALL */, "DISCONNECTED" /* DISCONNECTED */, "CONFERENCE" /* CONFERENCE */, "HOLD" /* HOLD */, "MUTE" /* MUTE */, "DIALING" /* DIALING */, "RINGING" /* RINGING */].includes((_f = each == null ? void 0 : each.status) != null ? _f : ""),
1330
+ disabled: (each == null ? void 0 : each.line) === 1 || ["ONCALL" /* ONCALL */, "DISCONNECTED" /* DISCONNECTED */, "CONFERENCE" /* CONFERENCE */, "HOLD" /* HOLD */, "MUTE" /* MUTE */, "DIALING" /* DIALING */, "RINGING" /* RINGING */].includes((_f = each == null ? void 0 : each.status) != null ? _f : "") || isLineDialing,
1331
1331
  onChange: (e) => {
1332
1332
  onConferenceLineUpdate(each, { phone: e.target.value });
1333
1333
  }
@@ -1455,7 +1455,7 @@ var ConferenceTableRow = ({ each }) => {
1455
1455
  onClick: () => {
1456
1456
  onConferenceCallStart(each, {});
1457
1457
  },
1458
- disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */,
1458
+ disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ || isLineDialing,
1459
1459
  children: conferenceCallStart ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1460
1460
  import_material3.CircularProgress,
1461
1461
  {
@@ -1556,7 +1556,7 @@ var ConferenceTableRow = ({ each }) => {
1556
1556
  );
1557
1557
  };
1558
1558
  function ConferenceDialog() {
1559
- var _a2;
1559
+ var _a2, _b;
1560
1560
  const state = useSDKState();
1561
1561
  const { showToast } = useToast();
1562
1562
  const [conferenceCallEndAll, setConferenceCallEndAll] = (0, import_react9.useState)(false);
@@ -1564,12 +1564,12 @@ function ConferenceDialog() {
1564
1564
  sdkStateManager.setOpenConferenceDialog(false);
1565
1565
  };
1566
1566
  const onEndAllConferenceCalls = () => {
1567
- var _a3, _b, _c, _d;
1567
+ var _a3, _b2, _c, _d;
1568
1568
  setConferenceCallEndAll(true);
1569
1569
  const payload = {
1570
1570
  action: "EXTERNAL_CONFERENCE",
1571
1571
  operation: "ENDCONFERENCE",
1572
- userid: (_b = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b : "",
1572
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1573
1573
  process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
1574
1574
  };
1575
1575
  axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then((res) => {
@@ -1578,13 +1578,15 @@ function ConferenceDialog() {
1578
1578
  sdkStateManager.resetConferenceLines();
1579
1579
  handleClose();
1580
1580
  }).catch((err) => {
1581
- var _a4, _b2, _c2, _d2;
1582
- const message = ((_b2 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b2.detail) || ((_d2 = (_c2 = err.response) == null ? void 0 : _c2.data) == null ? void 0 : _d2.message) || err.message || "An unknown error occurred";
1581
+ var _a4, _b3, _c2, _d2;
1582
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d2 = (_c2 = err.response) == null ? void 0 : _c2.data) == null ? void 0 : _d2.message) || err.message || "An unknown error occurred";
1583
1583
  showToast(message, "error");
1584
1584
  }).finally(() => {
1585
1585
  setConferenceCallEndAll(false);
1586
1586
  });
1587
1587
  };
1588
+ const isLineDialing = (_a2 = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _a2.some((item) => (item == null ? void 0 : item.status) === "DIALING" /* DIALING */);
1589
+ console.log("dataaaaa", state == null ? void 0 : state.conferenceLine, isLineDialing);
1588
1590
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1589
1591
  import_material3.Dialog,
1590
1592
  {
@@ -1604,7 +1606,7 @@ function ConferenceDialog() {
1604
1606
  },
1605
1607
  children: [
1606
1608
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Typography, { variant: "body1", children: [
1607
- (_a2 = state == null ? void 0 : state.agentId) != null ? _a2 : "",
1609
+ (_b = state == null ? void 0 : state.agentId) != null ? _b : "",
1608
1610
  " conference"
1609
1611
  ] }),
1610
1612
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
@@ -1680,7 +1682,7 @@ function ConferenceDialog() {
1680
1682
  ]
1681
1683
  }
1682
1684
  ) }),
1683
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConferenceTableRow, { each })) })
1685
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConferenceTableRow, { each, isLineDialing })) })
1684
1686
  ]
1685
1687
  }
1686
1688
  )
@@ -2873,83 +2875,6 @@ function createMicController(constraints = { audio: true }) {
2873
2875
  };
2874
2876
  }
2875
2877
 
2876
- // call-control-sdk/lib/utils/audioLoader.ts
2877
- var import_incoming = __toESM(require("./incoming-4WP3FJI4.mp3"));
2878
- var audioBlobUrl = null;
2879
- var audioBuffer = null;
2880
- async function loadAudioAsBlob() {
2881
- if (audioBlobUrl) {
2882
- return audioBlobUrl;
2883
- }
2884
- if (import_incoming.default.startsWith("data:") || import_incoming.default.startsWith("http://") || import_incoming.default.startsWith("https://") || import_incoming.default.startsWith("blob:")) {
2885
- return import_incoming.default;
2886
- }
2887
- try {
2888
- const response = await fetch(import_incoming.default);
2889
- if (!response.ok) {
2890
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
2891
- }
2892
- const blob = await response.blob();
2893
- if (blob.size === 0) {
2894
- throw new Error("Empty blob");
2895
- }
2896
- audioBlobUrl = URL.createObjectURL(blob);
2897
- return audioBlobUrl;
2898
- } catch (error) {
2899
- console.error("Could not create blob URL, using direct URL:", error);
2900
- return import_incoming.default;
2901
- }
2902
- }
2903
- async function createAudioElement() {
2904
- const audio = new Audio();
2905
- audio.loop = true;
2906
- audio.volume = 0.7;
2907
- audio.preload = "auto";
2908
- let audioUrl = "";
2909
- try {
2910
- audioUrl = await loadAudioAsBlob();
2911
- } catch (error) {
2912
- console.warn("Failed to load audio as blob, trying direct URL:", error);
2913
- audioUrl = import_incoming.default;
2914
- }
2915
- const tryLoadAudio = async (url) => {
2916
- return new Promise((resolve) => {
2917
- const checkCanPlay = () => {
2918
- const canPlay = audio.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;
2919
- if (canPlay) {
2920
- resolve(true);
2921
- return;
2922
- }
2923
- if (audio.error) {
2924
- resolve(false);
2925
- return;
2926
- }
2927
- setTimeout(checkCanPlay, 100);
2928
- };
2929
- audio.addEventListener("canplay", () => resolve(true), { once: true });
2930
- audio.addEventListener("error", () => resolve(false), { once: true });
2931
- audio.src = url;
2932
- audio.load();
2933
- setTimeout(() => resolve(false), 2e3);
2934
- });
2935
- };
2936
- let loaded = await tryLoadAudio(audioUrl);
2937
- if (!loaded && audioUrl !== import_incoming.default) {
2938
- loaded = await tryLoadAudio(import_incoming.default);
2939
- if (loaded) {
2940
- audioUrl = import_incoming.default;
2941
- }
2942
- }
2943
- return audio;
2944
- }
2945
- function cleanupAudioResources() {
2946
- if (audioBlobUrl) {
2947
- URL.revokeObjectURL(audioBlobUrl);
2948
- audioBlobUrl = null;
2949
- }
2950
- audioBuffer = null;
2951
- }
2952
-
2953
2878
  // call-control-sdk/lib/components/callControls.tsx
2954
2879
  var import_vault5 = require("@react-solutions/vault");
2955
2880
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -2993,7 +2918,6 @@ function CallControls({ onDataChange }) {
2993
2918
  });
2994
2919
  const micRef = (0, import_react11.useRef)(null);
2995
2920
  const webSocketRef = (0, import_react11.useRef)(null);
2996
- const audioRef = (0, import_react11.useRef)(null);
2997
2921
  const reconnectTimeoutRef = (0, import_react11.useRef)(null);
2998
2922
  const pingIntervalRef = (0, import_react11.useRef)(null);
2999
2923
  const reconnectAttemptsRef = (0, import_react11.useRef)(0);
@@ -3254,22 +3178,6 @@ function CallControls({ onDataChange }) {
3254
3178
  if (wrapUpinterval) clearInterval(wrapUpinterval);
3255
3179
  };
3256
3180
  }, [state.callData.status]);
3257
- (0, import_react11.useEffect)(() => {
3258
- createAudioElement().then((audio) => {
3259
- audioRef.current = audio;
3260
- }).catch((error) => {
3261
- console.error("Failed to load audio element:", error);
3262
- });
3263
- return () => {
3264
- if (audioRef.current) {
3265
- audioRef.current.pause();
3266
- audioRef.current.currentTime = 0;
3267
- audioRef.current.src = "";
3268
- audioRef.current = null;
3269
- }
3270
- cleanupAudioResources();
3271
- };
3272
- }, []);
3273
3181
  (0, import_react11.useEffect)(() => {
3274
3182
  if (onDataChange && state.callData) {
3275
3183
  const { process_id, process_name, status, phone_number, agent_id, convox_id } = state.callData;
@@ -3418,16 +3326,6 @@ function CallControls({ onDataChange }) {
3418
3326
  isMergeCall: false
3419
3327
  }
3420
3328
  ]);
3421
- if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current) {
3422
- audioRef.current.play().catch((error) => {
3423
- console.error("Failed to play ringtone:", error);
3424
- });
3425
- }
3426
- } else {
3427
- if (audioRef.current) {
3428
- audioRef.current.pause();
3429
- audioRef.current.currentTime = 0;
3430
- }
3431
3329
  }
3432
3330
  if (data.status === "ONCALL" /* ONCALL */) {
3433
3331
  sdkStateManager.startCall();