pollcatch 2.1.11 → 2.1.13

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/pc.js +97 -76
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pollcatch",
3
3
  "private": false,
4
- "version": "2.1.11",
4
+ "version": "2.1.13",
5
5
  "type": "module",
6
6
  "main": "pc.js",
7
7
  "module": "pc.js",
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, v = 0;
295
- for (; v < l.length && (a.lastIndex = v, c = a.exec(l), c !== null); ) v = 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 y = 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 + y) : l + P + (p === -2 ? n : y);
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 v = c[a++], y = s.getAttribute(p).split(P), E = /([.?@])?(.*)/.exec(v);
315
- l.push({ type: 1, index: i, name: E[2], strings: y, ctor: E[1] === "." ? je : E[1] === "?" ? Be : E[1] === "@" ? De : ct }), s.removeAttribute(p);
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), v = p.length - 1;
319
- if (v > 0) {
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 y = 0; y < v; y++) s.append(p[y], X()), M.nextNode(), l.push({ type: 2, index: ++i });
322
- s.append(p[v], X());
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 x = /* @__PURE__ */ ((e) => (e.reaction = "reaction", e.stars = "stars", e.poll = "poll", e.text = "text", e.nps = "nps", e))(x || {});
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
- }, $ = function(e, t, o) {
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: $(e.r), g: $(e.g), b: $(e.b), a: $(e.a, 3) };
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: $(e.h), s: $(e.s), l: $(e.l), a: $(e.a, 3) };
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 ? $(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 ? $(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
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 $($t(this.rgba), 2);
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($(255 * i)) : "", "#" + rt(o) + rt(r) + rt(s) + a;
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: $(t.h), s: $(t.s), v: $(t.v), a: $(t.a, 3) };
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 }) : $(this.rgba.a, 3);
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 }) : $(o.h);
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 v = St(e, p);
801
- v > u && (u = v, l = p);
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.`
@@ -1107,8 +1107,9 @@ function Ao(e, t = 50) {
1107
1107
  return e.length <= t ? e : e.substring(0, t).trim() + "...";
1108
1108
  }
1109
1109
  class _o {
1110
+ // Tracks if user has ever made a selection (even if later deselected)
1110
1111
  constructor(t) {
1111
- this.stats = O(), this.localStats = O(), this.isLoading = !0, this.isSubmitting = !1, (this.host = t).addController(this);
1112
+ this.stats = O(), this.localStats = O(), this.isLoading = !0, this.isSubmitting = !1, this.hasInteracted = !1, (this.host = t).addController(this);
1112
1113
  }
1113
1114
  hostConnected() {
1114
1115
  this.loadStats();
@@ -1137,15 +1138,15 @@ class _o {
1137
1138
  const o = await this.getProjectId(), r = t.name, s = t.type;
1138
1139
  let i;
1139
1140
  if (t.dataFunc && typeof window < "u") {
1140
- const v = t.dataFunc.replace(/^window\./, "").split(".");
1141
- let y = window;
1142
- for (const E of v)
1143
- if (y = y == null ? void 0 : y[E], y === void 0) break;
1144
- i = y;
1141
+ const w = t.dataFunc.replace(/^window\./, "").split(".");
1142
+ let v = window;
1143
+ for (const E of w)
1144
+ if (v = v == null ? void 0 : v[E], v === void 0) break;
1145
+ i = v;
1145
1146
  }
1146
1147
  let a, n;
1147
1148
  if (i && typeof i == "function") {
1148
- const p = t.options.map((v) => v.value);
1149
+ const p = this.getOptionsForDataFunc(t);
1149
1150
  if (m.debug(`Using data function for: ${r}`, {
1150
1151
  dataFuncName: t.dataFunc,
1151
1152
  projectKey: o,
@@ -1160,12 +1161,12 @@ class _o {
1160
1161
  const p = t.dataEndpoint || ee;
1161
1162
  if (!r)
1162
1163
  throw new Error("Name parameter is required");
1163
- const v = `${p}/${encodeURIComponent(o)}/${encodeURIComponent(r)}`;
1164
+ const w = `${p}/${encodeURIComponent(o)}/${encodeURIComponent(r)}`;
1164
1165
  m.debug(`Fetching stats for: ${r}`, { endpoint: p, projectKey: o });
1165
- const y = await fetch(v);
1166
- if (!y.ok)
1167
- throw new Error(`API request failed with status: ${y.status}`);
1168
- if (a = await y.json(), !a.success)
1166
+ const v = await fetch(w);
1167
+ if (!v.ok)
1168
+ throw new Error(`API request failed with status: ${v.status}`);
1169
+ if (a = await v.json(), !a.success)
1169
1170
  throw m.error("Backend returned unsuccessful response", a), new Error("Backend returned unsuccessful response");
1170
1171
  n = a.data || {};
1171
1172
  }
@@ -1174,7 +1175,7 @@ class _o {
1174
1175
  sum: n.sum,
1175
1176
  avg: l,
1176
1177
  pct: u,
1177
- nps: s === x.nps ? lt((n == null ? void 0 : n.breakdown) || {}) : 0,
1178
+ nps: s === $.nps ? lt((n == null ? void 0 : n.breakdown) || {}) : 0,
1178
1179
  breakdown: n.breakdown ?? {},
1179
1180
  updated: n.updated_at || (/* @__PURE__ */ new Date()).toISOString()
1180
1181
  };
@@ -1185,6 +1186,26 @@ class _o {
1185
1186
  this.isLoading = !1, this.host.requestUpdate();
1186
1187
  }
1187
1188
  }
1189
+ /**
1190
+ * Gets the options array for the data function based on widget type.
1191
+ * - For poll/reaction: uses the options from pcBase.options
1192
+ * - For stars: generates ['1', '2', ..., numStars]
1193
+ * - For NPS: generates ['0', '1', '2', ..., '10']
1194
+ */
1195
+ getOptionsForDataFunc(t) {
1196
+ switch (t.type) {
1197
+ case $.stars: {
1198
+ const r = t.numStars || 5;
1199
+ return Array.from({ length: r }, (s, i) => String(i + 1));
1200
+ }
1201
+ case $.nps:
1202
+ return Array.from({ length: 11 }, (r, s) => String(s));
1203
+ case $.poll:
1204
+ case $.reaction:
1205
+ default:
1206
+ return t.options.map((r) => r.value);
1207
+ }
1208
+ }
1188
1209
  /**
1189
1210
  * Loads the local stats from localStorage
1190
1211
  */
@@ -1219,8 +1240,8 @@ class _o {
1219
1240
  */
1220
1241
  updateStats(t, o) {
1221
1242
  const r = this.host;
1222
- if (this.stats && (this.stats = $o(this.stats, this.localStats)), this.localStats = {
1223
- count: t > 0 || r.type === x.nps ? 1 : 0,
1243
+ if (this.hasInteracted = !0, this.stats && (this.stats = $o(this.stats, this.localStats)), this.localStats = {
1244
+ count: t > 0 || r.type === $.nps ? 1 : 0,
1224
1245
  // always 1 or 0
1225
1246
  sum: t,
1226
1247
  // e.g. number of stars, nps value
@@ -1240,7 +1261,7 @@ class _o {
1240
1261
  this.localStats.submitted = (/* @__PURE__ */ new Date()).toISOString(), await this.persistLocalStats(), this.host.requestUpdate();
1241
1262
  }
1242
1263
  async submitStats() {
1243
- if (!this.hasLocalStats())
1264
+ if (!this.hasLocalStats() && !this.hasInteracted)
1244
1265
  throw m.warn("No local stats to submit"), new Error("No local stats to submit");
1245
1266
  const t = this.host, o = Math.floor(Date.now() / 1e3).toString(), r = await re(), s = await this.getProjectId(), i = t.name || "", a = this.localStats.sum, n = Object.keys(this.localStats.breakdown || {});
1246
1267
  this.isSubmitting = !0, this.host.requestUpdate();
@@ -1306,7 +1327,7 @@ class _o {
1306
1327
  sum: (o == null ? void 0 : o.sum) || 0,
1307
1328
  avg: (o == null ? void 0 : o.avg) || 0,
1308
1329
  pct: (o == null ? void 0 : o.pct) || 0,
1309
- nps: r.type === x.nps ? lt((o == null ? void 0 : o.breakdown) || {}) : 0
1330
+ nps: r.type === $.nps ? lt((o == null ? void 0 : o.breakdown) || {}) : 0
1310
1331
  };
1311
1332
  return m.debug("Stats data: ", this.stats), Co(t, s);
1312
1333
  }
@@ -1334,7 +1355,7 @@ class _o {
1334
1355
  toggleValueSelected(t, o) {
1335
1356
  const r = Object.keys(this.localStats.breakdown || {}), s = r.includes(t), i = this.host;
1336
1357
  let a = 1;
1337
- if ((i.type === x.stars || i.type === x.nps) && (a = parseInt(t)), s)
1358
+ if ((i.type === $.stars || i.type === $.nps) && (a = parseInt(t)), s)
1338
1359
  if (o) {
1339
1360
  const l = r.filter((u) => u !== t);
1340
1361
  this.updateStats(l.length > 0 ? 1 : 0, l);
@@ -1442,18 +1463,18 @@ class Eo {
1442
1463
  */
1443
1464
  shouldShowStats() {
1444
1465
  const t = this.host;
1445
- return t.showStats === void 0 || t.showStats === "never" ? !1 : t.showStats === "always" || t.showStats === "" || t.readOnly && t.showStats === "after-vote" ? !0 : t.hasEditButton && this.isEditing ? !1 : this.dataController.hasLocalStats();
1466
+ return t.showStats === void 0 || t.showStats === "never" ? !1 : t.showStats === "always" || t.showStats === "" || t.readOnly && t.showStats === "after-vote" ? !0 : t.hasEditButton && this.isEditing ? !1 : this.dataController.hasLocalStats() || this.dataController.hasInteracted;
1446
1467
  }
1447
1468
  shouldShowFooter() {
1448
1469
  return this.shouldShowSubmitButton() || this.shouldShowStats();
1449
1470
  }
1450
1471
  shouldShowChart() {
1451
1472
  const t = this.host;
1452
- return t.showChart ? t.readOnly ? this.isChartVisible : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats() || !this.isChartVisible) : !1;
1473
+ return t.showChart ? t.readOnly ? this.isChartVisible : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats() && !this.dataController.hasInteracted || !this.isChartVisible) : !1;
1453
1474
  }
1454
1475
  shouldShowChartToggle() {
1455
1476
  const t = this.host;
1456
- return t.showChart ? t.readOnly ? !0 : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats()) : !1;
1477
+ return t.showChart ? t.readOnly ? !0 : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats() && !this.dataController.hasInteracted) : !1;
1457
1478
  }
1458
1479
  shouldShowSubmitButton() {
1459
1480
  return !!this.isEditing;
@@ -1532,7 +1553,7 @@ let xe = class {
1532
1553
  * Copyright 2018 Google LLC
1533
1554
  * SPDX-License-Identifier: BSD-3-Clause
1534
1555
  */
1535
- const w = $e(class extends xe {
1556
+ const y = $e(class extends xe {
1536
1557
  constructor(e) {
1537
1558
  var t;
1538
1559
  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.");
@@ -1735,7 +1756,7 @@ const st = {
1735
1756
  "pc-status": !0,
1736
1757
  [`pc-flex-content-${k(this.statsPosition, this.statsAlign)}`]: !0
1737
1758
  };
1738
- return d`<div class="${w(o)}" data-testid="pc-status">
1759
+ return d`<div class="${y(o)}" data-testid="pc-status">
1739
1760
  ${this.renderStatsText()} ${this.renderChartToggle()} ${this.renderEditToggleIcon()}
1740
1761
  </div>`;
1741
1762
  }
@@ -2623,7 +2644,7 @@ var Io = Object.defineProperty, No = Object.getOwnPropertyDescriptor, Y = (e, t,
2623
2644
  };
2624
2645
  let I = class extends b {
2625
2646
  constructor() {
2626
- super(), this.min = 0, this.max = 10, this.type = x.nps, this.minLabel = "Not at all", this.maxLabel = "Extremely", this.minMaxPosition = "top", this.hoverValue = -1, this.handleNumberLeave = () => {
2647
+ 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 = () => {
2627
2648
  this.hoverValue = -1;
2628
2649
  }, this.handleKeyDown = (e) => {
2629
2650
  (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.hoverValue >= 0 && this.handleNumberClick(this.hoverValue));
@@ -2646,7 +2667,7 @@ let I = class extends b {
2646
2667
  <button
2647
2668
  data-testid="nps-button-${s}"
2648
2669
  ?disabled=${!this.displayController.allowEdit()}
2649
- class=${w(a)}
2670
+ class=${y(a)}
2650
2671
  @click="${() => this.handleNumberClick(s)}"
2651
2672
  @mouseenter="${() => this.handleNumberHover(s)}"
2652
2673
  @focus="${() => this.handleNumberHover(s)}"
@@ -2739,9 +2760,9 @@ let I = class extends b {
2739
2760
  [`pc-flex-align-${k(this.statsPosition, this.statsAlign)}`]: !0
2740
2761
  };
2741
2762
  return d`
2742
- <div class="pc-container ${w(e)}" data-testid="nps-container">
2763
+ <div class="pc-container ${y(e)}" data-testid="nps-container">
2743
2764
  ${this.renderLabelAtStart()}
2744
- <div class="pc-body ${w(t)}" data-testid="nps-body">
2765
+ <div class="pc-body ${y(t)}" data-testid="nps-body">
2745
2766
  ${this.renderStatusAtStart()} ${this.renderContent()} ${this.renderStatusAtEnd()}
2746
2767
  </div>
2747
2768
  ${this.renderLabelAtEnd()}
@@ -3032,14 +3053,14 @@ var Lo = Object.defineProperty, Ro = Object.getOwnPropertyDescriptor, Nt = (e, t
3032
3053
  };
3033
3054
  let tt = class extends b {
3034
3055
  constructor() {
3035
- super(), this.type = x.poll, this.multiple = !1, this.compact = !1, this.hasEditButton = !0, this.statsText = "{count} votes", this.questionPosition = "top", this.statsPosition = "bottom", this.showStats = "after-vote";
3056
+ 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";
3036
3057
  }
3037
3058
  renderStatus() {
3038
3059
  const t = {
3039
3060
  "pc-status": !0,
3040
3061
  [`pc-flex-content-${k("bottom", this.statsAlign)}`]: !0
3041
3062
  };
3042
- return d`<div class="${w(t)}" data-testid="pc-status">
3063
+ return d`<div class="${y(t)}" data-testid="pc-status">
3043
3064
  <span>${this.renderStatsText()} ${this.renderEditToggleIcon("stats-edit-button")}</span>
3044
3065
  </div>`;
3045
3066
  }
@@ -3054,7 +3075,7 @@ let tt = class extends b {
3054
3075
  }, t = this.displayController.shouldDisableSubmitButton();
3055
3076
  return d`
3056
3077
  <button
3057
- class="${w(e)}"
3078
+ class="${y(e)}"
3058
3079
  data-testid="pc-submit-button"
3059
3080
  @click="${this.handleSubmit}"
3060
3081
  ?disabled="${t}"
@@ -3135,7 +3156,7 @@ let tt = class extends b {
3135
3156
  return d`
3136
3157
  <button
3137
3158
  data-testid="poll-option-i${t}"
3138
- class="${w(s)}"
3159
+ class="${y(s)}"
3139
3160
  @click="${() => this.handleClick(e)}"
3140
3161
  ?disabled="${r}"
3141
3162
  id="${a}-option-${t}"
@@ -3162,7 +3183,7 @@ let tt = class extends b {
3162
3183
  });
3163
3184
  return d`
3164
3185
  <div
3165
- class="${w({
3186
+ class="${y({
3166
3187
  "poll-container": !0
3167
3188
  })}"
3168
3189
  data-testid="poll-option-container"
@@ -3179,12 +3200,12 @@ let tt = class extends b {
3179
3200
  renderBarChart() {
3180
3201
  var l, u;
3181
3202
  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) => {
3182
- const v = e[c.value] || 0, y = o > 0 ? Math.round(v / o * 100) : 0, E = (t[c.value] || 0) > 0;
3203
+ const w = e[c.value] || 0, v = o > 0 ? Math.round(w / o * 100) : 0, E = (t[c.value] || 0) > 0;
3183
3204
  return {
3184
3205
  option: c,
3185
3206
  index: p,
3186
- voteCount: v,
3187
- percentage: y,
3207
+ voteCount: w,
3208
+ percentage: v,
3188
3209
  isSelected: E
3189
3210
  };
3190
3211
  }), s = this.multiple ? _.GROUP : _.RADIOGROUP, i = this.question || this.name || "Options", a = B({
@@ -3193,7 +3214,7 @@ let tt = class extends b {
3193
3214
  });
3194
3215
  return d`
3195
3216
  <div
3196
- class="${w({
3217
+ class="${y({
3197
3218
  "poll-container": !0
3198
3219
  })}"
3199
3220
  data-testid="poll-chart-container"
@@ -3209,7 +3230,7 @@ let tt = class extends b {
3209
3230
  };
3210
3231
  return d`
3211
3232
  <div
3212
- class="${w(p)}"
3233
+ class="${y(p)}"
3213
3234
  data-testid="poll-chart-item-${c.index}"
3214
3235
  role="listitem"
3215
3236
  aria-label="${c.option.label}: ${c.percentage}% (${c.voteCount} votes)"
@@ -3280,12 +3301,12 @@ let tt = class extends b {
3280
3301
  });
3281
3302
  return d`
3282
3303
  <div
3283
- class="pc-container ${w(t)}"
3304
+ class="pc-container ${y(t)}"
3284
3305
  data-testid="poll-container"
3285
3306
  ...=${s}
3286
3307
  >
3287
3308
  ${this.renderLabelAtStart()}
3288
- <div class="${w(r)}" data-testid="poll-body">
3309
+ <div class="${y(r)}" data-testid="poll-body">
3289
3310
  ${this.renderContent()} ${this.renderFooter()}
3290
3311
  </div>
3291
3312
  ${this.renderLabelAtEnd()}
@@ -3418,7 +3439,7 @@ var Do = Object.defineProperty, Vo = Object.getOwnPropertyDescriptor, ut = (e, t
3418
3439
  };
3419
3440
  let V = class extends b {
3420
3441
  constructor() {
3421
- super(), this.type = x.stars, this.numStars = 5, this.hoverValue = -1, this.handleStarKeyDown = (e) => {
3442
+ super(), this.type = $.stars, this.numStars = 5, this.hoverValue = -1, this.handleStarKeyDown = (e) => {
3422
3443
  if (e.key === "Enter" || e.key === " ") {
3423
3444
  e.preventDefault();
3424
3445
  const t = e.target, o = parseInt(t.dataset.star || "0");
@@ -3452,7 +3473,7 @@ let V = class extends b {
3452
3473
  <div class="pc-section" data-testid="pc-section">
3453
3474
  <span
3454
3475
  data-testid="stars-view-star-${n}"
3455
- class=${w(c)}
3476
+ class=${y(c)}
3456
3477
  style=${Bo(p)}
3457
3478
  role="${r ? "button" : "presentation"}"
3458
3479
  tabindex="${r ? "0" : ""}"
@@ -3502,9 +3523,9 @@ let V = class extends b {
3502
3523
  [`pc-flex-align-${o}`]: !0
3503
3524
  };
3504
3525
  return d`
3505
- <div class="pc-container ${w(t)}" data-testid="pc-container">
3526
+ <div class="pc-container ${y(t)}" data-testid="pc-container">
3506
3527
  ${this.renderLabelAtStart()}
3507
- <div class="${w(r)}" data-testid="stars-body">
3528
+ <div class="${y(r)}" data-testid="stars-body">
3508
3529
  ${this.renderStatusAtStart()} ${this.renderChart()} ${this.renderStars()}
3509
3530
  ${this.renderStatusAtEnd()}
3510
3531
  </div>
@@ -3878,7 +3899,7 @@ var Fo = Object.defineProperty, Yo = Object.getOwnPropertyDescriptor, ht = (e, t
3878
3899
  };
3879
3900
  let q = class extends b {
3880
3901
  constructor() {
3881
- super(), this.type = x.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";
3902
+ 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";
3882
3903
  }
3883
3904
  /**
3884
3905
  * Get the display count for a specific reaction including local optimistic updates
@@ -3927,7 +3948,7 @@ let q = class extends b {
3927
3948
  }, n = `${e.tooltip || e.value} reaction${o ? ", selected" : ""}${t ? `, ${r} votes` : ""}`;
3928
3949
  return d`
3929
3950
  <button
3930
- class="${w(a)}"
3951
+ class="${y(a)}"
3931
3952
  @click="${() => this.handleReactionClick(e)}"
3932
3953
  ?disabled="${s}"
3933
3954
  aria-pressed="${o}"
@@ -3969,7 +3990,7 @@ let q = class extends b {
3969
3990
  bottom: this.popupPosition === "bottom" || this.popupPosition === "auto" && !this.shouldShowPopoverOnTop()
3970
3991
  };
3971
3992
  return d`
3972
- <div class="${w(e)}" role="menu">
3993
+ <div class="${y(e)}" role="menu">
3973
3994
  <div class="popover-content">
3974
3995
  ${this.options.map((t) => {
3975
3996
  const o = this.displayController.shouldDisableOption(t);
@@ -4016,7 +4037,7 @@ let q = class extends b {
4016
4037
  (o) => this.dataController.isValueSelected(o.value)
4017
4038
  );
4018
4039
  return d`
4019
- <div class="${w(e)}">
4040
+ <div class="${y(e)}">
4020
4041
  ${this.renderTriggerButton()}
4021
4042
  ${t.length > 0 ? d`
4022
4043
  <div class="reaction-list">
@@ -4030,7 +4051,7 @@ let q = class extends b {
4030
4051
  `;
4031
4052
  } else
4032
4053
  return d`
4033
- <div class="${w(e)}">
4054
+ <div class="${y(e)}">
4034
4055
  <div class="reaction-list">
4035
4056
  ${this.options.map((t) => this.renderReactionButton(t, this.showCounts))}
4036
4057
  </div>
@@ -4074,9 +4095,9 @@ let q = class extends b {
4074
4095
  [`pc-flex-align-${o}`]: !0
4075
4096
  };
4076
4097
  return d`
4077
- <div class="${w(t)}" data-testid="reaction-container">
4098
+ <div class="${y(t)}" data-testid="reaction-container">
4078
4099
  ${this.renderLabelAtStart()}
4079
- <div class="${w(r)}" data-testid="reaction-body">
4100
+ <div class="${y(r)}" data-testid="reaction-body">
4080
4101
  ${this.renderStatusAtStart()} ${this.renderChart()} ${this.renderReactions()}
4081
4102
  ${this.renderStatusAtEnd()}
4082
4103
  </div>
@@ -4192,13 +4213,13 @@ let H = class extends j {
4192
4213
  */
4193
4214
  render() {
4194
4215
  switch (this.type) {
4195
- case x.nps:
4216
+ case $.nps:
4196
4217
  return d`<pc-nps></pc-nps>`;
4197
- case x.poll:
4218
+ case $.poll:
4198
4219
  return d`<pc-poll .options=${this.parsedOptions}></pc-poll>`;
4199
- case x.stars:
4220
+ case $.stars:
4200
4221
  return d`<pc-stars></pc-stars>`;
4201
- case x.reaction:
4222
+ case $.reaction:
4202
4223
  return d`<pc-reaction .options=${this.parsedOptions}></pc-reaction>`;
4203
4224
  default:
4204
4225
  return console.warn(