call-control-sdk 6.5.1-uat.4 → 6.5.1-uat.6

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
@@ -88,7 +88,8 @@ var END_POINT = {
88
88
  TRANSFER_TO_DETAILS: `${BASE_URL}${VERSION.v1}/cti/transfer-to-details?provider=convox`,
89
89
  SEND_NOTIFICATIONS: `${BASE_URL}${VERSION.v1}/cti/notifications/send`,
90
90
  CALL_HISTORY: `${BASE_URL}${VERSION.v1}/dashboard/call-history`,
91
- SENTIMENTAL_ANALYSIS: `${BASE_URL}${VERSION.v1}/users/get_sentiment_analysis`
91
+ SENTIMENTAL_ANALYSIS: `${BASE_URL}${VERSION.v1}/users/get_sentiment_analysis`,
92
+ DISPOSITIONS: `${BASE_URL}${VERSION.v1}/cti/calls/dispositions`
92
93
  };
93
94
  var WS_END_POINT = {
94
95
  WS: `${WS_BASE_URL}${VERSION.v1}/cti/ws`
@@ -252,7 +253,7 @@ var SDKStateManager = class {
252
253
  });
253
254
  }
254
255
  } catch (error) {
255
- console.warn("Failed to load SDK state from localStorage:", error);
256
+ console.warn("Failed to load SDK state:", error);
256
257
  }
257
258
  }
258
259
  saveToStorage() {
@@ -276,7 +277,7 @@ var SDKStateManager = class {
276
277
  };
277
278
  localStorage.setItem(this.STORAGE_KEY, JSON.stringify(persistentState));
278
279
  } catch (error) {
279
- console.warn("Failed to save SDK state to localStorage:", error);
280
+ console.warn("Failed to save SDK state:", error);
280
281
  }
281
282
  }
282
283
  notifyListeners() {
@@ -410,7 +411,6 @@ var SDKStateManager = class {
410
411
  setConferenceLine(line) {
411
412
  var _a2;
412
413
  if (!this.state.conferenceLine || !Array.isArray(this.state.conferenceLine)) {
413
- console.warn("Conference line data corrupted, resetting to initial state");
414
414
  this.state.conferenceLine = this.getInitialState().conferenceLine;
415
415
  }
416
416
  const conferenceLineData = (_a2 = this.state.conferenceLine) == null ? void 0 : _a2.map((each) => {
@@ -485,19 +485,7 @@ var SDKStateManager = class {
485
485
  this.state = this.getInitialState();
486
486
  this.notifyListeners();
487
487
  } catch (error) {
488
- console.warn("Failed to clear localStorage:", error);
489
- }
490
- }
491
- debugStorage() {
492
- try {
493
- const stored = localStorage.getItem(this.STORAGE_KEY);
494
- console.log("Current localStorage data:", stored);
495
- if (stored) {
496
- console.log("Parsed localStorage data:", JSON.parse(stored));
497
- }
498
- console.log("Current state:", this.state);
499
- } catch (error) {
500
- console.error("Error debugging storage:", error);
488
+ console.warn("Failed to clear:", error);
501
489
  }
502
490
  }
503
491
  getConferenceLines() {
@@ -512,23 +500,17 @@ var EventTrackerSDK = class {
512
500
  __publicField(this, "config", null);
513
501
  __publicField(this, "ticketId", null);
514
502
  __publicField(this, "baseUrl", "");
515
- __publicField(this, "eventQueue", []);
516
- // private isOnline: boolean = true;
517
- // private retryQueue: Array<() => Promise<void>> = [];
518
503
  __publicField(this, "flushTimer", null);
519
504
  }
520
505
  async init(config) {
521
506
  this.config = __spreadValues({
522
- autoTrack: true,
523
507
  retryAttempts: 3,
524
508
  queueSize: 100,
525
509
  flushInterval: 5e3
526
510
  }, config);
527
511
  this.baseUrl = config.baseUrl || (typeof window !== "undefined" ? window.location.origin : "");
528
- this.setupNetworkDetection();
529
512
  const ticket = await this.createTicket();
530
513
  this.startPeriodicFlush();
531
- console.log("EventTracker SDK initialized successfully");
532
514
  return ticket;
533
515
  }
534
516
  isInitialized() {
@@ -562,104 +544,11 @@ var EventTrackerSDK = class {
562
544
  }
563
545
  const data = await response.json();
564
546
  this.ticketId = data.ticketId;
565
- if (this.config.autoTrack) {
566
- this.setupAutoTracking();
567
- }
568
547
  return data;
569
548
  } catch (error) {
570
- console.error("EventTracker initialization failed:", error);
571
549
  throw error;
572
550
  }
573
551
  }
574
- async logEvent(eventType, eventData) {
575
- if (!this.config || !this.ticketId) {
576
- console.warn("EventTracker not initialized, skipping event:", eventType);
577
- return;
578
- }
579
- const event = {
580
- eventType,
581
- eventData,
582
- timestamp: Date.now()
583
- };
584
- this.eventQueue.push(event);
585
- if (this.eventQueue.length > (this.config.queueSize || 100)) {
586
- this.eventQueue.shift();
587
- }
588
- }
589
- // private async sendEvent(event: {
590
- // eventType: string;
591
- // eventData?: EventData;
592
- // timestamp: number;
593
- // }): Promise<void> {
594
- // if (!this.config || !this.ticketId) return;
595
- // try {
596
- // const response = await this.makeRequest("/api/v1/et/event", {
597
- // method: "POST",
598
- // headers: {
599
- // "Content-Type": "application/json",
600
- // "X-API-Key": this.config.apiKey,
601
- // },
602
- // body: JSON.stringify({
603
- // ticketId: this.ticketId,
604
- // eventType: event.eventType,
605
- // eventData: event.eventData,
606
- // }),
607
- // });
608
- // if (!response.ok) {
609
- // throw new Error(`Failed to log event: ${response.status} ${response.statusText}`);
610
- // }
611
- // const index = this.eventQueue.findIndex((e) => e.timestamp === event.timestamp);
612
- // if (index > -1) {
613
- // this.eventQueue.splice(index, 1);
614
- // }
615
- // } catch (error) {
616
- // console.error("Event logging failed:", error);
617
- // // this.retryQueue.push(() => this.sendEvent(event));
618
- // }
619
- // }
620
- // async closeTicket(): Promise<void> {
621
- // if (!this.config || !this.ticketId) {
622
- // throw new Error("EventTracker not initialized");
623
- // }
624
- // await this.flush();
625
- // try {
626
- // const response = await this.makeRequest("/api/v1/et/close", {
627
- // method: "POST",
628
- // headers: {
629
- // "Content-Type": "application/json",
630
- // "X-API-Key": this.config.apiKey,
631
- // },
632
- // body: JSON.stringify({
633
- // ticketId: this.ticketId,
634
- // }),
635
- // });
636
- // if (!response.ok) {
637
- // throw new Error(`Failed to close ticket: ${response.status} ${response.statusText}`);
638
- // }
639
- // this.ticketId = null;
640
- // this.stopPeriodicFlush();
641
- // console.log("Ticket closed successfully");
642
- // } catch (error) {
643
- // console.error("Ticket close failed:", error);
644
- // throw error;
645
- // }
646
- // }
647
- // async flush(): Promise<void> {
648
- // if (!this.isOnline || this.eventQueue.length === 0) return;
649
- // // const eventsToFlush = [...this.eventQueue];
650
- // // for (const event of eventsToFlush) {
651
- // // await this.sendEvent(event);
652
- // // }
653
- // const retryItems = [...this.retryQueue];
654
- // this.retryQueue = [];
655
- // for (const retryFn of retryItems) {
656
- // try {
657
- // await retryFn();
658
- // } catch (error) {
659
- // console.error("Retry failed:", error);
660
- // }
661
- // }
662
- // }
663
552
  async makeRequest(url, options) {
664
553
  var _a2;
665
554
  const fullUrl = `${this.baseUrl}${url}`;
@@ -678,156 +567,11 @@ var EventTrackerSDK = class {
678
567
  }
679
568
  throw new Error("Max retries exceeded");
680
569
  }
681
- setupAutoTracking() {
682
- var _a2;
683
- if (typeof window === "undefined" || !((_a2 = this.config) == null ? void 0 : _a2.autoTrack)) return;
684
- const autoTrackConfig = this.config.autoTrack === true ? {} : this.config.autoTrack;
685
- if (autoTrackConfig.pageVisits !== false) {
686
- this.logEvent("pageVisit", {
687
- url: window.location.href,
688
- title: document.title,
689
- referrer: document.referrer,
690
- userAgent: navigator.userAgent,
691
- viewport: {
692
- width: window.innerWidth,
693
- height: window.innerHeight
694
- },
695
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
696
- }).catch((error) => console.warn("Failed to track page visit:", error));
697
- }
698
- if (autoTrackConfig.clicks !== false) {
699
- document.addEventListener("click", (event) => {
700
- var _a3;
701
- const target = event.target;
702
- if (target.tagName === "BUTTON" || target.tagName === "A" || target.onclick || target.getAttribute("role") === "button" || target instanceof HTMLButtonElement && target.type === "button") {
703
- this.logEvent("click", {
704
- element: target.tagName,
705
- text: (_a3 = target.textContent) == null ? void 0 : _a3.trim().substring(0, 100),
706
- href: target.getAttribute("href"),
707
- id: target.id,
708
- className: target.className,
709
- role: target.getAttribute("role"),
710
- position: {
711
- x: event.clientX,
712
- y: event.clientY
713
- },
714
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
715
- }).catch((error) => console.warn("Failed to track click:", error));
716
- }
717
- });
718
- }
719
- if (autoTrackConfig.forms !== false) {
720
- document.addEventListener("submit", (event) => {
721
- const target = event.target;
722
- const formData = new FormData(target);
723
- const formFields = {};
724
- formData.forEach((value, key) => {
725
- formFields[key] = value.toString();
726
- });
727
- this.logEvent("formSubmission", {
728
- formId: target.id,
729
- action: target.action,
730
- method: target.method,
731
- fields: Object.keys(formFields),
732
- fieldCount: Object.keys(formFields).length,
733
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
734
- }).catch((error) => console.warn("Failed to track form submission:", error));
735
- });
736
- }
737
- if (autoTrackConfig.inputs !== false) {
738
- let inputTimer;
739
- document.addEventListener("input", (event) => {
740
- const target = event.target;
741
- if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT") {
742
- clearTimeout(inputTimer);
743
- inputTimer = setTimeout(() => {
744
- var _a3;
745
- this.logEvent("fieldChange", {
746
- element: target.tagName,
747
- type: target.getAttribute("type"),
748
- name: target.getAttribute("name"),
749
- id: target.id,
750
- valueLength: ((_a3 = target.value) == null ? void 0 : _a3.length) || 0,
751
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
752
- }).catch((error) => console.warn("Failed to track field change:", error));
753
- }, 1e3);
754
- }
755
- });
756
- }
757
- const sessionStartTime = Date.now();
758
- window.addEventListener("beforeunload", () => {
759
- const sessionDuration = Date.now() - sessionStartTime;
760
- this.logEvent("pageUnload", {
761
- url: window.location.href,
762
- sessionDuration,
763
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
764
- });
765
- });
766
- if (autoTrackConfig.visibility !== false) {
767
- document.addEventListener("visibilitychange", () => {
768
- this.logEvent("visibilityChange", {
769
- hidden: document.hidden,
770
- visibilityState: document.visibilityState,
771
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
772
- });
773
- });
774
- }
775
- if (autoTrackConfig.errors !== false) {
776
- window.addEventListener("error", (event) => {
777
- this.logEvent("jsError", {
778
- message: event.message,
779
- filename: event.filename,
780
- lineno: event.lineno,
781
- colno: event.colno,
782
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
783
- });
784
- });
785
- window.addEventListener("unhandledrejection", (event) => {
786
- var _a3;
787
- this.logEvent("unhandledRejection", {
788
- reason: (_a3 = event.reason) == null ? void 0 : _a3.toString(),
789
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
790
- });
791
- });
792
- }
793
- if (autoTrackConfig.performance !== false && typeof window.performance !== "undefined" && window.performance.navigation) {
794
- window.addEventListener("load", () => {
795
- setTimeout(() => {
796
- const navigation = window.performance.navigation;
797
- const timing = window.performance.timing;
798
- this.logEvent("performanceMetrics", {
799
- navigationTime: timing.navigationStart,
800
- loadTime: timing.loadEventEnd - timing.navigationStart,
801
- domReady: timing.domContentLoadedEventEnd - timing.navigationStart,
802
- renderTime: timing.loadEventEnd - timing.domContentLoadedEventEnd,
803
- navigationType: navigation.type,
804
- redirectCount: navigation.redirectCount,
805
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
806
- });
807
- }, 1e3);
808
- });
809
- }
810
- }
811
- setupNetworkDetection() {
812
- if (typeof window === "undefined") return;
813
- window.addEventListener("online", () => {
814
- console.log("EventTracker: Back online, flushing queued events");
815
- });
816
- window.addEventListener("offline", () => {
817
- console.log("EventTracker: Offline, queueing events");
818
- });
819
- }
820
570
  startPeriodicFlush() {
821
571
  if (this.flushTimer) {
822
572
  clearInterval(this.flushTimer);
823
573
  }
824
574
  }
825
- // private stopPeriodicFlush(): void {
826
- // if (this.flushTimer) {
827
- // clearInterval(this.flushTimer);
828
- // this.flushTimer = null;
829
- // }
830
- // }
831
575
  };
832
576
  var eventTracker = new EventTrackerSDK();
833
577
  if (typeof window !== "undefined") {
@@ -876,12 +620,6 @@ function createAxiosInstance() {
876
620
  );
877
621
  instance.interceptors.response.use(
878
622
  (response) => {
879
- var _a3;
880
- const endTime = (/* @__PURE__ */ new Date()).getTime();
881
- const startTime = (_a3 = response.config.metadata) == null ? void 0 : _a3.startTime;
882
- if (startTime) {
883
- console.log(`Request to ${response.config.url} took ${endTime - startTime}ms`);
884
- }
885
623
  return response;
886
624
  },
887
625
  async (error) => {
@@ -1310,6 +1048,59 @@ var reducer = (state, action) => {
1310
1048
  }
1311
1049
  throw Error("Unknown action.");
1312
1050
  };
1051
+ var useGetRequest = (props = {}) => {
1052
+ const { onSuccess = null, onError = null } = props;
1053
+ const { showToast } = useToast();
1054
+ const [state, dispatch] = (0, import_react9.useReducer)(reducer, initialState);
1055
+ const getRequest = (0, import_react9.useCallback)(
1056
+ (url, config = {}) => {
1057
+ dispatch({
1058
+ type: "isLoading",
1059
+ payload: true
1060
+ });
1061
+ axios_default.get(url, config).then((res) => {
1062
+ var _a2, _b;
1063
+ if ((_a2 = res.data) == null ? void 0 : _a2.success) {
1064
+ dispatch({
1065
+ type: "isSuccess",
1066
+ payload: res.data
1067
+ });
1068
+ onSuccess == null ? void 0 : onSuccess(res.data, config);
1069
+ } else {
1070
+ dispatch({
1071
+ type: "isError",
1072
+ payload: res.data
1073
+ });
1074
+ showToast((_b = res.data) == null ? void 0 : _b.message, "error");
1075
+ onError == null ? void 0 : onError(res.data, config);
1076
+ }
1077
+ }).catch((err) => {
1078
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1079
+ const error = {
1080
+ status: (_b = (_a2 = err.response) == null ? void 0 : _a2.status) != null ? _b : 500,
1081
+ message: ((_d = (_c = err.response) == null ? void 0 : _c.data) == null ? void 0 : _d.detail) || ((_f = (_e = err.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) || err.message || "An unknown error occurred",
1082
+ data: (_h = (_g = err.response) == null ? void 0 : _g.data) != null ? _h : null,
1083
+ statusText: (_j = (_i = err.response) == null ? void 0 : _i.statusText) != null ? _j : "",
1084
+ code: (_k = err == null ? void 0 : err.code) != null ? _k : "",
1085
+ name: (_l = err == null ? void 0 : err.name) != null ? _l : ""
1086
+ };
1087
+ showToast(error.message, "error");
1088
+ dispatch({
1089
+ type: "isError",
1090
+ payload: error
1091
+ });
1092
+ onError == null ? void 0 : onError(error, config);
1093
+ }).finally(() => {
1094
+ dispatch({
1095
+ type: "isLoading",
1096
+ payload: false
1097
+ });
1098
+ });
1099
+ },
1100
+ [onSuccess, onError, showToast]
1101
+ );
1102
+ return [getRequest, state];
1103
+ };
1313
1104
  var usePostRequest = (props = {}) => {
1314
1105
  const { onSuccess = null, onError = null, disabledSuccessToast = false } = props;
1315
1106
  const { showToast } = useToast();
@@ -1451,7 +1242,7 @@ var ConferenceTableRow = ({ each }) => {
1451
1242
  const line_used = __spreadValues(__spreadValues({}, line), data);
1452
1243
  setConferenceCallStart(true);
1453
1244
  const payload = {
1454
- action: "EXTERNAL_CONFERENCE",
1245
+ action: "INTERNAL_CONFERENCE",
1455
1246
  operation: `CALL${line_used.line}`,
1456
1247
  line_used: String(line_used.line),
1457
1248
  thirdparty_no: line_used.phone,
@@ -1547,17 +1338,11 @@ var ConferenceTableRow = ({ each }) => {
1547
1338
  const [holdOrUnHold] = usePostRequest({
1548
1339
  onSuccess: () => {
1549
1340
  sdkStateManager.setHolding(!state.isHolding);
1550
- },
1551
- onError: (error) => {
1552
- console.log("\u274C Hold operation error:", error);
1553
1341
  }
1554
1342
  });
1555
1343
  const [muteOrUnMute] = usePostRequest({
1556
1344
  onSuccess: () => {
1557
1345
  sdkStateManager.setMuted(!state.isMuted);
1558
- },
1559
- onError: (error) => {
1560
- console.log("\u274C Mute operation error:", error);
1561
1346
  }
1562
1347
  });
1563
1348
  const handleHoldToggle = () => {
@@ -2454,7 +2239,8 @@ function CallTransferDialog({ open }) {
2454
2239
  ) });
2455
2240
  }
2456
2241
  function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2457
- var _a2, _b, _c, _d;
2242
+ var _a2, _b, _c, _d, _e;
2243
+ const [getDispositions, data] = useGetRequest();
2458
2244
  const [formData, setFormData] = (0, import_react10.useState)({
2459
2245
  disposition: { label: "Resolved", value: "RES" },
2460
2246
  followUp: { label: "No", value: "N" },
@@ -2463,10 +2249,6 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2463
2249
  callbackMins: "",
2464
2250
  selected_break: false
2465
2251
  });
2466
- const dispositionOptions = [
2467
- { label: "Not Interested", value: "NI" },
2468
- { label: "Resolved", value: "RES" }
2469
- ];
2470
2252
  const followUpOptions = [
2471
2253
  { label: "Yes", value: "Y" },
2472
2254
  { label: "No", value: "N" }
@@ -2488,6 +2270,16 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2488
2270
  handleReset();
2489
2271
  setOpen(false);
2490
2272
  };
2273
+ (0, import_react10.useEffect)(() => {
2274
+ getDispositions(END_POINT.DISPOSITIONS);
2275
+ }, []);
2276
+ const dispositionsOptions = (0, import_react10.useMemo)(() => {
2277
+ var _a3, _b2;
2278
+ return ((_b2 = (_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.data) == null ? void 0 : _b2.map((item) => ({
2279
+ label: item.name,
2280
+ value: item.code
2281
+ }))) || [];
2282
+ }, [(_a2 = data == null ? void 0 : data.data) == null ? void 0 : _a2.data]);
2491
2283
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2492
2284
  import_material3.Dialog,
2493
2285
  {
@@ -2540,7 +2332,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2540
2332
  import_material3.Autocomplete,
2541
2333
  {
2542
2334
  value: formData.disposition,
2543
- options: dispositionOptions,
2335
+ options: dispositionsOptions,
2544
2336
  getOptionLabel: (opt) => opt.label,
2545
2337
  onChange: (_, val) => handleChange("disposition", val),
2546
2338
  size: "small",
@@ -2605,7 +2397,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2605
2397
  ),
2606
2398
  " Mark as break"
2607
2399
  ] }),
2608
- ((_b = (_a2 = formData == null ? void 0 : formData.followUp) == null ? void 0 : _a2.label) == null ? void 0 : _b.toLowerCase()) === "yes" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2400
+ ((_c = (_b = formData == null ? void 0 : formData.followUp) == null ? void 0 : _b.label) == null ? void 0 : _c.toLowerCase()) === "yes" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2609
2401
  import_material3.TextField,
2610
2402
  {
2611
2403
  size: "small",
@@ -2623,7 +2415,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2623
2415
  ]
2624
2416
  }
2625
2417
  ),
2626
- ((_d = (_c = formData == null ? void 0 : formData.followUp) == null ? void 0 : _c.label) == null ? void 0 : _d.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2418
+ ((_e = (_d = formData == null ? void 0 : formData.followUp) == null ? void 0 : _d.label) == null ? void 0 : _e.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2627
2419
  import_material3.Box,
2628
2420
  {
2629
2421
  display: "flex",
@@ -2857,7 +2649,7 @@ async function loadAudioAsBlob() {
2857
2649
  audioBlobUrl = URL.createObjectURL(blob);
2858
2650
  return audioBlobUrl;
2859
2651
  } catch (error) {
2860
- console.warn("Could not create blob URL, using direct URL:", error);
2652
+ console.error("Could not create blob URL, using direct URL:", error);
2861
2653
  return import_incoming.default;
2862
2654
  }
2863
2655
  }
@@ -2896,15 +2688,11 @@ async function createAudioElement() {
2896
2688
  };
2897
2689
  let loaded = await tryLoadAudio(audioUrl);
2898
2690
  if (!loaded && audioUrl !== import_incoming.default) {
2899
- console.log("Primary URL failed, trying original import URL:", import_incoming.default);
2900
2691
  loaded = await tryLoadAudio(import_incoming.default);
2901
2692
  if (loaded) {
2902
2693
  audioUrl = import_incoming.default;
2903
2694
  }
2904
2695
  }
2905
- if (!loaded) {
2906
- console.error("Failed to load audio with all methods. URL:", audioUrl);
2907
- }
2908
2696
  return audio;
2909
2697
  }
2910
2698
  function cleanupAudioResources() {
@@ -3026,6 +2814,7 @@ function CallControls({ onDataChange }) {
3026
2814
  const [processList, setProcessList] = (0, import_react11.useState)(null);
3027
2815
  const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
3028
2816
  const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
2817
+ const [callWrapuptime, setCallWrapuptime] = (0, import_react11.useState)(null);
3029
2818
  const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
3030
2819
  state.controlPanelPosition,
3031
2820
  (newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
@@ -3049,17 +2838,11 @@ function CallControls({ onDataChange }) {
3049
2838
  const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest({
3050
2839
  onSuccess: () => {
3051
2840
  sdkStateManager.setHolding(!state.isHolding);
3052
- },
3053
- onError: (error) => {
3054
- console.log("\u274C Hold operation error:", error);
3055
2841
  }
3056
2842
  });
3057
2843
  const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest({
3058
2844
  onSuccess: () => {
3059
2845
  sdkStateManager.setMuted(!state.isMuted);
3060
- },
3061
- onError: (error) => {
3062
- console.log("\u274C Mute operation error:", error);
3063
2846
  }
3064
2847
  });
3065
2848
  const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
@@ -3231,6 +3014,7 @@ function CallControls({ onDataChange }) {
3231
3014
  }, []);
3232
3015
  (0, import_react11.useEffect)(() => {
3233
3016
  let interval;
3017
+ let wrapUpinterval;
3234
3018
  if (state.callData.status && state.callData.status === "ONCALL") {
3235
3019
  interval = setInterval(() => {
3236
3020
  const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
@@ -3239,8 +3023,28 @@ function CallControls({ onDataChange }) {
3239
3023
  } else {
3240
3024
  setCallDuration(0);
3241
3025
  }
3026
+ if (state.callData.status && state.callData.status === "WRAPUP" && callWrapuptime !== null) {
3027
+ wrapUpinterval = setInterval(() => {
3028
+ setCallWrapuptime((prevTime) => {
3029
+ if (prevTime === null || prevTime <= 1) {
3030
+ clearInterval(wrapUpinterval);
3031
+ handleEndCall({
3032
+ disposition: { label: "Resolved", value: "RES" },
3033
+ followUp: { label: "No", value: "N" },
3034
+ callbackDate: "",
3035
+ callbackHrs: "",
3036
+ callbackMins: "",
3037
+ selected_break: false
3038
+ });
3039
+ return null;
3040
+ }
3041
+ return prevTime - 1;
3042
+ });
3043
+ }, 1e3);
3044
+ }
3242
3045
  return () => {
3243
3046
  if (interval) clearInterval(interval);
3047
+ if (wrapUpinterval) clearInterval(wrapUpinterval);
3244
3048
  };
3245
3049
  }, [state.callData.status]);
3246
3050
  (0, import_react11.useEffect)(() => {
@@ -3291,13 +3095,10 @@ function CallControls({ onDataChange }) {
3291
3095
  }).catch((err) => {
3292
3096
  showToast(err.response.data.message, "error");
3293
3097
  });
3294
- } else {
3295
- console.log("No agentId available, skipping API call");
3296
3098
  }
3297
3099
  }, [state.agentId]);
3298
3100
  const connectWebSocket = () => {
3299
3101
  if (!state.agentId) {
3300
- console.log("No agentId available, cannot connect WebSocket");
3301
3102
  return;
3302
3103
  }
3303
3104
  if (reconnectTimeoutRef.current) {
@@ -3316,7 +3117,6 @@ function CallControls({ onDataChange }) {
3316
3117
  if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) {
3317
3118
  try {
3318
3119
  webSocketRef.current.send(JSON.stringify({ type: "ping" }));
3319
- console.log("\u{1F4E1} WebSocket ping sent");
3320
3120
  } catch (error) {
3321
3121
  console.error("Failed to send ping:", error);
3322
3122
  }
@@ -3324,14 +3124,14 @@ function CallControls({ onDataChange }) {
3324
3124
  }, 3e4);
3325
3125
  };
3326
3126
  webSocketRef.current.onmessage = (event) => {
3127
+ var _a3, _b2, _c2;
3327
3128
  try {
3328
3129
  const data = JSON.parse(event.data);
3329
3130
  if (data.type === "pong") {
3330
- console.log("\u{1F4E1} WebSocket pong received");
3331
3131
  return;
3332
3132
  }
3333
- const rls = localStorage.getItem("call-control-sdk-state");
3334
- const confrence = getCombineConfrenceData(JSON.parse(rls || "{}"), data);
3133
+ const rls = JSON.parse((_a3 = localStorage.getItem("call-control-sdk-state")) != null ? _a3 : "{}");
3134
+ const confrence = getCombineConfrenceData(rls, data);
3335
3135
  sdkStateManager.updateCallData(data);
3336
3136
  sdkStateManager.updateConferenceData([...confrence]);
3337
3137
  if ((data.status === "RINGING" || data.status === "DIALING") && (data == null ? void 0 : data.mode) !== "manual") {
@@ -3401,6 +3201,7 @@ function CallControls({ onDataChange }) {
3401
3201
  }
3402
3202
  if (data.status === "ONCALL") {
3403
3203
  sdkStateManager.startCall();
3204
+ setCallWrapuptime((_c2 = (_b2 = rls == null ? void 0 : rls.sdkConfig) == null ? void 0 : _b2.auto_wrapup_time) != null ? _c2 : null);
3404
3205
  if (!showIframe) {
3405
3206
  setShowIframe(true);
3406
3207
  }
@@ -3409,11 +3210,10 @@ function CallControls({ onDataChange }) {
3409
3210
  sdkStateManager.endCall();
3410
3211
  }
3411
3212
  } catch (e) {
3412
- console.log("\u{1F4E8} Raw message:", event.data);
3213
+ console.error("\u{1F4E8} Raw message:", event.data);
3413
3214
  }
3414
3215
  };
3415
3216
  webSocketRef.current.onclose = (event) => {
3416
- console.log("\u{1F50C} WebSocket connection closed", event.code, event.reason);
3417
3217
  if (pingIntervalRef.current) {
3418
3218
  clearInterval(pingIntervalRef.current);
3419
3219
  pingIntervalRef.current = null;
@@ -3424,14 +3224,13 @@ function CallControls({ onDataChange }) {
3424
3224
  baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3425
3225
  maxReconnectDelay
3426
3226
  );
3427
- console.log(
3227
+ console.warn(
3428
3228
  `\u{1F504} Attempting to reconnect WebSocket (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts}) in ${delay}ms`
3429
3229
  );
3430
3230
  reconnectTimeoutRef.current = setTimeout(() => {
3431
3231
  connectWebSocket();
3432
3232
  }, delay);
3433
3233
  } else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
3434
- console.error("\u274C Maximum reconnection attempts reached. Please refresh the page.");
3435
3234
  showToast("WebSocket connection failed. Please refresh the page.", "error");
3436
3235
  }
3437
3236
  };
@@ -3439,7 +3238,6 @@ function CallControls({ onDataChange }) {
3439
3238
  console.error("\u274C WebSocket error:", error);
3440
3239
  };
3441
3240
  } catch (error) {
3442
- console.error("\u274C Failed to create WebSocket:", error);
3443
3241
  if (reconnectAttemptsRef.current < maxReconnectAttempts) {
3444
3242
  reconnectAttemptsRef.current += 1;
3445
3243
  const delay = Math.min(
@@ -3592,7 +3390,7 @@ function CallControls({ onDataChange }) {
3592
3390
  fontWeight: "600",
3593
3391
  cursor: "pointer"
3594
3392
  },
3595
- children: formatDuration(callDuration)
3393
+ children: state.callData.status === "WRAPUP" && callWrapuptime !== null ? formatDuration(callWrapuptime) : formatDuration(callDuration)
3596
3394
  }
3597
3395
  ) }),
3598
3396
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -4142,7 +3940,7 @@ async function initSDK({
4142
3940
  baseUrl: BASE_URL
4143
3941
  });
4144
3942
  if (initResult) {
4145
- console.log("SDK initialized successfully");
3943
+ console.info("SDK initialized successfully");
4146
3944
  sdkStateManager.initialize(
4147
3945
  apiKey.trim(),
4148
3946
  tenantId.trim(),
@@ -4151,14 +3949,12 @@ async function initSDK({
4151
3949
  initResult
4152
3950
  );
4153
3951
  } else {
4154
- console.error("SDK initialization failed: Event tracker initialization returned false");
4155
3952
  sdkStateManager.setInitCheck();
4156
3953
  throw new Error(
4157
3954
  "SDK initialization failed: Unable to establish connection with the CTI system"
4158
3955
  );
4159
3956
  }
4160
3957
  } catch (error) {
4161
- console.error("SDK initialization error:", error);
4162
3958
  sdkStateManager.setInitCheck();
4163
3959
  if (error instanceof Error) {
4164
3960
  throw error;