@tmsoft/webphone 5.0.9 → 5.0.10

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.
@@ -7094,7 +7094,7 @@ var concatArrays = (e, t) => {
7094
7094
  "max",
7095
7095
  "fit",
7096
7096
  ...O()
7097
- ], dm = () => [
7097
+ ], pm = () => [
7098
7098
  isFraction,
7099
7099
  "screen",
7100
7100
  "full",
@@ -7121,7 +7121,7 @@ var concatArrays = (e, t) => {
7121
7121
  e,
7122
7122
  isArbitraryVariable,
7123
7123
  isArbitraryValue
7124
- ], fm = () => [
7124
+ ], mm = () => [
7125
7125
  ...w(),
7126
7126
  isArbitraryVariablePosition,
7127
7127
  isArbitraryPosition,
@@ -7155,12 +7155,12 @@ var concatArrays = (e, t) => {
7155
7155
  isNumber,
7156
7156
  isArbitraryVariableLength,
7157
7157
  isArbitraryLength
7158
- ], pm = () => [
7158
+ ], hm = () => [
7159
7159
  "solid",
7160
7160
  "dashed",
7161
7161
  "dotted",
7162
7162
  "double"
7163
- ], mm = () => [
7163
+ ], gm = () => [
7164
7164
  "normal",
7165
7165
  "multiply",
7166
7166
  "screen",
@@ -7188,7 +7188,7 @@ var concatArrays = (e, t) => {
7188
7188
  _,
7189
7189
  isArbitraryVariable,
7190
7190
  isArbitraryValue
7191
- ], hm = () => [
7191
+ ], _m = () => [
7192
7192
  "none",
7193
7193
  isNumber,
7194
7194
  isArbitraryVariable,
@@ -7491,9 +7491,9 @@ var concatArrays = (e, t) => {
7491
7491
  "space-y": [{ "space-y": O() }],
7492
7492
  "space-y-reverse": ["space-y-reverse"],
7493
7493
  size: [{ size: L() }],
7494
- "inline-size": [{ inline: ["auto", ...dm()] }],
7495
- "min-inline-size": [{ "min-inline": ["auto", ...dm()] }],
7496
- "max-inline-size": [{ "max-inline": ["none", ...dm()] }],
7494
+ "inline-size": [{ inline: ["auto", ...pm()] }],
7495
+ "min-inline-size": [{ "min-inline": ["auto", ...pm()] }],
7496
+ "max-inline-size": [{ "max-inline": ["none", ...pm()] }],
7497
7497
  "block-size": [{ block: ["auto", ...R()] }],
7498
7498
  "min-block-size": [{ "min-block": ["auto", ...R()] }],
7499
7499
  "max-block-size": [{ "max-block": ["none", ...R()] }],
@@ -7611,7 +7611,7 @@ var concatArrays = (e, t) => {
7611
7611
  "line-through",
7612
7612
  "no-underline"
7613
7613
  ],
7614
- "text-decoration-style": [{ decoration: [...pm(), "wavy"] }],
7614
+ "text-decoration-style": [{ decoration: [...hm(), "wavy"] }],
7615
7615
  "text-decoration-thickness": [{ decoration: [
7616
7616
  isNumber,
7617
7617
  "from-font",
@@ -7701,7 +7701,7 @@ var concatArrays = (e, t) => {
7701
7701
  "padding",
7702
7702
  "content"
7703
7703
  ] }],
7704
- "bg-position": [{ bg: fm() }],
7704
+ "bg-position": [{ bg: mm() }],
7705
7705
  "bg-repeat": [{ bg: B() }],
7706
7706
  "bg-size": [{ bg: V() }],
7707
7707
  "bg-image": [{ bg: [
@@ -7774,12 +7774,12 @@ var concatArrays = (e, t) => {
7774
7774
  "divide-y": [{ "divide-y": W() }],
7775
7775
  "divide-y-reverse": ["divide-y-reverse"],
7776
7776
  "border-style": [{ border: [
7777
- ...pm(),
7777
+ ...hm(),
7778
7778
  "hidden",
7779
7779
  "none"
7780
7780
  ] }],
7781
7781
  "divide-style": [{ divide: [
7782
- ...pm(),
7782
+ ...hm(),
7783
7783
  "hidden",
7784
7784
  "none"
7785
7785
  ] }],
@@ -7796,7 +7796,7 @@ var concatArrays = (e, t) => {
7796
7796
  "border-color-l": [{ "border-l": z() }],
7797
7797
  "divide-color": [{ divide: z() }],
7798
7798
  "outline-style": [{ outline: [
7799
- ...pm(),
7799
+ ...hm(),
7800
7800
  "none",
7801
7801
  "hidden"
7802
7802
  ] }],
@@ -7847,11 +7847,11 @@ var concatArrays = (e, t) => {
7847
7847
  isArbitraryValue
7848
7848
  ] }],
7849
7849
  "mix-blend": [{ "mix-blend": [
7850
- ...mm(),
7850
+ ...gm(),
7851
7851
  "plus-darker",
7852
7852
  "plus-lighter"
7853
7853
  ] }],
7854
- "bg-blend": [{ "bg-blend": mm() }],
7854
+ "bg-blend": [{ "bg-blend": gm() }],
7855
7855
  "mask-clip": [{ "mask-clip": [
7856
7856
  "border",
7857
7857
  "padding",
@@ -7924,7 +7924,7 @@ var concatArrays = (e, t) => {
7924
7924
  "stroke",
7925
7925
  "view"
7926
7926
  ] }],
7927
- "mask-position": [{ mask: fm() }],
7927
+ "mask-position": [{ mask: mm() }],
7928
7928
  "mask-repeat": [{ mask: B() }],
7929
7929
  "mask-size": [{ mask: V() }],
7930
7930
  "mask-type": [{ "mask-type": ["alpha", "luminance"] }],
@@ -8085,10 +8085,10 @@ var concatArrays = (e, t) => {
8085
8085
  isArbitraryValue
8086
8086
  ] }],
8087
8087
  "perspective-origin": [{ "perspective-origin": T() }],
8088
- rotate: [{ rotate: hm() }],
8089
- "rotate-x": [{ "rotate-x": hm() }],
8090
- "rotate-y": [{ "rotate-y": hm() }],
8091
- "rotate-z": [{ "rotate-z": hm() }],
8088
+ rotate: [{ rotate: _m() }],
8089
+ "rotate-x": [{ "rotate-x": _m() }],
8090
+ "rotate-y": [{ "rotate-y": _m() }],
8091
+ "rotate-z": [{ "rotate-z": _m() }],
8092
8092
  scale: [{ scale: q() }],
8093
8093
  "scale-x": [{ "scale-x": q() }],
8094
8094
  "scale-y": [{ "scale-y": q() }],
@@ -8456,7 +8456,110 @@ const AUTO_ANSWER_STORAGE_KEY = "webphone-auto-answer", isAutoAnswerEnabled = ()
8456
8456
  return !1;
8457
8457
  }
8458
8458
  };
8459
- var QUEUE_NAME_HEADER = "X-Nebula-Queue", QUEUE_ID_HEADER = "X-Nebula-Queue-Id";
8459
+ var sipSharedWorker_default = "/assets/sipSharedWorker-HqRmUaB2.js", SharedWorkerTransport = class {
8460
+ serverUrl;
8461
+ keepAliveInterval;
8462
+ clientId;
8463
+ connectionId;
8464
+ stateEventEmitter = new EmitterImpl();
8465
+ port;
8466
+ currentState = TransportState.Disconnected;
8467
+ connectPromise;
8468
+ connectResolve;
8469
+ connectReject;
8470
+ connectTimeout;
8471
+ onConnect;
8472
+ onDisconnect;
8473
+ onMessage;
8474
+ constructor(e, t) {
8475
+ this.serverUrl = t.server, this.keepAliveInterval = t.keepAliveInterval ?? 30, this.clientId = t.clientId, this.connectionId = t.connectionId;
8476
+ let n = new SharedWorker(sipSharedWorker_default, { name: `webphone-sip-${this.connectionId}` });
8477
+ this.port = n.port, n.addEventListener("error", (e) => {
8478
+ this.handle({
8479
+ type: "error",
8480
+ error: e.message || "SharedWorker failed to load"
8481
+ });
8482
+ }), this.port.addEventListener("message", (e) => this.handle(e.data)), this.port.start();
8483
+ }
8484
+ get protocol() {
8485
+ return new URL(this.serverUrl).protocol.replace(":", "").toUpperCase();
8486
+ }
8487
+ get server() {
8488
+ return this.serverUrl;
8489
+ }
8490
+ get state() {
8491
+ return this.currentState;
8492
+ }
8493
+ get stateChange() {
8494
+ return this.stateEventEmitter;
8495
+ }
8496
+ isConnected() {
8497
+ return this.currentState === TransportState.Connected;
8498
+ }
8499
+ connect() {
8500
+ return this.isConnected() ? Promise.resolve() : this.connectPromise ? this.connectPromise : (this.transition(TransportState.Connecting), this.connectPromise = new Promise((e, t) => {
8501
+ this.connectResolve = e, this.connectReject = t;
8502
+ }), this.connectTimeout = setTimeout(() => {
8503
+ if (this.currentState !== TransportState.Connecting) return;
8504
+ let e = /* @__PURE__ */ Error(`SharedWorker did not connect to ${this.serverUrl}`);
8505
+ this.transition(TransportState.Disconnected), this.connectReject?.(e), this.clearPromise();
8506
+ }, 1e4), this.post({
8507
+ type: "connect",
8508
+ clientId: this.clientId,
8509
+ connectionId: this.connectionId,
8510
+ server: this.serverUrl,
8511
+ keepAliveInterval: this.keepAliveInterval
8512
+ }), this.connectPromise);
8513
+ }
8514
+ async disconnect() {
8515
+ this.currentState !== TransportState.Disconnected && (this.transition(TransportState.Disconnecting), this.connectReject?.(/* @__PURE__ */ Error("SharedWorker WebSocket disconnected")), this.clearPromise(), this.post({
8516
+ type: "disconnect",
8517
+ clientId: this.clientId,
8518
+ connectionId: this.connectionId
8519
+ }), this.transition(TransportState.Disconnected));
8520
+ }
8521
+ async dispose() {
8522
+ await this.disconnect(), this.port.close();
8523
+ }
8524
+ send(e) {
8525
+ return this.isConnected() ? (this.post({
8526
+ type: "send",
8527
+ clientId: this.clientId,
8528
+ connectionId: this.connectionId,
8529
+ data: e
8530
+ }), Promise.resolve()) : Promise.reject(/* @__PURE__ */ Error("SharedWorker WebSocket is not connected"));
8531
+ }
8532
+ post(e) {
8533
+ this.port.postMessage(e);
8534
+ }
8535
+ handle(e) {
8536
+ switch (e.type) {
8537
+ case "connected":
8538
+ this.transition(TransportState.Connected), this.connectResolve?.(), this.clearPromise(), this.onConnect?.();
8539
+ break;
8540
+ case "message":
8541
+ this.isConnected() && this.onMessage?.(e.data);
8542
+ break;
8543
+ case "error":
8544
+ if (this.currentState === TransportState.Connecting) {
8545
+ let t = Error(e.error);
8546
+ this.transition(TransportState.Disconnected), this.connectReject?.(t), this.clearPromise();
8547
+ }
8548
+ break;
8549
+ case "disconnected": {
8550
+ let t = this.isConnected(), n = e.error ? Error(e.error) : void 0;
8551
+ this.transition(TransportState.Disconnected), this.connectReject && (this.connectReject(n ?? /* @__PURE__ */ Error("SharedWorker WebSocket disconnected")), this.clearPromise()), t && this.onDisconnect?.(n);
8552
+ break;
8553
+ }
8554
+ }
8555
+ }
8556
+ clearPromise() {
8557
+ this.connectTimeout && clearTimeout(this.connectTimeout), this.connectTimeout = void 0, this.connectPromise = void 0, this.connectResolve = void 0, this.connectReject = void 0;
8558
+ }
8559
+ transition(e) {
8560
+ this.currentState !== e && (this.currentState = e, this.stateEventEmitter.emit(e));
8561
+ }
8562
+ }, QUEUE_NAME_HEADER = "X-Nebula-Queue", QUEUE_ID_HEADER = "X-Nebula-Queue-Id";
8460
8563
  const createSipService = (e, t = {}) => {
8461
8564
  let n = shallowRef(null), i = shallowRef(null), a = shallowRef(/* @__PURE__ */ new Map()), o = new Audio();
8462
8565
  o.autoplay = !0;
@@ -8499,14 +8602,14 @@ const createSipService = (e, t = {}) => {
8499
8602
  localStream: s,
8500
8603
  remoteStream: l
8501
8604
  }));
8502
- }, dm = (e) => {
8605
+ }, pm = (e) => {
8503
8606
  f.delete(e), p.delete(e), m.delete(e);
8504
8607
  }, R = (n, i) => {
8505
8608
  if (a.value.get(n) !== i) return;
8506
8609
  let o = g.get(i);
8507
8610
  o && clearTimeout(o), g.delete(i);
8508
8611
  let s = e.channels.value.find((e) => e.id === n), l = f.get(n), u = m.has(n) || s?.status === "connected";
8509
- dm(n), a.value.delete(n), e.updateChannelState(n, {
8612
+ pm(n), a.value.delete(n), e.updateChannelState(n, {
8510
8613
  status: "idle",
8511
8614
  remoteNumber: "",
8512
8615
  remoteDisplayName: void 0,
@@ -8542,9 +8645,9 @@ const createSipService = (e, t = {}) => {
8542
8645
  }
8543
8646
  }, z = (e, t) => {
8544
8647
  g.has(t) || g.set(t, setTimeout(() => {
8545
- console.warn("[SipJs] Hangup did not terminate; releasing local call state"), fm(t), R(e, t);
8648
+ console.warn("[SipJs] Hangup did not terminate; releasing local call state"), mm(t), R(e, t);
8546
8649
  }, 5e3));
8547
- }, fm = (e) => {
8650
+ }, mm = (e) => {
8548
8651
  if (e.state !== SessionState.Terminated) try {
8549
8652
  e.dispose().catch((e) => {
8550
8653
  console.warn("[SipJs] Session disposal failed:", e);
@@ -8555,12 +8658,12 @@ const createSipService = (e, t = {}) => {
8555
8658
  }, B = () => {
8556
8659
  e.channels.value.some((e) => e.status === "incoming") && !isAutoAnswerEnabled() ? T() : E(), e.activeChannel.value?.status === "calling" ? D() : O();
8557
8660
  }, V = async (e, t, n) => {
8558
- await k(), isAutoAnswerEnabled() && a.value.get(e) === t && t.state === SessionState.Initial && await xm(n);
8661
+ await k(), isAutoAnswerEnabled() && a.value.get(e) === t && t.state === SessionState.Initial && await Cm(n);
8559
8662
  }, H = (e) => {
8560
8663
  o.volume = e / 100;
8561
8664
  }, U = async (e) => {
8562
8665
  typeof o.setSinkId == "function" && await o.setSinkId(e);
8563
- }, pm = async (t) => {
8666
+ }, hm = async (t) => {
8564
8667
  if (!t) return;
8565
8668
  let n = [...a.value.entries()].flatMap(([e, t]) => {
8566
8669
  let n = t.sessionDescriptionHandler, i = n?.peerConnection?.getSenders().find((e) => e.track?.kind === "audio");
@@ -8615,7 +8718,7 @@ const createSipService = (e, t = {}) => {
8615
8718
  } catch (e) {
8616
8719
  await Promise.allSettled(o.map(({ sender: e, previousTrack: t }) => e.replaceTrack(t))), i.forEach((e) => e.getTracks().forEach((e) => e.stop())), console.warn("[SipJs] Failed to switch microphone:", e);
8617
8720
  }
8618
- }, mm = (e, t) => {
8721
+ }, gm = (e, t) => {
8619
8722
  let n = !1, i = e.sessionDescriptionHandler;
8620
8723
  return i?.peerConnection && i.peerConnection.getSenders().forEach((e) => {
8621
8724
  e.track && e.track.kind === "audio" && (e.track.enabled = t, n = !0);
@@ -8626,15 +8729,15 @@ const createSipService = (e, t = {}) => {
8626
8729
  n.enabled = e, t = !0;
8627
8730
  }), t;
8628
8731
  }, K = (e, t) => {
8629
- let n = !(t?.isHeld || t?.isMuted), i = mm(e, n), a = G(n);
8732
+ let n = !(t?.isHeld || t?.isMuted), i = gm(e, n), a = G(n);
8630
8733
  !i && !a && console.warn("[SipJs] No audio tracks found to apply channel audio state");
8631
- }, hm = (t) => {
8734
+ }, _m = (t) => {
8632
8735
  for (let [n, i] of a.value.entries()) if (i === t) return e.channels.value.find((e) => e.id === n) || null;
8633
8736
  return e.activeChannel.value || null;
8634
8737
  }, q = async (e) => {
8635
8738
  let t = e.sessionDescriptionHandler?.peerConnection;
8636
8739
  if (!t) return;
8637
- let n = hm(e), i = !(n?.isHeld || n?.isMuted), o = t.getSenders().find((e) => e.track?.kind === "audio");
8740
+ let n = _m(e), i = !(n?.isHeld || n?.isMuted), o = t.getSenders().find((e) => e.track?.kind === "audio");
8638
8741
  if (o?.track) {
8639
8742
  o.track.enabled = i, n && L(e, n.id);
8640
8743
  return;
@@ -8676,7 +8779,7 @@ const createSipService = (e, t = {}) => {
8676
8779
  e.setConnected(!1);
8677
8780
  }
8678
8781
  } });
8679
- }, gm = async (t) => {
8782
+ }, vm = async (t) => {
8680
8783
  if (!n.value) {
8681
8784
  try {
8682
8785
  (await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop());
@@ -8687,13 +8790,14 @@ const createSipService = (e, t = {}) => {
8687
8790
  try {
8688
8791
  let a = UserAgent.makeURI(t.uri);
8689
8792
  if (!a) throw Error("Invalid URI");
8690
- _ = t.earlyMedia ?? !1, n.value = new UserAgent({
8793
+ _ = t.earlyMedia ?? !1;
8794
+ let o = {
8795
+ server: t.transportOptions.server,
8796
+ keepAliveInterval: t.transportOptions.keepAliveInterval ?? 30
8797
+ }, s = {
8691
8798
  uri: a,
8692
8799
  logLevel: "error",
8693
- transportOptions: {
8694
- server: t.transportOptions.server,
8695
- keepAliveInterval: t.transportOptions.keepAliveInterval ?? 30
8696
- },
8800
+ transportOptions: o,
8697
8801
  authorizationUsername: t.authorizationUsername,
8698
8802
  authorizationPassword: t.authorizationPassword,
8699
8803
  reconnectionDelay: 5,
@@ -8701,16 +8805,50 @@ const createSipService = (e, t = {}) => {
8701
8805
  delegate: {
8702
8806
  onConnect: () => {},
8703
8807
  onDisconnect: () => e.setConnected(!1),
8704
- onInvite: (e) => bm(e)
8808
+ onInvite: (e) => Sm(e)
8705
8809
  }
8706
- }), await n.value.start(), i.value = new Registerer(n.value), await Y(), _m();
8707
- } catch {}
8810
+ }, l = typeof SharedWorker < "u", u = l;
8811
+ l && (s.transportConstructor = SharedWorkerTransport, s.transportOptions = {
8812
+ ...o,
8813
+ clientId: crypto.randomUUID(),
8814
+ connectionId: `${t.transportOptions.server}|${t.uri}|${crypto.randomUUID()}`
8815
+ });
8816
+ try {
8817
+ n.value = new UserAgent(s);
8818
+ } catch (e) {
8819
+ if (!l) throw e;
8820
+ u = !1, console.warn("[SipJs] SharedWorker unavailable, using native WebSocket transport", e), delete s.transportConstructor, s.transportOptions = o, n.value = new UserAgent(s);
8821
+ }
8822
+ try {
8823
+ await n.value.start(), i.value = new Registerer(n.value), await Y();
8824
+ } catch (e) {
8825
+ if (!u) throw e;
8826
+ console.warn("[SipJs] SharedWorker connection failed, retrying with native WebSocket", e);
8827
+ let t = n.value;
8828
+ n.value = null, i.value = null;
8829
+ try {
8830
+ await t?.stop();
8831
+ } catch (e) {
8832
+ console.warn("[SipJs] Failed to clean up SharedWorker transport", e);
8833
+ }
8834
+ delete s.transportConstructor, s.transportOptions = o, n.value = new UserAgent(s), await n.value.start(), i.value = new Registerer(n.value), await Y();
8835
+ }
8836
+ ym();
8837
+ } catch (e) {
8838
+ console.error("[SipJs] Failed to initialize WSS/SIP connection", e);
8839
+ let t = n.value;
8840
+ if (n.value = null, i.value = null, t !== null) try {
8841
+ await t.stop();
8842
+ } catch (e) {
8843
+ console.warn("[SipJs] Failed to clean up after connection error", e);
8844
+ }
8845
+ }
8708
8846
  }
8709
- }, _m = () => {
8847
+ }, ym = () => {
8710
8848
  b = new AbortController();
8711
8849
  let { signal: t } = b, n = Date.now(), i = (e = 1e3) => {
8712
8850
  x && clearTimeout(x), x = setTimeout(async () => {
8713
- x = null, await vm();
8851
+ x = null, await bm();
8714
8852
  }, e);
8715
8853
  }, a = () => {
8716
8854
  if (document.visibilityState === "visible") {
@@ -8733,7 +8871,7 @@ const createSipService = (e, t = {}) => {
8733
8871
  }, { signal: t }), document.addEventListener("resume", () => {
8734
8872
  console.log("[SipJs] Page resumed"), n = Date.now(), l(), i(1e3);
8735
8873
  }, { signal: t }), l();
8736
- }, vm = async () => {
8874
+ }, bm = async () => {
8737
8875
  if (n.value) {
8738
8876
  if (!navigator.onLine) {
8739
8877
  console.log("[SipJs] Skipping reconnect, device is offline");
@@ -8751,12 +8889,12 @@ const createSipService = (e, t = {}) => {
8751
8889
  console.error("[SipJs] Reconnection failed:", e);
8752
8890
  }
8753
8891
  }
8754
- }, ym = async () => {
8892
+ }, xm = async () => {
8755
8893
  b?.abort(), b = null, x &&= (clearTimeout(x), null), S &&= (clearInterval(S), null);
8756
8894
  for (let [e, t] of a.value.entries()) {
8757
8895
  let n;
8758
8896
  try {
8759
- await Promise.race([Sm(e, t), new Promise((e) => {
8897
+ await Promise.race([wm(e, t), new Promise((e) => {
8760
8898
  n = setTimeout(e, 1500);
8761
8899
  })]);
8762
8900
  } finally {
@@ -8775,7 +8913,7 @@ const createSipService = (e, t = {}) => {
8775
8913
  } catch (e) {
8776
8914
  console.warn("[SipJs] UserAgent stop failed:", e);
8777
8915
  }
8778
- }, bm = (t) => {
8916
+ }, Sm = (t) => {
8779
8917
  console.log("[SipJs] 📞 Llamada entrante recibida"), console.log("[SipJs] Remote Identity URI:", t.remoteIdentity.uri.toString()), console.log("[SipJs] Remote Identity URI user:", t.remoteIdentity.uri.user), console.log("[SipJs] Remote Identity displayName:", t.remoteIdentity.displayName);
8780
8918
  let n = e.channels.value.find((e) => e.status === "idle" && !a.value.has(e.id));
8781
8919
  if (!n) {
@@ -8800,7 +8938,7 @@ const createSipService = (e, t = {}) => {
8800
8938
  m.add(i), e.updateChannelState(i, {
8801
8939
  status: "connected",
8802
8940
  startTime: Date.now()
8803
- }), I(i, "connected"), e.activeChannelId.value === i && (Nm(t), q(t).then(() => L(t, i))), B();
8941
+ }), I(i, "connected"), e.activeChannelId.value === i && (Fm(t), q(t).then(() => L(t, i))), B();
8804
8942
  break;
8805
8943
  }
8806
8944
  });
@@ -8826,7 +8964,7 @@ const createSipService = (e, t = {}) => {
8826
8964
  m.add(o), e.channels.value.find((e) => e.id === o)?.status !== "connected" && (e.updateChannelState(o, {
8827
8965
  status: "connected",
8828
8966
  startTime: Date.now()
8829
- }), I(o, "connected"), Nm(l), q(l).then(() => L(l, o)), B());
8967
+ }), I(o, "connected"), Fm(l), q(l).then(() => L(l, o)), B());
8830
8968
  break;
8831
8969
  case SessionState.Terminated:
8832
8970
  R(o, l);
@@ -8837,13 +8975,13 @@ const createSipService = (e, t = {}) => {
8837
8975
  sessionDescriptionHandlerOptions: { constraints: J(i) },
8838
8976
  requestDelegate: {
8839
8977
  onProgress: (t) => {
8840
- a.value.get(o) === l && (t.message.statusCode === 180 || t.message.statusCode === 183) && (t.message.body && (e.updateChannelState(o, { hasEarlyMedia: !0 }), Nm(l)), B());
8978
+ a.value.get(o) === l && (t.message.statusCode === 180 || t.message.statusCode === 183) && (t.message.body && (e.updateChannelState(o, { hasEarlyMedia: !0 }), Fm(l)), B());
8841
8979
  },
8842
8980
  onAccept: (t) => {
8843
8981
  a.value.get(o) === l && e.channels.value.find((e) => e.id === o)?.status !== "connected" && (m.add(o), e.updateChannelState(o, {
8844
8982
  status: "connected",
8845
8983
  startTime: Date.now()
8846
- }), I(o, "connected"), Nm(l), q(l).then(() => L(l, o)), B());
8984
+ }), I(o, "connected"), Fm(l), q(l).then(() => L(l, o)), B());
8847
8985
  }
8848
8986
  }
8849
8987
  };
@@ -8852,7 +8990,7 @@ const createSipService = (e, t = {}) => {
8852
8990
  } catch (e) {
8853
8991
  throw R(o, l), e;
8854
8992
  }
8855
- }, xm = async (t = !1) => {
8993
+ }, Cm = async (t = !1) => {
8856
8994
  let n = e.activeChannelId.value, i = a.value.get(n);
8857
8995
  if (i instanceof Invitation && i.state === SessionState.Initial) {
8858
8996
  E(), e.updateChannelState(n, {
@@ -8878,7 +9016,7 @@ const createSipService = (e, t = {}) => {
8878
9016
  }), B()), t;
8879
9017
  }
8880
9018
  }
8881
- }, Sm = async (e, t) => {
9019
+ }, wm = async (e, t) => {
8882
9020
  z(e, t);
8883
9021
  try {
8884
9022
  switch (t.state) {
@@ -8893,12 +9031,12 @@ const createSipService = (e, t = {}) => {
8893
9031
  } catch (e) {
8894
9032
  console.warn("[SipJs] Hangup signaling failed:", e);
8895
9033
  } finally {
8896
- fm(t), R(e, t);
9034
+ mm(t), R(e, t);
8897
9035
  }
8898
- }, Cm = async () => {
9036
+ }, Tm = async () => {
8899
9037
  let t = e.activeChannelId.value, n = a.value.get(t);
8900
- n && await Sm(t, n);
8901
- }, wm = () => {
9038
+ n && await wm(t, n);
9039
+ }, Em = () => {
8902
9040
  let t = a.value.get(e.activeChannelId.value);
8903
9041
  if (!t) return;
8904
9042
  let n = !e.isMuted.value;
@@ -8906,14 +9044,14 @@ const createSipService = (e, t = {}) => {
8906
9044
  }, Q = async (e, t) => {
8907
9045
  let n = { sessionDescriptionHandlerOptions: { hold: t } };
8908
9046
  await e.invite(n);
8909
- }, Tm = async () => {
9047
+ }, Dm = async () => {
8910
9048
  let t = a.value.get(e.activeChannelId.value);
8911
9049
  if (t?.state !== SessionState.Established) return;
8912
9050
  let n = !e.isHeld.value;
8913
9051
  try {
8914
9052
  await Q(t, n), e.setHeld(n), K(t, e.channels.value.find((t) => t.id === e.activeChannelId.value));
8915
9053
  } catch {}
8916
- }, Em = async (t) => {
9054
+ }, Om = async (t) => {
8917
9055
  let n = e.activeChannelId.value;
8918
9056
  if (n === t) return;
8919
9057
  let i = a.value.get(n), o = a.value.get(t), s = e.channels.value.find((e) => e.id === n), l = e.channels.value.find((e) => e.id === t);
@@ -8924,9 +9062,9 @@ const createSipService = (e, t = {}) => {
8924
9062
  if (l?.isHeld) try {
8925
9063
  await Q(o, !1), e.updateChannelState(t, { isHeld: !1 });
8926
9064
  } catch {}
8927
- K(o, e.channels.value.find((e) => e.id === t)), Nm(o);
9065
+ K(o, e.channels.value.find((e) => e.id === t)), Fm(o);
8928
9066
  } else $();
8929
- }, Dm = (t) => {
9067
+ }, km = (t) => {
8930
9068
  if (!/^[0-9*#]$/.test(t)) return;
8931
9069
  let n = a.value.get(e.activeChannelId.value);
8932
9070
  if (n?.state !== SessionState.Established) return;
@@ -8941,10 +9079,10 @@ const createSipService = (e, t = {}) => {
8941
9079
  contentDisposition: "signal"
8942
9080
  } } };
8943
9081
  n.info(o);
8944
- }, Om = (t, n) => {
9082
+ }, Am = (t, n) => {
8945
9083
  let i = e.channels.value.find((e) => e.id === t);
8946
- !i || i.status !== "connected" || (Nm(n), K(n, i), q(n), o.play().catch(() => {}));
8947
- }, km = async (t) => {
9084
+ !i || i.status !== "connected" || (Fm(n), K(n, i), q(n), o.play().catch(() => {}));
9085
+ }, jm = async (t) => {
8948
9086
  console.log("[SipJs] 🔄 transferCall iniciado"), console.log("[SipJs] Target:", t);
8949
9087
  let i = e.activeChannelId.value, o = a.value.get(i);
8950
9088
  if (!o) throw console.error("[SipJs] ❌ No hay sesión activa en el canal", i), Error("No active session to transfer");
@@ -8964,7 +9102,7 @@ const createSipService = (e, t = {}) => {
8964
9102
  },
8965
9103
  onReject: (e) => {
8966
9104
  let t = e.message.statusCode;
8967
- console.error("[SipJs] ❌ Transfer REFER rechazado:", t), console.error("[SipJs] Response completo:", e.message), Om(i, o);
9105
+ console.error("[SipJs] ❌ Transfer REFER rechazado:", t), console.error("[SipJs] Response completo:", e.message), Am(i, o);
8968
9106
  }
8969
9107
  },
8970
9108
  onNotify: (e) => {
@@ -8987,7 +9125,7 @@ const createSipService = (e, t = {}) => {
8987
9125
  487: "Transferencia cancelada",
8988
9126
  503: "Servicio no disponible - el destino puede estar fuera de línea"
8989
9127
  }[t] || `Error en transferencia (código ${t})`;
8990
- console.warn("[SipJs] 💬", e), Om(i, o);
9128
+ console.warn("[SipJs] 💬", e), Am(i, o);
8991
9129
  } else t >= 100 && t < 200 && console.log("[SipJs] 📞 Transferencia en progreso:", t, n);
8992
9130
  } else console.warn("[SipJs] ⚠️ No se pudo extraer el código de estado del NOTIFY body");
8993
9131
  } else console.warn("[SipJs] ⚠️ NOTIFY sin body");
@@ -8996,7 +9134,7 @@ const createSipService = (e, t = {}) => {
8996
9134
  } catch (e) {
8997
9135
  throw console.error("[SipJs] ❌ Error en transferCall:", e), console.error("[SipJs] Error type:", e?.constructor?.name), console.error("[SipJs] Error message:", e instanceof Error ? e.message : String(e)), console.error("[SipJs] Error stack:", e instanceof Error ? e.stack : "N/A"), e;
8998
9136
  }
8999
- }, Am = async (t) => {
9137
+ }, Mm = async (t) => {
9000
9138
  console.log("[SipJs] 🔄 startAttendedTransfer iniciado"), console.log("[SipJs] Target:", t);
9001
9139
  let n = e.activeChannelId.value, i = a.value.get(n);
9002
9140
  if (console.log("[SipJs] Canal original:", n), console.log("[SipJs] Sesión original:", i?.state), !i || i.state !== SessionState.Established) throw console.error("[SipJs] ❌ No hay llamada establecida para transferir"), Error("No established call to transfer");
@@ -9017,7 +9155,7 @@ const createSipService = (e, t = {}) => {
9017
9155
  } catch (t) {
9018
9156
  throw console.error("[SipJs] ❌ Failed to start consultation call:", t), console.log("[SipJs] 🔄 Volviendo al canal original y quitando hold..."), e.setActiveChannelId(n), await Q(i, !1).catch(() => {}), e.updateChannelState(n, { isHeld: !1 }), Error("Failed to initiate consultation call");
9019
9157
  }
9020
- }, jm = async () => {
9158
+ }, Nm = async () => {
9021
9159
  console.log("[SipJs] 🔄 completeAttendedTransfer iniciado");
9022
9160
  let t = e.transferInProgress.value;
9023
9161
  if (!t) throw console.error("[SipJs] ❌ No hay transferencia en progreso"), Error("No transfer in progress");
@@ -9045,7 +9183,7 @@ const createSipService = (e, t = {}) => {
9045
9183
  if (n && n[1]) {
9046
9184
  let a = parseInt(n[1]);
9047
9185
  a >= 200 && a < 300 ? setTimeout(() => {
9048
- Sm(t.originalChannelId, i), Sm(t.consultationChannelId, o), e.setTransferInProgress(null);
9186
+ wm(t.originalChannelId, i), wm(t.consultationChannelId, o), e.setTransferInProgress(null);
9049
9187
  }, 500) : a >= 400 && (console.error("[SipJs] Attended transfer failed with status:", a), e.setTransferInProgress(null));
9050
9188
  }
9051
9189
  }
@@ -9060,13 +9198,13 @@ const createSipService = (e, t = {}) => {
9060
9198
  } catch (e) {
9061
9199
  throw console.error("[SipJs] Attended transfer failed:", e), e;
9062
9200
  }
9063
- }, Mm = async () => {
9201
+ }, Pm = async () => {
9064
9202
  let t = e.transferInProgress.value;
9065
9203
  if (!t) throw Error("No transfer in progress");
9066
9204
  console.log("[SipJs] Canceling attended transfer...");
9067
9205
  let n = a.value.get(t.originalChannelId), i = a.value.get(t.consultationChannelId);
9068
9206
  if (i) try {
9069
- await Sm(t.consultationChannelId, i), console.log("[SipJs] Consultation call ended");
9207
+ await wm(t.consultationChannelId, i), console.log("[SipJs] Consultation call ended");
9070
9208
  } catch (e) {
9071
9209
  console.warn("[SipJs] Error ending consultation:", e);
9072
9210
  }
@@ -9076,7 +9214,7 @@ const createSipService = (e, t = {}) => {
9076
9214
  console.warn("[SipJs] Error resuming original call:", e);
9077
9215
  }
9078
9216
  e.setTransferInProgress(null);
9079
- }, Nm = (e) => {
9217
+ }, Fm = (e) => {
9080
9218
  let t = e.sessionDescriptionHandler;
9081
9219
  if (!t) {
9082
9220
  console.error("[SipJs] setupRemoteMedia: no sessionDescriptionHandler");
@@ -9089,7 +9227,7 @@ const createSipService = (e, t = {}) => {
9089
9227
  }
9090
9228
  if (u.value === n) return;
9091
9229
  o.pause(), o.srcObject = null, v?.abort(), v = new AbortController(), u.value = n, d.value = t.localMediaStream ?? null;
9092
- let i = hm(e);
9230
+ let i = _m(e);
9093
9231
  K(e, i), i && L(e, i.id);
9094
9232
  let a = (e) => {
9095
9233
  y?.abort(), y = new AbortController();
@@ -9111,26 +9249,26 @@ const createSipService = (e, t = {}) => {
9111
9249
  y?.abort(), y = null, v?.abort(), v = null, o.pause(), o.srcObject = null, u.value = null, d.value = null;
9112
9250
  };
9113
9251
  return {
9114
- initUserAgent: gm,
9115
- stop: ym,
9252
+ initUserAgent: vm,
9253
+ stop: xm,
9116
9254
  makeCall: Z,
9117
- answerCall: xm,
9118
- hangupCall: Cm,
9119
- toggleMute: wm,
9120
- toggleHold: Tm,
9121
- sendDTMF: Dm,
9122
- transferCall: km,
9123
- startAttendedTransfer: Am,
9124
- completeAttendedTransfer: jm,
9125
- cancelAttendedTransfer: Mm,
9126
- switchChannel: Em,
9255
+ answerCall: Cm,
9256
+ hangupCall: Tm,
9257
+ toggleMute: Em,
9258
+ toggleHold: Dm,
9259
+ sendDTMF: km,
9260
+ transferCall: jm,
9261
+ startAttendedTransfer: Mm,
9262
+ completeAttendedTransfer: Nm,
9263
+ cancelAttendedTransfer: Pm,
9264
+ switchChannel: Om,
9127
9265
  extension: w,
9128
9266
  setVolume: H,
9129
9267
  setNotificationVolume: A,
9130
9268
  setRingtoneVolume: j,
9131
9269
  setRingtoneTone: M,
9132
9270
  setOutputDevice: U,
9133
- setInputDevice: pm,
9271
+ setInputDevice: hm,
9134
9272
  remoteStream: u,
9135
9273
  localStream: d
9136
9274
  };
@@ -16208,7 +16346,7 @@ var IconDelete_default = { render: render$1 }, _hoisted_1$7 = ["data-call-status
16208
16346
  let n = t.status === "connected" || t.status === "calling" || t.status === "incoming";
16209
16347
  e[t.id] = n ? "wp:text-[var(--color-red)]" : "wp:text-[var(--color-avaible)]";
16210
16348
  }), e;
16211
- }), fm = computed(() => z.value[i.activeChannelId] ?? "wp:text-[var(--p-primary-color)]");
16349
+ }), mm = computed(() => z.value[i.activeChannelId] ?? "wp:text-[var(--p-primary-color)]");
16212
16350
  return (e, t) => (openBlock(), createElementBlock("div", {
16213
16351
  class: "webphone-actions wp:flex wp:justify-center wp:items-center wp:gap-2 wp:px-4 wp:relative wp:mb-4",
16214
16352
  "data-call-status": unref(i).callStatus
@@ -16231,7 +16369,7 @@ var IconDelete_default = { render: render$1 }, _hoisted_1$7 = ["data-call-status
16231
16369
  "aria-label": "Video Call",
16232
16370
  class: "webphone-actions__button webphone-actions__button--video wp:w-full wp:px-4 wp:bg-transparent wp:border wp:border-primary wp:hover:bg-[var(--p-primary-color)]/8"
16233
16371
  }, {
16234
- default: withCtx(() => [createVNode(unref(videocall_icon_default), { class: normalizeClass(["webphone-actions__button-icon wp:size-6 wp:text-primary wp:dark:text-white", fm.value]) }, null, 8, ["class"]), t[13] ||= createElementVNode("span", { class: "webphone-actions__button-label wp:w-full wp:text-primary wp:text-xs wp:dark:text-white" }, " Video llamada a extensiones ", -1)]),
16372
+ default: withCtx(() => [createVNode(unref(videocall_icon_default), { class: normalizeClass(["webphone-actions__button-icon wp:size-6 wp:text-primary wp:dark:text-white", mm.value]) }, null, 8, ["class"]), t[13] ||= createElementVNode("span", { class: "webphone-actions__button-label wp:w-full wp:text-primary wp:text-xs wp:dark:text-white" }, " Video llamada a extensiones ", -1)]),
16235
16373
  _: 1
16236
16374
  })) : createCommentVNode("", !0)])) : createCommentVNode("", !0),
16237
16375
  unref(i).callStatus === "incoming" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
@@ -17297,7 +17435,7 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
17297
17435
  set: (e) => {
17298
17436
  j.value = e[0], y(j.value);
17299
17437
  }
17300
- }), mm = computed({
17438
+ }), gm = computed({
17301
17439
  get: () => [N.value],
17302
17440
  set: (e) => {
17303
17441
  N.value = e[0] ?? 100, b(N.value);
@@ -17404,8 +17542,8 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
17404
17542
  default: withCtx(() => [...o[12] ||= [createTextVNode("Volumen del tono", -1)]]),
17405
17543
  _: 1
17406
17544
  }), createElementVNode("span", _hoisted_12$2, toDisplayString(unref(N)) + "%", 1)]), createVNode(unref(Slider_default), {
17407
- modelValue: mm.value,
17408
- "onUpdate:modelValue": o[4] ||= (e) => mm.value = e,
17545
+ modelValue: gm.value,
17546
+ "onUpdate:modelValue": o[4] ||= (e) => gm.value = e,
17409
17547
  max: 100,
17410
17548
  step: 1
17411
17549
  }, null, 8, ["modelValue"])]),
@@ -17868,7 +18006,7 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
17868
18006
  return i.autoOpenOnBlur !== !1 && e && o.value && t && !l.value && !u.value;
17869
18007
  }, v = () => {
17870
18008
  _() && (g && clearTimeout(g), g = setTimeout(() => {
17871
- _() && dm();
18009
+ _() && pm();
17872
18010
  }, 120));
17873
18011
  }, y = () => {
17874
18012
  v();
@@ -17993,7 +18131,7 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
17993
18131
  }, 1e3));
17994
18132
  }, L = () => {
17995
18133
  m &&= (clearInterval(m), null);
17996
- }, dm = async () => {
18134
+ }, pm = async () => {
17997
18135
  if (!(!o.value || l.value || u.value)) {
17998
18136
  u.value = !0;
17999
18137
  try {
@@ -18017,10 +18155,10 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18017
18155
  L(), d.value && (d.value.close(), d.value = null, l.value = !1, a("update:active", !1));
18018
18156
  };
18019
18157
  return t({
18020
- open: dm,
18158
+ open: pm,
18021
18159
  close: R,
18022
18160
  toggle: () => {
18023
- l.value ? R() : dm();
18161
+ l.value ? R() : pm();
18024
18162
  },
18025
18163
  isActive: l,
18026
18164
  isSupported: o,
@@ -18122,67 +18260,67 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18122
18260
  }
18123
18261
  e !== "idle" && x.isKeypadVisible && x.toggleKeypad();
18124
18262
  });
18125
- let mm = computed(() => x.channels.find((e) => e.id === x.activeChannelId) ?? null), G = (e) => {
18263
+ let gm = computed(() => x.channels.find((e) => e.id === x.activeChannelId) ?? null), G = (e) => {
18126
18264
  if (!e) return "";
18127
18265
  let t = e.trim(), n = t.startsWith("+"), i = t.replace(/[^\d]/g, "");
18128
18266
  return n ? `+${i}` : i;
18129
18267
  }, K = computed(() => {
18130
- let e = mm.value?.remoteNumber || x.remoteNumber, t = G(e), n = o.contacts.find((e) => G(e.number) === t);
18268
+ let e = gm.value?.remoteNumber || x.remoteNumber, t = G(e), n = o.contacts.find((e) => G(e.number) === t);
18131
18269
  return n?.name ? n.name : o.maskNumber && e ? maskPhoneNumber(e) : e || "Llamada";
18132
- }), hm = computed(() => {
18133
- let e = mm.value?.remoteNumber || x.remoteNumber;
18270
+ }), _m = computed(() => {
18271
+ let e = gm.value?.remoteNumber || x.remoteNumber;
18134
18272
  return o.maskNumber ? maskPhoneNumber(e) : e;
18135
- }), q = computed(() => (U.value, !!mm.value?.hasVideo || W(E.value) || W(D.value))), { isOnline: J } = useNetwork(), Y = computed(() => !J.value), _m = ref(null), Z = ref(!1), Cm = computed(() => o.enablePictureInPicture), wm = () => {
18136
- Cm.value && _m.value?.toggle();
18273
+ }), q = computed(() => (U.value, !!gm.value?.hasVideo || W(E.value) || W(D.value))), { isOnline: J } = useNetwork(), Y = computed(() => !J.value), ym = ref(null), Z = ref(!1), Tm = computed(() => o.enablePictureInPicture), Em = () => {
18274
+ Tm.value && ym.value?.toggle();
18137
18275
  }, Q = async (e, t) => {
18138
18276
  try {
18139
18277
  t === "blind" ? await S.transferCall(e) : await S.startAttendedTransfer(e);
18140
18278
  } catch (e) {
18141
18279
  console.error("[WebPhone] Transfer error:", e), alert(e instanceof Error ? e.message : "Transfer failed. Please try again.");
18142
18280
  }
18143
- }, Tm = async () => {
18281
+ }, Dm = async () => {
18144
18282
  try {
18145
18283
  await S.completeAttendedTransfer();
18146
18284
  } catch (e) {
18147
18285
  console.error("[WebPhone] Complete transfer error:", e), alert(e instanceof Error ? e.message : "Failed to complete transfer.");
18148
18286
  }
18149
- }, Em = async () => {
18287
+ }, Om = async () => {
18150
18288
  try {
18151
18289
  await S.cancelAttendedTransfer();
18152
18290
  } catch (e) {
18153
18291
  console.error("[WebPhone] Cancel transfer error:", e), alert(e instanceof Error ? e.message : "Failed to cancel transfer.");
18154
18292
  }
18155
- }, Dm = (e) => {
18293
+ }, km = (e) => {
18156
18294
  x.keypadValue = e, S.makeCall(e);
18157
- }, Om = (e) => {
18295
+ }, Am = (e) => {
18158
18296
  if (o.onAnswer) {
18159
18297
  o.onAnswer(e);
18160
18298
  return;
18161
18299
  }
18162
18300
  S.answerCall(e);
18163
- }, km = async () => {
18301
+ }, jm = async () => {
18164
18302
  await S.hangupCall(), await o.onHangup?.();
18165
- }, Am = () => {
18303
+ }, Mm = () => {
18166
18304
  if (o.onReject) {
18167
18305
  o.onReject();
18168
18306
  return;
18169
18307
  }
18170
18308
  S.hangupCall();
18171
- }, jm = () => {
18172
- j.value = !0, _m.value?.close(), window.focus();
18173
- }, Mm = () => {
18174
- if (!Cm.value) return !1;
18309
+ }, Nm = () => {
18310
+ j.value = !0, ym.value?.close(), window.focus();
18311
+ }, Pm = () => {
18312
+ if (!Tm.value) return !1;
18175
18313
  let e = x.callStatus !== "idle", t = document.hidden || !document.hasFocus();
18176
18314
  return e && t && !Z.value;
18177
18315
  }, $ = () => {
18178
18316
  window.setTimeout(() => {
18179
- Mm() && _m.value?.open();
18317
+ Pm() && ym.value?.open();
18180
18318
  }, 150);
18181
18319
  };
18182
18320
  watchEffect(() => {
18183
18321
  F.value && (Z.value || !E.value ? F.value.srcObject = null : F.value.srcObject = E.value), L.value && (Z.value || !D.value ? L.value.srcObject = null : L.value.srcObject = D.value);
18184
18322
  });
18185
- let Pm = (e) => {
18323
+ let Im = (e) => {
18186
18324
  if (!e || typeof e.addEventListener != "function" || typeof e.removeEventListener != "function") return () => {};
18187
18325
  let t = () => {
18188
18326
  U.value += 1;
@@ -18192,11 +18330,11 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18192
18330
  };
18193
18331
  };
18194
18332
  watch(E, (e, t, n) => {
18195
- U.value += 1, n(Pm(e));
18333
+ U.value += 1, n(Im(e));
18196
18334
  }, { immediate: !0 }), watch(D, (e, t, n) => {
18197
- U.value += 1, n(Pm(e));
18335
+ U.value += 1, n(Im(e));
18198
18336
  }, { immediate: !0 });
18199
- let Fm = [
18337
+ let Lm = [
18200
18338
  "button",
18201
18339
  "a",
18202
18340
  "input",
@@ -18207,15 +18345,15 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18207
18345
  "[role=\"button\"]",
18208
18346
  "[role=\"radio\"]",
18209
18347
  "[data-no-drag]"
18210
- ].join(", "), Im = () => {
18348
+ ].join(", "), Rm = () => {
18211
18349
  let e = window.innerWidth < 640, t = window.innerWidth < 1024, n = 360;
18212
18350
  return e ? n = window.innerWidth * .9 : t && (n = 340), {
18213
18351
  x: Math.max(0, (window.innerWidth - n) / 2),
18214
18352
  y: e ? 30 : 80
18215
18353
  };
18216
- }, { x: Lm, y: Rm, style: zm } = useDraggable(N, {
18354
+ }, { x: zm, y: Bm, style: Vm } = useDraggable(N, {
18217
18355
  initialValue: computed(() => {
18218
- let e = Im();
18356
+ let e = Rm();
18219
18357
  return {
18220
18358
  x: o.position.x ?? e.x,
18221
18359
  y: o.position.y ?? e.y
@@ -18224,14 +18362,14 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18224
18362
  preventDefault: !0,
18225
18363
  onStart: (e, t) => {
18226
18364
  let n = t.target;
18227
- if (n instanceof HTMLElement && n.closest(Fm)) return !1;
18365
+ if (n instanceof HTMLElement && n.closest(Lm)) return !1;
18228
18366
  }
18229
18367
  });
18230
18368
  watch(() => o.position, (e) => {
18231
- let t = Im();
18232
- Lm.value = e.x ?? t.x, Rm.value = e.y ?? t.y;
18369
+ let t = Rm();
18370
+ zm.value = e.x ?? t.x, Bm.value = e.y ?? t.y;
18233
18371
  }, { deep: !0 });
18234
- let Bm = [
18372
+ let Hm = [
18235
18373
  {
18236
18374
  label: "Canal 1",
18237
18375
  value: 0
@@ -18244,27 +18382,27 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18244
18382
  label: "Canal 3",
18245
18383
  value: 2
18246
18384
  }
18247
- ], Vm = ref(!1), Hm = computed({
18385
+ ], Um = ref(!1), Wm = computed({
18248
18386
  get: () => x.activeChannelId.toString(),
18249
18387
  set: async (e) => {
18250
- if (!Y.value && e && !Vm.value) {
18251
- Vm.value = !0;
18388
+ if (!Y.value && e && !Um.value) {
18389
+ Um.value = !0;
18252
18390
  try {
18253
18391
  await T(parseInt(e));
18254
18392
  } finally {
18255
- Vm.value = !1;
18393
+ Um.value = !1;
18256
18394
  }
18257
18395
  }
18258
18396
  }
18259
- }), Um = (e) => {
18397
+ }), Gm = (e) => {
18260
18398
  let t = x.channels.find((t) => t.id === e);
18261
18399
  return t ? t.status === "connected" || t.status === "calling" || t.status === "incoming" : !1;
18262
- }, Wm = (e) => {
18400
+ }, Km = (e) => {
18263
18401
  let t = x.channels.find((t) => t.id === e);
18264
18402
  return t ? t.isHeld || t.status === "held" : !1;
18265
- }, Gm = (e) => {
18266
- Y.value || (Hm.value = e.toString());
18267
- }, Km = (e) => {
18403
+ }, qm = (e) => {
18404
+ Y.value || (Wm.value = e.toString());
18405
+ }, Jm = (e) => {
18268
18406
  if (!Y.value && ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "h" && (e.preventDefault(), k.value = !0), (e.metaKey || e.ctrlKey) && e.key === "," && (e.preventDefault(), O.value = !0), (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k" && (e.preventDefault(), x.toggleKeypad()), (e.metaKey || e.ctrlKey) && [
18269
18407
  "1",
18270
18408
  "2",
@@ -18272,44 +18410,44 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18272
18410
  ].includes(e.key))) {
18273
18411
  e.preventDefault();
18274
18412
  let t = parseInt(e.key) - 1;
18275
- Vm.value || (Vm.value = !0, T(t).finally(() => {
18276
- Vm.value = !1;
18413
+ Um.value || (Um.value = !0, T(t).finally(() => {
18414
+ Um.value = !1;
18277
18415
  }));
18278
18416
  }
18279
18417
  };
18280
18418
  watch(() => x.callStatus, () => {
18281
- Mm() && $();
18419
+ Pm() && $();
18282
18420
  }), watch(() => x.isConnected, (e) => {
18283
18421
  v.value && a.set(v.value, e);
18284
- }, { immediate: !0 }), watch(Cm, (e) => {
18285
- !e && Z.value && _m.value?.close();
18422
+ }, { immediate: !0 }), watch(Tm, (e) => {
18423
+ !e && Z.value && ym.value?.close();
18286
18424
  });
18287
- let qm = ref(!1), Jm = async () => {
18288
- qm.value || Y.value || !o.host || !o.extension || !o.password || (await w({
18425
+ let Ym = ref(!1), Xm = async () => {
18426
+ Ym.value || Y.value || !o.host || !o.extension || !o.password || (await w({
18289
18427
  uri: `sip:${o.extension}@${o.host}`,
18290
18428
  transportOptions: { server: _.value },
18291
18429
  authorizationUsername: o.extension,
18292
18430
  authorizationPassword: o.password,
18293
18431
  earlyMedia: o.earlyMedia
18294
- }), S.extension.value && (qm.value = !0, o.mode === "webcall" && o.to && S.makeCall(o.to)));
18432
+ }), S.extension.value && (Ym.value = !0, o.mode === "webcall" && o.to && S.makeCall(o.to)));
18295
18433
  };
18296
18434
  return provide("webphoneRegistration", {
18297
18435
  isConnected: computed(() => x.isConnected),
18298
- register: () => Jm(),
18436
+ register: () => Xm(),
18299
18437
  unregister: async () => {
18300
- await S.stop(), qm.value = !1;
18438
+ await S.stop(), Ym.value = !1;
18301
18439
  }
18302
18440
  }), onMounted(async () => {
18303
- window.addEventListener("keydown", Km), document.addEventListener("visibilitychange", $), window.addEventListener("blur", $), window.addEventListener("pagehide", $), !(o.mode === "webcall" && (!o.to || !o.logo)) && await Jm();
18441
+ window.addEventListener("keydown", Jm), document.addEventListener("visibilitychange", $), window.addEventListener("blur", $), window.addEventListener("pagehide", $), !(o.mode === "webcall" && (!o.to || !o.logo)) && await Xm();
18304
18442
  }), watch(() => J.value, async (e) => {
18305
- e && await Jm();
18443
+ e && await Xm();
18306
18444
  }), onUnmounted(() => {
18307
- S.stop(), window.removeEventListener("keydown", Km), document.removeEventListener("visibilitychange", $), window.removeEventListener("blur", $), window.removeEventListener("pagehide", $);
18445
+ S.stop(), window.removeEventListener("keydown", Jm), document.removeEventListener("visibilitychange", $), window.removeEventListener("blur", $), window.removeEventListener("pagehide", $);
18308
18446
  }), (e, t) => (openBlock(), createElementBlock(Fragment, null, [
18309
18447
  createElementVNode("div", {
18310
18448
  ref_key: "phoneRef",
18311
18449
  ref: N,
18312
- style: normalizeStyle(unref(zm)),
18450
+ style: normalizeStyle(unref(Vm)),
18313
18451
  class: normalizeClass(["webphone webphone-container wp:bg-white wp:dark:bg-neutral-800 wp:rounded-lg wp:shadow-sm wp:inset-shadow-2xs wp:w-[min(92vw,330px)] wp:fixed wp:z-50 wp:select-none wp:[&_button]:cursor-pointer wp:**:[[role=button]]:cursor-pointer", Y.value ? "wp:opacity-70" : ""]),
18314
18452
  "data-mode": o.mode,
18315
18453
  "data-call-status": x.callStatus,
@@ -18331,22 +18469,22 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18331
18469
  }, null, 512)])])) : createCommentVNode("", !0),
18332
18470
  createElementVNode("div", _hoisted_4, [
18333
18471
  H.value ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_5, [createElementVNode("div", _hoisted_6, [
18334
- createElementVNode("div", _hoisted_7, [(openBlock(), createElementBlock(Fragment, null, renderList(Bm, (e) => createElementVNode("button", {
18472
+ createElementVNode("div", _hoisted_7, [(openBlock(), createElementBlock(Fragment, null, renderList(Hm, (e) => createElementVNode("button", {
18335
18473
  key: e.value,
18336
18474
  type: "button",
18337
18475
  role: "radio",
18338
- "aria-checked": Hm.value === e.value.toString(),
18476
+ "aria-checked": Wm.value === e.value.toString(),
18339
18477
  disabled: Y.value,
18340
18478
  title: `${e.label} (${unref(V)}${e.value + 1})`,
18341
- class: normalizeClass(["webphone__channel-button wp:flex wp:items-center wp:gap-1 wp:px-2 wp:py-2 wp:rounded-lg wp:transition-colors wp:duration-200 wp:outline-none wp:focus-visible:ring-2 wp:focus-visible:ring-[var(--p-primary-color)] wp:focus-visible:ring-offset-2 wp:focus-visible:ring-offset-white wp:dark:focus-visible:ring-offset-neutral-900", Wm(e.value) ? "wp:bg-status-hold/12 hover:wp:bg-status-hold/18" : Um(e.value) ? "wp:bg-[var(--color-red)]/12 hover:wp:bg-[var(--color-red)]/18" : Hm.value === e.value.toString() ? "wp:bg-[var(--p-primary-color)]/12" : "wp:hover:bg-neutral-100 wp:dark:hover:bg-neutral-800/80"]),
18479
+ class: normalizeClass(["webphone__channel-button wp:flex wp:items-center wp:gap-1 wp:px-2 wp:py-2 wp:rounded-lg wp:transition-colors wp:duration-200 wp:outline-none wp:focus-visible:ring-2 wp:focus-visible:ring-[var(--p-primary-color)] wp:focus-visible:ring-offset-2 wp:focus-visible:ring-offset-white wp:dark:focus-visible:ring-offset-neutral-900", Km(e.value) ? "wp:bg-status-hold/12 hover:wp:bg-status-hold/18" : Gm(e.value) ? "wp:bg-[var(--color-red)]/12 hover:wp:bg-[var(--color-red)]/18" : Wm.value === e.value.toString() ? "wp:bg-[var(--p-primary-color)]/12" : "wp:hover:bg-neutral-100 wp:dark:hover:bg-neutral-800/80"]),
18342
18480
  "data-channel-id": e.value,
18343
- "data-state": Hm.value === e.value.toString() ? "active" : "idle",
18344
- "data-call-state": Wm(e.value) ? "held" : Um(e.value) ? "busy" : "available",
18345
- onClick: (t) => Gm(e.value)
18481
+ "data-state": Wm.value === e.value.toString() ? "active" : "idle",
18482
+ "data-call-state": Km(e.value) ? "held" : Gm(e.value) ? "busy" : "available",
18483
+ onClick: (t) => qm(e.value)
18346
18484
  }, [createVNode(unref(icon_phone_default), {
18347
- class: normalizeClass(["webphone__channel-icon wp:size-3 wp:shrink-0", Wm(e.value) ? "wp:text-status-hold" : Um(e.value) ? "wp:text-[var(--color-red)]" : Hm.value === e.value.toString() ? "wp:text-[var(--p-primary-color)]" : "wp:text-neutral-400"]),
18485
+ class: normalizeClass(["webphone__channel-icon wp:size-3 wp:shrink-0", Km(e.value) ? "wp:text-status-hold" : Gm(e.value) ? "wp:text-[var(--color-red)]" : Wm.value === e.value.toString() ? "wp:text-[var(--p-primary-color)]" : "wp:text-neutral-400"]),
18348
18486
  "stroke-width": 1.8
18349
- }, null, 8, ["class"]), createElementVNode("span", { class: normalizeClass(["webphone__channel-label wp:text-[11px] wp:leading-none manrope wp:font-bold", Wm(e.value) ? "wp:text-status-hold" : Um(e.value) ? "wp:text-[var(--color-red)]" : Hm.value === e.value.toString() ? "wp:text-[var(--p-primary-color)]" : "wp:text-neutral-500 wp:dark:text-neutral-400"]) }, toDisplayString(e.label), 3)], 10, _hoisted_8)), 64))]),
18487
+ }, null, 8, ["class"]), createElementVNode("span", { class: normalizeClass(["webphone__channel-label wp:text-[11px] wp:leading-none manrope wp:font-bold", Km(e.value) ? "wp:text-status-hold" : Gm(e.value) ? "wp:text-[var(--color-red)]" : Wm.value === e.value.toString() ? "wp:text-[var(--p-primary-color)]" : "wp:text-neutral-500 wp:dark:text-neutral-400"]) }, toDisplayString(e.label), 3)], 10, _hoisted_8)), 64))]),
18350
18488
  createVNode(unref(TooltipProvider_default), null, {
18351
18489
  default: withCtx(() => [createVNode(unref(Tooltip_default), null, {
18352
18490
  default: withCtx(() => [createVNode(unref(TooltipTrigger_default), { "as-child": "" }, {
@@ -18355,7 +18493,7 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18355
18493
  size: "icon",
18356
18494
  class: normalizeClass(["wp:h-8 wp:w-8 wp:rounded-full", Z.value ? "wp:text-primary" : ""]),
18357
18495
  title: "Picture-in-Picture",
18358
- onClick: wm
18496
+ onClick: Em
18359
18497
  }, {
18360
18498
  default: withCtx(() => [createVNode(unref(PictureInPicture2), { class: "wp:w-4 wp:h-4 wp:text-[var(--color-settings)]" })]),
18361
18499
  _: 1
@@ -18425,8 +18563,8 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18425
18563
  "on-hangup": o.onHangup,
18426
18564
  "on-reject": o.onReject,
18427
18565
  onTransfer: t[1] ||= (e) => j.value = !0,
18428
- onCompleteTransfer: Tm,
18429
- onCancelTransfer: Em
18566
+ onCompleteTransfer: Dm,
18567
+ onCancelTransfer: Om
18430
18568
  }, null, 8, [
18431
18569
  "style",
18432
18570
  "destination",
@@ -18452,7 +18590,7 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18452
18590
  "onUpdate:visible": t[3] ||= (e) => k.value = e,
18453
18591
  contacts: o.contacts,
18454
18592
  "mask-number": o.maskNumber,
18455
- onCall: Dm
18593
+ onCall: km
18456
18594
  }, null, 8, [
18457
18595
  "visible",
18458
18596
  "contacts",
@@ -18466,12 +18604,12 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18466
18604
  }, null, 8, ["visible", "contacts"]),
18467
18605
  createVNode(DocumentPip_default, {
18468
18606
  ref_key: "documentPipRef",
18469
- ref: _m,
18607
+ ref: ym,
18470
18608
  active: Z.value,
18471
18609
  "onUpdate:active": t[5] ||= (e) => Z.value = e,
18472
- "auto-open-on-blur": Cm.value,
18610
+ "auto-open-on-blur": Tm.value,
18473
18611
  "is-connected": x.isConnected,
18474
- "remote-number": hm.value,
18612
+ "remote-number": _m.value,
18475
18613
  "caller-name": K.value,
18476
18614
  "has-video": q.value ?? !1,
18477
18615
  "remote-stream": unref(E),
@@ -18481,11 +18619,11 @@ var _hoisted_1$3 = { class: "wp:flex wp:flex-col wp:gap-6 wp:py-4" }, _hoisted_2
18481
18619
  "call-status": x.callStatus,
18482
18620
  "is-muted": x.isMuted,
18483
18621
  "is-held": x.isHeld,
18484
- onTransfer: jm,
18622
+ onTransfer: Nm,
18485
18623
  onTransferRequest: Q,
18486
- onHangup: km,
18487
- onReject: Am,
18488
- onAnswer: Om,
18624
+ onHangup: jm,
18625
+ onReject: Mm,
18626
+ onAnswer: Am,
18489
18627
  onToggleMute: t[6] ||= (e) => unref(S).toggleMute(),
18490
18628
  onToggleHold: t[7] ||= (e) => unref(S).toggleHold()
18491
18629
  }, null, 8, [