@popgrids/embed 0.0.1 → 0.0.2

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 (56) hide show
  1. package/AGENTS.md +141 -0
  2. package/LICENSE +21 -0
  3. package/README.md +60 -1
  4. package/dist/components/base-element.d.ts +33 -0
  5. package/dist/components/base-element.d.ts.map +1 -0
  6. package/dist/components/pop-auth-panel.d.ts +14 -0
  7. package/dist/components/pop-auth-panel.d.ts.map +1 -0
  8. package/dist/components/pop-comment-avatar.d.ts +16 -0
  9. package/dist/components/pop-comment-avatar.d.ts.map +1 -0
  10. package/dist/components/pop-comment-bar.d.ts +14 -0
  11. package/dist/components/pop-comment-bar.d.ts.map +1 -0
  12. package/dist/components/pop-comment-icon.d.ts +33 -0
  13. package/dist/components/pop-comment-icon.d.ts.map +1 -0
  14. package/dist/components/pop-comment-input.d.ts +19 -0
  15. package/dist/components/pop-comment-input.d.ts.map +1 -0
  16. package/dist/components/pop-comment-thread.d.ts +14 -0
  17. package/dist/components/pop-comment-thread.d.ts.map +1 -0
  18. package/dist/components/pop-comment.d.ts +32 -0
  19. package/dist/components/pop-comment.d.ts.map +1 -0
  20. package/dist/components/pop-feed.d.ts +17 -0
  21. package/dist/components/pop-feed.d.ts.map +1 -0
  22. package/dist/components/pop-grid.d.ts +12 -0
  23. package/dist/components/pop-grid.d.ts.map +1 -0
  24. package/dist/components/pop-widget.d.ts +13 -0
  25. package/dist/components/pop-widget.d.ts.map +1 -0
  26. package/dist/embed.js +2240 -0
  27. package/dist/embed.js.map +1 -0
  28. package/dist/helpers/author.d.ts +2 -0
  29. package/dist/helpers/author.d.ts.map +1 -0
  30. package/dist/helpers/color.d.ts +7 -0
  31. package/dist/helpers/color.d.ts.map +1 -0
  32. package/dist/helpers/theme.d.ts +3 -0
  33. package/dist/helpers/theme.d.ts.map +1 -0
  34. package/dist/helpers/time.d.ts +2 -0
  35. package/dist/helpers/time.d.ts.map +1 -0
  36. package/dist/index.cjs +1135 -741
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.ts +2 -989
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +1246 -1045
  41. package/dist/index.js.map +1 -1
  42. package/dist/lib/popup-auth.d.ts +22 -0
  43. package/dist/lib/popup-auth.d.ts.map +1 -0
  44. package/dist/store/auth-store.d.ts +8 -0
  45. package/dist/store/auth-store.d.ts.map +1 -0
  46. package/dist/store/grid-store.d.ts +45 -0
  47. package/dist/store/grid-store.d.ts.map +1 -0
  48. package/dist/store/registry.d.ts +5 -0
  49. package/dist/store/registry.d.ts.map +1 -0
  50. package/dist/types/models.d.ts +47 -0
  51. package/dist/types/models.d.ts.map +1 -0
  52. package/package.json +55 -45
  53. package/dist/apple-IX52EWYN.png +0 -0
  54. package/dist/google-Q3MFTU5A.png +0 -0
  55. package/dist/index.d.cts +0 -989
  56. package/dist/swirling-ovals-ZDTHSA3L.gif +0 -0
package/dist/index.js CHANGED
@@ -1,1071 +1,1272 @@
1
- var _t=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var Tt=Object.getPrototypeOf;var Mt=Reflect.get;var i=(s,a,t,e)=>{for(var r=e>1?void 0:e?Et(a,t):a,n=s.length-1,o;n>=0;n--)(o=s[n])&&(r=(e?o(a,t,r):o(r))||r);return e&&r&&_t(a,t,r),r};var l=(s,a,t)=>Mt(Tt(s),t,a);import{PopElement as Ht}from"@popgrids/ui";import{html as $t}from"lit";import{customElement as Bt}from"lit/decorators.js";import{classMap as zt}from"lit/directives/class-map.js";import{css as qt,unsafeCSS as Lt}from"lit";var F="./swirling-ovals-ZDTHSA3L.gif";var Z=qt`
2
- :host {
3
- display: flex;
4
- width: 100%;
5
- }
6
-
7
- .auth-join {
8
- background-image: url("${Lt(F)}"), none;
9
- background-color: lightgray;
10
- background-position: 79% center;
11
- background-size:
12
- 8.215% 59.149%,
13
- auto;
14
- background-repeat: no-repeat, repeat;
15
- background-color: var(--color-surface-bg-default, #fff);
16
- border: none;
17
- display: flex;
18
- align-items: flex-start;
19
- flex-direction: column;
20
- gap: var(--spacing-sm, 6px);
21
- justify-content: flex-end;
22
- padding: var(--spacing-xl, 16px) var(--spacing-md, 8px);
23
- width: 100%;
24
- }
25
-
26
- .auth-join__actions {
27
- color: var(--color-text-text-default, #000);
28
- font-feature-settings:
29
- "liga" off,
30
- "clig" off;
31
- display: flex;
32
- padding: 0px var(--spacing-md, 8px);
33
- justify-content: space-between;
34
- align-items: center;
35
- align-self: stretch;
36
- font-size: var(--text-widget-base);
37
- line-height: var(--text-widget-base--line-height);
38
- letter-spacing: var(--text-widget-base--letter-spacing);
39
- font-weight: 600;
40
- }
41
-
42
- .auth-join__logo {
43
- display: flex;
44
- width: 75px;
45
- height: 12px;
46
- padding: 0px var(--spacing-none, 0px);
47
- flex-direction: column;
48
- justify-content: center;
49
- align-items: center;
50
- color: var(--color-text-text-default, #000);
51
- }
52
- `;var j=class extends Ht{handleClick(){this.emit("pop-click")}render(){return $t` <button
53
- class=${zt({"auth-join":!0})}
54
- part="base"
55
- type="button"
56
- @click=${this.handleClick}
57
- >
58
- <div class="auth-join__actions">
59
- Join the Conversation
60
- <svg
61
- class="auth-join__logo"
62
- width="75"
63
- height="12"
64
- viewBox="0 0 75 12"
65
- fill="none"
66
- xmlns="http://www.w3.org/2000/svg"
67
- >
68
- <path
69
- d="M4.58333 0.265686C1.0463 0.265686 0 2.5714 0 5.47711C0 6.55283 0.115741 7.6114 0.25 8.67426C0.300926 9.08997 0.282407 9.54854 0.365741 9.96426C0.583333 11.0571 1.69444 11.5628 2.77315 11.5628C4.25 11.5628 5.23148 10.7014 5.23148 9.3214C5.23148 8.52426 4.94907 8.0014 4.13426 7.69283C4.08333 7.67569 4.03241 7.66283 4.03241 7.59854C4.03241 7.4914 4.21759 7.41426 4.33333 7.41426C4.73148 7.41426 5.36111 7.78283 5.91204 7.78283C8.06944 7.78283 9.26389 5.86283 9.26389 4.06283C9.26389 1.44854 7.18518 0.265686 4.58333 0.265686ZM4.56481 5.91854C4.43056 5.91854 4.31481 5.8114 4.31481 5.68711C4.31481 5.51997 4.56481 5.39569 4.64815 5.25854C4.8287 4.94997 4.87963 4.42711 4.87963 4.07569C4.87963 3.65997 4.76389 2.89283 4.48148 2.58426C4.39815 2.49426 4.28241 2.44711 4.28241 2.32283C4.28241 2.19854 4.41667 2.0914 4.5463 2.0914C5.11111 2.0914 5.39352 3.62997 5.39352 4.02854C5.39352 4.45711 5.24537 5.91854 4.56481 5.91854Z"
70
- fill="currentColor"
71
- />
72
- <path
73
- d="M14.9259 0.527108C11.4074 0.527108 9.2963 2.83282 9.2963 5.99568C9.2963 9.15854 11.4028 11.4643 14.9259 11.4643C18.4491 11.4643 20.537 9.12854 20.537 5.99568C20.537 2.86282 18.412 0.527108 14.9259 0.527108ZM15.0787 9.89997C15.0232 9.96425 14.912 10.0843 14.7778 10.0843C14.6435 10.0843 14.5139 9.97711 14.5139 9.85282C14.5139 9.80568 14.9445 9.20568 15.0139 9.02139C15.2778 8.29711 15.3287 7.51282 15.3287 6.74568C15.3287 5.71711 15.1296 4.39282 14.4491 3.54854C14.3148 3.39425 13.9028 3.10282 13.9028 2.93568C13.9028 2.81139 14.0185 2.70425 14.1528 2.70425C14.2685 2.70425 14.3843 2.79854 14.4676 2.85854C15.5278 3.67282 15.8472 5.53282 15.8472 6.74568C15.8472 7.69711 15.8056 9.08568 15.0833 9.89568L15.0787 9.89997Z"
74
- fill="currentColor"
75
- />
76
- <path
77
- d="M25.375 0.265686C21.838 0.265686 20.7917 2.5714 20.7917 5.47711C20.7917 6.55283 20.9074 7.6114 21.0417 8.67426C21.0926 9.08997 21.0741 9.54854 21.1574 9.96426C21.375 11.0571 22.4861 11.5628 23.5648 11.5628C25.0417 11.5628 26.0231 10.7014 26.0231 9.3214C26.0231 8.52426 25.7407 8.0014 24.9259 7.69283C24.875 7.67569 24.8241 7.66283 24.8241 7.59854C24.8241 7.4914 25.0092 7.41426 25.125 7.41426C25.5231 7.41426 26.1528 7.78283 26.7037 7.78283C28.8611 7.78283 30.0555 5.86283 30.0555 4.06283C30.0555 1.44854 27.9815 0.265686 25.375 0.265686ZM25.3611 5.91854C25.2268 5.91854 25.1111 5.8114 25.1111 5.68711C25.1111 5.51997 25.3611 5.39569 25.4444 5.25854C25.625 4.94997 25.6759 4.42711 25.6759 4.07569C25.6759 3.65997 25.5602 2.89283 25.2778 2.58426C25.1944 2.49426 25.0787 2.44711 25.0787 2.32283C25.0787 2.19854 25.213 2.0914 25.3426 2.0914C25.9074 2.0914 26.1898 3.62997 26.1898 4.02854C26.1898 4.45711 26.0417 5.91854 25.3611 5.91854Z"
78
- fill="currentColor"
79
- />
80
- <path
81
- d="M37.3843 4.81284C36.1898 4.81284 34.5278 5.31855 34.5278 6.64284C34.5278 7.39713 35.125 8.5157 36.0741 8.5157C36.6713 8.5157 37.0556 8.08713 37.2546 8.08713C37.3056 8.08713 37.3519 8.11713 37.3519 8.16427C37.3519 8.60998 36.4213 8.81141 36.0556 8.81141C34.7778 8.81141 34.0972 7.7957 34.0972 6.71998C34.0972 5.39998 35.4398 4.38427 36.8009 4.38427C37.1991 4.38427 37.6158 4.49141 38.0139 4.49141C39.1945 4.49141 40.0371 3.50998 40.0371 2.46427C40.0371 0.728554 37.8148 0.329982 36.3333 0.329982C32.3982 0.329982 30.1065 2.6957 30.1065 6.29141C30.1065 9.61284 31.9676 11.73 35.6528 11.73C38.0417 11.73 40.6482 10.7786 40.6482 8.19427C40.6482 6.42855 39.4028 4.81284 37.3796 4.81284H37.3843Z"
82
- fill="currentColor"
83
- />
84
- <path
85
- d="M48.3611 7.42711C48.0602 7.42711 47.8148 7.53426 47.5648 7.53426C47.5139 7.53426 47.5 7.48711 47.5 7.45712C47.5 7.34997 47.5509 7.30283 47.6342 7.27283C47.9167 7.18283 48.2176 7.11854 48.4954 6.99426C49.7592 6.4414 50.5046 5.45569 50.5046 4.15283C50.5046 1.79997 48.3287 0.372829 45.9398 0.372829C45.0741 0.372829 44.2315 0.604257 43.5 0.972829C41.5092 1.9714 41.125 3.40283 41.0092 5.35283C40.9583 6.11997 40.9583 6.8914 40.9583 7.65854V9.51854C40.9583 10.6843 41.787 11.6228 43.0972 11.6228C44.0416 11.6228 44.8889 10.9928 45.1065 10.1614C45.2222 9.66854 45.1574 9.08569 45.1574 8.60997C45.1574 8.56283 45.1759 8.54997 45.2222 8.54997C45.2685 8.54997 45.3241 8.57997 45.3565 8.59711C45.9398 9.90426 46.7361 11.5628 48.5417 11.5628C49.787 11.5628 50.8148 10.7485 50.8148 9.56569C50.8148 8.38283 49.6204 7.4314 48.3565 7.4314L48.3611 7.42711ZM45.6574 5.91854C45.5231 5.91854 45.4074 5.8114 45.4074 5.68711C45.4074 5.51997 45.6574 5.39569 45.7407 5.25854C45.9213 4.94997 45.9722 4.42711 45.9722 4.07569C45.9722 3.65997 45.8565 2.89283 45.5741 2.58426C45.4907 2.49426 45.3935 2.44711 45.3935 2.32283C45.3935 2.19854 45.5092 2.0914 45.6435 2.0914C46.2083 2.0914 46.4907 3.62997 46.4907 4.02854C46.4907 4.45711 46.3565 5.91854 45.662 5.91854H45.6574Z"
86
- fill="currentColor"
87
- />
88
- <path
89
- d="M54.8056 0.865677C54.4074 0.621391 53.8426 0.497105 53.3611 0.497105C52.3148 0.497105 51.4167 1.26425 51.3009 2.21996C51.2685 2.49853 51.2824 2.75996 51.2824 3.05139V5.66139L51.2315 8.41282V9.77996C51.2315 10.8557 52.2269 11.7 53.375 11.7C54.2222 11.7 55.1528 11.2071 55.4676 10.47C55.6482 10.0542 55.6667 9.47139 55.6667 9.02568V7.82568L55.6852 5.42996V3.03425C55.6852 2.14282 55.6667 1.43568 54.8056 0.865677Z"
90
- fill="currentColor"
91
- />
92
- <path
93
- d="M58.9445 0.402828C57.25 0.402828 56.4028 1.13997 56.4028 2.7214V3.3514L56.4213 4.59426V5.22426C56.4213 5.69997 56.4213 6.14568 56.4028 6.6214C56.3704 7.1914 56.287 7.75711 56.287 8.34426C56.287 10.4957 57.4815 11.5414 59.7917 11.5414C63.3426 11.5414 65.75 10.1271 65.75 6.60854C65.75 2.36568 63.5417 0.398542 58.9445 0.398542V0.402828ZM60.537 8.9014C60.4028 8.9014 60.287 8.79426 60.287 8.66997C60.287 8.62283 60.3056 8.59283 60.338 8.54568C60.7685 7.88568 60.8843 6.96426 60.8843 6.20997C60.8843 5.50283 60.8009 4.45711 60.3194 3.90426C60.2361 3.77997 60.0695 3.68997 60.0695 3.53569C60.0695 3.4114 60.1852 3.30426 60.3194 3.30426C60.5694 3.30426 60.9167 3.88711 61.0185 4.08854C61.3333 4.76569 61.3843 5.50283 61.3843 6.22283C61.3843 6.66854 61.1343 8.89711 60.537 8.89711V8.9014Z"
94
- fill="currentColor"
95
- />
96
- <path
97
- d="M73.5046 5.85855C72.5417 5.78141 71.162 5.47284 70.4167 4.88998C70.3194 4.81284 70.1528 4.7057 70.1528 4.56855C70.1528 4.52141 70.1713 4.44427 70.2361 4.44427C70.4167 4.44427 71.5787 5.3057 72.5787 5.3057C73.8426 5.3057 75 4.39713 75 3.20141C75 1.23427 72.1806 0.437125 70.4676 0.437125C67.9259 0.437125 66.037 1.95855 66.037 4.37141C66.037 4.89427 66.1204 5.61427 66.537 6.01713C66.7361 6.21855 67.0694 6.21855 67.3333 6.21855C68.3287 6.21855 69.5926 6.50998 70.1204 7.35427C70.1713 7.43141 70.2176 7.5557 70.2176 7.6457C70.2176 7.6757 70.2176 7.72284 70.1852 7.7057C70.088 7.6757 70.0046 7.59855 69.9352 7.53855C69.3519 7.0157 68.5555 6.49284 67.713 6.49284C66.4491 6.49284 66.0046 7.6157 66.0046 8.59713C66.0046 10.5771 67.9306 11.67 69.8889 11.67C72.213 11.67 75 10.2557 75 7.84284C75 6.95141 74.5833 5.95284 73.5046 5.86284V5.85855Z"
98
- fill="currentColor"
99
- />
100
- </svg>
1
+ import { computed as e, effect as t, signal as n, untracked as r } from "@preact/signals-core";
2
+ import { autoUpdate as i, computePosition as a, flip as o, offset as s, platform as c, shift as l } from "@floating-ui/dom";
3
+ var u = "/embed/auth/login", d = "popgrids-auth", f = "popup,width=480,height=640", ee = 300 * 1e3, te = 250, p = class extends Error {
4
+ constructor(e) {
5
+ super(e), this.name = "PopupAuthError";
6
+ }
7
+ }, m = (e, t, n) => {
8
+ let r = new URL(u, e);
9
+ return r.searchParams.set("publicKey", t), r.searchParams.set("returnOrigin", n), r.toString();
10
+ }, ne = (e, t) => {
11
+ let n = window.open(m(e, t, window.location.origin), d, f);
12
+ if (!n) throw new p("Popup blocked. Allow popups for this site and try again.");
13
+ return n;
14
+ }, h = (e, t) => typeof e == "object" && !!e && "type" in e && "source" in e && e.type === t && e.source === "popgrids-embed", re = (e) => {
15
+ if (typeof e != "object" || !e || !("user" in e)) return null;
16
+ let t = e.user;
17
+ if (typeof t != "object" || !t || !("id" in t)) return null;
18
+ let n = t;
19
+ return typeof n.id == "string" ? {
20
+ id: n.id,
21
+ name: typeof n.name == "string" ? n.name : "",
22
+ email: typeof n.email == "string" ? n.email : "",
23
+ image: typeof n.image == "string" ? n.image : null
24
+ } : null;
25
+ }, ie = (e, t, n) => new Promise((r, i) => {
26
+ let a = new URL(e).origin, o = !1, s = !1, c = !1, l = (e, t) => {
27
+ if (!o) {
28
+ if (o = !0, m(), e === "resolve") {
29
+ r();
30
+ return;
31
+ }
32
+ i(t ?? new p("Sign-in failed"));
33
+ }
34
+ }, u = (e) => {
35
+ if (e.origin === a) {
36
+ if (h(e.data, "popgrids:auth:success")) {
37
+ s = !0;
38
+ let t = re(e.data);
39
+ t && n?.onAuthUser?.(t), l("resolve");
40
+ return;
41
+ }
42
+ h(e.data, "popgrids:auth:error") && (s = !0, l("reject", new p(typeof e.data == "object" && e.data !== null && "error" in e.data && typeof e.data.error == "string" ? e.data.error : "Sign-in failed")));
43
+ }
44
+ }, d = window.setInterval(() => {
45
+ t.closed && (c || (c = !0, (async () => {
46
+ if (await new Promise((e) => window.setTimeout(e, te)), !(s || o)) {
47
+ if (n?.verifySignedIn && await n.verifySignedIn()) {
48
+ l("resolve");
49
+ return;
50
+ }
51
+ l("reject", new p("Sign-in was cancelled"));
52
+ }
53
+ })()));
54
+ }, 300), f = window.setTimeout(() => {
55
+ try {
56
+ t.close();
57
+ } catch {}
58
+ l("reject", new p("Sign-in timed out"));
59
+ }, ee), m = () => {
60
+ window.removeEventListener("message", u), clearInterval(d), clearTimeout(f);
61
+ };
62
+ window.addEventListener("message", u);
63
+ }), ae = async (e, t, n) => {
64
+ await ie(e, ne(e, t), n);
65
+ }, g = n(null), _ = n(null), v = n(!1), oe = [
66
+ 0,
67
+ 150,
68
+ 400
69
+ ], y = [
70
+ 0,
71
+ 100,
72
+ 200,
73
+ 400,
74
+ 800,
75
+ 1500,
76
+ 2500,
77
+ 4e3
78
+ ];
79
+ async function b(e, t, n = oe) {
80
+ if (!e || !t) return g.value = null, !1;
81
+ let r = new URL(`/api/v1/embed/grids/${t}/session`, e);
82
+ r.searchParams.set("pageUrl", window.location.href);
83
+ for (let e = 0; e < n.length; e++) {
84
+ let t = n[e] ?? 0;
85
+ t > 0 && await new Promise((e) => window.setTimeout(e, t));
86
+ try {
87
+ let e = await fetch(r, { credentials: "include" });
88
+ if (!e.ok) continue;
89
+ if (g.value = (await e.json()).user ?? null, g.value !== null) return !0;
90
+ } catch {}
91
+ }
92
+ return g.value = null, !1;
93
+ }
94
+ async function x(e, t) {
95
+ _.value = null, v.value = !0;
96
+ try {
97
+ return await ae(e, t, {
98
+ onAuthUser: (e) => {
99
+ g.value = e;
100
+ },
101
+ verifySignedIn: () => b(e, t, y)
102
+ }), g.value ? !0 : await b(e, t, y);
103
+ } catch (e) {
104
+ return _.value = e instanceof Error ? e.message : "Sign-in failed", !1;
105
+ } finally {
106
+ v.value = !1;
107
+ }
108
+ }
109
+ function se() {
110
+ _.value = null;
111
+ }
112
+ //#endregion
113
+ //#region src/store/registry.ts
114
+ var S = /* @__PURE__ */ new WeakMap(), ce = (e, t, n = t.constructor) => {
115
+ let r = S.get(e);
116
+ r || (r = /* @__PURE__ */ new Map(), S.set(e, r)), r.set(n, t);
117
+ }, le = (e) => {
118
+ S.delete(e);
119
+ }, ue = (e, t) => {
120
+ let n = e;
121
+ for (; n;) {
122
+ let e = S.get(n)?.get(t);
123
+ if (e) return e;
124
+ let r = n.getRootNode();
125
+ if (!(r instanceof ShadowRoot)) break;
126
+ n = r.host;
127
+ }
128
+ return null;
129
+ };
130
+ function C(e) {
131
+ return function(t, n) {
132
+ let r = Symbol("context_" + (e.name || "store"));
133
+ Object.defineProperty(t, n, {
134
+ get() {
135
+ if (this[r]) return this[r];
136
+ let t = ue(this, e);
137
+ if (!t) throw console.error(`[Context] resolveStore failed! isConnected: ${this.isConnected}`, this), Error(`[Context] Store for key "${e.name || e}" not resolved on <${this.localName}>.`);
138
+ return this[r] = t, t;
139
+ },
140
+ enumerable: !0,
141
+ configurable: !0
142
+ });
143
+ };
144
+ }
145
+ //#endregion
146
+ //#region src/store/grid-store.ts
147
+ var de = 3e4, w = 3, T = (e) => {
148
+ let t = typeof e.createdAt == "number" ? e.createdAt : Date.parse(String(e.createdAt));
149
+ return Number.isFinite(t) ? t : 0;
150
+ }, E = (e, t) => {
151
+ let n = e?.previewCount ?? t;
152
+ return n > 0 ? n : w;
153
+ }, D = class {
154
+ constructor(t) {
155
+ this.previewCount = w, this.grid = n(null), this.comments = n([]), this.loading = n(!0), this.error = n(null), this.open = n(!1), this.replyingTo = n(null), this.editingCommentId = n(null), this.scrollingCommentId = n(null), this.socket = null, this.reconnectAttempt = 0, this.reconnectTimer = null, this.disposed = !1, this.topLevelComments = e(() => this.comments.value.filter((e) => e.parentCommentId === null).sort((e, t) => String(e.sortKey).localeCompare(String(t.sortKey)))), this.replyingToComment = e(() => {
156
+ let e = this.replyingTo.value;
157
+ return e ? this.comments.value.find((t) => t.id === e) ?? null : null;
158
+ }), this.editingComment = e(() => {
159
+ let e = this.editingCommentId.value;
160
+ return e ? this.comments.value.find((t) => t.id === e) ?? null : null;
161
+ }), this.previewComments = e(() => this.topLevelComments.value.slice(0, E(this.grid.value, this.previewCount))), this.previewAvatars = e(() => {
162
+ let e = E(this.grid.value, this.previewCount), t = /* @__PURE__ */ new Set(), n = [], r = [...this.comments.value].sort((e, t) => T(t) - T(e));
163
+ for (let i of r) {
164
+ let r = i.author;
165
+ if (!(!r?.id || t.has(r.id)) && (t.add(r.id), n.push(r), n.length >= e)) break;
166
+ }
167
+ return n.reverse();
168
+ }), this.apiUrl = t.apiUrl, this.publicKey = t.publicKey, this.pageUrl = t.pageUrl, this.externalId = t.externalId?.trim() || null;
169
+ }
170
+ identityParams() {
171
+ let e = new URLSearchParams({ pageUrl: this.pageUrl });
172
+ return this.externalId && e.set("externalId", this.externalId), e.toString();
173
+ }
174
+ repliesFor(e) {
175
+ let t = this.comments.value.find((t) => t.id === e);
176
+ return t ? this.comments.value.filter((n) => n.id !== e && (n.sortKey === t.sortKey || n.sortKey.startsWith(t.sortKey + "/"))).sort((e, t) => String(e.sortKey).localeCompare(String(t.sortKey))) : [];
177
+ }
178
+ async load() {
179
+ this.loading.value = !0, this.error.value = null;
180
+ try {
181
+ let e = await fetch(`${this.apiUrl}/api/v1/embed/grids/${this.publicKey}`, { credentials: "include" });
182
+ if (!e.ok) return this.error.value = "There was a problem loading the PopGrid", !1;
183
+ let t = await e.json();
184
+ this.grid.value = t.grid, this.connectRealtime();
185
+ let n = await fetch(`${this.apiUrl}/api/v1/embed/grids/${this.publicKey}/comments?${this.identityParams()}`, { credentials: "include" });
186
+ if (n.ok) {
187
+ let e = await n.json();
188
+ this.comments.value = e.comments;
189
+ }
190
+ return !0;
191
+ } catch {
192
+ return console.error("Failed to load PopGrid"), this.error.value = "There was a problem loading the PopGrid", !1;
193
+ } finally {
194
+ this.loading.value = !1;
195
+ }
196
+ }
197
+ async postComment(e, t) {
198
+ let n = async () => fetch(`${this.apiUrl}/api/v1/embed/grids/${this.publicKey}/comments`, {
199
+ method: "POST",
200
+ credentials: "include",
201
+ headers: { "Content-Type": "application/json" },
202
+ body: JSON.stringify({
203
+ body: e,
204
+ pageUrl: this.pageUrl,
205
+ externalId: this.externalId ?? void 0,
206
+ parentCommentId: t
207
+ })
208
+ }), r = await n();
209
+ if (r.status === 401) {
210
+ if (!await x(this.apiUrl, this.publicKey)) return null;
211
+ r = await n();
212
+ }
213
+ if (!r.ok) return null;
214
+ let i = await r.json();
215
+ return this.upsertComment(i.comment), i.comment.author && !g.value && (g.value = {
216
+ id: i.comment.author.id,
217
+ name: i.comment.author.name ?? "",
218
+ email: "",
219
+ image: i.comment.author.image
220
+ }), i.comment;
221
+ }
222
+ destroy() {
223
+ this.disposed = !0, this.reconnectTimer &&= (clearTimeout(this.reconnectTimer), null), this.socket &&= (this.socket.onopen = null, this.socket.onmessage = null, this.socket.onclose = null, this.socket.onerror = null, this.socket.close(), null);
224
+ }
225
+ connectRealtime() {
226
+ let e = this.grid.value?.connectUrl;
227
+ if (!e || this.disposed) return;
228
+ this.socket &&= (this.socket.onopen = null, this.socket.onmessage = null, this.socket.onclose = null, this.socket.onerror = null, this.socket.close(), null);
229
+ let t = new URL(e, this.apiUrl);
230
+ t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.searchParams.set("pageUrl", this.pageUrl), this.externalId && t.searchParams.set("externalId", this.externalId);
231
+ let n = new WebSocket(t.toString());
232
+ this.socket = n, n.onopen = () => {
233
+ this.reconnectAttempt = 0;
234
+ }, n.onmessage = (e) => {
235
+ try {
236
+ let t = JSON.parse(String(e.data));
237
+ t.type === "comment.created" && t.comment ? this.upsertComment(t.comment) : t.type === "comment.updated" && t.comment && this.updateCommentInList(t.comment);
238
+ } catch {}
239
+ }, n.onclose = () => {
240
+ this.disposed || this.scheduleReconnect();
241
+ }, n.onerror = () => {
242
+ n.close();
243
+ };
244
+ }
245
+ scheduleReconnect() {
246
+ if (this.disposed || this.reconnectTimer) return;
247
+ let e = Math.min(1e3 * 2 ** this.reconnectAttempt, de);
248
+ this.reconnectAttempt += 1, this.reconnectTimer = setTimeout(() => {
249
+ this.reconnectTimer = null, this.connectRealtime();
250
+ }, e);
251
+ }
252
+ upsertComment(e) {
253
+ this.comments.value.some((t) => t.id === e.id) || (this.comments.value = [...this.comments.value, e]);
254
+ }
255
+ async editComment(e, t) {
256
+ let n = async () => fetch(`${this.apiUrl}/api/v1/embed/grids/${this.publicKey}/comments/${e}`, {
257
+ method: "PATCH",
258
+ credentials: "include",
259
+ headers: { "Content-Type": "application/json" },
260
+ body: JSON.stringify({
261
+ body: t,
262
+ pageUrl: this.pageUrl,
263
+ externalId: this.externalId ?? void 0
264
+ })
265
+ }), r = await n();
266
+ if (r.status === 401) {
267
+ if (!await x(this.apiUrl, this.publicKey)) return null;
268
+ r = await n();
269
+ }
270
+ if (!r.ok) return null;
271
+ let i = await r.json();
272
+ return this.updateCommentInList(i.comment), i.comment;
273
+ }
274
+ async deleteComment(e) {
275
+ let t = async () => fetch(`${this.apiUrl}/api/v1/embed/grids/${this.publicKey}/comments/${e}?${this.identityParams()}`, {
276
+ method: "DELETE",
277
+ credentials: "include"
278
+ }), n = await t();
279
+ if (n.status === 401) {
280
+ if (!await x(this.apiUrl, this.publicKey)) return null;
281
+ n = await t();
282
+ }
283
+ if (!n.ok) return null;
284
+ let r = await n.json();
285
+ return this.updateCommentInList(r.comment), r.comment;
286
+ }
287
+ async flagComment(e) {
288
+ let t = async () => fetch(`${this.apiUrl}/api/v1/embed/grids/${this.publicKey}/comments/${e}/flag?${this.identityParams()}`, {
289
+ method: "POST",
290
+ credentials: "include"
291
+ }), n = await t();
292
+ if (n.status === 401) {
293
+ if (!await x(this.apiUrl, this.publicKey)) return !1;
294
+ n = await t();
295
+ }
296
+ return n.ok;
297
+ }
298
+ updateCommentInList(e) {
299
+ this.comments.value = this.comments.value.map((t) => t.id === e.id ? e : t);
300
+ }
301
+ }, fe = "@layer base{:host{box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--pop-color-brand-midnight-100:oklch(96.58% .0161 262.75);--pop-color-brand-midnight-900:oklch(15% .03 255.43);--pop-color-brand-midnight-800:oklch(19% .05 255.43);--pop-color-brand-ocean-400:oklch(63% .19 255.43);--pop-color-brand-ocean-100:oklch(91% .05 255.43);--pop-color-brand-forest-900:oklch(38.66% .0698 180.75);--pop-color-brand-forest-700:oklch(45% .15 165.43);--pop-color-brand-forest-100:oklch(97% .04 165.43);--pop-color-brand-highlight-400:oklch(88% .25 105.43);--pop-color-brand-pumpkin-500:oklch(62% .18 45.43);--pop-color-brand-pumpkin-200:oklch(89% .08 45.43);--pop-color-brand-lemon-300:oklch(91% .12 85.43);--pop-color-brand-lemon-100:oklch(97% .04 85.43);--pop-duration-bouncy:1s;--pop-duration-card-highlight:.6s;--pop-duration-gentle:.833s;--pop-duration-menu:.4s;--pop-duration-pop-hover:.6s;--pop-duration-pop-text:.3s;--pop-duration-quick:.833s;--pop-duration-slow:1.167s;--pop-ease-bouncy:linear(0, .011, .045 1.3%, .184 2.7%, .911 7.4%, 1.153 9.4%, 1.301 11.2%, 1.342, 1.362 13%, 1.363, 1.355 14.4%, 1.306 16%, 1.028 21%, .939 23%, .89 24.7%, .876, .868 26.4%, .869, .882 29%, .907 30.5%, 1.014 35.9%, 1.038, 1.048 39.8% 41.1%, 1.043 42.5%, .995 49.3%, .987, .983 53.2%, .984 55.9%, 1.002 62.7%, 1.006 66.4%, .998 79.7%, 1);--pop-ease-card-highlight:linear(0, .008, .031 1.8%, .127 3.9%, .671 11.8%, .881 15.5%, .959, 1.02 19.2%, 1.064, 1.093 23.2%, 1.102, 1.108, 1.108, 1.104 28.7%, 1.089 31.4%, 1.038 38.1%, 1.016 41.5%, .999 45.4%, .99 49.6%, .989 55.3%, 1.001 74.9%, 1);--pop-ease-gentle:linear(0, .007, .026, .059 4.5%, .106 6.3%, .209 9.5%, .558 19.3%, .658, .742, .812, .87, .918, .957, .986 41.6%, 1.007 45.3%, 1.021 49.4%, 1.027 54% 60.9%, 1.007 83.2%, 1);--pop-ease-menu:linear(0, .0034 0.81%, .0278 2.42%, .097 4.84%, .5361 15.32%, .655 18.55%, .7314, .7964 23.39%, .8662, .9185, .9561, .9818, .9984, 1.0083 42.74%, 1.014 46.77%, 1.0145 53.22%, 1.0053 68.55%, 1.0019 77.42%, .9998 100%);--pop-ease-pop-hover:linear(0, .008, .031 1.8%, .127 3.9%, .671 11.8%, .881 15.5%, .959, 1.02 19.2%, 1.064, 1.093 23.2%, 1.102, 1.108, 1.108, 1.104 28.7%, 1.089 31.4%, 1.038 38.1%, 1.016 41.5%, .999 45.4%, .99 49.6%, .989 55.3%, 1.001 74.9%, 1);--pop-ease-pop-text:linear(0, .0051 0.99%, .0261, .0607 3.61%, .1192 5.26%, .2531 8.21%, .6509 16.1%, .7652 18.73%, .8512, .9232 23.33%, .9881 25.96%, 1.0305 28.26%, 1.0642 30.88%, 1.0782 32.53%, 1.089, 1.094 36.47%, 1.0942, 1.0896 41.07%, 1.0804 43.7%, 1.0354 53.23%, 1.0181 57.5%, 1.0061 61.44%, .9974 65.71%, .9925 70.31%, .991 75.9%, .9996 99.88%);--pop-ease-quick:linear(0, .008, .031 1.8%, .127 3.9%, .671 11.8%, .881 15.5%, .959, 1.02 19.2%, 1.064, 1.093 23.2%, 1.102, 1.108, 1.108, 1.104 28.7%, 1.089 31.4%, 1.038 38.1%, 1.016 41.5%, .999 45.4%, .99 49.6%, .989 55.3%, 1.001 74.9%, 1);--pop-ease-slow:linear(0, .005, .02 2%, .081 4.5%, .469 15.2%, .567, .65, .722 24.4%, .784, .835 31.1%, .878 34.9%, .914 39.1%, .942 43.8%, .964 49.1%, .979 55.4%, .989 62.4%, .995 71.1%, 1);--pop-shadow-xs:0px 1px 2px 0px #1018280d;--pop-shadow-sm:0px 1px 3px 0px #1018281a, 0px 1px 2px 0px #1018280f;--pop-shadow-md:0px 4px 8px -2px #1018281a, 0px 2px 4px -2px #1018280f;--pop-shadow-lg:0px 12px 16px -4px #10182814, 0px 4px 6px -2px #10182808;--pop-shadow-xl:0px 20px 24px -4px #10182814, 0px 8px 8px -4px #10182808;--pop-shadow-2xl:0px 24px 48px -12px #1018282e;--pop-shadow-3xl:0px 32px 48px -12px #10182852;--pop-shadow-4xl:0px 24px 32px -12px #10182847;--pop-radius-none:0;--pop-radius-xxs:.125rem;--pop-radius-xs:.25rem;--pop-radius-sm:.375rem;--pop-radius-md:.5rem;--pop-radius-lg:.625rem;--pop-radius-xl:.75rem;--pop-radius-2xl:1rem;--pop-radius-3xl:1.25rem;--pop-radius-4xl:1.5rem;--pop-radius-full:9999px;--pop-radius:.625rem;--pop-background:oklch(100% 0 0);--pop-foreground:oklch(0% 0 0);--pop-card:oklch(100% 0 0);--pop-card-foreground:oklch(14.5% 0 0);--pop-popover:oklch(100% 0 0);--pop-popover-foreground:oklch(0% 0 0);--pop-primary:oklch(20.5% 0 0);--pop-primary-foreground:oklch(98.5% 0 0);--pop-secondary:oklch(97% 0 0);--pop-secondary-foreground:oklch(20.5% 0 0);--pop-muted:oklch(97% 0 0);--pop-muted-foreground:oklch(71.52% .0233 256.76);--pop-accent:oklch(97% 0 0);--pop-accent-foreground:oklch(20.5% 0 0);--pop-destructive:var(--color-error-600);--pop-border:oklch(11.01% .0763 264.05/.102);--pop-input:oklch(92.2% 0 0);--pop-ring:oklch(62.3% .214 259.815);--pop-chart-1:oklch(64.6% .222 41.116);--pop-chart-2:oklch(60% .118 184.704);--pop-chart-3:oklch(39.8% .07 227.392);--pop-chart-4:oklch(82.8% .189 84.429);--pop-chart-5:oklch(76.9% .188 70.08);--pop-sidebar:oklch(98.5% 0 0);--pop-sidebar-foreground:oklch(14.5% 0 0);--pop-sidebar-primary:oklch(20.5% 0 0);--pop-sidebar-primary-foreground:oklch(98.5% 0 0);--pop-sidebar-accent:oklch(97% 0 0);--pop-sidebar-accent-foreground:oklch(20.5% 0 0);--pop-sidebar-border:oklch(92.2% 0 0);--pop-sidebar-ring:oklch(70.8% 0 0);font-family:Inter,sans-serif;font-size:16px}@media (prefers-color-scheme:dark){:host{--pop-background:oklch(15% .03 255.43);--pop-foreground:oklch(66% .006 255.43);--pop-card:oklch(20.5% 0 0);--pop-card-foreground:oklch(98.5% 0 0);--pop-popover:oklch(15% .03 255.43);--pop-popover-foreground:oklch(66% .006 255.43);--pop-primary:oklch(92.2% 0 0);--pop-primary-foreground:oklch(20.5% 0 0);--pop-secondary:oklch(26.9% 0 0);--pop-secondary-foreground:oklch(98.5% 0 0);--pop-muted:oklch(26.9% 0 0);--pop-muted-foreground:oklch(66% .006 255.43);--pop-accent:oklch(26.9% 0 0);--pop-accent-foreground:oklch(98.5% 0 0);--pop-destructive:var(--color-error-400);--pop-border:oklch(100% 0 0/.1);--pop-input:oklch(100% 0 0/.15);--pop-ring:oklch(62.3% .214 259.815);--pop-chart-1:oklch(48.8% .243 264.376);--pop-chart-2:oklch(69.6% .17 162.48);--pop-chart-3:oklch(76.9% .188 70.08);--pop-chart-4:oklch(62.7% .265 303.9);--pop-chart-5:oklch(64.5% .246 16.439);--pop-sidebar:oklch(20.5% 0 0);--pop-sidebar-foreground:oklch(98.5% 0 0);--pop-sidebar-primary:oklch(48.8% .243 264.376);--pop-sidebar-primary-foreground:oklch(98.5% 0 0);--pop-sidebar-accent:oklch(26.9% 0 0);--pop-sidebar-accent-foreground:oklch(98.5% 0 0);--pop-sidebar-border:oklch(100% 0 0/.1);--pop-sidebar-ring:oklch(55.6% 0 0)}}:host(.dark){--pop-background:oklch(15% .03 255.43);--pop-foreground:oklch(66% .006 255.43);--pop-card:oklch(20.5% 0 0);--pop-card-foreground:oklch(98.5% 0 0);--pop-popover:oklch(15% .03 255.43);--pop-popover-foreground:oklch(66% .006 255.43);--pop-primary:oklch(92.2% 0 0);--pop-primary-foreground:oklch(20.5% 0 0);--pop-secondary:oklch(26.9% 0 0);--pop-secondary-foreground:oklch(98.5% 0 0);--pop-muted:oklch(26.9% 0 0);--pop-muted-foreground:oklch(66% .006 255.43);--pop-accent:oklch(26.9% 0 0);--pop-accent-foreground:oklch(98.5% 0 0);--pop-destructive:var(--color-error-400);--pop-border:oklch(100% 0 0/.1);--pop-input:oklch(100% 0 0/.15);--pop-ring:oklch(62.3% .214 259.815);--pop-chart-1:oklch(48.8% .243 264.376);--pop-chart-2:oklch(69.6% .17 162.48);--pop-chart-3:oklch(76.9% .188 70.08);--pop-chart-4:oklch(62.7% .265 303.9);--pop-chart-5:oklch(64.5% .246 16.439);--pop-sidebar:oklch(20.5% 0 0);--pop-sidebar-foreground:oklch(98.5% 0 0);--pop-sidebar-primary:oklch(48.8% .243 264.376);--pop-sidebar-primary-foreground:oklch(98.5% 0 0);--pop-sidebar-accent:oklch(26.9% 0 0);--pop-sidebar-accent-foreground:oklch(98.5% 0 0);--pop-sidebar-border:oklch(100% 0 0/.1);--pop-sidebar-ring:oklch(55.6% 0 0)}*,:before,:after{box-sizing:inherit}html,body{margin:0;padding:0}svg{display:block}p{margin:0;padding:0}button{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin:0;padding:0;display:flex}}", pe = "@layer components{.btn{text-align:center;cursor:pointer;border:0;border-radius:4px;justify-content:center;align-items:center;gap:.625rem;height:auto;padding:.625rem 1.25rem;transition:background-color .2s,color .2s;display:flex}.btn-link{border-radius:var(--pop-radius-xs,4px);cursor:pointer;background-color:#0000;border-style:solid;border-color:#0000;justify-content:center;align-items:center;gap:2px;font-weight:500;text-decoration:none;transition:background-color .2s,border-color .2s,color .2s;display:inline-flex}.btn-link--size-sm{letter-spacing:-.08px;border-width:1px 2px;font-size:13px;line-height:18px}.btn-link--size-md{letter-spacing:0;border-width:1px 3px;font-size:14px;line-height:20px}.btn-link--size-lg{letter-spacing:0;border-width:1px 4px;font-size:16px;line-height:24px}.btn-link--theme-default{color:color-mix(in srgb, var(--pop-foreground) 50%, transparent)}.btn-link--theme-default.btn-link--primary{color:var(--pop-foreground)}.btn-link--theme-white{color:#fff}.btn-link--theme-black{color:#000}.btn-link--theme-default:hover,.btn-link--theme-black:hover{background-color:color-mix(in srgb, var(--pop-foreground) 10%, transparent);border-color:color-mix(in srgb, var(--pop-foreground) 10%, transparent)}.btn-link--theme-default:not(.btn-link--primary):hover{color:var(--pop-foreground)}.btn-link--theme-white:hover{background-color:#ffffff29;border-color:#ffffff29}.btn-link:active{background-color:#0000;border-color:#0000}.btn-link--theme-default:not(.btn-link--primary):active{color:color-mix(in srgb, var(--pop-foreground) 50%, transparent)}.btn-link:focus-visible{background-color:var(--pop-ring,#155eef);border-color:var(--pop-ring,#155eef);outline:none;color:#fff!important}.btn-link:disabled,.btn-link.is-disabled{cursor:not-allowed;pointer-events:none;color:color-mix(in srgb, var(--pop-foreground) 35%, transparent)!important;background-color:#0000!important;border-color:#0000!important}.btn:focus-visible{outline-offset:2px;outline:2px solid}}", me = "@layer components{.mask{-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}.mask-squircle{-webkit-mask-image:url(\"data:image/svg+xml,%3csvg width='160' height='160' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M 0 80 C 0 14.12 14.12 0 80 0 C 145.88 0 160 14.12 160 80 C 160 145.88 145.88 160 80 160 C 14.12 160 0 145.88 0 80 Z'/%3e%3c/svg%3e\");mask-image:url(\"data:image/svg+xml,%3csvg width='160' height='160' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M 0 80 C 0 14.12 14.12 0 80 0 C 145.88 0 160 14.12 160 80 C 160 145.88 145.88 160 80 160 C 14.12 160 0 145.88 0 80 Z'/%3e%3c/svg%3e\")}}", O = !1, k = /* @__PURE__ */ new Set(), A = null, j = null;
302
+ function M() {
303
+ if (typeof window > "u" || typeof document > "u") return !1;
304
+ let e = document.documentElement.classList.contains("dark") || document.body.classList.contains("dark"), t = document.documentElement.classList.contains("light") || document.body.classList.contains("light");
305
+ return e ? !0 : t ? !1 : (j ||= window.matchMedia("(prefers-color-scheme: dark)"), j.matches);
306
+ }
307
+ function N() {
308
+ let e = M();
309
+ e !== O && (O = e, k.forEach((e) => {
310
+ let t = O || !!e.closest(".dark");
311
+ e.classList.toggle("dark", t);
312
+ }));
313
+ }
314
+ var P = () => {
315
+ N();
316
+ };
317
+ function he(e) {
318
+ if (typeof window > "u" || typeof document > "u") return;
319
+ k.size === 0 && (O = M(), A = new MutationObserver(() => {
320
+ N();
321
+ }), A.observe(document.documentElement, {
322
+ attributes: !0,
323
+ attributeFilter: ["class"]
324
+ }), A.observe(document.body, {
325
+ attributes: !0,
326
+ attributeFilter: ["class"]
327
+ }), j = window.matchMedia("(prefers-color-scheme: dark)"), j.addEventListener("change", P)), k.add(e);
328
+ let t = O || !!e.closest(".dark");
329
+ e.classList.toggle("dark", t);
330
+ }
331
+ function ge(e) {
332
+ k.delete(e), k.size === 0 && (A &&= (A.disconnect(), null), j &&= (j.removeEventListener("change", P), null));
333
+ }
334
+ //#endregion
335
+ //#region src/components/base-element.ts
336
+ function F(e) {
337
+ let t = new CSSStyleSheet();
338
+ return t.replaceSync(e), t;
339
+ }
340
+ var _e = F(fe), ve = F(pe), ye = F(me), I = class extends HTMLElement {
341
+ get styleSheets() {
342
+ return [];
343
+ }
344
+ constructor() {
345
+ super(), this.baseStyleSheets = [
346
+ _e,
347
+ ve,
348
+ ye
349
+ ], this._hasRendered = !1, this._disposables = [], this.events = {}, this.attachShadow({ mode: "open" }), this.shadowRoot && (this.shadowRoot.adoptedStyleSheets = this.styles);
350
+ }
351
+ attributeChangedCallback(e, t, n) {
352
+ if (t === n) return;
353
+ let r = `on${e.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("")}Changed`;
354
+ typeof this[r] == "function" && this[r](n, t);
355
+ }
356
+ addEffect(e) {
357
+ this._disposables.push(t(e));
358
+ }
359
+ connectedCallback() {
360
+ he(this), r(() => {
361
+ this.render(), this._bindEvents(), this.setupEffects();
362
+ });
363
+ }
364
+ disconnectedCallback() {
365
+ ge(this), this._disposables.forEach((e) => e()), this._disposables = [];
366
+ }
367
+ _bindEvents() {
368
+ let e = this.shadowRoot;
369
+ e && Object.keys(this.events).forEach((t) => {
370
+ e.addEventListener(t, this);
371
+ });
372
+ }
373
+ handleEvent(e) {
374
+ let t = this.events[e.type];
375
+ t && typeof this[t] == "function" && this[t](e);
376
+ }
377
+ emit(e, t = {}) {
378
+ this.dispatchEvent(new CustomEvent(e, {
379
+ bubbles: !0,
380
+ composed: !0,
381
+ ...t
382
+ }));
383
+ }
384
+ get styles() {
385
+ return [...this.baseStyleSheets, ...this.styleSheets];
386
+ }
387
+ setupEffects() {}
388
+ render() {
389
+ this.shadowRoot && (this.shadowRoot.innerHTML = this.getTemplate(), this._hasRendered = !0);
390
+ }
391
+ hideElement(e, t, n = !0) {
392
+ if (!this.shadowRoot || !this._hasRendered) return;
393
+ let r = this.shadowRoot.querySelector(e);
394
+ if (!r) {
395
+ console.warn(`Element not found for selector: ${e}`);
396
+ return;
397
+ }
398
+ n ? r.classList.toggle("hidden", t) : r.classList.toggle("invisible", t);
399
+ }
400
+ setText(e, t) {
401
+ let n = this.shadowRoot?.querySelector(e);
402
+ n && n.textContent !== String(t) && (n.textContent = String(t));
403
+ }
404
+ setAttr(e, t, n) {
405
+ let r = this.shadowRoot?.querySelector(e);
406
+ r && (n === null ? r.removeAttribute(t) : r.getAttribute(t) !== n && r.setAttribute(t, n));
407
+ }
408
+ toggleClass(e, t, n) {
409
+ let r = this.shadowRoot?.querySelector(e);
410
+ r && r.classList.toggle(t, n);
411
+ }
412
+ getElement(e) {
413
+ return this.shadowRoot?.querySelector(e) ?? null;
414
+ }
415
+ };
416
+ //#endregion
417
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
418
+ function L(e, t, n, r) {
419
+ var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
420
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
421
+ else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
422
+ return i > 3 && a && Object.defineProperty(t, n, a), a;
423
+ }
424
+ //#endregion
425
+ //#region src/components/pop-auth-panel.ts
426
+ var be = F("\n :host {\n display: block;\n position: relative;\n\n --pop-auth-border: var(--pop-border, rgba(0, 0, 32, 0.04));\n --pop-auth-watermark: rgba(0, 0, 32, 0.4);\n --pop-auth-btn: #000000;\n --pop-auth-logo: rgba(0, 0, 32, 0.35);\n --pop-auth-error: #dc2626;\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n --pop-auth-border: var(--pop-border, rgba(255, 255, 255, 0.1));\n --pop-auth-watermark: rgba(255, 255, 255, 0.4);\n --pop-auth-btn: #ffffff;\n --pop-auth-logo: rgba(255, 255, 255, 0.35);\n --pop-auth-error: var(--pop-destructive, #f87171);\n }\n }\n\n :host(.dark) {\n --pop-auth-border: var(--pop-border, rgba(255, 255, 255, 0.1));\n --pop-auth-watermark: rgba(255, 255, 255, 0.4);\n --pop-auth-btn: #ffffff;\n --pop-auth-logo: rgba(255, 255, 255, 0.35);\n --pop-auth-error: var(--pop-destructive, #f87171);\n }\n\n .panel {\n position: relative;\n border-top: 1px solid var(--pop-auth-border);\n }\n\n .watermark {\n position: absolute;\n top: -16px;\n left: 8px;\n font-family: Inter, sans-serif;\n font-size: 8px;\n font-weight: 700;\n letter-spacing: 1px;\n color: var(--pop-auth-watermark);\n text-transform: uppercase;\n backdrop-filter: blur(4px);\n border-radius: 9999px;\n padding: 2px 6px;\n pointer-events: none;\n }\n\n .actions {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 16px;\n }\n\n .join-btn {\n font-family: Inter, sans-serif;\n font-size: 13px;\n font-weight: 600;\n color: var(--pop-auth-btn);\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n letter-spacing: -0.08px;\n line-height: 18px;\n }\n\n .join-btn:disabled {\n opacity: 0.6;\n cursor: default;\n }\n\n .logo {\n font-family: Inter, sans-serif;\n font-size: 9px;\n font-weight: 700;\n letter-spacing: 1.5px;\n color: var(--pop-auth-logo);\n text-transform: uppercase;\n }\n\n .error {\n padding: 0 16px 12px;\n font-family: Inter, sans-serif;\n font-size: 12px;\n line-height: 16px;\n color: var(--pop-auth-error);\n text-align: center;\n }\n"), R = class extends I {
427
+ constructor(...e) {
428
+ super(...e), this.events = { click: "onClick" };
429
+ }
430
+ get styleSheets() {
431
+ return [be];
432
+ }
433
+ onClick(e) {
434
+ e.target.closest(".join-btn") && this.handleJoin();
435
+ }
436
+ setupEffects() {
437
+ this.addEffect(() => {
438
+ let e = v.value, t = _.value, n = this.getElement(".join-btn");
439
+ n && (n.disabled = e, n.textContent = e ? "Signing in…" : "Join the Conversation");
440
+ let r = this.getElement(".error");
441
+ r && (t ? (r.hidden = !1, r.textContent = t) : (r.hidden = !0, r.textContent = ""));
442
+ });
443
+ }
444
+ async handleJoin() {
445
+ se(), await x(this.gridStore.apiUrl, this.gridStore.publicKey);
446
+ }
447
+ getTemplate() {
448
+ return "\n <div class=\"panel\">\n <div class=\"watermark\">Popgrids</div>\n <div class=\"actions\">\n <button class=\"join-btn\" type=\"button\">Join the Conversation</button>\n <span class=\"logo\">POPGRIDS</span>\n </div>\n <div class=\"error\" hidden></div>\n </div>\n ";
449
+ }
450
+ };
451
+ L([C(D)], R.prototype, "gridStore", void 0), customElements.get("pop-auth-panel") || customElements.define("pop-auth-panel", R);
452
+ //#endregion
453
+ //#region src/assets/popgrids-letter-p.png?inline
454
+ var xe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD8AAABMCAYAAADa6W+wAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAUuSURBVHgB5ZyBceIwEEX3bq4AOsAdQAdxKggl+Co4rgKcCkgqgFRAUgGkAqACOxVAKvDpg+VRHEmWQSubuTezg8Ega7UrebWS+UG8jIXEQoZCovI9lcd1ciHHUnZCPsrXXflZ7xkISYSshByEFJ5kLWRO54bsHRGdK+dTYZNkQhbUg4aI6FyRoiNBQyQUGLj3jMJYuleNMC4v1gel67Ig/WCq5Qe144+QlM6Wb2QwGNB4PD7JaDQ6veIzKZLj8XiSPM9Pr/v9nna73UnwWUtyIb+FbMgjM3K0QBzHxXq9Lg6HQ3Et2+22WCwWpzJdr1/KjDzRqLiwZDGbzbwobCLLslNDRFEUrAEmTReBVVCxkLRohIsbICLLiA5roxJdAm9zaIAJXUBmKhCtHtraJjAuNHjBgVrcBcDsFhSXoD4NDbB2VTyyFNI7xSUODTB1UX5hKmA+nxd9Bl0AYxGZ3X9wkdWTJCluARjIYv2ULrG6T3eHhabT6SkY4sASFB1aWx23FJ+IULcqm6MBUKbF+rFO+ZQCje6qa6J8jsjQYv2FTvmMAvb1yWRSXePp6anwzWq1cnb9MQXo6yqwthyZ0Q04y9e5/k9F+VjnCpiGCrckDjCtFV51OpZTWN/lo/4Gxqryd7pvCNckTkS/rI7f39/JN5b6j1TltU10d3dHnKjl+7Y8sHhtpS+iHm3f4JyfS2RIytHvMV4ZdMt+1lvhS9OUaSdu5DUuSFk5l60hksoPWv7QK9I1kb/zjU2HRsuHIFQj17FanusWV4fD4i5I5Ye6k8PhkELAqbxlHDn2os9L5Tm6mUX5vBfKy/s7x/U+Pz9Np7q3/GazqY7VaI+j/Br7zpV/e3urjjmiSUvUWJ3QRkHcqAlHzL58g+iUzAmNLxOboGAgur+/rwYkjgnU6+ur6VROXVpezbLA6hw5A9dMTnDlZRoLinPk8CwTmm85vE76PCdIvRn0ympdQL8YGWI6y0GD1atVGzngaePLrmLua8FAaqEaBTsb7bl4fHy0hbTPdB7pv7AmjYtwraZw0eDu6OuRqrTV7T8+PuhWkHGDhUeqWV0qr43+b6XPI4RVAyYNGyHL+odS+Vz3i1tQ/vn5uUlxnPitO/FL+cL3XzEkFAFmWsjRY28eZnKXTKBQBgY3y6xN8pcM+km0O66wlhZiUMJ1lstlY1yB8y335KU2peUOTKRQtvWTyOGJypJv4FGwmlD42zl4Aq6rZnQhFyxnYYBLXb4YEemXpjlx2ENziSBaTaglncT3nhtgTS23nEkyXYEhdl417KJwtfaUrkCrPPbOhEDdqNBS6ZQcd4HbWOkugN0NIWhhfRhpQR4eM/mlHGujPEvq1ysNOXu4tHzaKidPqLO6XPcFrkCnDgIdy/IYUryYiubkEVV5bSwbSnlgW04mBhqVDxnfh16tVZXXhk8hLW9bVCQGemV5y7VyCkAnUR5APEHmezkL9RxeZ4Oey5qab5yUVxcTuXh5eTGd2lMgnkjjepg/c9JmdYWT2FQJjo3BEsusLqPAbHUV4VpMTNPUZvUFBSYxVMT7vvsGxWH1iDpgTYbbDjzg2i6AXBweMSH77C2hjsAUy/psPLwASce2OD4GuqIA2B4hxzRyrrzHbfBb8I2ZGJKODw8PVeJRxujysXDcw/FYOBKWDhFjLuSeAkV1NlJqn125RjLqqJ+bSOk/VVwSEe9fRSzJQx6Om4T8NgLKiunGSMh8O3QR/Damjmn7hyF14KpxKSM6d49IOa/7u6dX6snfPf0DiVL6IWhCmZ4AAAAASUVORK5CYII=", z = /* @__PURE__ */ "#DDD0BE.#E9DCBB.#E9DCBB.#C7D1B0.#C6D0CB.#E9DCBB.#C7D1B0.#E9DCBB.#DFC2C0.#CFD4C6.#D7E3E8.#CFD4C6.#D6B3B3.#E9DCBB.#CFCBDC.#BFD6D7.#E3D2C6.#D1E2E7.#D6B3B3.#BFD6D7.#E9DCBB.#C7D1B0.#DFC2C0.#D1E2E7.#CFD4C6.#E9DCBB.#D7E3E8.#CFD4C6.#C6D0CB.#E9DCBB.#C7D1B0.#E9DCBB.#CFCBDC.#E3D2C6.#E9DCBB".split("."), Se = (e) => typeof e == "number" ? z[e % z.length] ?? "#e5e7eb" : z[Math.floor(Math.random() * z.length)];
455
+ function Ce(e) {
456
+ let t = new TextEncoder().encode(e), n = 2166136261;
457
+ for (let e = 0; e < t.length; e++) {
458
+ let r = t[e] ?? 0;
459
+ n ^= r, n = Math.imul(n, 16777619);
460
+ }
461
+ return n >>> 0;
462
+ }
463
+ function we(e) {
464
+ return z[Ce(e) % z.length] ?? "#e5e7eb";
465
+ }
466
+ //#endregion
467
+ //#region src/components/pop-comment-avatar.ts
468
+ var Te = F("\n :host {\n display: block;\n\n --comment-avatar-border-size: 1px;\n --comment-avatar-border-color: var(--color-background, #fff);\n --comment-avatar-size: 32px;\n }\n\n .comment-avatar {\n align-items: center;\n display: flex;\n flex-shrink: 0;\n isolation: isolate;\n justify-content: center;\n position: relative;\n width: calc(var(--comment-avatar-size) + calc(var(--comment-avatar-border-size) * 2));\n height: calc(var(--comment-avatar-size) + calc(var(--comment-avatar-border-size) * 2));\n }\n\n .comment-avatar--size-xs {\n --comment-avatar-size: 32px;\n }\n\n .comment-avatar--size-sm {\n --comment-avatar-size: 56px;\n }\n\n .comment-avatar--size-md {\n --comment-avatar-size: 80px;\n }\n\n .comment-avatar--size-lg {\n --comment-avatar-size: 120px;\n }\n\n .comment-avatar--size-xl {\n --comment-avatar-size: 140px;\n }\n\n .comment-avatar__background {\n background-color: var(--comment-avatar-border-color);\n position: absolute;\n top: 0;\n left: 0;\n z-index: 10;\n width: 100%;\n height: 100%;\n }\n\n /**\n * Content\n */\n\n .comment-avatar__content {\n align-items: center;\n background-color: var(--color-surface-bg-default);\n display: flex;\n justify-content: center;\n overflow: hidden;\n position: relative;\n height: var(--comment-avatar-size);\n width: var(--comment-avatar-size);\n z-index: 20;\n\n /* Initials styling */\n font-family: Inter, sans-serif;\n font-weight: 600;\n color: #374151;\n font-size: calc(var(--comment-avatar-size) * 0.35);\n line-height: 1;\n }\n\n .comment-avatar__content::slotted(img) {\n -webkit-user-drag: none;\n align-self: stretch;\n flex: 1 0 0;\n height: var(--comment-avatar-size);\n object-fit: cover;\n pointer-events: none;\n position: absolute;\n user-select: none;\n width: var(--comment-avatar-size);\n }\n\n .comment-avatar__deleted-mark {\n -webkit-user-drag: none;\n bottom: -3px;\n height: auto;\n left: 0;\n object-fit: cover;\n pointer-events: none;\n position: absolute;\n user-select: none;\n width: 100%;\n transform: scale(0.57);\n }\n"), Ee = class extends I {
469
+ constructor() {
470
+ super(), this._backgroundColor = Se() ?? "#e5e7eb";
471
+ }
472
+ static get observedAttributes() {
473
+ return [
474
+ "size",
475
+ "data-color-key",
476
+ "deleted"
477
+ ];
478
+ }
479
+ onSizeChanged() {
480
+ this.render();
481
+ }
482
+ onDataColorKeyChanged() {
483
+ this.render();
484
+ }
485
+ onDeletedChanged() {
486
+ this.render();
487
+ }
488
+ get styleSheets() {
489
+ return [Te];
490
+ }
491
+ get size() {
492
+ return this.getAttribute("size") || "md";
493
+ }
494
+ set size(e) {
495
+ this.setAttribute("size", e);
496
+ }
497
+ get deleted() {
498
+ return this.hasAttribute("deleted");
499
+ }
500
+ set deleted(e) {
501
+ e ? this.setAttribute("deleted", "") : this.removeAttribute("deleted");
502
+ }
503
+ getTemplate() {
504
+ let e = this.size, t = this.deleted, n = this.getAttribute("data-color-key"), r = t ? "var(--pop-muted-foreground, #e5e7eb)" : n ? we(n) : this._backgroundColor;
505
+ return `
506
+ <div class="comment-avatar comment-avatar--size-${e}" part="base">
507
+ <div class="comment-avatar__background mask mask-squircle" part="background"></div>
508
+ ${t ? `<div
509
+ class="comment-avatar__content mask mask-squircle"
510
+ part="content"
511
+ style="background-color: ${r}; opacity: 0.15"
512
+ ><img class="comment-avatar__deleted-mark" src="${xe}" alt="Deleted user" /></div>` : `<slot
513
+ class="comment-avatar__content mask mask-squircle"
514
+ part="content"
515
+ style="background-color: ${r};"
516
+ ></slot>`}
101
517
  </div>
102
- </button>`}};j.styles=[l(j,j,"styles"),Z],j=i([Bt("pop-auth-join")],j);var It=j;import{consume as Kt}from"@lit/context";import{PopElement as Nt}from"@popgrids/ui";import{html as $}from"lit";import{customElement as Qt,query as G,state as P}from"lit/decorators.js";import{classMap as Jt}from"lit/directives/class-map.js";import{ifDefined as Ft}from"lit/directives/if-defined.js";import{createContext as Rt}from"@lit/context";var D=Rt(Symbol("pop-auth-context"));import{css as Ut}from"lit";var Y=Ut`
103
- :host {
104
- display: flex;
105
- width: 100%;
106
- }
107
-
108
- .auth-panel {
109
- display: flex;
110
- border-top: 1px solid var(--color-surface-alpha-singular-alpha-input-bar, rgba(0, 0, 32, 0.04));
111
- flex-direction: column;
112
- height: 50px;
113
- position: absolute;
114
- bottom: 0;
115
- left: 0;
116
- right: 0;
117
- transition: height 150ms ease-in-out;
118
- width: 100%;
119
- overflow: hidden;
120
- background-color: var(--color-surface-bg-default, #fff);
121
- backdrop-filter: blur(var(--blur-2xl));
122
- }
123
-
124
- .auth-panel--is-open {
125
- /* Dynamic height will be set via JS */
126
- /* The max-height provides a constraint */
127
- max-height: 340px;
128
- transition: height var(--duration-quick) var(--ease-quick);
129
- }
130
-
131
- .auth-panel__content {
132
- position: relative;
133
- top: 0;
134
- left: 0;
135
- right: 0;
136
-
137
- display: flex;
138
- flex-direction: column;
139
- width: 100%;
140
- }
141
- `;var u=class extends Nt{constructor(){super(...arguments);this._email="";this._open=!1;this._resizeObserver=null;this.handleKeyDown=t=>{t.code==="Escape"&&(this._open=!1)};this.handleDocumentMouseDown=t=>{if(!this._open)return;let e=t.composedPath();this&&!e.includes(this._authPanel)&&(this._open=!1)}}handleJoinClick(){this._open=!0}async connectedCallback(){super.connectedCallback(),await this.updateComplete,document.addEventListener("mousedown",this.handleDocumentMouseDown),document.addEventListener("keydown",this.handleKeyDown),this.setupResizeObserver()}disconnectedCallback(){document.removeEventListener("mousedown",this.handleDocumentMouseDown),document.removeEventListener("keydown",this.handleKeyDown),this._resizeObserver?.disconnect(),super.disconnectedCallback()}setupResizeObserver(){this._resizeObserver=new ResizeObserver(t=>{requestAnimationFrame(()=>{for(let e of t)if(e.target===this._authPanelContent){let r=this._authPanelContent.offsetHeight;this._open?this._authPanel.style.height=`${r}px`:this._authPanel.style.height="50px"}})}),this._authPanelContent&&this._resizeObserver.observe(this._authPanelContent)}updated(t){super.updated(t),(t.has("_open")||t.has("authContext"))&&(t.has("_open")&&!this._open?this._authPanel.style.height="50px":this._open&&this._authPanelContent&&requestAnimationFrame(()=>{let e=this._authPanelContent.offsetHeight;this._authPanel.style.height=`${e}px`}),!this._resizeObserver&&this._authPanelContent&&this.setupResizeObserver())}handleSignInSuccess(t){t.detail?.email&&(this._email=t.detail.email)}handleCodeVerificationSuccess(){this._open=!1}renderAuthenticated(){return $`Authenticated`}renderJoinButton(){return $`<pop-auth-join @pop-click=${this.handleJoinClick}></pop-auth-join>`}renderSignInForm(){return $`<pop-auth-sign-in @pop-success=${this.handleSignInSuccess}></pop-auth-sign-in>`}renderVerifyCodeForm(){return $`
142
- <pop-auth-verify-code
143
- email=${Ft(this._email)}
144
- @pop-success=${this.handleCodeVerificationSuccess}
145
- ></pop-auth-verify-code>
146
- `}renderUnauthenticated(){return this._open?this.authContext?.isVerifying?this.renderVerifyCodeForm():this.renderSignInForm():this.renderJoinButton()}render(){return $`
147
- <div
148
- class=${Jt({"auth-panel":!0,"auth-panel--is-open":this._open})}
149
- >
150
- <div class="auth-panel__content">
151
- ${this.authContext?.isAuthenticated?this.renderAuthenticated():this.renderUnauthenticated()}
518
+ `;
519
+ }
520
+ };
521
+ customElements.get("pop-comment-avatar") || customElements.define("pop-comment-avatar", Ee);
522
+ //#endregion
523
+ //#region src/helpers/author.ts
524
+ function B(e) {
525
+ return e ? e.split(" ").map((e) => e[0] ?? "").join("").toUpperCase().slice(0, 2) : "?";
526
+ }
527
+ //#endregion
528
+ //#region src/components/pop-comment-bar.ts
529
+ var De = F("\n :host {\n background: var(--pop-background);\n border-top: 1px solid var(--pop-bar-input-bg);\n display: block;\n padding: 6px;\n position: relative;\n\n --pop-bar-avatar-bg: #e5e7eb;\n --pop-bar-avatar-color: #374151;\n --pop-bar-avatar-border: #ffffff;\n --pop-bar-input-bg: rgba(0, 0, 32, 0.04);\n --pop-bar-send-hover: rgba(0, 0, 32, 0.06);\n --pop-bar-send-color: #000000;\n --pop-bar-watermark: rgba(0, 0, 32, 0.1);\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n --pop-bar-avatar-bg: #1f2937;\n --pop-bar-avatar-color: #d1d5db;\n --pop-bar-avatar-border: var(--pop-popover, #151d2a);\n --pop-bar-input-bg: rgba(255, 255, 255, 0.05);\n --pop-bar-send-hover: rgba(255, 255, 255, 0.08);\n --pop-bar-send-color: #ffffff;\n --pop-bar-watermark: rgba(255, 255, 255, 0.1);\n }\n }\n\n :host(.dark) {\n --pop-bar-avatar-bg: #1f2937;\n --pop-bar-avatar-color: #d1d5db;\n --pop-bar-avatar-border: var(--pop-popover, #151d2a);\n --pop-bar-input-bg: rgba(255, 255, 255, 0.05);\n --pop-bar-send-hover: rgba(255, 255, 255, 0.08);\n --pop-bar-send-color: #ffffff;\n --pop-bar-watermark: rgba(255, 255, 255, 0.1);\n }\n\n .bar {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .bar__user {\n display: flex;\n align-items: center;\n align-self: flex-start;\n flex-shrink: 0;\n padding-top: 2px;\n }\n\n .bar__avatar {\n flex-shrink: 0;\n --comment-avatar-border-size: 0px;\n }\n\n .bar__avatar--reply {\n margin-right: -4px;\n z-index: 1;\n }\n\n .bar__avatar--user {\n z-index: 2;\n }\n\n .bar__user.has-reply .bar__avatar--user {\n --comment-avatar-border-size: 2px;\n --comment-avatar-border-color: var(--pop-bar-avatar-border);\n }\n\n .bar__input-wrap {\n flex: 1;\n min-width: 0;\n background: var(--pop-bar-input-bg);\n border-radius: 18px;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n padding: 4px 8px 4px 12px;\n max-height: 280px;\n }\n\n .bar__send {\n align-items: center;\n align-self: flex-end;\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n justify-content: center;\n padding-bottom: 2px;\n }\n\n .logo-watermark {\n position: absolute;\n top: -16px;\n left: 8px;\n font-family: Inter, sans-serif;\n font-size: 8px;\n font-weight: 700;\n letter-spacing: 1px;\n color: var(--pop-bar-watermark);\n text-transform: uppercase;\n border-radius: 9999px;\n padding: 2px 6px;\n pointer-events: none;\n user-select: none;\n }\n"), V = "<svg width=\"64\" height=\"11\" viewBox=\"0 0 64 11\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M3.91111 0C0.892839 0 0 2.11357 0 4.77714C0 5.76321 0.0987654 6.73357 0.213333 7.70786C0.25679 8.08893 0.240988 8.50929 0.312099 8.89036C0.497778 9.89214 1.44593 10.3557 2.36642 10.3557C3.62667 10.3557 4.4642 9.56607 4.4642 8.30107C4.4642 7.57036 4.22321 7.09107 3.5279 6.80821C3.48444 6.7925 3.44099 6.78071 3.44099 6.72179C3.44099 6.62357 3.59901 6.55286 3.69778 6.55286C4.03753 6.55286 4.57481 6.89071 5.04494 6.89071C6.88593 6.89071 7.90519 5.13071 7.90519 3.48071C7.90519 1.08429 6.13136 0 3.91111 0ZM3.89531 5.18179C3.78074 5.18179 3.68198 5.08357 3.68198 4.96964C3.68198 4.81643 3.89531 4.7025 3.96642 4.57679C4.12049 4.29393 4.16395 3.81464 4.16395 3.4925C4.16395 3.11143 4.06519 2.40821 3.8242 2.12536C3.75309 2.04286 3.65432 1.99964 3.65432 1.88571C3.65432 1.77179 3.76889 1.67357 3.87951 1.67357C4.36148 1.67357 4.60247 3.08393 4.60247 3.44929C4.60247 3.84214 4.47605 5.18179 3.89531 5.18179Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n<path d=\"M12.7368 0.239637C9.73433 0.239637 7.93285 2.35321 7.93285 5.25249C7.93285 8.15178 9.73038 10.2654 12.7368 10.2654C15.7432 10.2654 17.5249 8.12428 17.5249 5.25249C17.5249 2.38071 15.7116 0.239637 12.7368 0.239637ZM12.8672 8.83142C12.8198 8.89035 12.7249 9.00035 12.6104 9.00035C12.4958 9.00035 12.3852 8.90214 12.3852 8.78821C12.3852 8.74499 12.7526 8.19499 12.8119 8.02607C13.037 7.36214 13.0805 6.64321 13.0805 5.93999C13.0805 4.99714 12.9106 3.78321 12.3299 3.00928C12.2153 2.86785 11.8637 2.60071 11.8637 2.44749C11.8637 2.33357 11.9625 2.23535 12.077 2.23535C12.1758 2.23535 12.2746 2.32178 12.3457 2.37678C13.2504 3.12321 13.523 4.82821 13.523 5.93999C13.523 6.81214 13.4874 8.08499 12.8711 8.82749L12.8672 8.83142Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n<path d=\"M21.6533 0C18.6351 0 17.7422 2.11357 17.7422 4.77714C17.7422 5.76321 17.841 6.73357 17.9555 7.70786C17.999 8.08893 17.9832 8.50929 18.0543 8.89036C18.24 9.89214 19.1881 10.3557 20.1086 10.3557C21.3689 10.3557 22.2064 9.56607 22.2064 8.30107C22.2064 7.57036 21.9654 7.09107 21.2701 6.80821C21.2267 6.7925 21.1832 6.78071 21.1832 6.72179C21.1832 6.62357 21.3412 6.55286 21.44 6.55286C21.7797 6.55286 22.317 6.89071 22.7871 6.89071C24.6281 6.89071 25.6474 5.13071 25.6474 3.48071C25.6474 1.08429 23.8775 0 21.6533 0ZM21.6415 5.18179C21.5269 5.18179 21.4281 5.08357 21.4281 4.96964C21.4281 4.81643 21.6415 4.7025 21.7126 4.57679C21.8667 4.29393 21.9101 3.81464 21.9101 3.4925C21.9101 3.11143 21.8113 2.40821 21.5704 2.12536C21.4992 2.04286 21.4005 1.99964 21.4005 1.88571C21.4005 1.77179 21.5151 1.67357 21.6257 1.67357C22.1076 1.67357 22.3486 3.08393 22.3486 3.44929C22.3486 3.84214 22.2222 5.18179 21.6415 5.18179Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n<path d=\"M31.9012 4.16822C30.882 4.16822 29.4637 4.6318 29.4637 5.84572C29.4637 6.53715 29.9733 7.56251 30.7832 7.56251C31.2929 7.56251 31.6208 7.16965 31.7906 7.16965C31.8341 7.16965 31.8736 7.19715 31.8736 7.24037C31.8736 7.64894 31.0795 7.83358 30.7674 7.83358C29.677 7.83358 29.0963 6.90251 29.0963 5.91644C29.0963 4.70644 30.242 3.77537 31.4035 3.77537C31.7432 3.77537 32.0988 3.87358 32.4385 3.87358C33.4459 3.87358 34.165 2.97394 34.165 2.01537C34.165 0.424295 32.2687 0.0589382 31.0045 0.0589382C27.6464 0.0589382 25.6909 2.22751 25.6909 5.52358C25.6909 8.56822 27.279 10.5089 30.4237 10.5089C32.4622 10.5089 34.6864 9.6368 34.6864 7.26787C34.6864 5.6493 33.6237 4.16822 31.8973 4.16822H31.9012Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n<path d=\"M41.2681 6.56464C41.0113 6.56464 40.802 6.66286 40.5886 6.66286C40.5452 6.66286 40.5333 6.61964 40.5333 6.59214C40.5333 6.49393 40.5768 6.45071 40.6479 6.42321C40.8889 6.34071 41.1457 6.28179 41.3827 6.16786C42.4612 5.66107 43.0973 4.7575 43.0973 3.56321C43.0973 1.40643 41.2405 0.0982143 39.202 0.0982143C38.4632 0.0982143 37.7442 0.310357 37.12 0.648214C35.4212 1.56357 35.0933 2.87571 34.9946 4.66321C34.9511 5.36643 34.9511 6.07357 34.9511 6.77679V8.48179C34.9511 9.55036 35.6583 10.4107 36.7763 10.4107C37.5822 10.4107 38.3052 9.83321 38.4909 9.07107C38.5896 8.61929 38.5343 8.085 38.5343 7.64893C38.5343 7.60571 38.5501 7.59393 38.5896 7.59393C38.6291 7.59393 38.6765 7.62143 38.7042 7.63714C39.202 8.83536 39.8815 10.3557 41.4222 10.3557C42.4849 10.3557 43.362 9.60929 43.362 8.525C43.362 7.44071 42.3427 6.56857 41.2642 6.56857L41.2681 6.56464ZM38.961 5.18179C38.8464 5.18179 38.7476 5.08357 38.7476 4.96964C38.7476 4.81643 38.961 4.7025 39.0321 4.57679C39.1862 4.29393 39.2296 3.81464 39.2296 3.4925C39.2296 3.11143 39.1309 2.40821 38.8899 2.12536C38.8188 2.04286 38.7358 1.99964 38.7358 1.88571C38.7358 1.77179 38.8346 1.67357 38.9491 1.67357C39.4311 1.67357 39.6721 3.08393 39.6721 3.44929C39.6721 3.84214 39.5575 5.18179 38.9649 5.18179H38.961Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n<path d=\"M46.7674 0.549991C46.4277 0.326063 45.9457 0.212134 45.5348 0.212134C44.642 0.212134 43.8756 0.915349 43.7768 1.79142C43.7491 2.04678 43.761 2.28642 43.761 2.55356V4.94606L43.7175 7.46821V8.72142C43.7175 9.70749 44.5669 10.4814 45.5467 10.4814C46.2696 10.4814 47.0637 10.0296 47.3324 9.35392C47.4864 8.97285 47.5022 8.43856 47.5022 8.02999V6.92999L47.518 4.73392V2.53785C47.518 1.72071 47.5022 1.07249 46.7674 0.549991Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n<path d=\"M50.2993 0.125713C48.8533 0.125713 48.1304 0.801428 48.1304 2.25107V2.82857L48.1462 3.96786V4.54536C48.1462 4.98143 48.1462 5.39 48.1304 5.82607C48.1027 6.34857 48.0316 6.86714 48.0316 7.40536C48.0316 9.3775 49.0509 10.3361 51.0222 10.3361C54.0523 10.3361 56.1067 9.03964 56.1067 5.81429C56.1067 1.925 54.2222 0.121785 50.2993 0.121785V0.125713ZM51.6583 7.91607C51.5437 7.91607 51.4449 7.81786 51.4449 7.70393C51.4449 7.66071 51.4608 7.83352 51.4884 7.59C51.8558 6.985 51.9546 6.14036 51.9546 5.44893C51.9546 4.80071 51.8835 3.84214 51.4726 3.33536C51.4015 3.22143 51.2593 3.13893 51.2593 2.9975C51.2593 2.88357 51.358 2.78536 51.4726 2.78536C51.6859 2.78536 51.9822 3.31964 52.0691 3.50428C52.3378 4.125 52.3812 4.80071 52.3812 5.46071C52.3812 5.86928 52.1679 7.91214 51.6583 7.91214V7.91607Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n<path d=\"M62.7239 5.1268C61.9022 5.05608 60.7249 4.77322 60.0889 4.23894C60.0059 4.16822 59.8637 4.07001 59.8637 3.9443C59.8637 3.90108 59.8795 3.83037 59.9348 3.83037C60.0889 3.83037 61.0805 4.62001 61.9338 4.62001C63.0123 4.62001 64 3.78715 64 2.69108C64 0.887867 61.5941 0.157152 60.1324 0.157152C57.9635 0.157152 56.3516 1.5518 56.3516 3.76358C56.3516 4.24287 56.4227 4.90287 56.7783 5.27215C56.9482 5.4568 57.2326 5.4568 57.4578 5.4568C58.3072 5.4568 59.3857 5.72394 59.836 6.49787C59.8795 6.56858 59.919 6.68251 59.919 6.76501C59.919 6.79251 59.919 6.83572 59.8914 6.82001C59.8084 6.79251 59.7373 6.7218 59.678 6.6668C59.1802 6.18751 58.5007 5.70822 57.7817 5.70822C56.7032 5.70822 56.324 6.73751 56.324 7.63715C56.324 9.45215 57.9674 10.4539 59.6385 10.4539C61.6217 10.4539 64 9.15751 64 6.94572C64 6.12858 63.6444 5.21322 62.7239 5.13072V5.1268Z\" fill=\"#000020\" fill-opacity=\"0.1\"/>\n</svg>", H = class extends I {
530
+ constructor(...e) {
531
+ super(...e), this.events = { click: "onClick" };
532
+ }
533
+ get styleSheets() {
534
+ return [De];
535
+ }
536
+ onClick(e) {
537
+ e.target.closest(".bar__send") && this.handleSend();
538
+ }
539
+ setupEffects() {
540
+ let e = null, t = null;
541
+ this.addEffect(() => {
542
+ let t = this.gridStore.replyingTo.value;
543
+ if (t && t !== e) {
544
+ let e = this.getElement("pop-comment-input");
545
+ e && setTimeout(() => e.focus(), 0);
546
+ }
547
+ e = t;
548
+ }), this.addEffect(() => {
549
+ let e = this.gridStore.editingComment.value;
550
+ if (e && e.id !== t) {
551
+ let t = this.getElement("pop-comment-input");
552
+ t && (t.setValue(e.body), setTimeout(() => t.focus(), 0));
553
+ } else if (!e && t) {
554
+ let e = this.getElement("pop-comment-input");
555
+ e && e.clear();
556
+ }
557
+ t = e?.id ?? null;
558
+ }), this.addEffect(() => {
559
+ let e = g.value, t = this.getElement(".bar__user");
560
+ if (!t) return;
561
+ let n = this.gridStore.replyingToComment.value?.author;
562
+ if (this.gridStore.editingComment.value) {
563
+ t.classList.remove("has-reply");
564
+ let n = e?.id ?? e?.name ?? "";
565
+ t.innerHTML = e?.image ? `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--user" data-color-key="${n}"><img src="${e.image}" alt="${e.name ?? "User"}'s avatar"></pop-comment-avatar>` : `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--user" data-color-key="${n}">${B(e?.name)}</pop-comment-avatar>`;
566
+ } else if (n) {
567
+ t.classList.add("has-reply");
568
+ let r = n.id ?? n.name ?? "", i = e?.id ?? e?.name ?? "";
569
+ t.innerHTML = (n.image ? `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--reply" data-color-key="${r}"><img src="${n.image}" alt="${n.name ?? "User"}'s avatar"></pop-comment-avatar>` : `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--reply" data-color-key="${r}">${B(n.name)}</pop-comment-avatar>`) + (e?.image ? `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--user" data-color-key="${i}"><img src="${e.image}" alt="${e.name ?? "User"}'s avatar"></pop-comment-avatar>` : `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--user" data-color-key="${i}">${B(e?.name)}</pop-comment-avatar>`);
570
+ } else {
571
+ t.classList.remove("has-reply");
572
+ let n = e?.id ?? e?.name ?? "";
573
+ t.innerHTML = e?.image ? `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--user" data-color-key="${n}"><img src="${e.image}" alt="${e.name ?? "User"}'s avatar"></pop-comment-avatar>` : `<pop-comment-avatar size="xs" class="bar__avatar bar__avatar--user" data-color-key="${n}">${B(e?.name)}</pop-comment-avatar>`;
574
+ }
575
+ });
576
+ }
577
+ async handleSend() {
578
+ let e = this.getElement("pop-comment-input");
579
+ if (!e) return;
580
+ let t = e.getValue().trim();
581
+ if (!t) return;
582
+ let n = this.gridStore.editingCommentId.value;
583
+ if (n) e.clear(), this.gridStore.editingCommentId.value = null, await this.gridStore.editComment(n, t);
584
+ else {
585
+ e.clear();
586
+ let n = await this.gridStore.postComment(t, this.gridStore.replyingTo.value ?? void 0);
587
+ this.gridStore.replyingTo.value = null, n && (this.gridStore.scrollingCommentId.value = n.id);
588
+ }
589
+ }
590
+ getTemplate() {
591
+ return `
592
+ <div class="logo-watermark">${V}</div>
593
+ <div class="bar">
594
+ <div class="bar__user">
595
+ <pop-comment-avatar size="xs" class="bar__avatar bar__avatar--user">?</pop-comment-avatar>
152
596
  </div>
153
- </div>
154
- `}};u.styles=[l(u,u,"styles"),Y],i([Kt({context:D,subscribe:!0})],u.prototype,"authContext",2),i([G(".auth-panel")],u.prototype,"_authPanel",2),i([G(".auth-panel__content")],u.prototype,"_authPanelContent",2),i([P()],u.prototype,"_email",2),i([P()],u.prototype,"_open",2),u=i([Qt("pop-auth-panel")],u);var Zt=u;import{consume as Pt,provide as Wt}from"@lit/context";import{PopElement as Xt}from"@popgrids/ui";import{html as Ot}from"lit";import{customElement as te,property as ee,state as q}from"lit/decorators.js";import{createContext as Yt}from"@lit/context";var E=Yt(Symbol("pop-api-context"));import{css as Gt}from"lit";var W=Gt`
155
- :host {
156
- display: block;
157
- }
158
- `;var U="popgrids_token",f=class extends Xt{constructor(){super(...arguments);this.error=null;this.isAuthenticated=!1;this.currentAccount=null;this.isVerifying=!1;this.token=null;this.verificationExpiresAt=null;this.contextData={currentAccount:null,error:null,isAuthenticated:!1,isVerifying:!1,signIn:this.signIn.bind(this),signOut:this.signOut.bind(this),token:null,verificationExpiresAt:null,verifyCode:this.verifyCode.bind(this)}}connectedCallback(){super.connectedCallback();let t=localStorage.getItem(U);t&&(this.token=t,this.fetchCurrentAccount())}async fetchCurrentAccount(){if(!(!this.token||!this.apiState?.client)){console.log("fetchCurrentAccount",this.token);try{let{data:t,error:e}=await this.apiState.client.GET("/api/v1/users/me",{headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json",Accept:"application/json"}});e&&this.signOut(),t?(this.currentAccount=t,this.isAuthenticated=!0,this.updateContextData()):this.signOut()}catch(t){console.error("Failed to fetch current account:",t),this.signOut()}}}async signIn(t){if(!this.apiState?.client)throw new Error("API client not available");try{let{data:e,error:r}=await this.apiState.client.POST("/api/v1/session",{params:{query:{email:t.email}}});if(r&&(this.error=r,this.updateContextData()),e)return this.isVerifying=!0,this.verificationExpiresAt=e.expires,this.updateContextData(),e;throw new Error("Authentication failed")}catch(e){throw console.error("Sign in failed:",e),e}}async verifyCode(t,e){if(this.apiState?.client)try{let{data:r,error:n}=await this.apiState.client.PUT("/api/v1/session",{params:{query:{code:t,email:e}}});if(n&&(this.error=n,this.updateContextData()),r)this.token=`${r.token}`,localStorage.setItem(U,this.token),this.isVerifying=!1,this.verificationExpiresAt=null,await this.fetchCurrentAccount();else throw new Error("Verification failed")}catch(r){throw console.error("Verification failed:",r),r}}signOut(){this.token=null,this.currentAccount=null,this.isAuthenticated=!1,this.isVerifying=!1,this.verificationExpiresAt=null,localStorage.removeItem(U),this.updateContextData()}updateContextData(){this.contextData={...this.contextData,error:this.error,isAuthenticated:this.isAuthenticated,isVerifying:this.isVerifying,currentAccount:this.currentAccount,token:this.token,verificationExpiresAt:this.verificationExpiresAt}}render(){return Ot`<slot part="base"></slot>`}};f.styles=[W],i([Pt({context:E})],f.prototype,"apiState",2),i([q()],f.prototype,"error",2),i([q()],f.prototype,"isAuthenticated",2),i([q()],f.prototype,"currentAccount",2),i([q()],f.prototype,"isVerifying",2),i([q()],f.prototype,"token",2),i([q()],f.prototype,"verificationExpiresAt",2),i([Wt({context:D}),ee({attribute:!1})],f.prototype,"contextData",2),f=i([te("pop-auth-provider")],f);var ie=f;import{consume as se}from"@lit/context";import{PopElement as oe}from"@popgrids/ui";import{html as le}from"lit";import{customElement as de,state as B}from"lit/decorators.js";import{classMap as pe}from"lit/directives/class-map.js";var X="./apple-IX52EWYN.png";var O="./google-Q3MFTU5A.png";import{css as ne}from"lit";var tt=ne`
159
- :host {
160
- display: block;
161
- }
162
-
163
- .auth-sign-in {
164
- display: flex;
165
- padding: var(--spacing-2xl, 20px) var(--spacing-3xl, 24px);
166
- flex-direction: column;
167
- justify-content: center;
168
- align-items: center;
169
- gap: var(--spacing-xl, 16px);
170
- }
171
-
172
- .auth-sign-in__footer {
173
- display: flex;
174
- flex-direction: column;
175
- gap: var(--spacing-xl, 16px);
176
- font-size: var(--text-widget-base);
177
- line-height: var(--text-widget-base--line-height);
178
- letter-spacing: var(--text-widget-base--letter-spacing);
179
- font-weight: 500;
180
- }
181
-
182
- .auth-sign-in__form {
183
- display: flex;
184
- flex-direction: column;
185
- gap: var(--spacing-xl, 16px);
186
- justify-content: center;
187
- align-items: center;
188
- width: 100%;
189
- }
190
-
191
- .auth-sign-in__apple-icon,
192
- .auth-sign-in__google-icon {
193
- border: none;
194
- background-color: transparent;
195
- display: flex;
196
- width: 32px;
197
- height: 32px;
198
- justify-content: center;
199
- align-items: center;
200
- transition: transform 300ms ease-out;
201
- }
202
-
203
- .auth-sign-in__apple-icon:hover,
204
- .auth-sign-in__google-icon:hover {
205
- transform: scale(1.125);
206
- }
207
-
208
- .auth-sign-in__social-login {
209
- display: flex;
210
- padding: 0px var(--spacing-2xl, 20px);
211
- justify-content: center;
212
- align-items: center;
213
- gap: var(--spacing-4xl, 32px);
214
- align-self: stretch;
215
- }
216
-
217
- .auth-sign-in__title {
218
- font-size: var(--text-widget-base);
219
- line-height: var(--text-widget-base--line-height);
220
- letter-spacing: var(--text-widget-base--letter-spacing);
221
- font-weight: 600;
222
- }
223
-
224
- .auth-sign-in__submit-button {
225
- width: 100%;
226
- height: 40px;
227
- color: var(--color-text-text-default);
228
- }
229
-
230
- .auth-sign-in__email-input {
231
- width: 100%;
232
- height: 40px;
233
- color: var(--color-text-text-default);
234
- }
235
- `;var ce=O,me=X,h=class extends oe{constructor(){super(...arguments);this.email="";this.emailError="";this.isSubmitting=!1;this.isValid=!1}validateEmail(t){return t?!0:(this.emailError="Please enter an email address",this.isValid=!1,!1)}handleBlur(){this.email&&this.validateEmail(this.email)}handleEmailChange(t){this.email=t.target.value,this.email?this.validateEmail(this.email):(this.emailError="",this.isValid=!1)}handleInvalid(t){let{valid:e,validationMessage:r,validity:n}=t.detail;e||(console.log("Validation failed:",r),n.typeMismatch&&console.log("Invalid email format"),n.patternMismatch&&console.log("Pattern mismatch")),this.isValid=e}async handleSubmit(t){if(t.preventDefault(),!(!this.validateEmail(this.email)||this.isSubmitting)){if(!this.authContext?.signIn)throw new Error("Authentication context not available");this.isSubmitting=!0;try{let e=await this.authContext.signIn({email:this.email});this.onSuccess(e)}catch{this.onFailure()}finally{this.isSubmitting=!1}}}onSuccess(t){this.emit("pop-success",{email:t.email,expires:t.expires})}onFailure(){console.log("failure"),this.emit("pop-error",{error:"Creating a session failed",success:!1})}render(){return le`<div
236
- class=${pe({"auth-sign-in":!0})}
237
- part="base"
238
- >
239
- <form class="auth-sign-in__form" @submit=${this.handleSubmit}>
240
- <pop-logo variant="logo" theme="white" style="width: 100px; height: 16px;"></pop-logo>
241
- <h2 class="auth-sign-in__title">Small communities, big connections 👋</h2>
242
- <pop-form-input-simple
243
- aria-invalid=${this.emailError?"true":"false"}
244
- aria-describedby="email-error"
245
- autocomplete="off"
246
- errorMessage=${this.emailError}
247
- name="email"
248
- type="email"
249
- placeholder="Email"
250
- pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+.[a-zA-Z]{2,}"
251
- .value=${this.email}
252
- .disabled=${this.isSubmitting}
253
- ?required=${!0}
254
- ?error=${!!this.emailError}
255
- @input=${this.handleEmailChange}
256
- @blur=${this.handleBlur}
257
- @pop-invalid=${this.handleInvalid}
258
- ></pop-form-input-simple>
259
- <pop-button
260
- class="auth-sign-in__submit-button"
261
- theme="brand"
262
- variant="primary"
263
- current
264
- ?disabled=${this.isSubmitting||!this.isValid}
265
- >
266
- ${this.isSubmitting?"Submitting...":"Continue"}
267
- </pop-button>
268
- </form>
269
- <div class="auth-sign-in__social-login">
270
- <button class="auth-sign-in__google-icon" type="button">
271
- <img src=${ce} alt="Google" />
272
- </button>
273
- <button class="auth-sign-in__apple-icon" type="button">
274
- <img src=${me} alt="Apple" />
597
+ <div class="bar__input-wrap">
598
+ <pop-comment-input></pop-comment-input>
599
+ </div>
600
+ <button class="bar__send" type="button" aria-label="Send comment">
601
+ <pop-comment-icon theme="neutral" variant="send"></pop-comment-icon>
275
602
  </button>
276
603
  </div>
277
- <div class="auth-sign-in__footer">
278
- <pop-button-link ?primary=${!0} size="sm">What's Popgrids?</pop-button-link>
279
- </div>
280
- </div>`}};h.styles=[l(h,h,"styles"),tt],i([se({context:D,subscribe:!0})],h.prototype,"authContext",2),i([B()],h.prototype,"email",2),i([B()],h.prototype,"emailError",2),i([B()],h.prototype,"isSubmitting",2),i([B()],h.prototype,"isValid",2),h=i([de("pop-auth-sign-in")],h);var ue=h;import{consume as he}from"@lit/context";import{PopElement as ge}from"@popgrids/ui";import{html as z}from"lit";import{customElement as xe,property as ve,query as ye,queryAll as be,state as L}from"lit/decorators.js";import{classMap as Ce}from"lit/directives/class-map.js";import{when as it}from"lit/directives/when.js";import{css as fe}from"lit";var et=fe`
281
- :host {
282
- display: block;
283
- }
284
-
285
- .auth-verify-code {
286
- display: flex;
287
- padding: var(--spacing-2xl, 20px) var(--spacing-3xl, 24px);
288
- flex-direction: column;
289
- justify-content: center;
290
- align-items: center;
291
- gap: var(--spacing-xl, 16px);
292
- position: relative;
293
- }
294
-
295
- .auth-verify-code__toast {
296
- position: absolute;
297
- }
298
-
299
- .auth-verify-code__body {
300
- display: flex;
301
- flex-direction: column;
302
- align-items: center;
303
- gap: var(--spacing-md, 8px);
304
- align-self: stretch;
305
- font-size: var(--text-xs);
306
- line-height: var(--text-xs--line-height);
307
- text-align: center;
308
- }
309
-
310
- .auth-verify-code__help .auth-verify-code__body {
311
- text-align: left;
312
- }
313
-
314
- .auth-verify-code__body strong {
315
- font-weight: 600;
316
- }
317
-
318
- .auth-verify-code__footer {
319
- display: flex;
320
- color: var(--color-text-text-default);
321
- justify-content: center;
322
- align-items: flex-start;
323
- gap: var(--spacing-2xl, 20px);
324
- }
325
-
326
- .auth-verify-code__form {
327
- display: flex;
328
- flex-direction: column;
329
- align-items: center;
330
- gap: var(--spacing-xl, 16px);
331
- }
332
-
333
- .auth-verify-code__help {
334
- display: flex;
335
- flex-direction: column;
336
- align-items: center;
337
- gap: var(--spacing-xl, 16px);
338
- }
339
-
340
- .auth-verify-code__title {
341
- font-size: var(--text-widget-base);
342
- line-height: var(--text-widget-base--line-height);
343
- letter-spacing: var(--text-widget-base--letter-spacing);
344
- font-weight: 600;
345
- }
346
-
347
- .auth-verify-code__code-input-fields {
348
- display: flex;
349
- justify-content: center;
350
- align-items: flex-start;
351
- gap: var(--spacing-xl, 16px);
352
- margin-bottom: var(--spacing-xs, 4px);
353
- }
354
-
355
- .auth-verify-code__code-input-group {
356
- display: flex;
357
- align-items: center;
358
- gap: var(--spacing-sm, 6px);
359
- }
360
- `;var p=class extends ge{constructor(){super(...arguments);this.email="";this.code="";this.isSubmitting=!1;this.error="";this._showingHelp=!1;this._showingToast=!1;this._toastMessage=""}getCodeInput(t){return this.codeInputs[t]}closeToast(){this._showingToast=!1}handleContactSupport(){console.log("handleContactSupport")}async handleResendCode(){console.log("handleResendCode");try{let t=await this.authContext?.signIn({email:this.email});this._showingHelp=!1}catch(t){console.error(t)}finally{this.isSubmitting=!1}}handleInput(t){let e=t.target,r=/^\d$/.test(e.value);if(r||e.value===""){if(r){let n=Array.from(this.codeInputs).indexOf(t.currentTarget);n<this.codeInputs.length-1&&this.getCodeInput(n+1)?.focus()}this.updateCodeValue()}else e.value=""}handleKeyDown(t){let e=t.target,r=Array.from(this.codeInputs).indexOf(t.currentTarget);if(t.key==="Backspace"&&e.value===""&&r>0){let n=this.getCodeInput(r-1);n?.focus(),n?.select()}if(t.key==="ArrowLeft"&&r>0){let n=this.getCodeInput(r-1);n?.focus(),n?.select()}if(t.key==="ArrowRight"&&r<this.codeInputs.length-1){let n=this.getCodeInput(r+1);n?.focus(),n?.select()}}handleFocus(t){t.target.select()}showToast(t){this._showingToast=!0,this._toastMessage=t}toggleHelp(){this._showingHelp=!this._showingHelp,console.log("handleNeedHelpClick")}handleSubmit(t){t.preventDefault(),this.submitForm()}handlePaste(t){t.preventDefault();let e=t.clipboardData;if(!e)return;e.getData("text").replace(/\D/g,"").substring(0,this.codeInputs.length).split("").forEach((_,d)=>{if(d<this.codeInputs.length){let c=this.getCodeInput(d);c&&(c.value=_)}});let o=Array.from(this.codeInputs).findIndex(_=>!_.value),M=o!==-1?o:this.codeInputs.length-1;this.getCodeInput(M)?.focus(),this.updateCodeValue()}updateCodeValue(){let t=Array.from(this.codeInputs).map(r=>r.value);this.code=t.join(""),this.hiddenInput&&(this.hiddenInput.value=this.code),t.length===6&&t.every(r=>/^\d$/.test(r))&&setTimeout(()=>this.submitForm(),0)}async submitForm(){if(!(!this.authContext?.verifyCode||this.isSubmitting||!this.email||this.code.length!==6)){this.isSubmitting=!0,this.error="";try{await this.authContext.verifyCode(this.code,this.email),this.onSuccess()}catch{this.onFailure()}finally{this.isSubmitting=!1}}}onSuccess(){this.emit("pop-success")}onFailure(){this.showToast("Verification failed. Please try again."),Array.from(this.codeInputs).forEach(t=>{t.value=""}),this.codeInputs.length&&this.getCodeInput(0)?.focus(),this.code=""}render(){return z`<div
361
- class=${Ce({"auth-verify-code":!0})}
362
- part="base"
363
- >
364
- ${it(this._showingToast,()=>z`<pop-toast class="auth-verify-code__toast" theme="transparent" @pop-close=${this.closeToast}
365
- >${this._toastMessage}</pop-toast
366
- >`)}
367
- ${it(!this._showingHelp,()=>z`
368
- <form class="auth-verify-code__form" @submit=${this.handleSubmit}>
369
- <input type="hidden" name="code" value=${this.code} />
370
- <h2 class="auth-verify-code__title">Enter Verification Code</h2>
371
- <div class="auth-verify-code__code-input-fields">
372
- <div class="auth-verify-code__code-input-group">
373
- <pop-code-input-field
374
- name="code_1"
375
- autofocus
376
- .disabled=${this.isSubmitting}
377
- @input=${this.handleInput}
378
- @keydown=${this.handleKeyDown}
379
- @focus=${this.handleFocus}
380
- @paste=${this.handlePaste}
381
- ></pop-code-input-field>
382
- <pop-code-input-field
383
- name="code_2"
384
- .disabled=${this.isSubmitting}
385
- @input=${this.handleInput}
386
- @keydown=${this.handleKeyDown}
387
- @focus=${this.handleFocus}
388
- @paste=${this.handlePaste}
389
- ></pop-code-input-field>
390
- <pop-code-input-field
391
- name="code_3"
392
- .disabled=${this.isSubmitting}
393
- @input=${this.handleInput}
394
- @keydown=${this.handleKeyDown}
395
- @focus=${this.handleFocus}
396
- @paste=${this.handlePaste}
397
- ></pop-code-input-field>
398
- </div>
399
- <div class="auth-verify-code__code-input-group">
400
- <pop-code-input-field
401
- name="code_4"
402
- .disabled=${this.isSubmitting}
403
- @input=${this.handleInput}
404
- @keydown=${this.handleKeyDown}
405
- @focus=${this.handleFocus}
406
- @paste=${this.handlePaste}
407
- ></pop-code-input-field>
408
- <pop-code-input-field
409
- name="code_5"
410
- .disabled=${this.isSubmitting}
411
- @input=${this.handleInput}
412
- @keydown=${this.handleKeyDown}
413
- @focus=${this.handleFocus}
414
- @paste=${this.handlePaste}
415
- ></pop-code-input-field>
416
- <pop-code-input-field
417
- name="code_6"
418
- .disabled=${this.isSubmitting}
419
- @input=${this.handleInput}
420
- @keydown=${this.handleKeyDown}
421
- @focus=${this.handleFocus}
422
- @paste=${this.handlePaste}
423
- ></pop-code-input-field>
424
- </div>
425
- </div>
426
-
427
- <div class="auth-verify-code__body">
428
- <p>A verification code has been sent to your email. Enter code to continue.</p>
429
- <p>
430
- Code expires in
431
- <pop-timestamp-countdown>${this.authContext?.verificationExpiresAt}</pop-timestamp-countdown>.
432
- </p>
433
- </div>
434
-
435
- <div class="auth-verify-code__footer">
436
- <pop-button-link size="sm" theme="default" ?primary=${!0} @click=${this.toggleHelp}>
437
- No verification code?
438
- </pop-button-link>
439
- </div>
440
- </form>
441
- `,()=>z`
442
- <div class="auth-verify-code__help">
443
- <h2 class="auth-verify-code__title">Steps to Take</h2>
444
- <div class="auth-verify-code__body">
445
- <ul>
446
- <li><strong>Check spam/junk</strong> – it might be there.</li>
447
- <li><strong>Verify email</strong> – check your email for typos.</li>
448
- <li><strong>Wait a moment</strong> – emails take a few mins.</li>
449
- <li><strong>Whitelist us</strong> – it may be blocked.</li>
450
- </ul>
451
- </div>
452
- <div class="auth-verify-code__footer">
453
- <pop-button-link size="sm" theme="default" @click=${this.handleContactSupport}>
454
- Contact Support
455
- </pop-button-link>
456
- <pop-button-link size="sm" theme="default" ?primary=${!0} @click=${this.handleResendCode}>
457
- Resend Code
458
- </pop-button-link>
459
- </div>
460
- </div>
461
- `)}
462
- </div>`}};p.styles=[l(p,p,"styles"),et],i([he({context:D,subscribe:!0})],p.prototype,"authContext",2),i([ve({type:String})],p.prototype,"email",2),i([L()],p.prototype,"code",2),i([L()],p.prototype,"isSubmitting",2),i([L()],p.prototype,"error",2),i([L()],p.prototype,"_showingHelp",2),i([L()],p.prototype,"_showingToast",2),i([L()],p.prototype,"_toastMessage",2),i([ye('input[name="code"]')],p.prototype,"hiddenInput",2),i([be("pop-code-input-field")],p.prototype,"codeInputs",2),p=i([xe("pop-auth-verify-code")],p);var we=p;import{PopElement as ke}from"@popgrids/ui";import{html as je}from"lit";import{customElement as De}from"lit/decorators.js";import{classMap as Ae}from"lit/directives/class-map.js";import{css as Se}from"lit";var rt=Se`
463
- :host {
464
- display: block;
465
- }
466
-
467
- .comment-bar {
468
- align-items: flex-start;
469
- background: var(--color-border-singular-border-island);
470
- border-top: 1px solid var(--color-surface-alpha-alpha-input-bar);
471
- padding: var(--spacing-sm, 6px) var(--spacing-sm, 6px) var(--spacing-md, 8px) var(--spacing-sm, 6px);
472
- position: relative;
473
- transition: all var(--duration-quick) var(--ease-quick);
474
- }
475
-
476
- .comment-bar__actions {
477
- position: relative;
478
- display: grid;
479
- grid-template-columns: auto 1fr 0px;
480
- gap: 6px;
481
- align-items: start;
482
- transition: all var(--duration-quick) var(--ease-quick);
483
- }
484
- .comment-bar--has-content {
485
- grid-template-columns: auto 1fr 32px;
486
- }
487
-
488
- .comment-bar__avatars {
489
- display: flex;
490
- align-items: center;
491
- padding-top: 2px;
492
- }
493
-
494
- .comment-bar__avatars > *:not(:last-child) {
495
- margin-right: -4px;
496
- }
497
-
498
- .comment-bar__avatars > pop-comment-avatar {
499
- transition: transform var(--duration-pop-hover) var(--ease-pop-hover);
500
- }
501
- .comment-bar__avatars > pop-comment-avatar:hover {
502
- transform: scale(1.1875);
503
- }
504
-
505
- .comment-bar__send-icon {
506
- position: absolute;
507
- right: 0;
508
- bottom: 0.5px;
509
- transition: opacity var(--duration-150) var(--ease-linear);
510
- opacity: 0;
511
- }
512
- .comment-bar--has-content .comment-bar__send-icon {
513
- opacity: 1;
514
- }
515
- `;var A=class extends ke{render(){return je`
516
- <div
517
- class=${Ae({"comment-bar":!0})}
604
+ `;
605
+ }
606
+ };
607
+ L([C(D)], H.prototype, "gridStore", void 0), customElements.get("pop-comment-bar") || customElements.define("pop-comment-bar", H);
608
+ //#endregion
609
+ //#region src/components/pop-comment-icon.ts
610
+ var Oe = F("\n :host {\n /* Mode-level theme colors (defaults for light mode) */\n --pop-comment-color-black: #000000;\n --pop-comment-color-white: #ffffff;\n --pop-comment-color-default: #000000;\n --pop-comment-color-reversed: #ffffff;\n --pop-comment-bg-singular-resting: #121926;\n --pop-comment-bg-singular-hover: rgba(0, 0, 32, 0.08);\n --pop-comment-bg-reversed: #121926;\n --pop-comment-bg-blank-resting: #ffffff;\n\n display: flex;\n\n --pop-comment-icon-scale: 1;\n --pop-comment-icon-scale-hover: 1.1875;\n --pop-comment-icon-scale-active: 0.9375;\n --pop-comment-icon-size: 32px;\n --pop-comment-icon-color: var(--pop-foreground, #000000);\n --pop-comment-icon-color-hover: var(--pop-foreground, #000000);\n --pop-comment-icon-color-active: var(--pop-foreground, #000000);\n --pop-comment-icon-color-focused: var(--pop-foreground, #000000);\n --pop-comment-icon-background: var(\n --color-surface-buttons-singular-bg-launch-icon-hover,\n rgba(0, 0, 32, 0.08)\n );\n --pop-comment-icon-background-hover: var(\n --color-surface-buttons-singular-bg-launch-icon-hover,\n rgba(0, 0, 32, 0.08)\n );\n --pop-comment-icon-background-active: var(\n --color-surface-buttons-singular-bg-launch-icon-hover,\n rgba(0, 0, 32, 0.08)\n );\n --pop-comment-icon-background-focused: var(\n --color-surface-buttons-singular-bg-launch-icon-hover,\n rgba(0, 0, 32, 0.08)\n );\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n /* Overrides for dark mode */\n --pop-comment-color-black: #ffffff;\n --pop-comment-color-white: #000000;\n --pop-comment-color-default: #ffffff;\n --pop-comment-color-reversed: #000000;\n --pop-comment-bg-singular-resting: #ffffff;\n --pop-comment-bg-singular-hover: rgba(255, 255, 255, 0.15);\n --pop-comment-bg-reversed: #ffffff;\n --pop-comment-bg-blank-resting: #121926;\n }\n }\n\n :host(.dark) {\n /* Overrides for dark mode (.dark class on host) */\n --pop-comment-color-black: #ffffff;\n --pop-comment-color-white: #000000;\n --pop-comment-color-default: #ffffff;\n --pop-comment-color-reversed: #000000;\n --pop-comment-bg-singular-resting: #ffffff;\n --pop-comment-bg-singular-hover: rgba(255, 255, 255, 0.15);\n --pop-comment-bg-reversed: #ffffff;\n --pop-comment-bg-blank-resting: #121926;\n }\n\n .comment-icon {\n align-items: center;\n background: transparent;\n border: none;\n display: inline-flex;\n height: var(--pop-comment-icon-size);\n justify-content: center;\n padding: 0;\n position: relative;\n transform-origin: center;\n width: var(--pop-comment-icon-size);\n }\n\n .comment-icon--size-sm {\n --pop-comment-icon-size: 24px;\n }\n\n .comment-icon:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .comment-icon__focus-indicator {\n display: none;\n height: calc(100% + 3px);\n inset: -1.5px;\n transform-origin: center;\n transform: scale(var(--pop-comment-icon-scale));\n transition: all 200ms ease-out;\n width: calc(100% + 3px);\n }\n\n .comment-icon:focus-visible .comment-icon__focus-indicator {\n display: flex;\n }\n\n .comment-icon:focus-visible {\n outline: none;\n }\n\n .comment-icon__inner {\n align-items: center;\n background: var(--pop-comment-icon-background);\n color: var(--pop-comment-icon-color);\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n height: var(--pop-comment-icon-size);\n justify-content: center;\n position: absolute;\n transform-origin: center;\n transition: all 200ms ease-out;\n transform: scale(var(--pop-comment-icon-scale));\n width: var(--pop-comment-icon-size);\n }\n\n .comment-icon__icon-container {\n align-items: center;\n display: flex;\n height: 100%;\n justify-content: center;\n transition: transform ease-out 150ms;\n width: 100%;\n }\n\n .comment-icon__icon-container svg {\n width: calc(var(--pop-comment-icon-size) * 0.6875);\n height: calc(var(--pop-comment-icon-size) * 0.6875);\n }\n\n .comment-icon--variant-close.comment-icon--theme-neutral .comment-icon__icon-container svg {\n width: var(--pop-comment-icon-size);\n height: var(--pop-comment-icon-size);\n }\n\n .comment-icon__icon-image {\n display: flex;\n width: var(--pop-comment-icon-size);\n height: var(--pop-comment-icon-size);\n }\n\n .comment-icon__icon {\n display: flex;\n }\n\n .comment-icon__icon-image + .comment-icon__icon {\n display: none;\n }\n\n @media (hover: hover) and (pointer: fine) {\n .comment-icon:hover .comment-icon__inner {\n background: var(--pop-comment-icon-background-hover);\n color: var(--pop-comment-icon-color-hover);\n transition: transform var(--pop-ease-pop-hover) var(--pop-duration-pop-hover);\n transform: scale(var(--pop-comment-icon-scale-hover));\n }\n\n .comment-icon:hover .comment-icon__icon-image {\n display: none;\n }\n\n .comment-icon:hover .comment-icon__icon-image + .comment-icon__icon {\n display: flex;\n }\n }\n\n .comment-icon:active .comment-icon__inner {\n background: var(--pop-comment-icon-background-active);\n color: var(--pop-comment-icon-color-active);\n transform: scale(var(--pop-comment-icon-scale-active));\n transition-duration: 100ms;\n }\n\n .comment-icon:is(:focus-visible) .comment-icon__inner {\n background: var(--pop-comment-icon-background-focused);\n color: var(--pop-comment-icon-color-focused);\n }\n\n /* Brand / Add */\n .comment-icon--theme-brand.comment-icon--variant-add {\n --pop-comment-icon-color: var(--pop-comment-color-black);\n --pop-comment-icon-color-hover: var(--pop-comment-color-black);\n --pop-comment-icon-color-active: var(--pop-comment-color-black);\n --pop-comment-icon-color-focused: var(--pop-comment-color-black);\n --pop-comment-icon-background: transparent;\n --pop-comment-icon-background-hover: var(--pop-comment-bg-singular-hover);\n --pop-comment-icon-background-active: var(--pop-comment-bg-singular-hover);\n --pop-comment-icon-background-focused: transparent;\n }\n\n /* Brand / Close */\n .comment-icon--theme-brand.comment-icon--variant-close {\n --pop-comment-icon-color: var(--pop-comment-color-white);\n --pop-comment-icon-color-hover: var(--pop-comment-color-white);\n --pop-comment-icon-color-active: var(--pop-comment-color-white);\n --pop-comment-icon-color-focused: var(--pop-comment-color-white);\n --pop-comment-icon-background: var(--pop-comment-bg-singular-resting);\n --pop-comment-icon-background-hover: var(--pop-comment-bg-singular-resting);\n --pop-comment-icon-background-active: var(--pop-comment-bg-singular-resting);\n --pop-comment-icon-background-focused: var(--pop-comment-bg-singular-resting);\n }\n\n /* Neutral / Add */\n .comment-icon--theme-neutral.comment-icon--variant-add {\n --pop-comment-icon-color: var(--pop-comment-color-white);\n --pop-comment-icon-color-hover: var(--pop-comment-color-black);\n --pop-comment-icon-color-active: var(--pop-comment-color-black);\n --pop-comment-icon-color-focused: var(--pop-comment-color-white);\n --pop-comment-icon-background: var(--pop-comment-bg-singular-resting);\n --pop-comment-icon-background-hover: var(--pop-comment-bg-singular-hover);\n --pop-comment-icon-background-active: var(--pop-comment-bg-singular-hover);\n --pop-comment-icon-background-focused: var(--pop-comment-bg-singular-resting);\n }\n\n /* Neutral / Close */\n .comment-icon--theme-neutral.comment-icon--variant-close {\n --pop-comment-icon-color: var(--pop-comment-color-white);\n --pop-comment-icon-color-hover: var(--pop-comment-color-white);\n --pop-comment-icon-color-active: var(--pop-comment-color-white);\n --pop-comment-icon-color-focused: var(--pop-comment-color-white);\n --pop-comment-icon-background: var(--pop-comment-bg-singular-resting);\n --pop-comment-icon-background-hover: var(--pop-comment-bg-singular-resting);\n --pop-comment-icon-background-active: var(--pop-comment-bg-singular-resting);\n --pop-comment-icon-background-focused: var(--pop-comment-bg-singular-resting);\n }\n\n /* Neutral / Send */\n .comment-icon--theme-neutral.comment-icon--variant-send {\n --pop-comment-icon-color: var(--pop-comment-color-reversed);\n --pop-comment-icon-color-hover: var(--pop-comment-color-reversed);\n --pop-comment-icon-color-active: var(--pop-comment-color-reversed);\n --pop-comment-icon-color-focused: var(--pop-comment-color-reversed);\n --pop-comment-icon-background: var(--pop-comment-bg-reversed);\n --pop-comment-icon-background-hover: var(--pop-comment-bg-reversed);\n --pop-comment-icon-background-active: var(--pop-comment-bg-reversed);\n --pop-comment-icon-background-focused: var(--pop-comment-bg-reversed);\n }\n\n /* Neutral / More */\n .comment-icon--theme-neutral.comment-icon--variant-more {\n --pop-comment-icon-color: var(--pop-comment-color-default);\n --pop-comment-icon-color-hover: var(--pop-comment-color-reversed);\n --pop-comment-icon-color-active: var(--pop-comment-color-default);\n --pop-comment-icon-color-focused: var(--pop-comment-color-default);\n --pop-comment-icon-background: var(--pop-comment-bg-blank-resting);\n --pop-comment-icon-background-hover: var(--pop-comment-bg-reversed);\n --pop-comment-icon-background-active: var(--pop-comment-bg-blank-resting);\n --pop-comment-icon-background-focused: var(--pop-comment-bg-blank-resting);\n }\n\n /* Neutral / Cancel */\n .comment-icon--theme-neutral.comment-icon--variant-cancel {\n --pop-comment-icon-color: var(--pop-comment-color-default);\n --pop-comment-icon-color-hover: var(--pop-comment-color-default);\n --pop-comment-icon-color-active: var(--pop-comment-color-reversed);\n --pop-comment-icon-color-focused: var(--pop-comment-color-default);\n --pop-comment-icon-background: var(--pop-comment-bg-blank-resting);\n --pop-comment-icon-background-hover: var(--pop-comment-bg-blank-resting);\n --pop-comment-icon-background-active: var(--pop-comment-bg-reversed);\n --pop-comment-icon-background-focused: var(--pop-comment-bg-blank-resting);\n }\n"), ke = class extends I {
611
+ constructor(...e) {
612
+ super(...e), this.events = { click: "onClick" };
613
+ }
614
+ get styleSheets() {
615
+ return [Oe];
616
+ }
617
+ static get observedAttributes() {
618
+ return [
619
+ "counter",
620
+ "icon-url",
621
+ "size",
622
+ "theme",
623
+ "variant",
624
+ "type",
625
+ "disabled"
626
+ ];
627
+ }
628
+ onCounterChanged() {
629
+ this.render();
630
+ }
631
+ onIconUrlChanged() {
632
+ this.render();
633
+ }
634
+ onSizeChanged() {
635
+ this.render();
636
+ }
637
+ onThemeChanged() {
638
+ this.render();
639
+ }
640
+ onVariantChanged() {
641
+ this.render();
642
+ }
643
+ onTypeChanged() {
644
+ this.render();
645
+ }
646
+ onDisabledChanged() {
647
+ this.render();
648
+ }
649
+ get counter() {
650
+ return Number(this.getAttribute("counter") || "0");
651
+ }
652
+ set counter(e) {
653
+ this.setAttribute("counter", String(e));
654
+ }
655
+ get iconUrl() {
656
+ return this.getAttribute("icon-url") || void 0;
657
+ }
658
+ set iconUrl(e) {
659
+ e === void 0 ? this.removeAttribute("icon-url") : this.setAttribute("icon-url", e);
660
+ }
661
+ get size() {
662
+ return this.getAttribute("size") || "md";
663
+ }
664
+ set size(e) {
665
+ this.setAttribute("size", e);
666
+ }
667
+ get theme() {
668
+ return this.getAttribute("theme") || "brand";
669
+ }
670
+ set theme(e) {
671
+ this.setAttribute("theme", e);
672
+ }
673
+ get variant() {
674
+ return this.getAttribute("variant") || "add";
675
+ }
676
+ set variant(e) {
677
+ this.setAttribute("variant", e);
678
+ }
679
+ get type() {
680
+ return this.getAttribute("type") || "button";
681
+ }
682
+ set type(e) {
683
+ this.setAttribute("type", e);
684
+ }
685
+ get disabled() {
686
+ return this.hasAttribute("disabled");
687
+ }
688
+ set disabled(e) {
689
+ e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
690
+ }
691
+ onClick(e) {
692
+ if (this.disabled) {
693
+ e.preventDefault(), e.stopImmediatePropagation();
694
+ return;
695
+ }
696
+ this.emit("pop-click");
697
+ }
698
+ get icon() {
699
+ let e = "";
700
+ return this.theme === "brand" ? this.variant === "add" ? e = "\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M11 4.58331V17.4166M4.58333 11H17.4167\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n " : this.variant === "close" && (e = "\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M16.5 5.5L5.5 16.5M5.5 5.5L16.5 16.5\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n ") : this.theme === "neutral" && (this.variant === "add" ? e = "\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M11.0002 4.58301V17.4163M4.5835 10.9997H17.4168\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n " : this.variant === "close" ? e = "\n <svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M11.4628 11.4627L20.5373 20.5373M11.4628 20.5373L20.5373 11.4627\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n " : this.variant === "more" ? e = "\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M12.8335 16.5L7.3335 11L12.8335 5.5\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n " : this.variant === "send" ? e = "\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M18.0394 3.68048C18.2139 3.61601 18.3837 3.78583 18.3193 3.96036L12.3858 20.0241C12.314 20.2185 12.0369 20.2123 11.9739 20.0149L9.89172 13.4908C9.86908 13.4199 9.88424 13.3423 9.93191 13.2851L14.4838 7.82287C14.6536 7.61906 14.3807 7.34616 14.1769 7.516L8.71467 12.0678C8.65746 12.1155 8.57987 12.1307 8.50893 12.108L1.98489 10.0259C1.78743 9.96287 1.78121 9.68575 1.97565 9.61393L18.0394 3.68048Z\"\n fill=\"currentColor\"\n />\n </svg>\n " : this.variant === "cancel" && (e = "\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M16.5 5.5L5.5 16.5M5.5 5.5L16.5 16.5\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n ")), e;
701
+ }
702
+ getTemplate() {
703
+ let e = this.disabled ? "disabled" : "", t = [
704
+ "comment-icon",
705
+ this.size ? `comment-icon--size-${this.size}` : "",
706
+ this.theme ? `comment-icon--theme-${this.theme}` : "",
707
+ this.variant ? `comment-icon--variant-${this.variant}` : ""
708
+ ].filter(Boolean).join(" "), n = this.iconUrl ? `<img src="${this.iconUrl}" alt="" class="comment-icon__icon-image" />
709
+ <slot class="comment-icon__icon" name="icon">${this.icon}</slot>` : `<slot class="comment-icon__icon" name="icon">${this.icon}</slot>`;
710
+ return `
711
+ <button
712
+ class="${t}"
518
713
  part="base"
714
+ type="${this.type}"
715
+ ${e}
519
716
  >
520
- <div class="comment-bar__actions">
521
- <div>
522
- <div class="comment-bar__avatars">
523
- <pop-comment-avatar size="xs" style="--comment-avatar-border-size: 2px">
524
- <img src="https://i.pravatar.cc/90" alt="User avatar" />
525
- </pop-comment-avatar>
526
- <pop-comment-avatar size="xs" style="--comment-avatar-border-size: 2px">
527
- <img src="https://i.pravatar.cc/100" alt="User avatar" />
528
- </pop-comment-avatar>
529
- </div>
530
- </div>
531
- <pop-comment-input></pop-comment-input>
532
- <pop-comment-icon class="comment-bar__send-icon" theme="neutral" variant="send" size="sm"></pop-comment-icon>
717
+ <pop-focus-indicator class="comment-icon__focus-indicator"></pop-focus-indicator>
718
+ <div class="comment-icon__inner mask mask-squircle">
719
+ <div class="comment-icon__icon-container" part="icon">${n}</div>
533
720
  </div>
721
+ </button>
722
+ `;
723
+ }
724
+ };
725
+ customElements.get("pop-comment-icon") || customElements.define("pop-comment-icon", ke);
726
+ //#endregion
727
+ //#region src/components/pop-comment-input.ts
728
+ var Ae = F("\n :host {\n display: flex;\n flex: 1;\n min-width: 0;\n align-items: flex-end;\n }\n\n textarea {\n flex: 1;\n min-width: 0;\n background: none;\n border: none;\n outline: none;\n resize: none;\n font-family: Inter, sans-serif;\n font-size: 13px;\n color: black;\n line-height: 18px;\n padding: 5px 0;\n max-height: 200px;\n overflow-y: auto;\n width: 100%;\n letter-spacing: -0.08px;\n }\n\n textarea::placeholder {\n color: #697586;\n }\n"), U = class extends I {
729
+ constructor(...e) {
730
+ super(...e), this.events = {
731
+ input: "onInput",
732
+ keydown: "onKeyDown"
733
+ };
734
+ }
735
+ get styleSheets() {
736
+ return [Ae];
737
+ }
738
+ onInput(e) {
739
+ let t = e.target;
740
+ t.style.height = "auto", t.style.height = `${t.scrollHeight}px`;
741
+ }
742
+ onKeyDown(e) {
743
+ e.key === "Escape" && (this.gridStore.editingCommentId.value || this.gridStore.replyingTo.value) && (e.stopPropagation(), this.gridStore.editingCommentId.value = null, this.gridStore.replyingTo.value = null);
744
+ }
745
+ getValue() {
746
+ return this.getElement("textarea")?.value ?? "";
747
+ }
748
+ setValue(e) {
749
+ let t = this.getElement("textarea");
750
+ t && (t.value = e, t.style.height = "auto", t.style.height = `${t.scrollHeight}px`);
751
+ }
752
+ clear() {
753
+ let e = this.getElement("textarea");
754
+ e && (e.value = "", e.style.height = "auto");
755
+ }
756
+ focus() {
757
+ this.getElement("textarea")?.focus();
758
+ }
759
+ setupEffects() {
760
+ this.addEffect(() => {
761
+ let e = this.gridStore.replyingToComment.value, t = this.gridStore.editingComment.value, n = "Comment";
762
+ t ? n = "Edit comment..." : e?.author?.name && (n = `Reply to ${e.author.name}`), this.setAttr("textarea", "placeholder", n);
763
+ });
764
+ }
765
+ getTemplate() {
766
+ return "\n <textarea rows=\"1\" placeholder=\"Comment\"></textarea>\n ";
767
+ }
768
+ };
769
+ L([C(D)], U.prototype, "gridStore", void 0), customElements.get("pop-comment-input") || customElements.define("pop-comment-input", U);
770
+ //#endregion
771
+ //#region src/components/pop-comment-thread.ts
772
+ var je = F("\n :host {\n display: block;\n\n --pop-thread-link: rgba(0, 0, 32, 0.5);\n --pop-thread-link-hover: rgba(0, 0, 32, 0.8);\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n --pop-thread-link: rgba(255, 255, 255, 0.5);\n --pop-thread-link-hover: rgba(255, 255, 255, 0.8);\n }\n }\n\n :host(.dark) {\n --pop-thread-link: rgba(255, 255, 255, 0.5);\n --pop-thread-link-hover: rgba(255, 255, 255, 0.8);\n }\n\n .thread {\n align-items: stretch;\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .thread__replies {\n align-items: center;\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding-left: 24px;\n }\n\n .thread__more {\n display: flex;\n align-items: center;\n font-size: 13px;\n gap: 6px;\n padding-left: 30px;\n transition: opacity 0.15s ease;\n width: 100%;\n }\n\n .thread__more:hover {\n opacity: 1;\n }\n\n .thread__more-dot {\n width: 4px;\n height: 4px;\n border-radius: 50%;\n background: var(--pop-muted-foreground);\n flex-shrink: 0;\n opacity: 0.1;\n }\n"), W = 2, G = class extends I {
773
+ constructor(...e) {
774
+ super(...e), this._showAll = !1, this.events = { click: "onClick" };
775
+ }
776
+ get styleSheets() {
777
+ return [je];
778
+ }
779
+ onClick(e) {
780
+ e.target.closest(".thread__more-btn") && (this._showAll = !0, this.render());
781
+ }
782
+ setupEffects() {
783
+ this.addEffect(() => {
784
+ let e = this.getAttribute("comment-id"), t = this.gridStore.scrollingCommentId.value;
785
+ e && t && this.gridStore.repliesFor(e).some((e) => e.id === t) && (this._showAll = !0), this.gridStore.comments.value, this.render();
786
+ });
787
+ }
788
+ getTemplate() {
789
+ let e = this.getAttribute("comment-id");
790
+ if (!e) return "";
791
+ let t = this.gridStore.repliesFor(e), n = this._showAll || t.length <= W ? t : t.slice(0, W), r = t.length - n.length, i = r > 0 ? `<div class="thread__more">
792
+ <div class="thread__more-dot"></div>
793
+ <button class="thread__more-btn btn-link btn-link--size-sm btn-link--theme-default" type="button">
794
+ Show ${r} more ${r === 1 ? "reply" : "replies"}
795
+ </button>
796
+ </div>` : "";
797
+ return `
798
+ <div class="thread">
799
+ <pop-comment comment-id="${e}"></pop-comment>
800
+ ${t.length > 0 ? `<div class="thread__replies">
801
+ ${n.map((e) => `<pop-comment comment-id="${e.id}"></pop-comment>`).join("")}
802
+ ${i}
803
+ </div>` : ""}
534
804
  </div>
535
- `}};A.styles=[l(A,A,"styles"),rt],A=i([De("pop-comment-bar")],A);var _e=A;import{computePosition as Me,flip as Ve,offset as qe,shift as Le}from"@floating-ui/dom";import{consume as nt}from"@lit/context";import{PopElement as He}from"@popgrids/ui";import{Editor as $e,mergeAttributes as Be}from"@tiptap/core";import ze from"@tiptap/extension-document";import{Mention as Ie}from"@tiptap/extension-mention";import Re from"@tiptap/extension-paragraph";import Ue from"@tiptap/extension-placeholder";import Ke from"@tiptap/extension-text";import Ne from"@tiptap/extension-typography";import{html as st}from"lit";import{customElement as Qe,property as Je,query as Fe,state as ot}from"lit/decorators.js";import{classMap as Ze}from"lit/directives/class-map.js";import{createContext as Ee}from"@lit/context";var C=Ee(Symbol("pop-grid-context"));import{css as Te}from"lit";var at=Te`
536
- :host {
537
- display: flex;
538
- position: relative;
539
- }
540
-
541
- .comment-input {
542
- display: flex;
543
- align-items: flex-end;
544
- justify-content: center;
545
- max-height: 280px;
546
- width: 100%;
547
- padding-top: 4px;
548
- padding-right: 8px;
549
- padding-bottom: 4px;
550
- padding-left: 12px;
551
- background-color: var(--color-surface-alpha-singular-alpha-input-bar);
552
- transition: all var(--duration-quick) var(--ease-quick);
553
- border-radius: 18px;
554
- min-height: 36px;
555
- flex: 1 0 0;
556
- }
557
-
558
- .comment-input--has-error {
559
- border-color: var(--color-border-conditional-border-error);
560
- background-color: var(--color-surface-alpha-alpha-error);
561
- }
562
-
563
- .comment-input__input {
564
- display: flex;
565
- padding: 5px 0;
566
- align-items: flex-end;
567
- gap: 2px;
568
- flex: 1 0 0;
569
- font-size: var(--text-widget-base);
570
- line-height: var(--text-widget-base--line-height);
571
- letter-spacing: var(--text-widget-base--letter-spacing);
572
- white-space: pre-wrap;
573
- }
574
-
575
- .tiptap__editor {
576
- color: var(--color-text-text-default);
577
- font-size: var(--text-widget-base);
578
- line-height: var(--text-widget-base--line-height);
579
- letter-spacing: var(--text-widget-base--letter-spacing);
580
- max-height: 264px;
581
- outline: none;
582
- overflow-y: auto;
583
- position: relative;
584
- width: 100%;
585
- }
586
-
587
- .tiptap__mention {
588
- color: var(--color-text-singular-text-link);
589
- font-weight: var(--font-weight-medium);
590
- }
591
-
592
- .tiptap__mention-popup {
593
- background: var(--color-surface-bg-default);
594
- border-radius: var(--radius-sm);
595
- border: 1px solid var(--color-border-border-edge-strong);
596
- box-shadow: var(--shadow-lg);
597
- position: absolute;
598
- z-index: 1000;
599
- transition: opacity 0.1s ease-in-out;
600
- }
601
-
602
- .tiptap__mention-popup ul {
603
- align-items: flex-start;
604
- display: flex;
605
- flex-direction: column;
606
- list-style: none;
607
- margin: 0;
608
- padding: var(--spacing-sm);
609
- }
610
-
611
- .tiptap__mention-popup li {
612
- -webkit-box-orient: vertical;
613
- -webkit-line-clamp: 1;
614
- align-items: center;
615
- align-self: stretch;
616
- background: var(--color-surface-buttons-secondary-bg-blank-resting);
617
- border-radius: var(--radius-sm);
618
- color: var(--color-text-text-default);
619
- cursor: pointer;
620
- display: -webkit-box;
621
- display: flex;
622
- flex: 1 0 0;
623
- font-size: var(--text-widget-base);
624
- line-height: var(--text-widget-base--line-height);
625
- letter-spacing: var(--text-widget-base--letter-spacing);
626
- font-weight: 400;
627
- gap: 12px;
628
- padding: 8px;
629
- }
630
-
631
- .tiptap__mention-popup li:hover {
632
- background: #f0f0f0;
633
- }
634
-
635
- .tiptap__mention-popup li[data-selected] {
636
- background: var(--color-surface-buttons-secondary-bg-blank-hover);
637
- }
638
-
639
- .is-editor-empty:first-child::before {
640
- color: var(--color-text-text-placeholder);
641
- content: attr(data-placeholder);
642
- float: left;
643
- height: 0;
644
- pointer-events: none;
645
- }
646
- `;var m=class extends He{constructor(){super(...arguments);this.variant="text";this._content="";this._error=null}createMentionSuggestion(){return{items:async({query:t})=>{if(!t||t.trim().length===0)return[];let e=this.apiState?.client;if(!e)return[];let{data:r,error:n}=await e.GET("/api/v1/accounts",{params:{query:{by_name:t}}});return n?[]:r?r.map(o=>({id:o.id,label:o.name,href:o.url})):[]},render:()=>{let t,e,r,n,o=0,M=()=>{let d=n.querySelectorAll("li");d.forEach((c,S)=>{S===o?c.setAttribute("data-selected","true"):c.removeAttribute("data-selected")}),d.length>0?(e.style.visibility="visible",e.style.opacity="1"):(e.style.visibility="hidden",e.style.opacity="0")},R=async d=>{if(!e||!d)return;let c={getBoundingClientRect(){return d}},{x:S,y:k}=await Me(c,e,{placement:"top-start",middleware:[qe(6),Ve(),Le({padding:8})]});Object.assign(e.style,{position:"absolute",left:`${S}px`,top:`${k}px`})},_=()=>{e&&(e.style.opacity="0",e.style.visibility="hidden",setTimeout(()=>{e?.remove(),e=void 0,n=void 0},150))};return{onStart:d=>{t=d.command;let c=this.shadowRoot?.querySelector(".tiptap__mention-popup");if(c&&c.remove(),e=document.createElement("div"),e.className="tiptap__mention-popup",e.style.opacity="0",e.style.transition="opacity 150ms ease-in-out",e.style.visibility="hidden",this.shadowRoot?.appendChild(e),r=d.items,r.length===0){e.style.visibility="hidden",e.style.opacity="0";return}o=0,n=document.createElement("ul");for(let k of r){let V=document.createElement("li");V.textContent=k.label,V.addEventListener("click",J=>{J.preventDefault(),J.stopPropagation(),t({id:k.id,label:k.label,href:k.href}),_()}),n.appendChild(V)}e.appendChild(n),M();let S=d.clientRect?.();S&&R(S)},onUpdate:d=>{if(t=d.command,r=d.items,r.length===0){e.style.visibility="hidden",e.style.opacity="0";return}o=0,n?n.innerHTML="":(n=document.createElement("ul"),e.appendChild(n));for(let S of r){let k=document.createElement("li");k.textContent=S.label,k.addEventListener("click",V=>{V.preventDefault(),V.stopPropagation(),t({id:S.id,label:S.label,href:S.href}),_()}),n.appendChild(k)}M();let c=d.clientRect?.();c&&R(c)},onKeyDown:d=>{if(d.event?.key==="Escape")return _(),!0;if(d.event?.key==="ArrowDown")return o=(o+1)%r.length,M(),!0;if(d.event?.key==="ArrowUp")return o=(o-1+r.length)%r.length,M(),!0;if(d.event?.key==="Enter"){let c=r[o];if(c)return t({id:c.id,label:c.label,href:c.href}),_(),!0}return!1},onExit:()=>{_()}}}}}async firstUpdated(){await this.updateComplete,this.initializeEditor()}disconnectedCallback(){this.editor?.destroy(),super.disconnectedCallback()}initializeEditor(){if(!this._editor)return;let t=this.createMentionSuggestion();this.editor=new $e({element:this._editor,content:this._content,editable:!0,editorProps:{attributes:{class:"tiptap__editor"}},extensions:[ze,Ie.configure({HTMLAttributes:{class:"tiptap__mention"},renderText({options:e,node:r}){return`${e.suggestion.char}${r.attrs.label??r.attrs.id}`},renderHTML({options:e,node:r}){return["a",Be({href:`${r.attrs.href}`},e.HTMLAttributes),`${e.suggestion.char}${r.attrs.label??r.attrs.id}`]},suggestion:t}).extend({addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},href:{default:null,parseHTML:e=>e.getAttribute("href"),renderHTML:e=>({href:e.href})}}}}),Re,Ue.configure({placeholder:"Try mentioning someone using @ symbol"}),Ke,Ne],onUpdate:({editor:e})=>{this._content=e.getHTML(),this.emit("pop-content-change",this._content)}})}render(){return st`<div
647
- class=${Ze({"comment-input":!0,[`comment-input--variant-${this.variant}`]:!0,"comment-input--has-error":!!this._error})}
648
- part="base"
649
- >
650
- <div class="comment-input__input"></div>
651
- ${this._error?st`<div class="comment-input__error">${this._error.message}</div>`:""}
652
- </div>`}};m.styles=[l(m,m,"styles"),at],i([nt({context:E,subscribe:!0})],m.prototype,"apiState",2),i([nt({context:C,subscribe:!0})],m.prototype,"gridContext",2),i([Je({type:String})],m.prototype,"variant",2),i([Fe(".comment-input__input")],m.prototype,"_editor",2),i([ot()],m.prototype,"_content",2),i([ot()],m.prototype,"_error",2),m=i([Qe("pop-comment-input")],m);var Ye=m;import{consume as Pe}from"@lit/context";import{PopElement as We}from"@popgrids/ui";import{html as K}from"lit";import{customElement as Xe,property as Oe}from"lit/decorators.js";import{classMap as ti}from"lit/directives/class-map.js";import{when as ei}from"lit/directives/when.js";import{css as Ge}from"lit";var lt=Ge`
653
- :host {
654
- display: block;
655
- }
656
-
657
- .comment-thread {
658
- display: flex;
659
- flex-direction: column;
660
- align-items: stretch;
661
- gap: 12px;
662
- }
663
-
664
- .comment-thread--size-sm {
665
- }
666
-
667
- .comment-thread--size-md {
668
- }
669
-
670
- .comment-thread__replies {
671
- display: flex;
672
- padding-left: var(--spacing-3xl, 24px);
673
- flex-direction: column;
674
- align-items: center;
675
- gap: var(--spacing-lg, 12px);
676
- }
677
- `;var w=class extends We{get comment(){return this.gridContext?.comments.find(a=>a.id===this.id)}render(){return K`
678
- <div
679
- class=${ti({"comment-thread":!0})}
680
- >
681
- <pop-comment id=${this.id}></pop-comment>
682
- ${ei((this.comment?.repliesCount??0)>0,()=>K`
683
- <div class="comment-thread__replies">
684
- ${this.comment?.replies.map(a=>K`<pop-comment id=${a.id}></pop-comment>`)}
805
+ `;
806
+ }
807
+ };
808
+ L([C(D)], G.prototype, "gridStore", void 0), customElements.get("pop-comment-thread") || customElements.define("pop-comment-thread", G);
809
+ //#endregion
810
+ //#region src/helpers/time.ts
811
+ function K(e) {
812
+ let t = e instanceof Date ? e : new Date(e), n = (Date.now() - t.getTime()) / 1e3;
813
+ return n < 1 ? "now" : n < 60 ? `${Math.floor(n)}s` : n < 3600 ? `${Math.floor(n / 60)}m` : n < 86400 ? `${Math.floor(n / 3600)}h` : n < 604800 ? `${Math.floor(n / 86400)}d` : `${Math.floor(n / 604800)}w`;
814
+ }
815
+ //#endregion
816
+ //#region src/components/pop-comment.ts
817
+ var Me = F("\n :host {\n display: block;\n width: 100%;\n --pop-comment-hover: rgba(0, 0, 32, 0.04);\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n --pop-comment-hover: rgba(255, 255, 255, 0.04);\n }\n }\n\n .comment {\n display: flex;\n width: 100%;\n gap: 8px;\n align-items: center;\n background-color: transparent;\n border: none;\n padding: 0;\n border-radius: var(--pop-radius-md);\n outline: 6px solid transparent;\n text-align: left;\n transition:\n background-color 150ms ease,\n outline-color 150ms ease;\n }\n\n :host([data-size=\"sm\"]) .comment,\n :host:not([data-size]) .comment {\n --avatar-size: 32px;\n --width: 32px;\n gap: 8px;\n }\n\n :host([data-size=\"lg\"]) .comment {\n --avatar-size: 56px;\n --width: 56px;\n gap: 12px;\n }\n\n .comment--is-selected {\n background-color: var(--pop-muted);\n outline-color: var(--pop-muted);\n }\n\n :host(.is-signed-in) .comment {\n cursor: pointer;\n }\n\n @media (hover: hover) and (pointer: fine) {\n .comment:hover .comment__avatar {\n --avatar-translate-x: 2px;\n }\n\n .comment__avatar:hover {\n /* --avatar-scale: 1.06; */\n }\n\n .comment .comment__menu {\n display: none;\n }\n\n .comment:hover .comment__menu {\n display: flex;\n }\n }\n\n .comment--is-selected .comment__avatar {\n --avatar-translate-x: 2px;\n }\n\n .comment__avatar {\n --comment-avatar-border-size: 0;\n --avatar-translate-x: 0px;\n --avatar-scale: 1;\n width: var(--avatar-size);\n height: var(--avatar-size);\n transform: translateX(var(--avatar-translate-x)) scale(var(--avatar-scale));\n transition: transform var(--pop-duration-quick) var(--pop-ease-quick);\n }\n\n .comment__user {\n display: flex;\n width: var(--width);\n align-items: flex-start;\n gap: 10px;\n flex-shrink: 0;\n align-self: stretch;\n }\n\n .comment__content {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n flex: 1 0 0;\n align-self: stretch;\n }\n\n .comment__info {\n display: flex;\n align-items: flex-start;\n align-self: stretch;\n }\n\n .comment__menu {\n display: flex;\n justify-self: flex-end;\n }\n\n .comment__menu-trigger {\n background: none;\n border: none;\n cursor: pointer;\n border-radius: 9999px;\n aspect-ratio: 1;\n position: relative;\n }\n\n .comment__menu-trigger:before {\n content: \"\";\n height: 40px;\n left: 50%;\n position: absolute;\n top: 50%;\n transform: translate(-50%, -50%);\n width: 40px;\n }\n\n .comment__user-meta {\n display: flex;\n align-items: flex-start;\n gap: 4px;\n flex-shrink: 0;\n align-self: stretch;\n flex-grow: 1;\n }\n\n .comment__user-name {\n color: var(--pop-foreground);\n font-feature-settings:\n \"liga\" off,\n \"clig\" off;\n font-family: Inter, sans-serif;\n font-size: var(--text-widget-base, 13px);\n font-style: normal;\n font-weight: 500;\n line-height: var(--text-widget-base--line-height, 18px);\n letter-spacing: -0.08px;\n }\n\n .comment__timestamp {\n color: var(--pop-muted-foreground);\n font-feature-settings:\n \"liga\" off,\n \"clig\" off;\n font-family: Inter, sans-serif;\n font-size: var(--text-widget-base, 13px);\n font-style: normal;\n font-weight: 400;\n line-height: var(--text-widget-base--line-height, 18px);\n letter-spacing: -0.08px;\n opacity: 0.5;\n }\n\n .comment__text {\n align-self: stretch;\n color: var(--pop-foreground);\n font-feature-settings:\n \"liga\" off,\n \"clig\" off;\n font-family: Inter, sans-serif;\n font-size: 13px;\n font-style: normal;\n font-weight: 400;\n line-height: 18px;\n letter-spacing: -0.08px;\n text-align: left;\n\n /* Clamping when not expanded */\n display: -webkit-box;\n -webkit-line-clamp: 4;\n -webkit-box-orient: vertical;\n overflow: hidden;\n }\n\n .comment__text.expanded,\n .comment--is-selected .comment__text {\n -webkit-line-clamp: initial;\n display: block;\n }\n\n .comment__mention {\n color: #155eef;\n font-weight: 500;\n }\n\n .comment__menu {\n position: relative;\n }\n\n .comment__dropdown {\n background-color: var(--pop-background);\n border-radius: 6px;\n box-shadow: var(--pop-shadow-xl);\n display: none;\n flex-direction: column;\n gap: 6px;\n padding: 6px;\n pointer-events: auto;\n position: fixed;\n width: 120px;\n z-index: 1000;\n }\n\n .comment__dropdown.is-open {\n display: flex;\n }\n\n .comment__dropdown-item {\n align-items: center;\n background: none;\n border-radius: 4px;\n border: none;\n color: var(--pop-foreground);\n cursor: pointer;\n display: flex;\n flex: 1 0 0;\n font-family: Inter, sans-serif;\n font-size: 14px;\n font-weight: 500;\n justify-content: center;\n min-height: 40px;\n padding: 0 12px;\n text-align: left;\n transition: background-color 100ms ease;\n width: 100%;\n }\n\n .comment__dropdown-item:hover {\n background-color: var(--pop-comment-hover, rgba(0, 0, 0, 0.04));\n }\n\n .comment__dropdown-item--danger {\n color: #ef4444;\n }\n\n .comment__edit-form {\n display: flex;\n flex-direction: column;\n width: 100%;\n gap: 8px;\n margin-top: 4px;\n }\n\n .comment__edit-input {\n width: 100%;\n background: var(--pop-background, #ffffff);\n color: var(--pop-foreground, #000000);\n border: 1px solid var(--pop-border, #e4e4e7);\n border-radius: var(--pop-radius-sm, 4px);\n padding: 6px 8px;\n font-family: Inter, sans-serif;\n font-size: 13px;\n line-height: 18px;\n resize: vertical;\n outline: none;\n }\n\n .comment__edit-input:focus {\n border-color: var(--pop-ring, #000020);\n }\n\n .comment__edit-actions {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n }\n\n .comment__edit-save,\n .comment__edit-cancel {\n font-size: 12px;\n padding: 4px 8px;\n cursor: pointer;\n }\n\n .comment--deleted .comment__text {\n color: var(--pop-muted-foreground, #697586);\n font-style: italic;\n opacity: 0.8;\n }\n"), q = class extends I {
818
+ constructor(...e) {
819
+ super(...e), this.events = { click: "onClick" }, this._expanded = !1, this._dropdownOpen = !1, this._onOutsideClick = (e) => {
820
+ let t = e.composedPath(), n = this.getElement(".comment__dropdown"), r = this.getElement(".comment__menu-trigger");
821
+ n && r && !t.includes(n) && !t.includes(r) && this.closeDropdown();
822
+ }, this._timeUpdateTimer = null;
823
+ }
824
+ static get observedAttributes() {
825
+ return ["data-size", "comment-id"];
826
+ }
827
+ onDataSizeChanged() {
828
+ this.render();
829
+ }
830
+ onCommentIdChanged() {
831
+ this.render();
832
+ }
833
+ get size() {
834
+ return this.getAttribute("data-size") || "sm";
835
+ }
836
+ get commentAvatarSize() {
837
+ return this.size === "sm" ? "xs" : "sm";
838
+ }
839
+ get styleSheets() {
840
+ return [Me];
841
+ }
842
+ toggleDropdown() {
843
+ this._dropdownOpen ? this.closeDropdown() : this.openDropdown();
844
+ }
845
+ openDropdown() {
846
+ this._dropdownOpen = !0;
847
+ let e = this.getElement(".comment__dropdown"), t = this.getElement(".comment__menu-trigger");
848
+ if (e && t) {
849
+ e.classList.add("is-open");
850
+ let n = () => {
851
+ a(t, e, {
852
+ placement: "bottom-end",
853
+ middleware: [
854
+ s(4),
855
+ o(),
856
+ l({ padding: 8 })
857
+ ],
858
+ strategy: "fixed"
859
+ }).then(({ x: t, y: n }) => {
860
+ Object.assign(e.style, {
861
+ left: `${t}px`,
862
+ top: `${n}px`,
863
+ position: "fixed"
864
+ });
865
+ });
866
+ };
867
+ this._floatingCleanup = i(t, e, n), document.addEventListener("mousedown", this._onOutsideClick);
868
+ }
869
+ }
870
+ closeDropdown() {
871
+ this._dropdownOpen = !1;
872
+ let e = this.getElement(".comment__dropdown");
873
+ e && e.classList.remove("is-open"), this._floatingCleanup &&= (this._floatingCleanup(), void 0), document.removeEventListener("mousedown", this._onOutsideClick);
874
+ }
875
+ async deleteComment() {
876
+ let e = this.getAttribute("comment-id");
877
+ e && confirm("Are you sure you want to delete this comment?") && await this.gridStore.deleteComment(e);
878
+ }
879
+ async flagComment() {
880
+ let e = this.getAttribute("comment-id");
881
+ e && (await this.gridStore.flagComment(e) ? alert("Comment flagged successfully.") : alert("Failed to flag comment."));
882
+ }
883
+ onClick(e) {
884
+ let t = e.target;
885
+ if (t.closest(".comment__menu-trigger")) {
886
+ e.stopPropagation(), this.toggleDropdown();
887
+ return;
888
+ }
889
+ let n = t.closest(".comment__dropdown-item");
890
+ if (n) {
891
+ e.stopPropagation();
892
+ let t = n.getAttribute("data-action"), r = this.getAttribute("comment-id");
893
+ t === "edit" && r ? (this.gridStore.replyingTo.value = null, this.gridStore.editingCommentId.value = r) : t === "delete" ? this.deleteComment() : t === "flag" && this.flagComment(), this.closeDropdown();
894
+ return;
895
+ }
896
+ if (t.closest(".comment__dropdown")) {
897
+ e.stopPropagation();
898
+ return;
899
+ }
900
+ if (!g.value) return;
901
+ let r = this.getAttribute("comment-id");
902
+ r && this.gridStore.comments.value.find((e) => e.id === r)?.status !== "deleted" && (this.gridStore.replyingTo.value === r ? this.gridStore.replyingTo.value = null : this.gridStore.replyingTo.value = r, this.expandText());
903
+ }
904
+ expandText() {
905
+ let e = this.getElement(".comment__text");
906
+ if (!this._expanded && e) {
907
+ let t = e.offsetHeight;
908
+ this._expanded = !0, this.render();
909
+ let n = this.getElement(".comment__text");
910
+ if (n) {
911
+ let e = n.scrollHeight;
912
+ n.style.height = `${t}px`, n.style.overflow = "hidden", n.offsetHeight, n.style.transition = "height var(--pop-duration-quick) var(--pop-ease-quick)", n.style.height = `${e}px`, setTimeout(() => {
913
+ n.style.height = "", n.style.overflow = "";
914
+ }, 300);
915
+ }
916
+ }
917
+ }
918
+ disconnectedCallback() {
919
+ this.closeDropdown(), this.stopTimeUpdates(), super.disconnectedCallback();
920
+ }
921
+ startTimeUpdates() {
922
+ this.stopTimeUpdates();
923
+ let e = this.getAttribute("comment-id");
924
+ if (!e) return;
925
+ let t = this.gridStore.comments.value.find((t) => t.id === e);
926
+ if (!t) return;
927
+ let n = () => {
928
+ let e = this.getElement(".comment__timestamp");
929
+ e && (e.textContent = K(t.createdAt));
930
+ let r = Date.now() - (typeof t.createdAt == "number" ? t.createdAt : Date.parse(String(t.createdAt))), i = 6e4;
931
+ i = r < 6e4 ? 5e3 : r < 36e5 ? 6e4 : 18e5, this._timeUpdateTimer = setTimeout(n, i);
932
+ }, r = Date.now() - (typeof t.createdAt == "number" ? t.createdAt : Date.parse(String(t.createdAt))) < 6e4 ? 5e3 : 6e4;
933
+ this._timeUpdateTimer = setTimeout(n, r);
934
+ }
935
+ stopTimeUpdates() {
936
+ this._timeUpdateTimer &&= (clearTimeout(this._timeUpdateTimer), null);
937
+ }
938
+ setupEffects() {
939
+ this.addEffect(() => {
940
+ let e = this.getAttribute("comment-id"), t = g.value, n = this.gridStore.replyingTo.value, r = this.gridStore.editingCommentId.value, i = this.gridStore.scrollingCommentId.value;
941
+ this.classList.toggle("is-signed-in", t !== null), this.classList.toggle("is-replying", e !== null && n === e), this.classList.toggle("is-editing", e !== null && r === e), this.gridStore.comments.value, this.render(), this.startTimeUpdates(), e && i === e && setTimeout(() => {
942
+ let t = this.shadowRoot?.querySelector(`#comment-${e}`);
943
+ t ? t.scrollIntoView({
944
+ behavior: "smooth",
945
+ block: "center"
946
+ }) : this.scrollIntoView({
947
+ behavior: "smooth",
948
+ block: "center"
949
+ }), this.gridStore.scrollingCommentId.value = null;
950
+ }, 50);
951
+ });
952
+ }
953
+ getTemplate() {
954
+ let e = this.getAttribute("comment-id");
955
+ if (!e) return "";
956
+ let t = this.gridStore.comments.value.find((t) => t.id === e);
957
+ if (!t) return "";
958
+ let n = t.status === "deleted", r = t.authorDeleted === !0, i = n || r, a = i ? "" : t.author?.image ? `<img src="${t.author.image}" alt="${t.author.name ?? "User avatar"}" />` : B(t.author?.name), o = this.gridStore.replyingTo.value, s = e !== null && o === e, c = this.size, l = g.value && t.author && g.value.id === t.author.id, u = g.value && !n ? `<div class="comment__menu">
959
+ <button class="comment__menu-trigger" type="button">
960
+ <svg
961
+ width="18"
962
+ height="18"
963
+ viewBox="0 0 18 18"
964
+ fill="none"
965
+ xmlns="http://www.w3.org/2000/svg"
966
+ >
967
+ <path
968
+ d="M9 9.5C9.27614 9.5 9.5 9.27614 9.5 9C9.5 8.72386 9.27614 8.5 9 8.5C8.72386 8.5 8.5 8.72386 8.5 9C8.5 9.27614 8.72386 9.5 9 9.5Z"
969
+ fill="white"
970
+ />
971
+ <path
972
+ d="M12.5 9.5C12.7761 9.5 13 9.27614 13 9C13 8.72386 12.7761 8.5 12.5 8.5C12.2239 8.5 12 8.72386 12 9C12 9.27614 12.2239 9.5 12.5 9.5Z"
973
+ fill="white"
974
+ />
975
+ <path
976
+ d="M5.5 9.5C5.77614 9.5 6 9.27614 6 9C6 8.72386 5.77614 8.5 5.5 8.5C5.22386 8.5 5 8.72386 5 9C5 9.27614 5.22386 9.5 5.5 9.5Z"
977
+ fill="white"
978
+ />
979
+ <path
980
+ d="M9 9.5C9.27614 9.5 9.5 9.27614 9.5 9C9.5 8.72386 9.27614 8.5 9 8.5C8.72386 8.5 8.5 8.72386 8.5 9C8.5 9.27614 8.72386 9.5 9 9.5Z"
981
+ stroke="#000020"
982
+ stroke-opacity="0.5"
983
+ stroke-linecap="round"
984
+ stroke-linejoin="round"
985
+ />
986
+ <path
987
+ d="M12.5 9.5C12.7761 9.5 13 9.27614 13 9C13 8.72386 12.7761 8.5 12.5 8.5C12.2239 8.5 12 8.72386 12 9C12 9.27614 12.2239 9.5 12.5 9.5Z"
988
+ stroke="#000020"
989
+ stroke-opacity="0.5"
990
+ stroke-linecap="round"
991
+ stroke-linejoin="round"
992
+ />
993
+ <path
994
+ d="M5.5 9.5C5.77614 9.5 6 9.27614 6 9C6 8.72386 5.77614 8.5 5.5 8.5C5.22386 8.5 5 8.72386 5 9C5 9.27614 5.22386 9.5 5.5 9.5Z"
995
+ stroke="#000020"
996
+ stroke-opacity="0.5"
997
+ stroke-linecap="round"
998
+ stroke-linejoin="round"
999
+ />
1000
+ </svg>
1001
+ </button>
1002
+ <div class="comment__dropdown">
1003
+ ${l ? "<button class=\"comment__dropdown-item\" type=\"button\" data-action=\"edit\">Edit</button>\n <button class=\"comment__dropdown-item comment__dropdown-item--danger\" type=\"button\" data-action=\"delete\">Delete</button>" : ""}
1004
+ <button class="comment__dropdown-item" type="button" data-action="flag">Flag</button>
685
1005
  </div>
686
- `)}
687
- </div>
688
- `}};w.styles=[l(w,w,"styles"),lt],i([Pe({context:C,subscribe:!0})],w.prototype,"gridContext",2),i([Oe({type:String})],w.prototype,"id",2),w=i([Xe("pop-comment-thread")],w);var ii=w;import{consume as ai}from"@lit/context";import{PopElement as ni}from"@popgrids/ui";import{html as si}from"lit";import{customElement as oi,property as li,query as di,state as ct}from"lit/decorators.js";import{classMap as mt}from"lit/directives/class-map.js";import{styleMap as pi}from"lit/directives/style-map.js";import{sampleColor as ci}from"@popgrids/ui";function dt(s){let a=(Date.now()-s.getTime())/1e3;return a<60?`${Math.floor(a)}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}import{ifDefined as mi}from"lit/directives/if-defined.js";import{css as ri}from"lit";var pt=ri`
689
- :host {
690
- display: block;
691
- }
692
-
693
- .comment {
694
- display: flex;
695
- width: 100%;
696
- align-items: center;
697
- background-color: transparent;
698
-
699
- border: none;
700
- padding: 0;
701
- border-radius: var(--radius-md);
702
- outline: 6px solid transparent;
703
- transition:
704
- background-color 0.2s ease,
705
- outline-color 0.2s ease;
706
- }
707
-
708
- .comment--size-sm {
709
- --avatar-size: 32px;
710
- --width: 32px;
711
-
712
- gap: 8px;
713
- }
714
-
715
- .comment--size-lg {
716
- --avatar-size: 56px;
717
- --width: 56px;
718
-
719
- gap: 12px;
720
- }
721
-
722
- .comment--is-selected {
723
- background-color: var(--color-black-alpha-900);
724
- outline-color: var(--color-black-alpha-900);
725
- }
726
-
727
- @media (hover: hover) and (pointer: fine) {
728
- .comment:hover .comment__avatar {
729
- transform: translateX(2px);
730
- }
731
- }
732
-
733
- .comment--is-selected .comment__avatar {
734
- transform: translateX(2px);
735
- }
736
-
737
- .comment__avatar {
738
- --border-size: 0;
739
- width: var(--avatar-size);
740
- height: var(--avatar-size);
741
- }
742
-
743
- .comment__user {
744
- display: flex;
745
- width: var(--width);
746
- align-items: flex-start;
747
- gap: 10px;
748
- flex-shrink: 0;
749
- align-self: stretch;
750
- }
751
-
752
- .comment__content {
753
- display: flex;
754
- flex-direction: column;
755
- align-items: flex-start;
756
- flex: 1 0 0;
757
- align-self: stretch;
758
- }
759
-
760
- .comment__info {
761
- display: flex;
762
- align-items: flex-start;
763
- align-self: stretch;
764
- }
765
-
766
- .comment__user-name {
767
- color: var(--color-text-text-default, #000);
768
- font-feature-settings:
769
- "liga" off,
770
- "clig" off;
771
- font-family: Inter;
772
- font-size: var(--text-widget-base, 13px);
773
- font-style: normal;
774
- font-weight: 500;
775
- line-height: var(--text-widget-base--line-height, 18px);
776
- letter-spacing: -0.08px;
777
- }
778
-
779
- .comment__timestamp {
780
- color: var(--color-text-text-default-dim-light, #697586);
781
- font-feature-settings:
782
- "liga" off,
783
- "clig" off;
784
- /* Widget/Regular */
785
- font-family: Inter;
786
- font-size: var(--text-widget-base, 13px);
787
- font-style: normal;
788
- font-weight: 400;
789
- line-height: var(--text-widget-base--line-height, 18px);
790
- letter-spacing: -0.08px;
791
- }
792
-
793
- .comment__text {
794
- /* Base styles */
795
- align-self: stretch;
796
- color: var(--color-text-text-default-dim);
797
- font-feature-settings:
798
- "liga" off,
799
- "clig" off;
800
- font-family: Inter;
801
- font-size: var(--text-widget-base, 13px);
802
- font-style: normal;
803
- font-weight: 400;
804
- line-height: var(--text-widget-base--line-height, 18px);
805
- letter-spacing: -0.08px;
806
- text-align: left;
807
-
808
- /* Clamping when not expanded */
809
- display: -webkit-box;
810
- -webkit-line-clamp: 4;
811
- -webkit-box-orient: vertical;
812
- overflow: hidden;
813
- }
814
-
815
- .comment__text.expanded {
816
- /* Remove line clamping */
817
- -webkit-line-clamp: initial;
818
- display: block;
819
- }
820
- `;var g=class extends ni{constructor(){super(...arguments);this._randomColor=ci();this._expanded=!1}handleClick(){let t=this.selected;if(t?this.gridContext?.selectComment(null):this.gridContext?.selectComment(this.id),this.emit("pop-click",{id:this.id,selected:!t}),!this._expanded&&this._text){let e=this._text.offsetHeight;this._expanded=!0,this.requestUpdate(),this.updateComplete.then(()=>{let r=this._text.scrollHeight;this._text.style.height=`${e}px`,this._text.style.overflow="hidden",this._text.offsetHeight,this._text.style.transition="height var(--duration-quick) var(--ease-quick)",this._text.style.height=`${r}px`,setTimeout(()=>{this._text.style.height="",this._text.style.overflow=""},300)})}}get comment(){return this.findCommentOrReply(this.gridContext?.comments??[],this.id)}get commentAvatarSize(){return this.gridContext?.grid?.layout==="sm"?"xs":"sm"}get selected(){return this.gridContext?.selectedCommentId===this.id}findCommentOrReply(t,e){let r=[...t];for(;r.length>0;){let n=r.pop();if(n){if(n.id===e)return n;n.replies&&n.replies.length>0&&r.push(...n.replies)}}return null}render(){return si`
821
- <button
822
- class=${mt({comment:!0,[`comment--size-${this.gridContext?.grid?.layout??"sm"}`]:!0,"comment--is-selected":this.selected})}
823
- part="base"
824
- type="button"
825
- @click=${this.handleClick}
1006
+ </div>` : "";
1007
+ return `
1008
+ <div
1009
+ class="comment comment--size-${c}${s ? " comment--is-selected" : ""}${n ? " comment--deleted" : ""}"
1010
+ id="comment-${e}"
826
1011
  >
827
1012
  <div class="comment__user">
828
1013
  <pop-comment-avatar
829
1014
  class="comment__avatar"
830
- size=${this.commentAvatarSize}
831
- style="--comment-avatar-border-size: 0;"
1015
+ size="${this.commentAvatarSize}"
1016
+ data-color-key="${t.author?.id ?? t.author?.name ?? ""}"
1017
+ ${i ? "deleted" : ""}
832
1018
  >
833
- <img
834
- src=${mi(this.comment?.account?.avatar?.url)}
835
- alt="${this.comment?.account?.name}'s avatar"
836
- style=${pi({backgroundColor:this._randomColor})}
837
- />
1019
+ ${a}
838
1020
  </pop-comment-avatar>
839
1021
  </div>
840
1022
  <div class="comment__content">
841
1023
  <div class="comment__info">
842
- <div class="comment__user">
843
- <div class="comment__user-name">${this.comment?.account?.name}</div>
844
- <div class="comment__timestamp">
845
- ${this.comment?dt(new Date(this.comment.createdAt??"")):""}
1024
+ <div class="comment__user-meta">
1025
+ <div class="comment__user-name">
1026
+ ${n ? "[Deleted]" : r ? "[Deleted user]" : t.author?.name ?? ""}
846
1027
  </div>
1028
+ <div class="comment__timestamp">${K(t.createdAt)}</div>
847
1029
  </div>
1030
+ ${u}
848
1031
  </div>
849
- <div
850
- class=${mt({comment__text:!0,expanded:this._expanded})}
851
- >
852
- ${this.comment?.content}
853
- </div>
854
- </div>
855
- </button>
856
- `}};g.styles=[l(g,g,"styles"),pt],i([ai({context:C,subscribe:!0})],g.prototype,"gridContext",2),i([li({type:String})],g.prototype,"id",2),i([ct()],g.prototype,"_randomColor",2),i([ct()],g.prototype,"_expanded",2),i([di(".comment__text")],g.prototype,"_text",2),g=i([oi("pop-comment")],g);var ui=g;import{consume as ft}from"@lit/context";import{PopElement as hi}from"@popgrids/ui";import{html as H}from"lit";import{customElement as gi,property as ht}from"lit/decorators.js";import{classMap as xi}from"lit/directives/class-map.js";import{css as fi}from"lit";var ut=fi`
857
- :host {
858
- display: flex;
859
- }
860
-
861
- .feed {
862
- align-items: flex-start;
863
- background: var(--color-border-singular-border-island, #fff);
864
- border-radius: var(--border-radius-2xl, 16px);
865
- border: 1px solid var(--color-border-singular-border-island, #fff);
866
- box-shadow: var(--shadow-3xl);
867
- display: grid;
868
- grid-template-rows: 1fr 50px;
869
- max-height: 400px;
870
- max-width: 400px;
871
- overflow: hidden;
872
- position: relative;
873
- }
874
-
875
- .feed__footer {
876
- position: absolute;
877
- bottom: 0;
878
- min-height: 50px;
879
- width: 100%;
880
- }
881
-
882
- .feed__comment-bar {
883
- }
884
-
885
- .feed__content {
886
- align-items: flex-start;
887
- align-self: stretch;
888
- display: flex;
889
- gap: var(--spacing-md, 8px);
890
- min-height: 80px;
891
- max-height: 290px;
892
- overflow: hidden auto;
893
- padding: var(--spacing-md, 8px) 20px var(--spacing-xl, 16px) var(--spacing-md, 8px);
894
- }
895
-
896
- .feed__main {
897
- align-items: stretch;
898
- align-self: stretch;
899
- display: flex;
900
- flex-direction: column;
901
- flex: 1 0 0;
902
- gap: var(--spacing-xl, 16px);
903
- min-height: 100%;
904
- }
905
-
906
- .feed--size-md .feed__main {
907
- gap: var(--spacing-lg, 12px);
908
- }
909
- `;var v=class extends hi{constructor(){super(...arguments);this.open=!1;this.size="sm"}render(){return this.gridContext?this.gridContext.comments.length===0?H`<div class="feed__empty">No comments yet</div>`:H`
910
- <div
911
- class=${xi({feed:!0,"feed--is-open":this.open,[`feed--size-${this.gridContext.grid?.layout??"sm"}`]:!0})}
912
- part="base"
913
- >
914
- <div class="feed__content">
915
- <div class="feed__main">
916
- ${this.gridContext.comments.map(t=>H`<pop-comment-thread id=${t.id}></pop-comment-thread> `)}
917
- </div>
918
- </div>
919
- <div class="feed__footer">
920
- ${this.authContext?.isAuthenticated?H`<pop-comment-bar class="feed__comment-bar"></pop-comment-bar>`:H` <pop-auth-panel class="feed__auth-panel"></pop-auth-panel> `}
1032
+ <div class="comment__text${this._expanded ? " expanded" : ""}">${t.body}</div>
921
1033
  </div>
922
1034
  </div>
923
- `:H``}};v.styles=[l(v,v,"styles"),ut],i([ft({context:D,subscribe:!0})],v.prototype,"authContext",2),i([ft({context:C,subscribe:!0})],v.prototype,"gridContext",2),i([ht({type:Boolean,reflect:!0})],v.prototype,"open",2),i([ht({type:String})],v.prototype,"size",2),v=i([gi("pop-feed")],v);var vi=v;import{consume as yi,provide as bi}from"@lit/context";import{PopElement as Ci}from"@popgrids/ui";import{html as wi}from"lit";import{customElement as Si,property as gt,state as N}from"lit/decorators.js";var y=class extends Ci{constructor(){super(...arguments);this.grid=null;this.comments=[];this.loading=!1;this.contextData=this.initializeContextData()}initializeContextData(){return{grid:null,comments:[],loading:this.loading,fetchGrid:this.fetchGrid.bind(this),fetchReplies:this.fetchReplies.bind(this),selectedCommentId:null,selectComment:this.selectComment.bind(this)}}updateState(t){this.contextData={...this.contextData,...t},this.requestUpdate()}connectedCallback(){super.connectedCallback(),this.id?this.fetchGrid(this.id):console.error("ID not provided.")}async fetchGrid(t){if(!this.apiState?.client){console.error("No API client provided.");return}this.updateState({loading:!0});let{data:e,error:r}=await this.apiState.client.GET("/api/v1/grids/{id}",{params:{path:{id:t}}});if(e){let n=e;this.grid=n.grid,this.updateState({grid:this.grid,loading:!1}),this.fetchComments(this.id)}if(r){console.error("Failed to fetch grid:",r),this.loading=!1,this.updateState({loading:this.loading});return}}async fetchComments(t){if(!this.apiState?.client)return;let{data:e,error:r}=await this.apiState.client.GET("/api/v1/grids/{grid_id}/comments",{params:{path:{grid_id:t}}});if(this.loading=!1,e){let n=e;this.comments=n.comments,this.updateState({comments:this.comments,loading:this.loading})}if(r){console.error("Failed to fetch comments:",r),this.updateState({loading:this.loading});return}}async fetchReplies(t){if(this.apiState?.client)try{let e=await this.apiState.client.GET("/api/v1/grids/{grid_id}/comments/{id}/replies",{params:{path:{grid_id:this.id,id:t}}});if(e.data){let n=e.data.replies||[];this.comments=this.comments.map(o=>o.id===t?{...o,replies:[...o.replies||[],...n]}:o),this.updateState({comments:this.comments})}}catch(e){console.error(`Failed to fetch replies for comment ${t}:`,e)}}selectComment(t){this.updateState({selectedCommentId:t})}render(){return wi`<slot></slot>`}};y.styles=[],i([yi({context:E})],y.prototype,"apiState",2),i([gt({type:String})],y.prototype,"id",2),i([N()],y.prototype,"grid",2),i([N()],y.prototype,"comments",2),i([N()],y.prototype,"loading",2),i([bi({context:C}),gt({attribute:!1})],y.prototype,"contextData",2),y=i([Si("pop-grid-provider")],y);var ki=y;import{PopElement as Di}from"@popgrids/ui";import{html as Ai}from"lit";import{customElement as _i,property as vt}from"lit/decorators.js";import{css as ji}from"lit";var xt=ji`
924
- :host {
925
- display: flex;
926
- align-items: center;
927
- }
928
- `;var b=class extends Di{constructor(){super(...arguments);this.apiUrl="https://api.popgrids.com";this.gridId=""}render(){return Ai`
929
- <pop-api-provider api-url=${this.apiUrl}>
930
- <pop-grid-provider id=${this.gridId}>
931
- <pop-auth-provider>
932
- <pop-widget></pop-widget>
933
- </pop-auth-provider>
934
- </pop-grid-provider>
935
- </pop-api-provider>
936
- `}};b.styles=[l(b,b,"styles"),xt],i([vt({type:String,attribute:"api-url",reflect:!0})],b.prototype,"apiUrl",2),i([vt({type:String,attribute:"data-grid-id"})],b.prototype,"gridId",2),b=i([_i("pop-grid")],b);var Ei=b;customElements.get("pop-grid")||customElements.define("pop-grid",b);function yt(){let s=document.querySelectorAll("pop-grid[grid-id]:not([initialized])");for(let a of Array.from(s)){let t=a.getAttribute("grid-id");t&&(a.setAttribute("data-grid-id",t),a.setAttribute("initialized","true"))}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",yt):yt();import{autoUpdate as $i,computePosition as Bi,flip as zi,offset as Ii,platform as kt}from"@floating-ui/dom";import{consume as Ri}from"@lit/context";import{PopElement as Ui}from"@popgrids/ui";function Ti(){return typeof window<"u"}function bt(s){var a;return(s==null||(a=s.ownerDocument)==null?void 0:a.defaultView)||window}function Mi(s){return Ti()?s instanceof Element||s instanceof bt(s).Element:!1}function Ct(s){let a=Vi(),t=Mi(s)?qi(s):s;return["transform","translate","scale","rotate","perspective"].some(e=>t[e]?t[e]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!a&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!a&&(t.filter?t.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(e=>(t.willChange||"").includes(e))||["paint","layout","strict","content"].some(e=>(t.contain||"").includes(e))}function Vi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function qi(s){return bt(s).getComputedStyle(s)}function wt(s){return Li(s)}function Q(s){return s.assignedSlot?s.assignedSlot:s.parentNode instanceof ShadowRoot?s.parentNode.host:s.parentNode}function Li(s){for(let a=s;a;a=Q(a))if(a instanceof Element&&getComputedStyle(a).display==="none")return null;for(let a=Q(s);a;a=Q(a)){if(!(a instanceof Element))continue;let t=getComputedStyle(a);if(t.display!=="contents"&&(t.position!=="static"||Ct(t)||a.tagName==="BODY"))return a}return null}import{html as I}from"lit";import{customElement as Ki,query as jt,state as Ni}from"lit/decorators.js";import{classMap as Dt}from"lit/directives/class-map.js";import{ifDefined as Qi}from"lit/directives/if-defined.js";import{css as Hi}from"lit";var St=Hi`
937
- :host {
938
- display: block;
939
- }
940
-
941
- .grid-widget {
942
- display: flex;
943
- height: 100%;
944
- position: relative;
945
- width: 100%;
946
- }
947
-
948
- .grid-widget--align-left {
949
- justify-content: flex-start;
950
- }
951
-
952
- .grid-widget--align-center {
953
- justify-content: center;
954
- }
955
-
956
- .grid-widget--align-right {
957
- justify-content: flex-end;
958
- }
959
-
960
- .grid-widget__feed {
961
- position: fixed;
962
- top: 0;
963
- left: 0;
964
- z-index: 2147483647;
965
- display: none;
966
- opacity: 0;
967
- transform: scale(0.94);
968
- transition:
969
- opacity var(--duration-quick) var(--ease-quick),
970
- transform var(--duration-quick) var(--ease-quick),
971
- display var(--duration-quick) allow-discrete;
972
- }
973
-
974
- .grid-widget__feed[data-current-placement="top-start"] {
975
- transform-origin: left bottom;
976
- }
977
-
978
- .grid-widget__feed[data-current-placement="bottom-start"] {
979
- transform-origin: left top;
980
- }
981
-
982
- .grid-widget__feed[data-current-placement="top-end"] {
983
- transform-origin: right bottom;
984
- }
985
-
986
- .grid-widget__feed[data-current-placement="bottom-end"] {
987
- transform-origin: right top;
988
- }
989
-
990
- .grid-widget__feed[data-current-placement="top"] {
991
- transform-origin: bottom;
992
- }
993
-
994
- .grid-widget__feed[data-current-placement="bottom"] {
995
- transform-origin: top;
996
- }
997
-
998
- .grid-widget__feed--open {
999
- display: flex;
1000
- opacity: 1;
1001
- transform: scale(1);
1002
-
1003
- @starting-style {
1004
- display: flex;
1005
- opacity: 0;
1006
- transform: scale(0.94);
1007
- }
1008
- }
1009
-
1010
- .grid-widget__loader {
1011
- align-items: center;
1012
- display: flex;
1013
- min-height: 30px;
1014
- }
1015
-
1016
- .grid-widget__previews {
1017
- display: inline-flex;
1018
- align-items: flex-start;
1019
- }
1020
-
1021
- .grid-widget__previews > :not([hidden]) ~ :not([hidden]) {
1022
- margin-left: -4px;
1023
- }
1024
-
1025
- .grid-widget__preview-avatar,
1026
- .grid-widget__preview-sum {
1027
- transition: transform var(--ease-quick) 600ms;
1028
- }
1029
-
1030
- @media (hover: hover) and (pointer: fine) {
1031
- .grid-widget__preview-avatar:hover,
1032
- .grid-widget__preview-sum:hover {
1033
- cursor: pointer;
1034
- transform: scale(1.1875);
1035
- }
1036
- }
1037
-
1038
- .grid-widget__preview-avatar:active,
1039
- .grid-widget__preview-sum:active {
1040
- cursor: pointer;
1041
- transform: scale(0.875);
1042
- }
1043
- `;var Ji={default:1,md:3,lg:5},x=class extends Ui{constructor(){super(...arguments);this._open=!1;this.handleKeyDown=t=>{t.code==="Escape"&&(this._open=!1)};this.handleDocumentMouseDown=t=>{if(!this._open)return;let e=t.composedPath();this&&!e.includes(this._feed)&&(this._open=!1)};this.reposition=()=>{if(!this._open||!this._previews||!this._feed||!this.gridContext?.grid)return;let t=[];t=[Ii({mainAxis:this.gridContext.grid.position==="down"?-16:-48,crossAxis:-13})],(!this.gridContext.grid.position||this.gridContext.grid.position==="smart")&&t.push(zi({fallbackPlacements:["bottom-start","top-start"],fallbackStrategy:"bestFit",padding:16}));let e=r=>kt.getOffsetParent(r,wt);Bi(this._previews,this._feed,{placement:this.gridContext.grid.position==="down"?"bottom-start":"top-start",middleware:t,strategy:"fixed",platform:{...kt,getOffsetParent:e}}).then(({x:r,y:n,placement:o})=>{this._feed.setAttribute("data-current-placement",o),Object.assign(this._feed.style,{left:`${r}px`,top:`${n}px`})})}}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.start(),document.addEventListener("mousedown",this.handleDocumentMouseDown),document.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){document.removeEventListener("mousedown",this.handleDocumentMouseDown),document.removeEventListener("keydown",this.handleKeyDown),super.disconnectedCallback(),this.stop()}handlePopClick(){this._open||(this._open=!0)}start(){this._previews&&(this.cleanup=$i(this._previews,this._feed,()=>{this.reposition()}))}async stop(){return new Promise(t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.removeAttribute("data-current-placement"),this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame(()=>t())):t()})}async updated(t){super.updated(t),t.has("_open")&&(this._open?this.start():this.stop()),t.has("position")&&(this.gridContext?.grid?.position==="smart"&&this._open?this.start():this.stop()),this._open&&(await this.updateComplete,this.reposition())}get previewComments(){return this.gridContext?.comments.filter(t=>t.parentCommentId===null).sort((t,e)=>new Date(e.createdAt??"").getTime()-new Date(t.createdAt??"").getTime()).slice(0,Ji[this.gridContext.grid?.preview??"default"])}render(){return this.gridContext?.loading?I`<div class="grid-widget">
1044
- <pop-loader class="grid-widget__loader" variant="spinner"></pop-loader>
1045
- </div>`:this.gridContext?.grid?I`
1046
- <div
1047
- class=${Dt({"grid-widget":!0,[`grid-widget--align-${this.gridContext.grid.align}`]:!0,[`grid-widget--appearance-${this.gridContext.grid.appearance}`]:!0,[`grid-widget--icon-${this.gridContext.grid.icon}`]:!0,[`grid-widget--layout-${this.gridContext.grid.layout}`]:!0,[`grid-widget--position-${this.gridContext.grid.position}`]:!0,[`grid-widget--preview-${this.gridContext.grid.preview}`]:!0})}
1048
- >
1049
- <div class="grid-widget__previews">
1050
- ${(this.previewComments??[]).map(t=>I`
1051
- <pop-comment-avatar class="grid-widget__preview-avatar" size="xs" @click=${this.handlePopClick}>
1052
- <img src=${Qi(t.account?.avatar?.url)} alt="${t.account?.name}’s avatar" />
1053
- </pop-comment-avatar>
1054
- `)}
1055
- <pop-sum class="grid-widget__preview-sum">${this.gridContext.grid.commentsCount}</pop-sum>
1056
- <pop-comment-icon
1057
- size="sm"
1058
- theme=${this.gridContext.grid?.customAddIcon?"brand":"neutral"}
1059
- variant="add"
1060
- .iconUrl=${this.gridContext.grid?.customAddIcon||void 0}
1061
- ></pop-comment-icon>
1062
- </div>
1063
- <div
1064
- class=${Dt({"grid-widget__feed":!0,"grid-widget__feed--open":this._open})}
1065
- part="feed"
1066
- >
1067
- <pop-feed ?open=${this._open}></pop-feed>
1035
+ `;
1036
+ }
1037
+ };
1038
+ L([C(D)], q.prototype, "gridStore", void 0), customElements.get("pop-comment") || customElements.define("pop-comment", q);
1039
+ //#endregion
1040
+ //#region src/components/pop-feed.ts
1041
+ var Ne = F("\n :host {\n display: flex;\n background: var(--pop-background);\n border-radius: var(--pop-radius-2xl);\n border: 1px solid var(--pop-background);\n box-shadow: var(--pop-shadow-3xl);\n display: block;\n left: 0;\n max-height: 400px;\n max-width: 400px;\n min-width: 343px;\n opacity: 0;\n overflow: hidden;\n padding: 0 4px 0 0;\n pointer-events: none;\n position: fixed;\n top: 0;\n width: 100%;\n z-index: 9999;\n transform: scale(0.94);\n transition:\n opacity var(--pop-duration-quick) var(--pop-ease-quick),\n transform var(--pop-duration-quick) var(--pop-ease-quick),\n display var(--pop-duration-quick) allow-discrete;\n }\n\n :host([data-current-placement=\"top-start\"]) {\n transform-origin: left bottom;\n }\n\n :host([data-current-placement=\"bottom-start\"]) {\n transform-origin: left top;\n }\n\n :host([data-current-placement=\"top-end\"]) {\n transform-origin: right bottom;\n }\n\n :host([data-current-placement=\"bottom-end\"]) {\n transform-origin: right top;\n }\n\n :host([data-current-placement=\"top\"]) {\n transform-origin: bottom;\n }\n\n :host([data-current-placement=\"bottom\"]) {\n transform-origin: top;\n }\n\n :host([open]) {\n opacity: 1;\n pointer-events: auto;\n transform: scale(1);\n\n @starting-style {\n display: flex;\n opacity: 0;\n transform: scale(0.94);\n }\n }\n\n .feed {\n display: grid;\n grid-template-rows: 1fr 50px;\n }\n\n .feed__content {\n align-items: flex-start;\n align-self: stretch;\n display: flex;\n gap: 8px;\n min-height: 80px;\n max-height: 290px;\n }\n\n .feed__empty {\n padding: 24px 16px 24px 8px;\n text-align: center;\n font-family: Inter, sans-serif;\n font-size: 13px;\n color: var(--pop-muted-foreground);\n line-height: 18px;\n }\n\n .feed__footer {\n position: absolute;\n bottom: 0;\n min-height: 50px;\n width: 100%;\n }\n\n .feed__main {\n align-items: stretch;\n align-self: stretch;\n display: flex;\n flex-direction: column;\n flex: 1 0 0;\n gap: 16px;\n min-height: 100%;\n overflow: hidden auto;\n padding: 8px 10px 8px 8px;\n }\n\n .feed__main::-webkit-scrollbar {\n width: 4px;\n }\n\n .feed__main::-webkit-scrollbar-track {\n background: transparent;\n }\n\n .feed__main::-webkit-scrollbar-thumb {\n background: var(--pop-border);\n border-radius: 100px;\n }\n"), J = class extends I {
1042
+ constructor(...e) {
1043
+ super(...e), this._footerChild = null, this._wasOpen = !1;
1044
+ }
1045
+ get styleSheets() {
1046
+ return [Ne];
1047
+ }
1048
+ connectedCallback() {
1049
+ super.connectedCallback(), document.addEventListener("mousedown", this), document.addEventListener("keydown", this);
1050
+ }
1051
+ disconnectedCallback() {
1052
+ document.removeEventListener("mousedown", this), document.removeEventListener("keydown", this), super.disconnectedCallback();
1053
+ }
1054
+ handleEvent(e) {
1055
+ if (e.type === "mousedown") {
1056
+ this.onOutsideClick(e);
1057
+ return;
1058
+ }
1059
+ if (e.type === "keydown") {
1060
+ this.onKeyDown(e);
1061
+ return;
1062
+ }
1063
+ super.handleEvent(e);
1064
+ }
1065
+ onOutsideClick(e) {
1066
+ if (!this.gridStore.open.value) return;
1067
+ let t = e.composedPath(), n = this.getRootNode(), r = n instanceof ShadowRoot ? n.host : null;
1068
+ !t.includes(this) && (!r || !t.includes(r)) && (this.gridStore.open.value = !1);
1069
+ }
1070
+ onKeyDown(e) {
1071
+ e.key === "Escape" && (this.gridStore.open.value = !1);
1072
+ }
1073
+ setupEffects() {
1074
+ this.addEffect(() => {
1075
+ let e = this.gridStore.open.value;
1076
+ e && !this._wasOpen && this.gridStore.grid.value && b(this.gridStore.apiUrl, this.gridStore.publicKey), this._wasOpen = e, this.update();
1077
+ });
1078
+ }
1079
+ update() {
1080
+ this.gridStore.open.value ? this.setAttribute("open", "") : this.removeAttribute("open");
1081
+ let e = this.getElement(".feed__main");
1082
+ if (e) {
1083
+ let t = this.gridStore.topLevelComments.value;
1084
+ if (t.length === 0) e.querySelector(".feed__empty") || (e.innerHTML = "<div class=\"feed__empty\">Waiting for your thoughts…</div>");
1085
+ else {
1086
+ let n = Array.from(e.querySelectorAll("pop-comment-thread")).map((e) => e.getAttribute("comment-id")), r = t.map((e) => e.id);
1087
+ (n.length !== r.length || n.some((e, t) => e !== r[t])) && (e.innerHTML = t.map((e) => `<pop-comment-thread comment-id="${e.id}"></pop-comment-thread>`).join(""));
1088
+ }
1089
+ }
1090
+ let t = this.getElement(".feed__footer");
1091
+ if (t) {
1092
+ let e = g.value === null ? "pop-auth-panel" : "pop-comment-bar";
1093
+ this._footerChild !== e && (this._footerChild = e, t.innerHTML = `<${e}></${e}>`);
1094
+ }
1095
+ }
1096
+ getTemplate() {
1097
+ return "\n <div class=\"feed\">\n <div class=\"feed__content\">\n <div class=\"feed__main\"></div>\n </div>\n <div class=\"feed__footer\"></div>\n </div>\n ";
1098
+ }
1099
+ };
1100
+ L([C(D)], J.prototype, "gridStore", void 0), customElements.get("pop-feed") || customElements.define("pop-feed", J);
1101
+ //#endregion
1102
+ //#region node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1103
+ function Pe() {
1104
+ return typeof window < "u";
1105
+ }
1106
+ function Y(e) {
1107
+ var t;
1108
+ return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
1109
+ }
1110
+ function Fe(e) {
1111
+ return Pe() ? e instanceof Element || e instanceof Y(e).Element : !1;
1112
+ }
1113
+ var Ie = /transform|translate|scale|rotate|perspective|filter/, Le = /paint|layout|strict|content/, X = (e) => !!e && e !== "none", Z;
1114
+ function Re(e) {
1115
+ let t = Fe(e) ? Be(e) : e;
1116
+ return X(t.transform) || X(t.translate) || X(t.scale) || X(t.rotate) || X(t.perspective) || !ze() && (X(t.backdropFilter) || X(t.filter)) || Ie.test(t.willChange || "") || Le.test(t.contain || "");
1117
+ }
1118
+ function ze() {
1119
+ return Z ??= typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none"), Z;
1120
+ }
1121
+ function Be(e) {
1122
+ return Y(e).getComputedStyle(e);
1123
+ }
1124
+ //#endregion
1125
+ //#region node_modules/.pnpm/composed-offset-position@0.0.6_@floating-ui+utils@0.2.11/node_modules/composed-offset-position/dist/composed-offset-position.browser.min.mjs
1126
+ function Ve(e) {
1127
+ return He(e);
1128
+ }
1129
+ function Q(e) {
1130
+ return e.assignedSlot ? e.assignedSlot : e.parentNode instanceof ShadowRoot ? e.parentNode.host : e.parentNode;
1131
+ }
1132
+ function He(e) {
1133
+ for (let t = e; t; t = Q(t)) if (t instanceof Element && getComputedStyle(t).display === "none") return null;
1134
+ for (let t = Q(e); t; t = Q(t)) {
1135
+ if (!(t instanceof Element)) continue;
1136
+ let e = getComputedStyle(t);
1137
+ if (e.display !== "contents" && (e.position !== "static" || Re(e) || t.tagName === "BODY")) return t;
1138
+ }
1139
+ return null;
1140
+ }
1141
+ //#endregion
1142
+ //#region src/components/pop-grid.ts
1143
+ var Ue = F("\n :host {\n display: block;\n position: relative;\n }\n\n .grid {\n display: flex;\n height: 100%;\n position: relative;\n width: 100%;\n }\n\n .grid--align-start {\n justify-content: flex-start;\n }\n\n .grid--align-center {\n justify-content: center;\n }\n\n .grid--align-end {\n justify-content: flex-end;\n }\n"), We = class extends I {
1144
+ constructor(...e) {
1145
+ super(...e), this._initialized = !1;
1146
+ }
1147
+ get styleSheets() {
1148
+ return [Ue];
1149
+ }
1150
+ connectedCallback() {
1151
+ if (this._initialized) return;
1152
+ this._initialized = !0;
1153
+ let e = this.getAttribute("data-key") ?? this.getAttribute("public-key") ?? "", t = this.getAttribute("data-api-url") ?? this.getAttribute("api-url") ?? "", n = this.getAttribute("data-page-url") ?? this.getAttribute("page-url") ?? location.href, r = this.getAttribute("data-id");
1154
+ this._store = new D({
1155
+ apiUrl: t,
1156
+ publicKey: e,
1157
+ pageUrl: n,
1158
+ externalId: r
1159
+ }), ce(this, this._store), super.connectedCallback(), this._store.load().then((n) => {
1160
+ n && b(t, e);
1161
+ });
1162
+ }
1163
+ disconnectedCallback() {
1164
+ this._floatingCleanup?.(), this._store.destroy(), le(this), super.disconnectedCallback();
1165
+ }
1166
+ setupEffects() {
1167
+ this.addEffect(() => {
1168
+ let e = this._store.grid.value, t = this.getElement(".grid");
1169
+ if (!t) return;
1170
+ let n = Array.from(t.classList).filter((e) => e.startsWith("grid--"));
1171
+ if (n.length > 0 && t.classList.remove(...n), e) {
1172
+ e.align && t.classList.add(`grid--align-${e.align}`), e.appearance && t.classList.add(`grid--appearance-${e.appearance}`), e.icon && t.classList.add(`grid--icon-${e.icon}`), e.layout && t.classList.add(`grid--layout-${e.layout}`), e.position && t.classList.add(`grid--position-${e.position}`);
1173
+ let n = e.previewCount ?? this._store.previewCount;
1174
+ t.classList.add(`grid--preview-${n}`);
1175
+ }
1176
+ }), this.addEffect(() => {
1177
+ let e = this._store.open.value;
1178
+ if (this._floatingCleanup &&= (this._floatingCleanup(), void 0), !e) return;
1179
+ let t = this.getElement("pop-widget"), n = this.getElement("pop-feed");
1180
+ if (!t || !n) return;
1181
+ let r = this._store.grid.value;
1182
+ if (!r) return;
1183
+ let l = [];
1184
+ l = [s({
1185
+ mainAxis: r.position === "down" ? -16 : -54,
1186
+ crossAxis: -18
1187
+ })], (!r.position || r.position === "auto") && l.push(o({
1188
+ fallbackPlacements: ["bottom-start", "top-start"],
1189
+ fallbackStrategy: "bestFit",
1190
+ padding: 16
1191
+ }));
1192
+ let u = (e) => c.getOffsetParent(e, Ve), d = () => {
1193
+ a(t, n, {
1194
+ placement: r.position === "down" ? "bottom-start" : "top-start",
1195
+ middleware: l,
1196
+ strategy: "fixed",
1197
+ platform: {
1198
+ ...c,
1199
+ getOffsetParent: u
1200
+ }
1201
+ }).then(({ x: e, y: t, placement: r }) => {
1202
+ n.setAttribute("data-current-placement", r), Object.assign(n.style, {
1203
+ left: `${e}px`,
1204
+ top: `${t}px`
1205
+ });
1206
+ });
1207
+ };
1208
+ this._floatingCleanup = i(t, n, d);
1209
+ });
1210
+ }
1211
+ getTemplate() {
1212
+ return "\n <div class=\"grid\">\n <pop-widget></pop-widget>\n <pop-feed></pop-feed>\n </div>\n ";
1213
+ }
1214
+ };
1215
+ customElements.get("pop-grid") || customElements.define("pop-grid", We);
1216
+ //#endregion
1217
+ //#region src/components/pop-widget.ts
1218
+ var Ge = F("\n :host {\n --error-badge-bg: #fef2f2;\n --error-badge-text: #991b1b;\n --error-badge-border: #fecaca;\n\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n user-select: none;\n -webkit-user-select: none;\n }\n\n @media (prefers-color-scheme: dark) {\n :host {\n --error-badge-bg: #450a0a;\n --error-badge-text: #fca5a5;\n --error-badge-border: #7f1d1d;\n }\n }\n\n :host(.dark) {\n --error-badge-bg: #450a0a;\n --error-badge-text: #fca5a5;\n --error-badge-border: #7f1d1d;\n }\n\n :host([data-error]) {\n cursor: default;\n }\n\n .error-badge {\n display: inline-flex;\n align-items: center;\n padding: 2px 10px;\n border-radius: var(--pop-radius-full);\n border: 1px solid var(--error-badge-border);\n background: var(--error-badge-bg);\n color: var(--error-badge-text);\n font-size: 12px;\n font-weight: 500;\n line-height: 16px;\n white-space: nowrap;\n }\n\n .widget {\n display: inline-flex;\n align-items: flex-start;\n }\n\n .widget > :not([hidden]) ~ :not([hidden]) {\n margin-left: -6px;\n }\n\n .skeleton {\n width: 32px;\n height: 32px;\n background: var(--pop-muted);\n animation: pulse 1.5s ease-in-out infinite;\n }\n\n @keyframes pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n }\n\n .count {\n --count-size: calc(32px + var(--count-border-size));\n --count-background: var(--pop-background);\n --count-border-color: rgba(0 0 32 / 16%);\n --count-border-size: 1px;\n --count-color: var(--pop-foreground);\n\n align-items: center;\n background-color: var(--pop-background);\n display: flex;\n flex-shrink: 0;\n justify-content: center;\n padding: calc(var(--count-border-size) / 2);\n position: relative;\n z-index: 10;\n\n width: calc(var(--count-size) + (calc(var(--count-border-size))));\n height: calc(var(--count-size) + (calc(var(--count-border-size))));\n }\n\n .count__background {\n background-color: var(--count-border-color);\n position: absolute;\n top: 0;\n left: 0;\n z-index: 10;\n width: 100%;\n height: 100%;\n }\n\n .count__content {\n align-items: center;\n background: var(--count-background);\n display: flex;\n justify-content: center;\n overflow: hidden;\n height: var(--count-size);\n width: var(--count-size);\n }\n\n .count__label {\n color: var(--count-color);\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n letter-spacing: -0.96px;\n line-height: 28px;\n text-align: center;\n user-select: none;\n }\n\n .count__label-container {\n align-items: center;\n background: var(--pop-background);\n display: flex;\n height: calc(100% - calc(var(--count-border-size) * 2));\n justify-content: center;\n position: relative;\n text-indent: calc(calc(var(--count-border-size) * 2) * -1);\n width: calc(100% - calc(var(--count-border-size) * 2));\n z-index: 20;\n }\n"), $ = class extends I {
1219
+ constructor(...e) {
1220
+ super(...e), this.events = { click: "onClick" };
1221
+ }
1222
+ get styleSheets() {
1223
+ return [Ge];
1224
+ }
1225
+ onClick() {
1226
+ this.gridStore.error.value || (this.gridStore.open.value = !this.gridStore.open.value);
1227
+ }
1228
+ setupEffects() {
1229
+ this.addEffect(() => {
1230
+ this.gridStore.loading.value, this.gridStore.error.value, this.gridStore.previewAvatars.value, this.gridStore.comments.value, this.gridStore.grid.value;
1231
+ let e = !!this.gridStore.error.value;
1232
+ this.toggleAttribute("data-error", e), e && this.gridStore.open.value && (this.gridStore.open.value = !1), this.render();
1233
+ });
1234
+ }
1235
+ getTemplate() {
1236
+ if (this.gridStore.loading.value) return "<div class=\"widget\"><div class=\"skeleton mask mask-squircle\"></div></div>";
1237
+ if (this.gridStore.error.value) return "<div class=\"error-badge\">Error: there was a problem loading the PopGrid</div>";
1238
+ let e = this.gridStore.previewAvatars.value, t = this.gridStore.comments.value.length;
1239
+ return `
1240
+ <div class="widget">
1241
+ ${e.map((t, n) => {
1242
+ let r = e.length + n, i = t?.id ?? t?.name ?? "";
1243
+ return t?.image ? `<pop-comment-avatar size="xs" style="z-index: ${r}" data-color-key="${i}">
1244
+ <img src="${t.image}" alt="${t.name ?? "User"}" />
1245
+ </pop-comment-avatar>` : `<pop-comment-avatar size="xs" style="z-index: ${r}" data-color-key="${i}">
1246
+ ${B(t?.name)}
1247
+ </pop-comment-avatar>`;
1248
+ }).join("")}
1249
+ <div class="count mask mask-squircle">
1250
+ <span class="count__content mask mask-squircle">
1251
+ <div class="count__background mask mask-squircle"></div>
1252
+ <div class="count__label-container mask mask-squircle">
1253
+ <div class="count__label">${t}</div>
1254
+ </div>
1255
+ </span>
1068
1256
  </div>
1069
1257
  </div>
1070
- `:I`<p>No grid found.</p>`}};x.styles=[l(x,x,"styles"),St],i([Ri({context:C,subscribe:!0})],x.prototype,"gridContext",2),i([Ni()],x.prototype,"_open",2),i([jt(".grid-widget__previews")],x.prototype,"_previews",2),i([jt(".grid-widget__feed")],x.prototype,"_feed",2),x=i([Ki("pop-widget")],x);var Fi=x;import{provide as Yi}from"@lit/context";import{LitElement as Gi,html as Pi}from"lit";import{customElement as Wi,property as Xi,state as Oi}from"lit/decorators.js";import Zi from"openapi-fetch";var At=s=>Zi({baseUrl:s});var T=class extends Gi{constructor(){super(...arguments);this.apiState={baseUrl:"",client:null}}connectedCallback(){super.connectedCallback(),this.apiUrl?(this.apiState={...this.apiState,baseUrl:this.apiUrl,client:At(this.apiUrl)},this.requestUpdate()):console.error("API URL or ID not provided.")}render(){return Pi`<slot></slot>`}};i([Xi({type:String,attribute:"api-url"})],T.prototype,"apiUrl",2),i([Yi({context:E}),Oi()],T.prototype,"apiState",2),T=i([Wi("pop-api-provider")],T);var tr=T;export{tr as PopApiProvider,It as PopAuthJoin,Zt as PopAuthPanel,ie as PopAuthProvider,ue as PopAuthSignIn,we as PopAuthVerifyCode,ui as PopComment,_e as PopCommentBar,Ye as PopCommentInput,ii as PopCommentThread,vi as PopFeed,Ei as PopGrid,ki as PopGridProvider,Fi as PopWidget};
1258
+ `;
1259
+ }
1260
+ };
1261
+ //#endregion
1262
+ //#region src/index.ts
1263
+ if (L([C(D)], $.prototype, "gridStore", void 0), customElements.get("pop-widget") || customElements.define("pop-widget", $), typeof document < "u") {
1264
+ let e = "https://rsms.me/inter/inter.css";
1265
+ if (!document.querySelector(`link[href="${e}"]`)) {
1266
+ let t = document.createElement("link");
1267
+ t.rel = "stylesheet", t.href = e, document.head.appendChild(t);
1268
+ }
1269
+ }
1270
+ //#endregion
1271
+
1071
1272
  //# sourceMappingURL=index.js.map