pollcatch 2.1.10 → 2.1.12
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/package.json +1 -1
- package/pc.js +155 -129
package/package.json
CHANGED
package/pc.js
CHANGED
|
@@ -291,10 +291,10 @@ const Re = (e, t) => {
|
|
|
291
291
|
let s, i = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = Z;
|
|
292
292
|
for (let n = 0; n < o; n++) {
|
|
293
293
|
const l = e[n];
|
|
294
|
-
let u, c, p = -1,
|
|
295
|
-
for (;
|
|
296
|
-
const
|
|
297
|
-
i += a === Z ? l + Ne : p >= 0 ? (r.push(u), l.slice(0, p) + ne + l.slice(p) + P +
|
|
294
|
+
let u, c, p = -1, w = 0;
|
|
295
|
+
for (; w < l.length && (a.lastIndex = w, c = a.exec(l), c !== null); ) w = a.lastIndex, a === Z ? c[1] === "!--" ? a = Dt : c[1] !== void 0 ? a = Vt : c[2] !== void 0 ? (ce.test(c[2]) && (s = RegExp("</" + c[2], "g")), a = N) : c[3] !== void 0 && (a = N) : a === N ? c[0] === ">" ? (a = s ?? Z, p = -1) : c[1] === void 0 ? p = -2 : (p = a.lastIndex - c[2].length, u = c[1], a = c[3] === void 0 ? N : c[3] === '"' ? Ht : qt) : a === Ht || a === qt ? a = N : a === Dt || a === Vt ? a = Z : (a = N, s = void 0);
|
|
296
|
+
const v = a === N && e[n + 1].startsWith("/>") ? " " : "";
|
|
297
|
+
i += a === Z ? l + Ne : p >= 0 ? (r.push(u), l.slice(0, p) + ne + l.slice(p) + P + v) : l + P + (p === -2 ? n : v);
|
|
298
298
|
}
|
|
299
299
|
return [de(e, i + (e[o] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
|
|
300
300
|
};
|
|
@@ -311,15 +311,15 @@ let kt = class pe {
|
|
|
311
311
|
for (; (s = M.nextNode()) !== null && l.length < n; ) {
|
|
312
312
|
if (s.nodeType === 1) {
|
|
313
313
|
if (s.hasAttributes()) for (const p of s.getAttributeNames()) if (p.endsWith(ne)) {
|
|
314
|
-
const
|
|
315
|
-
l.push({ type: 1, index: i, name: E[2], strings:
|
|
314
|
+
const w = c[a++], v = s.getAttribute(p).split(P), E = /([.?@])?(.*)/.exec(w);
|
|
315
|
+
l.push({ type: 1, index: i, name: E[2], strings: v, ctor: E[1] === "." ? je : E[1] === "?" ? Be : E[1] === "@" ? De : ct }), s.removeAttribute(p);
|
|
316
316
|
} else p.startsWith(P) && (l.push({ type: 6, index: i }), s.removeAttribute(p));
|
|
317
317
|
if (ce.test(s.tagName)) {
|
|
318
|
-
const p = s.textContent.split(P),
|
|
319
|
-
if (
|
|
318
|
+
const p = s.textContent.split(P), w = p.length - 1;
|
|
319
|
+
if (w > 0) {
|
|
320
320
|
s.textContent = nt ? nt.emptyScript : "";
|
|
321
|
-
for (let
|
|
322
|
-
s.append(p[
|
|
321
|
+
for (let v = 0; v < w; v++) s.append(p[v], X()), M.nextNode(), l.push({ type: 2, index: ++i });
|
|
322
|
+
s.append(p[w], X());
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
} else if (s.nodeType === 8) if (s.data === le) l.push({ type: 2, index: i });
|
|
@@ -595,11 +595,11 @@ function f(e) {
|
|
|
595
595
|
function Ot(e) {
|
|
596
596
|
return f({ ...e, state: !0, attribute: !1 });
|
|
597
597
|
}
|
|
598
|
-
var
|
|
598
|
+
var $ = /* @__PURE__ */ ((e) => (e.reaction = "reaction", e.stars = "stars", e.poll = "poll", e.text = "text", e.nps = "nps", e))($ || {});
|
|
599
599
|
const Ye = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='%23434343'%3e%3cpath%20d='M640-160v-280h160v280H640Zm-240%200v-640h160v640H400Zm-240%200v-440h160v440H160Z'/%3e%3c/svg%3e", Ze = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='%23434343'%3e%3cpath%20d='M160-160v-440h160v440H160Zm240%200v-400l160%20160v240H400Zm160-354L400-674v-126h160v286Zm240%20240L640-434v-6h160v166Zm-9%20219L55-791l57-57%20736%20736-57%2057Z'/%3e%3c/svg%3e", Ge = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='currentColor'%3e%3cpath%20d='M200-200h57l391-391-57-57-391%20391v57Zm-80%2080v-170l528-527q12-11%2026.5-17t30.5-6q16%200%2031%206t26%2018l55%2056q12%2011%2017.5%2026t5.5%2030q0%2016-5.5%2030.5T817-647L290-120H120Zm640-584-56-56%2056%2056Zm-141%2085-28-29%2057%2057-29-28Z'/%3e%3c/svg%3e", Ke = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='16'%20height='16'%20fill='%23666666'%20class='bi%20bi-x'%20viewBox='0%200%2016%2016'%3e%3cpath%20d='M4.646%204.646a.5.5%200%200%201%20.708%200L8%207.293l2.646-2.647a.5.5%200%200%201%20.708.708L8.707%208l2.647%202.646a.5.5%200%200%201-.708.708L8%208.707l-2.646%202.647a.5.5%200%200%201-.708-.708L7.293%208%204.646%205.354a.5.5%200%200%201%200-.708'/%3e%3c/svg%3e";
|
|
600
600
|
var We = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
601
601
|
return typeof e == "string" ? e.length > 0 : typeof e == "number";
|
|
602
|
-
},
|
|
602
|
+
}, x = function(e, t, o) {
|
|
603
603
|
return t === void 0 && (t = 0), o === void 0 && (o = Math.pow(10, t)), Math.round(o * e) / o + 0;
|
|
604
604
|
}, S = function(e, t, o) {
|
|
605
605
|
return t === void 0 && (t = 0), o === void 0 && (o = 1), e > o ? o : e > t ? e : t;
|
|
@@ -608,7 +608,7 @@ var We = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
608
608
|
}, Yt = function(e) {
|
|
609
609
|
return { r: S(e.r, 0, 255), g: S(e.g, 0, 255), b: S(e.b, 0, 255), a: S(e.a) };
|
|
610
610
|
}, yt = function(e) {
|
|
611
|
-
return { r:
|
|
611
|
+
return { r: x(e.r), g: x(e.g), b: x(e.b), a: x(e.a, 3) };
|
|
612
612
|
}, Je = /^#([0-9a-f]{3,8})$/i, rt = function(e) {
|
|
613
613
|
var t = e.toString(16);
|
|
614
614
|
return t.length < 2 ? "0" + t : t;
|
|
@@ -623,7 +623,7 @@ var We = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
623
623
|
}, Zt = function(e) {
|
|
624
624
|
return { h: ue(e.h), s: S(e.s, 0, 100), l: S(e.l, 0, 100), a: S(e.a) };
|
|
625
625
|
}, Gt = function(e) {
|
|
626
|
-
return { h:
|
|
626
|
+
return { h: x(e.h), s: x(e.s), l: x(e.l), a: x(e.a, 3) };
|
|
627
627
|
}, Kt = function(e) {
|
|
628
628
|
return fe((o = (t = e).s, { h: t.h, s: (o *= ((r = t.l) < 50 ? r : 100 - r) / 100) > 0 ? 2 * o / (r + o) * 100 : 0, v: r + o, a: t.a }));
|
|
629
629
|
var t, o, r;
|
|
@@ -632,7 +632,7 @@ var We = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
632
632
|
var t, o, r, s;
|
|
633
633
|
}, Xe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Qe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, to = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, eo = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Wt = { string: [[function(e) {
|
|
634
634
|
var t = Je.exec(e);
|
|
635
|
-
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ?
|
|
635
|
+
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? x(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? x(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
636
636
|
}, "hex"], [function(e) {
|
|
637
637
|
var t = to.exec(e) || eo.exec(e);
|
|
638
638
|
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Yt({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
|
|
@@ -679,13 +679,13 @@ var We = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
679
679
|
return e.prototype.isValid = function() {
|
|
680
680
|
return this.parsed !== null;
|
|
681
681
|
}, e.prototype.brightness = function() {
|
|
682
|
-
return
|
|
682
|
+
return x($t(this.rgba), 2);
|
|
683
683
|
}, e.prototype.isDark = function() {
|
|
684
684
|
return $t(this.rgba) < 0.5;
|
|
685
685
|
}, e.prototype.isLight = function() {
|
|
686
686
|
return $t(this.rgba) >= 0.5;
|
|
687
687
|
}, e.prototype.toHex = function() {
|
|
688
|
-
return t = yt(this.rgba), o = t.r, r = t.g, s = t.b, a = (i = t.a) < 1 ? rt(
|
|
688
|
+
return t = yt(this.rgba), o = t.r, r = t.g, s = t.b, a = (i = t.a) < 1 ? rt(x(255 * i)) : "", "#" + rt(o) + rt(r) + rt(s) + a;
|
|
689
689
|
var t, o, r, s, i, a;
|
|
690
690
|
}, e.prototype.toRgb = function() {
|
|
691
691
|
return yt(this.rgba);
|
|
@@ -698,7 +698,7 @@ var We = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
698
698
|
return t = Gt(J(this.rgba)), o = t.h, r = t.s, s = t.l, (i = t.a) < 1 ? "hsla(" + o + ", " + r + "%, " + s + "%, " + i + ")" : "hsl(" + o + ", " + r + "%, " + s + "%)";
|
|
699
699
|
var t, o, r, s, i;
|
|
700
700
|
}, e.prototype.toHsv = function() {
|
|
701
|
-
return t = he(this.rgba), { h:
|
|
701
|
+
return t = he(this.rgba), { h: x(t.h), s: x(t.s), v: x(t.v), a: x(t.a, 3) };
|
|
702
702
|
var t;
|
|
703
703
|
}, e.prototype.invert = function() {
|
|
704
704
|
return C({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
|
|
@@ -716,11 +716,11 @@ var We = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
716
716
|
}, e.prototype.rotate = function(t) {
|
|
717
717
|
return t === void 0 && (t = 15), this.hue(this.hue() + t);
|
|
718
718
|
}, e.prototype.alpha = function(t) {
|
|
719
|
-
return typeof t == "number" ? C({ r: (o = this.rgba).r, g: o.g, b: o.b, a: t }) :
|
|
719
|
+
return typeof t == "number" ? C({ r: (o = this.rgba).r, g: o.g, b: o.b, a: t }) : x(this.rgba.a, 3);
|
|
720
720
|
var o;
|
|
721
721
|
}, e.prototype.hue = function(t) {
|
|
722
722
|
var o = J(this.rgba);
|
|
723
|
-
return typeof t == "number" ? C({ h: t, s: o.s, l: o.l, a: o.a }) :
|
|
723
|
+
return typeof t == "number" ? C({ h: t, s: o.s, l: o.l, a: o.a }) : x(o.h);
|
|
724
724
|
}, e.prototype.isEqual = function(t) {
|
|
725
725
|
return this.toHex() === C(t).toHex();
|
|
726
726
|
}, e;
|
|
@@ -797,8 +797,8 @@ function ao(e, t = {}) {
|
|
|
797
797
|
l = a, u = c;
|
|
798
798
|
for (const p of n) {
|
|
799
799
|
if (p === a) continue;
|
|
800
|
-
const
|
|
801
|
-
|
|
800
|
+
const w = St(e, p);
|
|
801
|
+
w > u && (u = w, l = p);
|
|
802
802
|
}
|
|
803
803
|
m.warn(
|
|
804
804
|
`No color option met the minimum contrast ratio of ${r}:1 against ${e}. Using ${l} with contrast ratio ${u.toFixed(2)}:1 instead.`
|
|
@@ -909,7 +909,13 @@ function fo(e) {
|
|
|
909
909
|
let t = e;
|
|
910
910
|
return t = t.replace(/@import[^;]+;/gi, "").replace(/expression\s*\([^)]*\)/gi, "").replace(/javascript:\s*[^"'\s;]*/gi, "").replace(/url\s*\(\s*["']?data:(?!image\/[^;]+;base64,)[^"')]*["']?\s*\)/gi, "").replace(/-moz-binding\s*:[^;]+;/gi, "").replace(/behavior\s*:[^;]+;/gi, ""), t;
|
|
911
911
|
}
|
|
912
|
-
|
|
912
|
+
function mo(e) {
|
|
913
|
+
return typeof e != "string" || !e.trim() ? "" : e.replace(
|
|
914
|
+
/([^{}:;]+):\s*([^;{}!]+)(\s*!important)?\s*(;|})/gi,
|
|
915
|
+
(t, o, r, s, i) => s ? t : `${o}: ${r.trim()} !important${i}`
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
const ee = "https://jpxwfjorwcsrqraorpbj.supabase.co/functions/v1/data", bo = "pc_session_id", go = 24 * 60 * 60 * 1e3;
|
|
913
919
|
function oe() {
|
|
914
920
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : (m.warn("crypto.randomUUID not available, using fallback UUID generator"), "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
915
921
|
const t = Math.random() * 16 | 0;
|
|
@@ -940,7 +946,7 @@ function ge(e, t) {
|
|
|
940
946
|
return m.warn(`Failed to set item in localStorage: ${e}`, o), !1;
|
|
941
947
|
}
|
|
942
948
|
}
|
|
943
|
-
async function
|
|
949
|
+
async function vo() {
|
|
944
950
|
if (typeof window < "u") {
|
|
945
951
|
if (window.pcProject !== void 0)
|
|
946
952
|
return m.debug("Found project key in global variable"), window.pcProject;
|
|
@@ -954,7 +960,7 @@ async function go() {
|
|
|
954
960
|
m.warn("No project key found in global variable or script tags");
|
|
955
961
|
}
|
|
956
962
|
async function re() {
|
|
957
|
-
const e =
|
|
963
|
+
const e = bo, t = go;
|
|
958
964
|
if (Tt()) {
|
|
959
965
|
const o = be(e);
|
|
960
966
|
if (o && o.id && o.timestamp && Date.now() - o.timestamp < t)
|
|
@@ -996,7 +1002,7 @@ function O() {
|
|
|
996
1002
|
updated: (/* @__PURE__ */ new Date()).toISOString()
|
|
997
1003
|
};
|
|
998
1004
|
}
|
|
999
|
-
function
|
|
1005
|
+
function yo(e) {
|
|
1000
1006
|
if (!Tt())
|
|
1001
1007
|
return O();
|
|
1002
1008
|
try {
|
|
@@ -1006,7 +1012,7 @@ function vo(e) {
|
|
|
1006
1012
|
return m.warn("Failed to load localStats from localStorage", t), O();
|
|
1007
1013
|
}
|
|
1008
1014
|
}
|
|
1009
|
-
function
|
|
1015
|
+
function wo(e, t) {
|
|
1010
1016
|
if (!Tt())
|
|
1011
1017
|
return !1;
|
|
1012
1018
|
try {
|
|
@@ -1015,7 +1021,7 @@ function yo(e, t) {
|
|
|
1015
1021
|
return m.warn("Failed to save localStats to localStorage", o), !1;
|
|
1016
1022
|
}
|
|
1017
1023
|
}
|
|
1018
|
-
function
|
|
1024
|
+
function $o(e, t) {
|
|
1019
1025
|
const o = {
|
|
1020
1026
|
count: Math.max(0, e.count - t.count),
|
|
1021
1027
|
sum: (e.sum || 0) - (t.sum || 0),
|
|
@@ -1030,7 +1036,7 @@ function wo(e, t) {
|
|
|
1030
1036
|
o.breakdown[r] && (o.breakdown[r] = Math.max(0, o.breakdown[r] - s), o.breakdown[r] === 0 && delete o.breakdown[r]);
|
|
1031
1037
|
return o.nps = lt((o == null ? void 0 : o.breakdown) || {}), o;
|
|
1032
1038
|
}
|
|
1033
|
-
function
|
|
1039
|
+
function xo(e, t) {
|
|
1034
1040
|
if (!e.count && !t.count)
|
|
1035
1041
|
return O();
|
|
1036
1042
|
if (!e.count)
|
|
@@ -1068,7 +1074,7 @@ function dt(e) {
|
|
|
1068
1074
|
return !1;
|
|
1069
1075
|
}
|
|
1070
1076
|
}
|
|
1071
|
-
function
|
|
1077
|
+
function So(e) {
|
|
1072
1078
|
if (!e || typeof e != "string")
|
|
1073
1079
|
return [];
|
|
1074
1080
|
const t = e.trim();
|
|
@@ -1083,24 +1089,24 @@ function xo(e) {
|
|
|
1083
1089
|
}
|
|
1084
1090
|
return t.split(",").map((o) => o.trim()).filter((o) => o !== "");
|
|
1085
1091
|
}
|
|
1086
|
-
function
|
|
1092
|
+
function Co(e, t) {
|
|
1087
1093
|
const o = /{([^{}]+)}/g;
|
|
1088
1094
|
return e.replace(o, (r, s) => {
|
|
1089
1095
|
const i = s.trim(), a = t[i];
|
|
1090
1096
|
return a !== void 0 ? String(a) : r;
|
|
1091
1097
|
});
|
|
1092
1098
|
}
|
|
1093
|
-
function
|
|
1099
|
+
function ko(e, t) {
|
|
1094
1100
|
let o = 2166136261;
|
|
1095
1101
|
const r = e + ":" + t;
|
|
1096
1102
|
for (let s = 0; s < r.length; s++)
|
|
1097
1103
|
o ^= r.charCodeAt(s), o += (o << 1) + (o << 4) + (o << 7) + (o << 8) + (o << 24);
|
|
1098
1104
|
return (o >>> 0).toString(16).padStart(8, "0");
|
|
1099
1105
|
}
|
|
1100
|
-
function
|
|
1106
|
+
function Ao(e, t = 50) {
|
|
1101
1107
|
return e.length <= t ? e : e.substring(0, t).trim() + "...";
|
|
1102
1108
|
}
|
|
1103
|
-
class
|
|
1109
|
+
class _o {
|
|
1104
1110
|
constructor(t) {
|
|
1105
1111
|
this.stats = O(), this.localStats = O(), this.isLoading = !0, this.isSubmitting = !1, (this.host = t).addController(this);
|
|
1106
1112
|
}
|
|
@@ -1108,7 +1114,7 @@ class Ao {
|
|
|
1108
1114
|
this.loadStats();
|
|
1109
1115
|
}
|
|
1110
1116
|
async getProjectId() {
|
|
1111
|
-
return this.host.project || await
|
|
1117
|
+
return this.host.project || await vo() || "public";
|
|
1112
1118
|
}
|
|
1113
1119
|
async getLocalStatsKey() {
|
|
1114
1120
|
const t = this.host, o = await re(), r = await this.getProjectId(), s = t.name || "unnamed";
|
|
@@ -1131,15 +1137,15 @@ class Ao {
|
|
|
1131
1137
|
const o = await this.getProjectId(), r = t.name, s = t.type;
|
|
1132
1138
|
let i;
|
|
1133
1139
|
if (t.dataFunc && typeof window < "u") {
|
|
1134
|
-
const
|
|
1135
|
-
let
|
|
1136
|
-
for (const E of
|
|
1137
|
-
if (
|
|
1138
|
-
i =
|
|
1140
|
+
const w = t.dataFunc.replace(/^window\./, "").split(".");
|
|
1141
|
+
let v = window;
|
|
1142
|
+
for (const E of w)
|
|
1143
|
+
if (v = v == null ? void 0 : v[E], v === void 0) break;
|
|
1144
|
+
i = v;
|
|
1139
1145
|
}
|
|
1140
1146
|
let a, n;
|
|
1141
1147
|
if (i && typeof i == "function") {
|
|
1142
|
-
const p =
|
|
1148
|
+
const p = this.getOptionsForDataFunc(t);
|
|
1143
1149
|
if (m.debug(`Using data function for: ${r}`, {
|
|
1144
1150
|
dataFuncName: t.dataFunc,
|
|
1145
1151
|
projectKey: o,
|
|
@@ -1154,12 +1160,12 @@ class Ao {
|
|
|
1154
1160
|
const p = t.dataEndpoint || ee;
|
|
1155
1161
|
if (!r)
|
|
1156
1162
|
throw new Error("Name parameter is required");
|
|
1157
|
-
const
|
|
1163
|
+
const w = `${p}/${encodeURIComponent(o)}/${encodeURIComponent(r)}`;
|
|
1158
1164
|
m.debug(`Fetching stats for: ${r}`, { endpoint: p, projectKey: o });
|
|
1159
|
-
const
|
|
1160
|
-
if (!
|
|
1161
|
-
throw new Error(`API request failed with status: ${
|
|
1162
|
-
if (a = await
|
|
1165
|
+
const v = await fetch(w);
|
|
1166
|
+
if (!v.ok)
|
|
1167
|
+
throw new Error(`API request failed with status: ${v.status}`);
|
|
1168
|
+
if (a = await v.json(), !a.success)
|
|
1163
1169
|
throw m.error("Backend returned unsuccessful response", a), new Error("Backend returned unsuccessful response");
|
|
1164
1170
|
n = a.data || {};
|
|
1165
1171
|
}
|
|
@@ -1168,7 +1174,7 @@ class Ao {
|
|
|
1168
1174
|
sum: n.sum,
|
|
1169
1175
|
avg: l,
|
|
1170
1176
|
pct: u,
|
|
1171
|
-
nps: s ===
|
|
1177
|
+
nps: s === $.nps ? lt((n == null ? void 0 : n.breakdown) || {}) : 0,
|
|
1172
1178
|
breakdown: n.breakdown ?? {},
|
|
1173
1179
|
updated: n.updated_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
1174
1180
|
};
|
|
@@ -1179,13 +1185,33 @@ class Ao {
|
|
|
1179
1185
|
this.isLoading = !1, this.host.requestUpdate();
|
|
1180
1186
|
}
|
|
1181
1187
|
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Gets the options array for the data function based on widget type.
|
|
1190
|
+
* - For poll/reaction: uses the options from pcBase.options
|
|
1191
|
+
* - For stars: generates ['1', '2', ..., numStars]
|
|
1192
|
+
* - For NPS: generates ['0', '1', '2', ..., '10']
|
|
1193
|
+
*/
|
|
1194
|
+
getOptionsForDataFunc(t) {
|
|
1195
|
+
switch (t.type) {
|
|
1196
|
+
case $.stars: {
|
|
1197
|
+
const r = t.numStars || 5;
|
|
1198
|
+
return Array.from({ length: r }, (s, i) => String(i + 1));
|
|
1199
|
+
}
|
|
1200
|
+
case $.nps:
|
|
1201
|
+
return Array.from({ length: 11 }, (r, s) => String(s));
|
|
1202
|
+
case $.poll:
|
|
1203
|
+
case $.reaction:
|
|
1204
|
+
default:
|
|
1205
|
+
return t.options.map((r) => r.value);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1182
1208
|
/**
|
|
1183
1209
|
* Loads the local stats from localStorage
|
|
1184
1210
|
*/
|
|
1185
1211
|
async loadLocalStats() {
|
|
1186
1212
|
const t = await this.getLocalStatsKey();
|
|
1187
1213
|
try {
|
|
1188
|
-
const o =
|
|
1214
|
+
const o = yo(t);
|
|
1189
1215
|
m.debug("Loaded localStats from localStorage", o), this.localStats = o;
|
|
1190
1216
|
} catch (o) {
|
|
1191
1217
|
m.warn("Failed to generate localStorage key for localStats", o), this.localStats = O();
|
|
@@ -1198,7 +1224,7 @@ class Ao {
|
|
|
1198
1224
|
async persistLocalStats() {
|
|
1199
1225
|
try {
|
|
1200
1226
|
const t = await this.getLocalStatsKey();
|
|
1201
|
-
|
|
1227
|
+
wo(t, this.localStats) || m.warn("Failed to save localStats to localStorage");
|
|
1202
1228
|
} catch (t) {
|
|
1203
1229
|
m.warn("Failed to save localStats to localStorage", t);
|
|
1204
1230
|
}
|
|
@@ -1213,8 +1239,8 @@ class Ao {
|
|
|
1213
1239
|
*/
|
|
1214
1240
|
updateStats(t, o) {
|
|
1215
1241
|
const r = this.host;
|
|
1216
|
-
if (this.stats && (this.stats =
|
|
1217
|
-
count: t > 0 || r.type ===
|
|
1242
|
+
if (this.stats && (this.stats = $o(this.stats, this.localStats)), this.localStats = {
|
|
1243
|
+
count: t > 0 || r.type === $.nps ? 1 : 0,
|
|
1218
1244
|
// always 1 or 0
|
|
1219
1245
|
sum: t,
|
|
1220
1246
|
// e.g. number of stars, nps value
|
|
@@ -1228,7 +1254,7 @@ class Ao {
|
|
|
1228
1254
|
}, o && o.length > 0)
|
|
1229
1255
|
for (const s of o)
|
|
1230
1256
|
s && (this.localStats.breakdown[s] = 1);
|
|
1231
|
-
this.stats =
|
|
1257
|
+
this.stats = xo(this.stats, this.localStats), m.debug("Stats updated - remote: ", this.stats), m.debug("Stats updated - local: ", this.stats), this.persistLocalStats(), this.host.requestUpdate();
|
|
1232
1258
|
}
|
|
1233
1259
|
async markStatsAsSubmitted() {
|
|
1234
1260
|
this.localStats.submitted = (/* @__PURE__ */ new Date()).toISOString(), await this.persistLocalStats(), this.host.requestUpdate();
|
|
@@ -1248,7 +1274,7 @@ class Ao {
|
|
|
1248
1274
|
textValues: n,
|
|
1249
1275
|
metadata: t.metadata,
|
|
1250
1276
|
timestamp: o
|
|
1251
|
-
}, u =
|
|
1277
|
+
}, u = ko(JSON.stringify(l), o);
|
|
1252
1278
|
try {
|
|
1253
1279
|
await this.sendStats({ ...l, hash: u }), await this.markStatsAsSubmitted(), this.dispatchSubmitEvent(l);
|
|
1254
1280
|
} catch (c) {
|
|
@@ -1300,9 +1326,9 @@ class Ao {
|
|
|
1300
1326
|
sum: (o == null ? void 0 : o.sum) || 0,
|
|
1301
1327
|
avg: (o == null ? void 0 : o.avg) || 0,
|
|
1302
1328
|
pct: (o == null ? void 0 : o.pct) || 0,
|
|
1303
|
-
nps: r.type ===
|
|
1329
|
+
nps: r.type === $.nps ? lt((o == null ? void 0 : o.breakdown) || {}) : 0
|
|
1304
1330
|
};
|
|
1305
|
-
return m.debug("Stats data: ", this.stats),
|
|
1331
|
+
return m.debug("Stats data: ", this.stats), Co(t, s);
|
|
1306
1332
|
}
|
|
1307
1333
|
/**
|
|
1308
1334
|
* Checks if a value is selected in the local stats
|
|
@@ -1328,7 +1354,7 @@ class Ao {
|
|
|
1328
1354
|
toggleValueSelected(t, o) {
|
|
1329
1355
|
const r = Object.keys(this.localStats.breakdown || {}), s = r.includes(t), i = this.host;
|
|
1330
1356
|
let a = 1;
|
|
1331
|
-
if ((i.type ===
|
|
1357
|
+
if ((i.type === $.stars || i.type === $.nps) && (a = parseInt(t)), s)
|
|
1332
1358
|
if (o) {
|
|
1333
1359
|
const l = r.filter((u) => u !== t);
|
|
1334
1360
|
this.updateStats(l.length > 0 ? 1 : 0, l);
|
|
@@ -1389,7 +1415,7 @@ class Ao {
|
|
|
1389
1415
|
return ((t = this.localStats) == null ? void 0 : t.submitted) !== void 0 && this.hasLocalStats();
|
|
1390
1416
|
}
|
|
1391
1417
|
}
|
|
1392
|
-
class
|
|
1418
|
+
class Eo {
|
|
1393
1419
|
constructor(t, o) {
|
|
1394
1420
|
this.isEditing = !0, this.isChartVisible = !1, this.isStatsVisible = !1, this.isThankYouVisible = !1, this.isReactionPopoverVisible = !1, this.initialized = !1, this.handleClickOutside = (r) => {
|
|
1395
1421
|
r.target !== this.host && (this.toggleThankYouVisibility(!1), this.toggleReactionPopoverVisibility(!1));
|
|
@@ -1490,13 +1516,13 @@ function ye(e, t = {}) {
|
|
|
1490
1516
|
ariaHidden: !1
|
|
1491
1517
|
};
|
|
1492
1518
|
}
|
|
1493
|
-
function
|
|
1519
|
+
function Po(e, t = "polite") {
|
|
1494
1520
|
let o = document.getElementById("screen-reader-announcer");
|
|
1495
1521
|
o ? o.setAttribute("aria-live", t) : (o = document.createElement("div"), o.id = "screen-reader-announcer", o.setAttribute("aria-live", t), o.setAttribute("role", "status"), o.setAttribute("aria-atomic", "true"), o.style.position = "absolute", o.style.width = "1px", o.style.height = "1px", o.style.margin = "-1px", o.style.padding = "0", o.style.overflow = "hidden", o.style.clip = "rect(0, 0, 0, 0)", o.style.whiteSpace = "nowrap", o.style.border = "0", document.body.appendChild(o)), o.textContent = "", setTimeout(() => {
|
|
1496
1522
|
o.textContent = e;
|
|
1497
1523
|
}, 50);
|
|
1498
1524
|
}
|
|
1499
|
-
function
|
|
1525
|
+
function Oo(e, t) {
|
|
1500
1526
|
return `${e}: ${t}`;
|
|
1501
1527
|
}
|
|
1502
1528
|
/**
|
|
@@ -1526,7 +1552,7 @@ let xe = class {
|
|
|
1526
1552
|
* Copyright 2018 Google LLC
|
|
1527
1553
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1528
1554
|
*/
|
|
1529
|
-
const
|
|
1555
|
+
const y = $e(class extends xe {
|
|
1530
1556
|
constructor(e) {
|
|
1531
1557
|
var t;
|
|
1532
1558
|
if (super(e), e.type !== we.ATTRIBUTE || e.name !== "class" || ((t = e.strings) == null ? void 0 : t.length) > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
|
|
@@ -1550,10 +1576,10 @@ const w = $e(class extends xe {
|
|
|
1550
1576
|
return z;
|
|
1551
1577
|
}
|
|
1552
1578
|
});
|
|
1553
|
-
var
|
|
1579
|
+
var To = Object.defineProperty, g = (e, t, o, r) => {
|
|
1554
1580
|
for (var s = void 0, i = e.length - 1, a; i >= 0; i--)
|
|
1555
1581
|
(a = e[i]) && (s = a(t, o, s) || s);
|
|
1556
|
-
return s &&
|
|
1582
|
+
return s && To(t, o, s), s;
|
|
1557
1583
|
};
|
|
1558
1584
|
const st = {
|
|
1559
1585
|
mobile: "480px",
|
|
@@ -1561,7 +1587,7 @@ const st = {
|
|
|
1561
1587
|
desktop: "1024px"
|
|
1562
1588
|
}, Mt = class Mt extends j {
|
|
1563
1589
|
constructor() {
|
|
1564
|
-
super(...arguments), this.dataController = new
|
|
1590
|
+
super(...arguments), this.dataController = new _o(this), this.displayController = new Eo(this, this.dataController), this.hasEditButton = !0, this.showStats = "never", this.showChart = !1, this.initialized = !1, this.lockAnswer = !1, this.ariaLabel = null, this.minContrast = me.AA_NORMAL, this.options = [], this.project = "public", this.questionPosition = "top", this.statsText = "{count} votes", this.buttonText = "Submit", this.buttonRadius = "sm", this.multiple = !1, this.readOnly = !1, this.handleEditToggleKeyDown = (t) => {
|
|
1565
1591
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.handleEnterEditMode());
|
|
1566
1592
|
};
|
|
1567
1593
|
}
|
|
@@ -1637,7 +1663,7 @@ const st = {
|
|
|
1637
1663
|
`;
|
|
1638
1664
|
}
|
|
1639
1665
|
o += `}
|
|
1640
|
-
`, this.css && (o += fo(this.css)), t.textContent = o;
|
|
1666
|
+
`, this.css && (o += mo(fo(this.css))), t.textContent = o;
|
|
1641
1667
|
}
|
|
1642
1668
|
/**
|
|
1643
1669
|
* Update ARIA attributes for accessibility
|
|
@@ -1668,7 +1694,7 @@ const st = {
|
|
|
1668
1694
|
*/
|
|
1669
1695
|
announceSelectionChange(t, o, r) {
|
|
1670
1696
|
const s = `Poll for "${t}"`, i = r ? `${o.label} selected` : `${o.label} unselected`;
|
|
1671
|
-
|
|
1697
|
+
Po(Oo(s, i));
|
|
1672
1698
|
}
|
|
1673
1699
|
/** Common render methods */
|
|
1674
1700
|
renderLabel() {
|
|
@@ -1729,7 +1755,7 @@ const st = {
|
|
|
1729
1755
|
"pc-status": !0,
|
|
1730
1756
|
[`pc-flex-content-${k(this.statsPosition, this.statsAlign)}`]: !0
|
|
1731
1757
|
};
|
|
1732
|
-
return d`<div class="${
|
|
1758
|
+
return d`<div class="${y(o)}" data-testid="pc-status">
|
|
1733
1759
|
${this.renderStatsText()} ${this.renderChartToggle()} ${this.renderEditToggleIcon()}
|
|
1734
1760
|
</div>`;
|
|
1735
1761
|
}
|
|
@@ -1745,7 +1771,7 @@ const st = {
|
|
|
1745
1771
|
renderThankYouMessage() {
|
|
1746
1772
|
if (!this.displayController.shouldDisplayThankYouMsg())
|
|
1747
1773
|
return h;
|
|
1748
|
-
const t =
|
|
1774
|
+
const t = Ao(this.thankYouMsg || "");
|
|
1749
1775
|
return d`
|
|
1750
1776
|
<div class="pc-thank-you-overlay" data-testid="poll-thank-you-overlay">
|
|
1751
1777
|
<div class="pc-thank-you" data-testid="thank-you">
|
|
@@ -1955,7 +1981,7 @@ g([
|
|
|
1955
1981
|
g([
|
|
1956
1982
|
f({ type: Boolean, attribute: "read-only" })
|
|
1957
1983
|
], b.prototype, "readOnly");
|
|
1958
|
-
const
|
|
1984
|
+
const zo = F`
|
|
1959
1985
|
/* CSS variables inherit from parent - defaults are specified at usage sites */
|
|
1960
1986
|
|
|
1961
1987
|
.pc-body {
|
|
@@ -2610,14 +2636,14 @@ function It(e, t = {}) {
|
|
|
2610
2636
|
</div>
|
|
2611
2637
|
`;
|
|
2612
2638
|
}
|
|
2613
|
-
var
|
|
2614
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2639
|
+
var Io = Object.defineProperty, No = Object.getOwnPropertyDescriptor, Y = (e, t, o, r) => {
|
|
2640
|
+
for (var s = r > 1 ? void 0 : r ? No(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
2615
2641
|
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
2616
|
-
return r && s &&
|
|
2642
|
+
return r && s && Io(t, o, s), s;
|
|
2617
2643
|
};
|
|
2618
2644
|
let I = class extends b {
|
|
2619
2645
|
constructor() {
|
|
2620
|
-
super(), this.min = 0, this.max = 10, this.type =
|
|
2646
|
+
super(), this.min = 0, this.max = 10, this.type = $.nps, this.minLabel = "Not at all", this.maxLabel = "Extremely", this.minMaxPosition = "top", this.hoverValue = -1, this.handleNumberLeave = () => {
|
|
2621
2647
|
this.hoverValue = -1;
|
|
2622
2648
|
}, this.handleKeyDown = (e) => {
|
|
2623
2649
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.hoverValue >= 0 && this.handleNumberClick(this.hoverValue));
|
|
@@ -2640,7 +2666,7 @@ let I = class extends b {
|
|
|
2640
2666
|
<button
|
|
2641
2667
|
data-testid="nps-button-${s}"
|
|
2642
2668
|
?disabled=${!this.displayController.allowEdit()}
|
|
2643
|
-
class=${
|
|
2669
|
+
class=${y(a)}
|
|
2644
2670
|
@click="${() => this.handleNumberClick(s)}"
|
|
2645
2671
|
@mouseenter="${() => this.handleNumberHover(s)}"
|
|
2646
2672
|
@focus="${() => this.handleNumberHover(s)}"
|
|
@@ -2733,9 +2759,9 @@ let I = class extends b {
|
|
|
2733
2759
|
[`pc-flex-align-${k(this.statsPosition, this.statsAlign)}`]: !0
|
|
2734
2760
|
};
|
|
2735
2761
|
return d`
|
|
2736
|
-
<div class="pc-container ${
|
|
2762
|
+
<div class="pc-container ${y(e)}" data-testid="nps-container">
|
|
2737
2763
|
${this.renderLabelAtStart()}
|
|
2738
|
-
<div class="pc-body ${
|
|
2764
|
+
<div class="pc-body ${y(t)}" data-testid="nps-body">
|
|
2739
2765
|
${this.renderStatusAtStart()} ${this.renderContent()} ${this.renderStatusAtEnd()}
|
|
2740
2766
|
</div>
|
|
2741
2767
|
${this.renderLabelAtEnd()}
|
|
@@ -2743,7 +2769,7 @@ let I = class extends b {
|
|
|
2743
2769
|
`;
|
|
2744
2770
|
}
|
|
2745
2771
|
};
|
|
2746
|
-
I.styles = [...b.styles, pt,
|
|
2772
|
+
I.styles = [...b.styles, pt, zo];
|
|
2747
2773
|
Y([
|
|
2748
2774
|
f({ type: String, attribute: "min-label" })
|
|
2749
2775
|
], I.prototype, "minLabel", 2);
|
|
@@ -2762,7 +2788,7 @@ Y([
|
|
|
2762
2788
|
I = Y([
|
|
2763
2789
|
ot("pc-nps")
|
|
2764
2790
|
], I);
|
|
2765
|
-
const
|
|
2791
|
+
const Mo = F`
|
|
2766
2792
|
/* CSS variables inherit from parent - defaults are specified at usage sites */
|
|
2767
2793
|
|
|
2768
2794
|
.pc-container {
|
|
@@ -3019,21 +3045,21 @@ const No = F`
|
|
|
3019
3045
|
visibility: hidden;
|
|
3020
3046
|
}
|
|
3021
3047
|
`;
|
|
3022
|
-
var
|
|
3023
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
3048
|
+
var Lo = Object.defineProperty, Ro = Object.getOwnPropertyDescriptor, Nt = (e, t, o, r) => {
|
|
3049
|
+
for (var s = r > 1 ? void 0 : r ? Ro(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
3024
3050
|
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
3025
|
-
return r && s &&
|
|
3051
|
+
return r && s && Lo(t, o, s), s;
|
|
3026
3052
|
};
|
|
3027
3053
|
let tt = class extends b {
|
|
3028
3054
|
constructor() {
|
|
3029
|
-
super(), this.type =
|
|
3055
|
+
super(), this.type = $.poll, this.multiple = !1, this.compact = !1, this.hasEditButton = !0, this.statsText = "{count} votes", this.questionPosition = "top", this.statsPosition = "bottom", this.showStats = "after-vote";
|
|
3030
3056
|
}
|
|
3031
3057
|
renderStatus() {
|
|
3032
3058
|
const t = {
|
|
3033
3059
|
"pc-status": !0,
|
|
3034
3060
|
[`pc-flex-content-${k("bottom", this.statsAlign)}`]: !0
|
|
3035
3061
|
};
|
|
3036
|
-
return d`<div class="${
|
|
3062
|
+
return d`<div class="${y(t)}" data-testid="pc-status">
|
|
3037
3063
|
<span>${this.renderStatsText()} ${this.renderEditToggleIcon("stats-edit-button")}</span>
|
|
3038
3064
|
</div>`;
|
|
3039
3065
|
}
|
|
@@ -3048,7 +3074,7 @@ let tt = class extends b {
|
|
|
3048
3074
|
}, t = this.displayController.shouldDisableSubmitButton();
|
|
3049
3075
|
return d`
|
|
3050
3076
|
<button
|
|
3051
|
-
class="${
|
|
3077
|
+
class="${y(e)}"
|
|
3052
3078
|
data-testid="pc-submit-button"
|
|
3053
3079
|
@click="${this.handleSubmit}"
|
|
3054
3080
|
?disabled="${t}"
|
|
@@ -3129,7 +3155,7 @@ let tt = class extends b {
|
|
|
3129
3155
|
return d`
|
|
3130
3156
|
<button
|
|
3131
3157
|
data-testid="poll-option-i${t}"
|
|
3132
|
-
class="${
|
|
3158
|
+
class="${y(s)}"
|
|
3133
3159
|
@click="${() => this.handleClick(e)}"
|
|
3134
3160
|
?disabled="${r}"
|
|
3135
3161
|
id="${a}-option-${t}"
|
|
@@ -3156,7 +3182,7 @@ let tt = class extends b {
|
|
|
3156
3182
|
});
|
|
3157
3183
|
return d`
|
|
3158
3184
|
<div
|
|
3159
|
-
class="${
|
|
3185
|
+
class="${y({
|
|
3160
3186
|
"poll-container": !0
|
|
3161
3187
|
})}"
|
|
3162
3188
|
data-testid="poll-option-container"
|
|
@@ -3173,12 +3199,12 @@ let tt = class extends b {
|
|
|
3173
3199
|
renderBarChart() {
|
|
3174
3200
|
var l, u;
|
|
3175
3201
|
const e = ((l = this.dataController.stats) == null ? void 0 : l.breakdown) || {}, t = ((u = this.dataController.localStats) == null ? void 0 : u.breakdown) || {}, o = Object.values(e).reduce((c, p) => c + p, 0), r = this.options.map((c, p) => {
|
|
3176
|
-
const
|
|
3202
|
+
const w = e[c.value] || 0, v = o > 0 ? Math.round(w / o * 100) : 0, E = (t[c.value] || 0) > 0;
|
|
3177
3203
|
return {
|
|
3178
3204
|
option: c,
|
|
3179
3205
|
index: p,
|
|
3180
|
-
voteCount:
|
|
3181
|
-
percentage:
|
|
3206
|
+
voteCount: w,
|
|
3207
|
+
percentage: v,
|
|
3182
3208
|
isSelected: E
|
|
3183
3209
|
};
|
|
3184
3210
|
}), s = this.multiple ? _.GROUP : _.RADIOGROUP, i = this.question || this.name || "Options", a = B({
|
|
@@ -3187,7 +3213,7 @@ let tt = class extends b {
|
|
|
3187
3213
|
});
|
|
3188
3214
|
return d`
|
|
3189
3215
|
<div
|
|
3190
|
-
class="${
|
|
3216
|
+
class="${y({
|
|
3191
3217
|
"poll-container": !0
|
|
3192
3218
|
})}"
|
|
3193
3219
|
data-testid="poll-chart-container"
|
|
@@ -3203,7 +3229,7 @@ let tt = class extends b {
|
|
|
3203
3229
|
};
|
|
3204
3230
|
return d`
|
|
3205
3231
|
<div
|
|
3206
|
-
class="${
|
|
3232
|
+
class="${y(p)}"
|
|
3207
3233
|
data-testid="poll-chart-item-${c.index}"
|
|
3208
3234
|
role="listitem"
|
|
3209
3235
|
aria-label="${c.option.label}: ${c.percentage}% (${c.voteCount} votes)"
|
|
@@ -3274,12 +3300,12 @@ let tt = class extends b {
|
|
|
3274
3300
|
});
|
|
3275
3301
|
return d`
|
|
3276
3302
|
<div
|
|
3277
|
-
class="pc-container ${
|
|
3303
|
+
class="pc-container ${y(t)}"
|
|
3278
3304
|
data-testid="poll-container"
|
|
3279
3305
|
...=${s}
|
|
3280
3306
|
>
|
|
3281
3307
|
${this.renderLabelAtStart()}
|
|
3282
|
-
<div class="${
|
|
3308
|
+
<div class="${y(r)}" data-testid="poll-body">
|
|
3283
3309
|
${this.renderContent()} ${this.renderFooter()}
|
|
3284
3310
|
</div>
|
|
3285
3311
|
${this.renderLabelAtEnd()}
|
|
@@ -3287,7 +3313,7 @@ let tt = class extends b {
|
|
|
3287
3313
|
`;
|
|
3288
3314
|
}
|
|
3289
3315
|
};
|
|
3290
|
-
tt.styles = [...b.styles, pt,
|
|
3316
|
+
tt.styles = [...b.styles, pt, Mo];
|
|
3291
3317
|
Nt([
|
|
3292
3318
|
f({ type: Boolean })
|
|
3293
3319
|
], tt.prototype, "multiple", 2);
|
|
@@ -3297,7 +3323,7 @@ Nt([
|
|
|
3297
3323
|
tt = Nt([
|
|
3298
3324
|
ot("pc-poll")
|
|
3299
3325
|
], tt);
|
|
3300
|
-
const
|
|
3326
|
+
const Uo = F`
|
|
3301
3327
|
/* CSS variables inherit from parent - defaults are specified at usage sites */
|
|
3302
3328
|
|
|
3303
3329
|
.pc-section {
|
|
@@ -3379,7 +3405,7 @@ const Ro = F`
|
|
|
3379
3405
|
* Copyright 2018 Google LLC
|
|
3380
3406
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
3381
3407
|
*/
|
|
3382
|
-
const Se = "important",
|
|
3408
|
+
const Se = "important", jo = " !" + Se, Bo = $e(class extends xe {
|
|
3383
3409
|
constructor(e) {
|
|
3384
3410
|
var t;
|
|
3385
3411
|
if (super(e), e.type !== we.ATTRIBUTE || e.name !== "style" || ((t = e.strings) == null ? void 0 : t.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
|
|
@@ -3398,21 +3424,21 @@ const Se = "important", Uo = " !" + Se, jo = $e(class extends xe {
|
|
|
3398
3424
|
const s = t[r];
|
|
3399
3425
|
if (s != null) {
|
|
3400
3426
|
this.ft.add(r);
|
|
3401
|
-
const i = typeof s == "string" && s.endsWith(
|
|
3427
|
+
const i = typeof s == "string" && s.endsWith(jo);
|
|
3402
3428
|
r.includes("-") || i ? o.setProperty(r, i ? s.slice(0, -11) : s, i ? Se : "") : o[r] = s;
|
|
3403
3429
|
}
|
|
3404
3430
|
}
|
|
3405
3431
|
return z;
|
|
3406
3432
|
}
|
|
3407
3433
|
});
|
|
3408
|
-
var
|
|
3409
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
3434
|
+
var Do = Object.defineProperty, Vo = Object.getOwnPropertyDescriptor, ut = (e, t, o, r) => {
|
|
3435
|
+
for (var s = r > 1 ? void 0 : r ? Vo(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
3410
3436
|
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
3411
|
-
return r && s &&
|
|
3437
|
+
return r && s && Do(t, o, s), s;
|
|
3412
3438
|
};
|
|
3413
3439
|
let V = class extends b {
|
|
3414
3440
|
constructor() {
|
|
3415
|
-
super(), this.type =
|
|
3441
|
+
super(), this.type = $.stars, this.numStars = 5, this.hoverValue = -1, this.handleStarKeyDown = (e) => {
|
|
3416
3442
|
if (e.key === "Enter" || e.key === " ") {
|
|
3417
3443
|
e.preventDefault();
|
|
3418
3444
|
const t = e.target, o = parseInt(t.dataset.star || "0");
|
|
@@ -3446,8 +3472,8 @@ let V = class extends b {
|
|
|
3446
3472
|
<div class="pc-section" data-testid="pc-section">
|
|
3447
3473
|
<span
|
|
3448
3474
|
data-testid="stars-view-star-${n}"
|
|
3449
|
-
class=${
|
|
3450
|
-
style=${
|
|
3475
|
+
class=${y(c)}
|
|
3476
|
+
style=${Bo(p)}
|
|
3451
3477
|
role="${r ? "button" : "presentation"}"
|
|
3452
3478
|
tabindex="${r ? "0" : ""}"
|
|
3453
3479
|
aria-label="${r ? `Rate ${n} star${n > 1 ? "s" : ""}` : ""}"
|
|
@@ -3496,9 +3522,9 @@ let V = class extends b {
|
|
|
3496
3522
|
[`pc-flex-align-${o}`]: !0
|
|
3497
3523
|
};
|
|
3498
3524
|
return d`
|
|
3499
|
-
<div class="pc-container ${
|
|
3525
|
+
<div class="pc-container ${y(t)}" data-testid="pc-container">
|
|
3500
3526
|
${this.renderLabelAtStart()}
|
|
3501
|
-
<div class="${
|
|
3527
|
+
<div class="${y(r)}" data-testid="stars-body">
|
|
3502
3528
|
${this.renderStatusAtStart()} ${this.renderChart()} ${this.renderStars()}
|
|
3503
3529
|
${this.renderStatusAtEnd()}
|
|
3504
3530
|
</div>
|
|
@@ -3507,7 +3533,7 @@ let V = class extends b {
|
|
|
3507
3533
|
`;
|
|
3508
3534
|
}
|
|
3509
3535
|
};
|
|
3510
|
-
V.styles = [...b.styles, pt,
|
|
3536
|
+
V.styles = [...b.styles, pt, Uo];
|
|
3511
3537
|
ut([
|
|
3512
3538
|
f({ type: String })
|
|
3513
3539
|
], V.prototype, "icon", 2);
|
|
@@ -3520,7 +3546,7 @@ ut([
|
|
|
3520
3546
|
V = ut([
|
|
3521
3547
|
ot("pc-stars")
|
|
3522
3548
|
], V);
|
|
3523
|
-
const
|
|
3549
|
+
const qo = F`
|
|
3524
3550
|
/* Adjust stats text for reactions */
|
|
3525
3551
|
.pc-stats-text {
|
|
3526
3552
|
font-size: var(--pc-font-size-small, var(--default-font-size-small));
|
|
@@ -3864,15 +3890,15 @@ function Ce(e) {
|
|
|
3864
3890
|
isRemoteImage: o
|
|
3865
3891
|
};
|
|
3866
3892
|
}
|
|
3867
|
-
const
|
|
3868
|
-
var
|
|
3869
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
3893
|
+
const Ho = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='%23434343'%3e%3cpath%20d='M480-480Zm0%20400q-83%200-156-31.5T197-197q-54-54-85.5-127T80-480q0-83%2031.5-156T197-763q54-54%20127-85.5T480-880q43%200%2083%208.5t77%2024.5v90q-35-20-75.5-31.5T480-800q-133%200-226.5%2093.5T160-480q0%20133%2093.5%20226.5T480-160q133%200%20226.5-93.5T800-480q0-32-6.5-62T776-600h86q9%2029%2013.5%2058.5T880-480q0%2083-31.5%20156T763-197q-54%2054-127%2085.5T480-80Zm320-600v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80ZM620-520q25%200%2042.5-17.5T680-580q0-25-17.5-42.5T620-640q-25%200-42.5%2017.5T560-580q0%2025%2017.5%2042.5T620-520Zm-280%200q25%200%2042.5-17.5T400-580q0-25-17.5-42.5T340-640q-25%200-42.5%2017.5T280-580q0%2025%2017.5%2042.5T340-520Zm140%20260q68%200%20123.5-38.5T684-400H276q25%2063%2080.5%20101.5T480-260Z'/%3e%3c/svg%3e";
|
|
3894
|
+
var Fo = Object.defineProperty, Yo = Object.getOwnPropertyDescriptor, ht = (e, t, o, r) => {
|
|
3895
|
+
for (var s = r > 1 ? void 0 : r ? Yo(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
3870
3896
|
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
3871
|
-
return r && s &&
|
|
3897
|
+
return r && s && Fo(t, o, s), s;
|
|
3872
3898
|
};
|
|
3873
3899
|
let q = class extends b {
|
|
3874
3900
|
constructor() {
|
|
3875
|
-
super(), this.type =
|
|
3901
|
+
super(), this.type = $.reaction, this.showCounts = !1, this.compact = !1, this.popupPosition = "auto", this.hasEditButton = !1, this.statsText = "{count} votes", this.buttonRadius = "990px", this.muteColor = "#cccccc", this.questionPosition = "top", this.statsPosition = "right", this.popupPosition = "auto";
|
|
3876
3902
|
}
|
|
3877
3903
|
/**
|
|
3878
3904
|
* Get the display count for a specific reaction including local optimistic updates
|
|
@@ -3921,7 +3947,7 @@ let q = class extends b {
|
|
|
3921
3947
|
}, n = `${e.tooltip || e.value} reaction${o ? ", selected" : ""}${t ? `, ${r} votes` : ""}`;
|
|
3922
3948
|
return d`
|
|
3923
3949
|
<button
|
|
3924
|
-
class="${
|
|
3950
|
+
class="${y(a)}"
|
|
3925
3951
|
@click="${() => this.handleReactionClick(e)}"
|
|
3926
3952
|
?disabled="${s}"
|
|
3927
3953
|
aria-pressed="${o}"
|
|
@@ -3948,7 +3974,7 @@ let q = class extends b {
|
|
|
3948
3974
|
aria-expanded="${this.displayController.shouldShowReactionPopover()}"
|
|
3949
3975
|
aria-haspopup="true"
|
|
3950
3976
|
>
|
|
3951
|
-
<img src="${
|
|
3977
|
+
<img src="${Ho}" alt="" class="trigger-icon" />
|
|
3952
3978
|
</button>
|
|
3953
3979
|
`;
|
|
3954
3980
|
}
|
|
@@ -3963,7 +3989,7 @@ let q = class extends b {
|
|
|
3963
3989
|
bottom: this.popupPosition === "bottom" || this.popupPosition === "auto" && !this.shouldShowPopoverOnTop()
|
|
3964
3990
|
};
|
|
3965
3991
|
return d`
|
|
3966
|
-
<div class="${
|
|
3992
|
+
<div class="${y(e)}" role="menu">
|
|
3967
3993
|
<div class="popover-content">
|
|
3968
3994
|
${this.options.map((t) => {
|
|
3969
3995
|
const o = this.displayController.shouldDisableOption(t);
|
|
@@ -4010,7 +4036,7 @@ let q = class extends b {
|
|
|
4010
4036
|
(o) => this.dataController.isValueSelected(o.value)
|
|
4011
4037
|
);
|
|
4012
4038
|
return d`
|
|
4013
|
-
<div class="${
|
|
4039
|
+
<div class="${y(e)}">
|
|
4014
4040
|
${this.renderTriggerButton()}
|
|
4015
4041
|
${t.length > 0 ? d`
|
|
4016
4042
|
<div class="reaction-list">
|
|
@@ -4024,7 +4050,7 @@ let q = class extends b {
|
|
|
4024
4050
|
`;
|
|
4025
4051
|
} else
|
|
4026
4052
|
return d`
|
|
4027
|
-
<div class="${
|
|
4053
|
+
<div class="${y(e)}">
|
|
4028
4054
|
<div class="reaction-list">
|
|
4029
4055
|
${this.options.map((t) => this.renderReactionButton(t, this.showCounts))}
|
|
4030
4056
|
</div>
|
|
@@ -4068,9 +4094,9 @@ let q = class extends b {
|
|
|
4068
4094
|
[`pc-flex-align-${o}`]: !0
|
|
4069
4095
|
};
|
|
4070
4096
|
return d`
|
|
4071
|
-
<div class="${
|
|
4097
|
+
<div class="${y(t)}" data-testid="reaction-container">
|
|
4072
4098
|
${this.renderLabelAtStart()}
|
|
4073
|
-
<div class="${
|
|
4099
|
+
<div class="${y(r)}" data-testid="reaction-body">
|
|
4074
4100
|
${this.renderStatusAtStart()} ${this.renderChart()} ${this.renderReactions()}
|
|
4075
4101
|
${this.renderStatusAtEnd()}
|
|
4076
4102
|
</div>
|
|
@@ -4079,7 +4105,7 @@ let q = class extends b {
|
|
|
4079
4105
|
`;
|
|
4080
4106
|
}
|
|
4081
4107
|
};
|
|
4082
|
-
q.styles = [...b.styles, pt,
|
|
4108
|
+
q.styles = [...b.styles, pt, qo];
|
|
4083
4109
|
ht([
|
|
4084
4110
|
f({ type: Boolean, attribute: "show-counts" })
|
|
4085
4111
|
], q.prototype, "showCounts", 2);
|
|
@@ -4096,14 +4122,14 @@ function G(e, t, o = void 0) {
|
|
|
4096
4122
|
const r = e.getAttribute(t);
|
|
4097
4123
|
return r === null ? o : r == null ? void 0 : r.trim();
|
|
4098
4124
|
}
|
|
4099
|
-
function
|
|
4125
|
+
function Zo(e, t = void 0) {
|
|
4100
4126
|
const o = e.textContent;
|
|
4101
4127
|
return o === "" || o === null ? t : o == null ? void 0 : o.trim();
|
|
4102
4128
|
}
|
|
4103
|
-
var
|
|
4104
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
4129
|
+
var Go = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, ft = (e, t, o, r) => {
|
|
4130
|
+
for (var s = r > 1 ? void 0 : r ? Ko(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
4105
4131
|
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
4106
|
-
return r && s &&
|
|
4132
|
+
return r && s && Go(t, o, s), s;
|
|
4107
4133
|
};
|
|
4108
4134
|
let H = class extends j {
|
|
4109
4135
|
constructor() {
|
|
@@ -4166,14 +4192,14 @@ let H = class extends j {
|
|
|
4166
4192
|
const e = this.querySelector("pc-poll, pc-reaction");
|
|
4167
4193
|
if (!e) return;
|
|
4168
4194
|
const t = this.querySelectorAll("poll-catch-option");
|
|
4169
|
-
let r =
|
|
4195
|
+
let r = So(this.options).map((s) => ({
|
|
4170
4196
|
value: s,
|
|
4171
4197
|
label: s,
|
|
4172
4198
|
icon: e.tagName === "PC-REACTION" ? s : void 0
|
|
4173
4199
|
// REACTION widget uses options for the icon
|
|
4174
4200
|
}));
|
|
4175
4201
|
t && t.length > 0 && (r = Array.from(t).map((s) => {
|
|
4176
|
-
const i = G(s, "value", "") || "", a = G(s, "label",
|
|
4202
|
+
const i = G(s, "value", "") || "", a = G(s, "label", Zo(s, i)) || "", n = G(s, "icon", void 0), l = G(s, "tooltip", void 0), u = G(s, "disabled", void 0), c = { value: i, label: a };
|
|
4177
4203
|
if (n !== void 0) {
|
|
4178
4204
|
const p = Ce(n);
|
|
4179
4205
|
c.icon = p.icon;
|
|
@@ -4186,13 +4212,13 @@ let H = class extends j {
|
|
|
4186
4212
|
*/
|
|
4187
4213
|
render() {
|
|
4188
4214
|
switch (this.type) {
|
|
4189
|
-
case
|
|
4215
|
+
case $.nps:
|
|
4190
4216
|
return d`<pc-nps></pc-nps>`;
|
|
4191
|
-
case
|
|
4217
|
+
case $.poll:
|
|
4192
4218
|
return d`<pc-poll .options=${this.parsedOptions}></pc-poll>`;
|
|
4193
|
-
case
|
|
4219
|
+
case $.stars:
|
|
4194
4220
|
return d`<pc-stars></pc-stars>`;
|
|
4195
|
-
case
|
|
4221
|
+
case $.reaction:
|
|
4196
4222
|
return d`<pc-reaction .options=${this.parsedOptions}></pc-reaction>`;
|
|
4197
4223
|
default:
|
|
4198
4224
|
return console.warn(
|