@bravophone/webphone 0.1.2 → 0.2.0
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/README.md +49 -3
- package/dist/bravophone.mjs +358 -287
- package/dist/bravophone.umd.js +43 -7
- package/host/_locales/pt_BR/messages.json +1430 -0
- package/host/allowed-origins.json +8 -0
- package/host/css/bravophoneContactDialer.css +385 -0
- package/host/css/dark-theme.css +116 -0
- package/host/favicon.ico +0 -0
- package/host/fonts/Audiowide-Regular.ttf +0 -0
- package/host/fonts/Seguiemj.ttf +0 -0
- package/host/images/answer-gray.png +0 -0
- package/host/images/answer.png +0 -0
- package/host/images/auto-answer-off.png +0 -0
- package/host/images/auto-answer-on.png +0 -0
- package/host/images/avatar.png +0 -0
- package/host/images/bravophone-logo.svg +39 -0
- package/host/images/bravotech_Bravotech_logo.png +0 -0
- package/host/images/circle-green.png +0 -0
- package/host/images/circle-orange.png +0 -0
- package/host/images/circle-red.png +0 -0
- package/host/images/dialer-button-down.png +0 -0
- package/host/images/dialer-button.png +0 -0
- package/host/images/gateways/activecampaign.png +0 -0
- package/host/images/gateways/agendor.png +0 -0
- package/host/images/gateways/appfacilita.png +0 -0
- package/host/images/gateways/call-in.png +0 -0
- package/host/images/gateways/click-to-call.png +0 -0
- package/host/images/gateways/clickup.png +0 -0
- package/host/images/gateways/exactsales.png +0 -0
- package/host/images/gateways/go-high-lvl.png +0 -0
- package/host/images/gateways/groner.png +0 -0
- package/host/images/gateways/hubspot.png +0 -0
- package/host/images/gateways/kommo.png +0 -0
- package/host/images/gateways/moskit.png +0 -0
- package/host/images/gateways/nectar.png +0 -0
- package/host/images/gateways/pipedrive.png +0 -0
- package/host/images/gateways/pipefy.png +0 -0
- package/host/images/gateways/piperun.png +0 -0
- package/host/images/gateways/ploomes.png +0 -0
- package/host/images/gateways/rdstation-crm.png +0 -0
- package/host/images/gateways/salesforce.png +0 -0
- package/host/images/gateways/sharpspring.png +0 -0
- package/host/images/gateways/sunhub.png +0 -0
- package/host/images/gateways/vendfly.png +0 -0
- package/host/images/gateways/zendesk.png +0 -0
- package/host/images/gateways/zoho.png +0 -0
- package/host/images/hangup.png +0 -0
- package/host/images/hold.png +0 -0
- package/host/images/icons/logo-128-christmas-celebration.png +0 -0
- package/host/images/icons/logo-128.png +0 -0
- package/host/images/icons/logo-16-christmas-celebration.png +0 -0
- package/host/images/icons/logo-16.png +0 -0
- package/host/images/icons/logo-24-christmas-celebration.png +0 -0
- package/host/images/icons/logo-24.png +0 -0
- package/host/images/icons/logo-32-christmas-celebration.png +0 -0
- package/host/images/icons/logo-32.png +0 -0
- package/host/images/icons/logo-48-christmas-celebration.png +0 -0
- package/host/images/icons/logo-48.png +0 -0
- package/host/images/loading.gif +0 -0
- package/host/images/logo-bravotech-white.png +0 -0
- package/host/images/logo-bravotech.png +0 -0
- package/host/images/logo-inline-christmas-celebration.png +0 -0
- package/host/images/logo-inline.png +0 -0
- package/host/images/mic-off.png +0 -0
- package/host/images/mic-on.png +0 -0
- package/host/images/play.png +0 -0
- package/host/images/transfer.png +0 -0
- package/host/index.html +34 -0
- package/host/js/bravophone-noise-suppressor.js +418 -0
- package/host/js/bravophone-route-selector.js +1099 -0
- package/host/js/libwebphone.js +20 -0
- package/host/js/noise/LICENSE-web-noise-suppressor.txt +21 -0
- package/host/js/noise/rnnoise-worklet.js +13 -0
- package/host/js/noise/rnnoise.wasm +0 -0
- package/host/js/noise/rnnoise_simd.wasm +0 -0
- package/host/mock-webphone.js +195 -0
- package/host/mock.html +54 -0
- package/host/popup.js +23 -0
- package/host/shim/chrome-shim.js +287 -0
- package/host/shim/guest-bridge.js +353 -0
- package/host/shim/messages.js +13 -0
- package/host/styles/theme-fixes.css +92 -0
- package/package.json +4 -2
- package/types/index.d.ts +21 -1
package/dist/bravophone.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Z = 'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"', me = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
2
2
|
<path class="bp-i-body" d="M15.6 12.8a11 11 0 0 1-4.4-4.4l1-1a1.6 1.6 0 0 0 .3-1.7c-.2-.7-.4-1.4-.5-2.2A1.6 1.6 0 0 0 10.4 2H7.9a1.6 1.6 0 0 0-1.6 1.8 15.8 15.8 0 0 0 2.4 6.9 15.6 15.6 0 0 0 4.8 4.8 15.8 15.8 0 0 0 6.9 2.4 1.6 1.6 0 0 0 1.7-1.6v-2.5a1.6 1.6 0 0 0-1.4-1.6c-.8-.1-1.5-.3-2.2-.5a1.6 1.6 0 0 0-1.7.4z"/>
|
|
3
3
|
<path class="bp-i-wave bp-i-wave-1" d="M14.5 6.2a4 4 0 0 1 3.3 3.3"/>
|
|
4
4
|
<path class="bp-i-wave bp-i-wave-2" d="M14.1 2.6a7.6 7.6 0 0 1 7.3 7.3"/>
|
|
5
|
-
</svg>`,
|
|
5
|
+
</svg>`, fe = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
6
6
|
<path class="bp-i-bar bp-i-bar-1" d="M4 10v4"/>
|
|
7
7
|
<path class="bp-i-bar bp-i-bar-2" d="M8.7 6.5v11"/>
|
|
8
8
|
<path class="bp-i-bar bp-i-bar-3" d="M12 3.5v17"/>
|
|
9
9
|
<path class="bp-i-bar bp-i-bar-4" d="M15.3 6.5v11"/>
|
|
10
10
|
<path class="bp-i-bar bp-i-bar-5" d="M20 10v4"/>
|
|
11
|
-
</svg>`,
|
|
11
|
+
</svg>`, xe = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
12
12
|
<path class="bp-i-body" d="M4 13v-1a8 8 0 0 1 16 0v1"/>
|
|
13
13
|
<path class="bp-i-body" d="M20 14.5v2a3.5 3.5 0 0 1-3.5 3.5H13"/>
|
|
14
14
|
<rect class="bp-i-cup" x="1.6" y="12.6" width="4.4" height="6.4" rx="1.8"/>
|
|
15
15
|
<rect class="bp-i-cup" x="18" y="12.6" width="4.4" height="6.4" rx="1.8"/>
|
|
16
|
-
</svg>`,
|
|
16
|
+
</svg>`, we = `<svg viewBox="0 0 24 24" fill="none" ${Z} aria-hidden="true">
|
|
17
17
|
<path class="bp-i-body" d="M21 11.5a8.4 8.4 0 0 1-9 8.4 9 9 0 0 1-2.9-.5L3 21.5l1.5-4.6A8.4 8.4 0 0 1 12 3.1a8.4 8.4 0 0 1 9 8.4z"/>
|
|
18
18
|
<path class="bp-i-hand" d="M14.6 14.4a6.5 6.5 0 0 1-3.2-3.2l.7-.7a1 1 0 0 0 .2-1.1 6 6 0 0 1-.3-1.2 1 1 0 0 0-1-.8H9.6a1 1 0 0 0-1 1.1 9.6 9.6 0 0 0 4.8 7.2 1 1 0 0 0 1.4-.9v-1.2a1 1 0 0 0-.8-1z"/>
|
|
19
|
-
</svg>`,
|
|
19
|
+
</svg>`, ye = `<svg viewBox="0 0 10 16" width="10" height="16" fill="currentColor" aria-hidden="true">
|
|
20
20
|
<circle cx="2.6" cy="2.6" r="1.35"/><circle cx="7.4" cy="2.6" r="1.35"/>
|
|
21
21
|
<circle cx="2.6" cy="8" r="1.35"/><circle cx="7.4" cy="8" r="1.35"/>
|
|
22
22
|
<circle cx="2.6" cy="13.4" r="1.35"/><circle cx="7.4" cy="13.4" r="1.35"/>
|
|
23
|
-
</svg>`,
|
|
24
|
-
"phone-waves":
|
|
25
|
-
waveform:
|
|
26
|
-
headset:
|
|
27
|
-
"chat-phone":
|
|
28
|
-
},
|
|
23
|
+
</svg>`, J = {
|
|
24
|
+
"phone-waves": me,
|
|
25
|
+
waveform: fe,
|
|
26
|
+
headset: xe,
|
|
27
|
+
"chat-phone": we
|
|
28
|
+
}, te = "phone-waves", ve = `
|
|
29
29
|
.bp-launcher-icon svg { width: 100%; height: 100%; display: block; overflow: visible; }
|
|
30
30
|
|
|
31
31
|
/* Ponto de status no canto do ícone — verde registrado, cinza sem linha. */
|
|
@@ -95,7 +95,7 @@ const K = 'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-
|
|
|
95
95
|
.bp-i-wave, .bp-i-body, .bp-i-hand, .bp-i-bar { animation: none !important; }
|
|
96
96
|
.bp-launcher-icon { transition: none; }
|
|
97
97
|
}
|
|
98
|
-
`,
|
|
98
|
+
`, ke = `
|
|
99
99
|
:host { all: initial; }
|
|
100
100
|
* { box-sizing: border-box; }
|
|
101
101
|
|
|
@@ -341,25 +341,25 @@ const K = 'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-
|
|
|
341
341
|
.bp-launcher[data-badge]:not([data-badge=""]) { animation: none; }
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
${
|
|
345
|
-
`,
|
|
346
|
-
function
|
|
344
|
+
${ve}
|
|
345
|
+
`, ue = "bravophone:widget:geometry", V = 28, X = 32;
|
|
346
|
+
function Me(e) {
|
|
347
347
|
try {
|
|
348
|
-
const a = localStorage.getItem(
|
|
348
|
+
const a = localStorage.getItem(ue);
|
|
349
349
|
if (!a) return { ...e };
|
|
350
|
-
const
|
|
351
|
-
return
|
|
350
|
+
const n = JSON.parse(a);
|
|
351
|
+
return n.dock ? { ...e, ...n, ...U(n.dock, n) } : { ...e, ...n };
|
|
352
352
|
} catch (a) {
|
|
353
353
|
return { ...e };
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function K(e) {
|
|
357
357
|
try {
|
|
358
|
-
localStorage.setItem(
|
|
358
|
+
localStorage.setItem(ue, JSON.stringify(e));
|
|
359
359
|
} catch (a) {
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function he(e) {
|
|
363
363
|
return {
|
|
364
364
|
minWidth: e.minWidth,
|
|
365
365
|
minHeight: e.minHeight,
|
|
@@ -370,169 +370,169 @@ function se(e) {
|
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
372
|
function R(e) {
|
|
373
|
-
const a = Math.max(0, window.innerWidth - e.width),
|
|
373
|
+
const a = Math.max(0, window.innerWidth - e.width), n = Math.max(0, window.innerHeight - 40);
|
|
374
374
|
return {
|
|
375
375
|
...e,
|
|
376
376
|
x: Math.min(Math.max(0, e.x), a),
|
|
377
|
-
y: Math.min(Math.max(0, e.y),
|
|
377
|
+
y: Math.min(Math.max(0, e.y), n)
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
const
|
|
380
|
+
function U(e, a) {
|
|
381
|
+
const n = window.innerWidth, o = window.innerHeight, i = Math.round(n / 2), s = Math.round(o / 2), u = Math.min(a.width, n);
|
|
382
382
|
switch (e) {
|
|
383
383
|
case "left":
|
|
384
|
-
return { x: 0, y: 0, width: u, height:
|
|
384
|
+
return { x: 0, y: 0, width: u, height: o };
|
|
385
385
|
case "right":
|
|
386
|
-
return { x:
|
|
386
|
+
return { x: n - u, y: 0, width: u, height: o };
|
|
387
387
|
case "left-half":
|
|
388
|
-
return { x: 0, y: 0, width:
|
|
388
|
+
return { x: 0, y: 0, width: i, height: o };
|
|
389
389
|
case "right-half":
|
|
390
|
-
return { x:
|
|
390
|
+
return { x: n - i, y: 0, width: i, height: o };
|
|
391
391
|
case "top":
|
|
392
392
|
return { x: a.x, y: 0, width: u, height: s };
|
|
393
393
|
case "bottom":
|
|
394
|
-
return { x: a.x, y:
|
|
394
|
+
return { x: a.x, y: o - s, width: u, height: s };
|
|
395
395
|
case "top-half":
|
|
396
|
-
return { x: 0, y: 0, width:
|
|
396
|
+
return { x: 0, y: 0, width: n, height: s };
|
|
397
397
|
case "bottom-half":
|
|
398
|
-
return { x: 0, y:
|
|
398
|
+
return { x: 0, y: o - s, width: n, height: s };
|
|
399
399
|
case "max":
|
|
400
|
-
return { x: 0, y: 0, width:
|
|
400
|
+
return { x: 0, y: 0, width: n, height: o };
|
|
401
401
|
default:
|
|
402
402
|
return { x: a.x, y: a.y, width: a.width, height: a.height };
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
|
-
function
|
|
406
|
-
const
|
|
407
|
-
return (
|
|
408
|
-
}
|
|
409
|
-
function
|
|
410
|
-
let t = { ...
|
|
411
|
-
const
|
|
412
|
-
e.style.left = `${t.x}px`, e.style.top = `${t.y}px`, e.style.width = `${t.width}px`, e.style.height = `${t.height}px`, e.classList.toggle("bp-docked", !!t.dock),
|
|
413
|
-
},
|
|
414
|
-
if (
|
|
415
|
-
if (!
|
|
416
|
-
|
|
405
|
+
function ze(e, a, n) {
|
|
406
|
+
const o = window.innerWidth, i = window.innerHeight, s = e <= V, u = e >= o - V, m = a <= V, t = a >= i - V;
|
|
407
|
+
return (m || t) && s ? "left-half" : (m || t) && u ? "right-half" : m ? n || "max" : t ? "bottom-half" : s ? "left" : u ? "right" : null;
|
|
408
|
+
}
|
|
409
|
+
function Le({ root: e, handle: a, handles: n, preview: o, geometry: i, limits: s, topDock: u, onChange: m }) {
|
|
410
|
+
let t = { ...i }, g = null, p = "", d = null, l = null, x = null, y = null;
|
|
411
|
+
const M = () => {
|
|
412
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.y}px`, e.style.width = `${t.width}px`, e.style.height = `${t.height}px`, e.classList.toggle("bp-docked", !!t.dock), m == null || m(t);
|
|
413
|
+
}, W = (r) => {
|
|
414
|
+
if (o) {
|
|
415
|
+
if (!r) {
|
|
416
|
+
o.hidden = !0;
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
|
|
419
|
+
o.hidden = !1, o.style.left = `${r.x}px`, o.style.top = `${r.y}px`, o.style.width = `${r.width}px`, o.style.height = `${r.height}px`;
|
|
420
420
|
}
|
|
421
|
-
},
|
|
422
|
-
const
|
|
423
|
-
let { x:
|
|
424
|
-
p.includes("e") && (
|
|
425
|
-
},
|
|
421
|
+
}, $ = (r, b) => {
|
|
422
|
+
const h = he(s);
|
|
423
|
+
let { x: v, y: z, width: L, height: H } = d;
|
|
424
|
+
p.includes("e") && (L = d.width + r), p.includes("w") && (L = d.width - r), p.includes("s") && (H = d.height + b), p.includes("n") && (H = d.height - b), L = Math.min(h.maxWidth, Math.max(h.minWidth, L)), H = Math.min(h.maxHeight, Math.max(h.minHeight, H)), p.includes("w") && (v = d.x + (d.width - L)), p.includes("n") && (z = d.y + (d.height - H)), p.includes("e") && Math.abs(v + L - window.innerWidth) <= X && (L = window.innerWidth - v), p.includes("w") && Math.abs(v) <= X && (L += v, v = 0), p.includes("s") && Math.abs(z + H - window.innerHeight) <= X && (H = window.innerHeight - z), p.includes("n") && Math.abs(z) <= X && (H += z, z = 0), t = { ...t, x: v, y: z, width: L, height: H, dock: null }, M();
|
|
425
|
+
}, j = (r, b, h, v) => {
|
|
426
426
|
if (t.dock) {
|
|
427
|
-
const
|
|
428
|
-
t = { ...t, ...
|
|
427
|
+
const z = y || { width: s.width, height: s.height }, L = l.x / Math.max(1, t.width);
|
|
428
|
+
t = { ...t, ...z, dock: null }, l = { x: Math.round(z.width * L), y: Math.min(l.y, 32) }, d = {
|
|
429
429
|
...d,
|
|
430
|
-
x:
|
|
431
|
-
y:
|
|
432
|
-
px: d.px +
|
|
430
|
+
x: h - l.x,
|
|
431
|
+
y: v - l.y,
|
|
432
|
+
px: d.px + r,
|
|
433
433
|
py: d.py + b
|
|
434
|
-
},
|
|
434
|
+
}, r = 0, b = 0;
|
|
435
435
|
}
|
|
436
|
-
t = R({ ...t, x: d.x +
|
|
437
|
-
},
|
|
438
|
-
|
|
439
|
-
},
|
|
440
|
-
|
|
441
|
-
},
|
|
436
|
+
t = R({ ...t, x: d.x + r, y: d.y + b }), M(), x = ze(h, v, u), W(x ? U(x, t) : null);
|
|
437
|
+
}, _ = () => {
|
|
438
|
+
x && (y = y || { width: t.width, height: t.height }, t = { ...t, ...U(x, t), dock: x }, M());
|
|
439
|
+
}, G = (r, b) => (h) => {
|
|
440
|
+
h.button === 0 && (r === "drag" && h.target.closest(".bp-btn") || (g = r, p = b || "", d = { px: h.clientX, py: h.clientY, ...t }, l = { x: h.clientX - t.x, y: h.clientY - t.y }, t.dock || (y = { width: t.width, height: t.height }), e.classList.add(r === "drag" ? "bp-dragging" : "bp-resizing"), h.currentTarget.setPointerCapture(h.pointerId), h.preventDefault()));
|
|
441
|
+
}, D = (r) => {
|
|
442
442
|
if (!g || !d) return;
|
|
443
|
-
const b =
|
|
444
|
-
g === "drag" ?
|
|
445
|
-
}, B = (
|
|
443
|
+
const b = r.clientX - d.px, h = r.clientY - d.py;
|
|
444
|
+
g === "drag" ? j(b, h, r.clientX, r.clientY) : $(b, h);
|
|
445
|
+
}, B = (r) => {
|
|
446
446
|
if (g) {
|
|
447
|
-
e.classList.remove("bp-dragging", "bp-resizing"),
|
|
447
|
+
e.classList.remove("bp-dragging", "bp-resizing"), W(null), g === "drag" && _(), g = null, p = "", d = null, x = null;
|
|
448
448
|
try {
|
|
449
|
-
|
|
449
|
+
r.currentTarget.releasePointerCapture(r.pointerId);
|
|
450
450
|
} catch (b) {
|
|
451
451
|
}
|
|
452
|
-
|
|
452
|
+
K(t);
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
|
-
a.addEventListener("pointerdown",
|
|
456
|
-
|
|
455
|
+
a.addEventListener("pointerdown", G("drag")), a.addEventListener("pointermove", D), a.addEventListener("pointerup", B), a.addEventListener("pointercancel", B), (n || []).forEach(({ el: r, dir: b }) => {
|
|
456
|
+
r.addEventListener("pointerdown", G("resize", b)), r.addEventListener("pointermove", D), r.addEventListener("pointerup", B), r.addEventListener("pointercancel", B);
|
|
457
457
|
});
|
|
458
|
-
const
|
|
459
|
-
t = t.dock ? { ...t, ...
|
|
458
|
+
const P = () => {
|
|
459
|
+
t = t.dock ? { ...t, ...U(t.dock, t) } : R(t), M();
|
|
460
460
|
};
|
|
461
|
-
window.addEventListener("resize",
|
|
462
|
-
const
|
|
463
|
-
start(
|
|
464
|
-
var b,
|
|
465
|
-
g = "drag", d = { px:
|
|
461
|
+
window.addEventListener("resize", P);
|
|
462
|
+
const Y = {
|
|
463
|
+
start(r) {
|
|
464
|
+
var b, h;
|
|
465
|
+
g = "drag", d = { px: r.x, py: r.y, ...t }, l = { x: (b = r.cx) != null ? b : t.width / 2, y: (h = r.cy) != null ? h : 20 }, t.dock || (y = { width: t.width, height: t.height }), e.classList.add("bp-dragging");
|
|
466
466
|
},
|
|
467
|
-
move(
|
|
467
|
+
move(r) {
|
|
468
468
|
if (g !== "drag" || !d) return;
|
|
469
|
-
const b =
|
|
470
|
-
|
|
469
|
+
const b = r.x - d.px, h = r.y - d.py;
|
|
470
|
+
j(b, h, d.x + b + l.x, d.y + h + l.y);
|
|
471
471
|
},
|
|
472
472
|
end() {
|
|
473
|
-
g === "drag" && (e.classList.remove("bp-dragging"),
|
|
473
|
+
g === "drag" && (e.classList.remove("bp-dragging"), W(null), _(), g = null, d = null, x = null, K(t));
|
|
474
474
|
}
|
|
475
475
|
};
|
|
476
|
-
return
|
|
477
|
-
external:
|
|
476
|
+
return M(), {
|
|
477
|
+
external: Y,
|
|
478
478
|
get geometry() {
|
|
479
479
|
return { ...t };
|
|
480
480
|
},
|
|
481
|
-
set(
|
|
482
|
-
const b =
|
|
483
|
-
|
|
481
|
+
set(r) {
|
|
482
|
+
const b = he(s), h = { ...t, ...r, dock: null };
|
|
483
|
+
h.width = Math.min(b.maxWidth, Math.max(b.minWidth, h.width)), h.height = Math.min(b.maxHeight, Math.max(b.minHeight, h.height)), t = R(h), M(), K(t);
|
|
484
484
|
},
|
|
485
485
|
/** 'left' | 'right' | 'left-half' | 'right-half' | 'max' | 'float' */
|
|
486
|
-
dock(
|
|
487
|
-
if (!
|
|
486
|
+
dock(r) {
|
|
487
|
+
if (!r || r === "float") {
|
|
488
488
|
const b = y || { width: s.width, height: s.height };
|
|
489
489
|
t = R({ ...t, ...b, dock: null });
|
|
490
490
|
} else
|
|
491
|
-
t.dock || (y = { width: t.width, height: t.height }), t = { ...t, ...
|
|
492
|
-
|
|
491
|
+
t.dock || (y = { width: t.width, height: t.height }), t = { ...t, ...U(r, t), dock: r };
|
|
492
|
+
M(), K(t);
|
|
493
493
|
},
|
|
494
494
|
destroy() {
|
|
495
|
-
window.removeEventListener("resize",
|
|
495
|
+
window.removeEventListener("resize", P);
|
|
496
496
|
}
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
|
-
const
|
|
500
|
-
function
|
|
501
|
-
const
|
|
502
|
-
let
|
|
503
|
-
const u = [],
|
|
499
|
+
const le = "bravophone/v1";
|
|
500
|
+
function Se({ frame: e, origin: a, onEvent: n }) {
|
|
501
|
+
const o = /* @__PURE__ */ new Map();
|
|
502
|
+
let i = 0, s = !1;
|
|
503
|
+
const u = [], m = (g) => {
|
|
504
504
|
var d;
|
|
505
505
|
if (g.origin !== a || g.source !== e.contentWindow) return;
|
|
506
506
|
const p = g.data;
|
|
507
|
-
if (!(!p || p.protocol !==
|
|
507
|
+
if (!(!p || p.protocol !== le)) {
|
|
508
508
|
if (p.type === "ready") {
|
|
509
509
|
for (s = !0; u.length; ) u.shift()();
|
|
510
|
-
|
|
510
|
+
n == null || n("ready", (d = p.payload) != null ? d : {});
|
|
511
511
|
return;
|
|
512
512
|
}
|
|
513
513
|
if (p.type === "reply") {
|
|
514
|
-
const
|
|
515
|
-
if (!
|
|
516
|
-
|
|
514
|
+
const l = o.get(p.id);
|
|
515
|
+
if (!l) return;
|
|
516
|
+
o.delete(p.id), clearTimeout(l.timer), p.error ? l.reject(new Error(p.error)) : l.resolve(p.payload);
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
|
-
p.type === "event" && (
|
|
519
|
+
p.type === "event" && (n == null || n(p.name, p.payload));
|
|
520
520
|
}
|
|
521
521
|
};
|
|
522
|
-
window.addEventListener("message",
|
|
522
|
+
window.addEventListener("message", m);
|
|
523
523
|
function t(g, p, { timeout: d = 15e3 } = {}) {
|
|
524
|
-
return new Promise((
|
|
525
|
-
const y = `${Date.now()}-${++
|
|
526
|
-
var
|
|
527
|
-
const
|
|
528
|
-
|
|
524
|
+
return new Promise((l, x) => {
|
|
525
|
+
const y = `${Date.now()}-${++i}`, M = () => {
|
|
526
|
+
var $;
|
|
527
|
+
const W = setTimeout(() => {
|
|
528
|
+
o.delete(y), x(new Error(`Bravophone: timeout no comando "${g}"`));
|
|
529
529
|
}, d);
|
|
530
|
-
|
|
531
|
-
{ protocol:
|
|
530
|
+
o.set(y, { resolve: l, reject: x, timer: W }), ($ = e.contentWindow) == null || $.postMessage(
|
|
531
|
+
{ protocol: le, type: "command", id: y, command: g, payload: p },
|
|
532
532
|
a
|
|
533
533
|
);
|
|
534
534
|
};
|
|
535
|
-
s ?
|
|
535
|
+
s ? M() : u.push(M);
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
538
|
return {
|
|
@@ -541,73 +541,117 @@ function Me({ frame: e, origin: a, onEvent: i }) {
|
|
|
541
541
|
return s;
|
|
542
542
|
},
|
|
543
543
|
destroy() {
|
|
544
|
-
window.removeEventListener("message",
|
|
544
|
+
window.removeEventListener("message", m), o.forEach(({ reject: g, timer: p }) => {
|
|
545
545
|
clearTimeout(p), g(new Error("Bravophone: widget destruído"));
|
|
546
|
-
}),
|
|
546
|
+
}), o.clear();
|
|
547
547
|
}
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
|
-
const
|
|
551
|
-
function
|
|
550
|
+
const ge = "bravophone:launcher", Ee = 4, ae = 8;
|
|
551
|
+
function He(e) {
|
|
552
552
|
try {
|
|
553
|
-
const a = localStorage.getItem(
|
|
553
|
+
const a = localStorage.getItem(ge);
|
|
554
554
|
return a ? { ...e, ...JSON.parse(a) } : { ...e };
|
|
555
555
|
} catch (a) {
|
|
556
556
|
return { ...e };
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function ie(e) {
|
|
560
560
|
try {
|
|
561
|
-
localStorage.setItem(
|
|
561
|
+
localStorage.setItem(ge, JSON.stringify(e));
|
|
562
562
|
} catch (a) {
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
|
-
function
|
|
566
|
-
const
|
|
567
|
-
return Math.min(Math.max(
|
|
568
|
-
}
|
|
569
|
-
function
|
|
570
|
-
let
|
|
571
|
-
const
|
|
572
|
-
e.dataset.side =
|
|
573
|
-
}, t = (
|
|
574
|
-
|
|
575
|
-
}, g = (
|
|
565
|
+
function F(e, a) {
|
|
566
|
+
const n = Math.max(ae, window.innerHeight - a - ae);
|
|
567
|
+
return Math.min(Math.max(ae, e), n);
|
|
568
|
+
}
|
|
569
|
+
function $e({ el: e, side: a, y: n, onOpen: o }) {
|
|
570
|
+
let i = { side: a, y: F(n, e.offsetHeight || 48) }, s = null, u = !1;
|
|
571
|
+
const m = () => {
|
|
572
|
+
e.dataset.side = i.side, e.style.top = `${i.y}px`, e.style.right = i.side === "right" ? "0px" : "auto", e.style.left = i.side === "left" ? "0px" : "auto";
|
|
573
|
+
}, t = (l) => {
|
|
574
|
+
l.button === 0 && (s = { py: l.clientY, y: i.y }, u = !1, e.setPointerCapture(l.pointerId));
|
|
575
|
+
}, g = (l) => {
|
|
576
576
|
if (!s) return;
|
|
577
|
-
const
|
|
578
|
-
!u && Math.abs(
|
|
579
|
-
}, p = (
|
|
577
|
+
const x = l.clientY - s.py;
|
|
578
|
+
!u && Math.abs(x) < Ee || (u || (u = !0, e.classList.add("bp-launcher-dragging")), i.y = F(s.y + x, e.offsetHeight), m());
|
|
579
|
+
}, p = (l) => {
|
|
580
580
|
if (!s) return;
|
|
581
|
-
const
|
|
581
|
+
const x = u;
|
|
582
582
|
s = null, u = !1, e.classList.remove("bp-launcher-dragging");
|
|
583
583
|
try {
|
|
584
|
-
e.releasePointerCapture(
|
|
584
|
+
e.releasePointerCapture(l.pointerId);
|
|
585
585
|
} catch (y) {
|
|
586
586
|
}
|
|
587
|
-
|
|
587
|
+
x ? ie(i) : o == null || o();
|
|
588
588
|
};
|
|
589
|
-
e.addEventListener("pointerdown", t), e.addEventListener("pointermove", g), e.addEventListener("pointerup", p), e.addEventListener("pointercancel", p), e.addEventListener("keydown", (
|
|
590
|
-
(
|
|
589
|
+
e.addEventListener("pointerdown", t), e.addEventListener("pointermove", g), e.addEventListener("pointerup", p), e.addEventListener("pointercancel", p), e.addEventListener("keydown", (l) => {
|
|
590
|
+
(l.key === "Enter" || l.key === " ") && (l.preventDefault(), o == null || o());
|
|
591
591
|
});
|
|
592
592
|
const d = () => {
|
|
593
|
-
|
|
593
|
+
i.y = F(i.y, e.offsetHeight), m();
|
|
594
594
|
};
|
|
595
|
-
return window.addEventListener("resize", d),
|
|
595
|
+
return window.addEventListener("resize", d), m(), {
|
|
596
596
|
get state() {
|
|
597
|
-
return { ...
|
|
597
|
+
return { ...i };
|
|
598
598
|
},
|
|
599
|
-
setSide(
|
|
600
|
-
|
|
599
|
+
setSide(l) {
|
|
600
|
+
i.side = l, m(), ie(i);
|
|
601
601
|
},
|
|
602
|
-
moveTo(
|
|
603
|
-
|
|
602
|
+
moveTo(l) {
|
|
603
|
+
i.y = F(l, e.offsetHeight), m(), ie(i);
|
|
604
604
|
},
|
|
605
605
|
destroy() {
|
|
606
606
|
window.removeEventListener("resize", d);
|
|
607
607
|
}
|
|
608
608
|
};
|
|
609
609
|
}
|
|
610
|
-
const
|
|
610
|
+
const Te = "https://cdn.jsdelivr.net/npm";
|
|
611
|
+
function Ie(e, a = "@bravophone/webphone") {
|
|
612
|
+
return `${Te}/${a}@${e}/host/`;
|
|
613
|
+
}
|
|
614
|
+
function Oe({ version: e, parentOrigin: a, token: n, base: o }) {
|
|
615
|
+
const i = o || Ie(e), s = JSON.stringify({ parentOrigin: a, token: n || null }).replace(/</g, "\\u003c");
|
|
616
|
+
return `<!doctype html>
|
|
617
|
+
<html lang="pt-BR">
|
|
618
|
+
<head>
|
|
619
|
+
<meta charset="UTF-8">
|
|
620
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
621
|
+
<title>Webphone BRAVOPHONE</title>
|
|
622
|
+
<link rel="stylesheet" href="${i}css/dark-theme.css">
|
|
623
|
+
<link rel="stylesheet" href="${i}styles/theme-fixes.css">
|
|
624
|
+
<style>
|
|
625
|
+
html, body { margin: 0; height: 100%; background: #10131c; overflow: hidden; }
|
|
626
|
+
#app { height: 100%; }
|
|
627
|
+
</style>
|
|
628
|
+
<script>
|
|
629
|
+
(function () {
|
|
630
|
+
var cfg = ${s};
|
|
631
|
+
// O guest-bridge lê daqui: em srcdoc não há query string para carregar a
|
|
632
|
+
// origem do pai.
|
|
633
|
+
window.__bpParentOrigin = cfg.parentOrigin;
|
|
634
|
+
if (cfg.token) {
|
|
635
|
+
// Grava onde o bundle procura, antes dele avaliar, para a sessão já subir
|
|
636
|
+
// autenticada em vez de piscar a tela de login.
|
|
637
|
+
try { localStorage.setItem('bp.local.vxToken', JSON.stringify(cfg.token)); } catch (e) {}
|
|
638
|
+
}
|
|
639
|
+
})();
|
|
640
|
+
<\/script>
|
|
641
|
+
<script src="${i}shim/messages.js"><\/script>
|
|
642
|
+
<script src="${i}shim/chrome-shim.js"><\/script>
|
|
643
|
+
<script src="${i}js/libwebphone.js"><\/script>
|
|
644
|
+
<script src="${i}js/bravophone-route-selector.js"><\/script>
|
|
645
|
+
<script defer src="${i}popup.js"><\/script>
|
|
646
|
+
<script defer src="${i}shim/guest-bridge.js"><\/script>
|
|
647
|
+
</head>
|
|
648
|
+
<body>
|
|
649
|
+
<noscript><strong>O webphone precisa de JavaScript habilitado.</strong></noscript>
|
|
650
|
+
<div id="app"></div>
|
|
651
|
+
</body>
|
|
652
|
+
</html>`;
|
|
653
|
+
}
|
|
654
|
+
const be = {
|
|
611
655
|
// 380x640 é a geometria da janela nativa da extensão — o layout do
|
|
612
656
|
// webphone é calibrado para ela, então é o ponto de partida aqui também.
|
|
613
657
|
width: 380,
|
|
@@ -620,196 +664,212 @@ const ce = {
|
|
|
620
664
|
maxHeight: 1400,
|
|
621
665
|
margin: 24
|
|
622
666
|
};
|
|
623
|
-
function
|
|
624
|
-
const
|
|
625
|
-
for (const [
|
|
626
|
-
|
|
627
|
-
return
|
|
667
|
+
function w(e, a = {}, n = []) {
|
|
668
|
+
const o = document.createElement(e);
|
|
669
|
+
for (const [i, s] of Object.entries(a))
|
|
670
|
+
i === "class" ? o.className = s : i === "text" ? o.textContent = s : s != null && o.setAttribute(i, s);
|
|
671
|
+
return n.forEach((i) => o.appendChild(i)), o;
|
|
628
672
|
}
|
|
629
|
-
function
|
|
673
|
+
function We(e) {
|
|
630
674
|
const {
|
|
631
675
|
hostUrl: a,
|
|
632
|
-
token:
|
|
633
|
-
position:
|
|
634
|
-
open:
|
|
676
|
+
token: n,
|
|
677
|
+
position: o = "bottom-right",
|
|
678
|
+
open: i = !1,
|
|
635
679
|
launcher: s = !0,
|
|
636
680
|
title: u = "BRAVOPHONE",
|
|
637
681
|
// 'none' preserva 100% da UI do webphone: sem barra de titulo, o arraste
|
|
638
682
|
// vem de dentro do iframe. 'bar' adiciona a barra com titulo e controles.
|
|
639
|
-
frame:
|
|
683
|
+
frame: m = "none",
|
|
640
684
|
// O que arrastar até a borda de cima faz. 'max' é o gesto universal;
|
|
641
685
|
// troque para 'top-half' se preferir as metades verticais no topo.
|
|
642
686
|
dockTop: t = "max",
|
|
643
687
|
// Lado da viewport em que a aba de abertura fica colada.
|
|
644
688
|
launcherSide: g = "right",
|
|
645
689
|
// Desenho da aba: 'phone-waves' | 'waveform' | 'headset' | 'chat-phone'
|
|
646
|
-
launcherIcon: p =
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
690
|
+
launcherIcon: p = te,
|
|
691
|
+
// 'hosted' — o iframe navega para hostUrl (padrão)
|
|
692
|
+
// 'srcdoc' — o iframe roda na origem do site e busca o conteúdo no CDN
|
|
693
|
+
mode: d = "hosted",
|
|
694
|
+
// Base dos assets no modo srcdoc. Padrão: o CDN travado nesta versão.
|
|
695
|
+
// Serve para desenvolvimento (localhost) e para quem espelhar os assets.
|
|
696
|
+
hostBase: l,
|
|
697
|
+
version: x,
|
|
698
|
+
emit: y
|
|
699
|
+
} = e, M = d === "srcdoc", W = M ? window.location.origin : new URL(a).origin, $ = w("div", { "data-bravophone": "root" });
|
|
700
|
+
$.style.cssText = "all:initial;position:static";
|
|
701
|
+
const j = $.attachShadow({ mode: "open" });
|
|
702
|
+
j.appendChild(w("style", { text: ke }));
|
|
703
|
+
const _ = (() => {
|
|
704
|
+
var pe;
|
|
705
|
+
const { width: c, height: E, margin: O } = be, N = window.innerWidth - c - O, de = window.innerHeight - E - O, ce = {
|
|
706
|
+
"bottom-right": { x: N, y: de },
|
|
707
|
+
"bottom-left": { x: O, y: de },
|
|
708
|
+
"top-right": { x: N, y: O },
|
|
709
|
+
"top-left": { x: O, y: O }
|
|
659
710
|
};
|
|
660
|
-
return R({ ...(
|
|
661
|
-
})(),
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
711
|
+
return R({ ...(pe = ce[o]) != null ? pe : ce["bottom-right"], width: c, height: E });
|
|
712
|
+
})(), G = R(Me(_)), D = w("span", { class: "bp-status", "data-state": "connecting" }), B = w("button", { class: "bp-btn bp-btn-min", title: "Minimizar", text: "—" }), P = w("button", { class: "bp-btn bp-btn-close", title: "Fechar", text: "×" }), Y = w("div", { class: "bp-header" }, [
|
|
713
|
+
D,
|
|
714
|
+
w("span", { class: "bp-title", text: u }),
|
|
715
|
+
B,
|
|
665
716
|
P
|
|
666
|
-
]),
|
|
717
|
+
]), r = w("iframe", {
|
|
667
718
|
class: "bp-frame",
|
|
668
|
-
|
|
719
|
+
// allow= é obrigatório no modo hospedado (cross-origin). Em srcdoc o
|
|
720
|
+
// microfone já é herdado do topo, mas declarar não custa e documenta.
|
|
669
721
|
allow: "microphone; autoplay; clipboard-write; speaker-selection",
|
|
670
722
|
title: "Webphone BRAVOPHONE"
|
|
671
|
-
})
|
|
672
|
-
|
|
723
|
+
});
|
|
724
|
+
M ? r.setAttribute(
|
|
725
|
+
"srcdoc",
|
|
726
|
+
Oe({ version: x, parentOrigin: W, token: n, base: l })
|
|
727
|
+
) : r.setAttribute(
|
|
728
|
+
"src",
|
|
729
|
+
Be(new URL(a), { token: n, embed: "1", parent: location.origin })
|
|
730
|
+
);
|
|
731
|
+
const h = ["n", "s", "w", "e", "nw", "ne", "sw", "se"].map((c) => ({
|
|
732
|
+
el: w("div", { class: `bp-h bp-h-${c}` }),
|
|
673
733
|
dir: c
|
|
674
|
-
})),
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
const
|
|
734
|
+
})), v = w("div", { class: "bp-preview" });
|
|
735
|
+
v.hidden = !0;
|
|
736
|
+
const z = w("button", { class: "bp-btn bp-btn-close", title: "Fechar", text: "×" }), L = w("div", { class: "bp-overlay" }, [z]), H = w("div", { class: "bp-body" }, [r, L]), T = w("div", { class: "bp-root" }, [Y, H, ...h.map((c) => c.el)]);
|
|
737
|
+
m !== "bar" && T.classList.add("bp-chromeless"), T.hidden = !i;
|
|
738
|
+
const Q = w("span", { class: "bp-launcher-icon" });
|
|
739
|
+
Q.innerHTML = J[p] || J[te];
|
|
740
|
+
const re = w("span", { class: "bp-launcher-grip", "aria-hidden": "true" });
|
|
741
|
+
re.innerHTML = ye;
|
|
742
|
+
const S = w("div", {
|
|
683
743
|
class: "bp-launcher",
|
|
684
744
|
role: "button",
|
|
685
745
|
tabindex: "0",
|
|
686
746
|
title: "Abrir webphone",
|
|
687
747
|
"aria-label": "Abrir webphone"
|
|
688
748
|
}, [
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
749
|
+
re,
|
|
750
|
+
Q,
|
|
751
|
+
w("span", { class: "bp-badge" })
|
|
692
752
|
]);
|
|
693
|
-
|
|
694
|
-
const
|
|
753
|
+
S.dataset.state = "connecting", S.hidden = !s || i, j.append(v, T, S), document.body.appendChild($);
|
|
754
|
+
const oe = He({
|
|
695
755
|
side: g,
|
|
696
756
|
y: Math.round(window.innerHeight / 2 - 24)
|
|
697
|
-
}),
|
|
698
|
-
el:
|
|
699
|
-
side:
|
|
700
|
-
y:
|
|
701
|
-
onOpen: () =>
|
|
702
|
-
}),
|
|
703
|
-
root:
|
|
704
|
-
handle:
|
|
705
|
-
handles:
|
|
706
|
-
preview:
|
|
707
|
-
geometry:
|
|
708
|
-
limits:
|
|
757
|
+
}), se = $e({
|
|
758
|
+
el: S,
|
|
759
|
+
side: oe.side,
|
|
760
|
+
y: F(oe.y, 48),
|
|
761
|
+
onOpen: () => I.show()
|
|
762
|
+
}), A = Le({
|
|
763
|
+
root: T,
|
|
764
|
+
handle: Y,
|
|
765
|
+
handles: h,
|
|
766
|
+
preview: v,
|
|
767
|
+
geometry: G,
|
|
768
|
+
limits: be,
|
|
709
769
|
topDock: t,
|
|
710
|
-
onChange: (c) =>
|
|
711
|
-
}),
|
|
712
|
-
frame:
|
|
713
|
-
origin:
|
|
770
|
+
onChange: (c) => y("resize", { width: c.width, height: c.height, dock: c.dock || null })
|
|
771
|
+
}), ee = Se({
|
|
772
|
+
frame: r,
|
|
773
|
+
origin: W,
|
|
714
774
|
onEvent: (c, E) => {
|
|
715
|
-
var
|
|
716
|
-
if (c === "ready" && (
|
|
775
|
+
var O;
|
|
776
|
+
if (c === "ready" && (D.dataset.state = "ready", S.dataset.state = "ready", n && ee.call("auth", { token: n }).catch(() => {
|
|
717
777
|
})), c === "state") {
|
|
718
|
-
const N = (
|
|
719
|
-
|
|
778
|
+
const N = (O = E == null ? void 0 : E.state) != null ? O : "ready";
|
|
779
|
+
D.dataset.state = N, S.dataset.state = N;
|
|
720
780
|
}
|
|
721
|
-
if (c === "call:incoming" && (
|
|
722
|
-
|
|
781
|
+
if (c === "call:incoming" && (I.show(), S.dataset.badge = "1", S.dataset.state = "ringing"), c === "call:answered" && (S.dataset.state = "incall"), (c === "call:ended" || c === "call:failed") && (delete S.dataset.badge, S.dataset.state = "ready"), c === "drag:start") {
|
|
782
|
+
A.external.start(E);
|
|
723
783
|
return;
|
|
724
784
|
}
|
|
725
785
|
if (c === "drag:move") {
|
|
726
|
-
|
|
786
|
+
A.external.move(E);
|
|
727
787
|
return;
|
|
728
788
|
}
|
|
729
789
|
if (c === "drag:end") {
|
|
730
|
-
|
|
790
|
+
A.external.end();
|
|
731
791
|
return;
|
|
732
792
|
}
|
|
733
|
-
|
|
793
|
+
y(c, E);
|
|
734
794
|
}
|
|
735
795
|
});
|
|
736
|
-
let
|
|
737
|
-
const
|
|
738
|
-
el:
|
|
739
|
-
bridge:
|
|
796
|
+
let q = !1;
|
|
797
|
+
const I = {
|
|
798
|
+
el: $,
|
|
799
|
+
bridge: ee,
|
|
740
800
|
show() {
|
|
741
|
-
|
|
801
|
+
T.hidden = !1, S.hidden = !0, y("open");
|
|
742
802
|
},
|
|
743
803
|
hide() {
|
|
744
|
-
|
|
804
|
+
T.hidden = !0, s && (S.hidden = !1), y("close");
|
|
745
805
|
},
|
|
746
806
|
toggle() {
|
|
747
|
-
|
|
807
|
+
T.hidden ? I.show() : I.hide();
|
|
748
808
|
},
|
|
749
809
|
get isOpen() {
|
|
750
|
-
return !
|
|
810
|
+
return !T.hidden;
|
|
751
811
|
},
|
|
752
812
|
minimize(c) {
|
|
753
|
-
if (
|
|
754
|
-
|
|
813
|
+
if (m !== "bar") {
|
|
814
|
+
I.hide();
|
|
755
815
|
return;
|
|
756
816
|
}
|
|
757
|
-
|
|
817
|
+
q = c != null ? c : !q, T.classList.toggle("bp-minimized", q), B.textContent = q ? "▢" : "—";
|
|
758
818
|
},
|
|
759
819
|
move(c, E) {
|
|
760
|
-
|
|
820
|
+
A.set({ x: c, y: E });
|
|
761
821
|
},
|
|
762
822
|
resize(c, E) {
|
|
763
|
-
|
|
823
|
+
A.set({ width: c, height: E });
|
|
764
824
|
},
|
|
765
825
|
dock(c) {
|
|
766
|
-
|
|
826
|
+
A.dock(c);
|
|
767
827
|
},
|
|
768
828
|
setLauncherSide(c) {
|
|
769
|
-
|
|
829
|
+
se.setSide(c);
|
|
770
830
|
},
|
|
771
831
|
setLauncherIcon(c) {
|
|
772
|
-
|
|
832
|
+
Q.innerHTML = J[c] || J[te];
|
|
773
833
|
},
|
|
774
834
|
get geometry() {
|
|
775
|
-
return
|
|
835
|
+
return A.geometry;
|
|
776
836
|
},
|
|
777
837
|
destroy() {
|
|
778
|
-
|
|
838
|
+
ee.destroy(), A.destroy(), se.destroy(), v.remove(), $.remove();
|
|
779
839
|
}
|
|
780
840
|
};
|
|
781
|
-
return P.addEventListener("click", () =>
|
|
782
|
-
}
|
|
783
|
-
function
|
|
784
|
-
const
|
|
785
|
-
for (const [
|
|
786
|
-
|
|
787
|
-
return a.token && (
|
|
788
|
-
}
|
|
789
|
-
const
|
|
790
|
-
let
|
|
791
|
-
const
|
|
792
|
-
function
|
|
793
|
-
var
|
|
794
|
-
(
|
|
841
|
+
return P.addEventListener("click", () => I.hide()), B.addEventListener("click", () => I.minimize()), z.addEventListener("click", () => I.hide()), I;
|
|
842
|
+
}
|
|
843
|
+
function Be(e, a) {
|
|
844
|
+
const n = new URL(e.href);
|
|
845
|
+
for (const [o, i] of Object.entries(a))
|
|
846
|
+
i != null && i !== "" && n.searchParams.set(o, i);
|
|
847
|
+
return a.token && (n.searchParams.delete("token"), n.hash = `token=${encodeURIComponent(a.token)}`), n.href;
|
|
848
|
+
}
|
|
849
|
+
const Ae = "https://webphone.bravophone.com/embed/";
|
|
850
|
+
let k = null;
|
|
851
|
+
const C = /* @__PURE__ */ new Map();
|
|
852
|
+
function Ce(e, a) {
|
|
853
|
+
var n, o;
|
|
854
|
+
(n = C.get(e)) == null || n.forEach((i) => {
|
|
795
855
|
try {
|
|
796
|
-
|
|
856
|
+
i(a);
|
|
797
857
|
} catch (s) {
|
|
798
858
|
console.error("[Bravophone] listener falhou:", s);
|
|
799
859
|
}
|
|
800
|
-
}), (
|
|
860
|
+
}), (o = C.get("*")) == null || o.forEach((i) => {
|
|
801
861
|
try {
|
|
802
|
-
|
|
862
|
+
i({ event: e, payload: a });
|
|
803
863
|
} catch (s) {
|
|
804
864
|
console.error("[Bravophone] listener falhou:", s);
|
|
805
865
|
}
|
|
806
866
|
});
|
|
807
867
|
}
|
|
808
|
-
function
|
|
809
|
-
if (!
|
|
810
|
-
return
|
|
868
|
+
function f() {
|
|
869
|
+
if (!k) throw new Error("Bravophone: chame Bravophone.init() antes.");
|
|
870
|
+
return k;
|
|
811
871
|
}
|
|
812
|
-
const
|
|
872
|
+
const ne = {
|
|
813
873
|
/**
|
|
814
874
|
* Monta o webphone na página.
|
|
815
875
|
* @param {object} opts
|
|
@@ -817,102 +877,113 @@ const le = {
|
|
|
817
877
|
* @param {string} [opts.token] Token de sessão do usuário (SSO do integrador).
|
|
818
878
|
* @param {'bottom-right'|'bottom-left'|'top-right'|'top-left'} [opts.position]
|
|
819
879
|
* @param {boolean} [opts.open] Abrir já visível (padrão: false, só o launcher).
|
|
820
|
-
* @param {boolean} [opts.launcher] Exibir
|
|
880
|
+
* @param {boolean} [opts.launcher] Exibir a aba de abertura (padrão: true).
|
|
881
|
+
* @param {'hosted'|'srcdoc'} [opts.mode]
|
|
882
|
+
* 'hosted' (padrão): o iframe navega para `hostUrl`. Uma origem fixa para
|
|
883
|
+
* o CORS dos backends, mas é um iframe de terceiro.
|
|
884
|
+
* 'srcdoc': o iframe roda na origem do próprio site e busca o webphone no
|
|
885
|
+
* CDN. Some o iframe de terceiro — em troca, a origem do integrador
|
|
886
|
+
* precisa estar na allowlist de CORS dos backends.
|
|
821
887
|
*/
|
|
822
888
|
init(e = {}) {
|
|
823
|
-
if (
|
|
889
|
+
if (k) return k;
|
|
824
890
|
if (typeof window == "undefined" || !document.body)
|
|
825
891
|
throw new Error("Bravophone: init() precisa rodar no browser, após o <body> existir.");
|
|
826
|
-
return location.protocol !== "https:" && location.hostname !== "localhost" && console.warn("[Bravophone] Contexto inseguro: o microfone exige HTTPS ou localhost."),
|
|
892
|
+
return location.protocol !== "https:" && location.hostname !== "localhost" && console.warn("[Bravophone] Contexto inseguro: o microfone exige HTTPS ou localhost."), k = We({
|
|
893
|
+
hostUrl: Ae,
|
|
894
|
+
version: ne.version,
|
|
895
|
+
...e,
|
|
896
|
+
emit: Ce
|
|
897
|
+
}), k;
|
|
827
898
|
},
|
|
828
899
|
// ---- Controle da janela ----
|
|
829
900
|
show() {
|
|
830
|
-
|
|
901
|
+
f().show();
|
|
831
902
|
},
|
|
832
903
|
hide() {
|
|
833
|
-
|
|
904
|
+
f().hide();
|
|
834
905
|
},
|
|
835
906
|
toggle() {
|
|
836
|
-
|
|
907
|
+
f().toggle();
|
|
837
908
|
},
|
|
838
909
|
minimize(e) {
|
|
839
|
-
|
|
910
|
+
f().minimize(e);
|
|
840
911
|
},
|
|
841
912
|
move(e, a) {
|
|
842
|
-
|
|
913
|
+
f().move(e, a);
|
|
843
914
|
},
|
|
844
915
|
resize(e, a) {
|
|
845
|
-
|
|
916
|
+
f().resize(e, a);
|
|
846
917
|
},
|
|
847
918
|
/** 'left' | 'right' | 'left-half' | 'right-half' | 'max' | 'float' */
|
|
848
919
|
dock(e) {
|
|
849
|
-
|
|
920
|
+
f().dock(e);
|
|
850
921
|
},
|
|
851
922
|
/** Move a aba de abertura para o outro lado da viewport. */
|
|
852
923
|
setLauncherSide(e) {
|
|
853
|
-
|
|
924
|
+
f().setLauncherSide(e);
|
|
854
925
|
},
|
|
855
926
|
/** 'phone-waves' | 'waveform' | 'headset' | 'chat-phone' */
|
|
856
927
|
setLauncherIcon(e) {
|
|
857
|
-
|
|
928
|
+
f().setLauncherIcon(e);
|
|
858
929
|
},
|
|
859
930
|
get isOpen() {
|
|
860
|
-
return
|
|
931
|
+
return k ? k.isOpen : !1;
|
|
861
932
|
},
|
|
862
933
|
get geometry() {
|
|
863
|
-
return
|
|
934
|
+
return k ? k.geometry : null;
|
|
864
935
|
},
|
|
865
936
|
// ---- Telefonia ----
|
|
866
937
|
/** Disca um número. Aceita formato livre; a normalização é a mesma da extensão. */
|
|
867
938
|
call(e, a) {
|
|
868
|
-
return
|
|
939
|
+
return f().bridge.call("call", { number: e, meta: a });
|
|
869
940
|
},
|
|
870
941
|
hangup() {
|
|
871
|
-
return
|
|
942
|
+
return f().bridge.call("hangup");
|
|
872
943
|
},
|
|
873
944
|
answer() {
|
|
874
|
-
return
|
|
945
|
+
return f().bridge.call("answer");
|
|
875
946
|
},
|
|
876
947
|
/** Alterna o mudo — o bundle só expõe toggle, não aceita estado alvo. */
|
|
877
948
|
mute() {
|
|
878
|
-
return
|
|
949
|
+
return f().bridge.call("mute");
|
|
879
950
|
},
|
|
880
951
|
/** Alterna a espera. Também toggle. */
|
|
881
952
|
hold() {
|
|
882
|
-
return
|
|
953
|
+
return f().bridge.call("hold");
|
|
883
954
|
},
|
|
884
955
|
sendDTMF(e) {
|
|
885
|
-
return
|
|
956
|
+
return f().bridge.call("dtmf", { tone: e });
|
|
886
957
|
},
|
|
887
958
|
transfer(e) {
|
|
888
|
-
return
|
|
959
|
+
return f().bridge.call("transfer", { to: e });
|
|
889
960
|
},
|
|
890
961
|
getStatus() {
|
|
891
|
-
return
|
|
962
|
+
return f().bridge.call("status");
|
|
892
963
|
},
|
|
893
964
|
setAuth(e) {
|
|
894
|
-
return
|
|
965
|
+
return f().bridge.call("auth", { token: e });
|
|
895
966
|
},
|
|
896
967
|
logout() {
|
|
897
|
-
return
|
|
968
|
+
return f().bridge.call("logout");
|
|
898
969
|
},
|
|
899
970
|
// ---- Eventos ----
|
|
900
971
|
/** Eventos: ready, state, call:dialing, call:incoming, call:answered,
|
|
901
972
|
* call:ended, call:failed, resize, open, close, error. */
|
|
902
973
|
on(e, a) {
|
|
903
|
-
return
|
|
974
|
+
return C.has(e) || C.set(e, /* @__PURE__ */ new Set()), C.get(e).add(a), () => ne.off(e, a);
|
|
904
975
|
},
|
|
905
976
|
off(e, a) {
|
|
906
|
-
var
|
|
907
|
-
(
|
|
977
|
+
var n;
|
|
978
|
+
(n = C.get(e)) == null || n.delete(a);
|
|
908
979
|
},
|
|
909
980
|
destroy() {
|
|
910
|
-
|
|
981
|
+
k == null || k.destroy(), k = null, C.clear();
|
|
911
982
|
},
|
|
912
983
|
// Substituída em build time pelo valor do package.json (ver vite.config.js).
|
|
913
|
-
version: "0.
|
|
984
|
+
version: "0.2.0"
|
|
914
985
|
};
|
|
915
|
-
typeof window != "undefined" && (window.Bravophone =
|
|
986
|
+
typeof window != "undefined" && (window.Bravophone = ne);
|
|
916
987
|
export {
|
|
917
|
-
|
|
988
|
+
ne as default
|
|
918
989
|
};
|