@pixelmatters/markup 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js ADDED
@@ -0,0 +1,4755 @@
1
+ import { useEffect as e } from "react";
2
+ //#region ../../node_modules/.pnpm/preact@10.29.1/node_modules/preact/dist/preact.module.js
3
+ var t, n, r, i, a, o, s, c, l, u, d, f, p, m, h = {}, g = [], _ = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, v = Array.isArray;
4
+ function y(e, t) {
5
+ for (var n in t) e[n] = t[n];
6
+ return e;
7
+ }
8
+ function b(e) {
9
+ e && e.parentNode && e.parentNode.removeChild(e);
10
+ }
11
+ function x(e, n, r) {
12
+ var i, a, o, s = {};
13
+ for (o in n) o == "key" ? i = n[o] : o == "ref" ? a = n[o] : s[o] = n[o];
14
+ if (arguments.length > 2 && (s.children = arguments.length > 3 ? t.call(arguments, 2) : r), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) s[o] === void 0 && (s[o] = e.defaultProps[o]);
15
+ return S(e, s, i, a, null);
16
+ }
17
+ function S(e, t, i, a, o) {
18
+ var s = {
19
+ type: e,
20
+ props: t,
21
+ key: i,
22
+ ref: a,
23
+ __k: null,
24
+ __: null,
25
+ __b: 0,
26
+ __e: null,
27
+ __c: null,
28
+ constructor: void 0,
29
+ __v: o ?? ++r,
30
+ __i: -1,
31
+ __u: 0
32
+ };
33
+ return o == null && n.vnode != null && n.vnode(s), s;
34
+ }
35
+ function C(e) {
36
+ return e.children;
37
+ }
38
+ function w(e, t) {
39
+ this.props = e, this.context = t;
40
+ }
41
+ function T(e, t) {
42
+ if (t == null) return e.__ ? T(e.__, e.__i + 1) : null;
43
+ for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
44
+ return typeof e.type == "function" ? T(e) : null;
45
+ }
46
+ function E(e) {
47
+ if (e.__P && e.__d) {
48
+ var t = e.__v, r = t.__e, i = [], a = [], o = y({}, t);
49
+ o.__v = t.__v + 1, n.vnode && n.vnode(o), re(e.__P, o, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [r] : null, i, r ?? T(t), !!(32 & t.__u), a), o.__v = t.__v, o.__.__k[o.__i] = o, ae(i, o, a), t.__e = t.__ = null, o.__e != r && D(o);
50
+ }
51
+ }
52
+ function D(e) {
53
+ if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
54
+ if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
55
+ }), D(e);
56
+ }
57
+ function O(e) {
58
+ (!e.__d && (e.__d = !0) && i.push(e) && !k.__r++ || a != n.debounceRendering) && ((a = n.debounceRendering) || o)(k);
59
+ }
60
+ function k() {
61
+ try {
62
+ for (var e, t = 1; i.length;) i.length > t && i.sort(s), e = i.shift(), t = i.length, E(e);
63
+ } finally {
64
+ i.length = k.__r = 0;
65
+ }
66
+ }
67
+ function A(e, t, n, r, i, a, o, s, c, l, u) {
68
+ var d, f, p, m, _, v, y, b = r && r.__k || g, x = t.length;
69
+ for (c = ee(n, t, b, c, x), d = 0; d < x; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && b[p.__i] || h, p.__i = d, v = re(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && se(f.ref, null, p), u.push(p.ref, p.__c || m, p)), _ == null && m != null && (_ = m), (y = !!(4 & p.__u)) || f.__k === p.__k ? (c = j(p, c, e, y), y && f.__e && (f.__e = null)) : typeof p.type == "function" && v !== void 0 ? c = v : m && (c = m.nextSibling), p.__u &= -7);
70
+ return n.__e = _, c;
71
+ }
72
+ function ee(e, t, n, r, i) {
73
+ var a, o, s, c, l, u = n.length, d = u, f = 0;
74
+ for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = S(null, o, null, null, null) : v(o) ? o = e.__k[a] = S(C, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = S(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = M(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
75
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = T(s)), ce(s, s));
76
+ return r;
77
+ }
78
+ function j(e, t, n, r) {
79
+ var i, a;
80
+ if (typeof e.type == "function") {
81
+ for (i = e.__k, a = 0; i && a < i.length; a++) i[a] && (i[a].__ = e, t = j(i[a], t, n, r));
82
+ return t;
83
+ }
84
+ e.__e != t && (r && (t && e.type && !t.parentNode && (t = T(e)), n.insertBefore(e.__e, t || null)), t = e.__e);
85
+ do
86
+ t &&= t.nextSibling;
87
+ while (t != null && t.nodeType == 8);
88
+ return t;
89
+ }
90
+ function M(e, t, n, r) {
91
+ var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && (2 & l.__u) == 0;
92
+ if (l === null && s == null || u && s == l.key && c == l.type) return n;
93
+ if (r > +!!u) {
94
+ for (i = n - 1, a = n + 1; i >= 0 || a < t.length;) if ((l = t[o = i >= 0 ? i-- : a++]) != null && !(2 & l.__u) && s == l.key && c == l.type) return o;
95
+ }
96
+ return -1;
97
+ }
98
+ function te(e, t, n) {
99
+ t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || _.test(t) ? n : n + "px";
100
+ }
101
+ function N(e, t, n, r, i) {
102
+ var a, o;
103
+ n: if (t == "style") if (typeof n == "string") e.style.cssText = n;
104
+ else {
105
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || te(e.style, t, "");
106
+ if (n) for (t in n) r && n[t] == r[t] || te(e.style, t, n[t]);
107
+ }
108
+ else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(d, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[u] = r[u] : (n[u] = f, e.addEventListener(t, a ? m : p, a)) : e.removeEventListener(t, a ? m : p, a);
109
+ else {
110
+ if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
111
+ else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
112
+ e[t] = n ?? "";
113
+ break n;
114
+ } catch {}
115
+ typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
116
+ }
117
+ }
118
+ function ne(e) {
119
+ return function(t) {
120
+ if (this.l) {
121
+ var r = this.l[t.type + e];
122
+ if (t[l] == null) t[l] = f++;
123
+ else if (t[l] < r[u]) return;
124
+ return r(n.event ? n.event(t) : t);
125
+ }
126
+ };
127
+ }
128
+ function re(e, t, r, i, a, o, s, c, l, u) {
129
+ var d, f, p, m, h, _, x, S, T, E, D, O, k, ee, j, M = t.type;
130
+ if (t.constructor !== void 0) return null;
131
+ 128 & r.__u && (l = !!(32 & r.__u), o = [c = t.__e = r.__e]), (d = n.__b) && d(t);
132
+ n: if (typeof M == "function") try {
133
+ if (S = t.props, T = M.prototype && M.prototype.render, E = (d = M.contextType) && i[d.__c], D = d ? E ? E.props.value : d.__ : i, r.__c ? x = (f = t.__c = r.__c).__ = f.__E : (T ? t.__c = f = new M(S, D) : (t.__c = f = new w(S, D), f.constructor = M, f.render = le), E && E.sub(f), f.state ||= {}, f.__n = i, p = f.__d = !0, f.__h = [], f._sb = []), T && f.__s == null && (f.__s = f.state), T && M.getDerivedStateFromProps != null && (f.__s == f.state && (f.__s = y({}, f.__s)), y(f.__s, M.getDerivedStateFromProps(S, f.__s))), m = f.props, h = f.state, f.__v = t, p) T && M.getDerivedStateFromProps == null && f.componentWillMount != null && f.componentWillMount(), T && f.componentDidMount != null && f.__h.push(f.componentDidMount);
134
+ else {
135
+ if (T && M.getDerivedStateFromProps == null && S !== m && f.componentWillReceiveProps != null && f.componentWillReceiveProps(S, D), t.__v == r.__v || !f.__e && f.shouldComponentUpdate != null && !1 === f.shouldComponentUpdate(S, f.__s, D)) {
136
+ t.__v != r.__v && (f.props = S, f.state = f.__s, f.__d = !1), t.__e = r.__e, t.__k = r.__k, t.__k.some(function(e) {
137
+ e && (e.__ = t);
138
+ }), g.push.apply(f.__h, f._sb), f._sb = [], f.__h.length && s.push(f);
139
+ break n;
140
+ }
141
+ f.componentWillUpdate != null && f.componentWillUpdate(S, f.__s, D), T && f.componentDidUpdate != null && f.__h.push(function() {
142
+ f.componentDidUpdate(m, h, _);
143
+ });
144
+ }
145
+ if (f.context = D, f.props = S, f.__P = e, f.__e = !1, O = n.__r, k = 0, T) f.state = f.__s, f.__d = !1, O && O(t), d = f.render(f.props, f.state, f.context), g.push.apply(f.__h, f._sb), f._sb = [];
146
+ else do
147
+ f.__d = !1, O && O(t), d = f.render(f.props, f.state, f.context), f.state = f.__s;
148
+ while (f.__d && ++k < 25);
149
+ f.state = f.__s, f.getChildContext != null && (i = y(y({}, i), f.getChildContext())), T && !p && f.getSnapshotBeforeUpdate != null && (_ = f.getSnapshotBeforeUpdate(m, h)), ee = d != null && d.type === C && d.key == null ? oe(d.props.children) : d, c = A(e, v(ee) ? ee : [ee], t, r, i, a, o, s, c, l, u), f.base = t.__e, t.__u &= -161, f.__h.length && s.push(f), x && (f.__E = f.__ = null);
150
+ } catch (e) {
151
+ if (t.__v = null, l || o != null) if (e.then) {
152
+ for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
153
+ o[o.indexOf(c)] = null, t.__e = c;
154
+ } else {
155
+ for (j = o.length; j--;) b(o[j]);
156
+ ie(t);
157
+ }
158
+ else t.__e = r.__e, t.__k = r.__k, e.then || ie(t);
159
+ n.__e(e, t, r);
160
+ }
161
+ else o == null && t.__v == r.__v ? (t.__k = r.__k, t.__e = r.__e) : c = t.__e = P(r.__e, t, r, i, a, o, s, l, u);
162
+ return (d = n.diffed) && d(t), 128 & t.__u ? void 0 : c;
163
+ }
164
+ function ie(e) {
165
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ie));
166
+ }
167
+ function ae(e, t, r) {
168
+ for (var i = 0; i < r.length; i++) se(r[i], r[++i], r[++i]);
169
+ n.__c && n.__c(t, e), e.some(function(t) {
170
+ try {
171
+ e = t.__h, t.__h = [], e.some(function(e) {
172
+ e.call(t);
173
+ });
174
+ } catch (e) {
175
+ n.__e(e, t.__v);
176
+ }
177
+ });
178
+ }
179
+ function oe(e) {
180
+ return typeof e != "object" || !e || e.__b > 0 ? e : v(e) ? e.map(oe) : y({}, e);
181
+ }
182
+ function P(e, r, i, a, o, s, c, l, u) {
183
+ var d, f, p, m, g, _, y, x = i.props || h, S = r.props, C = r.type;
184
+ if (C == "svg" ? o = "http://www.w3.org/2000/svg" : C == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o ||= "http://www.w3.org/1999/xhtml", s != null) {
185
+ for (d = 0; d < s.length; d++) if ((g = s[d]) && "setAttribute" in g == !!C && (C ? g.localName == C : g.nodeType == 3)) {
186
+ e = g, s[d] = null;
187
+ break;
188
+ }
189
+ }
190
+ if (e == null) {
191
+ if (C == null) return document.createTextNode(S);
192
+ e = document.createElementNS(o, C, S.is && S), l &&= (n.__m && n.__m(r, s), !1), s = null;
193
+ }
194
+ if (C == null) x === S || l && e.data == S || (e.data = S);
195
+ else {
196
+ if (s &&= t.call(e.childNodes), !l && s != null) for (x = {}, d = 0; d < e.attributes.length; d++) x[(g = e.attributes[d]).name] = g.value;
197
+ for (d in x) g = x[d], d == "dangerouslySetInnerHTML" ? p = g : d == "children" || d in S || d == "value" && "defaultValue" in S || d == "checked" && "defaultChecked" in S || N(e, d, null, g, o);
198
+ for (d in S) g = S[d], d == "children" ? m = g : d == "dangerouslySetInnerHTML" ? f = g : d == "value" ? _ = g : d == "checked" ? y = g : l && typeof g != "function" || x[d] === g || N(e, d, g, x[d], o);
199
+ if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), r.__k = [];
200
+ else if (p && (e.innerHTML = ""), A(r.type == "template" ? e.content : e, v(m) ? m : [m], r, i, a, C == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, s, c, s ? s[0] : i.__k && T(i, 0), l, u), s != null) for (d = s.length; d--;) b(s[d]);
201
+ l || (d = "value", C == "progress" && _ == null ? e.removeAttribute("value") : _ != null && (_ !== e[d] || C == "progress" && !_ || C == "option" && _ != x[d]) && N(e, d, _, x[d], o), d = "checked", y != null && y != e[d] && N(e, d, y, x[d], o));
202
+ }
203
+ return e;
204
+ }
205
+ function se(e, t, r) {
206
+ try {
207
+ if (typeof e == "function") {
208
+ var i = typeof e.__u == "function";
209
+ i && e.__u(), i && t == null || (e.__u = e(t));
210
+ } else e.current = t;
211
+ } catch (e) {
212
+ n.__e(e, r);
213
+ }
214
+ }
215
+ function ce(e, t, r) {
216
+ var i, a;
217
+ if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || se(i, null, t)), (i = e.__c) != null) {
218
+ if (i.componentWillUnmount) try {
219
+ i.componentWillUnmount();
220
+ } catch (e) {
221
+ n.__e(e, t);
222
+ }
223
+ i.base = i.__P = null;
224
+ }
225
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && ce(i[a], t, r || typeof e.type != "function");
226
+ r || b(e.__e), e.__c = e.__ = e.__e = void 0;
227
+ }
228
+ function le(e, t, n) {
229
+ return this.constructor(e, n);
230
+ }
231
+ function ue(e, r, i) {
232
+ var a, o, s, c;
233
+ r == document && (r = document.documentElement), n.__ && n.__(e, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [], re(r, e = (!a && i || r).__k = x(C, null, [e]), o || h, h, r.namespaceURI, !a && i ? [i] : o ? null : r.firstChild ? t.call(r.childNodes) : null, s, !a && i ? i : o ? o.__e : r.firstChild, a, c), ae(s, e, c);
234
+ }
235
+ t = g.slice, n = { __e: function(e, t, n, r) {
236
+ for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
237
+ if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
238
+ } catch (t) {
239
+ e = t;
240
+ }
241
+ throw e;
242
+ } }, r = 0, w.prototype.setState = function(e, t) {
243
+ var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = y({}, this.state);
244
+ typeof e == "function" && (e = e(y({}, n), this.props)), e && y(n, e), e != null && this.__v && (t && this._sb.push(t), O(this));
245
+ }, w.prototype.forceUpdate = function(e) {
246
+ this.__v && (this.__e = !0, e && this.__h.push(e), O(this));
247
+ }, w.prototype.render = C, i = [], o = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, s = function(e, t) {
248
+ return e.__v.__b - t.__v.__b;
249
+ }, k.__r = 0, c = Math.random().toString(8), l = "__d" + c, u = "__a" + c, d = /(PointerCapture)$|Capture$/i, f = 0, p = ne(!1), m = ne(!0);
250
+ //#endregion
251
+ //#region src/styles.css?inline
252
+ var de = ":host{--markup-paper:#fdfcfa;--markup-ink:#1a1614;--markup-muted:#6b6661;--markup-border:#1a16141a;--markup-border-strong:#1a16142e;--markup-brand:#e35d2a;--markup-brand-hover:#c84d20;--markup-team:#2a4ac8;--markup-shadow:0 1px 2px #1a16140f, 0 8px 28px #1a16141f;--markup-overlay-tint:#1a16140a;--markup-danger:#dc2626;--markup-radius:6px;--markup-radius-sm:4px;--markup-font:\"Geist Variable\", \"Geist\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", system-ui, sans-serif;--markup-font-mono:\"Geist Mono Variable\", \"Geist Mono\", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;all:initial;font-family:var(--markup-font);color:var(--markup-ink);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:14px;line-height:1.5}:host([data-theme=dark]){--markup-paper:#1a1614;--markup-ink:#fdfcfa;--markup-muted:#a8a39e;--markup-border:#fdfcfa1f;--markup-border-strong:#fdfcfa38;--markup-team:#7b99f0;--markup-shadow:0 1px 2px #00000059, 0 12px 40px #00000073;--markup-overlay-tint:#fdfcfa0d;--markup-danger:#f87171}@media (prefers-color-scheme:dark){:host(:not([data-theme=light])){--markup-paper:#1a1614;--markup-ink:#fdfcfa;--markup-muted:#a8a39e;--markup-border:#fdfcfa1f;--markup-border-strong:#fdfcfa38;--markup-team:#7b99f0;--markup-shadow:0 1px 2px #00000059, 0 12px 40px #00000073;--markup-overlay-tint:#fdfcfa0d;--markup-danger:#f87171}}.markup-shadow-root{font-family:var(--markup-font)}.markup-shadow-root *,.markup-shadow-root :before,.markup-shadow-root :after{box-sizing:border-box}:where(.markup-shadow-root button,.markup-shadow-root input,.markup-shadow-root textarea){font:inherit;color:inherit}.markup-eyebrow{font-family:var(--markup-font-mono);letter-spacing:.12em;text-transform:uppercase;color:var(--markup-muted);font-size:10px;font-weight:500}.markup-fab{z-index:10;background:var(--markup-ink);color:var(--markup-paper);cursor:pointer;letter-spacing:-.01em;pointer-events:auto;box-shadow:0 0 0 1px color-mix(in srgb, var(--markup-brand) 35%, transparent), var(--markup-shadow);border:none;border-radius:999px;align-items:center;gap:8px;padding:9px 14px;font-size:13px;font-weight:500;transition:background .15s,box-shadow .15s,transform .15s;display:inline-flex;position:fixed;bottom:24px}.markup-fab:hover{background:var(--markup-brand);box-shadow:0 0 0 1px color-mix(in srgb, var(--markup-brand) 0%, transparent), var(--markup-shadow)}.markup-fab:active{transform:translateY(1px)}.markup-fab.is-active{background:var(--markup-brand);box-shadow:var(--markup-shadow)}.markup-fab.is-active:hover{background:var(--markup-brand-hover)}.markup-fab .markup-fab-icon{color:var(--markup-brand);transition:color .15s}.markup-fab:hover .markup-fab-icon,.markup-fab.is-active .markup-fab-icon{color:var(--markup-paper)}.markup-fab-right{right:24px}.markup-fab-left{left:24px}.markup-fab-icon{align-items:center;display:inline-flex}.markup-fab-label{font-family:var(--markup-font)}.markup-hud-hidden-toast{z-index:10;background:var(--markup-ink);color:var(--markup-paper);letter-spacing:-.01em;box-shadow:var(--markup-shadow);pointer-events:none;border-radius:999px;align-items:center;gap:6px;padding:8px 14px;font-size:12px;font-weight:500;animation:.22s ease-out markup-hud-hidden-in,.32s ease-in 4.6s forwards markup-hud-hidden-out;display:inline-flex;position:fixed;bottom:24px}.markup-hud-hidden-toast-right{right:24px}.markup-hud-hidden-toast-left{left:24px}.markup-kbd{background:color-mix(in srgb, var(--markup-paper) 14%, transparent);min-width:18px;height:18px;color:var(--markup-paper);font-family:var(--markup-font);border-radius:4px;justify-content:center;align-items:center;padding:0 5px;font-size:10px;font-weight:600;line-height:1;display:inline-flex}@keyframes markup-hud-hidden-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes markup-hud-hidden-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(4px)}}.markup-pins-layer{pointer-events:none;position:fixed;inset:0}.markup-pin{background:var(--markup-ink);width:28px;height:28px;color:var(--markup-brand);cursor:pointer;pointer-events:auto;box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 3px color-mix(in srgb, var(--markup-brand) 35%, transparent), var(--markup-shadow);border:none;border-radius:50% 50% 50% 4px;justify-content:center;align-items:center;margin-top:-28px;padding:0;transition:transform .15s,background .15s,color .15s;display:inline-flex;position:absolute}.markup-pin:hover,.markup-pin.is-active{background:var(--markup-brand);color:var(--markup-paper)}.markup-pin.is-anchor{anchor-name:--markup-active-anchor}.markup-pin-ghost{background:var(--markup-brand);color:var(--markup-paper);cursor:default;pointer-events:none;animation:1.2s ease-in-out infinite markup-ghost-pulse}.markup-pin-dot{background:currentColor;border-radius:50%;width:6px;height:6px;display:inline-block}.markup-pin-count{background:var(--markup-brand);min-width:16px;height:16px;color:var(--markup-paper);font-family:var(--markup-font-mono);text-align:center;box-shadow:0 0 0 2px var(--markup-paper);border-radius:999px;padding:0 4px;font-size:9px;font-weight:600;line-height:16px;position:absolute;top:-4px;left:50%;transform:translate(-50%,-50%)}@keyframes markup-ghost-pulse{0%,to{box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 0 #e35d2a66}50%{box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 10px #e35d2a00}}.markup-placement-overlay{background:var(--markup-overlay-tint);cursor:crosshair;pointer-events:auto;z-index:1;animation:.18s ease-out markup-overlay-in;position:fixed;inset:0}.markup-placement-cursor-help{background:var(--markup-ink);color:var(--markup-paper);letter-spacing:-.01em;box-shadow:var(--markup-shadow);pointer-events:none;border-radius:999px;padding:10px 16px;font-size:12px;font-weight:500;animation:.22s ease-out 60ms backwards markup-help-in;position:fixed;top:24px;left:50%;transform:translate(-50%)}@keyframes markup-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes markup-help-in{0%{opacity:0;transform:translate(-50%,-8px)}to{opacity:1;transform:translate(-50%)}}.markup-popover{width:320px;max-width:calc(100vw - 24px);height:auto;max-height:calc(100dvh - 24px);inset:auto;left:var(--markup-pop-x,0);top:var(--markup-pop-y,0);background:var(--markup-paper);color:var(--markup-ink);border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius);box-shadow:var(--markup-shadow);pointer-events:auto;flex-direction:column;gap:0;margin:0;padding:0;animation:.16s ease-out markup-popover-in;display:flex;position:fixed;overflow:hidden}@supports (anchor-name:--x){.markup-popover{position-anchor:--markup-active-anchor;left:calc(anchor(right) + 8px);top:calc(anchor(top) - 9px);position-try-fallbacks:flip-block, flip-inline, flip-block flip-inline;position-try-order:most-block-size}}@keyframes markup-popover-in{0%{opacity:0;transform:translateY(-4px)scale(.98)}to{opacity:1;transform:translateY(0)scale(1)}}.markup-popover-header{border-bottom:1px solid var(--markup-border);justify-content:space-between;align-items:center;padding:10px 12px;display:flex}.markup-popover-header-actions{align-items:center;gap:4px;display:flex}.markup-thread-menu{display:flex;position:relative}.markup-thread-menu-list{z-index:10;background:var(--markup-paper);border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius);min-width:160px;box-shadow:var(--markup-shadow);padding:4px;animation:.12s ease-out markup-menu-in;position:absolute;top:calc(100% + 6px);right:0}.markup-thread-menu-item{border-radius:var(--markup-radius-sm);width:100%;color:var(--markup-ink);text-align:left;cursor:pointer;background:0 0;border:none;padding:7px 10px;font-size:13px;transition:background .1s,color .1s;display:block}.markup-thread-menu-item:hover{background:var(--markup-border)}.markup-thread-menu-item.is-danger{color:var(--markup-danger,#dc2626)}.markup-thread-menu-item.is-danger:hover{background:color-mix(in srgb, var(--markup-danger,#dc2626) 10%, transparent)}.markup-thread-menu-item:disabled{opacity:.5;cursor:default}@keyframes markup-menu-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.markup-popover-body{padding:12px}.markup-popover-byline{color:var(--markup-muted);align-items:center;gap:4px;margin:0 0 8px;font-size:12px;display:flex}.markup-popover-name{color:var(--markup-ink);font-weight:500}.markup-icon-btn{border-radius:var(--markup-radius-sm);width:24px;height:24px;color:var(--markup-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;transition:background .12s,color .12s;display:inline-flex}.markup-icon-btn:hover,.markup-icon-btn.is-open{background:var(--markup-border);color:var(--markup-ink)}.markup-comments{border-bottom:1px solid var(--markup-border);background:linear-gradient(var(--markup-paper), transparent) top / 100% 20px no-repeat local, linear-gradient(transparent, var(--markup-paper)) bottom / 100% 20px no-repeat local, radial-gradient(farthest-side at 50% 0%, #1a16141a, transparent) top / 100% 10px no-repeat scroll, radial-gradient(farthest-side at 50% 100%, #1a16141a, transparent) bottom / 100% 10px no-repeat scroll;flex-direction:column;gap:12px;max-height:280px;margin:0;padding:8px 12px 4px;list-style:none;display:flex;overflow-y:auto}.markup-comment{flex-direction:column;gap:4px;display:flex}.markup-comment-meta{align-items:center;gap:6px;font-size:11px;display:flex}.markup-comment-author{color:var(--markup-ink);font-weight:600}.markup-comment.is-team .markup-comment-author{color:var(--markup-team)}.markup-comment-badge{background:color-mix(in srgb, var(--markup-team) 12%, transparent);height:14px;color:var(--markup-team);font-family:var(--markup-font-mono);letter-spacing:.12em;text-transform:uppercase;border-radius:999px;align-items:center;padding:0 5px;font-size:9px;font-weight:500;line-height:1;display:inline-flex}.markup-comment-time{color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.04em;font-size:10px}.markup-comment-body{white-space:pre-wrap;word-break:break-word;margin:0;font-size:13px;line-height:1.5}.markup-comment-edited{color:var(--markup-muted);font-size:11px}.markup-thread-actions{align-items:center;gap:4px;display:flex}.markup-comment-meta .markup-reaction-picker-wrap,.markup-thread-actions{margin-left:auto}.markup-comment-meta .markup-reaction-add{width:22px;height:22px;margin-top:-4px;margin-bottom:-4px}.markup-reaction-picker-wrap>.markup-icon-btn,.markup-comment-menu>.markup-icon-btn{margin-top:-4px;margin-bottom:-4px}.markup-comment-menu.is-up .markup-thread-menu-list{animation-name:markup-menu-in-up;top:auto;bottom:calc(100% + 6px)}@keyframes markup-menu-in-up{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.markup-comment{position:relative}.markup-reactions{flex-wrap:wrap;align-items:center;gap:4px;margin-top:2px;display:flex}.markup-reaction-chip{border:1px solid var(--markup-border);height:22px;color:var(--markup-ink);font:inherit;cursor:pointer;background:0 0;border-radius:999px;align-items:center;gap:4px;padding:0 7px 0 6px;font-size:11px;line-height:1;transition:background .12s,border-color .12s;display:inline-flex}.markup-reaction-chip:hover:not(:disabled){background:color-mix(in srgb, var(--markup-ink) 5%, transparent)}.markup-reaction-chip.is-mine{border-color:color-mix(in srgb, var(--markup-brand) 45%, transparent);background:color-mix(in srgb, var(--markup-brand) 10%, transparent)}.markup-reaction-chip.is-mine:hover:not(:disabled){background:color-mix(in srgb, var(--markup-brand) 16%, transparent)}.markup-reaction-chip:disabled{cursor:default;opacity:.6}.markup-reaction-emoji{font-size:13px;line-height:1}.markup-reaction-count{font-family:var(--markup-font-mono);letter-spacing:.04em;color:var(--markup-muted);font-size:10px}.markup-reaction-chip.is-mine .markup-reaction-count{color:var(--markup-brand)}.markup-reaction-picker-wrap{opacity:0;flex:none;transition:opacity .12s;display:inline-flex;position:relative}.markup-comment:hover .markup-reaction-picker-wrap,.markup-comment:focus-within .markup-reaction-picker-wrap,.markup-reaction-picker-wrap.is-open{opacity:1}.markup-reaction-add{border:1px dashed var(--markup-border-strong);width:22px;height:22px;color:var(--markup-muted);font:inherit;cursor:pointer;background:0 0;border-radius:999px;justify-content:center;align-items:center;font-size:13px;line-height:1;transition:background .12s,color .12s,border-color .12s;display:inline-flex}.markup-reaction-add:hover,.markup-reaction-add.is-open{background:color-mix(in srgb, var(--markup-ink) 5%, transparent);color:var(--markup-ink);border-style:solid}.markup-reaction-picker{z-index:1;border:1px solid var(--markup-border-strong);background:var(--markup-paper);border-radius:8px;gap:2px;padding:4px;animation:.12s markup-menu-in;display:flex;position:absolute;top:calc(100% + 6px);right:0;box-shadow:0 1px 2px #1a16140f,0 8px 28px #1a16141a}.markup-reaction-picker-wrap.is-up .markup-reaction-picker{animation-name:markup-menu-in-up;top:auto;bottom:calc(100% + 6px)}.markup-reaction-picker-item{cursor:pointer;background:0 0;border:0;border-radius:6px;justify-content:center;align-items:center;width:28px;height:28px;font-size:16px;line-height:1;transition:background .12s;display:inline-flex}.markup-reaction-picker-item:hover{background:color-mix(in srgb, var(--markup-ink) 8%, transparent)}.markup-reaction-picker-item.is-mine{background:color-mix(in srgb, var(--markup-brand) 14%, transparent)}.markup-comment-edit-form{flex-direction:column;gap:6px;display:flex}.markup-comment-edit-form .markup-textarea{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;color:var(--markup-ink);resize:vertical;font:inherit;outline:none;padding:8px 10px;font-size:13px;line-height:1.5}.markup-comment-edit-form .markup-textarea:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-comment-edit-actions{justify-content:flex-end;gap:6px;display:flex}.markup-composer{flex-direction:column;display:flex;position:relative}.markup-composer-input{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;min-height:36px;max-height:96px;color:var(--markup-ink);resize:none;font-family:var(--markup-font);outline:none;padding:8px 10px;font-size:13px;line-height:1.5;transition:border-color .12s,box-shadow .12s,border-bottom-left-radius .15s,border-bottom-right-radius .15s}.markup-composer-input:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-composer-input:disabled{opacity:.6}.markup-composer-input::placeholder{color:var(--markup-muted)}.markup-composer.is-filled .markup-composer-input{border-bottom-right-radius:0;border-bottom-left-radius:0}.markup-composer-footer-wrap{grid-template-rows:0fr;transition:grid-template-rows .15s;display:grid}.markup-composer.is-filled .markup-composer-footer-wrap{grid-template-rows:1fr}.markup-composer-footer{border:1px solid var(--markup-border-strong);border-radius:0 0 var(--markup-radius-sm) var(--markup-radius-sm);opacity:0;border-top:none;justify-content:space-between;align-items:center;gap:8px;padding:2px 2px 2px 10px;transition:opacity .1s;display:flex;overflow:hidden}.markup-composer.is-filled .markup-composer-footer{opacity:1;transition-delay:60ms}.markup-composer-hint{font-family:var(--markup-font-mono);letter-spacing:.06em;color:var(--markup-muted);font-size:10px}.markup-composer-error{color:var(--markup-brand)}.markup-composer-actions{align-items:center;gap:6px;display:flex}.markup-composer-actions-empty{transition:opacity .12s;position:absolute;top:3px;right:3px}.markup-composer.is-filled .markup-composer-actions-empty{opacity:0;pointer-events:none}.markup-author-prompt{flex-direction:column;gap:10px;padding:12px;display:flex}.markup-input{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;height:36px;color:var(--markup-ink);outline:none;padding:0 10px;font-size:14px;transition:border-color .12s,box-shadow .12s}.markup-input:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-btn{border-radius:var(--markup-radius-sm);height:30px;color:var(--markup-ink);cursor:pointer;letter-spacing:-.01em;white-space:nowrap;background:0 0;border:1px solid #0000;justify-content:center;align-items:center;gap:6px;padding:0 8px;font-size:12px;font-weight:500;transition:background .12s,border-color .12s,color .12s,opacity .12s;display:inline-flex}.markup-btn:disabled{opacity:.5;cursor:not-allowed}.markup-btn-primary{background:var(--markup-ink);color:var(--markup-paper)}.markup-btn-primary:hover:not(:disabled){background:var(--markup-brand)}.markup-btn-ghost{color:var(--markup-muted)}.markup-btn-ghost:hover:not(:disabled){background:var(--markup-border);color:var(--markup-ink)}.markup-screenshot-row{border-top:1px solid var(--markup-border);margin-top:8px;padding-top:8px}.markup-screenshot-status{color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.06em;align-items:center;gap:5px;font-size:10px;display:flex}.markup-screenshot-toggle{cursor:pointer;color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.06em;align-items:center;gap:5px;font-size:10px;transition:color .12s;display:flex}.markup-screenshot-toggle:hover{color:var(--markup-ink)}.markup-screenshot-checkbox{width:12px;height:12px;accent-color:var(--markup-brand);cursor:pointer;margin:0}.markup-screenshot-thumb{border:1px solid var(--markup-border-strong);object-fit:cover;border-radius:3px;flex-shrink:0;width:auto;height:25px;margin:-5px 0 -5px auto;display:block}.markup-comment-screenshot{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);cursor:pointer;background:0 0;margin-top:8px;padding:0;transition:border-color .12s,opacity .12s;display:block;overflow:hidden}.markup-comment-screenshot:hover{border-color:var(--markup-brand);opacity:.9}.markup-comment-screenshot img{object-fit:cover;object-position:top;width:100%;height:auto;max-height:120px;display:block}.markup-lightbox{background:#1a1614e0;border:none;width:100%;max-width:100%;height:100%;max-height:100%;margin:0;padding:24px;position:fixed;inset:0}.markup-lightbox[open]{justify-content:center;align-items:center;display:flex}.markup-lightbox::backdrop{display:none}.markup-lightbox-img{border-radius:var(--markup-radius);object-fit:contain;max-width:100%;max-height:100%;box-shadow:var(--markup-shadow);animation:.16s ease-out markup-lightbox-in}.markup-lightbox-close{color:#fdfcfa;background:#1a161499;position:absolute;top:16px;right:16px}.markup-lightbox-close:hover{color:#fdfcfa;background:#1a1614d9}@keyframes markup-lightbox-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@media (prefers-reduced-motion:reduce){.markup-fab,.markup-pin,.markup-icon-btn,.markup-btn,.markup-popover,.markup-pin-ghost,.markup-placement-overlay,.markup-placement-cursor-help,.markup-lightbox-img{transition:none;animation:none}}", fe, F, pe, me, he = 0, ge = [], I = n, _e = I.__b, ve = I.__r, ye = I.diffed, be = I.__c, xe = I.unmount, Se = I.__;
253
+ function Ce(e, t) {
254
+ I.__h && I.__h(F, e, he || t), he = 0;
255
+ var n = F.__H ||= {
256
+ __: [],
257
+ __h: []
258
+ };
259
+ return e >= n.__.length && n.__.push({}), n.__[e];
260
+ }
261
+ function L(e) {
262
+ return he = 1, we(Me, e);
263
+ }
264
+ function we(e, t, n) {
265
+ var r = Ce(fe++, 2);
266
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Me(void 0, t), function(e) {
267
+ var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
268
+ t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
269
+ }], r.__c = F, !F.__f)) {
270
+ var i = function(e, t, n) {
271
+ if (!r.__c.__H) return !0;
272
+ var i = r.__c.__H.__.filter(function(e) {
273
+ return e.__c;
274
+ });
275
+ if (i.every(function(e) {
276
+ return !e.__N;
277
+ })) return !a || a.call(this, e, t, n);
278
+ var o = r.__c.props !== e;
279
+ return i.some(function(e) {
280
+ if (e.__N) {
281
+ var t = e.__[0];
282
+ e.__ = e.__N, e.__N = void 0, t !== e.__[0] && (o = !0);
283
+ }
284
+ }), a && a.call(this, e, t, n) || o;
285
+ };
286
+ F.__f = !0;
287
+ var a = F.shouldComponentUpdate, o = F.componentWillUpdate;
288
+ F.componentWillUpdate = function(e, t, n) {
289
+ if (this.__e) {
290
+ var r = a;
291
+ a = void 0, i(e, t, n), a = r;
292
+ }
293
+ o && o.call(this, e, t, n);
294
+ }, F.shouldComponentUpdate = i;
295
+ }
296
+ return r.__N || r.__;
297
+ }
298
+ function R(e, t) {
299
+ var n = Ce(fe++, 3);
300
+ !I.__s && je(n.__H, t) && (n.__ = e, n.u = t, F.__H.__h.push(n));
301
+ }
302
+ function z(e) {
303
+ return he = 5, Te(function() {
304
+ return { current: e };
305
+ }, []);
306
+ }
307
+ function Te(e, t) {
308
+ var n = Ce(fe++, 7);
309
+ return je(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
310
+ }
311
+ function B(e, t) {
312
+ return he = 8, Te(function() {
313
+ return e;
314
+ }, t);
315
+ }
316
+ function Ee() {
317
+ for (var e; e = ge.shift();) {
318
+ var t = e.__H;
319
+ if (e.__P && t) try {
320
+ t.__h.some(ke), t.__h.some(Ae), t.__h = [];
321
+ } catch (n) {
322
+ t.__h = [], I.__e(n, e.__v);
323
+ }
324
+ }
325
+ }
326
+ I.__b = function(e) {
327
+ F = null, _e && _e(e);
328
+ }, I.__ = function(e, t) {
329
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Se && Se(e, t);
330
+ }, I.__r = function(e) {
331
+ ve && ve(e), fe = 0;
332
+ var t = (F = e.__c).__H;
333
+ t && (pe === F ? (t.__h = [], F.__h = [], t.__.some(function(e) {
334
+ e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
335
+ })) : (t.__h.some(ke), t.__h.some(Ae), t.__h = [], fe = 0)), pe = F;
336
+ }, I.diffed = function(e) {
337
+ ye && ye(e);
338
+ var t = e.__c;
339
+ t && t.__H && (t.__H.__h.length && (ge.push(t) !== 1 && me === I.requestAnimationFrame || ((me = I.requestAnimationFrame) || Oe)(Ee)), t.__H.__.some(function(e) {
340
+ e.u && (e.__H = e.u), e.u = void 0;
341
+ })), pe = F = null;
342
+ }, I.__c = function(e, t) {
343
+ t.some(function(e) {
344
+ try {
345
+ e.__h.some(ke), e.__h = e.__h.filter(function(e) {
346
+ return !e.__ || Ae(e);
347
+ });
348
+ } catch (n) {
349
+ t.some(function(e) {
350
+ e.__h &&= [];
351
+ }), t = [], I.__e(n, e.__v);
352
+ }
353
+ }), be && be(e, t);
354
+ }, I.unmount = function(e) {
355
+ xe && xe(e);
356
+ var t, n = e.__c;
357
+ n && n.__H && (n.__H.__.some(function(e) {
358
+ try {
359
+ ke(e);
360
+ } catch (e) {
361
+ t = e;
362
+ }
363
+ }), n.__H = void 0, t && I.__e(t, n.__v));
364
+ };
365
+ var De = typeof requestAnimationFrame == "function";
366
+ function Oe(e) {
367
+ var t, n = function() {
368
+ clearTimeout(r), De && cancelAnimationFrame(t), setTimeout(e);
369
+ }, r = setTimeout(n, 35);
370
+ De && (t = requestAnimationFrame(n));
371
+ }
372
+ function ke(e) {
373
+ var t = F, n = e.__c;
374
+ typeof n == "function" && (e.__c = void 0, n()), F = t;
375
+ }
376
+ function Ae(e) {
377
+ var t = F;
378
+ e.__c = e.__(), F = t;
379
+ }
380
+ function je(e, t) {
381
+ return !e || e.length !== t.length || t.some(function(t, n) {
382
+ return t !== e[n];
383
+ });
384
+ }
385
+ function Me(e, t) {
386
+ return typeof t == "function" ? t(e) : t;
387
+ }
388
+ for (var Ne = "1.37.0", V = [], H = [], Pe = Uint8Array, Fe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ie = 0, Le = Fe.length; Ie < Le; ++Ie) V[Ie] = Fe[Ie], H[Fe.charCodeAt(Ie)] = Ie;
389
+ H[45] = 62, H[95] = 63;
390
+ function Re(e) {
391
+ var t = e.length;
392
+ if (t % 4 > 0) throw Error("Invalid string. Length must be a multiple of 4");
393
+ var n = e.indexOf("=");
394
+ n === -1 && (n = t);
395
+ var r = n === t ? 0 : 4 - n % 4;
396
+ return [n, r];
397
+ }
398
+ function ze(e, t, n) {
399
+ return (t + n) * 3 / 4 - n;
400
+ }
401
+ function Be(e) {
402
+ var t, n = Re(e), r = n[0], i = n[1], a = new Pe(ze(e, r, i)), o = 0, s = i > 0 ? r - 4 : r, c;
403
+ for (c = 0; c < s; c += 4) t = H[e.charCodeAt(c)] << 18 | H[e.charCodeAt(c + 1)] << 12 | H[e.charCodeAt(c + 2)] << 6 | H[e.charCodeAt(c + 3)], a[o++] = t >> 16 & 255, a[o++] = t >> 8 & 255, a[o++] = t & 255;
404
+ return i === 2 && (t = H[e.charCodeAt(c)] << 2 | H[e.charCodeAt(c + 1)] >> 4, a[o++] = t & 255), i === 1 && (t = H[e.charCodeAt(c)] << 10 | H[e.charCodeAt(c + 1)] << 4 | H[e.charCodeAt(c + 2)] >> 2, a[o++] = t >> 8 & 255, a[o++] = t & 255), a;
405
+ }
406
+ function Ve(e) {
407
+ return V[e >> 18 & 63] + V[e >> 12 & 63] + V[e >> 6 & 63] + V[e & 63];
408
+ }
409
+ function He(e, t, n) {
410
+ for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (e[a + 2] & 255), i.push(Ve(r));
411
+ return i.join("");
412
+ }
413
+ function Ue(e) {
414
+ for (var t, n = e.length, r = n % 3, i = [], a = 16383, o = 0, s = n - r; o < s; o += a) i.push(He(e, o, o + a > s ? s : o + a));
415
+ return r === 1 ? (t = e[n - 1], i.push(V[t >> 2] + V[t << 4 & 63] + "==")) : r === 2 && (t = (e[n - 2] << 8) + e[n - 1], i.push(V[t >> 10] + V[t >> 4 & 63] + V[t << 2 & 63] + "=")), i.join("");
416
+ }
417
+ //#endregion
418
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/common/index.js
419
+ function U(e) {
420
+ if (e === void 0) return {};
421
+ if (!Ge(e)) throw Error(`The arguments to a Convex function must be an object. Received: ${e}`);
422
+ return e;
423
+ }
424
+ function We(e) {
425
+ if (e === void 0) throw Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");
426
+ if (typeof e != "string") throw Error(`Invalid deployment address: found ${e}".`);
427
+ if (!(e.startsWith("http:") || e.startsWith("https:"))) throw Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${e}".`);
428
+ try {
429
+ new URL(e);
430
+ } catch {
431
+ throw Error(`Invalid deployment address: "${e}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
432
+ }
433
+ if (e.endsWith(".convex.site")) throw Error(`Invalid deployment address: "${e}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
434
+ }
435
+ function Ge(e) {
436
+ let t = typeof e == "object", n = Object.getPrototypeOf(e), r = n === null || n === Object.prototype || n?.constructor?.name === "Object";
437
+ return t && r;
438
+ }
439
+ //#endregion
440
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/values/value.js
441
+ var Ke = !0, qe = BigInt("-9223372036854775808"), Je = BigInt("9223372036854775807"), Ye = BigInt("0"), Xe = BigInt("8"), Ze = BigInt("256");
442
+ function Qe(e) {
443
+ return Number.isNaN(e) || !Number.isFinite(e) || Object.is(e, -0);
444
+ }
445
+ function $e(e) {
446
+ e < Ye && (e -= qe + qe);
447
+ let t = e.toString(16);
448
+ t.length % 2 == 1 && (t = "0" + t);
449
+ let n = new Uint8Array(/* @__PURE__ */ new ArrayBuffer(8)), r = 0;
450
+ for (let i of t.match(/.{2}/g).reverse()) n.set([parseInt(i, 16)], r++), e >>= Xe;
451
+ return Ue(n);
452
+ }
453
+ function et(e) {
454
+ let t = Be(e);
455
+ if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);
456
+ let n = Ye, r = Ye;
457
+ for (let e of t) n += BigInt(e) * Ze ** r, r++;
458
+ return n > Je && (n += qe + qe), n;
459
+ }
460
+ function tt(e) {
461
+ if (e < qe || Je < e) throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);
462
+ let t = /* @__PURE__ */ new ArrayBuffer(8);
463
+ return new DataView(t).setBigInt64(0, e, !0), Ue(new Uint8Array(t));
464
+ }
465
+ function nt(e) {
466
+ let t = Be(e);
467
+ if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);
468
+ return new DataView(t.buffer).getBigInt64(0, !0);
469
+ }
470
+ var rt = DataView.prototype.setBigInt64 ? tt : $e, it = DataView.prototype.getBigInt64 ? nt : et, at = 1024;
471
+ function ot(e) {
472
+ if (e.length > at) throw Error(`Field name ${e} exceeds maximum field name length ${at}.`);
473
+ if (e.startsWith("$")) throw Error(`Field name ${e} starts with a '$', which is reserved.`);
474
+ for (let t = 0; t < e.length; t += 1) {
475
+ let n = e.charCodeAt(t);
476
+ if (n < 32 || n >= 127) throw Error(`Field name ${e} has invalid character '${e[t]}': Field names can only contain non-control ASCII characters`);
477
+ }
478
+ }
479
+ function st(e) {
480
+ if (e === null || typeof e == "boolean" || typeof e == "number" || typeof e == "string") return e;
481
+ if (Array.isArray(e)) return e.map((e) => st(e));
482
+ if (typeof e != "object") throw Error(`Unexpected type of ${e}`);
483
+ let t = Object.entries(e);
484
+ if (t.length === 1) {
485
+ let n = t[0][0];
486
+ if (n === "$bytes") {
487
+ if (typeof e.$bytes != "string") throw Error(`Malformed $bytes field on ${e}`);
488
+ return Be(e.$bytes).buffer;
489
+ }
490
+ if (n === "$integer") {
491
+ if (typeof e.$integer != "string") throw Error(`Malformed $integer field on ${e}`);
492
+ return it(e.$integer);
493
+ }
494
+ if (n === "$float") {
495
+ if (typeof e.$float != "string") throw Error(`Malformed $float field on ${e}`);
496
+ let t = Be(e.$float);
497
+ if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $float`);
498
+ let n = new DataView(t.buffer).getFloat64(0, Ke);
499
+ if (!Qe(n)) throw Error(`Float ${n} should be encoded as a number`);
500
+ return n;
501
+ }
502
+ if (n === "$set") throw Error("Received a Set which is no longer supported as a Convex type.");
503
+ if (n === "$map") throw Error("Received a Map which is no longer supported as a Convex type.");
504
+ }
505
+ let n = {};
506
+ for (let [t, r] of Object.entries(e)) ot(t), n[t] = st(r);
507
+ return n;
508
+ }
509
+ var ct = 16384;
510
+ function lt(e) {
511
+ let t = JSON.stringify(e, (e, t) => t === void 0 ? "undefined" : typeof t == "bigint" ? `${t.toString()}n` : t);
512
+ if (t.length > ct) {
513
+ let e = ct - 14, n = t.codePointAt(e - 1);
514
+ return n !== void 0 && n > 65535 && --e, t.substring(0, e) + "[...truncated]";
515
+ }
516
+ return t;
517
+ }
518
+ function ut(e, t, n, r) {
519
+ if (e === void 0) {
520
+ let e = n && ` (present at path ${n} in original object ${lt(t)})`;
521
+ throw Error(`undefined is not a valid Convex value${e}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`);
522
+ }
523
+ if (e === null) return e;
524
+ if (typeof e == "bigint") {
525
+ if (e < qe || Je < e) throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);
526
+ return { $integer: rt(e) };
527
+ }
528
+ if (typeof e == "number") if (Qe(e)) {
529
+ let t = /* @__PURE__ */ new ArrayBuffer(8);
530
+ return new DataView(t).setFloat64(0, e, Ke), { $float: Ue(new Uint8Array(t)) };
531
+ } else return e;
532
+ if (typeof e == "boolean" || typeof e == "string") return e;
533
+ if (e instanceof ArrayBuffer) return { $bytes: Ue(new Uint8Array(e)) };
534
+ if (Array.isArray(e)) return e.map((e, r) => ut(e, t, n + `[${r}]`, !1));
535
+ if (e instanceof Set) throw Error(dt(n, "Set", [...e], t));
536
+ if (e instanceof Map) throw Error(dt(n, "Map", [...e], t));
537
+ if (!Ge(e)) {
538
+ let r = e?.constructor?.name, i = r ? `${r} ` : "";
539
+ throw Error(dt(n, i, e, t));
540
+ }
541
+ let i = {}, a = Object.entries(e);
542
+ a.sort(([e, t], [n, r]) => e === n ? 0 : e < n ? -1 : 1);
543
+ for (let [e, o] of a) o === void 0 ? r && (ot(e), i[e] = ft(o, t, n + `.${e}`)) : (ot(e), i[e] = ut(o, t, n + `.${e}`, !1));
544
+ return i;
545
+ }
546
+ function dt(e, t, n, r) {
547
+ return e ? `${t}${lt(n)} is not a supported Convex type (present at path ${e} in original object ${lt(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.` : `${t}${lt(n)} is not a supported Convex type.`;
548
+ }
549
+ function ft(e, t, n) {
550
+ if (e === void 0) return { $undefined: null };
551
+ if (t === void 0) throw Error(`Programming error. Current value is ${lt(e)} but original value is undefined`);
552
+ return ut(e, t, n, !1);
553
+ }
554
+ function pt(e) {
555
+ return ut(e, e, "", !1);
556
+ }
557
+ //#endregion
558
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/values/errors.js
559
+ var mt = Object.defineProperty, ht = (e, t, n) => t in e ? mt(e, t, {
560
+ enumerable: !0,
561
+ configurable: !0,
562
+ writable: !0,
563
+ value: n
564
+ }) : e[t] = n, gt = (e, t, n) => ht(e, typeof t == "symbol" ? t : t + "", n), _t, vt, yt = Symbol.for("ConvexError"), bt = class extends (vt = Error, _t = yt, vt) {
565
+ constructor(e) {
566
+ super(typeof e == "string" ? e : lt(e)), gt(this, "name", "ConvexError"), gt(this, "data"), gt(this, _t, !0), this.data = e;
567
+ }
568
+ }, xt = Object.defineProperty, St = (e, t, n) => t in e ? xt(e, t, {
569
+ enumerable: !0,
570
+ configurable: !0,
571
+ writable: !0,
572
+ value: n
573
+ }) : e[t] = n, Ct = (e, t, n) => St(e, typeof t == "symbol" ? t : t + "", n), wt = "color:rgb(0, 145, 255)";
574
+ function Tt(e) {
575
+ switch (e) {
576
+ case "query": return "Q";
577
+ case "mutation": return "M";
578
+ case "action": return "A";
579
+ case "any": return "?";
580
+ }
581
+ }
582
+ var Et = class {
583
+ constructor(e) {
584
+ Ct(this, "_onLogLineFuncs"), Ct(this, "_verbose"), this._onLogLineFuncs = {}, this._verbose = e.verbose;
585
+ }
586
+ addLogLineListener(e) {
587
+ let t = Math.random().toString(36).substring(2, 15);
588
+ for (let e = 0; e < 10 && this._onLogLineFuncs[t] !== void 0; e++) t = Math.random().toString(36).substring(2, 15);
589
+ return this._onLogLineFuncs[t] = e, () => {
590
+ delete this._onLogLineFuncs[t];
591
+ };
592
+ }
593
+ logVerbose(...e) {
594
+ if (this._verbose) for (let t of Object.values(this._onLogLineFuncs)) t("debug", `${(/* @__PURE__ */ new Date()).toISOString()}`, ...e);
595
+ }
596
+ log(...e) {
597
+ for (let t of Object.values(this._onLogLineFuncs)) t("info", ...e);
598
+ }
599
+ warn(...e) {
600
+ for (let t of Object.values(this._onLogLineFuncs)) t("warn", ...e);
601
+ }
602
+ error(...e) {
603
+ for (let t of Object.values(this._onLogLineFuncs)) t("error", ...e);
604
+ }
605
+ };
606
+ function Dt(e) {
607
+ let t = new Et(e);
608
+ return t.addLogLineListener((e, ...t) => {
609
+ switch (e) {
610
+ case "debug":
611
+ console.debug(...t);
612
+ break;
613
+ case "info":
614
+ console.log(...t);
615
+ break;
616
+ case "warn":
617
+ console.warn(...t);
618
+ break;
619
+ case "error":
620
+ console.error(...t);
621
+ break;
622
+ default: console.log(...t);
623
+ }
624
+ }), t;
625
+ }
626
+ function Ot(e) {
627
+ return new Et(e);
628
+ }
629
+ function kt(e, t, n, r, i) {
630
+ let a = Tt(n);
631
+ if (typeof i == "object" && (i = `ConvexError ${JSON.stringify(i.errorData, null, 2)}`), t === "info") {
632
+ let t = i.match(/^\[.*?\] /);
633
+ if (t === null) {
634
+ e.error(`[CONVEX ${a}(${r})] Could not parse console.log`);
635
+ return;
636
+ }
637
+ let n = i.slice(1, t[0].length - 2), o = i.slice(t[0].length);
638
+ e.log(`%c[CONVEX ${a}(${r})] [${n}]`, wt, o);
639
+ } else e.error(`[CONVEX ${a}(${r})] ${i}`);
640
+ }
641
+ function At(e, t) {
642
+ let n = `[CONVEX FATAL ERROR] ${t}`;
643
+ return e.error(n), Error(n);
644
+ }
645
+ function jt(e, t, n) {
646
+ return `[CONVEX ${Tt(e)}(${t})] ${n.errorMessage}
647
+ Called by client`;
648
+ }
649
+ function Mt(e, t) {
650
+ return t.data = e.errorData, t;
651
+ }
652
+ //#endregion
653
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/udf_path_utils.js
654
+ function Nt(e) {
655
+ let t = e.split(":"), n, r;
656
+ return t.length === 1 ? (n = t[0], r = "default") : (n = t.slice(0, t.length - 1).join(":"), r = t[t.length - 1]), n.endsWith(".js") && (n = n.slice(0, -3)), `${n}:${r}`;
657
+ }
658
+ function Pt(e, t) {
659
+ return JSON.stringify({
660
+ udfPath: Nt(e),
661
+ args: pt(t)
662
+ });
663
+ }
664
+ function Ft(e, t, n) {
665
+ let { initialNumItems: r, id: i } = n;
666
+ return JSON.stringify({
667
+ type: "paginated",
668
+ udfPath: Nt(e),
669
+ args: pt(t),
670
+ options: pt({
671
+ initialNumItems: r,
672
+ id: i
673
+ })
674
+ });
675
+ }
676
+ function It(e) {
677
+ return JSON.parse(e).type === "paginated";
678
+ }
679
+ //#endregion
680
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/local_state.js
681
+ var Lt = Object.defineProperty, Rt = (e, t, n) => t in e ? Lt(e, t, {
682
+ enumerable: !0,
683
+ configurable: !0,
684
+ writable: !0,
685
+ value: n
686
+ }) : e[t] = n, W = (e, t, n) => Rt(e, typeof t == "symbol" ? t : t + "", n), zt = class {
687
+ constructor() {
688
+ W(this, "nextQueryId"), W(this, "querySetVersion"), W(this, "querySet"), W(this, "queryIdToToken"), W(this, "identityVersion"), W(this, "auth"), W(this, "outstandingQueriesOlderThanRestart"), W(this, "outstandingAuthOlderThanRestart"), W(this, "paused"), W(this, "pendingQuerySetModifications"), this.nextQueryId = 0, this.querySetVersion = 0, this.identityVersion = 0, this.querySet = /* @__PURE__ */ new Map(), this.queryIdToToken = /* @__PURE__ */ new Map(), this.outstandingQueriesOlderThanRestart = /* @__PURE__ */ new Set(), this.outstandingAuthOlderThanRestart = !1, this.paused = !1, this.pendingQuerySetModifications = /* @__PURE__ */ new Map();
689
+ }
690
+ hasSyncedPastLastReconnect() {
691
+ return this.outstandingQueriesOlderThanRestart.size === 0 && !this.outstandingAuthOlderThanRestart;
692
+ }
693
+ markAuthCompletion() {
694
+ this.outstandingAuthOlderThanRestart = !1;
695
+ }
696
+ subscribe(e, t, n, r) {
697
+ let i = Nt(e), a = Pt(i, t), o = this.querySet.get(a);
698
+ if (o !== void 0) return o.numSubscribers += 1, {
699
+ queryToken: a,
700
+ modification: null,
701
+ unsubscribe: () => this.removeSubscriber(a)
702
+ };
703
+ {
704
+ let e = this.nextQueryId++, o = {
705
+ id: e,
706
+ canonicalizedUdfPath: i,
707
+ args: t,
708
+ numSubscribers: 1,
709
+ journal: n,
710
+ componentPath: r
711
+ };
712
+ this.querySet.set(a, o), this.queryIdToToken.set(e, a);
713
+ let s = this.querySetVersion, c = this.querySetVersion + 1, l = {
714
+ type: "Add",
715
+ queryId: e,
716
+ udfPath: i,
717
+ args: [pt(t)],
718
+ journal: n,
719
+ componentPath: r
720
+ };
721
+ return this.paused ? this.pendingQuerySetModifications.set(e, l) : this.querySetVersion = c, {
722
+ queryToken: a,
723
+ modification: {
724
+ type: "ModifyQuerySet",
725
+ baseVersion: s,
726
+ newVersion: c,
727
+ modifications: [l]
728
+ },
729
+ unsubscribe: () => this.removeSubscriber(a)
730
+ };
731
+ }
732
+ }
733
+ transition(e) {
734
+ for (let t of e.modifications) switch (t.type) {
735
+ case "QueryUpdated":
736
+ case "QueryFailed": {
737
+ this.outstandingQueriesOlderThanRestart.delete(t.queryId);
738
+ let e = t.journal;
739
+ if (e !== void 0) {
740
+ let n = this.queryIdToToken.get(t.queryId);
741
+ n !== void 0 && (this.querySet.get(n).journal = e);
742
+ }
743
+ break;
744
+ }
745
+ case "QueryRemoved":
746
+ this.outstandingQueriesOlderThanRestart.delete(t.queryId);
747
+ break;
748
+ default: throw Error(`Invalid modification ${t.type}`);
749
+ }
750
+ }
751
+ queryId(e, t) {
752
+ let n = Pt(Nt(e), t), r = this.querySet.get(n);
753
+ return r === void 0 ? null : r.id;
754
+ }
755
+ isCurrentOrNewerAuthVersion(e) {
756
+ return e >= this.identityVersion;
757
+ }
758
+ getAuth() {
759
+ return this.auth;
760
+ }
761
+ setAuth(e) {
762
+ this.auth = {
763
+ tokenType: "User",
764
+ value: e
765
+ };
766
+ let t = this.identityVersion;
767
+ return this.paused || (this.identityVersion = t + 1), {
768
+ type: "Authenticate",
769
+ baseVersion: t,
770
+ ...this.auth
771
+ };
772
+ }
773
+ setAdminAuth(e, t) {
774
+ let n = {
775
+ tokenType: "Admin",
776
+ value: e,
777
+ impersonating: t
778
+ };
779
+ this.auth = n;
780
+ let r = this.identityVersion;
781
+ return this.paused || (this.identityVersion = r + 1), {
782
+ type: "Authenticate",
783
+ baseVersion: r,
784
+ ...n
785
+ };
786
+ }
787
+ clearAuth() {
788
+ this.auth = void 0, this.markAuthCompletion();
789
+ let e = this.identityVersion;
790
+ return this.paused || (this.identityVersion = e + 1), {
791
+ type: "Authenticate",
792
+ tokenType: "None",
793
+ baseVersion: e
794
+ };
795
+ }
796
+ hasAuth() {
797
+ return !!this.auth;
798
+ }
799
+ isNewAuth(e) {
800
+ return this.auth?.value !== e;
801
+ }
802
+ queryPath(e) {
803
+ let t = this.queryIdToToken.get(e);
804
+ return t ? this.querySet.get(t).canonicalizedUdfPath : null;
805
+ }
806
+ queryArgs(e) {
807
+ let t = this.queryIdToToken.get(e);
808
+ return t ? this.querySet.get(t).args : null;
809
+ }
810
+ queryToken(e) {
811
+ return this.queryIdToToken.get(e) ?? null;
812
+ }
813
+ queryJournal(e) {
814
+ return this.querySet.get(e)?.journal;
815
+ }
816
+ restart() {
817
+ this.unpause(), this.outstandingQueriesOlderThanRestart.clear();
818
+ let e = [];
819
+ for (let t of this.querySet.values()) {
820
+ let n = {
821
+ type: "Add",
822
+ queryId: t.id,
823
+ udfPath: t.canonicalizedUdfPath,
824
+ args: [pt(t.args)],
825
+ journal: t.journal,
826
+ componentPath: t.componentPath
827
+ };
828
+ e.push(n), this.outstandingQueriesOlderThanRestart.add(t.id);
829
+ }
830
+ this.querySetVersion = 1;
831
+ let t = {
832
+ type: "ModifyQuerySet",
833
+ baseVersion: 0,
834
+ newVersion: 1,
835
+ modifications: e
836
+ };
837
+ if (!this.auth) return this.identityVersion = 0, [t, void 0];
838
+ this.outstandingAuthOlderThanRestart = !0;
839
+ let n = {
840
+ type: "Authenticate",
841
+ baseVersion: 0,
842
+ ...this.auth
843
+ };
844
+ return this.identityVersion = 1, [t, n];
845
+ }
846
+ pause() {
847
+ this.paused = !0;
848
+ }
849
+ resume() {
850
+ let e = this.pendingQuerySetModifications.size > 0 ? {
851
+ type: "ModifyQuerySet",
852
+ baseVersion: this.querySetVersion,
853
+ newVersion: ++this.querySetVersion,
854
+ modifications: Array.from(this.pendingQuerySetModifications.values())
855
+ } : void 0, t = this.auth === void 0 ? void 0 : {
856
+ type: "Authenticate",
857
+ baseVersion: this.identityVersion++,
858
+ ...this.auth
859
+ };
860
+ return this.unpause(), [e, t];
861
+ }
862
+ unpause() {
863
+ this.paused = !1, this.pendingQuerySetModifications.clear();
864
+ }
865
+ removeSubscriber(e) {
866
+ let t = this.querySet.get(e);
867
+ if (t.numSubscribers > 1) return --t.numSubscribers, null;
868
+ {
869
+ this.querySet.delete(e), this.queryIdToToken.delete(t.id), this.outstandingQueriesOlderThanRestart.delete(t.id);
870
+ let n = this.querySetVersion, r = this.querySetVersion + 1, i = {
871
+ type: "Remove",
872
+ queryId: t.id
873
+ };
874
+ return this.paused ? this.pendingQuerySetModifications.has(t.id) ? this.pendingQuerySetModifications.delete(t.id) : this.pendingQuerySetModifications.set(t.id, i) : this.querySetVersion = r, {
875
+ type: "ModifyQuerySet",
876
+ baseVersion: n,
877
+ newVersion: r,
878
+ modifications: [i]
879
+ };
880
+ }
881
+ }
882
+ }, Bt = Object.defineProperty, Vt = (e, t, n) => t in e ? Bt(e, t, {
883
+ enumerable: !0,
884
+ configurable: !0,
885
+ writable: !0,
886
+ value: n
887
+ }) : e[t] = n, Ht = (e, t, n) => Vt(e, typeof t == "symbol" ? t : t + "", n), Ut = class {
888
+ constructor(e, t) {
889
+ this.logger = e, this.markConnectionStateDirty = t, Ht(this, "inflightRequests"), Ht(this, "requestsOlderThanRestart"), Ht(this, "inflightMutationsCount", 0), Ht(this, "inflightActionsCount", 0), this.inflightRequests = /* @__PURE__ */ new Map(), this.requestsOlderThanRestart = /* @__PURE__ */ new Set();
890
+ }
891
+ request(e, t) {
892
+ let n = new Promise((n) => {
893
+ let r = t ? "Requested" : "NotSent";
894
+ this.inflightRequests.set(e.requestId, {
895
+ message: e,
896
+ status: {
897
+ status: r,
898
+ requestedAt: /* @__PURE__ */ new Date(),
899
+ onResult: n
900
+ }
901
+ }), e.type === "Mutation" ? this.inflightMutationsCount++ : e.type === "Action" && this.inflightActionsCount++;
902
+ });
903
+ return this.markConnectionStateDirty(), n;
904
+ }
905
+ onResponse(e) {
906
+ let t = this.inflightRequests.get(e.requestId);
907
+ if (t === void 0 || t.status.status === "Completed") return null;
908
+ let n = t.message.type === "Mutation" ? "mutation" : "action", r = t.message.udfPath;
909
+ for (let t of e.logLines) kt(this.logger, "info", n, r, t);
910
+ let i = t.status, a, o;
911
+ if (e.success) a = {
912
+ success: !0,
913
+ logLines: e.logLines,
914
+ value: st(e.result)
915
+ }, o = () => i.onResult(a);
916
+ else {
917
+ let t = e.result, { errorData: s } = e;
918
+ kt(this.logger, "error", n, r, t), a = {
919
+ success: !1,
920
+ errorMessage: t,
921
+ errorData: s === void 0 ? void 0 : st(s),
922
+ logLines: e.logLines
923
+ }, o = () => i.onResult(a);
924
+ }
925
+ return e.type === "ActionResponse" || !e.success ? (o(), this.inflightRequests.delete(e.requestId), this.requestsOlderThanRestart.delete(e.requestId), t.message.type === "Action" ? this.inflightActionsCount-- : t.message.type === "Mutation" && this.inflightMutationsCount--, this.markConnectionStateDirty(), {
926
+ requestId: e.requestId,
927
+ result: a
928
+ }) : (t.status = {
929
+ status: "Completed",
930
+ result: a,
931
+ ts: e.ts,
932
+ onResolve: o
933
+ }, null);
934
+ }
935
+ removeCompleted(e) {
936
+ let t = /* @__PURE__ */ new Map();
937
+ for (let [n, r] of this.inflightRequests.entries()) {
938
+ let i = r.status;
939
+ i.status === "Completed" && i.ts.lessThanOrEqual(e) && (i.onResolve(), t.set(n, i.result), r.message.type === "Mutation" ? this.inflightMutationsCount-- : r.message.type === "Action" && this.inflightActionsCount--, this.inflightRequests.delete(n), this.requestsOlderThanRestart.delete(n));
940
+ }
941
+ return t.size > 0 && this.markConnectionStateDirty(), t;
942
+ }
943
+ restart() {
944
+ this.requestsOlderThanRestart = new Set(this.inflightRequests.keys());
945
+ let e = [];
946
+ for (let [t, n] of this.inflightRequests) {
947
+ if (n.status.status === "NotSent") {
948
+ n.status.status = "Requested", e.push(n.message);
949
+ continue;
950
+ }
951
+ if (n.message.type === "Mutation") e.push(n.message);
952
+ else if (n.message.type === "Action") {
953
+ if (this.inflightRequests.delete(t), this.requestsOlderThanRestart.delete(t), this.inflightActionsCount--, n.status.status === "Completed") throw Error("Action should never be in 'Completed' state");
954
+ n.status.onResult({
955
+ success: !1,
956
+ errorMessage: "Connection lost while action was in flight",
957
+ logLines: []
958
+ });
959
+ }
960
+ }
961
+ return this.markConnectionStateDirty(), e;
962
+ }
963
+ resume() {
964
+ let e = [];
965
+ for (let [, t] of this.inflightRequests) if (t.status.status === "NotSent") {
966
+ t.status.status = "Requested", e.push(t.message);
967
+ continue;
968
+ }
969
+ return e;
970
+ }
971
+ hasIncompleteRequests() {
972
+ for (let e of this.inflightRequests.values()) if (e.status.status === "Requested") return !0;
973
+ return !1;
974
+ }
975
+ hasInflightRequests() {
976
+ return this.inflightRequests.size > 0;
977
+ }
978
+ hasSyncedPastLastReconnect() {
979
+ return this.requestsOlderThanRestart.size === 0;
980
+ }
981
+ timeOfOldestInflightRequest() {
982
+ if (this.inflightRequests.size === 0) return null;
983
+ let e = Date.now();
984
+ for (let t of this.inflightRequests.values()) t.status.status !== "Completed" && t.status.requestedAt.getTime() < e && (e = t.status.requestedAt.getTime());
985
+ return new Date(e);
986
+ }
987
+ inflightMutations() {
988
+ return this.inflightMutationsCount;
989
+ }
990
+ inflightActions() {
991
+ return this.inflightActionsCount;
992
+ }
993
+ }, Wt = Symbol.for("functionName"), Gt = Symbol.for("toReferencePath");
994
+ function Kt(e) {
995
+ return e[Gt] ?? null;
996
+ }
997
+ function qt(e) {
998
+ return e.startsWith("function://");
999
+ }
1000
+ function Jt(e) {
1001
+ let t;
1002
+ if (typeof e == "string") t = qt(e) ? { functionHandle: e } : { name: e };
1003
+ else if (e[Wt]) t = { name: e[Wt] };
1004
+ else {
1005
+ let n = Kt(e);
1006
+ if (!n) throw Error(`${e} is not a functionReference`);
1007
+ t = { reference: n };
1008
+ }
1009
+ return t;
1010
+ }
1011
+ //#endregion
1012
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/server/api.js
1013
+ function G(e) {
1014
+ let t = Jt(e);
1015
+ if (t.name === void 0) throw t.functionHandle === void 0 ? t.reference === void 0 ? Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(t)}`) : Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${t.reference}`) : Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${t.functionHandle}`);
1016
+ if (typeof e == "string") return e;
1017
+ let n = e[Wt];
1018
+ if (!n) throw Error(`${e} is not a functionReference`);
1019
+ return n;
1020
+ }
1021
+ function Yt(e) {
1022
+ return { [Wt]: e };
1023
+ }
1024
+ function Xt(e = []) {
1025
+ return new Proxy({}, { get(t, n) {
1026
+ if (typeof n == "string") return Xt([...e, n]);
1027
+ if (n === Wt) {
1028
+ if (e.length < 2) {
1029
+ let t = ["api", ...e].join(".");
1030
+ throw Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${t}\``);
1031
+ }
1032
+ let t = e.slice(0, -1).join("/"), n = e[e.length - 1];
1033
+ return n === "default" ? t : t + ":" + n;
1034
+ } else if (n === Symbol.toStringTag) return "FunctionReference";
1035
+ else return;
1036
+ } });
1037
+ }
1038
+ Xt();
1039
+ //#endregion
1040
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/optimistic_updates_impl.js
1041
+ var Zt = Object.defineProperty, Qt = (e, t, n) => t in e ? Zt(e, t, {
1042
+ enumerable: !0,
1043
+ configurable: !0,
1044
+ writable: !0,
1045
+ value: n
1046
+ }) : e[t] = n, $t = (e, t, n) => Qt(e, typeof t == "symbol" ? t : t + "", n), en = class e {
1047
+ constructor(e) {
1048
+ $t(this, "queryResults"), $t(this, "modifiedQueries"), this.queryResults = e, this.modifiedQueries = [];
1049
+ }
1050
+ getQuery(t, ...n) {
1051
+ let r = U(n[0]), i = G(t), a = this.queryResults.get(Pt(i, r));
1052
+ if (a !== void 0) return e.queryValue(a.result);
1053
+ }
1054
+ getAllQueries(t) {
1055
+ let n = [], r = G(t);
1056
+ for (let t of this.queryResults.values()) t.udfPath === Nt(r) && n.push({
1057
+ args: t.args,
1058
+ value: e.queryValue(t.result)
1059
+ });
1060
+ return n;
1061
+ }
1062
+ setQuery(e, t, n) {
1063
+ let r = U(t), i = G(e), a = Pt(i, r), o;
1064
+ o = n === void 0 ? void 0 : {
1065
+ success: !0,
1066
+ value: n,
1067
+ logLines: []
1068
+ };
1069
+ let s = {
1070
+ udfPath: i,
1071
+ args: r,
1072
+ result: o
1073
+ };
1074
+ this.queryResults.set(a, s), this.modifiedQueries.push(a);
1075
+ }
1076
+ static queryValue(e) {
1077
+ if (e !== void 0 && e.success) return e.value;
1078
+ }
1079
+ }, tn = class {
1080
+ constructor() {
1081
+ $t(this, "queryResults"), $t(this, "optimisticUpdates"), this.queryResults = /* @__PURE__ */ new Map(), this.optimisticUpdates = [];
1082
+ }
1083
+ ingestQueryResultsFromServer(e, t) {
1084
+ this.optimisticUpdates = this.optimisticUpdates.filter((e) => !t.has(e.mutationId));
1085
+ let n = this.queryResults;
1086
+ this.queryResults = new Map(e);
1087
+ let r = new en(this.queryResults);
1088
+ for (let e of this.optimisticUpdates) e.update(r);
1089
+ let i = [];
1090
+ for (let [e, t] of this.queryResults) {
1091
+ let r = n.get(e);
1092
+ (r === void 0 || r.result !== t.result) && i.push(e);
1093
+ }
1094
+ return i;
1095
+ }
1096
+ applyOptimisticUpdate(e, t) {
1097
+ this.optimisticUpdates.push({
1098
+ update: e,
1099
+ mutationId: t
1100
+ });
1101
+ let n = new en(this.queryResults);
1102
+ return e(n), n.modifiedQueries;
1103
+ }
1104
+ rawQueryResult(e) {
1105
+ let t = this.queryResults.get(e);
1106
+ if (t !== void 0) return t.result;
1107
+ }
1108
+ queryResult(e) {
1109
+ let t = this.queryResults.get(e);
1110
+ if (t === void 0) return;
1111
+ let n = t.result;
1112
+ if (n !== void 0) {
1113
+ if (n.success) return n.value;
1114
+ throw n.errorData === void 0 ? Error(jt("query", t.udfPath, n)) : Mt(n, new bt(jt("query", t.udfPath, n)));
1115
+ }
1116
+ }
1117
+ hasQueryResult(e) {
1118
+ return this.queryResults.get(e) !== void 0;
1119
+ }
1120
+ queryLogs(e) {
1121
+ return this.queryResults.get(e)?.result?.logLines;
1122
+ }
1123
+ }, nn = Object.defineProperty, rn = (e, t, n) => t in e ? nn(e, t, {
1124
+ enumerable: !0,
1125
+ configurable: !0,
1126
+ writable: !0,
1127
+ value: n
1128
+ }) : e[t] = n, an = (e, t, n) => rn(e, typeof t == "symbol" ? t : t + "", n), on = class e {
1129
+ constructor(e, t) {
1130
+ an(this, "low"), an(this, "high"), an(this, "__isUnsignedLong__"), this.low = e | 0, this.high = t | 0, this.__isUnsignedLong__ = !0;
1131
+ }
1132
+ static isLong(e) {
1133
+ return (e && e.__isUnsignedLong__) === !0;
1134
+ }
1135
+ static fromBytesLE(t) {
1136
+ return new e(t[0] | t[1] << 8 | t[2] << 16 | t[3] << 24, t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24);
1137
+ }
1138
+ toBytesLE() {
1139
+ let e = this.high, t = this.low;
1140
+ return [
1141
+ t & 255,
1142
+ t >>> 8 & 255,
1143
+ t >>> 16 & 255,
1144
+ t >>> 24,
1145
+ e & 255,
1146
+ e >>> 8 & 255,
1147
+ e >>> 16 & 255,
1148
+ e >>> 24
1149
+ ];
1150
+ }
1151
+ static fromNumber(t) {
1152
+ return isNaN(t) || t < 0 ? sn : t >= un ? dn : new e(t % ln | 0, t / ln | 0);
1153
+ }
1154
+ toString() {
1155
+ return (BigInt(this.high) * BigInt(ln) + BigInt(this.low)).toString();
1156
+ }
1157
+ equals(t) {
1158
+ return e.isLong(t) || (t = e.fromValue(t)), this.high >>> 31 == 1 && t.high >>> 31 == 1 ? !1 : this.high === t.high && this.low === t.low;
1159
+ }
1160
+ notEquals(e) {
1161
+ return !this.equals(e);
1162
+ }
1163
+ comp(t) {
1164
+ return e.isLong(t) || (t = e.fromValue(t)), this.equals(t) ? 0 : t.high >>> 0 > this.high >>> 0 || t.high === this.high && t.low >>> 0 > this.low >>> 0 ? -1 : 1;
1165
+ }
1166
+ lessThanOrEqual(e) {
1167
+ return this.comp(e) <= 0;
1168
+ }
1169
+ static fromValue(t) {
1170
+ return typeof t == "number" ? e.fromNumber(t) : new e(t.low, t.high);
1171
+ }
1172
+ }, sn = new on(0, 0), cn = 65536, ln = cn * cn, un = ln * ln, dn = new on(-1, -1), fn = Object.defineProperty, pn = (e, t, n) => t in e ? fn(e, t, {
1173
+ enumerable: !0,
1174
+ configurable: !0,
1175
+ writable: !0,
1176
+ value: n
1177
+ }) : e[t] = n, mn = (e, t, n) => pn(e, typeof t == "symbol" ? t : t + "", n), hn = class {
1178
+ constructor(e, t) {
1179
+ mn(this, "version"), mn(this, "remoteQuerySet"), mn(this, "queryPath"), mn(this, "logger"), this.version = {
1180
+ querySet: 0,
1181
+ ts: on.fromNumber(0),
1182
+ identity: 0
1183
+ }, this.remoteQuerySet = /* @__PURE__ */ new Map(), this.queryPath = e, this.logger = t;
1184
+ }
1185
+ transition(e) {
1186
+ let t = e.startVersion;
1187
+ if (this.version.querySet !== t.querySet || this.version.ts.notEquals(t.ts) || this.version.identity !== t.identity) throw Error(`Invalid start version: ${t.ts.toString()}:${t.querySet}:${t.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);
1188
+ for (let t of e.modifications) switch (t.type) {
1189
+ case "QueryUpdated": {
1190
+ let e = this.queryPath(t.queryId);
1191
+ if (e) for (let n of t.logLines) kt(this.logger, "info", "query", e, n);
1192
+ let n = st(t.value ?? null);
1193
+ this.remoteQuerySet.set(t.queryId, {
1194
+ success: !0,
1195
+ value: n,
1196
+ logLines: t.logLines
1197
+ });
1198
+ break;
1199
+ }
1200
+ case "QueryFailed": {
1201
+ let e = this.queryPath(t.queryId);
1202
+ if (e) for (let n of t.logLines) kt(this.logger, "info", "query", e, n);
1203
+ let { errorData: n } = t;
1204
+ this.remoteQuerySet.set(t.queryId, {
1205
+ success: !1,
1206
+ errorMessage: t.errorMessage,
1207
+ errorData: n === void 0 ? void 0 : st(n),
1208
+ logLines: t.logLines
1209
+ });
1210
+ break;
1211
+ }
1212
+ case "QueryRemoved":
1213
+ this.remoteQuerySet.delete(t.queryId);
1214
+ break;
1215
+ default: throw Error(`Invalid modification ${t.type}`);
1216
+ }
1217
+ this.version = e.endVersion;
1218
+ }
1219
+ remoteQueryResults() {
1220
+ return this.remoteQuerySet;
1221
+ }
1222
+ timestamp() {
1223
+ return this.version.ts;
1224
+ }
1225
+ };
1226
+ //#endregion
1227
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/protocol.js
1228
+ function gn(e) {
1229
+ let t = Be(e);
1230
+ return on.fromBytesLE(Array.from(t));
1231
+ }
1232
+ function _n(e) {
1233
+ return Ue(new Uint8Array(e.toBytesLE()));
1234
+ }
1235
+ function vn(e) {
1236
+ switch (e.type) {
1237
+ case "FatalError":
1238
+ case "AuthError":
1239
+ case "ActionResponse":
1240
+ case "TransitionChunk":
1241
+ case "Ping": return { ...e };
1242
+ case "MutationResponse": return e.success ? {
1243
+ ...e,
1244
+ ts: gn(e.ts)
1245
+ } : { ...e };
1246
+ case "Transition": return {
1247
+ ...e,
1248
+ startVersion: {
1249
+ ...e.startVersion,
1250
+ ts: gn(e.startVersion.ts)
1251
+ },
1252
+ endVersion: {
1253
+ ...e.endVersion,
1254
+ ts: gn(e.endVersion.ts)
1255
+ }
1256
+ };
1257
+ default:
1258
+ }
1259
+ }
1260
+ function yn(e) {
1261
+ switch (e.type) {
1262
+ case "Authenticate":
1263
+ case "ModifyQuerySet":
1264
+ case "Mutation":
1265
+ case "Action":
1266
+ case "Event": return { ...e };
1267
+ case "Connect": return e.maxObservedTimestamp === void 0 ? {
1268
+ ...e,
1269
+ maxObservedTimestamp: void 0
1270
+ } : {
1271
+ ...e,
1272
+ maxObservedTimestamp: _n(e.maxObservedTimestamp)
1273
+ };
1274
+ default:
1275
+ }
1276
+ }
1277
+ //#endregion
1278
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/web_socket_manager.js
1279
+ var bn = Object.defineProperty, xn = (e, t, n) => t in e ? bn(e, t, {
1280
+ enumerable: !0,
1281
+ configurable: !0,
1282
+ writable: !0,
1283
+ value: n
1284
+ }) : e[t] = n, K = (e, t, n) => xn(e, typeof t == "symbol" ? t : t + "", n), Sn = 1e3, Cn = 1001, wn = 1005, Tn = 4040, En;
1285
+ function Dn() {
1286
+ return En === void 0 && (En = Date.now()), typeof performance > "u" || !performance.now ? Date.now() : Math.round(En + performance.now());
1287
+ }
1288
+ function On() {
1289
+ return `t=${Math.round((Dn() - En) / 100) / 10}s`;
1290
+ }
1291
+ var kn = {
1292
+ InternalServerError: { timeout: 1e3 },
1293
+ SubscriptionsWorkerFullError: { timeout: 3e3 },
1294
+ TooManyConcurrentRequests: { timeout: 3e3 },
1295
+ CommitterFullError: { timeout: 3e3 },
1296
+ AwsTooManyRequestsException: { timeout: 3e3 },
1297
+ ExecuteFullError: { timeout: 3e3 },
1298
+ SystemTimeoutError: { timeout: 3e3 },
1299
+ ExpiredInQueue: { timeout: 3e3 },
1300
+ VectorIndexesUnavailable: { timeout: 1e3 },
1301
+ SearchIndexesUnavailable: { timeout: 1e3 },
1302
+ TableSummariesUnavailable: { timeout: 1e3 },
1303
+ VectorIndexTooLarge: { timeout: 3e3 },
1304
+ SearchIndexTooLarge: { timeout: 3e3 },
1305
+ TooManyWritesInTimePeriod: { timeout: 3e3 }
1306
+ };
1307
+ function An(e) {
1308
+ if (e === void 0) return "Unknown";
1309
+ for (let t of Object.keys(kn)) if (e.startsWith(t)) return t;
1310
+ return "Unknown";
1311
+ }
1312
+ var jn = class {
1313
+ constructor(e, t, n, r, i, a) {
1314
+ this.markConnectionStateDirty = i, this.debug = a, K(this, "socket"), K(this, "connectionCount"), K(this, "_hasEverConnected", !1), K(this, "lastCloseReason"), K(this, "transitionChunkBuffer", null), K(this, "defaultInitialBackoff"), K(this, "maxBackoff"), K(this, "retries"), K(this, "serverInactivityThreshold"), K(this, "reconnectDueToServerInactivityTimeout"), K(this, "scheduledReconnect", null), K(this, "networkOnlineHandler", null), K(this, "pendingNetworkRecoveryInfo", null), K(this, "uri"), K(this, "onOpen"), K(this, "onResume"), K(this, "onMessage"), K(this, "webSocketConstructor"), K(this, "logger"), K(this, "onServerDisconnectError"), this.webSocketConstructor = n, this.socket = { state: "disconnected" }, this.connectionCount = 0, this.lastCloseReason = "InitialConnect", this.defaultInitialBackoff = 1e3, this.maxBackoff = 16e3, this.retries = 0, this.serverInactivityThreshold = 6e4, this.reconnectDueToServerInactivityTimeout = null, this.uri = e, this.onOpen = t.onOpen, this.onResume = t.onResume, this.onMessage = t.onMessage, this.onServerDisconnectError = t.onServerDisconnectError, this.logger = r, this.setupNetworkListener(), this.connect();
1315
+ }
1316
+ setSocketState(e) {
1317
+ this.socket = e, this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused" in this.socket ? this.socket.paused : void 0}`), this.markConnectionStateDirty();
1318
+ }
1319
+ setupNetworkListener() {
1320
+ typeof window > "u" || typeof window.addEventListener != "function" || this.networkOnlineHandler === null && (this.networkOnlineHandler = () => {
1321
+ this._logVerbose("network online event detected"), this.tryReconnectImmediately();
1322
+ }, window.addEventListener("online", this.networkOnlineHandler), this._logVerbose("network online event listener registered"));
1323
+ }
1324
+ cleanupNetworkListener() {
1325
+ this.networkOnlineHandler && typeof window < "u" && typeof window.removeEventListener == "function" && (window.removeEventListener("online", this.networkOnlineHandler), this.networkOnlineHandler = null, this._logVerbose("network online event listener removed"));
1326
+ }
1327
+ assembleTransition(e) {
1328
+ if (e.partNumber < 0 || e.partNumber >= e.totalParts || e.totalParts === 0 || this.transitionChunkBuffer && (this.transitionChunkBuffer.totalParts !== e.totalParts || this.transitionChunkBuffer.transitionId !== e.transitionId)) throw this.transitionChunkBuffer = null, Error("Invalid TransitionChunk");
1329
+ if (this.transitionChunkBuffer === null && (this.transitionChunkBuffer = {
1330
+ chunks: [],
1331
+ totalParts: e.totalParts,
1332
+ transitionId: e.transitionId
1333
+ }), e.partNumber !== this.transitionChunkBuffer.chunks.length) {
1334
+ let t = this.transitionChunkBuffer.chunks.length;
1335
+ throw this.transitionChunkBuffer = null, Error(`TransitionChunk received out of order: expected part ${t}, got ${e.partNumber}`);
1336
+ }
1337
+ if (this.transitionChunkBuffer.chunks.push(e.chunk), this.transitionChunkBuffer.chunks.length === e.totalParts) {
1338
+ let e = this.transitionChunkBuffer.chunks.join("");
1339
+ this.transitionChunkBuffer = null;
1340
+ let t = vn(JSON.parse(e));
1341
+ if (t.type !== "Transition") throw Error(`Expected Transition, got ${t.type} after assembling chunks`);
1342
+ return t;
1343
+ }
1344
+ return null;
1345
+ }
1346
+ connect() {
1347
+ if (this.socket.state === "terminated") return;
1348
+ if (this.socket.state !== "disconnected" && this.socket.state !== "stopped") throw Error("Didn't start connection from disconnected state: " + this.socket.state);
1349
+ let e = new this.webSocketConstructor(this.uri);
1350
+ this._logVerbose("constructed WebSocket"), this.setSocketState({
1351
+ state: "connecting",
1352
+ ws: e,
1353
+ paused: "no"
1354
+ }), this.resetServerInactivityTimeout(), e.onopen = () => {
1355
+ if (this.logger.logVerbose("begin ws.onopen"), this.socket.state !== "connecting") throw Error("onopen called with socket not in connecting state");
1356
+ if (this.setSocketState({
1357
+ state: "ready",
1358
+ ws: e,
1359
+ paused: this.socket.paused === "yes" ? "uninitialized" : "no"
1360
+ }), this.resetServerInactivityTimeout(), this.socket.paused === "no" && (this._hasEverConnected = !0, this.onOpen({
1361
+ connectionCount: this.connectionCount,
1362
+ lastCloseReason: this.lastCloseReason,
1363
+ clientTs: Dn()
1364
+ })), this.lastCloseReason !== "InitialConnect" && (this.lastCloseReason ? this.logger.log("WebSocket reconnected at", On(), "after disconnect due to", this.lastCloseReason) : this.logger.log("WebSocket reconnected at", On())), this.connectionCount += 1, this.lastCloseReason = null, this.pendingNetworkRecoveryInfo !== null) {
1365
+ let { timeSavedMs: e } = this.pendingNetworkRecoveryInfo;
1366
+ this.pendingNetworkRecoveryInfo = null, this.sendMessage({
1367
+ type: "Event",
1368
+ eventType: "NetworkRecoveryReconnect",
1369
+ event: { timeSavedMs: e }
1370
+ }), this.logger.log(`Network recovery reconnect saved ~${Math.round(e / 1e3)}s of waiting`);
1371
+ }
1372
+ }, e.onerror = (e) => {
1373
+ this.transitionChunkBuffer = null;
1374
+ let t = e.message;
1375
+ t && this.logger.log(`WebSocket error message: ${t}`);
1376
+ }, e.onmessage = (e) => {
1377
+ this.resetServerInactivityTimeout();
1378
+ let t = e.data.length, n = vn(JSON.parse(e.data));
1379
+ if (this._logVerbose(`received ws message with type ${n.type}`), n.type !== "Ping") {
1380
+ if (n.type === "TransitionChunk") {
1381
+ let e = this.assembleTransition(n);
1382
+ if (!e) return;
1383
+ n = e, this._logVerbose(`assembled full ws message of type ${n.type}`);
1384
+ }
1385
+ this.transitionChunkBuffer !== null && (this.transitionChunkBuffer = null, this.logger.log(`Received unexpected ${n.type} while buffering TransitionChunks`)), n.type === "Transition" && this.reportLargeTransition({
1386
+ messageLength: t,
1387
+ transition: n
1388
+ }), this.onMessage(n).hasSyncedPastLastReconnect && (this.retries = 0, this.markConnectionStateDirty());
1389
+ }
1390
+ }, e.onclose = (e) => {
1391
+ if (this._logVerbose("begin ws.onclose"), this.transitionChunkBuffer = null, this.lastCloseReason === null && (this.lastCloseReason = e.reason || `closed with code ${e.code}`), e.code !== Sn && e.code !== Cn && e.code !== wn && e.code !== Tn) {
1392
+ let t = `WebSocket closed with code ${e.code}`;
1393
+ e.reason && (t += `: ${e.reason}`), this.logger.log(t), this.onServerDisconnectError && e.reason && this.onServerDisconnectError(t);
1394
+ }
1395
+ let t = An(e.reason);
1396
+ this.scheduleReconnect(t);
1397
+ };
1398
+ }
1399
+ socketState() {
1400
+ return this.socket.state;
1401
+ }
1402
+ sendMessage(e) {
1403
+ let t = {
1404
+ type: e.type,
1405
+ ...e.type === "Authenticate" && e.tokenType === "User" ? { value: `...${e.value.slice(-7)}` } : {}
1406
+ };
1407
+ if (this.socket.state === "ready" && this.socket.paused === "no") {
1408
+ let n = yn(e), r = JSON.stringify(n), i = !1;
1409
+ try {
1410
+ this.socket.ws.send(r), i = !0;
1411
+ } catch (e) {
1412
+ this.logger.log(`Failed to send message on WebSocket, reconnecting: ${e}`), this.closeAndReconnect("FailedToSendMessage");
1413
+ }
1414
+ return this._logVerbose(`${i ? "sent" : "failed to send"} message with type ${e.type}: ${JSON.stringify(t)}`), !0;
1415
+ }
1416
+ return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused" in this.socket ? this.socket.paused : void 0}): ${JSON.stringify(t)}`), !1;
1417
+ }
1418
+ resetServerInactivityTimeout() {
1419
+ this.socket.state !== "terminated" && (this.reconnectDueToServerInactivityTimeout !== null && (clearTimeout(this.reconnectDueToServerInactivityTimeout), this.reconnectDueToServerInactivityTimeout = null), this.reconnectDueToServerInactivityTimeout = setTimeout(() => {
1420
+ this.closeAndReconnect("InactiveServer");
1421
+ }, this.serverInactivityThreshold));
1422
+ }
1423
+ scheduleReconnect(e) {
1424
+ this.scheduledReconnect &&= (clearTimeout(this.scheduledReconnect.timeout), null), this.socket = { state: "disconnected" };
1425
+ let t = this.nextBackoff(e);
1426
+ this.markConnectionStateDirty(), this.logger.log(`Attempting reconnect in ${Math.round(t)}ms`);
1427
+ let n = Dn(), r = setTimeout(() => {
1428
+ this.scheduledReconnect?.timeout === r && (this.scheduledReconnect = null, this.connect());
1429
+ }, t);
1430
+ this.scheduledReconnect = {
1431
+ timeout: r,
1432
+ scheduledAt: n,
1433
+ backoffMs: t
1434
+ };
1435
+ }
1436
+ closeAndReconnect(e) {
1437
+ switch (this._logVerbose(`begin closeAndReconnect with reason ${e}`), this.socket.state) {
1438
+ case "disconnected":
1439
+ case "terminated":
1440
+ case "stopped": return;
1441
+ case "connecting":
1442
+ case "ready":
1443
+ this.lastCloseReason = e, this.close(), this.scheduleReconnect("client");
1444
+ return;
1445
+ default: this.socket;
1446
+ }
1447
+ }
1448
+ close() {
1449
+ switch (this.transitionChunkBuffer = null, this.socket.state) {
1450
+ case "disconnected":
1451
+ case "terminated":
1452
+ case "stopped": return Promise.resolve();
1453
+ case "connecting": {
1454
+ let e = this.socket.ws;
1455
+ return e.onmessage = (e) => {
1456
+ this._logVerbose("Ignoring message received after close");
1457
+ }, new Promise((t) => {
1458
+ e.onclose = () => {
1459
+ this._logVerbose("Closed after connecting"), t();
1460
+ }, e.onopen = () => {
1461
+ this._logVerbose("Opened after connecting"), e.close();
1462
+ };
1463
+ });
1464
+ }
1465
+ case "ready": {
1466
+ this._logVerbose("ws.close called");
1467
+ let e = this.socket.ws;
1468
+ e.onmessage = (e) => {
1469
+ this._logVerbose("Ignoring message received after close");
1470
+ };
1471
+ let t = new Promise((t) => {
1472
+ e.onclose = () => {
1473
+ t();
1474
+ };
1475
+ });
1476
+ return e.close(), t;
1477
+ }
1478
+ default: return this.socket, Promise.resolve();
1479
+ }
1480
+ }
1481
+ terminate() {
1482
+ switch (this.reconnectDueToServerInactivityTimeout && clearTimeout(this.reconnectDueToServerInactivityTimeout), this.scheduledReconnect &&= (clearTimeout(this.scheduledReconnect.timeout), null), this.cleanupNetworkListener(), this.socket.state) {
1483
+ case "terminated":
1484
+ case "stopped":
1485
+ case "disconnected":
1486
+ case "connecting":
1487
+ case "ready": {
1488
+ let e = this.close();
1489
+ return this.setSocketState({ state: "terminated" }), e;
1490
+ }
1491
+ default: throw this.socket, Error(`Invalid websocket state: ${this.socket.state}`);
1492
+ }
1493
+ }
1494
+ stop() {
1495
+ switch (this.socket.state) {
1496
+ case "terminated": return Promise.resolve();
1497
+ case "connecting":
1498
+ case "stopped":
1499
+ case "disconnected":
1500
+ case "ready": {
1501
+ this.cleanupNetworkListener();
1502
+ let e = this.close();
1503
+ return this.socket = { state: "stopped" }, e;
1504
+ }
1505
+ default: return this.socket, Promise.resolve();
1506
+ }
1507
+ }
1508
+ tryRestart() {
1509
+ switch (this.socket.state) {
1510
+ case "stopped": break;
1511
+ case "terminated":
1512
+ case "connecting":
1513
+ case "ready":
1514
+ case "disconnected":
1515
+ this.logger.logVerbose("Restart called without stopping first");
1516
+ return;
1517
+ default: this.socket;
1518
+ }
1519
+ this.setupNetworkListener(), this.connect();
1520
+ }
1521
+ pause() {
1522
+ switch (this.socket.state) {
1523
+ case "disconnected":
1524
+ case "stopped":
1525
+ case "terminated": return;
1526
+ case "connecting":
1527
+ case "ready":
1528
+ this.socket = {
1529
+ ...this.socket,
1530
+ paused: "yes"
1531
+ };
1532
+ return;
1533
+ default:
1534
+ this.socket;
1535
+ return;
1536
+ }
1537
+ }
1538
+ tryReconnectImmediately() {
1539
+ if (this._logVerbose("tryReconnectImmediately called"), this.socket.state !== "disconnected") {
1540
+ this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);
1541
+ return;
1542
+ }
1543
+ let e = null;
1544
+ if (this.scheduledReconnect) {
1545
+ let t = Dn() - this.scheduledReconnect.scheduledAt;
1546
+ e = Math.max(0, this.scheduledReconnect.backoffMs - t), this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(t)}ms)`), clearTimeout(this.scheduledReconnect.timeout), this.scheduledReconnect = null, this._logVerbose("canceled scheduled reconnect");
1547
+ }
1548
+ this.logger.log("Network recovery detected, reconnecting immediately"), this.pendingNetworkRecoveryInfo = e === null ? null : { timeSavedMs: e }, this.connect();
1549
+ }
1550
+ resume() {
1551
+ switch (this.socket.state) {
1552
+ case "connecting":
1553
+ this.socket = {
1554
+ ...this.socket,
1555
+ paused: "no"
1556
+ };
1557
+ return;
1558
+ case "ready":
1559
+ this.socket.paused === "uninitialized" ? (this.socket = {
1560
+ ...this.socket,
1561
+ paused: "no"
1562
+ }, this._hasEverConnected = !0, this.onOpen({
1563
+ connectionCount: this.connectionCount,
1564
+ lastCloseReason: this.lastCloseReason,
1565
+ clientTs: Dn()
1566
+ })) : this.socket.paused === "yes" && (this.socket = {
1567
+ ...this.socket,
1568
+ paused: "no"
1569
+ }, this.onResume());
1570
+ return;
1571
+ case "terminated":
1572
+ case "stopped":
1573
+ case "disconnected": return;
1574
+ default: this.socket;
1575
+ }
1576
+ this.connect();
1577
+ }
1578
+ connectionState() {
1579
+ return {
1580
+ isConnected: this.socket.state === "ready",
1581
+ hasEverConnected: this._hasEverConnected,
1582
+ connectionCount: this.connectionCount,
1583
+ connectionRetries: this.retries
1584
+ };
1585
+ }
1586
+ _logVerbose(e) {
1587
+ this.logger.logVerbose(e);
1588
+ }
1589
+ nextBackoff(e) {
1590
+ let t = (e === "client" ? 100 : e === "Unknown" ? this.defaultInitialBackoff : kn[e].timeout) * 2 ** this.retries;
1591
+ this.retries += 1;
1592
+ let n = Math.min(t, this.maxBackoff);
1593
+ return n + n * (Math.random() - .5);
1594
+ }
1595
+ reportLargeTransition({ transition: e, messageLength: t }) {
1596
+ if (e.clientClockSkew === void 0 || e.serverTs === void 0) return;
1597
+ let n = Dn() - e.clientClockSkew - e.serverTs / 1e6, r = `${Math.round(n)}ms`, i = `${Math.round(t / 1e4) / 100}MB`, a = t / (n / 1e3), o = `${Math.round(a / 1e4) / 100}MB per second`;
1598
+ this._logVerbose(`received ${i} transition in ${r} at ${o}`), t > 2e7 ? this.logger.log(`received query results totaling more that 20MB (${i}) which will take a long time to download on slower connections`) : n > 2e4 && this.logger.log(`received query results totaling ${i} which took more than 20s to arrive (${r})`), this.debug && this.sendMessage({
1599
+ type: "Event",
1600
+ eventType: "ClientReceivedTransition",
1601
+ event: {
1602
+ transitionTransitTime: n,
1603
+ messageLength: t
1604
+ }
1605
+ });
1606
+ }
1607
+ };
1608
+ //#endregion
1609
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/session.js
1610
+ function Mn() {
1611
+ return Nn();
1612
+ }
1613
+ function Nn() {
1614
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
1615
+ let t = Math.random() * 16 | 0;
1616
+ return (e === "x" ? t : t & 3 | 8).toString(16);
1617
+ });
1618
+ }
1619
+ //#endregion
1620
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/vendor/jwt-decode/index.js
1621
+ var Pn = class extends Error {};
1622
+ Pn.prototype.name = "InvalidTokenError";
1623
+ function Fn(e) {
1624
+ return decodeURIComponent(atob(e).replace(/(.)/g, (e, t) => {
1625
+ let n = t.charCodeAt(0).toString(16).toUpperCase();
1626
+ return n.length < 2 && (n = "0" + n), "%" + n;
1627
+ }));
1628
+ }
1629
+ function In(e) {
1630
+ let t = e.replace(/-/g, "+").replace(/_/g, "/");
1631
+ switch (t.length % 4) {
1632
+ case 0: break;
1633
+ case 2:
1634
+ t += "==";
1635
+ break;
1636
+ case 3:
1637
+ t += "=";
1638
+ break;
1639
+ default: throw Error("base64 string is not of the correct length");
1640
+ }
1641
+ try {
1642
+ return Fn(t);
1643
+ } catch {
1644
+ return atob(t);
1645
+ }
1646
+ }
1647
+ function Ln(e, t) {
1648
+ if (typeof e != "string") throw new Pn("Invalid token specified: must be a string");
1649
+ t ||= {};
1650
+ let n = t.header === !0 ? 0 : 1, r = e.split(".")[n];
1651
+ if (typeof r != "string") throw new Pn(`Invalid token specified: missing part #${n + 1}`);
1652
+ let i;
1653
+ try {
1654
+ i = In(r);
1655
+ } catch (e) {
1656
+ throw new Pn(`Invalid token specified: invalid base64 for part #${n + 1} (${e.message})`);
1657
+ }
1658
+ try {
1659
+ return JSON.parse(i);
1660
+ } catch (e) {
1661
+ throw new Pn(`Invalid token specified: invalid json for part #${n + 1} (${e.message})`);
1662
+ }
1663
+ }
1664
+ //#endregion
1665
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/authentication_manager.js
1666
+ var Rn = Object.defineProperty, zn = (e, t, n) => t in e ? Rn(e, t, {
1667
+ enumerable: !0,
1668
+ configurable: !0,
1669
+ writable: !0,
1670
+ value: n
1671
+ }) : e[t] = n, q = (e, t, n) => zn(e, typeof t == "symbol" ? t : t + "", n), Bn = 480 * 60 * 60 * 1e3, Vn = 2, Hn = class {
1672
+ constructor(e, t, n) {
1673
+ q(this, "authState", { state: "noAuth" }), q(this, "configVersion", 0), q(this, "syncState"), q(this, "authenticate"), q(this, "stopSocket"), q(this, "tryRestartSocket"), q(this, "pauseSocket"), q(this, "resumeSocket"), q(this, "clearAuth"), q(this, "logger"), q(this, "refreshTokenLeewaySeconds"), q(this, "tokenConfirmationAttempts", 0), this.syncState = e, this.authenticate = t.authenticate, this.stopSocket = t.stopSocket, this.tryRestartSocket = t.tryRestartSocket, this.pauseSocket = t.pauseSocket, this.resumeSocket = t.resumeSocket, this.clearAuth = t.clearAuth, this.logger = n.logger, this.refreshTokenLeewaySeconds = n.refreshTokenLeewaySeconds;
1674
+ }
1675
+ async setConfig(e, t) {
1676
+ this.resetAuthState(), this._logVerbose("pausing WS for auth token fetch"), this.pauseSocket();
1677
+ let n = await this.fetchTokenAndGuardAgainstRace(e, { forceRefreshToken: !1 });
1678
+ n.isFromOutdatedConfig || (n.value ? (this.setAuthState({
1679
+ state: "waitingForServerConfirmationOfCachedToken",
1680
+ config: {
1681
+ fetchToken: e,
1682
+ onAuthChange: t
1683
+ },
1684
+ hasRetried: !1
1685
+ }), this.authenticate(n.value)) : (this.setAuthState({
1686
+ state: "initialRefetch",
1687
+ config: {
1688
+ fetchToken: e,
1689
+ onAuthChange: t
1690
+ }
1691
+ }), await this.refetchToken()), this._logVerbose("resuming WS after auth token fetch"), this.resumeSocket());
1692
+ }
1693
+ onTransition(e) {
1694
+ if (this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity) && !(e.endVersion.identity <= e.startVersion.identity)) {
1695
+ if (this._logVerbose(`auth state is ${this.authState.state} when handling transition`), this.syncState.markAuthCompletion(), this.authState.state === "waitingForServerConfirmationOfCachedToken") {
1696
+ this._logVerbose("server confirmed auth token is valid"), this.refetchToken(), this.authState.config.onAuthChange(!0);
1697
+ return;
1698
+ }
1699
+ this.authState.state === "waitingForServerConfirmationOfFreshToken" && (this._logVerbose("server confirmed new auth token is valid"), this.scheduleTokenRefetch(this.authState.token), this.tokenConfirmationAttempts = 0, this.authState.hadAuth || this.authState.config.onAuthChange(!0));
1700
+ }
1701
+ }
1702
+ onAuthError(e) {
1703
+ if (e.authUpdateAttempted === !1 && (this.authState.state === "waitingForServerConfirmationOfFreshToken" || this.authState.state === "waitingForServerConfirmationOfCachedToken")) {
1704
+ this._logVerbose("ignoring non-auth token expired error");
1705
+ return;
1706
+ }
1707
+ let { baseVersion: t } = e;
1708
+ if (!this.syncState.isCurrentOrNewerAuthVersion(t + 1)) {
1709
+ this._logVerbose("ignoring auth error for previous auth attempt");
1710
+ return;
1711
+ }
1712
+ this.tryToReauthenticate(e);
1713
+ }
1714
+ async tryToReauthenticate(e) {
1715
+ if (this._logVerbose(`attempting to reauthenticate: ${e.error}`), this.authState.state === "noAuth" || this.authState.state === "waitingForServerConfirmationOfFreshToken" && this.tokenConfirmationAttempts >= Vn) {
1716
+ this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`), this.syncState.hasAuth() && this.syncState.clearAuth(), this.authState.state !== "noAuth" && this.setAndReportAuthFailed(this.authState.config.onAuthChange);
1717
+ return;
1718
+ }
1719
+ this.authState.state === "waitingForServerConfirmationOfFreshToken" && (this.tokenConfirmationAttempts++, this._logVerbose(`retrying reauthentication, ${Vn - this.tokenConfirmationAttempts} attempts remaining`)), await this.stopSocket();
1720
+ let t = await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken, { forceRefreshToken: !0 });
1721
+ t.isFromOutdatedConfig || (t.value && this.syncState.isNewAuth(t.value) ? (this.authenticate(t.value), this.setAuthState({
1722
+ state: "waitingForServerConfirmationOfFreshToken",
1723
+ config: this.authState.config,
1724
+ token: t.value,
1725
+ hadAuth: this.authState.state === "notRefetching" || this.authState.state === "waitingForScheduledRefetch"
1726
+ })) : (this._logVerbose("reauthentication failed, could not fetch a new token"), this.syncState.hasAuth() && this.syncState.clearAuth(), this.setAndReportAuthFailed(this.authState.config.onAuthChange)), this.tryRestartSocket());
1727
+ }
1728
+ async refetchToken() {
1729
+ if (this.authState.state === "noAuth") return;
1730
+ this._logVerbose("refetching auth token");
1731
+ let e = await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken, { forceRefreshToken: !0 });
1732
+ e.isFromOutdatedConfig || (e.value ? this.syncState.isNewAuth(e.value) ? (this.setAuthState({
1733
+ state: "waitingForServerConfirmationOfFreshToken",
1734
+ hadAuth: this.syncState.hasAuth(),
1735
+ token: e.value,
1736
+ config: this.authState.config
1737
+ }), this.authenticate(e.value)) : this.setAuthState({
1738
+ state: "notRefetching",
1739
+ config: this.authState.config
1740
+ }) : (this._logVerbose("refetching token failed"), this.syncState.hasAuth() && this.clearAuth(), this.setAndReportAuthFailed(this.authState.config.onAuthChange)), this._logVerbose("restarting WS after auth token fetch (if currently stopped)"), this.tryRestartSocket());
1741
+ }
1742
+ scheduleTokenRefetch(e) {
1743
+ if (this.authState.state === "noAuth") return;
1744
+ let t = this.decodeToken(e);
1745
+ if (!t) {
1746
+ this.logger.error("Auth token is not a valid JWT, cannot refetch the token");
1747
+ return;
1748
+ }
1749
+ let { iat: n, exp: r } = t;
1750
+ if (!n || !r) {
1751
+ this.logger.error("Auth token does not have required fields, cannot refetch the token");
1752
+ return;
1753
+ }
1754
+ let i = r - n;
1755
+ if (i <= 2) {
1756
+ this.logger.error("Auth token does not live long enough, cannot refetch the token");
1757
+ return;
1758
+ }
1759
+ let a = Math.min(Bn, (i - this.refreshTokenLeewaySeconds) * 1e3);
1760
+ a <= 0 && (this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${i}s`), a = 0);
1761
+ let o = setTimeout(() => {
1762
+ this._logVerbose("running scheduled token refetch"), this.refetchToken();
1763
+ }, a);
1764
+ this.setAuthState({
1765
+ state: "waitingForScheduledRefetch",
1766
+ refetchTokenTimeoutId: o,
1767
+ config: this.authState.config
1768
+ }), this._logVerbose(`scheduled preemptive auth token refetching in ${a}ms`);
1769
+ }
1770
+ async fetchTokenAndGuardAgainstRace(e, t) {
1771
+ let n = ++this.configVersion;
1772
+ this._logVerbose(`fetching token with config version ${n}`);
1773
+ let r = await e(t);
1774
+ return this.configVersion === n ? {
1775
+ isFromOutdatedConfig: !1,
1776
+ value: r
1777
+ } : (this._logVerbose(`stale config version, expected ${n}, got ${this.configVersion}`), { isFromOutdatedConfig: !0 });
1778
+ }
1779
+ stop() {
1780
+ this.resetAuthState(), this.configVersion++, this._logVerbose(`config version bumped to ${this.configVersion}`);
1781
+ }
1782
+ setAndReportAuthFailed(e) {
1783
+ e(!1), this.resetAuthState();
1784
+ }
1785
+ resetAuthState() {
1786
+ this.setAuthState({ state: "noAuth" });
1787
+ }
1788
+ setAuthState(e) {
1789
+ let t = e.state === "waitingForServerConfirmationOfFreshToken" ? {
1790
+ hadAuth: e.hadAuth,
1791
+ state: e.state,
1792
+ token: `...${e.token.slice(-7)}`
1793
+ } : { state: e.state };
1794
+ switch (this._logVerbose(`setting auth state to ${JSON.stringify(t)}`), e.state) {
1795
+ case "waitingForScheduledRefetch":
1796
+ case "notRefetching":
1797
+ case "noAuth":
1798
+ this.tokenConfirmationAttempts = 0;
1799
+ break;
1800
+ case "waitingForServerConfirmationOfFreshToken":
1801
+ case "waitingForServerConfirmationOfCachedToken":
1802
+ case "initialRefetch": break;
1803
+ default:
1804
+ }
1805
+ this.authState.state === "waitingForScheduledRefetch" && clearTimeout(this.authState.refetchTokenTimeoutId), this.authState = e;
1806
+ }
1807
+ decodeToken(e) {
1808
+ try {
1809
+ return Ln(e);
1810
+ } catch (e) {
1811
+ return this._logVerbose(`Error decoding token: ${e instanceof Error ? e.message : "Unknown error"}`), null;
1812
+ }
1813
+ }
1814
+ _logVerbose(e) {
1815
+ this.logger.logVerbose(`${e} [v${this.configVersion}]`);
1816
+ }
1817
+ }, Un = [
1818
+ "convexClientConstructed",
1819
+ "convexWebSocketOpen",
1820
+ "convexFirstMessageReceived"
1821
+ ];
1822
+ function Wn(e, t) {
1823
+ let n = { sessionId: t };
1824
+ typeof performance > "u" || !performance.mark || performance.mark(e, { detail: n });
1825
+ }
1826
+ function Gn(e) {
1827
+ let t = e.name.slice(6);
1828
+ return t = t.charAt(0).toLowerCase() + t.slice(1), {
1829
+ name: t,
1830
+ startTime: e.startTime
1831
+ };
1832
+ }
1833
+ function Kn(e) {
1834
+ if (typeof performance > "u" || !performance.getEntriesByName) return [];
1835
+ let t = [];
1836
+ for (let n of Un) {
1837
+ let r = performance.getEntriesByName(n).filter((e) => e.entryType === "mark").filter((t) => t.detail.sessionId === e);
1838
+ t.push(...r);
1839
+ }
1840
+ return t.map(Gn);
1841
+ }
1842
+ //#endregion
1843
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/client.js
1844
+ var qn = Object.defineProperty, Jn = (e, t, n) => t in e ? qn(e, t, {
1845
+ enumerable: !0,
1846
+ configurable: !0,
1847
+ writable: !0,
1848
+ value: n
1849
+ }) : e[t] = n, J = (e, t, n) => Jn(e, typeof t == "symbol" ? t : t + "", n), Yn = class {
1850
+ constructor(e, t, n) {
1851
+ if (J(this, "address"), J(this, "state"), J(this, "requestManager"), J(this, "webSocketManager"), J(this, "authenticationManager"), J(this, "remoteQuerySet"), J(this, "optimisticQueryResults"), J(this, "_transitionHandlerCounter", 0), J(this, "_nextRequestId"), J(this, "_onTransitionFns", /* @__PURE__ */ new Map()), J(this, "_sessionId"), J(this, "firstMessageReceived", !1), J(this, "debug"), J(this, "logger"), J(this, "maxObservedTimestamp"), J(this, "connectionStateSubscribers", /* @__PURE__ */ new Map()), J(this, "nextConnectionStateSubscriberId", 0), J(this, "_lastPublishedConnectionState"), J(this, "markConnectionStateDirty", () => {
1852
+ Promise.resolve().then(() => {
1853
+ let e = this.connectionState();
1854
+ if (JSON.stringify(e) !== JSON.stringify(this._lastPublishedConnectionState)) {
1855
+ this._lastPublishedConnectionState = e;
1856
+ for (let t of this.connectionStateSubscribers.values()) t(e);
1857
+ }
1858
+ });
1859
+ }), J(this, "mark", (e) => {
1860
+ this.debug && Wn(e, this.sessionId);
1861
+ }), typeof e == "object") throw Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");
1862
+ n?.skipConvexDeploymentUrlCheck !== !0 && We(e), n = { ...n };
1863
+ let r = n.authRefreshTokenLeewaySeconds ?? 10, i = n.webSocketConstructor;
1864
+ if (!i && typeof WebSocket > "u") throw Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");
1865
+ i ||= WebSocket, this.debug = n.reportDebugInfoToConvex ?? !1, this.address = e, this.logger = n.logger === !1 ? Ot({ verbose: n.verbose ?? !1 }) : n.logger !== !0 && n.logger ? n.logger : Dt({ verbose: n.verbose ?? !1 });
1866
+ let a = e.search("://");
1867
+ if (a === -1) throw Error("Provided address was not an absolute URL.");
1868
+ let o = e.substring(a + 3), s = e.substring(0, a), c;
1869
+ if (s === "http") c = "ws";
1870
+ else if (s === "https") c = "wss";
1871
+ else throw Error(`Unknown parent protocol ${s}`);
1872
+ let l = `${c}://${o}/api/${Ne}/sync`;
1873
+ this.state = new zt(), this.remoteQuerySet = new hn((e) => this.state.queryPath(e), this.logger), this.requestManager = new Ut(this.logger, this.markConnectionStateDirty);
1874
+ let u = () => {
1875
+ this.webSocketManager.pause(), this.state.pause();
1876
+ };
1877
+ this.authenticationManager = new Hn(this.state, {
1878
+ authenticate: (e) => {
1879
+ let t = this.state.setAuth(e);
1880
+ return this.webSocketManager.sendMessage(t), t.baseVersion;
1881
+ },
1882
+ stopSocket: () => this.webSocketManager.stop(),
1883
+ tryRestartSocket: () => this.webSocketManager.tryRestart(),
1884
+ pauseSocket: u,
1885
+ resumeSocket: () => this.webSocketManager.resume(),
1886
+ clearAuth: () => {
1887
+ this.clearAuth();
1888
+ }
1889
+ }, {
1890
+ logger: this.logger,
1891
+ refreshTokenLeewaySeconds: r
1892
+ }), this.optimisticQueryResults = new tn(), this.addOnTransitionHandler((e) => {
1893
+ t(e.queries.map((e) => e.token));
1894
+ }), this._nextRequestId = 0, this._sessionId = Mn();
1895
+ let { unsavedChangesWarning: d } = n;
1896
+ if (typeof window > "u" || window.addEventListener === void 0) {
1897
+ if (d === !0) throw Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.");
1898
+ } else d !== !1 && window.addEventListener("beforeunload", (e) => {
1899
+ if (this.requestManager.hasIncompleteRequests()) {
1900
+ e.preventDefault();
1901
+ let t = "Are you sure you want to leave? Your changes may not be saved.";
1902
+ return (e || window.event).returnValue = t, t;
1903
+ }
1904
+ });
1905
+ this.webSocketManager = new jn(l, {
1906
+ onOpen: (e) => {
1907
+ this.mark("convexWebSocketOpen"), this.webSocketManager.sendMessage({
1908
+ ...e,
1909
+ type: "Connect",
1910
+ sessionId: this._sessionId,
1911
+ maxObservedTimestamp: this.maxObservedTimestamp
1912
+ }), this.remoteQuerySet = new hn((e) => this.state.queryPath(e), this.logger);
1913
+ let [t, n] = this.state.restart();
1914
+ n && this.webSocketManager.sendMessage(n), this.webSocketManager.sendMessage(t);
1915
+ for (let e of this.requestManager.restart()) this.webSocketManager.sendMessage(e);
1916
+ },
1917
+ onResume: () => {
1918
+ let [e, t] = this.state.resume();
1919
+ t && this.webSocketManager.sendMessage(t), e && this.webSocketManager.sendMessage(e);
1920
+ for (let e of this.requestManager.resume()) this.webSocketManager.sendMessage(e);
1921
+ },
1922
+ onMessage: (e) => {
1923
+ switch (this.firstMessageReceived || (this.firstMessageReceived = !0, this.mark("convexFirstMessageReceived"), this.reportMarks()), e.type) {
1924
+ case "Transition": {
1925
+ this.observedTimestamp(e.endVersion.ts), this.authenticationManager.onTransition(e), this.remoteQuerySet.transition(e), this.state.transition(e);
1926
+ let t = this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());
1927
+ this.notifyOnQueryResultChanges(t);
1928
+ break;
1929
+ }
1930
+ case "MutationResponse": {
1931
+ e.success && this.observedTimestamp(e.ts);
1932
+ let t = this.requestManager.onResponse(e);
1933
+ t !== null && this.notifyOnQueryResultChanges(/* @__PURE__ */ new Map([[t.requestId, t.result]]));
1934
+ break;
1935
+ }
1936
+ case "ActionResponse":
1937
+ this.requestManager.onResponse(e);
1938
+ break;
1939
+ case "AuthError":
1940
+ this.authenticationManager.onAuthError(e);
1941
+ break;
1942
+ case "FatalError": {
1943
+ let t = At(this.logger, e.error);
1944
+ throw this.webSocketManager.terminate(), t;
1945
+ }
1946
+ default:
1947
+ }
1948
+ return { hasSyncedPastLastReconnect: this.hasSyncedPastLastReconnect() };
1949
+ },
1950
+ onServerDisconnectError: n.onServerDisconnectError
1951
+ }, i, this.logger, this.markConnectionStateDirty, this.debug), this.mark("convexClientConstructed"), n.expectAuth && u();
1952
+ }
1953
+ hasSyncedPastLastReconnect() {
1954
+ return this.requestManager.hasSyncedPastLastReconnect() && this.state.hasSyncedPastLastReconnect();
1955
+ }
1956
+ observedTimestamp(e) {
1957
+ (this.maxObservedTimestamp === void 0 || this.maxObservedTimestamp.lessThanOrEqual(e)) && (this.maxObservedTimestamp = e);
1958
+ }
1959
+ getMaxObservedTimestamp() {
1960
+ return this.maxObservedTimestamp;
1961
+ }
1962
+ notifyOnQueryResultChanges(e) {
1963
+ let t = this.remoteQuerySet.remoteQueryResults(), n = /* @__PURE__ */ new Map();
1964
+ for (let [e, r] of t) {
1965
+ let t = this.state.queryToken(e);
1966
+ if (t !== null) {
1967
+ let i = {
1968
+ result: r,
1969
+ udfPath: this.state.queryPath(e),
1970
+ args: this.state.queryArgs(e)
1971
+ };
1972
+ n.set(t, i);
1973
+ }
1974
+ }
1975
+ let r = this.optimisticQueryResults.ingestQueryResultsFromServer(n, new Set(e.keys()));
1976
+ this.handleTransition({
1977
+ queries: r.map((e) => ({
1978
+ token: e,
1979
+ modification: {
1980
+ kind: "Updated",
1981
+ result: this.optimisticQueryResults.rawQueryResult(e)
1982
+ }
1983
+ })),
1984
+ reflectedMutations: Array.from(e).map(([e, t]) => ({
1985
+ requestId: e,
1986
+ result: t
1987
+ })),
1988
+ timestamp: this.remoteQuerySet.timestamp()
1989
+ });
1990
+ }
1991
+ handleTransition(e) {
1992
+ for (let t of this._onTransitionFns.values()) t(e);
1993
+ }
1994
+ addOnTransitionHandler(e) {
1995
+ let t = this._transitionHandlerCounter++;
1996
+ return this._onTransitionFns.set(t, e), () => this._onTransitionFns.delete(t);
1997
+ }
1998
+ getCurrentAuthClaims() {
1999
+ let e = this.state.getAuth(), t = {};
2000
+ if (e && e.tokenType === "User") try {
2001
+ t = e ? Ln(e.value) : {};
2002
+ } catch {
2003
+ t = {};
2004
+ }
2005
+ else return;
2006
+ return {
2007
+ token: e.value,
2008
+ decoded: t
2009
+ };
2010
+ }
2011
+ setAuth(e, t) {
2012
+ this.authenticationManager.setConfig(e, t);
2013
+ }
2014
+ hasAuth() {
2015
+ return this.state.hasAuth();
2016
+ }
2017
+ setAdminAuth(e, t) {
2018
+ let n = this.state.setAdminAuth(e, t);
2019
+ this.webSocketManager.sendMessage(n);
2020
+ }
2021
+ clearAuth() {
2022
+ let e = this.state.clearAuth();
2023
+ this.webSocketManager.sendMessage(e);
2024
+ }
2025
+ subscribe(e, t, n) {
2026
+ let r = U(t), { modification: i, queryToken: a, unsubscribe: o } = this.state.subscribe(e, r, n?.journal, n?.componentPath);
2027
+ return i !== null && this.webSocketManager.sendMessage(i), {
2028
+ queryToken: a,
2029
+ unsubscribe: () => {
2030
+ let e = o();
2031
+ e && this.webSocketManager.sendMessage(e);
2032
+ }
2033
+ };
2034
+ }
2035
+ localQueryResult(e, t) {
2036
+ let n = Pt(e, U(t));
2037
+ return this.optimisticQueryResults.queryResult(n);
2038
+ }
2039
+ localQueryResultByToken(e) {
2040
+ return this.optimisticQueryResults.queryResult(e);
2041
+ }
2042
+ hasLocalQueryResultByToken(e) {
2043
+ return this.optimisticQueryResults.hasQueryResult(e);
2044
+ }
2045
+ localQueryLogs(e, t) {
2046
+ let n = Pt(e, U(t));
2047
+ return this.optimisticQueryResults.queryLogs(n);
2048
+ }
2049
+ queryJournal(e, t) {
2050
+ let n = Pt(e, U(t));
2051
+ return this.state.queryJournal(n);
2052
+ }
2053
+ connectionState() {
2054
+ let e = this.webSocketManager.connectionState();
2055
+ return {
2056
+ hasInflightRequests: this.requestManager.hasInflightRequests(),
2057
+ isWebSocketConnected: e.isConnected,
2058
+ hasEverConnected: e.hasEverConnected,
2059
+ connectionCount: e.connectionCount,
2060
+ connectionRetries: e.connectionRetries,
2061
+ timeOfOldestInflightRequest: this.requestManager.timeOfOldestInflightRequest(),
2062
+ inflightMutations: this.requestManager.inflightMutations(),
2063
+ inflightActions: this.requestManager.inflightActions()
2064
+ };
2065
+ }
2066
+ subscribeToConnectionState(e) {
2067
+ let t = this.nextConnectionStateSubscriberId++;
2068
+ return this.connectionStateSubscribers.set(t, e), () => {
2069
+ this.connectionStateSubscribers.delete(t);
2070
+ };
2071
+ }
2072
+ async mutation(e, t, n) {
2073
+ let r = await this.mutationInternal(e, t, n);
2074
+ if (!r.success) throw r.errorData === void 0 ? Error(jt("mutation", e, r)) : Mt(r, new bt(jt("mutation", e, r)));
2075
+ return r.value;
2076
+ }
2077
+ async mutationInternal(e, t, n, r) {
2078
+ let { mutationPromise: i } = this.enqueueMutation(e, t, n, r);
2079
+ return i;
2080
+ }
2081
+ enqueueMutation(e, t, n, r) {
2082
+ let i = U(t);
2083
+ this.tryReportLongDisconnect();
2084
+ let a = this.nextRequestId;
2085
+ if (this._nextRequestId++, n !== void 0) {
2086
+ let e = n.optimisticUpdate;
2087
+ if (e !== void 0) {
2088
+ let t = this.optimisticQueryResults.applyOptimisticUpdate((t) => {
2089
+ e(t, i) instanceof Promise && this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.");
2090
+ }, a).map((e) => {
2091
+ let t = this.localQueryResultByToken(e);
2092
+ return {
2093
+ token: e,
2094
+ modification: {
2095
+ kind: "Updated",
2096
+ result: t === void 0 ? void 0 : {
2097
+ success: !0,
2098
+ value: t,
2099
+ logLines: []
2100
+ }
2101
+ }
2102
+ };
2103
+ });
2104
+ this.handleTransition({
2105
+ queries: t,
2106
+ reflectedMutations: [],
2107
+ timestamp: this.remoteQuerySet.timestamp()
2108
+ });
2109
+ }
2110
+ }
2111
+ let o = {
2112
+ type: "Mutation",
2113
+ requestId: a,
2114
+ udfPath: e,
2115
+ componentPath: r,
2116
+ args: [pt(i)]
2117
+ }, s = this.webSocketManager.sendMessage(o);
2118
+ return {
2119
+ requestId: a,
2120
+ mutationPromise: this.requestManager.request(o, s)
2121
+ };
2122
+ }
2123
+ async action(e, t) {
2124
+ let n = await this.actionInternal(e, t);
2125
+ if (!n.success) throw n.errorData === void 0 ? Error(jt("action", e, n)) : Mt(n, new bt(jt("action", e, n)));
2126
+ return n.value;
2127
+ }
2128
+ async actionInternal(e, t, n) {
2129
+ let r = U(t), i = this.nextRequestId;
2130
+ this._nextRequestId++, this.tryReportLongDisconnect();
2131
+ let a = {
2132
+ type: "Action",
2133
+ requestId: i,
2134
+ udfPath: e,
2135
+ componentPath: n,
2136
+ args: [pt(r)]
2137
+ }, o = this.webSocketManager.sendMessage(a);
2138
+ return this.requestManager.request(a, o);
2139
+ }
2140
+ async close() {
2141
+ return this.authenticationManager.stop(), this.webSocketManager.terminate();
2142
+ }
2143
+ get url() {
2144
+ return this.address;
2145
+ }
2146
+ get nextRequestId() {
2147
+ return this._nextRequestId;
2148
+ }
2149
+ get sessionId() {
2150
+ return this._sessionId;
2151
+ }
2152
+ reportMarks() {
2153
+ if (this.debug) {
2154
+ let e = Kn(this.sessionId);
2155
+ this.webSocketManager.sendMessage({
2156
+ type: "Event",
2157
+ eventType: "ClientConnect",
2158
+ event: e
2159
+ });
2160
+ }
2161
+ }
2162
+ tryReportLongDisconnect() {
2163
+ if (!this.debug) return;
2164
+ let e = this.connectionState().timeOfOldestInflightRequest;
2165
+ if (e === null || Date.now() - e.getTime() <= 60 * 1e3) return;
2166
+ let t = `${this.address}/api/debug_event`;
2167
+ fetch(t, {
2168
+ method: "POST",
2169
+ headers: {
2170
+ "Content-Type": "application/json",
2171
+ "Convex-Client": `npm-${Ne}`
2172
+ },
2173
+ body: JSON.stringify({ event: "LongWebsocketDisconnect" })
2174
+ }).then((e) => {
2175
+ e.ok || this.logger.warn("Analytics request failed with response:", e.body);
2176
+ }).catch((e) => {
2177
+ this.logger.warn("Analytics response failed with error:", e);
2178
+ });
2179
+ }
2180
+ };
2181
+ //#endregion
2182
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/pagination.js
2183
+ function Xn(e) {
2184
+ if (typeof e != "object" || !e || !Array.isArray(e.page) || typeof e.isDone != "boolean" || typeof e.continueCursor != "string") throw Error(`Not a valid paginated query result: ${e?.toString()}`);
2185
+ return e;
2186
+ }
2187
+ //#endregion
2188
+ //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/paginated_query_client.js
2189
+ var Zn = Object.defineProperty, Qn = (e, t, n) => t in e ? Zn(e, t, {
2190
+ enumerable: !0,
2191
+ configurable: !0,
2192
+ writable: !0,
2193
+ value: n
2194
+ }) : e[t] = n, $n = (e, t, n) => Qn(e, typeof t == "symbol" ? t : t + "", n), er = class {
2195
+ constructor(e, t) {
2196
+ this.client = e, this.onTransition = t, $n(this, "paginatedQuerySet", /* @__PURE__ */ new Map()), $n(this, "lastTransitionTs"), this.lastTransitionTs = on.fromNumber(0), this.client.addOnTransitionHandler((e) => this.onBaseTransition(e));
2197
+ }
2198
+ subscribe(e, t, n) {
2199
+ let r = Nt(e), i = Ft(r, t, n), a = () => this.removePaginatedQuerySubscriber(i), o = this.paginatedQuerySet.get(i);
2200
+ return o ? (o.numSubscribers += 1, {
2201
+ paginatedQueryToken: i,
2202
+ unsubscribe: a
2203
+ }) : (this.paginatedQuerySet.set(i, {
2204
+ token: i,
2205
+ canonicalizedUdfPath: r,
2206
+ args: t,
2207
+ numSubscribers: 1,
2208
+ options: { initialNumItems: n.initialNumItems },
2209
+ nextPageKey: 0,
2210
+ pageKeys: [],
2211
+ pageKeyToQuery: /* @__PURE__ */ new Map(),
2212
+ ongoingSplits: /* @__PURE__ */ new Map(),
2213
+ skip: !1,
2214
+ id: n.id
2215
+ }), this.addPageToPaginatedQuery(i, null, n.initialNumItems), {
2216
+ paginatedQueryToken: i,
2217
+ unsubscribe: a
2218
+ });
2219
+ }
2220
+ localQueryResult(e, t, n) {
2221
+ let r = Ft(Nt(e), t, n);
2222
+ return this.localQueryResultByToken(r);
2223
+ }
2224
+ localQueryResultByToken(e) {
2225
+ let t = this.paginatedQuerySet.get(e);
2226
+ if (!t) return;
2227
+ let n = this.activePageQueryTokens(t);
2228
+ if (n.length === 0) return {
2229
+ results: [],
2230
+ status: "LoadingFirstPage",
2231
+ loadMore: (t) => this.loadMoreOfPaginatedQuery(e, t)
2232
+ };
2233
+ let r = [], i = !1, a = !1;
2234
+ for (let e of n) {
2235
+ let t = this.client.localQueryResultByToken(e);
2236
+ if (t === void 0) {
2237
+ i = !0, a = !1;
2238
+ continue;
2239
+ }
2240
+ let n = Xn(t);
2241
+ r = r.concat(n.page), a = !!n.isDone;
2242
+ }
2243
+ let o;
2244
+ return o = i ? r.length === 0 ? "LoadingFirstPage" : "LoadingMore" : a ? "Exhausted" : "CanLoadMore", {
2245
+ results: r,
2246
+ status: o,
2247
+ loadMore: (t) => this.loadMoreOfPaginatedQuery(e, t)
2248
+ };
2249
+ }
2250
+ onBaseTransition(e) {
2251
+ let t = e.queries.map((e) => e.token), n = this.queriesContainingTokens(t), r = [];
2252
+ n.length > 0 && (this.processPaginatedQuerySplits(n, (e) => this.client.localQueryResultByToken(e)), r = n.map((e) => ({
2253
+ token: e,
2254
+ modification: {
2255
+ kind: "Updated",
2256
+ result: this.localQueryResultByToken(e)
2257
+ }
2258
+ })));
2259
+ let i = {
2260
+ ...e,
2261
+ paginatedQueries: r
2262
+ };
2263
+ this.onTransition(i);
2264
+ }
2265
+ loadMoreOfPaginatedQuery(e, t) {
2266
+ this.mustGetPaginatedQuery(e);
2267
+ let n = this.queryTokenForLastPageOfPaginatedQuery(e), r = this.client.localQueryResultByToken(n);
2268
+ if (!r) return !1;
2269
+ let i = Xn(r);
2270
+ if (i.isDone) return !1;
2271
+ this.addPageToPaginatedQuery(e, i.continueCursor, t);
2272
+ let a = {
2273
+ timestamp: this.lastTransitionTs,
2274
+ reflectedMutations: [],
2275
+ queries: [],
2276
+ paginatedQueries: [{
2277
+ token: e,
2278
+ modification: {
2279
+ kind: "Updated",
2280
+ result: this.localQueryResultByToken(e)
2281
+ }
2282
+ }]
2283
+ };
2284
+ return this.onTransition(a), !0;
2285
+ }
2286
+ queriesContainingTokens(e) {
2287
+ if (e.length === 0) return [];
2288
+ let t = [], n = new Set(e);
2289
+ for (let [e, r] of this.paginatedQuerySet) for (let i of this.allQueryTokens(r)) if (n.has(i)) {
2290
+ t.push(e);
2291
+ break;
2292
+ }
2293
+ return t;
2294
+ }
2295
+ processPaginatedQuerySplits(e, t) {
2296
+ for (let n of e) {
2297
+ let e = this.mustGetPaginatedQuery(n), { ongoingSplits: r, pageKeyToQuery: i, pageKeys: a } = e;
2298
+ for (let [n, [a, o]] of r) t(i.get(a).queryToken) !== void 0 && t(i.get(o).queryToken) !== void 0 && this.completePaginatedQuerySplit(e, n, a, o);
2299
+ for (let n of a) {
2300
+ if (r.has(n)) continue;
2301
+ let a = i.get(n).queryToken, o = t(a);
2302
+ if (!o) continue;
2303
+ let s = Xn(o);
2304
+ s.splitCursor && (s.pageStatus === "SplitRecommended" || s.pageStatus === "SplitRequired" || s.page.length > e.options.initialNumItems * 2) && this.splitPaginatedQueryPage(e, n, s.splitCursor, s.continueCursor);
2305
+ }
2306
+ }
2307
+ }
2308
+ splitPaginatedQueryPage(e, t, n, r) {
2309
+ let i = e.nextPageKey++, a = e.nextPageKey++, o = {
2310
+ cursor: r,
2311
+ numItems: e.options.initialNumItems,
2312
+ id: e.id
2313
+ }, s = this.client.subscribe(e.canonicalizedUdfPath, {
2314
+ ...e.args,
2315
+ paginationOpts: {
2316
+ ...o,
2317
+ cursor: null,
2318
+ endCursor: n
2319
+ }
2320
+ });
2321
+ e.pageKeyToQuery.set(i, s);
2322
+ let c = this.client.subscribe(e.canonicalizedUdfPath, {
2323
+ ...e.args,
2324
+ paginationOpts: {
2325
+ ...o,
2326
+ cursor: n,
2327
+ endCursor: r
2328
+ }
2329
+ });
2330
+ e.pageKeyToQuery.set(a, c), e.ongoingSplits.set(t, [i, a]);
2331
+ }
2332
+ addPageToPaginatedQuery(e, t, n) {
2333
+ let r = this.mustGetPaginatedQuery(e), i = r.nextPageKey++, a = {
2334
+ cursor: t,
2335
+ numItems: n,
2336
+ id: r.id
2337
+ }, o = {
2338
+ ...r.args,
2339
+ paginationOpts: a
2340
+ }, s = this.client.subscribe(r.canonicalizedUdfPath, o);
2341
+ return r.pageKeys.push(i), r.pageKeyToQuery.set(i, s), s;
2342
+ }
2343
+ removePaginatedQuerySubscriber(e) {
2344
+ let t = this.paginatedQuerySet.get(e);
2345
+ if (t && (--t.numSubscribers, !(t.numSubscribers > 0))) {
2346
+ for (let e of t.pageKeyToQuery.values()) e.unsubscribe();
2347
+ this.paginatedQuerySet.delete(e);
2348
+ }
2349
+ }
2350
+ completePaginatedQuerySplit(e, t, n, r) {
2351
+ let i = e.pageKeyToQuery.get(t);
2352
+ e.pageKeyToQuery.delete(t);
2353
+ let a = e.pageKeys.indexOf(t);
2354
+ e.pageKeys.splice(a, 1, n, r), e.ongoingSplits.delete(t), i.unsubscribe();
2355
+ }
2356
+ activePageQueryTokens(e) {
2357
+ return e.pageKeys.map((t) => e.pageKeyToQuery.get(t).queryToken);
2358
+ }
2359
+ allQueryTokens(e) {
2360
+ return Array.from(e.pageKeyToQuery.values()).map((e) => e.queryToken);
2361
+ }
2362
+ queryTokenForLastPageOfPaginatedQuery(e) {
2363
+ let t = this.mustGetPaginatedQuery(e), n = t.pageKeys[t.pageKeys.length - 1];
2364
+ if (n === void 0) throw Error(`No pages for paginated query ${e}`);
2365
+ return t.pageKeyToQuery.get(n).queryToken;
2366
+ }
2367
+ mustGetPaginatedQuery(e) {
2368
+ let t = this.paginatedQuerySet.get(e);
2369
+ if (!t) throw Error("paginated query no longer exists for token " + e);
2370
+ return t;
2371
+ }
2372
+ }, tr = Object.defineProperty, nr = (e, t, n) => t in e ? tr(e, t, {
2373
+ enumerable: !0,
2374
+ configurable: !0,
2375
+ writable: !0,
2376
+ value: n
2377
+ }) : e[t] = n, rr = (e, t, n) => nr(e, typeof t == "symbol" ? t : t + "", n), ir, ar = class {
2378
+ constructor(e, t = {}) {
2379
+ rr(this, "listeners"), rr(this, "_client"), rr(this, "_paginatedClient"), rr(this, "callNewListenersWithCurrentValuesTimer"), rr(this, "_closed"), rr(this, "_disabled"), t.skipConvexDeploymentUrlCheck !== !0 && We(e);
2380
+ let { disabled: n, ...r } = t;
2381
+ this._closed = !1, this._disabled = !!n, ir && !("webSocketConstructor" in r) && typeof WebSocket > "u" && (r.webSocketConstructor = ir), typeof window > "u" && !("unsavedChangesWarning" in r) && (r.unsavedChangesWarning = !1), this.disabled || (this._client = new Yn(e, () => {}, r), this._paginatedClient = new er(this._client, (e) => this._transition(e))), this.listeners = /* @__PURE__ */ new Set();
2382
+ }
2383
+ get closed() {
2384
+ return this._closed;
2385
+ }
2386
+ get client() {
2387
+ if (this._client) return this._client;
2388
+ throw Error("ConvexClient is disabled");
2389
+ }
2390
+ get paginatedClient() {
2391
+ if (this._paginatedClient) return this._paginatedClient;
2392
+ throw Error("ConvexClient is disabled");
2393
+ }
2394
+ get disabled() {
2395
+ return this._disabled;
2396
+ }
2397
+ onUpdate(e, t, n, r) {
2398
+ if (this.disabled) return this.createDisabledUnsubscribe();
2399
+ let { queryToken: i, unsubscribe: a } = this.client.subscribe(G(e), t), o = {
2400
+ queryToken: i,
2401
+ callback: n,
2402
+ onError: r,
2403
+ unsubscribe: a,
2404
+ hasEverRun: !1,
2405
+ query: e,
2406
+ args: t,
2407
+ paginationOptions: void 0
2408
+ };
2409
+ this.listeners.add(o), this.queryResultReady(i) && this.callNewListenersWithCurrentValuesTimer === void 0 && (this.callNewListenersWithCurrentValuesTimer = setTimeout(() => this.callNewListenersWithCurrentValues(), 0));
2410
+ let s = {
2411
+ unsubscribe: () => {
2412
+ this.closed || (this.listeners.delete(o), a());
2413
+ },
2414
+ getCurrentValue: () => this.client.localQueryResultByToken(i),
2415
+ getQueryLogs: () => this.client.localQueryLogs(i)
2416
+ }, c = s.unsubscribe;
2417
+ return Object.assign(c, s), c;
2418
+ }
2419
+ onPaginatedUpdate_experimental(e, t, n, r, i) {
2420
+ if (this.disabled) return this.createDisabledUnsubscribe();
2421
+ let a = {
2422
+ initialNumItems: n.initialNumItems,
2423
+ id: -1
2424
+ }, { paginatedQueryToken: o, unsubscribe: s } = this.paginatedClient.subscribe(G(e), t, a), c = {
2425
+ queryToken: o,
2426
+ callback: r,
2427
+ onError: i,
2428
+ unsubscribe: s,
2429
+ hasEverRun: !1,
2430
+ query: e,
2431
+ args: t,
2432
+ paginationOptions: a
2433
+ };
2434
+ this.listeners.add(c), this.paginatedClient.localQueryResultByToken(o) && this.callNewListenersWithCurrentValuesTimer === void 0 && (this.callNewListenersWithCurrentValuesTimer = setTimeout(() => this.callNewListenersWithCurrentValues(), 0));
2435
+ let l = {
2436
+ unsubscribe: () => {
2437
+ this.closed || (this.listeners.delete(c), s());
2438
+ },
2439
+ getCurrentValue: () => this.paginatedClient.localQueryResult(G(e), t, a),
2440
+ getQueryLogs: () => []
2441
+ }, u = l.unsubscribe;
2442
+ return Object.assign(u, l), u;
2443
+ }
2444
+ callNewListenersWithCurrentValues() {
2445
+ this.callNewListenersWithCurrentValuesTimer = void 0, this._transition({
2446
+ queries: [],
2447
+ paginatedQueries: []
2448
+ }, !0);
2449
+ }
2450
+ queryResultReady(e) {
2451
+ return this.client.hasLocalQueryResultByToken(e);
2452
+ }
2453
+ createDisabledUnsubscribe() {
2454
+ let e = (() => {});
2455
+ return Object.assign(e, {
2456
+ unsubscribe: e,
2457
+ getCurrentValue: () => void 0,
2458
+ getQueryLogs: () => void 0
2459
+ }), e;
2460
+ }
2461
+ async close() {
2462
+ if (!this.disabled) return this.listeners.clear(), this._closed = !0, this._paginatedClient &&= void 0, this.client.close();
2463
+ }
2464
+ getAuth() {
2465
+ if (!this.disabled) return this.client.getCurrentAuthClaims();
2466
+ }
2467
+ setAuth(e, t) {
2468
+ this.disabled || this.client.setAuth(e, t ?? (() => {}));
2469
+ }
2470
+ setAdminAuth(e, t) {
2471
+ if (this.closed) throw Error("ConvexClient has already been closed.");
2472
+ this.disabled || this.client.setAdminAuth(e, t);
2473
+ }
2474
+ _transition({ queries: e, paginatedQueries: t }, n = !1) {
2475
+ let r = [...e.map((e) => e.token), ...t.map((e) => e.token)];
2476
+ for (let e of this.listeners) {
2477
+ let { callback: t, queryToken: i, onError: a, hasEverRun: o } = e, s = It(i), c = s ? !!this.paginatedClient.localQueryResultByToken(i) : this.client.hasLocalQueryResultByToken(i);
2478
+ if (r.includes(i) || n && !o && c) {
2479
+ e.hasEverRun = !0;
2480
+ let n;
2481
+ try {
2482
+ n = s ? this.paginatedClient.localQueryResultByToken(i) : this.client.localQueryResultByToken(i);
2483
+ } catch (e) {
2484
+ if (!(e instanceof Error)) throw e;
2485
+ a ? a(e, "Second argument to onUpdate onError is reserved for later use") : Promise.reject(e);
2486
+ continue;
2487
+ }
2488
+ t(n, "Second argument to onUpdate callback is reserved for later use");
2489
+ }
2490
+ }
2491
+ }
2492
+ async mutation(e, t, n) {
2493
+ if (this.disabled) throw Error("ConvexClient is disabled");
2494
+ return await this.client.mutation(G(e), t, n);
2495
+ }
2496
+ async action(e, t) {
2497
+ if (this.disabled) throw Error("ConvexClient is disabled");
2498
+ return await this.client.action(G(e), t);
2499
+ }
2500
+ async query(e, t) {
2501
+ if (this.disabled) throw Error("ConvexClient is disabled");
2502
+ let n = this.client.localQueryResult(G(e), t);
2503
+ return n === void 0 ? new Promise((n, r) => {
2504
+ let { unsubscribe: i } = this.onUpdate(e, t, (e) => {
2505
+ i(), n(e);
2506
+ }, (e) => {
2507
+ i(), r(e);
2508
+ });
2509
+ }) : Promise.resolve(n);
2510
+ }
2511
+ connectionState() {
2512
+ if (this.disabled) throw Error("ConvexClient is disabled");
2513
+ return this.client.connectionState();
2514
+ }
2515
+ subscribeToConnectionState(e) {
2516
+ return this.disabled ? () => {} : this.client.subscribeToConnectionState(e);
2517
+ }
2518
+ }, or = new Set([
2519
+ "role",
2520
+ "name",
2521
+ "aria-label",
2522
+ "rel",
2523
+ "href"
2524
+ ]);
2525
+ function sr(e, t) {
2526
+ let n = or.has(e);
2527
+ n ||= e.startsWith("data-") && pr(e);
2528
+ let r = pr(t) && t.length < 100;
2529
+ return r ||= t.startsWith("#") && pr(t.slice(1)), n && r;
2530
+ }
2531
+ function cr(e) {
2532
+ return pr(e);
2533
+ }
2534
+ function lr(e) {
2535
+ return pr(e);
2536
+ }
2537
+ function ur(e) {
2538
+ return !0;
2539
+ }
2540
+ function dr(e, t) {
2541
+ if (e.nodeType !== Node.ELEMENT_NODE) throw Error("Can't generate CSS selector for non-element node type.");
2542
+ if (e.tagName.toLowerCase() === "html") return "html";
2543
+ let n = {
2544
+ root: document.body,
2545
+ idName: cr,
2546
+ className: lr,
2547
+ tagName: ur,
2548
+ attr: sr,
2549
+ timeoutMs: 1e3,
2550
+ seedMinLength: 3,
2551
+ optimizedMinLength: 2,
2552
+ maxNumberOfPathChecks: Infinity
2553
+ }, r = /* @__PURE__ */ new Date(), i = {
2554
+ ...n,
2555
+ ...t
2556
+ }, a = Cr(i.root, n), o, s = 0;
2557
+ for (let t of fr(e, i, a)) {
2558
+ if ((/* @__PURE__ */ new Date()).getTime() - r.getTime() > i.timeoutMs || s >= i.maxNumberOfPathChecks) {
2559
+ let t = yr(e, a);
2560
+ if (!t) throw Error(`Timeout: Can't find a unique selector after ${i.timeoutMs}ms`);
2561
+ return hr(t);
2562
+ }
2563
+ if (s++, wr(t, a)) {
2564
+ o = t;
2565
+ break;
2566
+ }
2567
+ }
2568
+ if (!o) throw Error("Selector was not found.");
2569
+ let c = [...Tr(o, e, i, a, r)];
2570
+ return c.sort(_r), c.length > 0 ? hr(c[0]) : hr(o);
2571
+ }
2572
+ function* fr(e, t, n) {
2573
+ let r = [], i = [], a = e, o = 0;
2574
+ for (; a && a !== n;) {
2575
+ let e = mr(a, t);
2576
+ for (let t of e) t.level = o;
2577
+ if (r.push(e), a = a.parentElement, o++, i.push(...Sr(r)), o >= t.seedMinLength) {
2578
+ i.sort(_r);
2579
+ for (let e of i) yield e;
2580
+ i = [];
2581
+ }
2582
+ }
2583
+ i.sort(_r);
2584
+ for (let e of i) yield e;
2585
+ }
2586
+ function pr(e) {
2587
+ if (/^[a-z\-]{3,}$/i.test(e)) {
2588
+ let t = e.split(/-|[A-Z]/);
2589
+ for (let e of t) if (e.length <= 2 || /[^aeiou]{4,}/i.test(e)) return !1;
2590
+ return !0;
2591
+ }
2592
+ return !1;
2593
+ }
2594
+ function mr(e, t) {
2595
+ let n = [], r = e.getAttribute("id");
2596
+ r && t.idName(r) && n.push({
2597
+ name: "#" + CSS.escape(r),
2598
+ penalty: 0
2599
+ });
2600
+ for (let r = 0; r < e.classList.length; r++) {
2601
+ let i = e.classList[r];
2602
+ t.className(i) && n.push({
2603
+ name: "." + CSS.escape(i),
2604
+ penalty: 1
2605
+ });
2606
+ }
2607
+ for (let r = 0; r < e.attributes.length; r++) {
2608
+ let i = e.attributes[r];
2609
+ t.attr(i.name, i.value) && n.push({
2610
+ name: `[${CSS.escape(i.name)}="${CSS.escape(i.value)}"]`,
2611
+ penalty: 2
2612
+ });
2613
+ }
2614
+ let i = e.tagName.toLowerCase();
2615
+ if (t.tagName(i)) {
2616
+ n.push({
2617
+ name: i,
2618
+ penalty: 5
2619
+ });
2620
+ let t = vr(e, i);
2621
+ t !== void 0 && n.push({
2622
+ name: xr(i, t),
2623
+ penalty: 10
2624
+ });
2625
+ }
2626
+ let a = vr(e);
2627
+ return a !== void 0 && n.push({
2628
+ name: br(i, a),
2629
+ penalty: 50
2630
+ }), n;
2631
+ }
2632
+ function hr(e) {
2633
+ let t = e[0], n = t.name;
2634
+ for (let r = 1; r < e.length; r++) {
2635
+ let i = e[r].level || 0;
2636
+ n = t.level === i - 1 ? `${e[r].name} > ${n}` : `${e[r].name} ${n}`, t = e[r];
2637
+ }
2638
+ return n;
2639
+ }
2640
+ function gr(e) {
2641
+ return e.map((e) => e.penalty).reduce((e, t) => e + t, 0);
2642
+ }
2643
+ function _r(e, t) {
2644
+ return gr(e) - gr(t);
2645
+ }
2646
+ function vr(e, t) {
2647
+ let n = e.parentNode;
2648
+ if (!n) return;
2649
+ let r = n.firstChild;
2650
+ if (!r) return;
2651
+ let i = 0;
2652
+ for (; r && (r.nodeType === Node.ELEMENT_NODE && (t === void 0 || r.tagName.toLowerCase() === t) && i++, r !== e);) r = r.nextSibling;
2653
+ return i;
2654
+ }
2655
+ function yr(e, t) {
2656
+ let n = 0, r = e, i = [];
2657
+ for (; r && r !== t;) {
2658
+ let e = r.tagName.toLowerCase(), t = vr(r, e);
2659
+ if (t === void 0) return;
2660
+ i.push({
2661
+ name: xr(e, t),
2662
+ penalty: NaN,
2663
+ level: n
2664
+ }), r = r.parentElement, n++;
2665
+ }
2666
+ if (wr(i, t)) return i;
2667
+ }
2668
+ function br(e, t) {
2669
+ return e === "html" ? "html" : `${e}:nth-child(${t})`;
2670
+ }
2671
+ function xr(e, t) {
2672
+ return e === "html" ? "html" : `${e}:nth-of-type(${t})`;
2673
+ }
2674
+ function* Sr(e, t = []) {
2675
+ if (e.length > 0) for (let n of e[0]) yield* Sr(e.slice(1, e.length), t.concat(n));
2676
+ else yield t;
2677
+ }
2678
+ function Cr(e, t) {
2679
+ return e.nodeType === Node.DOCUMENT_NODE ? e : e === t.root ? e.ownerDocument : e;
2680
+ }
2681
+ function wr(e, t) {
2682
+ let n = hr(e);
2683
+ switch (t.querySelectorAll(n).length) {
2684
+ case 0: throw Error(`Can't select any node with this selector: ${n}`);
2685
+ case 1: return !0;
2686
+ default: return !1;
2687
+ }
2688
+ }
2689
+ function* Tr(e, t, n, r, i) {
2690
+ if (e.length > 2 && e.length > n.optimizedMinLength) for (let a = 1; a < e.length - 1; a++) {
2691
+ if ((/* @__PURE__ */ new Date()).getTime() - i.getTime() > n.timeoutMs) return;
2692
+ let o = [...e];
2693
+ o.splice(a, 1), wr(o, r) && r.querySelector(hr(o)) === t && (yield o, yield* Tr(o, t, n, r, i));
2694
+ }
2695
+ }
2696
+ //#endregion
2697
+ //#region src/runtime/anchor.ts
2698
+ function Er(e, t) {
2699
+ let n = document.documentElement, r = Math.max(n.scrollWidth, n.clientWidth), i = Math.max(n.scrollHeight, n.clientHeight), a = e.clientX + window.scrollX, o = e.clientY + window.scrollY, s = t === void 0 ? e.target instanceof Element ? e.target : null : t, c = s ? Or(s) : void 0, l, u;
2700
+ if (s) {
2701
+ let t = s.getBoundingClientRect();
2702
+ t.width > 0 && t.height > 0 && (l = Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)), u = Math.max(0, Math.min(1, (e.clientY - t.top) / t.height)));
2703
+ }
2704
+ return {
2705
+ anchorX: r > 0 ? a / r : 0,
2706
+ anchorY: i > 0 ? o / i : 0,
2707
+ viewportW: window.innerWidth,
2708
+ viewportY: window.scrollY,
2709
+ anchorSelector: c,
2710
+ anchorOffsetX: l,
2711
+ anchorOffsetY: u
2712
+ };
2713
+ }
2714
+ function Dr(e) {
2715
+ if (e.anchorSelector) try {
2716
+ let t = document.querySelector(e.anchorSelector);
2717
+ if (t) {
2718
+ let n = t.getBoundingClientRect();
2719
+ return {
2720
+ pageX: n.left + window.scrollX + (e.anchorOffsetX ?? .5) * n.width,
2721
+ pageY: n.top + window.scrollY + (e.anchorOffsetY ?? .5) * n.height
2722
+ };
2723
+ }
2724
+ } catch {}
2725
+ let t = document.documentElement, n = Math.max(t.scrollWidth, t.clientWidth), r = Math.max(t.scrollHeight, t.clientHeight);
2726
+ return {
2727
+ pageX: e.anchorX * n,
2728
+ pageY: e.anchorY * r
2729
+ };
2730
+ }
2731
+ function Or(e) {
2732
+ try {
2733
+ return dr(e, { timeoutMs: 1e3 });
2734
+ } catch {
2735
+ return;
2736
+ }
2737
+ }
2738
+ //#endregion
2739
+ //#region src/runtime/api.ts
2740
+ var kr = class extends Error {
2741
+ status;
2742
+ constructor(e, t) {
2743
+ super(e), this.name = "WidgetApiError", this.status = t;
2744
+ }
2745
+ };
2746
+ function Ar(e) {
2747
+ let t = e.apiUrl.replace(/\/+$/, "");
2748
+ async function n(n, r = {}) {
2749
+ let i = {
2750
+ "content-type": "application/json",
2751
+ "x-markup-api-key": e.apiKey,
2752
+ ...r.headers ?? {}
2753
+ }, a = e.getToken?.() ?? null, o = a != null && a.token.length > 0 && a.expiresAt > Date.now();
2754
+ o && a && (i.authorization = `Bearer ${a.token}`);
2755
+ let s = await fetch(`${t}${n}`, {
2756
+ ...r,
2757
+ headers: i
2758
+ }), c = await s.text(), l = c ? jr(c) : null;
2759
+ if (!s.ok) throw s.status === 401 && o && e.onUnauthorized?.(), new kr((l && typeof l == "object" && "error" in l && typeof l.error == "string" ? l.error : null) ?? `Request failed with ${s.status}`, s.status);
2760
+ return l;
2761
+ }
2762
+ return {
2763
+ getScreenshotUploadUrl() {
2764
+ return n("/widget/screenshots/upload-url", { method: "POST" });
2765
+ },
2766
+ listThreads(e) {
2767
+ return n(`/widget/threads?route=${encodeURIComponent(e)}`, { method: "GET" });
2768
+ },
2769
+ createThread(e) {
2770
+ return n("/widget/threads", {
2771
+ method: "POST",
2772
+ body: JSON.stringify(e)
2773
+ });
2774
+ },
2775
+ deleteThread(e) {
2776
+ return n(`/widget/threads/${encodeURIComponent(e)}`, { method: "DELETE" });
2777
+ },
2778
+ resolveThread(e, t) {
2779
+ return n(`/widget/threads/${encodeURIComponent(e)}`, {
2780
+ method: "PATCH",
2781
+ body: JSON.stringify({ resolvedBy: t })
2782
+ });
2783
+ },
2784
+ addComment(e, t) {
2785
+ return n(`/widget/threads/${encodeURIComponent(e)}/comments`, {
2786
+ method: "POST",
2787
+ body: JSON.stringify(t)
2788
+ });
2789
+ },
2790
+ editComment(e, t, r) {
2791
+ return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, {
2792
+ method: "PATCH",
2793
+ body: JSON.stringify(r)
2794
+ });
2795
+ },
2796
+ deleteComment(e, t, r = {}) {
2797
+ return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, {
2798
+ method: "DELETE",
2799
+ body: JSON.stringify(r)
2800
+ });
2801
+ },
2802
+ toggleReaction(e, t) {
2803
+ return n(`/widget/comments/${encodeURIComponent(e)}/reactions`, {
2804
+ method: "POST",
2805
+ body: JSON.stringify(t)
2806
+ });
2807
+ }
2808
+ };
2809
+ }
2810
+ function jr(e) {
2811
+ try {
2812
+ return JSON.parse(e);
2813
+ } catch {
2814
+ return null;
2815
+ }
2816
+ }
2817
+ //#endregion
2818
+ //#region src/runtime/identity-store.ts
2819
+ var Mr = "markup.identity";
2820
+ function Nr() {
2821
+ try {
2822
+ let e = localStorage.getItem(Mr);
2823
+ if (!e) return null;
2824
+ let t = JSON.parse(e);
2825
+ return typeof t?.clientId == "string" ? t : null;
2826
+ } catch {
2827
+ return null;
2828
+ }
2829
+ }
2830
+ function Pr(e) {
2831
+ try {
2832
+ localStorage.setItem(Mr, JSON.stringify(e));
2833
+ } catch {}
2834
+ }
2835
+ function Fr() {
2836
+ let e = crypto;
2837
+ if ("randomUUID" in e && typeof e.randomUUID == "function") return e.randomUUID();
2838
+ let t = new Uint8Array(16);
2839
+ e.getRandomValues(t), t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128;
2840
+ let n = Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
2841
+ return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
2842
+ }
2843
+ //#endregion
2844
+ //#region src/runtime/popup-auth.ts
2845
+ function Ir(e, t) {
2846
+ let n = new URL(e).origin, r = new URL("/widget/auth", e);
2847
+ r.searchParams.set("apiKey", t), r.searchParams.set("origin", window.location.origin);
2848
+ let i = Math.max(0, window.screenX + (window.outerWidth - 420) / 2), a = Math.max(0, window.screenY + (window.outerHeight - 560) / 2), o = window.open(r.toString(), "markup-auth", `width=420,height=560,left=${i},top=${a}`);
2849
+ return o ? new Promise((e, t) => {
2850
+ function r() {
2851
+ window.removeEventListener("message", i), clearInterval(a);
2852
+ }
2853
+ function i(i) {
2854
+ if (i.origin !== n) return;
2855
+ let a = i.data;
2856
+ a?.type === "MARKUP_AUTH_RESULT" && (r(), a.identity?.id && a.identity?.name ? e({
2857
+ identity: a.identity,
2858
+ token: typeof a.token == "string" ? a.token : null,
2859
+ tokenExpiresAt: typeof a.tokenExpiresAt == "number" ? a.tokenExpiresAt : null
2860
+ }) : t(/* @__PURE__ */ Error("Sign-in cancelled")));
2861
+ }
2862
+ let a = window.setInterval(() => {
2863
+ o.closed && (r(), t(/* @__PURE__ */ Error("Sign-in cancelled")));
2864
+ }, 500);
2865
+ window.addEventListener("message", i);
2866
+ }) : Promise.reject(/* @__PURE__ */ Error("Popup blocked — allow popups for this site to sign in"));
2867
+ }
2868
+ //#endregion
2869
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/util.js
2870
+ function Lr(e, t) {
2871
+ if (e.match(/^[a-z]+:\/\//i)) return e;
2872
+ if (e.match(/^\/\//)) return window.location.protocol + e;
2873
+ if (e.match(/^[a-z]+:/i)) return e;
2874
+ let n = document.implementation.createHTMLDocument(), r = n.createElement("base"), i = n.createElement("a");
2875
+ return n.head.appendChild(r), n.body.appendChild(i), t && (r.href = t), i.href = e, i.href;
2876
+ }
2877
+ var Rr = (() => {
2878
+ let e = 0, t = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
2879
+ return () => (e += 1, `u${t()}${e}`);
2880
+ })();
2881
+ function Y(e) {
2882
+ let t = [];
2883
+ for (let n = 0, r = e.length; n < r; n++) t.push(e[n]);
2884
+ return t;
2885
+ }
2886
+ var zr = null;
2887
+ function Br(e = {}) {
2888
+ return zr || (e.includeStyleProperties ? (zr = e.includeStyleProperties, zr) : (zr = Y(window.getComputedStyle(document.documentElement)), zr));
2889
+ }
2890
+ function Vr(e, t) {
2891
+ let n = (e.ownerDocument.defaultView || window).getComputedStyle(e).getPropertyValue(t);
2892
+ return n ? parseFloat(n.replace("px", "")) : 0;
2893
+ }
2894
+ function Hr(e) {
2895
+ let t = Vr(e, "border-left-width"), n = Vr(e, "border-right-width");
2896
+ return e.clientWidth + t + n;
2897
+ }
2898
+ function Ur(e) {
2899
+ let t = Vr(e, "border-top-width"), n = Vr(e, "border-bottom-width");
2900
+ return e.clientHeight + t + n;
2901
+ }
2902
+ function Wr(e, t = {}) {
2903
+ return {
2904
+ width: t.width || Hr(e),
2905
+ height: t.height || Ur(e)
2906
+ };
2907
+ }
2908
+ function Gr() {
2909
+ let e, t;
2910
+ try {
2911
+ t = process;
2912
+ } catch {}
2913
+ let n = t && t.env ? t.env.devicePixelRatio : null;
2914
+ return n && (e = parseInt(n, 10), Number.isNaN(e) && (e = 1)), e || window.devicePixelRatio || 1;
2915
+ }
2916
+ var X = 16384;
2917
+ function Kr(e) {
2918
+ (e.width > X || e.height > X) && (e.width > X && e.height > X ? e.width > e.height ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X) : e.width > X ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X));
2919
+ }
2920
+ function qr(e) {
2921
+ return new Promise((t, n) => {
2922
+ let r = new Image();
2923
+ r.onload = () => {
2924
+ r.decode().then(() => {
2925
+ requestAnimationFrame(() => t(r));
2926
+ });
2927
+ }, r.onerror = n, r.crossOrigin = "anonymous", r.decoding = "async", r.src = e;
2928
+ });
2929
+ }
2930
+ async function Jr(e) {
2931
+ return Promise.resolve().then(() => new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
2932
+ }
2933
+ async function Yr(e, t, n) {
2934
+ let r = "http://www.w3.org/2000/svg", i = document.createElementNS(r, "svg"), a = document.createElementNS(r, "foreignObject");
2935
+ return i.setAttribute("width", `${t}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${t} ${n}`), a.setAttribute("width", "100%"), a.setAttribute("height", "100%"), a.setAttribute("x", "0"), a.setAttribute("y", "0"), a.setAttribute("externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(e), Jr(i);
2936
+ }
2937
+ var Z = (e, t) => {
2938
+ if (e instanceof t) return !0;
2939
+ let n = Object.getPrototypeOf(e);
2940
+ return n === null ? !1 : n.constructor.name === t.name || Z(n, t);
2941
+ };
2942
+ //#endregion
2943
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-pseudos.js
2944
+ function Xr(e) {
2945
+ let t = e.getPropertyValue("content");
2946
+ return `${e.cssText} content: '${t.replace(/'|"/g, "")}';`;
2947
+ }
2948
+ function Zr(e, t) {
2949
+ return Br(t).map((t) => `${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t) ? " !important" : ""};`).join(" ");
2950
+ }
2951
+ function Qr(e, t, n, r) {
2952
+ let i = `.${e}:${t}`, a = n.cssText ? Xr(n) : Zr(n, r);
2953
+ return document.createTextNode(`${i}{${a}}`);
2954
+ }
2955
+ function $r(e, t, n, r) {
2956
+ let i = window.getComputedStyle(e, n), a = i.getPropertyValue("content");
2957
+ if (a === "" || a === "none") return;
2958
+ let o = Rr();
2959
+ try {
2960
+ t.className = `${t.className} ${o}`;
2961
+ } catch {
2962
+ return;
2963
+ }
2964
+ let s = document.createElement("style");
2965
+ s.appendChild(Qr(o, n, i, r)), t.appendChild(s);
2966
+ }
2967
+ function ei(e, t, n) {
2968
+ $r(e, t, ":before", n), $r(e, t, ":after", n);
2969
+ }
2970
+ //#endregion
2971
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/mimes.js
2972
+ var ti = "application/font-woff", ni = "image/jpeg", ri = {
2973
+ woff: ti,
2974
+ woff2: ti,
2975
+ ttf: "application/font-truetype",
2976
+ eot: "application/vnd.ms-fontobject",
2977
+ png: "image/png",
2978
+ jpg: ni,
2979
+ jpeg: ni,
2980
+ gif: "image/gif",
2981
+ tiff: "image/tiff",
2982
+ svg: "image/svg+xml",
2983
+ webp: "image/webp"
2984
+ };
2985
+ function ii(e) {
2986
+ let t = /\.([^./]*?)$/g.exec(e);
2987
+ return t ? t[1] : "";
2988
+ }
2989
+ function ai(e) {
2990
+ return ri[ii(e).toLowerCase()] || "";
2991
+ }
2992
+ //#endregion
2993
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/dataurl.js
2994
+ function oi(e) {
2995
+ return e.split(/,/)[1];
2996
+ }
2997
+ function si(e) {
2998
+ return e.search(/^(data:)/) !== -1;
2999
+ }
3000
+ function ci(e, t) {
3001
+ return `data:${t};base64,${e}`;
3002
+ }
3003
+ async function li(e, t, n) {
3004
+ let r = await fetch(e, t);
3005
+ if (r.status === 404) throw Error(`Resource "${r.url}" not found`);
3006
+ let i = await r.blob();
3007
+ return new Promise((e, t) => {
3008
+ let a = new FileReader();
3009
+ a.onerror = t, a.onloadend = () => {
3010
+ try {
3011
+ e(n({
3012
+ res: r,
3013
+ result: a.result
3014
+ }));
3015
+ } catch (e) {
3016
+ t(e);
3017
+ }
3018
+ }, a.readAsDataURL(i);
3019
+ });
3020
+ }
3021
+ var ui = {};
3022
+ function di(e, t, n) {
3023
+ let r = e.replace(/\?.*/, "");
3024
+ return n && (r = e), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
3025
+ }
3026
+ async function fi(e, t, n) {
3027
+ let r = di(e, t, n.includeQueryParams);
3028
+ if (ui[r] != null) return ui[r];
3029
+ n.cacheBust && (e += (/\?/.test(e) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
3030
+ let i;
3031
+ try {
3032
+ i = ci(await li(e, n.fetchRequestInit, ({ res: e, result: n }) => (t ||= e.headers.get("Content-Type") || "", oi(n))), t);
3033
+ } catch (t) {
3034
+ i = n.imagePlaceholder || "";
3035
+ let r = `Failed to fetch resource: ${e}`;
3036
+ t && (r = typeof t == "string" ? t : t.message), r && console.warn(r);
3037
+ }
3038
+ return ui[r] = i, i;
3039
+ }
3040
+ //#endregion
3041
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-node.js
3042
+ async function pi(e) {
3043
+ let t = e.toDataURL();
3044
+ return t === "data:," ? e.cloneNode(!1) : qr(t);
3045
+ }
3046
+ async function mi(e, t) {
3047
+ if (e.currentSrc) {
3048
+ let t = document.createElement("canvas"), n = t.getContext("2d");
3049
+ return t.width = e.clientWidth, t.height = e.clientHeight, n?.drawImage(e, 0, 0, t.width, t.height), qr(t.toDataURL());
3050
+ }
3051
+ let n = e.poster;
3052
+ return qr(await fi(n, ai(n), t));
3053
+ }
3054
+ async function hi(e, t) {
3055
+ try {
3056
+ if (e?.contentDocument?.body) return await Ti(e.contentDocument.body, t, !0);
3057
+ } catch {}
3058
+ return e.cloneNode(!1);
3059
+ }
3060
+ async function gi(e, t) {
3061
+ return Z(e, HTMLCanvasElement) ? pi(e) : Z(e, HTMLVideoElement) ? mi(e, t) : Z(e, HTMLIFrameElement) ? hi(e, t) : e.cloneNode(vi(e));
3062
+ }
3063
+ var _i = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT", vi = (e) => e.tagName != null && e.tagName.toUpperCase() === "SVG";
3064
+ async function yi(e, t, n) {
3065
+ if (vi(t)) return t;
3066
+ let r = [];
3067
+ return r = _i(e) && e.assignedNodes ? Y(e.assignedNodes()) : Z(e, HTMLIFrameElement) && e.contentDocument?.body ? Y(e.contentDocument.body.childNodes) : Y((e.shadowRoot ?? e).childNodes), r.length === 0 || Z(e, HTMLVideoElement) || await r.reduce((e, r) => e.then(() => Ti(r, n)).then((e) => {
3068
+ e && t.appendChild(e);
3069
+ }), Promise.resolve()), t;
3070
+ }
3071
+ function bi(e, t, n) {
3072
+ let r = t.style;
3073
+ if (!r) return;
3074
+ let i = window.getComputedStyle(e);
3075
+ i.cssText ? (r.cssText = i.cssText, r.transformOrigin = i.transformOrigin) : Br(n).forEach((n) => {
3076
+ let a = i.getPropertyValue(n);
3077
+ n === "font-size" && a.endsWith("px") && (a = `${Math.floor(parseFloat(a.substring(0, a.length - 2))) - .1}px`), Z(e, HTMLIFrameElement) && n === "display" && a === "inline" && (a = "block"), n === "d" && t.getAttribute("d") && (a = `path(${t.getAttribute("d")})`), r.setProperty(n, a, i.getPropertyPriority(n));
3078
+ });
3079
+ }
3080
+ function xi(e, t) {
3081
+ Z(e, HTMLTextAreaElement) && (t.innerHTML = e.value), Z(e, HTMLInputElement) && t.setAttribute("value", e.value);
3082
+ }
3083
+ function Si(e, t) {
3084
+ if (Z(e, HTMLSelectElement)) {
3085
+ let n = t, r = Array.from(n.children).find((t) => e.value === t.getAttribute("value"));
3086
+ r && r.setAttribute("selected", "");
3087
+ }
3088
+ }
3089
+ function Ci(e, t, n) {
3090
+ return Z(t, Element) && (bi(e, t, n), ei(e, t, n), xi(e, t), Si(e, t)), t;
3091
+ }
3092
+ async function wi(e, t) {
3093
+ let n = e.querySelectorAll ? e.querySelectorAll("use") : [];
3094
+ if (n.length === 0) return e;
3095
+ let r = {};
3096
+ for (let i = 0; i < n.length; i++) {
3097
+ let a = n[i].getAttribute("xlink:href");
3098
+ if (a) {
3099
+ let n = e.querySelector(a), i = document.querySelector(a);
3100
+ !n && i && !r[a] && (r[a] = await Ti(i, t, !0));
3101
+ }
3102
+ }
3103
+ let i = Object.values(r);
3104
+ if (i.length) {
3105
+ let t = "http://www.w3.org/1999/xhtml", n = document.createElementNS(t, "svg");
3106
+ n.setAttribute("xmlns", t), n.style.position = "absolute", n.style.width = "0", n.style.height = "0", n.style.overflow = "hidden", n.style.display = "none";
3107
+ let r = document.createElementNS(t, "defs");
3108
+ n.appendChild(r);
3109
+ for (let e = 0; e < i.length; e++) r.appendChild(i[e]);
3110
+ e.appendChild(n);
3111
+ }
3112
+ return e;
3113
+ }
3114
+ async function Ti(e, t, n) {
3115
+ return !n && t.filter && !t.filter(e) ? null : Promise.resolve(e).then((e) => gi(e, t)).then((n) => yi(e, n, t)).then((n) => Ci(e, n, t)).then((e) => wi(e, t));
3116
+ }
3117
+ //#endregion
3118
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-resources.js
3119
+ var Ei = /url\((['"]?)([^'"]+?)\1\)/g, Di = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, Oi = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
3120
+ function ki(e) {
3121
+ let t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
3122
+ return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
3123
+ }
3124
+ function Ai(e) {
3125
+ let t = [];
3126
+ return e.replace(Ei, (e, n, r) => (t.push(r), e)), t.filter((e) => !si(e));
3127
+ }
3128
+ async function ji(e, t, n, r, i) {
3129
+ try {
3130
+ let a = n ? Lr(t, n) : t, o = ai(t), s;
3131
+ return s = i ? ci(await i(a), o) : await fi(a, o, r), e.replace(ki(t), `$1${s}$3`);
3132
+ } catch {}
3133
+ return e;
3134
+ }
3135
+ function Mi(e, { preferredFontFormat: t }) {
3136
+ return t ? e.replace(Oi, (e) => {
3137
+ for (;;) {
3138
+ let [n, , r] = Di.exec(e) || [];
3139
+ if (!r) return "";
3140
+ if (r === t) return `src: ${n};`;
3141
+ }
3142
+ }) : e;
3143
+ }
3144
+ function Ni(e) {
3145
+ return e.search(Ei) !== -1;
3146
+ }
3147
+ async function Pi(e, t, n) {
3148
+ if (!Ni(e)) return e;
3149
+ let r = Mi(e, n);
3150
+ return Ai(r).reduce((e, r) => e.then((e) => ji(e, r, t, n)), Promise.resolve(r));
3151
+ }
3152
+ //#endregion
3153
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-images.js
3154
+ async function Fi(e, t, n) {
3155
+ let r = t.style?.getPropertyValue(e);
3156
+ if (r) {
3157
+ let i = await Pi(r, null, n);
3158
+ return t.style.setProperty(e, i, t.style.getPropertyPriority(e)), !0;
3159
+ }
3160
+ return !1;
3161
+ }
3162
+ async function Ii(e, t) {
3163
+ await Fi("background", e, t) || await Fi("background-image", e, t), await Fi("mask", e, t) || await Fi("-webkit-mask", e, t) || await Fi("mask-image", e, t) || await Fi("-webkit-mask-image", e, t);
3164
+ }
3165
+ async function Li(e, t) {
3166
+ let n = Z(e, HTMLImageElement);
3167
+ if (!(n && !si(e.src)) && !(Z(e, SVGImageElement) && !si(e.href.baseVal))) return;
3168
+ let r = n ? e.src : e.href.baseVal, i = await fi(r, ai(r), t);
3169
+ await new Promise((r, a) => {
3170
+ e.onload = r, e.onerror = t.onImageErrorHandler ? (...e) => {
3171
+ try {
3172
+ r(t.onImageErrorHandler(...e));
3173
+ } catch (e) {
3174
+ a(e);
3175
+ }
3176
+ } : a;
3177
+ let o = e;
3178
+ o.decode &&= r, o.loading === "lazy" && (o.loading = "eager"), n ? (e.srcset = "", e.src = i) : e.href.baseVal = i;
3179
+ });
3180
+ }
3181
+ async function Ri(e, t) {
3182
+ let n = Y(e.childNodes).map((e) => zi(e, t));
3183
+ await Promise.all(n).then(() => e);
3184
+ }
3185
+ async function zi(e, t) {
3186
+ Z(e, Element) && (await Ii(e, t), await Li(e, t), await Ri(e, t));
3187
+ }
3188
+ //#endregion
3189
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/apply-style.js
3190
+ function Bi(e, t) {
3191
+ let { style: n } = e;
3192
+ t.backgroundColor && (n.backgroundColor = t.backgroundColor), t.width && (n.width = `${t.width}px`), t.height && (n.height = `${t.height}px`);
3193
+ let r = t.style;
3194
+ return r != null && Object.keys(r).forEach((e) => {
3195
+ n[e] = r[e];
3196
+ }), e;
3197
+ }
3198
+ //#endregion
3199
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-webfonts.js
3200
+ var Vi = {};
3201
+ async function Hi(e) {
3202
+ let t = Vi[e];
3203
+ return t ?? (t = {
3204
+ url: e,
3205
+ cssText: await (await fetch(e)).text()
3206
+ }, Vi[e] = t, t);
3207
+ }
3208
+ async function Ui(e, t) {
3209
+ let n = e.cssText, r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (i) => {
3210
+ let a = i.replace(r, "$1");
3211
+ return a.startsWith("https://") || (a = new URL(a, e.url).href), li(a, t.fetchRequestInit, ({ result: e }) => (n = n.replace(i, `url(${e})`), [i, e]));
3212
+ });
3213
+ return Promise.all(i).then(() => n);
3214
+ }
3215
+ function Wi(e) {
3216
+ if (e == null) return [];
3217
+ let t = [], n = e.replace(/(\/\*[\s\S]*?\*\/)/gi, ""), r = /* @__PURE__ */ RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
3218
+ for (;;) {
3219
+ let e = r.exec(n);
3220
+ if (e === null) break;
3221
+ t.push(e[0]);
3222
+ }
3223
+ n = n.replace(r, "");
3224
+ let i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = /* @__PURE__ */ RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
3225
+ for (;;) {
3226
+ let e = i.exec(n);
3227
+ if (e === null) {
3228
+ if (e = a.exec(n), e === null) break;
3229
+ i.lastIndex = a.lastIndex;
3230
+ } else a.lastIndex = i.lastIndex;
3231
+ t.push(e[0]);
3232
+ }
3233
+ return t;
3234
+ }
3235
+ async function Gi(e, t) {
3236
+ let n = [], r = [];
3237
+ return e.forEach((n) => {
3238
+ if ("cssRules" in n) try {
3239
+ Y(n.cssRules || []).forEach((e, i) => {
3240
+ if (e.type === CSSRule.IMPORT_RULE) {
3241
+ let a = i + 1, o = e.href, s = Hi(o).then((e) => Ui(e, t)).then((e) => Wi(e).forEach((e) => {
3242
+ try {
3243
+ n.insertRule(e, e.startsWith("@import") ? a += 1 : n.cssRules.length);
3244
+ } catch (t) {
3245
+ console.error("Error inserting rule from remote css", {
3246
+ rule: e,
3247
+ error: t
3248
+ });
3249
+ }
3250
+ })).catch((e) => {
3251
+ console.error("Error loading remote css", e.toString());
3252
+ });
3253
+ r.push(s);
3254
+ }
3255
+ });
3256
+ } catch (i) {
3257
+ let a = e.find((e) => e.href == null) || document.styleSheets[0];
3258
+ n.href != null && r.push(Hi(n.href).then((e) => Ui(e, t)).then((e) => Wi(e).forEach((e) => {
3259
+ a.insertRule(e, a.cssRules.length);
3260
+ })).catch((e) => {
3261
+ console.error("Error loading remote stylesheet", e);
3262
+ })), console.error("Error inlining remote css file", i);
3263
+ }
3264
+ }), Promise.all(r).then(() => (e.forEach((e) => {
3265
+ if ("cssRules" in e) try {
3266
+ Y(e.cssRules || []).forEach((e) => {
3267
+ n.push(e);
3268
+ });
3269
+ } catch (t) {
3270
+ console.error(`Error while reading CSS rules from ${e.href}`, t);
3271
+ }
3272
+ }), n));
3273
+ }
3274
+ function Ki(e) {
3275
+ return e.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => Ni(e.style.getPropertyValue("src")));
3276
+ }
3277
+ async function qi(e, t) {
3278
+ if (e.ownerDocument == null) throw Error("Provided element is not within a Document");
3279
+ return Ki(await Gi(Y(e.ownerDocument.styleSheets), t));
3280
+ }
3281
+ function Ji(e) {
3282
+ return e.trim().replace(/["']/g, "");
3283
+ }
3284
+ function Yi(e) {
3285
+ let t = /* @__PURE__ */ new Set();
3286
+ function n(e) {
3287
+ (e.style.fontFamily || getComputedStyle(e).fontFamily).split(",").forEach((e) => {
3288
+ t.add(Ji(e));
3289
+ }), Array.from(e.children).forEach((e) => {
3290
+ e instanceof HTMLElement && n(e);
3291
+ });
3292
+ }
3293
+ return n(e), t;
3294
+ }
3295
+ async function Xi(e, t) {
3296
+ let n = await qi(e, t), r = Yi(e);
3297
+ return (await Promise.all(n.filter((e) => r.has(Ji(e.style.fontFamily))).map((e) => {
3298
+ let n = e.parentStyleSheet ? e.parentStyleSheet.href : null;
3299
+ return Pi(e.cssText, n, t);
3300
+ }))).join("\n");
3301
+ }
3302
+ async function Zi(e, t) {
3303
+ let n = t.fontEmbedCSS == null ? t.skipFonts ? null : await Xi(e, t) : t.fontEmbedCSS;
3304
+ if (n) {
3305
+ let t = document.createElement("style"), r = document.createTextNode(n);
3306
+ t.appendChild(r), e.firstChild ? e.insertBefore(t, e.firstChild) : e.appendChild(t);
3307
+ }
3308
+ }
3309
+ //#endregion
3310
+ //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/index.js
3311
+ async function Qi(e, t = {}) {
3312
+ let { width: n, height: r } = Wr(e, t), i = await Ti(e, t, !0);
3313
+ return await Zi(i, t), await zi(i, t), Bi(i, t), await Yr(i, n, r);
3314
+ }
3315
+ async function $i(e, t = {}) {
3316
+ let { width: n, height: r } = Wr(e, t), i = await qr(await Qi(e, t)), a = document.createElement("canvas"), o = a.getContext("2d"), s = t.pixelRatio || Gr(), c = t.canvasWidth || n, l = t.canvasHeight || r;
3317
+ return a.width = c * s, a.height = l * s, t.skipAutoScale || Kr(a), a.style.width = `${c}`, a.style.height = `${l}`, t.backgroundColor && (o.fillStyle = t.backgroundColor, o.fillRect(0, 0, a.width, a.height)), o.drawImage(i, 0, 0, a.width, a.height), a;
3318
+ }
3319
+ //#endregion
3320
+ //#region src/runtime/screenshot.ts
3321
+ var ea = 2 * 1024 * 1024;
3322
+ async function ta(e, t) {
3323
+ try {
3324
+ function n(t) {
3325
+ return !(e && (t === e || e.contains(t)));
3326
+ }
3327
+ let r = window.innerWidth, i = window.innerHeight, a = Math.min(window.devicePixelRatio, 2), o = await $i(document.documentElement, {
3328
+ width: r,
3329
+ height: i,
3330
+ cacheBust: !0,
3331
+ backgroundColor: "#ffffff",
3332
+ pixelRatio: a,
3333
+ filter: n,
3334
+ style: {
3335
+ transform: `translateY(-${window.scrollY}px)`,
3336
+ transformOrigin: "top left"
3337
+ }
3338
+ });
3339
+ if (t) {
3340
+ let e = o.getContext("2d");
3341
+ e && ra(e, t.x, t.y, a);
3342
+ }
3343
+ let s = await na(o, .85);
3344
+ if (!s) return null;
3345
+ if (s.size <= ea) return s;
3346
+ let c = await na(o, .5);
3347
+ return !c || c.size > ea ? null : c;
3348
+ } catch {
3349
+ return null;
3350
+ }
3351
+ }
3352
+ function na(e, t) {
3353
+ return new Promise((n) => e.toBlob(n, "image/jpeg", t));
3354
+ }
3355
+ function ra(e, t, n, r) {
3356
+ let i = r, a = 28 * i, o = a / 2, s = t * i, c = n * i;
3357
+ e.save(), e.translate(s, c), e.rotate(-Math.PI / 4);
3358
+ let l = 2 * i;
3359
+ e.beginPath(), e.roundRect(-o - l, -o - l, a + l * 2, a + l * 2, [
3360
+ 14 * i + l,
3361
+ 14 * i + l,
3362
+ 14 * i + l,
3363
+ 4 * i + l
3364
+ ]), e.fillStyle = "#ffffff", e.fill(), e.beginPath(), e.roundRect(-o, -o, a, a, [
3365
+ 14 * i,
3366
+ 14 * i,
3367
+ 14 * i,
3368
+ 4 * i
3369
+ ]), e.fillStyle = "#1a1614", e.fill(), e.rotate(Math.PI / 4), e.beginPath(), e.arc(0, 0, 3 * i, 0, Math.PI * 2), e.fillStyle = "rgba(255, 255, 255, 0.85)", e.fill(), e.restore();
3370
+ }
3371
+ //#endregion
3372
+ //#region src/runtime/utils.ts
3373
+ function Q(...e) {
3374
+ return e.filter(Boolean).join(" ");
3375
+ }
3376
+ //#endregion
3377
+ //#region ../../node_modules/.pnpm/preact@10.29.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
3378
+ var ia = 0;
3379
+ Array.isArray;
3380
+ function $(e, t, r, i, a, o) {
3381
+ t ||= {};
3382
+ var s, c, l = t;
3383
+ if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
3384
+ var u = {
3385
+ type: e,
3386
+ props: l,
3387
+ key: r,
3388
+ ref: s,
3389
+ __k: null,
3390
+ __: null,
3391
+ __b: 0,
3392
+ __e: null,
3393
+ __c: null,
3394
+ constructor: void 0,
3395
+ __v: --ia,
3396
+ __i: -1,
3397
+ __u: 0,
3398
+ __source: a,
3399
+ __self: o
3400
+ };
3401
+ if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
3402
+ return n.vnode && n.vnode(u), u;
3403
+ }
3404
+ //#endregion
3405
+ //#region src/runtime/ui/icons.tsx
3406
+ function aa({ size: e = 16 }) {
3407
+ return /* @__PURE__ */ $("svg", {
3408
+ width: e,
3409
+ height: e,
3410
+ viewBox: "0 0 126 126",
3411
+ fill: "currentColor",
3412
+ "aria-hidden": !0,
3413
+ children: /* @__PURE__ */ $("path", { d: "M63.4561 0.00557731C70.6277 -0.0175584 76.9025 1.04088 83.5898 3.71066C97.7952 9.43043 109.186 20.5001 115.311 34.5359C119.708 44.8002 120.746 54.7869 119.156 65.8171C116.857 82.7956 105.129 98.8382 90.0566 106.846C83.4394 110.362 74.7336 113.029 67.2051 113.271C62.4204 113.425 61.1274 113.32 56.6807 115.204C50.2035 117.858 43.6874 120.417 37.1348 122.879C34.8442 123.763 32.3203 124.902 29.9404 125.51C29.4023 125.648 28.1978 125.009 27.7598 124.646C26.9046 123.951 27.0582 122.505 27.0264 121.484C26.8123 114.646 27.3302 107.458 26.8604 100.656C25.1578 98.6714 22.4026 96.603 20.3086 94.1989C12.1853 84.8731 7.05334 73.9949 6.18164 61.6101C4.95583 46.292 9.97176 31.1285 20.0908 19.5632C29.989 8.13202 44.0369 1.11921 59.1221 0.0788195C60.2694 -0.0356049 62.2637 0.00944821 63.4561 0.00557731ZM92.2676 55.7497C91.5754 39.5314 77.8207 26.9725 61.6064 27.7536C45.5175 28.5287 33.0758 42.1537 33.7627 58.2468C34.4496 74.3398 48.007 86.8553 64.1035 86.2566C80.3254 85.6533 92.9599 71.968 92.2676 55.7497Z" })
3414
+ });
3415
+ }
3416
+ function oa({ size: e = 16 }) {
3417
+ return /* @__PURE__ */ $("svg", {
3418
+ width: e,
3419
+ height: e,
3420
+ viewBox: "0 0 20 20",
3421
+ fill: "currentColor",
3422
+ children: /* @__PURE__ */ $("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" })
3423
+ });
3424
+ }
3425
+ function sa({ size: e = 16 }) {
3426
+ return /* @__PURE__ */ $("svg", {
3427
+ width: e,
3428
+ height: e,
3429
+ viewBox: "0 0 20 20",
3430
+ fill: "currentColor",
3431
+ children: /* @__PURE__ */ $("path", { d: "M3 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM8.5 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM15.5 8.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z" })
3432
+ });
3433
+ }
3434
+ function ca({ size: e = 16 }) {
3435
+ return /* @__PURE__ */ $("svg", {
3436
+ width: e,
3437
+ height: e,
3438
+ viewBox: "0 0 16 16",
3439
+ fill: "currentColor",
3440
+ children: /* @__PURE__ */ $("path", {
3441
+ fillRule: "evenodd",
3442
+ d: "M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 0 1 1.04-.207Z",
3443
+ clipRule: "evenodd"
3444
+ })
3445
+ });
3446
+ }
3447
+ function la({ size: e = 16 }) {
3448
+ return /* @__PURE__ */ $("svg", {
3449
+ width: e,
3450
+ height: e,
3451
+ viewBox: "0 0 20 20",
3452
+ fill: "currentColor",
3453
+ "aria-hidden": !0,
3454
+ children: /* @__PURE__ */ $("path", {
3455
+ "fill-rule": "evenodd",
3456
+ d: "M1 8a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 8.07 3h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 16.07 6H17a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8Zm13.5 3a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM10 14a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",
3457
+ "clip-rule": "evenodd"
3458
+ })
3459
+ });
3460
+ }
3461
+ function ua({ size: e = 16 }) {
3462
+ return /* @__PURE__ */ $("svg", {
3463
+ width: e,
3464
+ height: e,
3465
+ viewBox: "0 0 16 16",
3466
+ fill: "currentColor",
3467
+ children: /* @__PURE__ */ $("path", { d: "M2.87 2.298a.75.75 0 0 0-.812 1.021L3.39 6.624a1 1 0 0 0 .928.626H8.25a.75.75 0 0 1 0 1.5H4.318a1 1 0 0 0-.927.626l-1.333 3.305a.75.75 0 0 0 .811 1.022 24.89 24.89 0 0 0 11.668-5.115.75.75 0 0 0 0-1.175A24.89 24.89 0 0 0 2.869 2.298Z" })
3468
+ });
3469
+ }
3470
+ function da({ size: e = 16 }) {
3471
+ return /* @__PURE__ */ $("svg", {
3472
+ width: e,
3473
+ height: e,
3474
+ viewBox: "0 0 256 256",
3475
+ fill: "currentColor",
3476
+ "aria-hidden": !0,
3477
+ children: /* @__PURE__ */ $("path", { d: "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM80,108a12,12,0,1,1,12,12A12,12,0,0,1,80,108Zm96,0a12,12,0,1,1-12-12A12,12,0,0,1,176,108Zm-1.07,48c-10.29,17.79-27.4,28-46.93,28s-36.63-10.2-46.92-28a8,8,0,1,1,13.84-8c7.47,12.91,19.21,20,33.08,20s25.61-7.1,33.07-20a8,8,0,0,1,13.86,8Z" })
3478
+ });
3479
+ }
3480
+ //#endregion
3481
+ //#region src/runtime/ui/fab.tsx
3482
+ function fa({ active: e, onToggle: t, onHide: n, position: r = "bottom-right" }) {
3483
+ return /* @__PURE__ */ $("button", {
3484
+ type: "button",
3485
+ class: Q("markup-fab", r === "bottom-left" ? "markup-fab-left" : "markup-fab-right", e && "is-active"),
3486
+ onClick: (e) => {
3487
+ if (e.preventDefault(), e.stopPropagation(), (e.metaKey || e.ctrlKey) && n) {
3488
+ n();
3489
+ return;
3490
+ }
3491
+ t();
3492
+ },
3493
+ onPointerDown: (e) => {
3494
+ e.preventDefault(), e.stopPropagation();
3495
+ },
3496
+ "aria-label": e ? "Cancel placing markup" : "Leave a markup",
3497
+ "aria-pressed": e,
3498
+ children: [/* @__PURE__ */ $("span", {
3499
+ class: "markup-fab-icon",
3500
+ children: $(e ? oa : aa, { size: 16 })
3501
+ }), /* @__PURE__ */ $("span", {
3502
+ class: "markup-fab-label",
3503
+ children: e ? "Cancel" : "Markup"
3504
+ })]
3505
+ });
3506
+ }
3507
+ //#endregion
3508
+ //#region src/runtime/use-focus-trap.ts
3509
+ var pa = [
3510
+ "a[href]",
3511
+ "button:not([disabled])",
3512
+ "input:not([disabled])",
3513
+ "select:not([disabled])",
3514
+ "textarea:not([disabled])",
3515
+ "[tabindex]:not([tabindex=\"-1\"])"
3516
+ ].join(",");
3517
+ function ma(e, t) {
3518
+ R(() => {
3519
+ if (!t) return;
3520
+ let n = e.current;
3521
+ if (!n) return;
3522
+ function r(e) {
3523
+ if (e.key !== "Tab") return;
3524
+ let t = Array.from(n.querySelectorAll(pa)), r = t[0], i = t[t.length - 1];
3525
+ if (!r || !i) return;
3526
+ let a = n.getRootNode(), o = a instanceof ShadowRoot ? a.activeElement : document.activeElement;
3527
+ (e.shiftKey ? o === r : o === i) && (e.preventDefault(), (e.shiftKey ? i : r).focus());
3528
+ }
3529
+ return n.addEventListener("keydown", r), () => n.removeEventListener("keydown", r);
3530
+ }, [e, t]);
3531
+ }
3532
+ //#endregion
3533
+ //#region src/runtime/ui/author-prompt.tsx
3534
+ function ha({ pending: e, onSubmit: t, onCancel: n, onSignIn: r }) {
3535
+ let [i, a] = L(""), [o, s] = L(""), c = z(null);
3536
+ R(() => {
3537
+ c.current?.focus();
3538
+ }, []);
3539
+ function l(n) {
3540
+ n?.preventDefault();
3541
+ let r = i.trim();
3542
+ !r || e || t(r, o.trim() || void 0);
3543
+ }
3544
+ return /* @__PURE__ */ $("form", {
3545
+ class: "markup-author-prompt",
3546
+ onSubmit: l,
3547
+ children: [
3548
+ r ? /* @__PURE__ */ $(C, { children: [/* @__PURE__ */ $("button", {
3549
+ type: "button",
3550
+ class: "markup-btn markup-btn-primary",
3551
+ onClick: r,
3552
+ disabled: e,
3553
+ children: "Sign in with Markup"
3554
+ }), /* @__PURE__ */ $("p", {
3555
+ class: "markup-author-divider",
3556
+ children: "or continue as a guest"
3557
+ })] }) : /* @__PURE__ */ $("p", {
3558
+ class: "markup-eyebrow",
3559
+ children: "who's leaving feedback?"
3560
+ }),
3561
+ /* @__PURE__ */ $("input", {
3562
+ ref: c,
3563
+ class: "markup-input",
3564
+ type: "text",
3565
+ name: "name",
3566
+ placeholder: "Your name",
3567
+ value: i,
3568
+ maxLength: 80,
3569
+ autoComplete: "name",
3570
+ onInput: (e) => a(e.currentTarget.value),
3571
+ disabled: e,
3572
+ "data-1p-ignore": !0
3573
+ }),
3574
+ /* @__PURE__ */ $("input", {
3575
+ class: "markup-input",
3576
+ type: "email",
3577
+ name: "email",
3578
+ placeholder: "Email (optional)",
3579
+ value: o,
3580
+ maxLength: 254,
3581
+ autoComplete: "email",
3582
+ onInput: (e) => s(e.currentTarget.value),
3583
+ disabled: e,
3584
+ "data-1p-ignore": !0
3585
+ }),
3586
+ /* @__PURE__ */ $("div", {
3587
+ class: "markup-composer-actions",
3588
+ children: [/* @__PURE__ */ $("button", {
3589
+ type: "button",
3590
+ class: "markup-btn markup-btn-ghost",
3591
+ onClick: n,
3592
+ disabled: e,
3593
+ children: "Cancel"
3594
+ }), /* @__PURE__ */ $("button", {
3595
+ type: "submit",
3596
+ class: "markup-btn markup-btn-primary",
3597
+ disabled: !i.trim() || e,
3598
+ children: "Continue"
3599
+ })]
3600
+ })
3601
+ ]
3602
+ });
3603
+ }
3604
+ //#endregion
3605
+ //#region src/runtime/ui/composer.tsx
3606
+ var ga = 4e3;
3607
+ function _a({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "Post", initialFocus: r = !0, pending: i, error: a, onSubmit: o }) {
3608
+ let [s, c] = L(""), l = z(null), u = z(!1);
3609
+ R(() => {
3610
+ r && l.current?.focus();
3611
+ }, [r]), R(() => {
3612
+ let e = l.current;
3613
+ e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 160)}px`);
3614
+ }, [s]), R(() => {
3615
+ u.current && !i && !a && (c(""), l.current?.focus()), u.current = i;
3616
+ }, [i, a]);
3617
+ function d(e) {
3618
+ e?.preventDefault();
3619
+ let t = s.trim();
3620
+ !t || i || o(t);
3621
+ }
3622
+ function f(e) {
3623
+ (e.metaKey || e.ctrlKey) && e.key === "Enter" && d(e);
3624
+ }
3625
+ let p = ga - s.length, m = p < 0, h = s.length > 0;
3626
+ function g(e) {
3627
+ return /* @__PURE__ */ $("button", {
3628
+ type: "submit",
3629
+ class: "markup-btn markup-btn-primary",
3630
+ disabled: i || !s.trim() || m,
3631
+ "aria-label": i ? "Sending…" : n,
3632
+ title: i ? "Sending…" : n,
3633
+ tabIndex: e,
3634
+ children: /* @__PURE__ */ $(ua, { size: 14 })
3635
+ });
3636
+ }
3637
+ return /* @__PURE__ */ $("form", {
3638
+ class: Q("markup-composer", h && "is-filled"),
3639
+ onSubmit: d,
3640
+ children: [
3641
+ /* @__PURE__ */ $("textarea", {
3642
+ ref: l,
3643
+ name: "reply",
3644
+ class: "markup-composer-input",
3645
+ placeholder: t,
3646
+ rows: h ? 2 : 1,
3647
+ maxLength: ga + 100,
3648
+ value: s,
3649
+ onInput: (e) => c(e.currentTarget.value),
3650
+ onKeyDown: f,
3651
+ disabled: i,
3652
+ "aria-label": e
3653
+ }),
3654
+ /* @__PURE__ */ $("div", {
3655
+ class: "markup-composer-footer-wrap",
3656
+ children: /* @__PURE__ */ $("div", {
3657
+ class: "markup-composer-footer",
3658
+ children: [/* @__PURE__ */ $("span", {
3659
+ class: "markup-composer-hint",
3660
+ children: a ? /* @__PURE__ */ $("span", {
3661
+ class: "markup-composer-error",
3662
+ children: a
3663
+ }) : m ? /* @__PURE__ */ $("span", {
3664
+ class: "markup-composer-error",
3665
+ children: [Math.abs(p), " too long"]
3666
+ }) : /* @__PURE__ */ $("span", { children: "⌘↵ to send" })
3667
+ }), /* @__PURE__ */ $("div", {
3668
+ class: "markup-composer-actions",
3669
+ children: g(h ? void 0 : -1)
3670
+ })]
3671
+ })
3672
+ }),
3673
+ /* @__PURE__ */ $("span", {
3674
+ class: "markup-composer-actions-empty",
3675
+ "aria-hidden": h || void 0,
3676
+ children: g(h ? -1 : void 0)
3677
+ })
3678
+ ]
3679
+ });
3680
+ }
3681
+ //#endregion
3682
+ //#region src/runtime/ui/new-thread-popover.tsx
3683
+ function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, error: a, screenshot: o, screenshotCapturing: s, onAuthor: c, onSignIn: l, onSubmit: u, onClose: d }) {
3684
+ let f = z(null);
3685
+ ma(f, !0);
3686
+ let [p, m] = L(!1), [h, g] = L(null);
3687
+ R(() => {
3688
+ if (!o) return;
3689
+ let e = URL.createObjectURL(o);
3690
+ return g(e), () => URL.revokeObjectURL(e);
3691
+ }, [o]), R(() => {
3692
+ let e = f.current;
3693
+ if (!e) return;
3694
+ if (typeof e.showPopover == "function" && !e.matches(":popover-open")) try {
3695
+ e.showPopover();
3696
+ } catch {}
3697
+ function t(e) {
3698
+ e.newState === "closed" && d();
3699
+ }
3700
+ return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
3701
+ }, [d]);
3702
+ let _ = ya(e - window.scrollX + 16, 12, window.innerWidth - 320 - 12), v = ya(t - window.scrollY - 16, 12, window.innerHeight - 220), y = o != null, b = s || y;
3703
+ return /* @__PURE__ */ $("div", {
3704
+ ref: f,
3705
+ class: "markup-popover",
3706
+ popover: "auto",
3707
+ style: {
3708
+ "--markup-pop-x": `${_}px`,
3709
+ "--markup-pop-y": `${v}px`
3710
+ },
3711
+ role: "dialog",
3712
+ "aria-label": "New markup",
3713
+ children: [/* @__PURE__ */ $("header", {
3714
+ class: "markup-popover-header",
3715
+ children: [/* @__PURE__ */ $("span", {
3716
+ class: "markup-eyebrow",
3717
+ children: "new · markup"
3718
+ }), /* @__PURE__ */ $("button", {
3719
+ type: "button",
3720
+ class: "markup-icon-btn",
3721
+ "aria-label": "Discard pin",
3722
+ onClick: d,
3723
+ children: /* @__PURE__ */ $(oa, { size: 16 })
3724
+ })]
3725
+ }), n == null ? /* @__PURE__ */ $(ha, {
3726
+ pending: i,
3727
+ onSubmit: c,
3728
+ onCancel: d,
3729
+ onSignIn: l
3730
+ }) : /* @__PURE__ */ $("div", {
3731
+ class: "markup-popover-body",
3732
+ children: [
3733
+ /* @__PURE__ */ $("p", {
3734
+ class: "markup-popover-byline",
3735
+ children: [
3736
+ "posting as ",
3737
+ /* @__PURE__ */ $("span", {
3738
+ class: "markup-popover-name",
3739
+ children: n
3740
+ }),
3741
+ r ? /* @__PURE__ */ $("span", {
3742
+ class: "markup-comment-badge",
3743
+ children: "team"
3744
+ }) : null
3745
+ ]
3746
+ }),
3747
+ /* @__PURE__ */ $(_a, {
3748
+ label: "Feedback",
3749
+ placeholder: "What's wrong, missing, or worth noting?",
3750
+ submitLabel: "Post markup",
3751
+ pending: i,
3752
+ error: a,
3753
+ onSubmit: (e) => u(e, p && y)
3754
+ }),
3755
+ b ? /* @__PURE__ */ $("div", {
3756
+ class: "markup-screenshot-row",
3757
+ children: s ? /* @__PURE__ */ $("span", {
3758
+ class: "markup-screenshot-status",
3759
+ children: [
3760
+ /* @__PURE__ */ $("input", {
3761
+ type: "checkbox",
3762
+ class: "markup-screenshot-checkbox",
3763
+ disabled: !0
3764
+ }),
3765
+ /* @__PURE__ */ $(la, { size: 12 }),
3766
+ /* @__PURE__ */ $("span", { children: "Capturing…" })
3767
+ ]
3768
+ }) : /* @__PURE__ */ $("label", {
3769
+ class: "markup-screenshot-toggle",
3770
+ children: [
3771
+ /* @__PURE__ */ $("input", {
3772
+ type: "checkbox",
3773
+ class: "markup-screenshot-checkbox",
3774
+ checked: p,
3775
+ onChange: (e) => m(e.currentTarget.checked)
3776
+ }),
3777
+ /* @__PURE__ */ $(la, { size: 12 }),
3778
+ /* @__PURE__ */ $("span", { children: "Attach screenshot" }),
3779
+ h && p ? /* @__PURE__ */ $("img", {
3780
+ class: "markup-screenshot-thumb",
3781
+ src: h,
3782
+ alt: "Screenshot preview"
3783
+ }) : null
3784
+ ]
3785
+ })
3786
+ }) : null
3787
+ ]
3788
+ })]
3789
+ });
3790
+ }
3791
+ function ya(e, t, n) {
3792
+ return Math.max(t, Math.min(n, e));
3793
+ }
3794
+ //#endregion
3795
+ //#region src/runtime/ui/pin.tsx
3796
+ function ba({ pageX: e, pageY: t, count: n, active: r, onClick: i }) {
3797
+ let a = t - window.scrollY, o = e - window.scrollX;
3798
+ return /* @__PURE__ */ $("button", {
3799
+ type: "button",
3800
+ class: Q("markup-pin", r && "is-active is-anchor"),
3801
+ style: {
3802
+ top: `${a}px`,
3803
+ left: `${o}px`
3804
+ },
3805
+ popovertarget: "markup-thread-popover",
3806
+ popovertargetaction: "show",
3807
+ onClick: i,
3808
+ "aria-label": `Open feedback thread (${n} comment${n === 1 ? "" : "s"})`,
3809
+ title: `Open feedback thread (${n} comment${n === 1 ? "" : "s"})`,
3810
+ children: [/* @__PURE__ */ $("span", {
3811
+ class: "markup-pin-dot",
3812
+ "aria-hidden": !0
3813
+ }), n > 1 ? /* @__PURE__ */ $("span", {
3814
+ class: "markup-pin-count",
3815
+ children: n
3816
+ }) : null]
3817
+ });
3818
+ }
3819
+ function xa({ pageX: e, pageY: t }) {
3820
+ let n = t - window.scrollY, r = e - window.scrollX;
3821
+ return /* @__PURE__ */ $("div", {
3822
+ class: "markup-pin markup-pin-ghost is-anchor",
3823
+ style: {
3824
+ top: `${n}px`,
3825
+ left: `${r}px`
3826
+ },
3827
+ children: /* @__PURE__ */ $("span", {
3828
+ class: "markup-pin-dot",
3829
+ "aria-hidden": !0
3830
+ })
3831
+ });
3832
+ }
3833
+ //#endregion
3834
+ //#region src/runtime/ui/placement-overlay.tsx
3835
+ function Sa({ onPlace: e, onCancel: t }) {
3836
+ R(() => {
3837
+ function e(e) {
3838
+ e.key === "Escape" && t();
3839
+ }
3840
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
3841
+ }, [t]);
3842
+ function n(t) {
3843
+ t.stopPropagation(), t.preventDefault(), e(Er(t, document.elementsFromPoint(t.clientX, t.clientY).find((e) => !e.shadowRoot) ?? null), t.clientX, t.clientY);
3844
+ }
3845
+ function r(e) {
3846
+ e.preventDefault(), e.stopPropagation();
3847
+ }
3848
+ return /* @__PURE__ */ $("div", {
3849
+ class: "markup-placement-overlay",
3850
+ onPointerDown: r,
3851
+ onClick: n,
3852
+ role: "presentation",
3853
+ children: /* @__PURE__ */ $("div", {
3854
+ class: "markup-placement-cursor-help",
3855
+ children: /* @__PURE__ */ $("span", { children: "Click anywhere to drop a pin · ESC to cancel" })
3856
+ })
3857
+ });
3858
+ }
3859
+ //#endregion
3860
+ //#region src/runtime/ui/thread-popover.tsx
3861
+ var Ca = [
3862
+ "👍",
3863
+ "❤️",
3864
+ "🎉",
3865
+ "😮",
3866
+ "😄",
3867
+ "❓"
3868
+ ];
3869
+ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDelete: i, pending: a, error: o, onAuthor: s, onSignIn: c, onClose: l, onReply: u, onEditComment: d, onDeleteComment: f, onToggleReaction: p, onResolve: m, onDelete: h }) {
3870
+ let g = z(null), _ = z(null), v = z(null), y = z(null), b = z(null), [x, S] = L(!1), [C, w] = L(!1), [T, E] = L(null), [D, O] = L(""), [k, A] = L(null), [ee, j] = L("down"), [M, te] = L(null), [N, ne] = L(null), [re, ie] = L("down"), ae = z(null);
3871
+ ma(g, !0);
3872
+ let oe = e.resolvedAt != null, P = Te(() => e.comments.filter((e) => !e.deleted), [e.comments]);
3873
+ function se(e, t) {
3874
+ E(e), O(t);
3875
+ }
3876
+ function ce() {
3877
+ E(null), O("");
3878
+ }
3879
+ R(() => {
3880
+ if (!T) return;
3881
+ let t = e.comments.find((e) => e._id === T);
3882
+ (!t || t.deleted) && ce();
3883
+ }, [e.comments, T]);
3884
+ let le = z(!0);
3885
+ R(() => {
3886
+ let e = y.current;
3887
+ if (e) {
3888
+ if (le.current) {
3889
+ le.current = !1, e.scrollTop = e.scrollHeight;
3890
+ return;
3891
+ }
3892
+ e.scrollHeight - e.scrollTop - e.clientHeight < 80 && (e.scrollTop = e.scrollHeight);
3893
+ }
3894
+ }, [P.length]), R(() => {
3895
+ if (!x) {
3896
+ w(!1);
3897
+ return;
3898
+ }
3899
+ function e(e) {
3900
+ _.current && !e.composedPath().includes(_.current) && S(!1);
3901
+ }
3902
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3903
+ }, [x]), R(() => {
3904
+ if (!k) {
3905
+ te(null);
3906
+ return;
3907
+ }
3908
+ function e(e) {
3909
+ v.current && !e.composedPath().includes(v.current) && A(null);
3910
+ }
3911
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3912
+ }, [k]), R(() => {
3913
+ if (!N) return;
3914
+ function e(e) {
3915
+ ae.current && !e.composedPath().includes(ae.current) && ne(null);
3916
+ }
3917
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3918
+ }, [N]), R(() => {
3919
+ let e = g.current;
3920
+ if (!e) return;
3921
+ if (typeof e.showPopover == "function" && !e.matches(":popover-open")) try {
3922
+ e.showPopover();
3923
+ } catch {}
3924
+ function t(e) {
3925
+ e.newState === "closed" && l();
3926
+ }
3927
+ return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
3928
+ }, [l]);
3929
+ let ue = Te(() => {
3930
+ let t = Dr({
3931
+ anchorX: e.anchorX,
3932
+ anchorY: e.anchorY,
3933
+ anchorSelector: e.anchorSelector
3934
+ });
3935
+ return {
3936
+ left: Oa(t.pageX - window.scrollX + 16, 12, window.innerWidth - 320 - 12),
3937
+ top: Oa(t.pageY - window.scrollY - 16, 12, window.innerHeight - 200)
3938
+ };
3939
+ }, [
3940
+ e.anchorX,
3941
+ e.anchorY,
3942
+ e.anchorSelector
3943
+ ]);
3944
+ return /* @__PURE__ */ $("div", {
3945
+ ref: g,
3946
+ id: "markup-thread-popover",
3947
+ class: "markup-popover",
3948
+ popover: "auto",
3949
+ style: {
3950
+ "--markup-pop-x": `${ue.left}px`,
3951
+ "--markup-pop-y": `${ue.top}px`
3952
+ },
3953
+ role: "dialog",
3954
+ "aria-label": "Markup thread",
3955
+ children: [
3956
+ /* @__PURE__ */ $("header", {
3957
+ class: "markup-popover-header",
3958
+ children: [/* @__PURE__ */ $("span", {
3959
+ class: "markup-eyebrow",
3960
+ children: [
3961
+ "thread · ",
3962
+ P.length,
3963
+ " ",
3964
+ P.length === 1 ? "comment" : "comments"
3965
+ ]
3966
+ }), /* @__PURE__ */ $("div", {
3967
+ class: "markup-popover-header-actions",
3968
+ children: [
3969
+ /* @__PURE__ */ $("div", {
3970
+ class: "markup-thread-menu",
3971
+ ref: _,
3972
+ children: [/* @__PURE__ */ $("button", {
3973
+ type: "button",
3974
+ class: Q("markup-icon-btn", x && "is-open"),
3975
+ title: "More options",
3976
+ onClick: () => S((e) => !e),
3977
+ children: /* @__PURE__ */ $(sa, { size: 16 })
3978
+ }), x ? /* @__PURE__ */ $("div", {
3979
+ class: "markup-thread-menu-list",
3980
+ children: [/* @__PURE__ */ $("button", {
3981
+ type: "button",
3982
+ class: "markup-thread-menu-item",
3983
+ onClick: () => {
3984
+ let t = new URL(e.url);
3985
+ t.hash = `markup-thread=${e._id}`, navigator.clipboard.writeText(t.toString()).catch(() => {}), S(!1);
3986
+ },
3987
+ children: "Copy link"
3988
+ }), i ? /* @__PURE__ */ $("button", {
3989
+ type: "button",
3990
+ class: Q("markup-thread-menu-item", C && "is-danger"),
3991
+ disabled: a,
3992
+ onClick: () => {
3993
+ C ? (S(!1), h()) : w(!0);
3994
+ },
3995
+ children: C ? "Confirm delete" : "Delete thread…"
3996
+ }) : null]
3997
+ }) : null]
3998
+ }),
3999
+ r ? /* @__PURE__ */ $("button", {
4000
+ type: "button",
4001
+ class: "markup-icon-btn",
4002
+ title: "Mark as resolved",
4003
+ disabled: a,
4004
+ onClick: m,
4005
+ children: /* @__PURE__ */ $(ca, { size: 16 })
4006
+ }) : null,
4007
+ /* @__PURE__ */ $("button", {
4008
+ type: "button",
4009
+ class: "markup-icon-btn",
4010
+ title: "Close thread",
4011
+ onClick: l,
4012
+ children: /* @__PURE__ */ $(oa, { size: 16 })
4013
+ })
4014
+ ]
4015
+ })]
4016
+ }),
4017
+ /* @__PURE__ */ $("ol", {
4018
+ ref: y,
4019
+ class: "markup-comments",
4020
+ children: P.map((t, r) => {
4021
+ let i = !t.fromDashboard && n != null && t.authorClientId === n, o = r === 0, s = i && !oe && !t.deleted, c = i && !oe && !t.deleted && !o, l = T === t._id, u = (s || c) && !l && !t.deleted, m = k === t._id, h = M === t._id;
4022
+ return /* @__PURE__ */ $("li", {
4023
+ class: Q("markup-comment", t.fromDashboard && "is-team"),
4024
+ children: [
4025
+ /* @__PURE__ */ $("div", {
4026
+ class: "markup-comment-meta",
4027
+ children: [
4028
+ /* @__PURE__ */ $("span", {
4029
+ class: "markup-comment-author",
4030
+ children: t.authorName
4031
+ }),
4032
+ t.fromDashboard ? /* @__PURE__ */ $("span", {
4033
+ class: "markup-comment-badge",
4034
+ children: "team"
4035
+ }) : null,
4036
+ /* @__PURE__ */ $("time", {
4037
+ class: "markup-comment-time",
4038
+ datetime: new Date(t.createdAt).toISOString(),
4039
+ title: Aa(t.createdAt),
4040
+ children: ka(t.createdAt)
4041
+ }),
4042
+ /* @__PURE__ */ $("div", {
4043
+ class: "markup-thread-actions",
4044
+ children: [!oe && !l ? /* @__PURE__ */ $(Ta, {
4045
+ comment: t,
4046
+ pickerOpen: N === t._id,
4047
+ pickerDirection: re,
4048
+ pickerRef: (e) => {
4049
+ N === t._id && (ae.current = e);
4050
+ },
4051
+ onPickerClick: (e) => {
4052
+ if (N === t._id) {
4053
+ ne(null);
4054
+ return;
4055
+ }
4056
+ let n = e.currentTarget.getBoundingClientRect(), r = y.current?.getBoundingClientRect();
4057
+ ie((r ? r.bottom - n.bottom : Infinity) < 44 ? "up" : "down"), ne(t._id);
4058
+ },
4059
+ onPickerSelect: (e) => {
4060
+ ne(null), p(t._id, e);
4061
+ }
4062
+ }) : null, u ? /* @__PURE__ */ $("div", {
4063
+ class: Q("markup-thread-menu markup-comment-menu", m && "is-open", m && ee === "up" && "is-up"),
4064
+ ref: (e) => {
4065
+ m && (v.current = e);
4066
+ },
4067
+ children: [/* @__PURE__ */ $("button", {
4068
+ type: "button",
4069
+ class: Q("markup-icon-btn", m && "is-open"),
4070
+ title: "More options",
4071
+ onClick: (e) => {
4072
+ if (k === t._id) {
4073
+ A(null);
4074
+ return;
4075
+ }
4076
+ let n = e.currentTarget.getBoundingClientRect(), r = y.current?.getBoundingClientRect(), i = (+!!s + +!!c) * 32 + 8 + 6;
4077
+ j((r ? r.bottom - n.bottom : Infinity) < i ? "up" : "down"), A(t._id);
4078
+ },
4079
+ children: /* @__PURE__ */ $(sa, { size: 16 })
4080
+ }), m ? /* @__PURE__ */ $("div", {
4081
+ class: "markup-thread-menu-list",
4082
+ children: [s ? /* @__PURE__ */ $("button", {
4083
+ type: "button",
4084
+ class: "markup-thread-menu-item",
4085
+ onClick: () => {
4086
+ A(null), se(t._id, t.body);
4087
+ },
4088
+ children: "Edit"
4089
+ }) : null, c ? /* @__PURE__ */ $("button", {
4090
+ type: "button",
4091
+ class: Q("markup-thread-menu-item", h && "is-danger"),
4092
+ onClick: () => {
4093
+ h ? (A(null), f(t._id)) : te(t._id);
4094
+ },
4095
+ children: h ? "Confirm delete" : "Delete…"
4096
+ }) : null]
4097
+ }) : null]
4098
+ }) : null]
4099
+ })
4100
+ ]
4101
+ }),
4102
+ l ? /* @__PURE__ */ $("form", {
4103
+ class: "markup-comment-edit-form",
4104
+ onSubmit: async (e) => {
4105
+ e.preventDefault();
4106
+ let n = D.trim();
4107
+ if (!n || n === t.body) {
4108
+ ce();
4109
+ return;
4110
+ }
4111
+ try {
4112
+ await d(t._id, n), ce();
4113
+ } catch {}
4114
+ },
4115
+ children: [/* @__PURE__ */ $("textarea", {
4116
+ class: "markup-textarea",
4117
+ value: D,
4118
+ onInput: (e) => O(e.currentTarget.value),
4119
+ rows: 3,
4120
+ autoFocus: !0,
4121
+ disabled: a
4122
+ }), /* @__PURE__ */ $("div", {
4123
+ class: "markup-comment-edit-actions",
4124
+ children: [/* @__PURE__ */ $("button", {
4125
+ type: "button",
4126
+ class: "markup-btn markup-btn-ghost",
4127
+ onClick: ce,
4128
+ disabled: a,
4129
+ children: "Cancel"
4130
+ }), /* @__PURE__ */ $("button", {
4131
+ type: "submit",
4132
+ class: "markup-btn markup-btn-primary",
4133
+ disabled: a || D.trim().length === 0,
4134
+ children: "Save"
4135
+ })]
4136
+ })]
4137
+ }) : /* @__PURE__ */ $("p", {
4138
+ class: "markup-comment-body",
4139
+ children: [t.body, t.editedAt == null ? null : /* @__PURE__ */ $("time", {
4140
+ class: "markup-comment-edited",
4141
+ datetime: new Date(t.editedAt).toISOString(),
4142
+ title: Aa(t.editedAt),
4143
+ children: [" ", "(edited)"]
4144
+ })]
4145
+ }),
4146
+ !l && t.reactions.length > 0 ? /* @__PURE__ */ $(Ea, {
4147
+ comment: t,
4148
+ isResolved: oe,
4149
+ onToggle: (e) => p(t._id, e)
4150
+ }) : null,
4151
+ r === 0 && e.screenshotUrl ? /* @__PURE__ */ $("button", {
4152
+ type: "button",
4153
+ class: "markup-comment-screenshot",
4154
+ onClick: () => b.current?.showModal(),
4155
+ children: /* @__PURE__ */ $("img", {
4156
+ src: e.screenshotUrl,
4157
+ alt: "Screenshot"
4158
+ })
4159
+ }) : null
4160
+ ]
4161
+ }, t._id);
4162
+ })
4163
+ }),
4164
+ e.screenshotUrl ? /* @__PURE__ */ $("dialog", {
4165
+ ref: b,
4166
+ class: "markup-lightbox",
4167
+ onClick: () => b.current?.close(),
4168
+ children: [/* @__PURE__ */ $("button", {
4169
+ type: "button",
4170
+ class: "markup-lightbox-close markup-icon-btn",
4171
+ "aria-label": "Close screenshot",
4172
+ onClick: (e) => {
4173
+ e.stopPropagation(), b.current?.close();
4174
+ },
4175
+ children: /* @__PURE__ */ $(oa, { size: 16 })
4176
+ }), /* @__PURE__ */ $("img", {
4177
+ class: "markup-lightbox-img",
4178
+ src: e.screenshotUrl,
4179
+ alt: "Screenshot",
4180
+ onClick: (e) => e.stopPropagation()
4181
+ })]
4182
+ }) : null,
4183
+ t == null ? /* @__PURE__ */ $(ha, {
4184
+ pending: a,
4185
+ onSubmit: s,
4186
+ onCancel: l,
4187
+ onSignIn: c
4188
+ }) : /* @__PURE__ */ $("div", {
4189
+ class: "markup-popover-body",
4190
+ children: [/* @__PURE__ */ $("p", {
4191
+ class: "markup-popover-byline",
4192
+ children: [
4193
+ "replying as ",
4194
+ /* @__PURE__ */ $("span", {
4195
+ class: "markup-popover-name",
4196
+ children: t
4197
+ }),
4198
+ r ? /* @__PURE__ */ $("span", {
4199
+ class: "markup-comment-badge",
4200
+ children: "team"
4201
+ }) : null
4202
+ ]
4203
+ }), /* @__PURE__ */ $(_a, {
4204
+ label: "Reply",
4205
+ placeholder: "Write a reply…",
4206
+ submitLabel: "Reply",
4207
+ initialFocus: !1,
4208
+ pending: a,
4209
+ error: o,
4210
+ onSubmit: u
4211
+ })]
4212
+ })
4213
+ ]
4214
+ });
4215
+ }
4216
+ function Ta({ comment: e, pickerOpen: t, pickerDirection: n, pickerRef: r, onPickerClick: i, onPickerSelect: a }) {
4217
+ return /* @__PURE__ */ $("div", {
4218
+ class: Q("markup-reaction-picker-wrap", t && "is-open", t && n === "up" && "is-up"),
4219
+ ref: r,
4220
+ children: [/* @__PURE__ */ $("button", {
4221
+ type: "button",
4222
+ class: Q("markup-icon-btn", t && "is-open"),
4223
+ title: "Add reaction",
4224
+ "aria-label": "Add reaction",
4225
+ onClick: i,
4226
+ children: /* @__PURE__ */ $(da, { size: 16 })
4227
+ }), t ? /* @__PURE__ */ $("div", {
4228
+ class: "markup-reaction-picker",
4229
+ role: "menu",
4230
+ children: Ca.map((t) => /* @__PURE__ */ $("button", {
4231
+ type: "button",
4232
+ role: "menuitem",
4233
+ class: Q("markup-reaction-picker-item", (e.reactions.find((e) => e.emoji === t)?.mine ?? !1) && "is-mine"),
4234
+ onClick: () => a(t),
4235
+ children: t
4236
+ }, t))
4237
+ }) : null]
4238
+ });
4239
+ }
4240
+ function Ea({ comment: e, isResolved: t, onToggle: n }) {
4241
+ return /* @__PURE__ */ $("div", {
4242
+ class: "markup-reactions",
4243
+ children: e.reactions.map((e) => {
4244
+ let r = Da(e.reactors, e.mine, e.count, e.emoji);
4245
+ return /* @__PURE__ */ $("button", {
4246
+ type: "button",
4247
+ class: Q("markup-reaction-chip", e.mine && "is-mine"),
4248
+ disabled: t,
4249
+ onClick: () => n(e.emoji),
4250
+ "aria-pressed": e.mine,
4251
+ "aria-label": r,
4252
+ title: r,
4253
+ children: [/* @__PURE__ */ $("span", {
4254
+ class: "markup-reaction-emoji",
4255
+ "aria-hidden": !0,
4256
+ children: e.emoji
4257
+ }), /* @__PURE__ */ $("span", {
4258
+ class: "markup-reaction-count",
4259
+ children: e.count
4260
+ })]
4261
+ }, e.emoji);
4262
+ })
4263
+ });
4264
+ }
4265
+ function Da(e, t, n, r) {
4266
+ let i = e.slice(), a = i.length + +!!t, o = Math.max(0, n - a);
4267
+ return o > 0 && i.push(`${o} other${o === 1 ? "" : "s"}`), t && i.push("you"), i.length === 0 ? `${n} reacted with ${r}` : `${i.length === 1 ? i[0] : `${i.slice(0, -1).join(", ")} and ${i[i.length - 1]}`} reacted with ${r}`;
4268
+ }
4269
+ function Oa(e, t, n) {
4270
+ return Math.max(t, Math.min(n, e));
4271
+ }
4272
+ function ka(e) {
4273
+ let t = Date.now() - e, n = Math.floor(t / 1e3);
4274
+ if (n < 60) return "just now";
4275
+ let r = Math.floor(n / 60);
4276
+ if (r < 60) return `${r} minute${r === 1 ? "" : "s"} ago`;
4277
+ let i = Math.floor(r / 60);
4278
+ if (i < 24) return `${i} hour${i === 1 ? "" : "s"} ago`;
4279
+ let a = Math.floor(i / 24);
4280
+ return a < 30 ? `${a} day${a === 1 ? "" : "s"} ago` : new Date(e).getFullYear() === (/* @__PURE__ */ new Date()).getFullYear() ? new Date(e).toLocaleDateString([], {
4281
+ month: "long",
4282
+ day: "numeric"
4283
+ }) : new Date(e).toLocaleDateString([], {
4284
+ month: "long",
4285
+ day: "numeric",
4286
+ year: "numeric"
4287
+ });
4288
+ }
4289
+ function Aa(e) {
4290
+ return new Date(e).toLocaleDateString([], {
4291
+ month: "long",
4292
+ day: "numeric",
4293
+ year: "numeric",
4294
+ hour: "numeric",
4295
+ minute: "numeric"
4296
+ });
4297
+ }
4298
+ //#endregion
4299
+ //#region src/runtime/ui/app.tsx
4300
+ function ja(e) {
4301
+ return {
4302
+ clientId: `markup_user_${e.identity.id}`,
4303
+ name: e.identity.name,
4304
+ email: e.identity.email,
4305
+ isVerified: !0,
4306
+ token: e.token ?? void 0,
4307
+ tokenExpiresAt: e.tokenExpiresAt ?? void 0
4308
+ };
4309
+ }
4310
+ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4311
+ let [r, i] = L(() => window.location.pathname), [a, o] = L([]), [s, c] = L(null), l = z(null);
4312
+ l.current = s;
4313
+ let u = Te(() => Ar({
4314
+ apiUrl: e,
4315
+ apiKey: t,
4316
+ getToken: () => {
4317
+ let e = l.current;
4318
+ return e?.token && e.tokenExpiresAt ? {
4319
+ token: e.token,
4320
+ expiresAt: e.tokenExpiresAt
4321
+ } : null;
4322
+ },
4323
+ onUnauthorized: () => {
4324
+ let e = l.current;
4325
+ if (!e) return;
4326
+ let t = {
4327
+ clientId: e.clientId,
4328
+ name: e.name,
4329
+ email: e.email
4330
+ };
4331
+ l.current = t, c(t), Pr(t);
4332
+ }
4333
+ }), [e, t]), [d, f] = L({ kind: "idle" }), [p, m] = L(!1), [h, g] = L(null), [_, v] = L(!1), [y, b] = L(!1), [, x] = L(0), S = z(null), C = s?.name ?? null, w = s?.isVerified ?? !1;
4334
+ R(() => {
4335
+ let e = Nr();
4336
+ if (e) {
4337
+ c(e);
4338
+ return;
4339
+ }
4340
+ let t = { clientId: Fr() };
4341
+ Pr(t), c(t);
4342
+ }, []);
4343
+ let [T, E] = L(null);
4344
+ R(() => {
4345
+ Pa(t).then(E).catch(() => {});
4346
+ }, [t]);
4347
+ let D = z(null);
4348
+ R(() => {
4349
+ let t = new ar(e.replace(/\.convex\.site(\/.*)?$/, ".convex.cloud"));
4350
+ return D.current = t, () => {
4351
+ t.close(), D.current = null;
4352
+ };
4353
+ }, [e]);
4354
+ let O = z(!1);
4355
+ R(() => {
4356
+ let e = D.current;
4357
+ if (!(!e || !T)) return O.current = !1, g(null), e.onUpdate(Yt("widget/queries:subscribeThreadsForRoute"), {
4358
+ apiKeyHash: T,
4359
+ route: r,
4360
+ viewerClientId: s?.clientId ?? void 0
4361
+ }, (e) => {
4362
+ e !== void 0 && o(e);
4363
+ });
4364
+ }, [
4365
+ T,
4366
+ r,
4367
+ s?.clientId
4368
+ ]), R(() => {
4369
+ if (O.current) return;
4370
+ let e = window.location.hash.match(/^#markup-thread=(.+)$/);
4371
+ if (!e) {
4372
+ O.current = !0;
4373
+ return;
4374
+ }
4375
+ let t = decodeURIComponent(e[1] ?? "");
4376
+ a.find((e) => e._id === t) && (O.current = !0, f({
4377
+ kind: "thread",
4378
+ threadId: t
4379
+ }), history.replaceState(null, "", window.location.pathname + window.location.search));
4380
+ }, [a]), R(() => {
4381
+ function e() {
4382
+ i(window.location.pathname);
4383
+ }
4384
+ window.addEventListener("popstate", e);
4385
+ let t = history.pushState, n = history.replaceState;
4386
+ return history.pushState = function(...n) {
4387
+ t.apply(this, n), e();
4388
+ }, history.replaceState = function(...t) {
4389
+ n.apply(this, t), e();
4390
+ }, () => {
4391
+ window.removeEventListener("popstate", e), history.pushState = t, history.replaceState = n;
4392
+ };
4393
+ }, []), R(() => {
4394
+ function e(e) {
4395
+ e.key === "." && (e.metaKey || e.ctrlKey) && (e.altKey || e.shiftKey || (e.preventDefault(), v((e) => !e)));
4396
+ }
4397
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
4398
+ }, []), R(() => {
4399
+ if (!y) return;
4400
+ if (!_) {
4401
+ b(!1);
4402
+ return;
4403
+ }
4404
+ let e = window.setTimeout(() => b(!1), 5e3);
4405
+ return () => window.clearTimeout(e);
4406
+ }, [y, _]), R(() => {
4407
+ function e() {
4408
+ x((e) => e + 1);
4409
+ }
4410
+ window.addEventListener("scroll", e, { passive: !0 }), window.addEventListener("resize", e);
4411
+ let t = new ResizeObserver(e);
4412
+ return t.observe(document.body), () => {
4413
+ window.removeEventListener("scroll", e), window.removeEventListener("resize", e), t.disconnect();
4414
+ };
4415
+ }, []);
4416
+ let k = B(() => {
4417
+ g(null), f({ kind: "placing" });
4418
+ }, []), A = B(() => {
4419
+ f({ kind: "idle" }), g(null);
4420
+ }, []), ee = B((e, t, n) => {
4421
+ f({
4422
+ kind: "composing-new",
4423
+ coords: e,
4424
+ pageX: t + window.scrollX,
4425
+ pageY: n + window.scrollY,
4426
+ screenshot: null,
4427
+ screenshotCapturing: !0
4428
+ }), ta(S.current != null && S.current.getRootNode() instanceof ShadowRoot ? S.current.getRootNode().host : null, {
4429
+ x: t,
4430
+ y: n
4431
+ }).then((e) => {
4432
+ f((t) => t.kind === "composing-new" ? {
4433
+ ...t,
4434
+ screenshot: e,
4435
+ screenshotCapturing: !1
4436
+ } : t);
4437
+ });
4438
+ }, []), j = B((e, t) => {
4439
+ let n = {
4440
+ clientId: s?.clientId ?? Fr(),
4441
+ name: e,
4442
+ email: t
4443
+ };
4444
+ Pr(n), c(n);
4445
+ }, [s]), M = B(async () => {
4446
+ g(null);
4447
+ try {
4448
+ let n = ja(await Ir(e, t));
4449
+ Pr(n), c(n);
4450
+ } catch (e) {
4451
+ g(e instanceof Error ? e.message : "Sign-in failed");
4452
+ }
4453
+ }, [e, t]), te = B(async (e, t) => {
4454
+ if (!(d.kind !== "composing-new" || !s?.name)) {
4455
+ m(!0), g(null);
4456
+ try {
4457
+ let n;
4458
+ if (t && d.screenshot) {
4459
+ let { uploadUrl: e } = await u.getScreenshotUploadUrl(), t = await fetch(e, {
4460
+ method: "POST",
4461
+ headers: { "Content-Type": d.screenshot.type || "image/png" },
4462
+ body: d.screenshot
4463
+ });
4464
+ if (t.ok) {
4465
+ let { storageId: e } = await t.json();
4466
+ n = e;
4467
+ }
4468
+ }
4469
+ let i = await u.createThread({
4470
+ url: window.location.href,
4471
+ route: r,
4472
+ anchorSelector: d.coords.anchorSelector,
4473
+ anchorX: d.coords.anchorX,
4474
+ anchorY: d.coords.anchorY,
4475
+ anchorOffsetX: d.coords.anchorOffsetX,
4476
+ anchorOffsetY: d.coords.anchorOffsetY,
4477
+ viewportW: d.coords.viewportW,
4478
+ viewportY: d.coords.viewportY,
4479
+ userAgent: navigator.userAgent,
4480
+ authorName: s.name,
4481
+ authorEmail: s.email,
4482
+ authorClientId: s.clientId,
4483
+ body: e,
4484
+ screenshotStorageId: n
4485
+ });
4486
+ o((e) => [...e, i.thread]), f({
4487
+ kind: "thread",
4488
+ threadId: i.thread._id
4489
+ });
4490
+ } catch (e) {
4491
+ g(e instanceof Error ? e.message : "Failed to post");
4492
+ } finally {
4493
+ m(!1);
4494
+ }
4495
+ }
4496
+ }, [
4497
+ u,
4498
+ s,
4499
+ d,
4500
+ r
4501
+ ]), N = B(async () => {
4502
+ if (d.kind !== "thread") return;
4503
+ let e = d.threadId;
4504
+ m(!0), g(null);
4505
+ try {
4506
+ await u.deleteThread(e), o((t) => t.filter((t) => t._id !== e)), f({ kind: "idle" });
4507
+ } catch (e) {
4508
+ g(e instanceof Error ? e.message : "Failed to delete");
4509
+ } finally {
4510
+ m(!1);
4511
+ }
4512
+ }, [u, d]), ne = B(async () => {
4513
+ if (d.kind !== "thread") return;
4514
+ let e = d.threadId;
4515
+ m(!0), g(null);
4516
+ try {
4517
+ await u.resolveThread(e, s?.clientId), o((t) => t.filter((t) => t._id !== e)), f({ kind: "idle" });
4518
+ } catch (e) {
4519
+ g(e instanceof Error ? e.message : "Failed to resolve");
4520
+ } finally {
4521
+ m(!1);
4522
+ }
4523
+ }, [
4524
+ u,
4525
+ d,
4526
+ s?.clientId
4527
+ ]), re = B(async (e) => {
4528
+ if (d.kind !== "thread" || !s?.name) return;
4529
+ let t = d.threadId;
4530
+ m(!0), g(null);
4531
+ try {
4532
+ let n = await u.addComment(t, {
4533
+ body: e,
4534
+ authorName: s.name,
4535
+ authorEmail: s.email,
4536
+ authorClientId: s.clientId
4537
+ });
4538
+ o((e) => e.map((e) => e._id === t ? n.thread : e));
4539
+ } catch (e) {
4540
+ g(e instanceof Error ? e.message : "Failed to reply");
4541
+ } finally {
4542
+ m(!1);
4543
+ }
4544
+ }, [
4545
+ u,
4546
+ s,
4547
+ d
4548
+ ]), ie = B(async (e, t) => {
4549
+ if (d.kind !== "thread" || !s) return;
4550
+ let n = d.threadId;
4551
+ m(!0), g(null);
4552
+ try {
4553
+ let r = await u.editComment(n, e, {
4554
+ body: t,
4555
+ authorClientId: s.clientId
4556
+ });
4557
+ o((e) => e.map((e) => e._id === n ? r.thread : e));
4558
+ } catch (e) {
4559
+ throw g(e instanceof Error ? e.message : "Failed to edit"), e;
4560
+ } finally {
4561
+ m(!1);
4562
+ }
4563
+ }, [
4564
+ u,
4565
+ s,
4566
+ d
4567
+ ]), ae = B(async (e) => {
4568
+ if (d.kind !== "thread" || !s) return;
4569
+ let t = d.threadId;
4570
+ m(!0), g(null);
4571
+ try {
4572
+ let n = await u.deleteComment(t, e, { authorClientId: s.clientId });
4573
+ o((e) => e.map((e) => e._id === t ? n.thread : e));
4574
+ } catch (e) {
4575
+ g(e instanceof Error ? e.message : "Failed to delete");
4576
+ } finally {
4577
+ m(!1);
4578
+ }
4579
+ }, [
4580
+ u,
4581
+ s,
4582
+ d
4583
+ ]), oe = B(async (e, t) => {
4584
+ if (d.kind !== "thread" || !s) return;
4585
+ let n = d.threadId;
4586
+ g(null);
4587
+ try {
4588
+ let r = await u.toggleReaction(e, {
4589
+ emoji: t,
4590
+ authorClientId: s.clientId,
4591
+ authorName: s.name
4592
+ });
4593
+ o((e) => e.map((e) => e._id === n ? r.thread : e));
4594
+ } catch (e) {
4595
+ g(e instanceof Error ? e.message : "Failed to react");
4596
+ }
4597
+ }, [
4598
+ u,
4599
+ s,
4600
+ d
4601
+ ]), P = d.kind === "thread" ? a.find((e) => e._id === d.threadId) ?? null : null, se = w || s?.clientId != null && s.clientId === P?.authorClientId;
4602
+ return /* @__PURE__ */ $("div", {
4603
+ class: "markup-root",
4604
+ ref: S,
4605
+ children: [
4606
+ d.kind === "placing" ? null : /* @__PURE__ */ $("div", {
4607
+ class: "markup-pins-layer",
4608
+ children: [_ ? null : a.map((e) => {
4609
+ let t = d.kind === "thread" && d.threadId === e._id, n = Dr({
4610
+ anchorX: e.anchorX,
4611
+ anchorY: e.anchorY,
4612
+ anchorSelector: e.anchorSelector,
4613
+ anchorOffsetX: e.anchorOffsetX,
4614
+ anchorOffsetY: e.anchorOffsetY
4615
+ }), r = e.comments.reduce((e, t) => e + +!t.deleted, 0);
4616
+ return /* @__PURE__ */ $(ba, {
4617
+ pageX: n.pageX,
4618
+ pageY: n.pageY,
4619
+ count: r,
4620
+ active: t,
4621
+ onClick: () => f({
4622
+ kind: "thread",
4623
+ threadId: e._id
4624
+ })
4625
+ }, e._id);
4626
+ }), d.kind === "composing-new" ? /* @__PURE__ */ $(xa, {
4627
+ pageX: d.pageX,
4628
+ pageY: d.pageY
4629
+ }) : null]
4630
+ }),
4631
+ d.kind === "placing" ? /* @__PURE__ */ $(Sa, {
4632
+ onPlace: ee,
4633
+ onCancel: A
4634
+ }) : null,
4635
+ d.kind === "thread" && P && !_ ? /* @__PURE__ */ $(wa, {
4636
+ thread: P,
4637
+ authorName: C,
4638
+ currentClientId: s?.clientId ?? null,
4639
+ isVerified: w,
4640
+ canDelete: se,
4641
+ pending: p,
4642
+ error: h,
4643
+ onAuthor: j,
4644
+ onSignIn: M,
4645
+ onClose: A,
4646
+ onReply: re,
4647
+ onEditComment: ie,
4648
+ onDeleteComment: ae,
4649
+ onToggleReaction: oe,
4650
+ onDelete: N,
4651
+ onResolve: ne
4652
+ }) : null,
4653
+ d.kind === "composing-new" ? /* @__PURE__ */ $(va, {
4654
+ pageX: d.pageX,
4655
+ pageY: d.pageY,
4656
+ authorName: C,
4657
+ isVerified: w,
4658
+ pending: p,
4659
+ error: h,
4660
+ screenshot: d.screenshot,
4661
+ screenshotCapturing: d.screenshotCapturing,
4662
+ onAuthor: j,
4663
+ onSignIn: M,
4664
+ onSubmit: te,
4665
+ onClose: A
4666
+ }) : null,
4667
+ !_ || d.kind === "placing" || d.kind === "composing-new" ? /* @__PURE__ */ $(fa, {
4668
+ active: d.kind === "placing",
4669
+ onToggle: () => d.kind === "placing" ? A() : k(),
4670
+ onHide: () => {
4671
+ v(!0), b(!0);
4672
+ },
4673
+ position: n
4674
+ }) : null,
4675
+ _ && y ? /* @__PURE__ */ $(Na, { position: n }) : null
4676
+ ]
4677
+ });
4678
+ }
4679
+ function Na({ position: e }) {
4680
+ let t = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl";
4681
+ return /* @__PURE__ */ $("div", {
4682
+ class: Q("markup-hud-hidden-toast", e === "bottom-left" ? "markup-hud-hidden-toast-left" : "markup-hud-hidden-toast-right"),
4683
+ role: "status",
4684
+ "aria-live": "polite",
4685
+ children: [
4686
+ "Markup hidden — press ",
4687
+ /* @__PURE__ */ $("kbd", {
4688
+ class: "markup-kbd",
4689
+ children: t
4690
+ }),
4691
+ /* @__PURE__ */ $("kbd", {
4692
+ class: "markup-kbd",
4693
+ children: "."
4694
+ }),
4695
+ " or refresh to bring it back."
4696
+ ]
4697
+ });
4698
+ }
4699
+ async function Pa(e) {
4700
+ let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
4701
+ return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
4702
+ }
4703
+ //#endregion
4704
+ //#region src/runtime/mount.tsx
4705
+ function Fa(e, t) {
4706
+ e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "2147483647", e.style.pointerEvents = "none";
4707
+ let n = t.theme ?? "auto";
4708
+ n !== "auto" && (e.dataset.theme = n);
4709
+ let r = e.attachShadow({ mode: "open" }), i = document.createElement("style");
4710
+ i.textContent = de, r.appendChild(i);
4711
+ let a = document.createElement("div");
4712
+ a.className = "markup-shadow-root", r.appendChild(a);
4713
+ let { theme: o, ...s } = t;
4714
+ return ue(/* @__PURE__ */ $(Ma, { ...s }), a), () => ue(null, a);
4715
+ }
4716
+ //#endregion
4717
+ //#region src/widget.ts
4718
+ var Ia = null, La = null;
4719
+ function Ra(e) {
4720
+ za();
4721
+ let t = document.createElement("div");
4722
+ return t.id = "markup-widget", document.body.appendChild(t), La = t, Ia = Fa(t, e), za;
4723
+ }
4724
+ function za() {
4725
+ Ia &&= (Ia(), null), La?.parentNode && La.parentNode.removeChild(La), La = null;
4726
+ }
4727
+ if (typeof document < "u") {
4728
+ let e = document.currentScript ?? document.querySelector("script[data-markup-widget=\"true\"]"), t = e?.dataset.apiUrl, n = e?.dataset.apiKey;
4729
+ if (t && n) {
4730
+ let r = e?.dataset.position, i = e?.dataset.theme, a = () => Ra({
4731
+ apiUrl: t,
4732
+ apiKey: n,
4733
+ position: r,
4734
+ theme: i
4735
+ });
4736
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", a, { once: !0 }) : a();
4737
+ }
4738
+ }
4739
+ //#endregion
4740
+ //#region src/react.tsx
4741
+ function Ba(t) {
4742
+ return e(() => (Ra({
4743
+ apiUrl: t.apiUrl,
4744
+ apiKey: t.apiKey,
4745
+ position: t.position,
4746
+ theme: t.theme
4747
+ }), () => za()), [
4748
+ t.apiUrl,
4749
+ t.apiKey,
4750
+ t.position,
4751
+ t.theme
4752
+ ]), null;
4753
+ }
4754
+ //#endregion
4755
+ export { Ba as MarkupWidget };