UNPKG

@sprig-technologies/sprig-browser

Version:

npm package for the sprig web sdk

1,020 lines (925 loc) 53.9 kB
import { u, c as _, a as $, F as Me, h as de, p as J, _ as K, g as Ce, S as Oe, b as le, y as ue, d as Be } from "./view-CDrJuRMn.js"; import { g as He, i as Se, E as Ve, b as ye } from "./core-YTxB8B8q.js"; import { d as Ue } from "./debounce-CMb8f7wh.js"; import { v as Fe } from "./metricsReporter-0HbKrvkx.js"; const Ne = (e) => u("button", { ...e, className: _("ul-card-text__button", e.className), id: "ul-card-text__button" }), $e = ({ html: e, ...n }) => { const { enableCspTrustedTypes: o } = $((i) => ({ enableCspTrustedTypes: i.enableCspTrustedTypes })), t = Me(() => He(e, o), [o, e]); return u("div", { ...n, dangerouslySetInnerHTML: { __html: t } }); }, xe = () => { const { viewDocument: e } = $((t) => ({ viewDocument: t.viewDocument })), [n, o] = de(!1); return J(() => { const t = e.querySelector(".sprig-question-body"), i = new ResizeObserver(() => { window.requestAnimationFrame(() => { o(!!(t && Se(t) && t.scrollHeight > t.offsetHeight)); }); }); return t && i.observe(t), () => { t && i.disconnect(); }; }, [e]), n; }, ve = ({ plainText: e, richText: n, id: o, className: t, isHeader: i, showAsterisk: s }) => n ? u($e, { className: t, html: n, id: o }) : e ? i ? u("h1", { className: t, id: o, children: [e, s && "*"] }) : u("p", { className: t, id: o, children: e }) : null, rn = ({ message: e, properties: n, isRequired: o }) => { const t = K(null), i = n == null ? void 0 : n.captionText, s = xe(); return u("div", { className: _("question-header-container", "sprig-header-container", s ? "sprig-border-bottom" : null), ref: t, children: [u("div", { className: "question-header-button-container", children: u(ve, { className: "ul-question", id: "ul-question", isHeader: !0, plainText: e, richText: n == null ? void 0 : n.questionHtml, showAsterisk: o }) }), u(ve, { className: "ul-caption", id: "ul-caption", plainText: i, richText: n == null ? void 0 : n.captionHtml })] }); }, Ae = () => u("svg", { fill: "none", height: "10", viewBox: "0 0 13 10", width: "13", xmlns: "http://www.w3.org/2000/svg", children: u("path", { d: "M11.5 1.5L4.5 8.5L1 5", stroke: "#FFFFFF", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) }), sn = ({ isSubmitDisabled: e, handleSubmit: n }) => u("div", { className: "ul-card-longform__submit-button-container", children: u(Ne, { className: "ul-card-longform__submit-button", disabled: e, onClick: n, children: ["OK ", u(Ae, {})] }) }), ln = (e, n) => { const o = K(0); return () => { if (e.current) { const t = e.current; t.style.height = "1px"; const i = t.scrollHeight + (t.offsetHeight - t.clientHeight), s = parseInt(window.getComputedStyle(t).getPropertyValue("max-height")), l = i <= s ? i : s; o.current !== l && requestAnimationFrame(() => { n(); }), o.current = l, t.style.height = `${l}px`; } }; }, an = (e) => { const n = K(), { setAllResponsesRaw: o } = $((t) => ({ setAllResponsesRaw: t.setAllResponsesRaw })); J(() => { const t = n.current; (!t || Object.keys(e).length !== Object.keys(t).length || Object.keys(e).some((i) => e[i] !== t[i])) && (o(e), n.current = e); }, [e, o]); }, he = ({ buttonText: e = "View Prototype", handleClick: n }) => u("button", { className: "prototype-button", onClick: n, children: e }, "prototype-btn"), dn = ({ embeddedType: e = "prototype", properties: n, children: o }) => { var I; const { handleClickEmbedButton: t, hasViewedEmbed: i, headers: s, useDesktopPrototype: l } = $((g) => ({ handleClickEmbedButton: g.handleClickEmbedButton, hasViewedEmbed: g.hasViewedEmbed, headers: g.headers, useDesktopPrototype: g.useDesktopPrototype })), v = (n == null ? void 0 : n.conceptUrl) || ((I = n == null ? void 0 : n.consentDocument) == null ? void 0 : I.url), r = window.innerWidth < Ve, c = s["userleap-platform"], h = (g, T) => { g.preventDefault(), t(T); }; if ((() => { const { update: g, index: T, isConversationalUI: f, viewDocument: L } = $(({ update: w, index: j, isConversationalUI: b, viewDocument: k }) => ({ update: w, index: j, isConversationalUI: b, viewDocument: k })), d = Ue(g, 100); J(() => { if (f) return; const w = new ResizeObserver(d), j = L.querySelector(".ul-card__container"); return j && w.observe(j, { box: "border-box" }), () => { w.disconnect(); }; }, [d, g, T, f, L]); })(), !l && r && !i && v && ["email", "link"].includes(c)) { if (e === "prototype") return u(he, { handleClick: (g) => { h(g, "question.prototype.click"); } }); if (e === "pdf") return u(he, { buttonText: (n == null ? void 0 : n.viewDocumentText) || "View Document", handleClick: (g) => { h(g, "question.agreement.click"); } }); } return u(Ce, { children: o }); }, je = ({ isSelected: e, id: n, divId: o, themeColor: t, disabled: i = !1 }) => u("div", { "aria-checked": e, "aria-disabled": i, "aria-labelledby": `label-${n}`, className: "select-checkbox", id: o, role: "checkbox", style: { ...e ? { backgroundColor: t, borderColor: t, boxShadow: "none" } : {}, ...i ? { opacity: 0.5 } : {} }, tabIndex: i ? -1 : 0, children: e && u(Oe, {}) }), cn = ({ ariaLabel: e, border: n, choiceStyle: o = {}, label: t, isSelected: i, value: s, text: l, id: v, isRadio: r, useMobileStyling: c, error: h, allowTextEntry: I, noneOfTheAbove: g, promptText: T, disabled: f = !1, onUserInputChanged: L }) => { const { styleNonce: d, viewDocument: w } = $((E) => ({ styleNonce: E.styleNonce, viewDocument: E.viewDocument })), [j, b] = de(!1); qe(w, n, d); const k = ({ isSelected: E, userText: y }) => { L && L({ id: v, selected: E, value: s, userText: y, noneOfTheAbove: g }); }, M = (E) => { f || (E.stopPropagation(), k({ isSelected: r || !i, userText: l }), b(!1)); }, Y = () => { j || b(!0); }, O = () => { j && b(!1); }, B = { onClick: (E) => M(E), onKeyPress: (E) => ((y) => { f || y.key !== "Enter" && y.key !== " " || M(y); })(E) }; "ontouchstart" in w.documentElement ? (B.onTouchStart = O, B.onTouchCancel = O, B.onTouchEnd = O) : (B.onMouseDown = Y, B.onMouseLeave = O); const W = r ? `radio-${v}` : `checkbox-${v}`, p = i || j ? [ee] : [], C = [...h ? [Ee] : [], ...p, ...f ? ["ul-choice-disabled"] : []], m = t ? { "aria-labelledby": `label-${v}` } : { "aria-label": e }; return u("div", { className: _(le("choice", c), ...C), id: `choice-div-${v}`, style: { ...o, ...h ? { borderColor: ye } : {}, ...f ? { opacity: 0.5, cursor: "not-allowed" } : {} }, ...f ? {} : B, "aria-disabled": f, children: [u("div", { className: _("choice-label-container"), children: [r ? u("div", { ...m, className: _("select-radio", ...p), id: W, role: "radio", tabIndex: 0 }) : u(je, { disabled: f, divId: W, id: v, isSelected: i, themeColor: n }), t && u("label", { className: _(le("select-label", c)), htmlFor: W, id: `label-${v}`, children: t })] }), I && i && u("div", { className: _("choice-text-entry-container", ...p), children: u(ze, { onTextChange: (E) => k({ isSelected: i, userText: E }), promptText: T || "Please specify", textValue: l, useMobileStyling: c }) })] }); }, ze = ({ promptText: e, textValue: n, onTextChange: o, useMobileStyling: t }) => { const i = K(null); return J(() => { i.current && i.current.focus(); }, []), u("textarea", { "aria-label": e, "aria-multiline": "true", "aria-placeholder": e, className: _(le("choice-text-input", t)), "data-gramm": "false", maxLength: 5e3, name: "text", onChange: (s) => { s.stopPropagation(), o(s.currentTarget.value); }, onClick: (s) => { s.stopPropagation(); }, onKeyPress: (s) => { s.stopPropagation(); }, placeholder: e, ref: i, role: "textbox", rows: 1, value: n }); }, me = "ul-select-style-element", ee = "ul-select-active-dynamic-style", Ee = "ul-select-error-dynamic-style", qe = (e, n, o) => { let t = e.getElementById(me), i = !1; t || (t = e.createElement("style"), i = !0), t.tagName.toLowerCase() === "style" && (t.id = me, o && (t.nonce = o), t.textContent = Ze(n), i && e.head.appendChild(t)); }, Ze = (e) => ` .${ee} { border-color: ${e}; } .${ee} .select-radio, .${ee}.select-radio { border: 6px solid ${e}; box-shadow: none; } .${Ee} { border-color: ${ye}; } `, pn = ({ children: e }) => u("div", { className: "sprig-question-body", children: e }), un = ({ children: e }) => { const n = xe(), { isConversationalUI: o } = $((t) => ({ isConversationalUI: t.isConversationalUI })); return u("div", { className: _("sprig-question-footer-container", n && !o ? "sprig-border-top" : null), children: e }); }, Ge = ({ options: e, selectItem: n, selectedOptions: o, showCheckbox: t, disabledOptions: i, dropdownFooter: s, panelRef: l }) => { const { themeColor: v } = $((r) => ({ doc: r.viewDocument, themeColor: r.border })); return u("div", { className: "select-list", ref: l, children: [e.map((r) => { return u("div", { "aria-disabled": i == null ? void 0 : i.includes(r), className: _("select-option", i != null && i.includes(r) ? "ul-choice-disabled" : ""), onClick: (h) => { i != null && i.includes(r) || (n(r), h.stopPropagation()); }, role: "option", style: { ...i != null && i.includes(r) ? { opacity: 0.5, cursor: "not-allowed" } : {} }, children: [t && u(je, { divId: (c = r.id, `checkbox-div-${c}`), id: r.id, isSelected: o.includes(r), themeColor: v }), r.label] }, r.id); var c; }), s] }); }, vn = ({ isMultiSelect: e = !1, multiselectText: n = "choices selected", onChange: o, options: t, placeholderText: i, value: s, disabledOptions: l = [], dropdownFooter: v }) => { const [r, c] = de(!1), h = K(null), { viewDocument: I, update: g, isConversationalUI: T } = $((d) => ({ viewDocument: d.viewDocument, update: d.update, isConversationalUI: d.isConversationalUI })), f = () => { c(!r); }; ue(() => { T || g(); }, [r, T, g]), ue(() => { r && h.current && h.current.scrollIntoView({ behavior: "smooth", block: "nearest" }); }, [r]), J(() => { var w; const d = (j) => { const b = j.target; (b == null ? void 0 : b.closest(".select-option.ul-choice-disabled")) || c(!1); }; I.addEventListener("click", d); try { (w = window.parent) == null || w.addEventListener("click", d); } catch { window.addEventListener("click", d); } return () => { var j; I.removeEventListener("click", d); try { (j = window.parent) == null || j.removeEventListener("click", d); } catch { window.removeEventListener("click", d); } }; }, [I]); const L = s.length === 0 ? ["select-button-placeholder"] : []; return u(Ce, { children: [u("button", { "aria-label": "choice dropdown button", className: _("select-button", ...L), onClick: (d) => { d.stopPropagation(), f(); }, type: "button", children: [u("span", { children: s.length === 0 ? i : s.length === 1 ? s[0].label : `${s.length} ${n}` }), u(Be, {})] }), r && u(Ge, { disabledOptions: l, dropdownFooter: v, options: t, panelRef: h, selectedOptions: s, selectItem: (d) => { var b; const w = s.some((k) => k.id === d.id), j = s.some((k) => { var M; return (M = k.optionProperties) == null ? void 0 : M.noneOfTheAbove; }); (b = d.optionProperties) != null && b.noneOfTheAbove && !w ? o([d]) : e ? o(w ? s.filter((k) => k.id !== d.id) : j ? [d] : [...s, d]) : w || o([d]), e || f(); }, showCheckbox: e })] }); }, We = { "{{user_id}}": "externalUserId", "{{email}}": "email" }, hn = (e = void 0, n = {}) => { if (!e) return e; const o = ["http:", "https:", "itms-apps:", "market:"], t = ((l) => /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(l) ? l : `http://${l}`)(e); if (!t) return; try { const l = new URL(t); if (!l.protocol || !o.includes(l.protocol)) return; } catch { return; } const i = [], s = ((l, v, r) => { let c = l; for (const [h, I] of Object.entries(We)) if (c.toLowerCase().includes(h)) if (v[I]) { const g = new RegExp(h, "gi"); c = c.replace(g, v[I]); } else r.push(h); return c; })(t, n, i); return i.length === 0 ? s : ((l, v) => { if (!l.includes("?")) return l; const r = l.slice(0, l.indexOf("?")), c = l.slice(l.indexOf("?") + 1).split("&").map((h) => h.split("=")).filter((h) => !v.includes(h[1])); return c.length === 0 ? r : `${r}?${c.map((h) => h.join("=")).join("&")}`; })(s, i); }, G = "https://cdn.sprig.com", a = { document: void 0, videojs: void 0 }, ce = (e) => e + "-loading-spiner", D = "hidden", ge = ".m3u8", te = "questionId", re = "ul-video-recorder-camera-off-button", ie = "ul-recording-in-session", Ye = [{ type: "link", content: `${G}/dependencies/videojs-record-4.5.0.min.css` }, { type: "script", content: `${G}/dependencies/RecordRTC-5.6.2.js` }, { type: "script", content: `${G}/dependencies/adapter.8.0.0.min.js` }, { type: "script", content: `${G}/dependencies/videojs-record-4.5.0.min.js` }, { type: "script", content: `${G}/userleap-web-upchunk-v2.2.2.js` }], ke = [{ type: "link", content: `${G}/dependencies/video-js-7.18.0.min.css` }, { type: "script", content: `${G}/dependencies/video-js-7.18.0.min.js` }, { type: "style", content: `/* progress control styles */ .video-js .vjs-control { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; } .video-js .vjs-progress-control .vjs-progress-holder { margin: 0 0px; } .video-js .vjs-progress-control { position: absolute; height: 3px; width: 100%; } /* position and align the buttons and button texts */ .ul-control-panel { bottom: 0; width: 100%; flex-direction: column; background-color: white; height: fit-content; z-index: 2; } .ul-buttons-panel { color: black; display: flex; gap: 20px; height: 50px; justify-content: center; margin: 10px; padding: 2px 14px 0; } .video-js .vjs-volume-panel { height: 30px; width: 40px; } .ul-inactive { opacity: 0.3; cursor: default; pointer-events: none; } /* buttons */ .ul-buttons-panel > .vjs-button { background-color: rgba(0, 0, 0, 0.05); border-radius: 50%; display: flex; height: 3em; justify-content: center; width: 3em; } .vjs-button>.vjs-icon-placeholder:before { align-items: center; display: flex; font-size: unset; line-height: 0.5; justify-content: center; } span.ul-button-text { align-self: flex-end; position: relative; top: 14px; } #ul-camera-button { white-space: nowrap; } .video-js .vjs-volume-control.vjs-volume-horizontal { background-color: #fff; z-index: 1; } .vjs-volume-bar.vjs-slider-horizontal .vjs-volume-level { background-color: black; } .video-js .vjs-volume-panel.vjs-volume-panel-horizontal.vjs-hover, .video-js .vjs-volume-panel.vjs-volume-panel-horizontal.vjs-slider-active, .video-js .vjs-volume-panel.vjs-volume-panel-horizontal:active { width: 40px; } .video-js .vjs-volume-panel .vjs-volume-control.vjs-slider-active, .video-js .vjs-volume-panel .vjs-volume-control:active, .video-js .vjs-volume-panel.vjs-hover .vjs-mute-control ~ .vjs-volume-control, .video-js .vjs-volume-panel.vjs-hover .vjs-volume-control, .video-js .vjs-volume-panel:active .vjs-volume-control, .video-js .vjs-volume-panel:focus .vjs-volume-control { visibility: visible; left: 40px; position: absolute; transition: visibility 0.1s, opacity 0.1s, height 0.1s, width 0.1s, left 0s, top 0s; } /* play button customization */ .video-js .vjs-play-control { color: black; } .video-js .vjs-play-control .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5363 6.40226L1.93958 10.7006C1.64037 10.8502 1.28833 10.6326 1.28833 10.2981V1.7014C1.28833 1.36688 1.64037 1.14931 1.93958 1.29891L10.5363 5.59727C10.868 5.76311 10.868 6.23642 10.5363 6.40226Z' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); } /* position and style the current timer */ .ul-time-panel { position: absolute; bottom: 80px; left: 10px; height: 22px; color: black; border: 1px solid #e0e0eb; border-radius: 23px; background-color: white; width: fit-content; } .video-js .vjs-current-time, .vjs-no-flex .vjs-current-time { display: flex; align-items: center; text-align: center; } /* remove the dot progress indicator */ .video-js .vjs-play-progress:before, .video-js .vjs-volume-level:before, .vjs-icon-circle:before, .vjs-seek-to-live-control .vjs-icon-placeholder:before { content: none; } .video-js .vjs-mute-control .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='19' height='14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8.825.324A.75.75 0 019.25 1v11.667a.75.75 0 01-1.219.585l-3.96-3.169H1a.75.75 0 01-.75-.75v-5a.75.75 0 01.75-.75h3.07L8.031.414a.75.75 0 01.794-.09zM7.75 2.56L4.802 4.92a.75.75 0 01-.469.164H1.75v3.5h2.583a.75.75 0 01.469.165l2.948 2.358V2.56zM14.911.47a.75.75 0 011.061 0 9.084 9.084 0 010 12.844.75.75 0 01-1.06-1.06 7.584 7.584 0 000-10.724.75.75 0 010-1.06zM11.97 3.41a.75.75 0 011.06 0 4.917 4.917 0 010 6.953.75.75 0 11-1.06-1.06 3.417 3.417 0 000-4.832.75.75 0 010-1.06z' fill='%23262136'/%3E%3C/svg%3E"); } .video-js .vjs-mute-control.vjs-vol-0 .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='19' height='14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8.5 1.167L4.333 4.5H1v5h3.333L8.5 12.833V1.167zM17.17 4.5l-5 5M12.17 4.5l5 5' stroke='%23262136' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); } .video-js .vjs-mute-control.vjs-vol-1 .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='19' height='14' viewBox='0 0 19 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8.82489 0.32403C9.08474 0.44892 9.25 0.711703 9.25 1.00001V12.6667C9.25 12.955 9.08474 13.2178 8.82489 13.3427C8.56504 13.4675 8.25661 13.4324 8.03148 13.2523L4.07025 10.0833H1C0.585786 10.0833 0.25 9.74755 0.25 9.33334V4.33334C0.25 3.91913 0.585786 3.58334 1 3.58334H4.07025L8.03148 0.414355C8.25661 0.234253 8.56504 0.19914 8.82489 0.32403ZM7.75 2.56048L4.80185 4.91899C4.66887 5.02538 4.50364 5.08334 4.33333 5.08334H1.75V8.58334H4.33333C4.50364 8.58334 4.66887 8.6413 4.80185 8.74769L7.75 11.1062V2.56048Z' fill='%23262136'/%3E%3C/svg%3E%0A"); } .video-js .vjs-mute-control.vjs-vol-2 .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='19' height='14' viewBox='0 0 19 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8.82489 0.32403C9.08474 0.44892 9.25 0.711703 9.25 1.00001V12.6667C9.25 12.955 9.08474 13.2178 8.82489 13.3427C8.56504 13.4675 8.25661 13.4324 8.03148 13.2523L4.07025 10.0833H1C0.585786 10.0833 0.25 9.74755 0.25 9.33334V4.33334C0.25 3.91913 0.585786 3.58334 1 3.58334H4.07025L8.03148 0.414355C8.25661 0.234253 8.56504 0.19914 8.82489 0.32403ZM7.75 2.56048L4.80185 4.91899C4.66887 5.02538 4.50364 5.08334 4.33333 5.08334H1.75V8.58334H4.33333C4.50364 8.58334 4.66887 8.6413 4.80185 8.74769L7.75 11.1062V2.56048Z' fill='%23262136'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.9698 3.41124C12.2627 3.11839 12.7376 3.11846 13.0304 3.4114C13.9521 4.33341 14.4699 5.58376 14.4699 6.88748C14.4699 8.19121 13.9521 9.44156 13.0304 10.3636C12.7376 10.6565 12.2627 10.6566 11.9698 10.3637C11.6768 10.0709 11.6767 9.596 11.9696 9.30307C12.6101 8.66235 12.9699 7.79346 12.9699 6.88748C12.9699 5.98151 12.6101 5.11262 11.9696 4.4719C11.6767 4.17896 11.6768 3.70409 11.9698 3.41124Z' fill='%23262136'/%3E%3C/svg%3E%0A"); } .video-js .vjs-volume-control:hover .vjs-mouse-display { display: none !important; } .video-js .vjs-play-progress { background-color: black; } /* position video player inside the container */ .video-js .vjs-tech { position: static; } .video-js .vjs-time-tooltip { padding: 0.25em 0.75em; align-items: center; color: #333; background: #FCFCFD; border-radius: 99px; text-align: center; border: 1px solid #E0E0EB; display: flex; align-items: center; justify-content: center; top: -25px; font-size: 12px !important; width: 50px !important; } .video-js .vjs-play-progress.vjs-slider-bar .vjs-time-tooltip { visibility: hidden !important; } .video-js .vjs-progress-control .vjs-mouse-display { z-index: 2; } .ul-video-player { width: 100%; display: flex; flex-direction: column; height: auto; border: 1px solid #E6E6E6; background-color: white; box-sizing: border-box; border-radius: 4px; background-clip: border-box; overflow: hidden; } .video-js.vjs-fullscreen:not(.vjs-ios-native-fs) { border: none; } #video-response-player-secondary-video-player { max-width: 200px; margin-right: 20px; background-color: transparent; } #ul-card-video__player_recorder-video-recorder.vjs-fullscreen { display: table; } .video-js div.vjs-progress-control { margin-top: -3px; } .video-js .vjs-progress-control .vjs-slider { background-color: #B2BBBD; } .vjs-record.video-js .vjs-control.vjs-button.vjs-fullscreen-control { position:relative; } .video-js .vjs-fullscreen-control .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9.82143 2.54004L12.2614 2.54004C12.9242 2.54004 13.4614 3.0773 13.4614 3.74004L13.4614 6.18004' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M6.17955 13.46L3.73955 13.46C3.07681 13.46 2.53955 12.9227 2.53955 12.26L2.53955 9.81996' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M12.7772 3.22266L9.36475 6.63516' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M6.29434 9.70605L2.88184 13.1186' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); } .video-js.vjs-fullscreen .vjs-fullscreen-control .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='16' height='16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.583 9.813H5.25a1 1 0 011 1v3.666M5.375 10.688L1 15.061M14.917 5.813H11.25a1 1 0 01-1-1V1.146M15.063 1l-4.376 4.375' stroke='%23262136' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); } .video-js .vjs-play-control.vjs-ended .vjs-icon-placeholder:before, .video-js .vjs-icon-replay:before { content: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5363 6.40226L1.93958 10.7006C1.64037 10.8502 1.28833 10.6326 1.28833 10.2981V1.7014C1.28833 1.36688 1.64037 1.14931 1.93958 1.29891L10.5363 5.59727C10.868 5.76311 10.868 6.23642 10.5363 6.40226Z' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); } .video-js .vjs-play-control.vjs-playing .vjs-icon-placeholder:before, .vjs-icon-pause:before { content: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='3.61885' y='2.06074' width='3.16185' height='11.88' rx='0.9' fill='black' stroke='%23EDEDED' stroke-width='0.6' stroke-linecap='round'/%3E%3Crect x='9.21797' y='2.06074' width='3.16185' height='11.88' rx='0.9' fill='black' stroke='%23EDEDED' stroke-width='0.6' stroke-linecap='round'/%3E%3C/svg%3E%0A"); padding: 2px; } .vjs-error-display { display: none; } .ul-video-player-video { position: relative; top: 0; left: 0; width: 100%; } .ul-video-container { width: 100%; height: auto; left: 0px; top: 0px; background-color: transparent; border-radius: 4px; align-items: start; display: flex; flex-direction: column; /* Inside Auto Layout */ flex: none; order: 0; flex-grow: 0; margin: 10px 0px; position: relative; } .vjs-record button.vjs-device-button.vjs-control { background: rgba(255, 255, 255, 96); width: 100%; height: 100%; left: 0; top: 0; margin: 0; border-radius: 0; line-height: 0.6; padding: 10px; display: flex; align-items: center; flex-direction: column; justify-content: center; z-index: 3; } .vjs-record .vjs-device-button.vjs-control:before { font-size: 14px !important; color: #333; content: "Your browser needs to access your camera and microphone for video recording"; line-height: 135%; } .vjs-record .vjs-device-button.vjs-control.permission-denied:before { font-size: 16px !important; color: #262136; content: "Unable to access your camera and microphone"; } .vjs-record .vjs-device-button.vjs-control:after { display: inline-block; background: #F0F0F5; font-size: 13px; border-radius: 4px; content: "Request Permissions"; padding: 1em 2em; color: #333; margin-top: 20px; } .vjs-record .vjs-device-button.vjs-control.permission-denied:after { display: inline-block; background: white; font-size: 13px; content: "Please go to your browser settings and update permissions to enable recording"; padding: 1em; color: #4B575D; margin: 5px; line-height: 135%; text-align: center; } .vjs-control.vjs-button.ul-video-recorder-delete-button, .vjs-control.vjs-button.ul-video-recorder-toggle-button, .vjs-control.vjs-button.ul-video-recorder-camera-off-button-audio-only, .vjs-control.vjs-button.ul-video-recorder-camera-off-button { cursor: pointer; } .ul-video-recorder-delete-button .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9.21234 7.37549V11.1193M2.53931 4.25595H13.4593H2.53931ZM5.57234 4.25595V3.00833C5.57222 2.84433 5.60354 2.68192 5.6645 2.53038C5.72546 2.37884 5.81488 2.24115 5.92762 2.12519C6.04037 2.00922 6.17424 1.91726 6.32158 1.85456C6.46892 1.79185 6.62683 1.75964 6.78628 1.75977H9.21234C9.37179 1.75964 9.5297 1.79185 9.67703 1.85456C9.82437 1.91726 9.95824 2.00922 10.071 2.12519C10.1837 2.24115 10.2732 2.37884 10.3341 2.53038C10.3951 2.68192 10.4264 2.84433 10.4263 3.00833V4.25595H5.57234ZM12.2463 4.25595V12.9912C12.2463 13.3223 12.1184 13.6399 11.8907 13.8741C11.6631 14.1082 11.3543 14.2398 11.0323 14.2398H4.96628C4.64432 14.2398 4.33555 14.1082 4.10789 13.8741C3.88023 13.6399 3.75234 13.3223 3.75234 12.9912V4.25595H12.2463ZM6.78628 7.37549V11.1193V7.37549Z' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A"); } .ul-video-recorder-toggle-button .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 0C12.4183 0 16 3.58172 16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8C0 3.58172 3.58172 0 8 0Z' fill='%23D15153'/%3E%3C/svg%3E"); } .ul-video-recorder-toggle-button.ul-recording-in-session .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 10L12 2C12 0.89543 11.1046 -4.85396e-07 10 -4.37114e-07L2 -8.74228e-08C0.89543 -3.91405e-08 -4.85396e-07 0.895431 -4.37114e-07 2L-8.74228e-08 10C-3.91405e-08 11.1046 0.895431 12 2 12L10 12C11.1046 12 12 11.1046 12 10Z' fill='%23D15153'/%3E%3C/svg%3E%0A"); } .ul-video-recorder-camera-off-button .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_2645_4654)'%3E%3Cpath d='M15.1491 4.75L10.5991 8L15.1491 11.25V4.75Z' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M9.29912 3.4502H2.14912C1.43115 3.4502 0.849121 4.03223 0.849121 4.7502V11.2502C0.849121 11.9682 1.43115 12.5502 2.14912 12.5502H9.29912C10.0171 12.5502 10.5991 11.9682 10.5991 11.2502V4.7502C10.5991 4.03223 10.0171 3.4502 9.29912 3.4502Z' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_2645_4654'%3E%3Crect width='15.6' height='15.6' fill='white' transform='translate(0.199951 0.200195)'/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E"); } .ul-video-recorder-camera-off-button-audio-only .vjs-icon-placeholder:before { content: url("data:image/svg+xml,%3Csvg width='22' height='15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M.75 3A2.75 2.75 0 013.5.25h9.081A2.75 2.75 0 0115.331 3v9a2.75 2.75 0 01-2.75 2.75H3.5A2.75 2.75 0 01.75 12V3zM3.5 1.75c-.69 0-1.25.56-1.25 1.25v9c0 .69.56 1.25 1.25 1.25h9.081c.69 0 1.25-.56 1.25-1.25V3c0-.69-.56-1.25-1.25-1.25H3.5z' fill='%23262136'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M14.53 2.03l-12 12-1.06-1.06 12-12 1.06 1.06zM20.87 1.525a.75.75 0 01.38.652v10.588a.75.75 0 01-1.134.644l-5.92-3.53a.75.75 0 01-.365-.643v-3.53a.75.75 0 01.366-.644l5.919-3.53a.75.75 0 01.754-.007zm-5.539 4.607V8.81l4.419 2.635V3.497l-4.419 2.635z' fill='%23262136'/%3E%3C/svg%3E"); transform: scale(0.75); } .ul-upload-progress-label { padding: 0.15em 0.75em; align-items: center; font-size: 12px; color: #333; background: #FCFCFD; border-radius: 99px; text-align: center; border: 1px solid #E0E0EB; display: flex; align-items: center; justify-content: center; position: absolute; bottom: 75px; left: calc(50% - 65px); width: 130px; z-index: 5; } .ul-upload-progress-label__time { display: inline-flex; margin-left: 0.8em; align-items: center; } .ul-upload-progress-label__time:before { content: ""; display: inline-flex; width: 1px; height: 12px; background-color: #E0E0EB; margin-right: 0.8em; } @keyframes grow { 0% { transform: scale(1); background-color: #EEECFC; } 50% { transform: scale(1.2); background-color: #E1DFF4; } 100% { transform: scale(1); background-color: #EEECFC; } } .ul-audio-recorder-placeholder:before { width: 80px; height: 80px; border-radius: 120px; background-color: #EEECFC; content: ""; position: absolute; left: calc(50% - 40px); top: calc(50% - 40px); animation: 6s infinite grow; transform-origin: 50% 60%; } .ul-audio-recorder-placeholder:after { content: url("data:image/svg+xml,%3Csvg width='98' height='98' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cmask id='a' maskUnits='userSpaceOnUse' x='0' y='0' width='98' height='98'%3E%3Ccircle cx='49' cy='49' r='49' fill='%23EDECF8'/%3E%3C/mask%3E%3Cg mask='url(%23a)'%3E%3Ccircle cx='49' cy='49' r='50' fill='%23645CC2'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.422 81.812c5.405-15.547 20.187-26.706 37.576-26.706 17.39 0 32.172 11.159 37.577 26.707-9.164 10.43-22.601 17.013-37.576 17.013-14.976 0-28.414-6.583-37.577-17.014z' fill='%23fff' fill-opacity='.6'/%3E%3Ccircle cx='49' cy='29' r='17' fill='%23fff' fill-opacity='.7'/%3E%3C/g%3E%3C/svg%3E"); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); transform: translate(-50%, -50%) scale(0.6); } .ul-audio-recorder-placeholder { min-height: 150px; width: 100%; background-color: #fcfcfd; display: block; position: relative; } .vjs-fullscreen .ul-audio-recorder-placeholder { vertical-align: middle; display: table-cell; } .vjs-fullscreen .ul-control-panel { height: 80px; position: absolute; bottom: 0; left: 0; width: 100%; max-width: 100%; background-color: #F8F8F8; } .vjs-playback-rate .vjs-playback-rate-value { align-items: center; display: flex; font-size: 12px; justify-content: center; } .vjs-playback-rate .vjs-menu { left: -5px; bottom: 3px; } .vjs-menu-button-popup .vjs-menu .vjs-menu-content { background-color: white; border: 1px solid rgba(0, 0, 0, 0.1); box-sizing: border-box; border-radius: 4px; } .vjs-menu li { font-size: 12px; padding: 5px 0; } .vjs-menu li.vjs-selected { color: lightgray; } .vjs-menu li.vjs-menu-item:hover { background-color: rgba(0, 0, 0, 0.05); } .vjs-fullscreen .ul-buttons-panel { top: calc(50% - 30px); position: relative; } .vjs-fullscreen .vjs-record-indicator.vjs-control { bottom: 90px !important; } .vjs-record.video-js div.vjs-control.vjs-record-indicator { padding: 0.3em 0.75em 0.15em 15px; align-items: center; font-size: 12px; color: #333; background: #FCFCFD; border-radius: 99px; text-align: center; border: 1px solid #E0E0EB; display: flex; justify-content: center; align-items: center; position: absolute; bottom: 75px; top: auto; left: calc(50% - 21px); width: 43px; height: 16px; z-index: 4; } .vjs-record.video-js div.vjs-control.vjs-record-indicator:after { content: ""; background-color: #EB5757; width: 6px; height: 6px; border-radius: 8px; animation: none; top: 4px; left: 5px; } .vjs-record.video-js div.vjs-control.vjs-record-indicator:before { position: relative; font-size: 9px; animation: none; opacity: 1; color: #333; top: auto; left: auto; } .ul-video-player-loading { display: inline-block; position: relative; width: 6rem; height: 6rem; } .ul-video-player-loading div { box-sizing: border-box; position: absolute; display: block; width: 80%; height: 80%; margin: 5px; border: 5px solid #666; border-radius: 50%; animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; border-color: #666 transparent transparent transparent; } .first { animation-delay: -0.45s; } .second { animation-delay: -0.3s; } .third { animation-delay: -0.15s; } @keyframes lds-ring { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .ul-video-btn { width: 100%; border: 1px solid #E6E6E6; border-radius: 4px; background-color: rgba(0, 0, 0, 0.02); padding: 8px; font-weight: 500; font-size: 15px; } .ul-record-response-btn:before, .ul-record-response-btn:after, .ul-back-question-btn:before, .ul-back-question-btn:after { margin: 0 5px; vertical-align: middle; } .ul-record-response-btn:before { content: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_2645_4654)'%3E%3Cpath d='M15.1491 4.75L10.5991 8L15.1491 11.25V4.75Z' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M9.29912 3.4502H2.14912C1.43115 3.4502 0.849121 4.03223 0.849121 4.7502V11.2502C0.849121 11.9682 1.43115 12.5502 2.14912 12.5502H9.29912C10.0171 12.5502 10.5991 11.9682 10.5991 11.2502V4.7502C10.5991 4.03223 10.0171 3.4502 9.29912 3.4502Z' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_2645_4654'%3E%3Crect width='15.6' height='15.6' fill='white' transform='translate(0.199951 0.200195)'/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E"); display: inline-block; transform: translate(0px, 2px); } .ul-record-response-btn:after { content: 'Record your Response'; } .ul-back-question-btn:before { content: url("data:image/svg+xml,%3Csvg width='15' height='16' viewBox='0 0 15 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13.8757 8.22361L1.1118 14.6056C0.945578 14.6887 0.75 14.5678 0.75 14.382V1.61803C0.75 1.43219 0.945579 1.31131 1.1118 1.39443L13.8757 7.77639C14.06 7.86852 14.06 8.13148 13.8757 8.22361Z' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); display: inline-block; transform: scale(0.85) translate(0, 1px); -moz-transform: scale(0.85) translate(0, 2px); } .ul-back-question-btn:after { content: 'Back to Question'; } .hidden { display: none !important; opacity: 0; visibility: hidden; } .visible { visibility: visible; opacity: 1; animation: fade 0.3s; } @keyframes fade { 0% { opacity: 0; } 100% { opacity: 1; } } #ul-recording-countdown-screen { width: 100%; height: 100%; color: black; background-color: rgba(255, 255, 255, 0.8); position: absolute; text-align: center; font-size: 15px; z-index: 1; display: table; } .ul-countdown-text { vertical-align: middle; display: table-cell; transform: translate(0, -25px); } .vjs-fullscreen > #ul-recording-countdown-screen { font-size: 25px; transform: unset; } .vjs-poster { background-size: cover; } ` }], Ie = "-video-player", be = "-secondary-video-player", De = "-video-recorder"; let V, fe; const z = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: i, metadata: s }) => { const l = a.document.documentElement; if (!t || !i) return; const v = { event: `SDK - ${e}`, visitorId: t, environmentId: i, metadata: { ...s || {}, screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: l.clientWidth, clientHeight: l.clientHeight, location: window.location.href, language: navigator.language } }; (await fetch(`${n}/sdk/1/visitors/${t}/analytics`, { method: "POST", cache: "no-cache", headers: o, body: JSON.stringify(v) })).ok || console.warn("[Sprig] (ERR-444) Failed to track analytics", e); }, N = async (e, n, o, t, i, s) => { z({ event: `Video Error ${n}`, apiBase: o, headers: t, visitorId: i, envId: s, metadata: { errorMessage: e.message } }); const l = a.document.documentElement, v = { screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: l.clientWidth, clientHeight: l.clientHeight, location: window.location.href, language: navigator.language }, r = { action: n, err: { message: e.message, stack: e.stack }, meta: v, vid: i, envId: s }; (await fetch(`${o}/sdk/1/errors`, { method: "POST", cache: "no-cache", headers: { ...t, "userleap-platform": "video_recorder", "x-ul-error": window.btoa(`userleap-${Date.now()}-error`) }, body: JSON.stringify(r) })).ok || console.warn("[Sprig] (ERR-444) Failed to report error to API", e); }, Te = (e, n) => { if (e.length === 0) return n && n(); Promise.all(e.reduce((o, t) => (o.push(((i, { type: s, content: l }) => new Promise(function(v, r) { let c; s === "script" ? (c = a.document.createElement("script"), c.src = l) : s === "link" ? (c = a.document.createElement("link"), c.rel = "stylesheet", c.href = l, c.type = "text/css") : (c = a.document.createElement("style"), c.innerHTML = l), c.onload = function() { v(l); }, c.onerror = function() { r(l); }, c.async = !1, c.id = btoa(l), i.appendChild(c); }))(a.document.head, t)), o), [])).then(() => { a.videojs = a.document.defaultView.videojs, n && n(); }).catch(function(o) { console.log(o + " failed to load"); }); }, we = (e, n, o) => { if (n === "start" && (e.style.visibility = "visible"), n === "none") e.style.visibility = D; else if (n === "success") e.style.visibility = D, e.innerHTML = "Upload succeeded!"; else { const t = Math.round(parseFloat(o)); e.innerHTML = `Uploading <span class="ul-upload-progress-label__time">${t}%</span>`, e.style.background = `linear-gradient(to right, #E0E0EB 0%, #E0E0EB ${t}%, #FCFCFD ${t}%, #FCFCFD 100%)`; } }, se = (e, n) => { const o = a.videojs(e.id()); return o == null ? void 0 : o.payload[n]; }, Le = (e, n) => { const o = new (a.videojs.getComponent("Component"))(e); return o.addClass("ul-buttons-panel"), n.map((t) => { o.addChild(t); }), Je(o), o; }, Je = (e) => { e.children().forEach((n) => { if (P[n.name_]) { const o = ne(P[n.name_], `ul-${P[n.name_]}`); n.el_.appendChild(o); } }); }, ne = (e, n = "") => { const o = a.document.createElement("span"); return o.className = "ul-button-text", o.innerHTML = e, o.id = n, o; }, Re = (e, n, o, t, i = !1, s) => { e.addClass("ul-video-player"); const l = new (a.videojs.getComponent("Component"))(e); l.addClass("ul-control-panel"), e.progressBar = l.addChild("ProgressControl"), o && e.src(o), e.audioPlayerPlaceholder = new (a.videojs.getComponent("Component"))(e), e.audioPlayerPlaceholder.addClass("ul-audio-recorder-placeholder"); const v = o && o.src ? Xe(o.src) : null; !o || !i && v ? (e.audioPlayerPlaceholder.hide(), a.document.getElementById(`${e.id()}_html5_api`).style.height = "100%", v && e.poster(v)) : (e.children()[0].classList.add("vjs-hidden"), a.document.getElementById(`${e.id()}_html5_api`).style.height = "0px"), e.on("play", () => { i || !o || v || Qe(e), s == null || s.play(); }), e.on("pause", () => { s == null || s.pause(); }), e.on("seeked", () => { s == null || s.currentTime(e.currentTime()); }), e.on("ratechange", () => { s == null || s.playbackRate(e.playbackRate()); }), e.addChild(e.audioPlayerPlaceholder, {}, 1), l.addChild(n), e.addChild(l), t && t(e); }, Ke = (e, n, o, t, i, s, l, v = !1) => { fe = Date.now(); const r = oe(n, { controls: !1, bigPlayButton: !1, fluid: !1, width: 1280, height: 720, playsinline: !0, plugins: { record: { audio: !0, video: { mandatory: { minWidth: 1280, minHeight: 720 } }, frameWidth: 1280, frameHeight: 720, maxLength: 600, autoMuteDevice: !0 } } }); if (!r) return; r.payload = o; const { surveyId: c, questionId: h, responseGroupUid: I, visitorId: g, envId: T } = o; let f; const L = (p) => { const C = re, m = re + "-audio-only"; we(r.uploadProgressLabel, "none"), V && V.startTime >= fe && V.abort(); const E = a.document.getElementById("ul-camera-button"); p ? (r.children()[0].classList.add("vjs-hidden"), b.removeClass(C), b.addClass(m), E.innerHTML = P.TurnOnCamera, r.audioPlayerPlaceholder.removeClass("vjs-hidden"), f == null || f.getTracks().forEach((y) => { y.stop(); }), window.navigator.mediaDevices.getUserMedia({ video: !0, audio: !0 }).then((y) => { f = y, y.getVideoTracks().forEach((U) => { U.enabled = !1; }), r.record().onDeviceReady(y); }).catch(r.record().onDeviceError.bind(r.record()))) : (f == null || f.getVideoTracks().forEach((y) => { y.enabled = !0; }), r.children()[0].classList.remove("vjs-hidden"), r.record().getDevice(), b.removeClass(m), b.addClass(C), E.innerHTML = P.TurnOffCamera, r.audioPlayerPlaceholder.addClass("vjs-hidden")); }, d = new (a.videojs.getComponent("Button"))(r, { clickHandler: () => { d.hasClass(D) || (z({ event: "Video Delete Button Clicked", apiBase: t, headers: l, visitorId: g, envId: T, metadata: { questionId: h, responseGroupUid: I, surveyId: c } }), L(r.cameraOff), i(x.DELETE, {}), b.removeClass(D), d.addClass(D)); } }); d.addClass("ul-video-recorder-delete-button"), d.el_.appendChild(ne(P.DeleteButton, "ul-delete-button")); const w = a.document.getElementById(n), j = () => { w.classList.contains("vjs-fullscreen") && r.cameraOff ? w.style.display = "table" : w.style.display = "flex"; }; j(); const b = new (a.videojs.getComponent("Button"))(r, { clickHandler: () => { r.record().isRecording() || (r.cameraOff = !r.cameraOff, z({ event: "Video Camera Button Clicked", apiBase: t, headers: l, visitorId: o.visitorId, envId: o.envId, metadata: { questionId: h, responseGroupUid: I, surveyId: c, cameraOff: r.cameraOff } }), L(r.cameraOff), !d.hasClass(D) && d.addClass(D), i(x.DELETE, {}), j()); } }); b.addClass(re), b.el_.appendChild(ne(P.TurnOffCamera, "ul-camera-button")); const k = new (a.videojs.getComponent("Button"))(r, { clickHandler: () => { const p = a.document.getElementById("ul-recorder-toggle"); if (r.record().isRecording()) r.record().stop(), p && (p.innerHTML = P.RecordButton), k.removeClass(ie), d.removeClass(D); else { const C = a.document.getElementById("ul-recording-countdown-screen"); if (C) C.remove(), p && (p.innerHTML = P.RecordButton), L(r.cameraOff), i(x.DELETE, {}), b.removeClass(D), d.addClass(D), k.removeClass(ie), O.show(); else { k.addClass(ie), O.hide(), b.addClass(D), d.addClass(D), p && (p.innerHTML = P.StopButton); const m = a.document.createElement("div"); m.id = "ul-recording-countdown-screen", w.insertBefore(m, w.children[1]), m.style.height = `${w.offsetHeight}px`, Pe(r, 3); } } } }); k.addClass("ul-video-recorder-toggle-button"), k.el_.appendChild(ne(P.RecordButton, "ul-recorder-toggle")); const M = a.document.createElement("p"); M.style.visibility = "hidden", M.className = "ul-upload-progress-label", e.appendChild(M), r.uploadProgressLabel = M; const Y = Le(r, [d, b, "PlayToggle", k, "FullscreenToggle"]), O = Y.children().find((p) => p.name_ === "FullscreenToggle"); O.hasClass("vjs-disabled") && O.hide(); const B = Y.children().find((p) => p.name_ === "PlayToggle"); B.hide(), d.addClass(D), Re(r, Y, s, !1, v), r.on("stopRecord", () => { k.hide(), B.show(), O.show(), d.removeClass(D); }), r.on("deviceReady", () => { k.show(), B.hide(), d.addClass(D); }), ((p, C, m, E, y) => { const { surveyId: U, responseGroupUid: q, visitorId: R, envId: H } = p.payload; p.on("deviceError", function() { console.warn("device error: ", p.deviceErrorCode), p.deviceErrorCode.message === "Permission denied" ? (p.deviceButton.addClass("permission-denied"), m && m(x.ERROR, { type: x.PERMISSION_DENIED }), z({ event: "Video Permission Denied", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { questionId: se(p, te), responseGroupUid: q, surveyId: U } })) : (m && m(x.ERROR, { type: x.OTHER }), N(new Error(p.deviceErrorCode.message), "recorderDeviceError", C, y, R, H)); }), p.on("error", function(Z, F) { N(F || p.error(), "recorderError", C, y, R, H); }), p.on("startRecord", function(Z, F) { E(p.uploadProgressLabel, "none"), z({ event: "Video Record Start", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { questionId: se(p, te), responseGroupUid: q, surveyId: U } }); }), p.on("finishRecord", async function() { E(p.uploadProgressLabel, "start", 0); const Z = se(p, te); if (!U) { const S = "internal error: missing fields in payload"; return m && m(x.ERROR, { type: x.OTHER }), N(new Error(S), "finishRecord", C, y, R, H), null; } p.record().stopDevice(); const F = p.cameraOff ? x.MEDIA_TYPE_AUDIO : x.MEDIA_TYPE_VIDEO, A = Fe(); z({ event: "Video Record Finish", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: U, mediaType: F } }); const Q = { surveyId: U, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), mediaType: F, mediaRecordingUid: A }; Z && (Q.questionId = Z), q && (Q.responseGroupUid = q), R && (Q.visitorId = R); const X = await (async () => { const S = await fetch(`${C}/2/environments/integrations/upload`, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(Q) }); if (S.ok) { const pe = await S.json(); return m && m(x.UPLOAD_STARTED, { [x.UPLOAD_ID]: pe.upload.id, [x.MEDIA_TYPE]: F, [x.MEDIA_RECORDING_UID]: A }), pe.upload.url; } return m && m(x.ERROR, { type: x.OTHER, response: S }), N(new Error("failed to get upload response with url"), "finishRecord", C, y, R, H), null; })(); X && (V = a.document.defaultView.UpChunk.createUpload({ endpoint: X, file: new a.document.defaultView.File([p.recordedData], `recording ${F} ${Date.now()}`), chunkSize: 5120 }), V.startTime = Date.now(), z({ event: "Video Upload Start", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: U, mediaType: F, url: X } }), V.on("error", (S) => { E(p.uploadProgressLabel, "none"), m && m(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: A }), N(S, "finishRecord", C, y, R, H); }), V.on("progress", (S) => { m && m(x.UPLOAD_PROGRESS, { [x.MEDIA_RECORDING_UID]: A, [x.UPLOAD_PROGRESS_PCT]: S.detail }), E(p.uploadProgressLabel, "progress", S.detail); }), V.on("success", () => { E(p.uploadProgressLabel, "success"), m && m(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: A }), z({ event: "Video Upload Success", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: U, mediaType: F, url: X, elapsedMs: V.startTime && Date.now() - V.startTime } }); })); }); })(r, t, i, we, l); const W = [{ name: "microphone" }]; !r.cameraOff && W.push({ name: "camera" }), Promise.all(W.map((p) => { var C; return (C = navigator == null ? void 0 : navigator.permissions) == null ? void 0 : C.query(p); })).then((p) => { p.reduce((C, m) => C & m.state === "granted", !0) && r && (r.deviceButton && r.deviceButton.hide(), r.record().getDevice()); }).catch((p) => { }); }, Pe = (e, n = 3) => { const o = a.document.getElementById("ul-recording-countdown-screen"); o && n === 0 ? (o.remove(), e.record().start()) : o && (o.innerHTML = `<span class='ul-countdown-text'>Recording in... ${n}</span>`, setTimeout(() => { Pe(e, n - 1); }, 1e3)); }, _e = (e) => { const n = a.document.createElement("div"); return n.className = "ul-video-container", n.appendChild(((o) => { const t = a.document.createElement("div"); return t.className = "ul-video-player-loading", t.id = ce(o), ["first", "second", "third", "fourth"].map((i) => { const s = a.document.createElement("div"); s.className = i, t.appendChild(s); }), t; })(e)), n; }, ae = (e, n) => { const o = a.document.createElement("video"); o.id = e, o.className = "video-js vjs-default-skin ul-video-player-video"; const t = a.document.createElement("p"); t.className = "vjs-no-js", t.innerHTML = "To view this video please enable JavaScript, and consider upgrading to a web b