@qaiddev/thumbs-embed 1.11.0 → 1.12.1
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/LICENSE +21 -0
- package/README.md +39 -13
- package/dist/a11y-dialog.d.ts +77 -0
- package/dist/a11y.d.ts +6 -65
- package/dist/chunks/annotate-DGyRcgPt.js +2 -0
- package/dist/chunks/{annotate-5zJWs-aB.js.map → annotate-DGyRcgPt.js.map} +1 -1
- package/dist/chunks/core-BsR7oV99.js +26 -0
- package/dist/chunks/core-BsR7oV99.js.map +1 -0
- package/dist/chunks/dom-scpOS8nl.js +2 -0
- package/dist/chunks/{dom-DvdtcUS8.js.map → dom-scpOS8nl.js.map} +1 -1
- package/dist/chunks/modal-DYxcs1Gm.js +2 -0
- package/dist/chunks/modal-DYxcs1Gm.js.map +1 -0
- package/dist/chunks/recording-BUw5-5Rf.js +2 -0
- package/dist/chunks/{recording-CPzxRL7f.js.map → recording-BUw5-5Rf.js.map} +1 -1
- package/dist/chunks/screenshot-CNe1irEz.js +2 -0
- package/dist/chunks/{screenshot-DYOKg2bS.js.map → screenshot-CNe1irEz.js.map} +1 -1
- package/dist/chunks/screenshot-dom-ZYP2w2h0.js +2 -0
- package/dist/chunks/{screenshot-dom-CME7tYRE.js.map → screenshot-dom-ZYP2w2h0.js.map} +1 -1
- package/dist/chunks/send-C26DRoYc.js +2 -0
- package/dist/chunks/send-C26DRoYc.js.map +1 -0
- package/dist/chunks/targeting-CMUEe-7C.js +6 -0
- package/dist/chunks/{targeting-mahtuPpo.js.map → targeting-CMUEe-7C.js.map} +1 -1
- package/dist/chunks/video-BSP4s2te.js +2 -0
- package/dist/chunks/{video-Bd_29-rK.js.map → video-BSP4s2te.js.map} +1 -1
- package/dist/embed.d.ts +26 -31
- package/dist/index.js +1495 -1390
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +6 -4
- package/dist/loader.js +1 -6
- package/dist/loader.js.map +1 -1
- package/dist/modal-positioning.d.ts +0 -27
- package/dist/qaid.umd.cjs +14 -14
- package/dist/qaid.umd.cjs.map +1 -1
- package/dist/quest-config.d.ts +2 -0
- package/dist/quest-launcher.d.ts +1 -3
- package/dist/send.d.ts +60 -0
- package/dist/tooltip-positioning.d.ts +31 -0
- package/package.json +2 -2
- package/dist/chunks/annotate-5zJWs-aB.js +0 -357
- package/dist/chunks/core-CL1dwdaN.js +0 -1342
- package/dist/chunks/core-CL1dwdaN.js.map +0 -1
- package/dist/chunks/dom-DvdtcUS8.js +0 -17
- package/dist/chunks/modal-DccueVYZ.js +0 -222
- package/dist/chunks/modal-DccueVYZ.js.map +0 -1
- package/dist/chunks/recording-CPzxRL7f.js +0 -323
- package/dist/chunks/screenshot-DYOKg2bS.js +0 -33
- package/dist/chunks/screenshot-dom-CME7tYRE.js +0 -63
- package/dist/chunks/targeting-mahtuPpo.js +0 -298
- package/dist/chunks/video-Bd_29-rK.js +0 -214
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { b as p, T as h, d as m, F as b, D as u, E as g } from "./core-CL1dwdaN.js";
|
|
2
|
-
import { h as a } from "./dom-DvdtcUS8.js";
|
|
3
|
-
const q = ".qaid-backdrop{position:fixed;inset:0;z-index:45;background:#0000004d}.qaid-modal-container{position:fixed;z-index:50;display:flex;flex-direction:column;align-items:flex-start;max-height:calc(100vh - 32px);font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-modal-container.qaid-above{flex-direction:column-reverse}.qaid-modal-arrow{width:0;height:0;border-left:12px solid transparent;border-right:12px solid transparent;position:relative;align-self:flex-start}.qaid-modal-container.qaid-below .qaid-modal-arrow{border-bottom:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-container.qaid-above .qaid-modal-arrow{border-top:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5));width:var(--qaid-modal-width, 400px);max-width:calc(100vw - 32px);max-height:calc(100vh - 60px);overflow-y:auto}.qaid-modal-header{display:flex;align-items:flex-start;gap:.75rem;margin-bottom:1rem}button.qaid-type-toggle{border:none;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s;flex-shrink:0;-webkit-appearance:none;appearance:none}button.qaid-type-toggle:hover{transform:scale(1.1)}button.qaid-type-toggle:not(.qaid-type-toggle-custom){width:2.5rem;height:2.5rem;border-radius:50%}button.qaid-type-toggle:not(.qaid-type-toggle-custom) svg{width:1.25rem;height:1.25rem}button.qaid-type-toggle.qaid-type-up{background:var(--qaid-positive);color:#fff}button.qaid-type-toggle.qaid-type-down{background:var(--qaid-negative);color:#fff}.qaid-type-static{width:2.5rem;height:2.5rem;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:var(--qaid-marker, #6365f1);color:var(--qaid-marker-text, white)}.qaid-type-static svg{width:1.25rem;height:1.25rem}.qaid-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size:calc(var(--qaid-font-size, 16px) * 1.125);font-weight:700;margin:0 0 .25rem;color:light-dark(#1f2937,#f9fafb)}.qaid-modal-subtitle{color:light-dark(#6b7280,#9ca3af);margin:0;font-size:calc(var(--qaid-font-size, 16px) * .875)}.qaid-textarea{width:100%;height:6rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:var(--qaid-font-size, 16px);resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-btn-row{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-btn-submit{padding:.5rem 1rem;background:var(--qaid-marker);color:var(--qaid-marker-text, white);border:none;border-radius:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-btn-submit:hover{filter:brightness(.85)}button.qaid-btn-submit:focus{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 30%,transparent)}.qaid-bottom-sheet{position:fixed;bottom:0;left:0;right:0;z-index:50;animation:qaid-slideUpSheet .3s ease-out;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-bottom-sheet-content{background:light-dark(#ffffff,#1f2937);border-radius:1rem 1rem 0 0;padding:1.5rem;padding-bottom:max(1.5rem,env(safe-area-inset-bottom))}.qaid-bottom-sheet-handle{width:36px;height:4px;background:light-dark(rgba(0,0,0,.2),rgba(255,255,255,.2));border-radius:2px;margin:0 auto 1rem}@keyframes qaid-slideUpSheet{0%{transform:translateY(100%)}to{transform:translateY(0)}}.qaid-confirm{display:flex;flex-direction:column;align-items:center;text-align:center;gap:.5rem;padding:.5rem 0}.qaid-confirm-icon{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:9999px;color:#fff;background:var(--qaid-success, #22c55e);margin-bottom:.25rem;animation:qaid-confirm-pop .28s cubic-bezier(.34,1.56,.64,1)}.qaid-confirm-icon .qaid-icon{width:24px;height:24px}.qaid-confirm-error .qaid-confirm-icon{background:var(--qaid-error, #dc2626)}.qaid-confirm-title{margin:0;font-size:var(--qaid-font-size, 16px);font-weight:600;color:var(--qaid-text, light-dark(#111827, #f9fafb))}.qaid-confirm-title:focus-visible{outline:2px solid var(--qaid-primary, #6365f1);outline-offset:3px;border-radius:4px}.qaid-confirm-message{margin:0;font-size:calc(var(--qaid-font-size, 16px) * .875);color:var(--qaid-text-muted, light-dark(#6b7280, #9ca3af))}.qaid-confirm .qaid-confirm-close{margin-top:.5rem;min-width:96px}@keyframes qaid-confirm-pop{0%{transform:scale(.6);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.qaid-confirm-icon{animation:none}}.qaid-textarea:focus-visible,button.qaid-btn-submit:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}@media(forced-colors:active){.qaid-textarea:focus,button.qaid-btn-submit:focus{outline:2px solid CanvasText;outline-offset:2px}}";
|
|
4
|
-
class v {
|
|
5
|
-
constructor(t) {
|
|
6
|
-
this.host = t;
|
|
7
|
-
}
|
|
8
|
-
host;
|
|
9
|
-
modalContainer = null;
|
|
10
|
-
backdrop = null;
|
|
11
|
-
/** Set once the message is sent, so closing does not PATCH over it. */
|
|
12
|
-
finalized = !1;
|
|
13
|
-
open() {
|
|
14
|
-
this.finalized = !1;
|
|
15
|
-
const t = this.host.ensureOverlayHost();
|
|
16
|
-
this.backdrop = document.createElement("div"), this.backdrop.className = "qaid-backdrop", this.backdrop.style.zIndex = String(this.host.config.zIndex + 2), this.backdrop.style.background = `rgba(0, 0, 0, ${this.host.config.backdropOpacity})`, this.backdrop.addEventListener("click", () => this.close()), this.host.applyVars(this.backdrop), this.host.isMobile ? this.showBottomSheet() : this.showPositionedModal(), t.appendChild(this.backdrop), document.addEventListener("keydown", this.host.boundKeyDown);
|
|
17
|
-
}
|
|
18
|
-
/** Escape / external close. Runs the finalize-PATCH + teardown. */
|
|
19
|
-
close() {
|
|
20
|
-
this.host.state === "MODAL_OPEN" && !this.finalized && (this.finalized = !0, this.host.whenFeedbackId().then((t) => {
|
|
21
|
-
t && fetch(`${this.host.config.endpoint}/${t}`, {
|
|
22
|
-
method: "PATCH",
|
|
23
|
-
headers: { "Content-Type": "application/json" },
|
|
24
|
-
body: JSON.stringify({ message: null })
|
|
25
|
-
}).catch((e) => console.error("Failed to finalize feedback:", e));
|
|
26
|
-
})), this.teardown(), this.host.resetFeedbackUi();
|
|
27
|
-
}
|
|
28
|
-
/** DOM/listener teardown only — no PATCH, no state reset (for embed destroy). */
|
|
29
|
-
destroy() {
|
|
30
|
-
this.teardown();
|
|
31
|
-
}
|
|
32
|
-
teardown() {
|
|
33
|
-
this.host.closeDialogA11y(), this.modalContainer && (this.modalContainer.remove(), this.modalContainer = null), this.backdrop && (this.backdrop.remove(), this.backdrop = null), document.removeEventListener("keydown", this.host.boundKeyDown);
|
|
34
|
-
}
|
|
35
|
-
showBottomSheet() {
|
|
36
|
-
const t = this.host.ensureOverlayHost(), e = document.createElement("div");
|
|
37
|
-
e.className = "qaid-bottom-sheet", e.style.zIndex = String(this.host.config.zIndex + 3), e.appendChild(
|
|
38
|
-
a(
|
|
39
|
-
"div",
|
|
40
|
-
{ class: "qaid-bottom-sheet-content" },
|
|
41
|
-
a("div", { class: "qaid-bottom-sheet-handle" }),
|
|
42
|
-
this.buildModalContent()
|
|
43
|
-
)
|
|
44
|
-
), this.host.applyVars(e), t.appendChild(e), this.modalContainer = e, this.setupModalInteractions();
|
|
45
|
-
}
|
|
46
|
-
showPositionedModal() {
|
|
47
|
-
const t = this.host.ensureOverlayHost(), { modal: e, arrow: o } = p(
|
|
48
|
-
this.host.selectedBounds,
|
|
49
|
-
window.innerWidth,
|
|
50
|
-
window.innerHeight,
|
|
51
|
-
{
|
|
52
|
-
width: this.host.config.modalWidth,
|
|
53
|
-
height: 280,
|
|
54
|
-
arrowHeight: 12,
|
|
55
|
-
gap: 8,
|
|
56
|
-
viewportPadding: 16
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
this.modalContainer = document.createElement("div"), this.modalContainer.className = `qaid-modal-container qaid-${e.position}`, this.modalContainer.style.top = `${e.top}px`, this.modalContainer.style.left = `${e.left}px`, this.modalContainer.style.zIndex = String(this.host.config.zIndex + 3);
|
|
60
|
-
const i = document.createElement("div");
|
|
61
|
-
i.className = "qaid-modal-arrow", i.style.left = `${o.left}px`;
|
|
62
|
-
const s = document.createElement("div");
|
|
63
|
-
s.className = "qaid-modal-box", s.appendChild(this.buildModalContent()), this.modalContainer.appendChild(i), this.modalContainer.appendChild(s), this.host.applyVars(this.modalContainer), t.appendChild(this.modalContainer), this.setupModalInteractions();
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The modal's contents, built as nodes rather than an HTML string.
|
|
67
|
-
*
|
|
68
|
-
* Every piece of copy (title, subtitle, placeholder, button) goes in as
|
|
69
|
-
* text, so a `<`, `&` or `"` in a translation shows as written instead of
|
|
70
|
-
* being parsed as markup or cutting an attribute short. Only the icons are
|
|
71
|
-
* markup, because they are documented as SVG/HTML strings.
|
|
72
|
-
*/
|
|
73
|
-
buildModalContent() {
|
|
74
|
-
const { config: t, uid: e } = this.host, o = t.text, i = this.host.feedbackData.feedbackType, s = i === "up", n = t.positiveIcon || h, r = t.negativeIcon || m, d = t.buttonClass ? `qaid-type-toggle qaid-type-toggle-custom ${t.buttonClass} ${s ? "qaid-btn-up" : "qaid-btn-down"}` : `qaid-type-toggle ${s ? "qaid-type-up" : "qaid-type-down"}`, l = s ? "Feedback type: positive" : "Feedback type: negative", f = i === "neutral" ? a("span", {
|
|
75
|
-
class: "qaid-type-static",
|
|
76
|
-
html: t.feedbackIcon || b,
|
|
77
|
-
attrs: { "aria-hidden": "true" }
|
|
78
|
-
}) : a("button", {
|
|
79
|
-
class: d,
|
|
80
|
-
html: s ? n : r,
|
|
81
|
-
attrs: {
|
|
82
|
-
type: "button",
|
|
83
|
-
title: "Click to switch",
|
|
84
|
-
"aria-pressed": String(s),
|
|
85
|
-
"aria-label": l
|
|
86
|
-
}
|
|
87
|
-
}), c = document.createDocumentFragment();
|
|
88
|
-
return c.append(
|
|
89
|
-
a(
|
|
90
|
-
"div",
|
|
91
|
-
{ class: "qaid-modal-header" },
|
|
92
|
-
f,
|
|
93
|
-
a(
|
|
94
|
-
"div",
|
|
95
|
-
{ class: "qaid-modal-header-text" },
|
|
96
|
-
a("h3", {
|
|
97
|
-
class: "qaid-modal-title",
|
|
98
|
-
text: o.modalTitle,
|
|
99
|
-
attrs: { id: `qaid-modal-title-${e}` }
|
|
100
|
-
}),
|
|
101
|
-
a("p", {
|
|
102
|
-
class: "qaid-modal-subtitle",
|
|
103
|
-
text: o.modalSubtitle,
|
|
104
|
-
attrs: { id: `qaid-modal-subtitle-${e}` }
|
|
105
|
-
})
|
|
106
|
-
)
|
|
107
|
-
),
|
|
108
|
-
a("textarea", {
|
|
109
|
-
class: "qaid-textarea",
|
|
110
|
-
attrs: { "aria-label": o.modalSubtitle, placeholder: o.placeholder }
|
|
111
|
-
}),
|
|
112
|
-
a(
|
|
113
|
-
"div",
|
|
114
|
-
{ class: "qaid-btn-row" },
|
|
115
|
-
a("button", {
|
|
116
|
-
class: "qaid-btn-submit",
|
|
117
|
-
text: o.skipButton,
|
|
118
|
-
attrs: { type: "button" }
|
|
119
|
-
})
|
|
120
|
-
)
|
|
121
|
-
), c;
|
|
122
|
-
}
|
|
123
|
-
setupModalInteractions() {
|
|
124
|
-
this.host.openDialogA11y(this.modalContainer, {
|
|
125
|
-
labelledbyId: `qaid-modal-title-${this.host.uid}`,
|
|
126
|
-
describedbyId: `qaid-modal-subtitle-${this.host.uid}`
|
|
127
|
-
});
|
|
128
|
-
const t = this.modalContainer.querySelector(".qaid-textarea"), e = this.modalContainer.querySelector(".qaid-btn-submit");
|
|
129
|
-
t && (setTimeout(() => t.focus(), 100), t.addEventListener("input", () => {
|
|
130
|
-
e && (e.textContent = t.value.trim() ? this.host.config.text.submitButton : this.host.config.text.skipButton);
|
|
131
|
-
})), e && e.addEventListener("click", () => {
|
|
132
|
-
const i = t?.value.trim() || null;
|
|
133
|
-
this.submitMessage(i);
|
|
134
|
-
});
|
|
135
|
-
const o = this.modalContainer.querySelector(".qaid-type-toggle");
|
|
136
|
-
o && o.addEventListener("click", () => {
|
|
137
|
-
const i = this.host.feedbackData.feedbackType === "up" ? "down" : "up";
|
|
138
|
-
this.host.feedbackData.feedbackType = i, this.host.config.buttonClass ? (o.classList.toggle("qaid-btn-up", i === "up"), o.classList.toggle("qaid-btn-down", i === "down")) : (o.classList.toggle("qaid-type-up", i === "up"), o.classList.toggle("qaid-type-down", i === "down"));
|
|
139
|
-
const s = this.host.config.positiveIcon || h, n = this.host.config.negativeIcon || m;
|
|
140
|
-
o.innerHTML = i === "up" ? s : n;
|
|
141
|
-
const r = i === "up" ? "Feedback type: positive" : "Feedback type: negative";
|
|
142
|
-
o.setAttribute("aria-pressed", String(i === "up")), o.setAttribute("aria-label", r), this.host.announceMsg(r), this.host.whenFeedbackId().then((d) => {
|
|
143
|
-
d && fetch(`${this.host.config.endpoint}/${d}`, {
|
|
144
|
-
method: "PATCH",
|
|
145
|
-
headers: { "Content-Type": "application/json" },
|
|
146
|
-
body: JSON.stringify({ feedbackType: i })
|
|
147
|
-
}).catch((l) => console.error("Failed to update feedback type:", l));
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
async submitMessage(t) {
|
|
152
|
-
let e = null;
|
|
153
|
-
this.finalized = !0;
|
|
154
|
-
const o = await this.host.whenFeedbackId();
|
|
155
|
-
if (o)
|
|
156
|
-
try {
|
|
157
|
-
const i = await fetch(`${this.host.config.endpoint}/${o}`, {
|
|
158
|
-
method: "PATCH",
|
|
159
|
-
headers: { "Content-Type": "application/json" },
|
|
160
|
-
body: JSON.stringify({ message: t })
|
|
161
|
-
});
|
|
162
|
-
e = i.ok, i.ok || console.error("Failed to submit feedback message: HTTP", i.status);
|
|
163
|
-
} catch (i) {
|
|
164
|
-
console.error("Failed to submit feedback message:", i), e = !1;
|
|
165
|
-
}
|
|
166
|
-
if (e === !1) {
|
|
167
|
-
this.showResult(!1);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (e && !this.host.config.hideConfirmation) {
|
|
171
|
-
this.showResult(!0);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
this.close();
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Replace the modal's contents with the outcome: a checkmark and a short
|
|
178
|
-
* acknowledgement, or an error mark and a "not sent" notice.
|
|
179
|
-
*
|
|
180
|
-
* The submit button that had focus is gone by this point, so focus moves to
|
|
181
|
-
* the heading (WCAG 2.4.3) and the message is announced. Mirrors the quests
|
|
182
|
-
* embed's thank-you screen so the two products confirm the same way. Copy
|
|
183
|
-
* goes in as text, never markup.
|
|
184
|
-
*/
|
|
185
|
-
showResult(t) {
|
|
186
|
-
const e = this.modalContainer?.querySelector(".qaid-modal-box") ?? this.modalContainer?.querySelector(".qaid-bottom-sheet-content") ?? this.modalContainer;
|
|
187
|
-
if (!e) {
|
|
188
|
-
this.close();
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const o = this.host.config.text, i = t ? o.confirmationTitle : o.errorTitle, s = t ? o.confirmationMessage : o.errorMessage, n = a("h3", {
|
|
192
|
-
class: "qaid-confirm-title",
|
|
193
|
-
text: i,
|
|
194
|
-
attrs: { id: `qaid-confirm-title-${this.host.uid}`, tabindex: "-1" }
|
|
195
|
-
});
|
|
196
|
-
e.textContent = "", e.appendChild(
|
|
197
|
-
a(
|
|
198
|
-
"div",
|
|
199
|
-
{ class: t ? "qaid-confirm" : "qaid-confirm qaid-confirm-error" },
|
|
200
|
-
a("span", {
|
|
201
|
-
class: "qaid-confirm-icon",
|
|
202
|
-
html: t ? u : g,
|
|
203
|
-
attrs: { "aria-hidden": "true" }
|
|
204
|
-
}),
|
|
205
|
-
n,
|
|
206
|
-
a("p", { class: "qaid-confirm-message", text: s }),
|
|
207
|
-
a("button", {
|
|
208
|
-
class: "qaid-btn-submit qaid-confirm-close",
|
|
209
|
-
text: o.confirmationClose,
|
|
210
|
-
attrs: { type: "button" },
|
|
211
|
-
on: { click: () => this.close() }
|
|
212
|
-
})
|
|
213
|
-
)
|
|
214
|
-
), requestAnimationFrame(() => n.focus()), this.host.announceMsg(`${i} ${s}`, !0);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
const w = q;
|
|
218
|
-
export {
|
|
219
|
-
v as ModalController,
|
|
220
|
-
w as styles
|
|
221
|
-
};
|
|
222
|
-
//# sourceMappingURL=modal-DccueVYZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modal-DccueVYZ.js","sources":["../../src/modal.ts"],"sourcesContent":["/**\n * Feedback message modal — extracted from embed.ts into its own lazily-loaded\n * chunk. It's fetched the first time a message modal opens (after feedback is\n * submitted), and pre-warmed while the user is targeting an element.\n *\n * The controller owns the modal/backdrop DOM and the message PATCH flow, and\n * talks back to the embed through the narrow `ModalHost` interface.\n */\n\nimport { calculateModalAndArrowPosition } from \"./modal-positioning\";\nimport { h } from \"./dom\";\nimport featureStyles from \"./styles-modal.css?inline\";\nimport {\n THUMBS_UP_ICON,\n THUMBS_DOWN_ICON,\n FEEDBACK_ICON,\n DONE_ICON,\n ERROR_ICON,\n} from \"./icons\";\nimport type {\n ResolvedFeedbackConfig,\n EmbedState,\n FeedbackData,\n SelectedBounds,\n} from \"./types\";\n\n/** The slice of the embed the modal needs. */\nexport interface ModalHost {\n readonly config: ResolvedFeedbackConfig;\n readonly uid: string;\n readonly isMobile: boolean;\n readonly state: EmbedState;\n readonly boundKeyDown: (e: KeyboardEvent) => void;\n /** Live references — the toggle mutates feedbackType; positioning reads bounds. */\n readonly feedbackData: FeedbackData;\n readonly selectedBounds: SelectedBounds;\n /**\n * The id of this feedback's record. The modal opens while the POST that\n * creates it is still in flight, so every PATCH waits on this; null when\n * the POST failed.\n */\n whenFeedbackId(): Promise<number | null>;\n ensureOverlayHost(): ShadowRoot;\n applyVars(el: HTMLElement): void;\n announceMsg(message: string, assertive?: boolean): void;\n openDialogA11y(\n container: HTMLElement,\n opts: { labelledbyId?: string; describedbyId?: string; label?: string }\n ): void;\n closeDialogA11y(): void;\n resetFeedbackUi(): void;\n}\n\nexport class ModalController {\n private modalContainer: HTMLDivElement | null = null;\n private backdrop: HTMLDivElement | null = null;\n /** Set once the message is sent, so closing does not PATCH over it. */\n private finalized = false;\n\n constructor(private host: ModalHost) {}\n\n open(): void {\n this.finalized = false;\n const root = this.host.ensureOverlayHost();\n\n // Create backdrop\n this.backdrop = document.createElement(\"div\");\n this.backdrop.className = \"qaid-backdrop\";\n this.backdrop.style.zIndex = String(this.host.config.zIndex + 2);\n this.backdrop.style.background = `rgba(0, 0, 0, ${this.host.config.backdropOpacity})`;\n this.backdrop.addEventListener(\"click\", () => this.close());\n this.host.applyVars(this.backdrop);\n\n if (this.host.isMobile) {\n this.showBottomSheet();\n } else {\n this.showPositionedModal();\n }\n\n root.appendChild(this.backdrop);\n document.addEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n /** Escape / external close. Runs the finalize-PATCH + teardown. */\n close(): void {\n // If the modal is open and we're closing without submitting, still finalize.\n // Taken before the reset below, which starts the next feedback afresh.\n if (this.host.state === \"MODAL_OPEN\" && !this.finalized) {\n this.finalized = true;\n void this.host.whenFeedbackId().then((id) => {\n if (!id) return;\n fetch(`${this.host.config.endpoint}/${id}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ message: null }),\n }).catch((err) => console.error(\"Failed to finalize feedback:\", err));\n });\n }\n\n this.teardown();\n this.host.resetFeedbackUi();\n }\n\n /** DOM/listener teardown only — no PATCH, no state reset (for embed destroy). */\n destroy(): void {\n this.teardown();\n }\n\n private teardown(): void {\n this.host.closeDialogA11y();\n if (this.modalContainer) {\n this.modalContainer.remove();\n this.modalContainer = null;\n }\n if (this.backdrop) {\n this.backdrop.remove();\n this.backdrop = null;\n }\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n private showBottomSheet(): void {\n const root = this.host.ensureOverlayHost();\n\n const sheet = document.createElement(\"div\");\n sheet.className = \"qaid-bottom-sheet\";\n sheet.style.zIndex = String(this.host.config.zIndex + 3);\n\n sheet.appendChild(\n h(\n \"div\",\n { class: \"qaid-bottom-sheet-content\" },\n h(\"div\", { class: \"qaid-bottom-sheet-handle\" }),\n this.buildModalContent()\n )\n );\n\n this.host.applyVars(sheet);\n root.appendChild(sheet);\n this.modalContainer = sheet;\n\n this.setupModalInteractions();\n }\n\n private showPositionedModal(): void {\n const root = this.host.ensureOverlayHost();\n\n const { modal, arrow } = calculateModalAndArrowPosition(\n this.host.selectedBounds,\n window.innerWidth,\n window.innerHeight,\n {\n width: this.host.config.modalWidth,\n height: 280,\n arrowHeight: 12,\n gap: 8,\n viewportPadding: 16,\n }\n );\n\n this.modalContainer = document.createElement(\"div\");\n this.modalContainer.className = `qaid-modal-container qaid-${modal.position}`;\n this.modalContainer.style.top = `${modal.top}px`;\n this.modalContainer.style.left = `${modal.left}px`;\n this.modalContainer.style.zIndex = String(this.host.config.zIndex + 3);\n\n const arrowEl = document.createElement(\"div\");\n arrowEl.className = \"qaid-modal-arrow\";\n arrowEl.style.left = `${arrow.left}px`;\n\n const box = document.createElement(\"div\");\n box.className = \"qaid-modal-box\";\n box.appendChild(this.buildModalContent());\n\n this.modalContainer.appendChild(arrowEl);\n this.modalContainer.appendChild(box);\n this.host.applyVars(this.modalContainer);\n root.appendChild(this.modalContainer);\n\n this.setupModalInteractions();\n }\n\n /**\n * The modal's contents, built as nodes rather than an HTML string.\n *\n * Every piece of copy (title, subtitle, placeholder, button) goes in as\n * text, so a `<`, `&` or `\"` in a translation shows as written instead of\n * being parsed as markup or cutting an attribute short. Only the icons are\n * markup, because they are documented as SVG/HTML strings.\n */\n private buildModalContent(): DocumentFragment {\n const { config, uid } = this.host;\n const text = config.text;\n const type = this.host.feedbackData.feedbackType;\n const isUp = type === \"up\";\n const positiveIcon = config.positiveIcon || THUMBS_UP_ICON;\n const negativeIcon = config.negativeIcon || THUMBS_DOWN_ICON;\n const toggleClass = config.buttonClass\n ? `qaid-type-toggle qaid-type-toggle-custom ${config.buttonClass} ${isUp ? \"qaid-btn-up\" : \"qaid-btn-down\"}`\n : `qaid-type-toggle ${isUp ? \"qaid-type-up\" : \"qaid-type-down\"}`;\n const toggleLabel = isUp ? \"Feedback type: positive\" : \"Feedback type: negative\";\n // Neutral (single-button) feedback has no sentiment to toggle — show a\n // static feedback icon in place of the up/down toggle.\n const header =\n type === \"neutral\"\n ? h(\"span\", {\n class: \"qaid-type-static\",\n html: config.feedbackIcon || FEEDBACK_ICON,\n attrs: { \"aria-hidden\": \"true\" },\n })\n : h(\"button\", {\n class: toggleClass,\n html: isUp ? positiveIcon : negativeIcon,\n attrs: {\n type: \"button\",\n title: \"Click to switch\",\n \"aria-pressed\": String(isUp),\n \"aria-label\": toggleLabel,\n },\n });\n\n const fragment = document.createDocumentFragment();\n fragment.append(\n h(\n \"div\",\n { class: \"qaid-modal-header\" },\n header,\n h(\n \"div\",\n { class: \"qaid-modal-header-text\" },\n h(\"h3\", {\n class: \"qaid-modal-title\",\n text: text.modalTitle,\n attrs: { id: `qaid-modal-title-${uid}` },\n }),\n h(\"p\", {\n class: \"qaid-modal-subtitle\",\n text: text.modalSubtitle,\n attrs: { id: `qaid-modal-subtitle-${uid}` },\n })\n )\n ),\n h(\"textarea\", {\n class: \"qaid-textarea\",\n attrs: { \"aria-label\": text.modalSubtitle, placeholder: text.placeholder },\n }),\n h(\n \"div\",\n { class: \"qaid-btn-row\" },\n h(\"button\", {\n class: \"qaid-btn-submit\",\n text: text.skipButton,\n attrs: { type: \"button\" },\n })\n )\n );\n return fragment;\n }\n\n private setupModalInteractions(): void {\n // Dialog semantics + focus trap + background inert\n this.host.openDialogA11y(this.modalContainer!, {\n labelledbyId: `qaid-modal-title-${this.host.uid}`,\n describedbyId: `qaid-modal-subtitle-${this.host.uid}`,\n });\n\n const textarea =\n this.modalContainer!.querySelector<HTMLTextAreaElement>(\".qaid-textarea\");\n const submitBtn =\n this.modalContainer!.querySelector<HTMLButtonElement>(\".qaid-btn-submit\");\n if (textarea) {\n // Auto-focus\n setTimeout(() => textarea.focus(), 100);\n\n // Update button text based on content\n textarea.addEventListener(\"input\", () => {\n if (submitBtn) {\n submitBtn.textContent = textarea.value.trim()\n ? this.host.config.text.submitButton\n : this.host.config.text.skipButton;\n }\n });\n }\n\n if (submitBtn) {\n submitBtn.addEventListener(\"click\", () => {\n const message = textarea?.value.trim() || null;\n this.submitMessage(message);\n });\n }\n\n // Handle feedback type toggle\n const typeToggle = this.modalContainer!.querySelector<HTMLButtonElement>(\".qaid-type-toggle\");\n if (typeToggle) {\n typeToggle.addEventListener(\"click\", () => {\n const newType = this.host.feedbackData.feedbackType === \"up\" ? \"down\" : \"up\";\n this.host.feedbackData.feedbackType = newType;\n\n // Update UI — use different classes depending on custom buttonClass\n if (this.host.config.buttonClass) {\n typeToggle.classList.toggle(\"qaid-btn-up\", newType === \"up\");\n typeToggle.classList.toggle(\"qaid-btn-down\", newType === \"down\");\n } else {\n typeToggle.classList.toggle(\"qaid-type-up\", newType === \"up\");\n typeToggle.classList.toggle(\"qaid-type-down\", newType === \"down\");\n }\n const positiveIcon = this.host.config.positiveIcon || THUMBS_UP_ICON;\n const negativeIcon = this.host.config.negativeIcon || THUMBS_DOWN_ICON;\n typeToggle.innerHTML = newType === \"up\" ? positiveIcon : negativeIcon;\n\n // Update accessible state and announce the change\n const toggleLabel = newType === \"up\" ? \"Feedback type: positive\" : \"Feedback type: negative\";\n typeToggle.setAttribute(\"aria-pressed\", String(newType === \"up\"));\n typeToggle.setAttribute(\"aria-label\", toggleLabel);\n this.host.announceMsg(toggleLabel);\n\n // Update feedback on server, once the record exists\n void this.host.whenFeedbackId().then((id) => {\n if (!id) return;\n fetch(`${this.host.config.endpoint}/${id}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ feedbackType: newType }),\n }).catch((err) => console.error(\"Failed to update feedback type:\", err));\n });\n });\n }\n }\n\n private async submitMessage(message: string | null): Promise<void> {\n // null = nothing was attempted (the initial POST never produced an id);\n // otherwise whether the server accepted the PATCH.\n let delivered: boolean | null = null;\n\n // Before the await: an Escape while the POST is still out must not send\n // a second, empty PATCH over this message.\n this.finalized = true;\n const id = await this.host.whenFeedbackId();\n if (id) {\n try {\n const response = await fetch(`${this.host.config.endpoint}/${id}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ message }),\n });\n // fetch resolves on any HTTP reply. A 4xx/5xx means the server\n // refused or lost the message, so it is not a success.\n delivered = response.ok;\n if (!response.ok) {\n console.error(\"Failed to submit feedback message: HTTP\", response.status);\n }\n } catch (error) {\n console.error(\"Failed to submit feedback message:\", error);\n delivered = false;\n }\n }\n\n // The message was lost. Closing quietly reads as success, so say so —\n // even with hideConfirmation, which only opts out of the success screen.\n if (delivered === false) {\n this.showResult(false);\n return;\n }\n\n // A submit that simply removes the modal reads as a failure — nothing\n // acknowledges that the message was sent. Show a success screen unless the\n // host opted out.\n //\n // With no feedbackId the initial POST never landed and there was nothing\n // to send the message to; that path closes exactly as it did before.\n if (delivered && !this.host.config.hideConfirmation) {\n this.showResult(true);\n return;\n }\n this.close();\n }\n\n /**\n * Replace the modal's contents with the outcome: a checkmark and a short\n * acknowledgement, or an error mark and a \"not sent\" notice.\n *\n * The submit button that had focus is gone by this point, so focus moves to\n * the heading (WCAG 2.4.3) and the message is announced. Mirrors the quests\n * embed's thank-you screen so the two products confirm the same way. Copy\n * goes in as text, never markup.\n */\n private showResult(delivered: boolean): void {\n const box = this.modalContainer?.querySelector(\".qaid-modal-box\")\n ?? this.modalContainer?.querySelector(\".qaid-bottom-sheet-content\")\n ?? this.modalContainer;\n\n if (!box) {\n // Nothing to draw into — never strand the user with an open modal.\n this.close();\n return;\n }\n\n const text = this.host.config.text;\n const heading = delivered ? text.confirmationTitle : text.errorTitle;\n const body = delivered ? text.confirmationMessage : text.errorMessage;\n\n const title = h(\"h3\", {\n class: \"qaid-confirm-title\",\n text: heading,\n attrs: { id: `qaid-confirm-title-${this.host.uid}`, tabindex: \"-1\" },\n });\n\n box.textContent = \"\";\n box.appendChild(\n h(\n \"div\",\n { class: delivered ? \"qaid-confirm\" : \"qaid-confirm qaid-confirm-error\" },\n h(\"span\", {\n class: \"qaid-confirm-icon\",\n html: delivered ? DONE_ICON : ERROR_ICON,\n attrs: { \"aria-hidden\": \"true\" },\n }),\n title,\n h(\"p\", { class: \"qaid-confirm-message\", text: body }),\n h(\"button\", {\n class: \"qaid-btn-submit qaid-confirm-close\",\n text: text.confirmationClose,\n attrs: { type: \"button\" },\n on: { click: () => this.close() },\n })\n )\n );\n\n // Focus after paint, matching the quests embed.\n requestAnimationFrame(() => title.focus());\n this.host.announceMsg(`${heading} ${body}`, true);\n }\n}\n\n/** This feature's shadow-DOM styles; the embed adds them when it loads the chunk. */\nexport const styles = featureStyles;\n"],"names":["ModalController","host","root","id","err","sheet","h","modal","arrow","calculateModalAndArrowPosition","arrowEl","box","config","uid","text","type","isUp","positiveIcon","THUMBS_UP_ICON","negativeIcon","THUMBS_DOWN_ICON","toggleClass","toggleLabel","header","FEEDBACK_ICON","fragment","textarea","submitBtn","message","typeToggle","newType","delivered","response","error","heading","body","title","DONE_ICON","ERROR_ICON","styles","featureStyles"],"mappings":";;;AAqDO,MAAMA,EAAgB;AAAA,EAM3B,YAAoBC,GAAiB;AAAjB,SAAA,OAAAA;AAAA,EAAkB;AAAA,EAAlB;AAAA,EALZ,iBAAwC;AAAA,EACxC,WAAkC;AAAA;AAAA,EAElC,YAAY;AAAA,EAIpB,OAAa;AACX,SAAK,YAAY;AACjB,UAAMC,IAAO,KAAK,KAAK,kBAAA;AAGvB,SAAK,WAAW,SAAS,cAAc,KAAK,GAC5C,KAAK,SAAS,YAAY,iBAC1B,KAAK,SAAS,MAAM,SAAS,OAAO,KAAK,KAAK,OAAO,SAAS,CAAC,GAC/D,KAAK,SAAS,MAAM,aAAa,iBAAiB,KAAK,KAAK,OAAO,eAAe,KAClF,KAAK,SAAS,iBAAiB,SAAS,MAAM,KAAK,OAAO,GAC1D,KAAK,KAAK,UAAU,KAAK,QAAQ,GAE7B,KAAK,KAAK,WACZ,KAAK,gBAAA,IAEL,KAAK,oBAAA,GAGPA,EAAK,YAAY,KAAK,QAAQ,GAC9B,SAAS,iBAAiB,WAAW,KAAK,KAAK,YAAY;AAAA,EAC7D;AAAA;AAAA,EAGA,QAAc;AAGZ,I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iBAAiB,KAC3D,KAAK,gBAAgB,cAAc,4BAA4B,KAC/D,KAAK;AAEV,QAAI,CAACA,GAAK;AAER,WAAK,MAAA;AACL;AAAA,IACF;AAEA,UAAMG,IAAO,KAAK,KAAK,OAAO,MACxBoB,IAAUH,IAAYjB,EAAK,oBAAoBA,EAAK,YACpDqB,IAAOJ,IAAYjB,EAAK,sBAAsBA,EAAK,cAEnDsB,IAAQ9B,EAAE,MAAM;AAAA,MACpB,OAAO;AAAA,MACP,MAAM4B;AAAA,MACN,OAAO,EAAE,IAAI,sBAAsB,KAAK,KAAK,GAAG,IAAI,UAAU,KAAA;AAAA,IAAK,CACpE;AAED,IAAAvB,EAAI,cAAc,IAClBA,EAAI;AAAA,MACFL;AAAA,QACE;AAAA,QACA,EAAE,OAAOyB,IAAY,iBAAiB,kCAAA;AAAA,QACtCzB,EAAE,QAAQ;AAAA,UACR,OAAO;AAAA,UACP,MAAMyB,IAAYM,IAAYC;AAAA,UAC9B,OAAO,EAAE,eAAe,OAAA;AAAA,QAAO,CAChC;AAAA,QACDF;AAAA,QACA9B,EAAE,KAAK,EAAE,OAAO,wBAAwB,MAAM6B,GAAM;AAAA,QACpD7B,EAAE,UAAU;AAAA,UACV,OAAO;AAAA,UACP,MAAMQ,EAAK;AAAA,UACX,OAAO,EAAE,MAAM,SAAA;AAAA,UACf,IAAI,EAAE,OAAO,MAAM,KAAK,QAAM;AAAA,QAAE,CACjC;AAAA,MAAA;AAAA,IACH,GAIF,sBAAsB,MAAMsB,EAAM,OAAO,GACzC,KAAK,KAAK,YAAY,GAAGF,CAAO,IAAIC,CAAI,IAAI,EAAI;AAAA,EAClD;AACF;AAGO,MAAMI,IAASC;"}
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { h as n } from "./dom-DvdtcUS8.js";
|
|
2
|
-
import { i as g } from "./core-CL1dwdaN.js";
|
|
3
|
-
const v = ".qaid-recording-indicator{position:fixed;pointer-events:auto;top:12px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:light-dark(#1f2937,#374151);color:#fff;border-radius:9999px;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;box-shadow:0 4px 12px #0000004d;z-index:99999;animation:qaid-slideDown .2s ease-out}.qaid-recording-dot{width:10px;height:10px;background:#dc2626;border-radius:50%;animation:qaid-dotPulse 1.5s ease-in-out infinite}@keyframes qaid-dotPulse{0%,to{opacity:1}50%{opacity:.3}}.qaid-recording-time{font-variant-numeric:tabular-nums;min-width:2.5rem;text-align:center}button.qaid-recording-stop{padding:.25rem .75rem;background:#dc2626;color:#fff;border:none;border-radius:9999px;font-size:calc(var(--qaid-font-size, 16px) * .75);font-weight:600;cursor:pointer;transition:background-color .2s;-webkit-appearance:none;appearance:none}button.qaid-recording-stop:hover{background:#b91c1c}.qaid-video-preview{position:fixed;inset:0 0 auto;height:100vh;height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#0009;z-index:99998;animation:qaid-fadeIn .2s ease-out}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}.qaid-video-preview-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px #00000080;width:560px;max-width:100%;max-height:100%;overflow-y:auto;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-video-preview-box h3{font-size:calc(var(--qaid-font-size, 16px) * 1.125);font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;max-height:50vh;max-height:50dvh;object-fit:contain;border-radius:.5rem;background:#000;margin-bottom:1rem}.qaid-video-preview-box textarea{width:100%;height:4rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:calc(var(--qaid-font-size, 16px) * .875);resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-video-error{margin:0 0 .75rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;color:light-dark(#b91c1c,#fca5a5)}.qaid-video-preview-actions{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-video-btn{padding:.5rem 1rem;border:none;border-radius:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-video-btn-cancel{background:light-dark(#f3f4f6,#374151);color:light-dark(#374151,#d1d5db)}button.qaid-video-btn-cancel:hover{background:light-dark(#e5e7eb,#4b5563)}button.qaid-video-btn-rerecord{background:light-dark(#fef3c7,#78350f);color:light-dark(#92400e,#fde68a)}button.qaid-video-btn-rerecord:hover{filter:brightness(.9)}button.qaid-video-btn-send{background:var(--qaid-marker);color:var(--qaid-marker-text, white)}button.qaid-video-btn-send:hover{filter:brightness(.85)}button.qaid-video-btn-send:disabled{opacity:.5;cursor:not-allowed}.qaid-video-sending{display:flex;align-items:center;gap:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);color:light-dark(#6b7280,#9ca3af)}@keyframes qaid-slideDown{0%{transform:translateY(-100%)}to{transform:translateY(0)}}button.qaid-recording-stop{min-height:24px}.qaid-video-preview-box textarea:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}@media(forced-colors:active){.qaid-video-preview-box textarea:focus{outline:2px solid CanvasText;outline-offset:2px}}", b = 20, u = 4096;
|
|
4
|
-
function l(d) {
|
|
5
|
-
const e = typeof d == "string" ? d : JSON.stringify(d);
|
|
6
|
-
return e.length > u ? e.slice(0, u) + "…[truncated]" : e;
|
|
7
|
-
}
|
|
8
|
-
function p(d, e) {
|
|
9
|
-
d.length >= b && d.shift(), d.push(e);
|
|
10
|
-
}
|
|
11
|
-
async function m(d) {
|
|
12
|
-
try {
|
|
13
|
-
const e = await d.clone().text();
|
|
14
|
-
return l(e);
|
|
15
|
-
} catch {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function x() {
|
|
20
|
-
const d = [], e = window.fetch;
|
|
21
|
-
window.fetch = async function(o, r) {
|
|
22
|
-
const s = typeof o == "string" ? o : o instanceof URL ? o.toString() : o.url, a = r?.method ?? (typeof o == "object" && "method" in o ? o.method : "GET");
|
|
23
|
-
let c;
|
|
24
|
-
r?.body && (c = l(r.body));
|
|
25
|
-
const h = await e.apply(window, [o, r]);
|
|
26
|
-
if (h.status >= 400) {
|
|
27
|
-
const f = await m(h);
|
|
28
|
-
p(d, {
|
|
29
|
-
url: s,
|
|
30
|
-
method: a.toUpperCase(),
|
|
31
|
-
status: h.status,
|
|
32
|
-
statusText: h.statusText,
|
|
33
|
-
requestBody: c,
|
|
34
|
-
responseBody: f,
|
|
35
|
-
timestamp: Date.now()
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return h;
|
|
39
|
-
};
|
|
40
|
-
const i = XMLHttpRequest.prototype.open, t = XMLHttpRequest.prototype.send;
|
|
41
|
-
return XMLHttpRequest.prototype.open = function(o, r, ...s) {
|
|
42
|
-
return this._qaid_method = o, this._qaid_url = typeof r == "string" ? r : r.toString(), i.apply(this, [o, r, ...s]);
|
|
43
|
-
}, XMLHttpRequest.prototype.send = function(o) {
|
|
44
|
-
const r = this, s = o ? l(o) : void 0;
|
|
45
|
-
return r.addEventListener("load", function() {
|
|
46
|
-
r.status >= 400 && p(d, {
|
|
47
|
-
url: r._qaid_url,
|
|
48
|
-
method: r._qaid_method.toUpperCase(),
|
|
49
|
-
status: r.status,
|
|
50
|
-
statusText: r.statusText,
|
|
51
|
-
requestBody: s,
|
|
52
|
-
responseBody: l(r.responseText),
|
|
53
|
-
timestamp: Date.now()
|
|
54
|
-
});
|
|
55
|
-
}), t.apply(this, [o]);
|
|
56
|
-
}, {
|
|
57
|
-
errors: d,
|
|
58
|
-
restore: () => {
|
|
59
|
-
window.fetch = e, XMLHttpRequest.prototype.open = i, XMLHttpRequest.prototype.send = t;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
class k {
|
|
64
|
-
constructor(e) {
|
|
65
|
-
this.host = e;
|
|
66
|
-
}
|
|
67
|
-
host;
|
|
68
|
-
videoRecorder = null;
|
|
69
|
-
networkCapture = null;
|
|
70
|
-
recordedBlob = null;
|
|
71
|
-
recordingIndicator = null;
|
|
72
|
-
videoPreview = null;
|
|
73
|
-
isRecording = !1;
|
|
74
|
-
isSendingVideo = !1;
|
|
75
|
-
// Pre-recording redaction picking.
|
|
76
|
-
redactPicks = [];
|
|
77
|
-
redactPickerRoot = null;
|
|
78
|
-
redactRafId = 0;
|
|
79
|
-
boundRedactClick = (e) => this.handleRedactPickClick(e);
|
|
80
|
-
/** Escape-key handler; returns true when it consumed the key. */
|
|
81
|
-
handleEscape() {
|
|
82
|
-
return this.isRecording ? (this.stopRecording(), !0) : this.videoPreview ? (this.cancelRecordingPreview(), !0) : this.redactPickerRoot ? (this.finishRedactionPicking(!1), !0) : !1;
|
|
83
|
-
}
|
|
84
|
-
destroy() {
|
|
85
|
-
this.redactRafId && cancelAnimationFrame(this.redactRafId), this.redactRafId = 0, document.removeEventListener("click", this.boundRedactClick, !0), this.redactPickerRoot && (this.redactPickerRoot.remove(), this.redactPickerRoot = null), this.redactPicks = [], this.cleanupRecording(), this.removeVideoPreview();
|
|
86
|
-
}
|
|
87
|
-
async startRecording(e = []) {
|
|
88
|
-
if (!(this.isRecording || this.host.state !== "IDLE"))
|
|
89
|
-
try {
|
|
90
|
-
this.networkCapture = x();
|
|
91
|
-
const { createVideoRecorder: i } = await import("./video-Bd_29-rK.js");
|
|
92
|
-
this.videoRecorder = i({
|
|
93
|
-
maxDuration: this.host.config.videoOptions.maxDuration,
|
|
94
|
-
redactionElements: e
|
|
95
|
-
}), this.videoRecorder.onTick((t) => {
|
|
96
|
-
this.updateRecordingTimer(t);
|
|
97
|
-
}), this.videoRecorder.onStop((t) => {
|
|
98
|
-
this.isRecording && (this.recordedBlob = t, this.isRecording = !1, this.host.announceMsg("Recording stopped"), this.removeRecordingIndicator(), document.removeEventListener("keydown", this.host.boundKeyDown), this.host.setButtonsDisabled(!1), t && t.size > 0 ? this.showRecordingPreview() : this.cleanupRecording());
|
|
99
|
-
}), await this.videoRecorder.start(), this.isRecording = !0, this.host.announceMsg("Recording started"), this.host.setButtonsDisabled(!0), this.showRecordingIndicator(), document.addEventListener("keydown", this.host.boundKeyDown);
|
|
100
|
-
} catch (i) {
|
|
101
|
-
i instanceof Error && /current tab|cannot blur/i.test(i.message) && this.host.announceMsg(i.message), this.cleanupRecording();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
async stopRecording() {
|
|
105
|
-
try {
|
|
106
|
-
this.recordedBlob = await this.videoRecorder.stop();
|
|
107
|
-
} catch {
|
|
108
|
-
this.recordedBlob = null;
|
|
109
|
-
}
|
|
110
|
-
this.isRecording = !1, this.host.announceMsg("Recording stopped"), this.removeRecordingIndicator(), document.removeEventListener("keydown", this.host.boundKeyDown), this.recordedBlob && this.recordedBlob.size > 0 ? this.showRecordingPreview() : this.cleanupRecording();
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Pre-recording redaction picker. The user clicks page areas to blur; each
|
|
114
|
-
* gets an outline that tracks its position, then "Start recording" hands the
|
|
115
|
-
* picks to the recorder, which blurs their live bounding boxes so the
|
|
116
|
-
* redaction follows the content as the page scrolls. "Cancel"/Escape aborts.
|
|
117
|
-
*/
|
|
118
|
-
startPicking() {
|
|
119
|
-
if (this.isRecording || this.host.state !== "IDLE") return;
|
|
120
|
-
this.host.setState("REDACT_PICKING"), this.redactPicks = [];
|
|
121
|
-
const e = this.host.ensureOverlayHost(), i = n("div", { style: "position:absolute;inset:0;" }), t = n(
|
|
122
|
-
"div",
|
|
123
|
-
{ class: "qaid-redact-picker", style: "position:fixed;inset:0;pointer-events:none;" },
|
|
124
|
-
i,
|
|
125
|
-
// Control bar — the only pointer-interactive part of the overlay.
|
|
126
|
-
n(
|
|
127
|
-
"div",
|
|
128
|
-
{
|
|
129
|
-
style: "position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;gap:12px;align-items:center;pointer-events:auto;background:#0b1220;color:#fff;border:1px solid #ff6b6b;border-radius:9999px;padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 8px 30px rgba(0,0,0,.5);"
|
|
130
|
-
},
|
|
131
|
-
n("span", {
|
|
132
|
-
text: "Click sensitive areas to blur",
|
|
133
|
-
attrs: { "data-qaid-redact-label": "" }
|
|
134
|
-
}),
|
|
135
|
-
n("button", {
|
|
136
|
-
text: "Start recording",
|
|
137
|
-
attrs: { type: "button" },
|
|
138
|
-
style: "cursor:pointer;border:0;border-radius:9999px;padding:8px 14px;background:#ff6b6b;color:#0b1220;font:inherit;",
|
|
139
|
-
on: { click: () => this.finishRedactionPicking(!0) }
|
|
140
|
-
}),
|
|
141
|
-
n("button", {
|
|
142
|
-
text: "Cancel",
|
|
143
|
-
attrs: { type: "button" },
|
|
144
|
-
style: "cursor:pointer;border:0;background:transparent;color:#9fb3c8;font:inherit;",
|
|
145
|
-
on: { click: () => this.finishRedactionPicking(!1) }
|
|
146
|
-
})
|
|
147
|
-
)
|
|
148
|
-
);
|
|
149
|
-
e.appendChild(t), this.redactPickerRoot = t;
|
|
150
|
-
const o = () => {
|
|
151
|
-
this.renderRedactPicks(i), this.redactRafId = requestAnimationFrame(o);
|
|
152
|
-
};
|
|
153
|
-
o(), document.addEventListener("click", this.boundRedactClick, !0), document.addEventListener("keydown", this.host.boundKeyDown), this.host.announceMsg("Click sensitive areas to blur, then start recording");
|
|
154
|
-
}
|
|
155
|
-
handleRedactPickClick(e) {
|
|
156
|
-
const i = e.target instanceof Element ? e.target : null;
|
|
157
|
-
if (!i || g(i) || this.redactPickerRoot?.contains(i)) return;
|
|
158
|
-
e.preventDefault(), e.stopPropagation();
|
|
159
|
-
const t = this.redactPicks.indexOf(i);
|
|
160
|
-
t >= 0 ? this.redactPicks.splice(t, 1) : this.redactPicks.push(i);
|
|
161
|
-
const o = this.redactPickerRoot?.querySelector("[data-qaid-redact-label]");
|
|
162
|
-
if (o) {
|
|
163
|
-
const r = this.redactPicks.length;
|
|
164
|
-
o.textContent = r === 0 ? "Click sensitive areas to blur" : `${r} area${r === 1 ? "" : "s"} will be blurred`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
renderRedactPicks(e) {
|
|
168
|
-
e.textContent = "";
|
|
169
|
-
for (const i of this.redactPicks) {
|
|
170
|
-
const t = i.getBoundingClientRect();
|
|
171
|
-
t.width <= 0 || t.height <= 0 || e.appendChild(
|
|
172
|
-
n("div", {
|
|
173
|
-
style: `position:fixed;left:${t.left}px;top:${t.top}px;width:${t.width}px;height:${t.height}px;border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;`
|
|
174
|
-
})
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
finishRedactionPicking(e) {
|
|
179
|
-
this.redactRafId && cancelAnimationFrame(this.redactRafId), this.redactRafId = 0, document.removeEventListener("click", this.boundRedactClick, !0), document.removeEventListener("keydown", this.host.boundKeyDown), this.redactPickerRoot && (this.redactPickerRoot.remove(), this.redactPickerRoot = null);
|
|
180
|
-
const i = this.redactPicks;
|
|
181
|
-
this.redactPicks = [], this.host.setState("IDLE"), e && this.startRecording(i);
|
|
182
|
-
}
|
|
183
|
-
showRecordingIndicator() {
|
|
184
|
-
const e = this.host.ensureOverlayHost();
|
|
185
|
-
this.recordingIndicator = n(
|
|
186
|
-
"div",
|
|
187
|
-
{ class: "qaid-recording-indicator", style: `z-index:${this.host.config.zIndex + 100}` },
|
|
188
|
-
n("div", { class: "qaid-recording-dot" }),
|
|
189
|
-
n("span", {
|
|
190
|
-
class: "qaid-recording-time",
|
|
191
|
-
text: this.formatTime(this.host.config.videoOptions.maxDuration)
|
|
192
|
-
}),
|
|
193
|
-
n("button", {
|
|
194
|
-
class: "qaid-recording-stop",
|
|
195
|
-
text: "Stop",
|
|
196
|
-
attrs: { type: "button" },
|
|
197
|
-
on: { click: () => this.stopRecording() }
|
|
198
|
-
})
|
|
199
|
-
), this.host.applyVars(this.recordingIndicator), e.appendChild(this.recordingIndicator);
|
|
200
|
-
}
|
|
201
|
-
updateRecordingTimer(e) {
|
|
202
|
-
if (!this.recordingIndicator) return;
|
|
203
|
-
const i = this.recordingIndicator.querySelector(".qaid-recording-time");
|
|
204
|
-
if (i) {
|
|
205
|
-
const t = Math.max(0, this.host.config.videoOptions.maxDuration - e);
|
|
206
|
-
i.textContent = this.formatTime(t), t > 0 && t <= 5 && this.host.announceMsg(`${t} second${t === 1 ? "" : "s"} remaining`);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
formatTime(e) {
|
|
210
|
-
const i = Math.floor(e / 60), t = e % 60;
|
|
211
|
-
return `${i}:${t.toString().padStart(2, "0")}`;
|
|
212
|
-
}
|
|
213
|
-
removeRecordingIndicator() {
|
|
214
|
-
this.recordingIndicator && (this.recordingIndicator.remove(), this.recordingIndicator = null);
|
|
215
|
-
}
|
|
216
|
-
showRecordingPreview() {
|
|
217
|
-
const e = this.host.ensureOverlayHost(), i = URL.createObjectURL(this.recordedBlob), t = `qaid-video-title-${this.host.uid}`, o = n("h3", { text: "Review your recording", attrs: { id: t } }), r = n("video");
|
|
218
|
-
r.src = i, r.controls = !0, r.autoplay = !0, r.muted = !0;
|
|
219
|
-
const s = n("textarea", {
|
|
220
|
-
attrs: {
|
|
221
|
-
placeholder: "Optional: Describe the issue you recorded...",
|
|
222
|
-
"aria-label": "Describe the issue you recorded"
|
|
223
|
-
}
|
|
224
|
-
}), a = n("button", {
|
|
225
|
-
class: "qaid-video-btn qaid-video-btn-send",
|
|
226
|
-
text: "Send",
|
|
227
|
-
attrs: { type: "button" },
|
|
228
|
-
on: { click: () => this.submitVideoFeedback(s.value.trim() || null, a) }
|
|
229
|
-
}), c = n(
|
|
230
|
-
"div",
|
|
231
|
-
{ class: "qaid-video-preview-box" },
|
|
232
|
-
o,
|
|
233
|
-
r,
|
|
234
|
-
s,
|
|
235
|
-
n(
|
|
236
|
-
"div",
|
|
237
|
-
{ class: "qaid-video-preview-actions" },
|
|
238
|
-
n("button", {
|
|
239
|
-
class: "qaid-video-btn qaid-video-btn-cancel",
|
|
240
|
-
text: "Cancel",
|
|
241
|
-
attrs: { type: "button" },
|
|
242
|
-
on: { click: () => this.cancelRecordingPreview() }
|
|
243
|
-
}),
|
|
244
|
-
n("button", {
|
|
245
|
-
class: "qaid-video-btn qaid-video-btn-rerecord",
|
|
246
|
-
text: "Re-record",
|
|
247
|
-
attrs: { type: "button" },
|
|
248
|
-
on: {
|
|
249
|
-
click: () => {
|
|
250
|
-
this.cancelRecordingPreview(), this.startRecording();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}),
|
|
254
|
-
a
|
|
255
|
-
)
|
|
256
|
-
);
|
|
257
|
-
this.videoPreview = n(
|
|
258
|
-
"div",
|
|
259
|
-
{ class: "qaid-video-preview", style: `z-index:${this.host.config.zIndex + 100}` },
|
|
260
|
-
c
|
|
261
|
-
), this.host.applyVars(this.videoPreview), this.host.overlayShadowHost && (this.host.overlayShadowHost.style.pointerEvents = "auto"), e.appendChild(this.videoPreview), this.host.openDialogA11y(c, { labelledbyId: o.id }), document.addEventListener("keydown", this.host.boundKeyDown);
|
|
262
|
-
}
|
|
263
|
-
cancelRecordingPreview() {
|
|
264
|
-
this.removeVideoPreview(), this.cleanupRecording();
|
|
265
|
-
}
|
|
266
|
-
removeVideoPreview() {
|
|
267
|
-
if (this.host.closeDialogA11y(), this.videoPreview) {
|
|
268
|
-
const e = this.videoPreview.querySelector("video");
|
|
269
|
-
e?.src && URL.revokeObjectURL(e.src), this.videoPreview.remove(), this.videoPreview = null;
|
|
270
|
-
}
|
|
271
|
-
document.removeEventListener("keydown", this.host.boundKeyDown);
|
|
272
|
-
}
|
|
273
|
-
async submitVideoFeedback(e, i) {
|
|
274
|
-
if (!this.recordedBlob || this.isSendingVideo) return;
|
|
275
|
-
this.isSendingVideo = !0, i.disabled = !0, i.textContent = "Sending...";
|
|
276
|
-
const t = new FormData();
|
|
277
|
-
t.append("video", this.recordedBlob, `recording.${this.recordedBlob.type.includes("mp4") ? "mp4" : "webm"}`), t.append("pageUrl", window.location.href), t.append("visitorId", this.host.visitorId), this.host.config.apiKey && t.append("apiKey", this.host.config.apiKey), e && t.append("message", e), this.host.consoleCapture && t.append("consoleErrors", JSON.stringify(this.host.consoleCapture.errors)), this.networkCapture && t.append("networkErrors", JSON.stringify(this.networkCapture.errors));
|
|
278
|
-
let o = null, r = null;
|
|
279
|
-
try {
|
|
280
|
-
const s = await fetch(`${this.host.config.endpoint}/video`, {
|
|
281
|
-
method: "POST",
|
|
282
|
-
body: t
|
|
283
|
-
});
|
|
284
|
-
if (s.ok) {
|
|
285
|
-
this.host.announceMsg("Recording sent");
|
|
286
|
-
try {
|
|
287
|
-
o = (await s.json())?.id ?? null;
|
|
288
|
-
} catch {
|
|
289
|
-
}
|
|
290
|
-
} else
|
|
291
|
-
console.error("Failed to submit video feedback:", await s.text()), r = s.status === 413 ? "This recording is too large to send. Try a shorter one." : "Your recording could not be sent.";
|
|
292
|
-
} catch (s) {
|
|
293
|
-
console.error("Failed to submit video feedback:", s), r = "Your recording could not be sent. Check your connection and try again.";
|
|
294
|
-
}
|
|
295
|
-
if (this.isSendingVideo = !1, r) {
|
|
296
|
-
this.showSendError(r, i);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
this.removeVideoPreview(), this.cleanupRecording(), await this.host.tryLaunchQuest("video", o);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Keep the preview open and say the upload failed. Closing it, as a success
|
|
303
|
-
* does, told the visitor their recording had arrived when it had not. Send
|
|
304
|
-
* is re-enabled for another try; Cancel and Re-record still work.
|
|
305
|
-
*/
|
|
306
|
-
showSendError(e, i) {
|
|
307
|
-
this.host.announceMsg(`Failed to send recording. ${e}`, !0), i.disabled = !1, i.textContent = "Send";
|
|
308
|
-
const t = this.videoPreview?.querySelector(".qaid-video-preview-actions");
|
|
309
|
-
if (t) {
|
|
310
|
-
let o = this.videoPreview.querySelector(".qaid-video-error");
|
|
311
|
-
o || (o = n("p", { class: "qaid-video-error" }), t.before(o)), o.textContent = e;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
cleanupRecording() {
|
|
315
|
-
this.isRecording = !1, this.removeRecordingIndicator(), this.videoRecorder && (this.videoRecorder.destroy(), this.videoRecorder = null), this.networkCapture && (this.networkCapture.restore(), this.networkCapture = null), this.recordedBlob && (this.recordedBlob = null), this.host.setButtonsDisabled(!1), this.host.overlayShadowHost && this.host.state === "IDLE" && (this.host.overlayShadowHost.style.pointerEvents = "none");
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
const R = v;
|
|
319
|
-
export {
|
|
320
|
-
k as RecordingController,
|
|
321
|
-
R as styles
|
|
322
|
-
};
|
|
323
|
-
//# sourceMappingURL=recording-CPzxRL7f.js.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
async function v(m = {}) {
|
|
2
|
-
const { quality: g = 0.8, maxWidth: w = 1280, maxHeight: p = 800 } = m;
|
|
3
|
-
try {
|
|
4
|
-
if (!navigator.mediaDevices?.getDisplayMedia)
|
|
5
|
-
return console.warn("Screen Capture API not available"), null;
|
|
6
|
-
const a = await navigator.mediaDevices.getDisplayMedia({
|
|
7
|
-
preferCurrentTab: !0,
|
|
8
|
-
video: {
|
|
9
|
-
displaySurface: "browser"
|
|
10
|
-
}
|
|
11
|
-
}), i = a.getVideoTracks()[0], r = i.getSettings(), e = document.createElement("video");
|
|
12
|
-
e.srcObject = a, e.muted = !0, await new Promise((t) => {
|
|
13
|
-
e.onloadedmetadata = () => {
|
|
14
|
-
e.play(), t();
|
|
15
|
-
};
|
|
16
|
-
}), await new Promise((t) => {
|
|
17
|
-
const l = () => {
|
|
18
|
-
e.readyState >= 2 ? t() : requestAnimationFrame(l);
|
|
19
|
-
};
|
|
20
|
-
l();
|
|
21
|
-
}), await new Promise((t) => setTimeout(t, 100));
|
|
22
|
-
const o = r.width || e.videoWidth, c = r.height || e.videoHeight, s = Math.min(w / o, p / c, 1), d = Math.round(o * s), u = Math.round(c * s), n = document.createElement("canvas");
|
|
23
|
-
n.width = d, n.height = u;
|
|
24
|
-
const h = n.getContext("2d");
|
|
25
|
-
return h ? (h.drawImage(e, 0, 0, d, u), i.stop(), n.toDataURL("image/webp", g)) : (i.stop(), null);
|
|
26
|
-
} catch (a) {
|
|
27
|
-
return console.warn("Screenshot capture failed:", a), null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
v as captureScreenshot
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=screenshot-DYOKg2bS.js.map
|