PageSourceSearch

https://intranet.freienwill.de/dist/js/chatCall_BV2d6peS.min.js

js freienwill.de collected 2026-09-25 10:59:19 UTC 14,521 bytes, 505 lines download raw bytes

1(function() {
2	try {
3		var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {};
4		e.SENTRY_RELEASE = { id: "live_2026-09-24-1148" };
5		var t = new e.Error().stack;
6		t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "9051ec9c-48ca-4ab5-9ec9-b8f5ff47c410", e._sentryDebugIdIdentifier = "sentry-dbid-9051ec9c-48ca-4ab5-9ec9-b8f5ff47c410");
7	} catch (e) {}
8})();
9import { a as e } from "./rolldown-runtime_YVF6yP6t.min.js";
10import { $o as t, Ac as n, ml as r, n as i, rl as a } from "./topMessageHandler_BfquHqnZ.min.js";
11import { c as o, nt as s, q as c } from "./runtime-core.esm-bundler_Bi-f_fgM.min.js";
12import { a as l, o as u } from "./mailtransport_CUV2WTT3.min.js";
13import { n as d, t as f } from "./asyncToGenerator_SUcgKOYT.min.js";
14import { a as p, t as ee } from "./webRtc_BrSnxH42.min.js";
15//#region src/composables/sharedAudio.ts
16function te(e) {
17	e.commit("sharedAudio/acquire");
18	let t = !1;
19	return {
20		setStream(n) {
21			t || e.commit("sharedAudio/setStream", n);
22		},
23		setSinkId(n) {
24			return t ? Promise.resolve() : e.dispatch("sharedAudio/setSinkId", n);
25		},
26		play() {
27			return t ? Promise.resolve() : e.dispatch("sharedAudio/play");
28		},
29		pause() {
30			t || e.commit("sharedAudio/pause");
31		},
32		release() {
33			t || (t = !0, e.commit("sharedAudio/release"));
34		}
35	};
36}
37//#endregion
38//#region src/composables/chatCallPopup.ts
39u();
40var ne = "portunaChatCall", re = 750, ie = 550, m = "portuna-call-window-command", ae = 1e4, h = s(null), g = s(null), _ = /* @__PURE__ */ new Set(), oe = (e) => (_.add(e), () => {
41	_.delete(e);
42}), v = null, se = () => {
43	v !== null && (window.clearInterval(v), v = null);
44}, ce = () => {
45	v === null && (v = window.setInterval(() => {
46		if (h.value && !h.value.closed) return;
47		se(), h.value = null;
48		let e = g.value;
49		g.value = null, e && _.forEach((t) => t(e));
50	}, 1e3));
51}, le = (e) => {
52	try {
53		window.localStorage.setItem(m, JSON.stringify(e));
54	} catch (e) {}
55}, y = (e) => {
56	let t = h.value;
57	return !t || t.closed ? !1 : (le(l(l({}, e), {}, { ts: Date.now() })), !0);
58}, ue = (e = {}) => {
59	let { chatId: t } = e, n = t === void 0 ? null : {
60		chatId: t,
61		isSingleChat: e.isSingleChat === !0
62	};
63	if (h.value && !h.value.closed) return h.value.focus(), t !== void 0 && (g.value = n, y({
64		type: "start",
65		chatId: t
66	})), !0;
67	let r = Math.max(0, Math.round((window.screen.availWidth - re) / 2)), i = Math.max(0, Math.round((window.screen.availHeight - ie) / 2)), a = t === void 0 ? "/chat/call" : "/chat/call?start=" + t, o = [
68		"width=750",
69		"height=550",
70		"left=" + r,
71		"top=" + i,
72		"resizable=yes",
73		"scrollbars=no"
74	].join(","), s = window.open(a, ne, o);
75	return s ? (h.value = s, g.value = n, ce(), !0) : !1;
76};
77function b() {
78	return {
79		callWindow: h,
80		openCallWindow: ue,
81		sendCallWindowCommand: y,
82		onCallWindowClosed: oe
83	};
84}
85//#endregion
86//#region src/library/sound.ts
87d();
88function x(e, t, n) {
89	let r = e.createOscillator(), i = e.createGain(), a = n.startTime + n.duration;
90	return r.type = "sine", r.frequency.setValueAtTime(n.frequency, n.startTime), i.gain.setValueAtTime(1e-4, n.startTime), i.gain.linearRampToValueAtTime(n.volume, n.startTime + .02), i.gain.setValueAtTime(n.volume, n.startTime + n.duration * .55), i.gain.exponentialRampToValueAtTime(1e-4, a), r.connect(i), i.connect(t), r;
91}
92function de() {
93	return S.apply(this, arguments);
94}
95function S() {
96	return S = f(function* () {
97		try {
98			let e = new AudioContext();
99			yield e.resume();
100			let t = e.currentTime, n = x(e, e.destination, {
101				frequency: 659.26,
102				startTime: t,
103				duration: .16,
104				volume: .12
105			}), r = x(e, e.destination, {
106				frequency: 392,
107				startTime: t + .12,
108				duration: .3,
109				volume: .15
110			});
111			r.addEventListener("ended", () => {
112				e.close();
113			}, { once: !0 }), n.start(t), n.stop(t + .16), r.start(t + .12), r.stop(t + .42);
114		} catch (e) {
115			return;
116		}
117	}), S.apply(this, arguments);
118}
119var fe = 2500, C = null;
120function w() {
121	let e = C;
122	if (!e) return;
123	let t = e.audioContext.currentTime, n = x(e.audioContext, e.master, {
124		frequency: 783.99,
125		startTime: t,
126		duration: .3,
127		volume: .15
128	}), r = x(e.audioContext, e.master, {
129		frequency: 587.33,
130		startTime: t + .4,
131		duration: .3,
132		volume: .18
133	});
134	n.start(t), n.stop(t + .3), r.start(t + .4), r.stop(t + .7), e.timeout = window.setTimeout(w, fe);
135}
136function pe() {
137	T();
138	try {
139		let e = new AudioContext(), t = e.createGain();
140		t.connect(e.destination), C = {
141			audioContext: e,
142			master: t,
143			timeout: 0
144		}, e.resume().then(() => {
145			(C == null ? void 0 : C.audioContext) === e && w();
146		}).catch(() => {
147			(C == null ? void 0 : C.audioContext) === e && T();
148		});
149	} catch (e) {
150		C = null;
151	}
152}
153function T() {
154	let e = C;
155	if (C = null, !e) return;
156	window.clearTimeout(e.timeout);
157	let t = e.audioContext.currentTime;
158	e.master.gain.setValueAtTime(e.master.gain.value, t), e.master.gain.linearRampToValueAtTime(1e-4, t + .08), window.setTimeout(() => {
159		e.audioContext.close();
160	}, 120);
161}
162//#endregion
163//#region src/composables/chatCall.ts
164var me = /* @__PURE__ */ e(r(), 1);
165d(), u();
166var E = ee(), D = s(null), O = s(!1), k = o(() => D.value !== null), he = "chat", ge = () => {
167	let e = i.state.layoutData.user;
168	return {
169		id: e.id,
170		name: e.name
171	};
172}, A = () => i.getters["module/chat/chatsLoaded"] === !0 && i.getters["module/chat/isLicensedCalling"] !== !0, j = "portuna-chat-call", _e = () => {
173	try {
174		let e = window.sessionStorage.getItem(j);
175		if (!e) return null;
176		let t = JSON.parse(e);
177		return t.chatId > 0 ? t.chatId : null;
178	} catch (e) {
179		return null;
180	}
181}, M = "portuna-chat-call-answered", ve = 600 * 1e3, N = me.default.createInstance({
182	name: "portunaChatCall",
183	storeName: "chatCall"
184}), ye = function() {
185	var e = f(function* (e, t) {
186		try {
187			yield N.setItem(M, {
188				chatId: e,
189				roomId: t,
190				at: Date.now()
191			});
192		} catch (e) {}
193	});
194	return function(t, n) {
195		return e.apply(this, arguments);
196	};
197}(), be = function() {
198	var e = f(function* (e, t) {
199		try {
200			let n = yield N.getItem(M);
201			return n !== null && n.chatId === e && n.roomId === t && Date.now() - n.at < ve;
202		} catch (e) {
203			return !1;
204		}
205	});
206	return function(t, n) {
207		return e.apply(this, arguments);
208	};
209}(), P = function() {
210	var e = f(function* (e) {
211		try {
212			yield n.post("/chat/chat/mark-call-answered/id/" + e);
213		} catch (e) {
214			p("chat call: mark-answered failed", void 0, e);
215		}
216	});
217	return function(t) {
218		return e.apply(this, arguments);
219	};
220}(), xe = (e) => {
221	try {
222		window.sessionStorage.setItem(j, JSON.stringify({ chatId: e }));
223	} catch (e) {}
224}, F = () => {
225	try {
226		window.sessionStorage.removeItem(j);
227	} catch (e) {}
228}, I = "webrtc.media.devices", L = null, R = s(!1), z = "", Se = () => {
229	let e = a.get(I);
230	return typeof (e == null ? void 0 : e.speakerDeviceId) == "string" ? e.speakerDeviceId : "";
231};
232a.on(I, (e) => {
233	var t;
234	let n = typeof ((t = e.newValue) == null ? void 0 : t.speakerDeviceId) == "string" ? e.newValue.speakerDeviceId : "";
235	L && n && L.setSinkId(n);
236});
237var B = () => {
238	if (!L) return;
239	let e = [];
240	for (let t of E.remotePeers.values()) e.push(...t.stream.getAudioTracks());
241	let t = e.map((e) => e.id).join("|");
242	if (t !== z) {
243		z = t, L.setStream(e.length > 0 ? new MediaStream(e) : null);
244		let n = Se();
245		n && L.setSinkId(n);
246	}
247	if (e.length > 0 && !R.value) {
248		L.play();
249		return;
250	}
251	L.pause();
252}, Ce = () => {
253	L || (L = te(i));
254}, we = () => {
255	L && (L.setStream(null), L.release(), L = null, z = "");
256}, V = () => {
257	var e, t, n;
258	i.commit("setWebRtcCall", {
259		active: D.value !== null,
260		state: E.state.value,
261		type: D.value ? he : null,
262		roomId: (e = (t = D.value) == null ? void 0 : t.roomId) == null ? "" : e,
263		chatId: (n = D.value) == null ? void 0 : n.chatId,
264		startedAt: D.value === null ? null : i.state.webRtcCall.startedAt
265	});
266}, Te = 600, H = 0, U = () => {
267	let e = Date.now();
268	return O.value || e - H < Te ? !0 : (H = e, !1);
269};
270c(() => E.state.value, (e) => {
271	(e === "closed" || e === "error") && D.value !== null && (D.value = null), e === "connected" && i.commit("setWebRtcCall", { startedAt: Date.now() }), V();
272}), c(D, V, { immediate: !0 }), c(D, (e) => {
273	e != null && e.chatId ? (xe(e.chatId), Ce()) : (F(), we());
274}), c(D, (e, t) => {
275	!e && t && de();
276}), c(() => E.remotePeers, B, { deep: !0 }), c(R, B);
277var Ee = (e) => {
278	R.value = e;
279}, W = () => {
280	D.value = null;
281	try {
282		E.disconnect();
283	} catch (e) {
284		p("chat call: disconnect failed", void 0, e);
285	}
286}, G = function() {
287	var e = f(function* (e) {
288		if (!(!e || !e.isSingleChat) && !(E.state.value === "closed" || E.state.value === "idle")) try {
289			yield E.endRoom();
290		} catch (e) {
291			p("chat call: endRoom failed", void 0, e);
292		}
293	});
294	return function(t) {
295		return e.apply(this, arguments);
296	};
297}(), K = null, q = () => K === null ? 0 : Math.max(0, Math.floor((Date.now() - K) / 1e3)), J = function() {
298	var e = f(function* (e, t = 0, r = !1) {
299		let i = "/chat/chat/end-call/id/" + e;
300		t > 0 && (i += "/duration/" + t), r && (i += "/cancel/1"), yield n.post(i).catch((e) => {
301			p("chat call: end-call failed", void 0, e);
302		});
303	});
304	return function(t) {
305		return e.apply(this, arguments);
306	};
307}(), Y = function() {
308	var e = f(function* (e, t = 0, n = !1) {
309		yield J(e.chatId, t, n);
310	});
311	return function(t) {
312		return e.apply(this, arguments);
313	};
314}(), X = (e) => i.getters["module/chat/isAdmin"] === !0 ? !i.getters["module/chat/participantChats"].some((t) => t.id === e) : !1, De = function() {
315	var e = f(function* (e) {
316		let t = q();
317		!e.isSingleChat && (E.remotePeers.size > 0 || t <= 0) || (yield Y(e, t));
318	});
319	return function(t) {
320		return e.apply(this, arguments);
321	};
322}(), Oe = function() {
323	var e = f(function* (e) {
324		if (A()) return null;
325		try {
326			var t;
327			let { data: r } = yield n.get("/chat/chat/get-active-call/id/" + e), i = (t = r.data) == null ? r : t;
328			return i != null && i.roomId ? i : null;
329		} catch (e) {
330			return p("chat call: get-active-call failed", void 0, e), null;
331		}
332	});
333	return function(t) {
334		return e.apply(this, arguments);
335	};
336}(), ke = (e, t) => {
337	D.value = l(l({}, t), {}, {
338		isSingleChat: t.isSingleChat === !0,
339		chatId: e
340	}), ye(e, t.roomId);
341}, Z = function() {
342	var e = f(function* (e, t) {
343		ke(e, t), yield E.connect({
344			apiUrl: t.apiUrl,
345			wsUrl: t.wsUrl || void 0,
346			roomId: t.roomId,
347			role: "member",
348			token: t.hostToken,
349			mic: !0,
350			user: ge()
351		});
352	});
353	return function(t, n) {
354		return e.apply(this, arguments);
355	};
356}(), Ae = function() {
357	var e = f(function* (e) {
358		var t;
359		if (A() || ((t = D.value) == null ? void 0 : t.chatId) === e || U()) return;
360		O.value = !0;
361		let r = null;
362		try {
363			var i;
364			K = null;
365			let t = D.value;
366			t !== null && !X(t.chatId) && (yield De(t), yield G(t)), W();
367			let o = yield Oe(e);
368			if (o !== null) {
369				if (yield Z(e, o), E.state.value === "connected") return;
370				W();
371			}
372			let { data: s } = yield n.post("/chat/chat/start-call/id/" + e), c = (i = s.data) == null ? s : i;
373			if (r = l(l({}, c), {}, {
374				isSingleChat: c.isSingleChat,
375				chatId: e
376			}
376), yield Z(e, c), E.state.value !== "connected") {
377				var a;
378				throw Error((a = E.error.value) == null ? "Chat-Telefonat konnte nicht verbunden werden." : a);
379			}
380		} catch (e) {
381			throw D.value = null, E.disconnect(), p("chat call: connect failed", void 0, e), r !== null && (yield Y(r, 0, !0)), e;
382		} finally {
383			O.value = !1;
384		}
385	});
386	return function(t) {
387		return e.apply(this, arguments);
388	};
389}(), je = function() {
390	var e = f(function* (e) {
391		var t;
392		let r = i.getters["module/chat/singleChatIdForUser"](e);
393		if (r !== null) return r;
394		let { data: a } = yield n.post("/chat/chat/ensure-direct-chat/user-id/" + e), o = (t = a.data) == null ? a : t, s = o == null ? void 0 : o.chatId;
395		if (!s || !Number.isInteger(s)) throw Error("Der Chat mit dem Mitarbeiter konnte nicht geöffnet werden.");
396		return s;
397	});
398	return function(t) {
399		return e.apply(this, arguments);
400	};
401}(), Me = function() {
402	var e = f(function* () {
403		if (!k.value || U()) return;
404		let e = D.value;
405		if (e !== null) {
406			O.value = !0;
407			try {
408				X(e.chatId) || (yield De(e), yield G(e));
409			} finally {
410				W(), O.value = !1;
411			}
412		}
413	});
414	return function() {
415		return e.apply(this, arguments);
416	};
417}(), Ne = function() {
418	var e = f(function* () {
419		if (!k.value) return;
420		let e = D.value;
421		yield G(e), W();
422	});
423	return function() {
424		return e.apply(this, arguments);
425	};
426}
426(), Pe = 3e4, Q = null, $ = !1, Fe = () => {
427	Q !== null && (window.clearTimeout(Q), Q = null);
428};
429c(D, (e, t) => {
430	if ((e == null ? void 0 : e.chatId) !== (t == null ? void 0 : t.chatId) && (Fe(), $ = E.remotePeers.size > 0, K = $ ? Date.now() : null, e !== null && $ && P(e.chatId), (e == null ? void 0 : e.isSingleChat) === !0 && E.remotePeers.size === 0)) {
431		let t = e.chatId;
432		Q = window.setTimeout(() => {
433			var e;
434			Q = null, !$ && ((e = D.value) == null ? void 0 : e.chatId) === t && E.remotePeers.size === 0 && Me();
435		}, Pe);
436	}
437}), c(() => E.remotePeers.size, (e) => {
438	if (e > 0) {
439		var t;
440		$ = !0, K === null && (K = Date.now());
441		let e = (t = D.value) == null ? void 0 : t.chatId;
442		e !== void 0 && P(e), Fe();
443	}
444});
445var Ie = !1, Le = function() {
446	var e = f(function* () {
447		if (Ie || k.value || O.value) return;
448		Ie = !0;
449		let e = _e();
450		if (e) {
451			O.value = !0;
452			try {
453				K = null;
454				let t = yield Oe(e);
455				if (t === null) {
456					F();
457					return;
458				}
459				yield Z(e, t);
460			} catch (e) {
461				D.value = null, F(), E.disconnect(), p("chat call: reconnect failed", void 0, e);
462			} finally {
463				O.value = !1;
464			}
465		}
466	});
467	return function() {
468		return e.apply(this, arguments);
469	};
470}();
471window.addEventListener("pagehide", () => {
472	let e = D.value;
473	if (!e || !e.isSingleChat) return;
474	let r = q(), i = "/chat/chat/end-call/id/" + e.chatId;
475	r > 0 && (i += "/duration/" + r), n.post(i, void 0, {
476		adapter: "fetch",
477		withCredentials: !0,
478		fetchOptions: { keepalive: !0 }
479	}).catch(t);
480});
481var { onCallWindowClosed: Re } = b();
482Re((e) => {
483	e.isSingleChat && J(e.chatId);
484});
485function ze() {
486	return {
487		isActive: k,
488		busy: O,
489		payload: D,
490		rtc: E,
491		state: E.state,
492		error: E.error,
493		start: Ae,
494		ensureDirectChat: je,
495		leave: Me,
496		tearDown: Ne,
497		reconnect: Le,
498		setPlayerVisible: Ee,
499		isCallAnswered: be
500	};
501}
502//#endregion
503export { ae as a, m as i, pe as n, b as o, T as r, ze as t };
504
505//# sourceMappingURL=chatCall_BV2d6peS.min.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.