@mindbowser_inc/ui-feedback-plugin 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  var K = Object.defineProperty;
2
- var J = (e, t, r) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var H = (e, t, r) => J(e, typeof t != "symbol" ? t + "" : t, r);
2
+ var J = (e, t, o) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var H = (e, t, o) => J(e, typeof t != "symbol" ? t + "" : t, o);
4
4
  const O = /* @__PURE__ */ new Set();
5
5
  let T = {
6
6
  active: !1,
@@ -15,7 +15,7 @@ let T = {
15
15
  function L() {
16
16
  return T;
17
17
  }
18
- function b(e) {
18
+ function y(e) {
19
19
  T = { ...T, ...e }, O.forEach((t) => t(T));
20
20
  }
21
21
  function P(e) {
@@ -24,12 +24,12 @@ function P(e) {
24
24
  function X() {
25
25
  if (T.userName) return T.userName;
26
26
  const e = localStorage.getItem("ufp_user_name");
27
- return e ? (b({ userName: e }), e) : null;
27
+ return e ? (y({ userName: e }), e) : null;
28
28
  }
29
29
  function Y(e) {
30
- localStorage.setItem("ufp_user_name", e), b({ userName: e });
30
+ localStorage.setItem("ufp_user_name", e), y({ userName: e });
31
31
  }
32
- function U(e) {
32
+ function I(e) {
33
33
  try {
34
34
  const t = new URL(e);
35
35
  return t.origin + t.pathname;
@@ -597,10 +597,10 @@ const Z = {
597
597
  "bottom-left": { bottom: "24px", left: "24px" },
598
598
  "top-right": { top: "24px", right: "24px" },
599
599
  "top-left": { top: "24px", left: "24px" }
600
- }, $ = "#6366f1", I = "#4f46e5", j = "#4338ca";
601
- function ee(e, t, r, n) {
602
- const o = document.createElement("div");
603
- Object.assign(o.style, {
600
+ }, $ = "#6366f1", U = "#4f46e5", j = "#4338ca";
601
+ function ee(e, t, o, n) {
602
+ const r = document.createElement("div");
603
+ Object.assign(r.style, {
604
604
  position: "fixed",
605
605
  zIndex: "2147483647",
606
606
  display: "flex",
@@ -627,18 +627,18 @@ function ee(e, t, r, n) {
627
627
  <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
628
628
  </svg>
629
629
  <span id="ufp-panel-count" style="font-size:13px;font-weight:600;min-width:8px;text-align:center;"></span>
630
- `, o.appendChild(a), o.appendChild(d), o.appendChild(l), e.appendChild(o);
631
- const p = o.querySelector("#ufp-annotate-label"), s = o.querySelector("#ufp-panel-count");
630
+ `, r.appendChild(a), r.appendChild(d), r.appendChild(l), e.appendChild(r);
631
+ const p = r.querySelector("#ufp-annotate-label"), s = r.querySelector("#ufp-panel-count");
632
632
  return a.addEventListener("click", (i) => {
633
- if (i.stopPropagation(), o._dragged) return;
633
+ if (i.stopPropagation(), r._dragged) return;
634
634
  const u = L();
635
- u.active || (u.panelOpen ? (n(), setTimeout(r, 220)) : r());
635
+ u.active || (u.panelOpen ? (n(), setTimeout(o, 220)) : o());
636
636
  }), l.addEventListener("click", (i) => {
637
- i.stopPropagation(), !o._dragged && (L().active || n());
638
- }), _(a, () => (L().panelOpen, $), I), _(l, () => L().panelOpen ? j : $, I), P((i) => {
637
+ i.stopPropagation(), !r._dragged && (L().active || n());
638
+ }), _(a, () => (L().panelOpen, $), U), _(l, () => L().panelOpen ? j : $, U), P((i) => {
639
639
  const u = i.comments.filter((w) => !w.resolved).length;
640
640
  s.textContent = u > 0 ? String(u) : "", i.active ? (p.textContent = "Drawing…", a.style.opacity = "0.65", l.style.opacity = "0.65", a.style.pointerEvents = "none", l.style.pointerEvents = "none") : (p.textContent = "Feedback", a.style.opacity = "1", l.style.opacity = "1", a.style.pointerEvents = "auto", l.style.pointerEvents = "auto"), l.style.background = i.panelOpen ? j : $;
641
- }), te(o), o;
641
+ }), te(r), r;
642
642
  }
643
643
  function D(e) {
644
644
  Object.assign(e.style, {
@@ -654,23 +654,23 @@ function D(e) {
654
654
  transition: "background 0.12s"
655
655
  });
656
656
  }
657
- function _(e, t, r) {
657
+ function _(e, t, o) {
658
658
  e.addEventListener("mouseenter", () => {
659
- e.style.background = r;
659
+ e.style.background = o;
660
660
  }), e.addEventListener("mouseleave", () => {
661
661
  e.style.background = t();
662
662
  });
663
663
  }
664
664
  function te(e) {
665
- let t = 0, r = 0, n = 0, o = 0;
665
+ let t = 0, o = 0, n = 0, r = 0;
666
666
  e.addEventListener("pointerdown", (a) => {
667
667
  if (a.button !== 0) return;
668
- t = a.clientX, r = a.clientY;
668
+ t = a.clientX, o = a.clientY;
669
669
  const d = e.getBoundingClientRect();
670
- n = d.left, o = d.top, e._dragged = !1;
670
+ n = d.left, r = d.top, e._dragged = !1;
671
671
  const l = (s) => {
672
- const i = s.clientX - t, u = s.clientY - r;
673
- !e._dragged && Math.sqrt(i * i + u * u) < 5 || (e._dragged = !0, e.style.left = `${Math.max(0, Math.min(window.innerWidth - e.offsetWidth, n + i))}px`, e.style.top = `${Math.max(0, Math.min(window.innerHeight - e.offsetHeight, o + u))}px`, e.style.right = "auto", e.style.bottom = "auto");
672
+ const i = s.clientX - t, u = s.clientY - o;
673
+ !e._dragged && Math.sqrt(i * i + u * u) < 5 || (e._dragged = !0, e.style.left = `${Math.max(0, Math.min(window.innerWidth - e.offsetWidth, n + i))}px`, e.style.top = `${Math.max(0, Math.min(window.innerHeight - e.offsetHeight, r + u))}px`, e.style.right = "auto", e.style.bottom = "auto");
674
674
  }, p = () => {
675
675
  document.removeEventListener("pointermove", l), document.removeEventListener("pointerup", p), requestAnimationFrame(() => {
676
676
  e._dragged = !1;
@@ -681,8 +681,8 @@ function te(e) {
681
681
  }
682
682
  function ne(e) {
683
683
  return new Promise((t) => {
684
- const r = document.createElement("div");
685
- r.className = "ufp-modal-backdrop", r.innerHTML = `
684
+ const o = document.createElement("div");
685
+ o.className = "ufp-modal-backdrop", o.innerHTML = `
686
686
  <div class="ufp-modal" role="dialog" aria-modal="true" aria-labelledby="ufp-modal-title">
687
687
  <h2 id="ufp-modal-title">Welcome to Feedback Mode</h2>
688
688
  <p>Enter your name so others can see who left the comment.</p>
@@ -698,43 +698,43 @@ function ne(e) {
698
698
  <button class="ufp-btn ufp-btn-primary" id="ufp-name-submit" disabled>Continue</button>
699
699
  </div>
700
700
  </div>
701
- `, e.appendChild(r);
702
- const n = r.querySelector("#ufp-name-input"), o = r.querySelector("#ufp-name-submit");
701
+ `, e.appendChild(o);
702
+ const n = o.querySelector("#ufp-name-input"), r = o.querySelector("#ufp-name-submit");
703
703
  n.addEventListener("input", () => {
704
- o.disabled = n.value.trim().length === 0;
704
+ r.disabled = n.value.trim().length === 0;
705
705
  });
706
706
  const a = () => {
707
707
  const d = n.value.trim();
708
- d && (Y(d), r.remove(), t(d));
708
+ d && (Y(d), o.remove(), t(d));
709
709
  };
710
- o.addEventListener("click", a), n.addEventListener("keydown", (d) => {
710
+ r.addEventListener("click", a), n.addEventListener("keydown", (d) => {
711
711
  d.key === "Enter" && a();
712
712
  }), requestAnimationFrame(() => n.focus());
713
713
  });
714
714
  }
715
715
  const C = "#6366f1", M = 3;
716
- function z(e, t = 1, r = 1) {
716
+ function z(e, t = 1, o = 1) {
717
717
  switch (e.type) {
718
718
  case "pen": {
719
719
  const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
720
- return n.setAttribute("d", oe(e.points, t, r)), n.setAttribute("stroke", e.color), n.setAttribute("stroke-width", String(e.width * Math.min(t, r))), n.setAttribute("fill", "none"), n.setAttribute("stroke-linecap", "round"), n.setAttribute("stroke-linejoin", "round"), n;
720
+ return n.setAttribute("d", oe(e.points, t, o)), n.setAttribute("stroke", e.color), n.setAttribute("stroke-width", String(e.width * Math.min(t, o))), n.setAttribute("fill", "none"), n.setAttribute("stroke-linecap", "round"), n.setAttribute("stroke-linejoin", "round"), n;
721
721
  }
722
722
  case "rect": {
723
723
  const n = document.createElementNS("http://www.w3.org/2000/svg", "rect");
724
- return n.setAttribute("x", String(e.x * t)), n.setAttribute("y", String(e.y * r)), n.setAttribute("width", String(e.width * t)), n.setAttribute("height", String(e.height * r)), n.setAttribute("stroke", e.color), n.setAttribute("stroke-width", String(e.strokeWidth * Math.min(t, r))), n.setAttribute("fill", "none"), n.setAttribute("rx", "3"), n;
724
+ return n.setAttribute("x", String(e.x * t)), n.setAttribute("y", String(e.y * o)), n.setAttribute("width", String(e.width * t)), n.setAttribute("height", String(e.height * o)), n.setAttribute("stroke", e.color), n.setAttribute("stroke-width", String(e.strokeWidth * Math.min(t, o))), n.setAttribute("fill", "none"), n.setAttribute("rx", "3"), n;
725
725
  }
726
726
  case "circle": {
727
727
  const n = document.createElementNS("http://www.w3.org/2000/svg", "ellipse");
728
- return n.setAttribute("cx", String(e.cx * t)), n.setAttribute("cy", String(e.cy * r)), n.setAttribute("rx", String(e.rx * t)), n.setAttribute("ry", String(e.ry * r)), n.setAttribute("stroke", e.color), n.setAttribute("stroke-width", String(e.strokeWidth * Math.min(t, r))), n.setAttribute("fill", "none"), n;
728
+ return n.setAttribute("cx", String(e.cx * t)), n.setAttribute("cy", String(e.cy * o)), n.setAttribute("rx", String(e.rx * t)), n.setAttribute("ry", String(e.ry * o)), n.setAttribute("stroke", e.color), n.setAttribute("stroke-width", String(e.strokeWidth * Math.min(t, o))), n.setAttribute("fill", "none"), n;
729
729
  }
730
730
  case "arrow": {
731
- const n = document.createElementNS("http://www.w3.org/2000/svg", "g"), o = document.createElementNS("http://www.w3.org/2000/svg", "line");
732
- return o.setAttribute("x1", String(e.x1 * t)), o.setAttribute("y1", String(e.y1 * r)), o.setAttribute("x2", String(e.x2 * t)), o.setAttribute("y2", String(e.y2 * r)), o.setAttribute("stroke", e.color), o.setAttribute("stroke-width", String(e.width * Math.min(t, r))), o.setAttribute("marker-end", "url(#ufp-arrowhead)"), n.appendChild(o), n;
731
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "g"), r = document.createElementNS("http://www.w3.org/2000/svg", "line");
732
+ return r.setAttribute("x1", String(e.x1 * t)), r.setAttribute("y1", String(e.y1 * o)), r.setAttribute("x2", String(e.x2 * t)), r.setAttribute("y2", String(e.y2 * o)), r.setAttribute("stroke", e.color), r.setAttribute("stroke-width", String(e.width * Math.min(t, o))), r.setAttribute("marker-end", "url(#ufp-arrowhead)"), n.appendChild(r), n;
733
733
  }
734
734
  }
735
735
  }
736
- function re(e, t, r, n) {
737
- const o = r / t.pageWidth, a = n / t.pageHeight;
736
+ function re(e, t, o, n) {
737
+ const r = o / t.pageWidth, a = n / t.pageHeight;
738
738
  e.innerHTML = "";
739
739
  const d = document.createElementNS("http://www.w3.org/2000/svg", "defs");
740
740
  d.innerHTML = `
@@ -742,25 +742,25 @@ function re(e, t, r, n) {
742
742
  <polygon points="0 0, 10 3.5, 0 7" fill="${C}" />
743
743
  </marker>
744
744
  `, e.appendChild(d), t.shapes.forEach((l) => {
745
- e.appendChild(z(l, o, a));
745
+ e.appendChild(z(l, r, a));
746
746
  });
747
747
  }
748
- function oe(e, t, r) {
748
+ function oe(e, t, o) {
749
749
  if (e.length === 0) return "";
750
750
  if (e.length === 1) {
751
- const o = e[0];
752
- return `M ${o.x * t} ${o.y * r}`;
751
+ const r = e[0];
752
+ return `M ${r.x * t} ${r.y * o}`;
753
753
  }
754
- let n = `M ${e[0].x * t} ${e[0].y * r}`;
755
- for (let o = 1; o < e.length; o++)
756
- n += ` L ${e[o].x * t} ${e[o].y * r}`;
754
+ let n = `M ${e[0].x * t} ${e[0].y * o}`;
755
+ for (let r = 1; r < e.length; r++)
756
+ n += ` L ${e[r].x * t} ${e[r].y * o}`;
757
757
  return n;
758
758
  }
759
759
  function ie(e) {
760
760
  return new Promise((t) => {
761
- let r = "pen";
761
+ let o = "pen";
762
762
  const n = [];
763
- let o = !1, a = 0, d = 0, l = [], p = null, s = null;
763
+ let r = !1, a = 0, d = 0, l = [], p = null, s = null;
764
764
  const i = document.createElement("div");
765
765
  i.style.cssText = "position:fixed;inset:0;z-index:2147483645;cursor:crosshair;background:rgba(99,102,241,0.04);";
766
766
  const u = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@@ -772,7 +772,7 @@ function ie(e) {
772
772
  </defs>
773
773
  `, i.appendChild(u);
774
774
  function w() {
775
- i.remove(), v.remove(), s == null || s.remove();
775
+ i.remove(), b.remove(), s == null || s.remove();
776
776
  }
777
777
  function h() {
778
778
  const m = u.querySelector("defs");
@@ -782,8 +782,8 @@ function ie(e) {
782
782
  let m = 0, x = 0, g = 0;
783
783
  return n.forEach((c) => {
784
784
  if (c.type === "pen" && c.points.length) {
785
- const y = c.points[c.points.length - 1];
786
- m += y.x, x += y.y, g++;
785
+ const v = c.points[c.points.length - 1];
786
+ m += v.x, x += v.y, g++;
787
787
  } else c.type === "rect" ? (m += c.x + c.width, x += c.y + c.height, g++) : c.type === "circle" ? (m += c.cx, x += c.cy, g++) : c.type === "arrow" && (m += c.x2, x += c.y2, g++);
788
788
  }), {
789
789
  anchorX: g > 0 ? m / g - window.scrollX : window.innerWidth / 2,
@@ -791,14 +791,14 @@ function ie(e) {
791
791
  };
792
792
  }
793
793
  function E() {
794
- i.style.pointerEvents = "none", v.style.pointerEvents = "none", f();
794
+ i.style.pointerEvents = "none", b.style.pointerEvents = "none", f();
795
795
  }
796
796
  function f() {
797
797
  s && s.remove();
798
798
  const { anchorX: m, anchorY: x } = k(), g = 300, c = 12;
799
- let y = m + c, S = x + c;
800
- y + g > window.innerWidth - c && (y = m - g - c), y < c && (y = c), S + 210 > window.innerHeight - c && (S = window.innerHeight - 210 - c), S < c && (S = c), s = document.createElement("div"), s.style.cssText = `
801
- position:fixed;left:${y}px;top:${S}px;z-index:2147483647;
799
+ let v = m + c, S = x + c;
800
+ v + g > window.innerWidth - c && (v = m - g - c), v < c && (v = c), S + 210 > window.innerHeight - c && (S = window.innerHeight - 210 - c), S < c && (S = c), s = document.createElement("div"), s.style.cssText = `
801
+ position:fixed;left:${v}px;top:${S}px;z-index:2147483647;
802
802
  background:#fff;border-radius:12px;padding:16px;width:${g}px;
803
803
  box-shadow:0 4px 24px rgba(0,0,0,0.18);
804
804
  display:flex;flex-direction:column;gap:10px;
@@ -833,54 +833,54 @@ function ie(e) {
833
833
  w(), t(null);
834
834
  }), requestAnimationFrame(() => B.focus());
835
835
  }
836
- const v = ae(
836
+ const b = ae(
837
837
  e,
838
838
  (m) => {
839
- r = m;
839
+ o = m;
840
840
  },
841
841
  () => {
842
842
  w(), t(null);
843
843
  },
844
844
  () => {
845
- n.length !== 0 && (s && (s.remove(), s = null, i.style.pointerEvents = "auto", v.style.pointerEvents = "auto"), n.pop(), h());
845
+ n.length !== 0 && (s && (s.remove(), s = null, i.style.pointerEvents = "auto", b.style.pointerEvents = "auto"), n.pop(), h());
846
846
  }
847
847
  );
848
848
  e.appendChild(i), i.addEventListener("pointerdown", (m) => {
849
- m.button === 0 && (i.setPointerCapture(m.pointerId), o = !0, a = m.clientX + window.scrollX, d = m.clientY + window.scrollY, r === "pen" && (l = [{ x: a, y: d }]));
849
+ m.button === 0 && (i.setPointerCapture(m.pointerId), r = !0, a = m.clientX + window.scrollX, d = m.clientY + window.scrollY, o === "pen" && (l = [{ x: a, y: d }]));
850
850
  }), i.addEventListener("pointermove", (m) => {
851
- if (!o) return;
851
+ if (!r) return;
852
852
  const x = m.clientX + window.scrollX, g = m.clientY + window.scrollY;
853
- if (p && p.remove(), r === "pen")
853
+ if (p && p.remove(), o === "pen")
854
854
  l.push({ x, y: g }), p = z({ type: "pen", points: [...l], color: C, width: M });
855
- else if (r === "rect") {
855
+ else if (o === "rect") {
856
856
  const c = { type: "rect", x: Math.min(a, x), y: Math.min(d, g), width: Math.abs(x - a), height: Math.abs(g - d), color: C, strokeWidth: M };
857
857
  p = z(c);
858
- } else if (r === "circle") {
859
- const c = Math.abs(x - a) / 2, y = Math.abs(g - d) / 2, S = { type: "circle", cx: Math.min(a, x) + c, cy: Math.min(d, g) + y, rx: c, ry: y, color: C, strokeWidth: M };
858
+ } else if (o === "circle") {
859
+ const c = Math.abs(x - a) / 2, v = Math.abs(g - d) / 2, S = { type: "circle", cx: Math.min(a, x) + c, cy: Math.min(d, g) + v, rx: c, ry: v, color: C, strokeWidth: M };
860
860
  p = z(S);
861
- } else r === "arrow" && (p = z({ type: "arrow", x1: a, y1: d, x2: x, y2: g, color: C, width: M }));
861
+ } else o === "arrow" && (p = z({ type: "arrow", x1: a, y1: d, x2: x, y2: g, color: C, width: M }));
862
862
  p && u.appendChild(p);
863
863
  }), i.addEventListener("pointerup", (m) => {
864
- if (!o) return;
865
- o = !1, p && (p.remove(), p = null);
864
+ if (!r) return;
865
+ r = !1, p && (p.remove(), p = null);
866
866
  const x = m.clientX + window.scrollX, g = m.clientY + window.scrollY;
867
867
  let c = !1;
868
- if (r === "pen" && l.length > 1)
868
+ if (o === "pen" && l.length > 1)
869
869
  n.push({ type: "pen", points: [...l], color: C, width: M }), l = [], c = !0;
870
- else if (r === "rect") {
871
- const y = Math.abs(x - a), S = Math.abs(g - d);
872
- y > 4 && S > 4 && (n.push({ type: "rect", x: Math.min(a, x), y: Math.min(d, g), width: y, height: S, color: C, strokeWidth: M }), c = !0);
873
- } else if (r === "circle") {
874
- const y = Math.abs(x - a) / 2, S = Math.abs(g - d) / 2;
875
- y > 4 && S > 4 && (n.push({ type: "circle", cx: Math.min(a, x) + y, cy: Math.min(d, g) + S, rx: y, ry: S, color: C, strokeWidth: M }), c = !0);
876
- } else r === "arrow" && Math.sqrt((x - a) ** 2 + (g - d) ** 2) > 10 && (n.push({ type: "arrow", x1: a, y1: d, x2: x, y2: g, color: C, width: M }), c = !0);
870
+ else if (o === "rect") {
871
+ const v = Math.abs(x - a), S = Math.abs(g - d);
872
+ v > 4 && S > 4 && (n.push({ type: "rect", x: Math.min(a, x), y: Math.min(d, g), width: v, height: S, color: C, strokeWidth: M }), c = !0);
873
+ } else if (o === "circle") {
874
+ const v = Math.abs(x - a) / 2, S = Math.abs(g - d) / 2;
875
+ v > 4 && S > 4 && (n.push({ type: "circle", cx: Math.min(a, x) + v, cy: Math.min(d, g) + S, rx: v, ry: S, color: C, strokeWidth: M }), c = !0);
876
+ } else o === "arrow" && Math.sqrt((x - a) ** 2 + (g - d) ** 2) > 10 && (n.push({ type: "arrow", x1: a, y1: d, x2: x, y2: g, color: C, width: M }), c = !0);
877
877
  c && (h(), E());
878
878
  });
879
879
  });
880
880
  }
881
- function ae(e, t, r, n) {
882
- const o = document.createElement("div");
883
- return o.className = "ufp-toolbar", o.innerHTML = `
881
+ function ae(e, t, o, n) {
882
+ const r = document.createElement("div");
883
+ return r.className = "ufp-toolbar", r.innerHTML = `
884
884
  <span class="ufp-toolbar-label">Draw to annotate</span>
885
885
  <div class="ufp-toolbar-sep"></div>
886
886
  <button class="ufp-btn-icon active" data-tool="pen" title="Pen">
@@ -907,20 +907,20 @@ function ae(e, t, r, n) {
907
907
  </button>
908
908
  <div class="ufp-toolbar-sep"></div>
909
909
  <button class="ufp-btn ufp-btn-ghost" id="ufp-cancel-btn">Cancel</button>
910
- `, o.querySelectorAll("[data-tool]").forEach((a) => {
910
+ `, r.querySelectorAll("[data-tool]").forEach((a) => {
911
911
  a.addEventListener("click", () => {
912
- o.querySelectorAll("[data-tool]").forEach((d) => d.classList.remove("active")), a.classList.add("active"), t(a.dataset.tool);
912
+ r.querySelectorAll("[data-tool]").forEach((d) => d.classList.remove("active")), a.classList.add("active"), t(a.dataset.tool);
913
913
  });
914
- }), o.querySelector("#ufp-undo-btn").addEventListener("click", n), o.querySelector("#ufp-cancel-btn").addEventListener("click", r), e.appendChild(o), o;
914
+ }), r.querySelector("#ufp-undo-btn").addEventListener("click", n), r.querySelector("#ufp-cancel-btn").addEventListener("click", o), e.appendChild(r), r;
915
915
  }
916
916
  function W(e) {
917
- const t = Date.now() - e, r = Math.floor(t / 1e3);
918
- if (r < 60) return "just now";
919
- const n = Math.floor(r / 60);
917
+ const t = Date.now() - e, o = Math.floor(t / 1e3);
918
+ if (o < 60) return "just now";
919
+ const n = Math.floor(o / 60);
920
920
  if (n < 60) return `${n}m ago`;
921
- const o = Math.floor(n / 60);
922
- if (o < 24) return `${o}h ago`;
923
- const a = Math.floor(o / 24);
921
+ const r = Math.floor(n / 60);
922
+ if (r < 24) return `${r}h ago`;
923
+ const a = Math.floor(r / 24);
924
924
  return a < 7 ? `${a}d ago` : new Date(e).toLocaleDateString();
925
925
  }
926
926
  function F(e) {
@@ -929,8 +929,8 @@ function F(e) {
929
929
  function A(e) {
930
930
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
931
931
  }
932
- function se(e, t, r, n) {
933
- let o = [...t];
932
+ function se(e, t, o, n) {
933
+ let r = [...t];
934
934
  const a = document.createElement("div");
935
935
  a.className = "ufp-replies";
936
936
  const d = (h) => {
@@ -939,15 +939,15 @@ function se(e, t, r, n) {
939
939
  const E = document.createElement("div");
940
940
  if (E.className = "ufp-replies-list", E.style.cssText = "display:flex;flex-direction:column;gap:12px;", h.length > 0) {
941
941
  const f = document.createElement("div");
942
- f.className = "ufp-replies-title", f.textContent = `${h.length} ${h.length === 1 ? "Reply" : "Replies"}`, E.appendChild(f), h.forEach((v) => {
942
+ f.className = "ufp-replies-title", f.textContent = `${h.length} ${h.length === 1 ? "Reply" : "Replies"}`, E.appendChild(f), h.forEach((b) => {
943
943
  const m = document.createElement("div");
944
944
  m.className = "ufp-reply", m.innerHTML = `
945
945
  <div class="ufp-reply-meta">
946
- <div class="ufp-avatar" style="width:22px;height:22px;font-size:10px;">${F(v.authorName)}</div>
947
- <span class="ufp-reply-author">${A(v.authorName)}</span>
948
- <span class="ufp-reply-time">${W(v.createdAt)}</span>
946
+ <div class="ufp-avatar" style="width:22px;height:22px;font-size:10px;">${F(b.authorName)}</div>
947
+ <span class="ufp-reply-author">${A(b.authorName)}</span>
948
+ <span class="ufp-reply-time">${W(b.createdAt)}</span>
949
949
  </div>
950
- <div class="ufp-reply-text">${A(v.text)}</div>
950
+ <div class="ufp-reply-text">${A(b.text)}</div>
951
951
  `, E.appendChild(m);
952
952
  });
953
953
  }
@@ -992,16 +992,16 @@ function se(e, t, r, n) {
992
992
  createdAt: Date.now()
993
993
  };
994
994
  try {
995
- const v = { id: await r.addReply(E), ...E };
996
- i.value = "", u.textContent = "Reply", u.disabled = !0, o = [...o, v], d(o), n(v);
995
+ const b = { id: await o.addReply(E), ...E };
996
+ i.value = "", u.textContent = "Reply", u.disabled = !0, r = [...r, b], d(r), n(b);
997
997
  } catch (f) {
998
998
  console.error("[ui-feedback-plugin] Failed to save reply:", f), u.disabled = !1, u.textContent = "Reply";
999
999
  }
1000
- }), a.appendChild(l), d(o), a.addReply = (h) => {
1001
- o = [...o, h], d(o);
1000
+ }), a.appendChild(l), d(r), a.addReply = (h) => {
1001
+ r = [...r, h], d(r);
1002
1002
  }, a;
1003
1003
  }
1004
- function le(e, t, r, n, o, a, d, l) {
1004
+ function le(e, t, o, n, r, a, d, l) {
1005
1005
  const p = document.createElement("div");
1006
1006
  p.className = "ufp-detail", p.innerHTML = `
1007
1007
  <div class="ufp-detail-image-area">
@@ -1047,7 +1047,7 @@ function le(e, t, r, n, o, a, d, l) {
1047
1047
  </div>
1048
1048
  </div>
1049
1049
  `, e.appendChild(p), p.querySelector("#ufp-detail-back").addEventListener("click", () => {
1050
- p.remove(), b({ panelOpen: !0 });
1050
+ p.remove(), y({ panelOpen: !0 });
1051
1051
  });
1052
1052
  const s = p.querySelector("#ufp-detail-actions");
1053
1053
  if (t.resolved) {
@@ -1057,7 +1057,7 @@ function le(e, t, r, n, o, a, d, l) {
1057
1057
  style="vertical-align:middle;margin-right:4px"><polyline points="9 14 4 9 9 4"/><path d="M20 20v-7a4 4 0 0 0-4-4H4"/></svg>
1058
1058
  Reopen
1059
1059
  `, f.addEventListener("click", async () => {
1060
- f.disabled = !0, f.textContent = "Reopening…", await n.updateComment(t.id, { resolved: !1 }), a(t.id), p.remove(), b({ panelOpen: !0 });
1060
+ f.disabled = !0, f.textContent = "Reopening…", await n.updateComment(t.id, { resolved: !1 }), a(t.id), p.remove(), y({ panelOpen: !0 });
1061
1061
  }), s.appendChild(f);
1062
1062
  } else {
1063
1063
  const f = document.createElement("button");
@@ -1066,27 +1066,27 @@ function le(e, t, r, n, o, a, d, l) {
1066
1066
  style="vertical-align:middle;margin-right:4px"><polyline points="20 6 9 17 4 12"/></svg>
1067
1067
  Mark Resolved
1068
1068
  `, f.addEventListener("click", async () => {
1069
- f.disabled = !0, f.textContent = "Resolving…", await n.updateComment(t.id, { resolved: !0 }), o(t.id), p.remove(), b({ panelOpen: !0 });
1069
+ f.disabled = !0, f.textContent = "Resolving…", await n.updateComment(t.id, { resolved: !0 }), r(t.id), p.remove(), y({ panelOpen: !0 });
1070
1070
  }), s.appendChild(f);
1071
1071
  }
1072
1072
  const i = document.createElement("button");
1073
1073
  i.className = "ufp-btn ufp-btn-ghost", i.style.fontSize = "13px", i.textContent = "Delete", i.addEventListener("click", async () => {
1074
- confirm("Delete this comment and all its replies?") && (i.disabled = !0, await n.deleteComment(t.id), d(t.id), p.remove(), b({ panelOpen: !0 }));
1074
+ confirm("Delete this comment and all its replies?") && (i.disabled = !0, await n.deleteComment(t.id), d(t.id), p.remove(), y({ panelOpen: !0 }));
1075
1075
  }), s.appendChild(i);
1076
- const u = p.querySelector("#ufp-detail-replies"), w = se(t.id, r, n, (f) => {
1077
- var v;
1078
- (v = w.addReply) == null || v.call(w, f), l == null || l(f);
1076
+ const u = p.querySelector("#ufp-detail-replies"), w = se(t.id, o, n, (f) => {
1077
+ var b;
1078
+ (b = w.addReply) == null || b.call(w, f), l == null || l(f);
1079
1079
  });
1080
1080
  u.appendChild(w);
1081
1081
  const h = p.querySelector(".ufp-detail-screenshot"), k = p.querySelector(".ufp-detail-annotation-svg"), E = () => {
1082
- const f = h.clientWidth, v = h.clientHeight;
1083
- k.setAttribute("viewBox", `0 0 ${f} ${v}`), re(k, t.annotation, f, v), k.querySelectorAll("[marker-end]").forEach((m) => {
1082
+ const f = h.clientWidth, b = h.clientHeight;
1083
+ k.setAttribute("viewBox", `0 0 ${f} ${b}`), re(k, t.annotation, f, b), k.querySelectorAll("[marker-end]").forEach((m) => {
1084
1084
  m.setAttribute("marker-end", "url(#ufp-detail-arrowhead)");
1085
1085
  });
1086
1086
  };
1087
1087
  h.complete && h.naturalWidth > 0 ? E() : h.addEventListener("load", E);
1088
1088
  }
1089
- function pe(e, t, r) {
1089
+ function pe(e, t, o) {
1090
1090
  const n = document.createElement("div");
1091
1091
  n.className = "ufp-panel", n.innerHTML = `
1092
1092
  <div class="ufp-panel-header">
@@ -1109,18 +1109,18 @@ function pe(e, t, r) {
1109
1109
  </div>
1110
1110
  <div class="ufp-panel-list" id="ufp-comment-list"></div>
1111
1111
  `, e.appendChild(n), n.querySelector("#ufp-panel-close").addEventListener("click", () => {
1112
- b({ panelOpen: !1 });
1112
+ y({ panelOpen: !1 });
1113
1113
  }), n.querySelector("#ufp-new-feedback").addEventListener("click", () => {
1114
- b({ panelOpen: !1 }), r();
1114
+ y({ panelOpen: !1 }), o();
1115
1115
  }), n.querySelectorAll(".ufp-filter-tab").forEach((l) => {
1116
1116
  l.addEventListener("click", () => {
1117
- n.querySelectorAll(".ufp-filter-tab").forEach((p) => p.classList.remove("active")), l.classList.add("active"), b({ filter: l.dataset.filter });
1117
+ n.querySelectorAll(".ufp-filter-tab").forEach((p) => p.classList.remove("active")), l.classList.add("active"), y({ filter: l.dataset.filter });
1118
1118
  });
1119
1119
  });
1120
- const o = n.querySelector("#ufp-comment-list"), a = /* @__PURE__ */ new Map(), d = async (l, p) => {
1120
+ const r = n.querySelector("#ufp-comment-list"), a = /* @__PURE__ */ new Map(), d = async (l, p) => {
1121
1121
  const s = l.filter((i) => p === "open" ? !i.resolved : i.resolved);
1122
- if (o.innerHTML = "", s.length === 0) {
1123
- o.innerHTML = `
1122
+ if (r.innerHTML = "", s.length === 0) {
1123
+ r.innerHTML = `
1124
1124
  <div class="ufp-panel-empty">
1125
1125
  <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" opacity="0.4">
1126
1126
  <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
@@ -1138,7 +1138,7 @@ function pe(e, t, r) {
1138
1138
  } catch {
1139
1139
  a.set(i.id, []);
1140
1140
  }
1141
- o.appendChild(
1141
+ r.appendChild(
1142
1142
  de(i, a, e, t)
1143
1143
  );
1144
1144
  }
@@ -1147,7 +1147,7 @@ function pe(e, t, r) {
1147
1147
  n.classList.toggle("open", l.panelOpen), l.panelOpen && await d(l.comments, l.filter);
1148
1148
  }), n;
1149
1149
  }
1150
- function de(e, t, r, n, o) {
1150
+ function de(e, t, o, n, r) {
1151
1151
  const a = t.get(e.id) ?? [], d = document.createElement("div");
1152
1152
  return d.className = "ufp-comment-card", d.dataset.id = e.id, d.innerHTML = `
1153
1153
  <div class="ufp-comment-card-header">
@@ -1175,28 +1175,28 @@ function de(e, t, r, n, o) {
1175
1175
  console.error("[ui-feedback-plugin] Failed to fetch replies:", p);
1176
1176
  }
1177
1177
  le(
1178
- r,
1178
+ o,
1179
1179
  e,
1180
1180
  l,
1181
1181
  n,
1182
1182
  (p) => {
1183
1183
  const s = L();
1184
- b({ comments: s.comments.map((i) => i.id === p ? { ...i, resolved: !0 } : i) });
1184
+ y({ comments: s.comments.map((i) => i.id === p ? { ...i, resolved: !0 } : i) });
1185
1185
  },
1186
1186
  (p) => {
1187
1187
  const s = L();
1188
- b({ comments: s.comments.map((i) => i.id === p ? { ...i, resolved: !1 } : i) });
1188
+ y({ comments: s.comments.map((i) => i.id === p ? { ...i, resolved: !1 } : i) });
1189
1189
  },
1190
1190
  (p) => {
1191
1191
  const s = L();
1192
- b({ comments: s.comments.filter((i) => i.id !== p) }), t.delete(p);
1192
+ y({ comments: s.comments.filter((i) => i.id !== p) }), t.delete(p);
1193
1193
  },
1194
1194
  // When a reply is added in the detail view, update badge count immediately
1195
1195
  (p) => {
1196
1196
  const s = t.get(e.id) ?? [];
1197
1197
  t.set(e.id, [...s, p]);
1198
1198
  const i = L();
1199
- b({ comments: [...i.comments] });
1199
+ y({ comments: [...i.comments] });
1200
1200
  }
1201
1201
  );
1202
1202
  }), d;
@@ -1213,7 +1213,7 @@ async function ue() {
1213
1213
  return (await import("./html2canvas.esm-d2sM-0Wm.mjs")).default;
1214
1214
  }
1215
1215
  async function fe(e) {
1216
- const t = window.scrollX, r = window.scrollY;
1216
+ const t = window.scrollX, o = window.scrollY;
1217
1217
  window.scrollTo(0, 0);
1218
1218
  try {
1219
1219
  return (await e(document.body, {
@@ -1227,10 +1227,10 @@ async function fe(e) {
1227
1227
  windowHeight: document.documentElement.scrollHeight,
1228
1228
  x: 0,
1229
1229
  y: 0,
1230
- ignoreElements: (o) => o.tagName === "UI-FEEDBACK-PLUGIN"
1230
+ ignoreElements: (r) => r.tagName === "UI-FEEDBACK-PLUGIN"
1231
1231
  })).toDataURL("image/png");
1232
1232
  } finally {
1233
- window.scrollTo(t, r);
1233
+ window.scrollTo(t, o);
1234
1234
  }
1235
1235
  }
1236
1236
  function me() {
@@ -1241,50 +1241,34 @@ function me() {
1241
1241
  }
1242
1242
  const q = "ui-feedback-plugin";
1243
1243
  async function he(e) {
1244
- const t = e.database;
1244
+ const { backend: t } = e;
1245
1245
  if (t.provider === "firebase") {
1246
- const { FirebaseAdapter: r } = await import("./firebase-BGU5KpRU.mjs");
1247
- return new r(t);
1246
+ const { FirebaseAdapter: o } = await import("./firebase-BGU5KpRU.mjs"), n = new o(t);
1247
+ return { db: n, screenshot: n };
1248
1248
  }
1249
1249
  if (t.provider === "supabase") {
1250
- const { SupabaseAdapter: r } = await import("./supabase-BUHP2OkK.mjs");
1251
- return new r(t.url, t.anonKey);
1250
+ const { SupabaseAdapter: o } = await import("./supabase-BUHP2OkK.mjs"), n = new o(t.url, t.anonKey);
1251
+ return { db: n, screenshot: n };
1252
1252
  }
1253
- throw new Error("[ui-feedback-plugin] Unknown database provider");
1254
- }
1255
- async function ge(e, t) {
1256
- const r = e.screenshots;
1257
- if (!r)
1258
- return t;
1259
- if (r.provider === "s3") {
1260
- const { S3ScreenshotAdapter: n } = await import("./s3-DkzKoz0A.mjs");
1261
- return new n(r.uploadEndpoint, r.headers);
1262
- }
1263
- if (r.provider === "firebase") {
1264
- if (e.database.provider !== "firebase")
1265
- throw new Error('[ui-feedback-plugin] screenshots.provider "firebase" requires database.provider "firebase"');
1266
- return t;
1267
- }
1268
- if (r.provider === "supabase") {
1269
- if (e.database.provider !== "supabase")
1270
- throw new Error('[ui-feedback-plugin] screenshots.provider "supabase" requires database.provider "supabase"');
1271
- return t;
1253
+ if (t.provider === "s3") {
1254
+ const { S3Adapter: o } = await import("./s3-4V57aJiZ.mjs"), n = new o(t.apiUrl, t.headers, t.pollInterval);
1255
+ return { db: n, screenshot: n };
1272
1256
  }
1273
- throw new Error("[ui-feedback-plugin] Unknown screenshot storage provider");
1257
+ throw new Error("[ui-feedback-plugin] Unknown backend provider");
1274
1258
  }
1275
- function be(e) {
1259
+ function xe(e) {
1276
1260
  var d;
1277
1261
  if (customElements.get(q))
1278
1262
  return console.warn("[ui-feedback-plugin] Already initialized."), () => {
1279
1263
  };
1280
- const t = ((d = e.theme) == null ? void 0 : d.primaryColor) ?? "#6366f1", r = e.projectKey ?? "default", n = e.position ?? "bottom-right";
1281
- b({ config: e });
1282
- class o extends HTMLElement {
1264
+ const t = ((d = e.theme) == null ? void 0 : d.primaryColor) ?? "#6366f1", o = e.projectKey ?? "default", n = e.position ?? "bottom-right";
1265
+ y({ config: e });
1266
+ class r extends HTMLElement {
1283
1267
  constructor() {
1284
1268
  super();
1285
1269
  H(this, "shadow");
1286
- H(this, "dbAdapter");
1287
- H(this, "screenshotAdapter");
1270
+ H(this, "db");
1271
+ H(this, "screenshot");
1288
1272
  H(this, "unsubscribe", null);
1289
1273
  this.shadow = this.attachShadow({ mode: "open" });
1290
1274
  }
@@ -1292,9 +1276,10 @@ function be(e) {
1292
1276
  const s = document.createElement("style");
1293
1277
  s.textContent = Q(t), this.shadow.appendChild(s);
1294
1278
  try {
1295
- this.dbAdapter = await he(e), this.screenshotAdapter = await ge(e, this.dbAdapter);
1279
+ const i = await he(e);
1280
+ this.db = i.db, this.screenshot = i.screenshot;
1296
1281
  } catch (i) {
1297
- console.error("[ui-feedback-plugin] Failed to initialize adapters:", i);
1282
+ console.error("[ui-feedback-plugin] Failed to initialise backend:", i);
1298
1283
  return;
1299
1284
  }
1300
1285
  this.mount();
@@ -1304,37 +1289,37 @@ function be(e) {
1304
1289
  (s = this.unsubscribe) == null || s.call(this);
1305
1290
  }
1306
1291
  mount() {
1307
- const s = U(window.location.href);
1308
- pe(this.shadow, this.dbAdapter, () => this.startAnnotation()), ee(
1292
+ const s = I(window.location.href);
1293
+ pe(this.shadow, this.db, () => this.startAnnotation()), ee(
1309
1294
  this.shadow,
1310
1295
  n,
1311
1296
  () => this.startAnnotation(),
1312
- () => b({ panelOpen: !L().panelOpen })
1313
- ), this.unsubscribe = this.dbAdapter.subscribeToComments(s, r, (i) => {
1314
- b({ comments: i });
1297
+ () => y({ panelOpen: !L().panelOpen })
1298
+ ), this.unsubscribe = this.db.subscribeToComments(s, o, (i) => {
1299
+ y({ comments: i });
1315
1300
  });
1316
1301
  }
1317
1302
  async startAnnotation() {
1318
1303
  let s = X();
1319
1304
  if (!s && (s = await ne(this.shadow), !s))
1320
1305
  return;
1321
- b({ active: !0, panelOpen: !1 });
1306
+ y({ active: !0, panelOpen: !1 });
1322
1307
  const i = await ie(this.shadow);
1323
1308
  if (!i) {
1324
- b({ active: !1 });
1309
+ y({ active: !1 });
1325
1310
  return;
1326
1311
  }
1327
- b({ active: !1 }), this.showToast("Saving comment…", "info");
1312
+ y({ active: !1 }), this.showToast("Saving comment…", "info");
1328
1313
  try {
1329
1314
  await this.saveComment(s, i.text, i.shapes), this.showToast("Comment saved!", "success");
1330
1315
  } catch (u) {
1331
1316
  console.error("[ui-feedback-plugin] Failed to save comment:", u), this.showToast("Failed to save — check the browser console for details.", "error");
1332
1317
  return;
1333
1318
  }
1334
- b({ panelOpen: !0 });
1319
+ y({ panelOpen: !0 });
1335
1320
  }
1336
1321
  async saveComment(s, i, u) {
1337
- const w = U(window.location.href), h = {
1322
+ const w = I(window.location.href), h = {
1338
1323
  shapes: u,
1339
1324
  pageWidth: document.documentElement.scrollWidth,
1340
1325
  pageHeight: document.documentElement.scrollHeight
@@ -1348,15 +1333,15 @@ function be(e) {
1348
1333
  }
1349
1334
  const E = {
1350
1335
  pageUrl: w,
1351
- projectKey: r,
1336
+ projectKey: o,
1352
1337
  authorName: s,
1353
1338
  text: i,
1354
1339
  screenshotUrl: "",
1355
1340
  annotation: h,
1356
1341
  resolved: !1,
1357
1342
  createdAt: Date.now()
1358
- }, f = await this.dbAdapter.addComment(E), v = await this.screenshotAdapter.uploadScreenshot(f, k);
1359
- await this.dbAdapter.updateComment(f, { screenshotUrl: v });
1343
+ }, f = await this.db.addComment(E), b = await this.screenshot.uploadScreenshot(f, k);
1344
+ await this.db.updateComment(f, { screenshotUrl: b });
1360
1345
  }
1361
1346
  showToast(s, i) {
1362
1347
  const u = this.shadow.querySelector(".ufp-toast");
@@ -1372,11 +1357,11 @@ function be(e) {
1372
1357
  `, h.textContent = s, this.shadow.appendChild(h), setTimeout(() => h.remove(), i === "error" ? 6e3 : 2500);
1373
1358
  }
1374
1359
  }
1375
- customElements.define(q, o);
1360
+ customElements.define(q, r);
1376
1361
  const a = document.createElement(q);
1377
1362
  return document.body.appendChild(a), () => a.remove();
1378
1363
  }
1379
1364
  export {
1380
- be as initFeedbackPlugin
1365
+ xe as initFeedbackPlugin
1381
1366
  };
1382
1367
  //# sourceMappingURL=ui-feedback-plugin.es.js.map