@makefully/notefully 0.1.35 → 0.1.37

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/notefully.js CHANGED
@@ -1,14 +1,14 @@
1
- function Le(t, e) {
1
+ function He(t, e) {
2
2
  if (t.match(/^[a-z]+:\/\//i))
3
3
  return t;
4
4
  if (t.match(/^\/\//))
5
5
  return window.location.protocol + t;
6
6
  if (t.match(/^[a-z]+:/i))
7
7
  return t;
8
- const n = document.implementation.createHTMLDocument(), r = n.createElement("base"), o = n.createElement("a");
9
- return n.head.appendChild(r), n.body.appendChild(o), e && (r.href = e), o.href = t, o.href;
8
+ const n = document.implementation.createHTMLDocument(), r = n.createElement("base"), a = n.createElement("a");
9
+ return n.head.appendChild(r), n.body.appendChild(a), e && (r.href = e), a.href = t, a.href;
10
10
  }
11
- const Re = /* @__PURE__ */ (() => {
11
+ const De = /* @__PURE__ */ (() => {
12
12
  let t = 0;
13
13
  const e = () => (
14
14
  // eslint-disable-next-line no-bitwise
@@ -16,33 +16,33 @@ const Re = /* @__PURE__ */ (() => {
16
16
  );
17
17
  return () => (t += 1, `u${e()}${t}`);
18
18
  })();
19
- function F(t) {
19
+ function H(t) {
20
20
  const e = [];
21
21
  for (let n = 0, r = t.length; n < r; n++)
22
22
  e.push(t[n]);
23
23
  return e;
24
24
  }
25
- let V = null;
26
- function Zt(t = {}) {
27
- return V || (t.includeStyleProperties ? (V = t.includeStyleProperties, V) : (V = F(window.getComputedStyle(document.documentElement)), V));
25
+ let q = null;
26
+ function ae(t = {}) {
27
+ return q || (t.includeStyleProperties ? (q = t.includeStyleProperties, q) : (q = H(window.getComputedStyle(document.documentElement)), q));
28
28
  }
29
- function Z(t, e) {
29
+ function rt(t, e) {
30
30
  const r = (t.ownerDocument.defaultView || window).getComputedStyle(t).getPropertyValue(e);
31
31
  return r ? parseFloat(r.replace("px", "")) : 0;
32
32
  }
33
- function $e(t) {
34
- const e = Z(t, "border-left-width"), n = Z(t, "border-right-width");
33
+ function Fe(t) {
34
+ const e = rt(t, "border-left-width"), n = rt(t, "border-right-width");
35
35
  return t.clientWidth + e + n;
36
36
  }
37
- function Pe(t) {
38
- const e = Z(t, "border-top-width"), n = Z(t, "border-bottom-width");
37
+ function Ue(t) {
38
+ const e = rt(t, "border-top-width"), n = rt(t, "border-bottom-width");
39
39
  return t.clientHeight + e + n;
40
40
  }
41
- function te(t, e = {}) {
42
- const n = e.width || $e(t), r = e.height || Pe(t);
41
+ function oe(t, e = {}) {
42
+ const n = e.width || Fe(t), r = e.height || Ue(t);
43
43
  return { width: n, height: r };
44
44
  }
45
- function ke() {
45
+ function Ne() {
46
46
  let t, e;
47
47
  try {
48
48
  e = process;
@@ -51,11 +51,11 @@ function ke() {
51
51
  const n = e && e.env ? e.env.devicePixelRatio : null;
52
52
  return n && (t = parseInt(n, 10), Number.isNaN(t) && (t = 1)), t || window.devicePixelRatio || 1;
53
53
  }
54
- const C = 16384;
55
- function Te(t) {
56
- (t.width > C || t.height > C) && (t.width > C && t.height > C ? t.width > t.height ? (t.height *= C / t.width, t.width = C) : (t.width *= C / t.height, t.height = C) : t.width > C ? (t.height *= C / t.width, t.width = C) : (t.width *= C / t.height, t.height = C));
54
+ const E = 16384;
55
+ function je(t) {
56
+ (t.width > E || t.height > E) && (t.width > E && t.height > E ? t.width > t.height ? (t.height *= E / t.width, t.width = E) : (t.width *= E / t.height, t.height = E) : t.width > E ? (t.height *= E / t.width, t.width = E) : (t.width *= E / t.height, t.height = E));
57
57
  }
58
- function tt(t) {
58
+ function it(t) {
59
59
  return new Promise((e, n) => {
60
60
  const r = new Image();
61
61
  r.onload = () => {
@@ -65,175 +65,175 @@ function tt(t) {
65
65
  }, r.onerror = n, r.crossOrigin = "anonymous", r.decoding = "async", r.src = t;
66
66
  });
67
67
  }
68
- async function Ie(t) {
68
+ async function _e(t) {
69
69
  return Promise.resolve().then(() => new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
70
70
  }
71
- async function Oe(t, e, n) {
72
- const r = "http://www.w3.org/2000/svg", o = document.createElementNS(r, "svg"), i = document.createElementNS(r, "foreignObject");
73
- return o.setAttribute("width", `${e}`), o.setAttribute("height", `${n}`), o.setAttribute("viewBox", `0 0 ${e} ${n}`), i.setAttribute("width", "100%"), i.setAttribute("height", "100%"), i.setAttribute("x", "0"), i.setAttribute("y", "0"), i.setAttribute("externalResourcesRequired", "true"), o.appendChild(i), i.appendChild(t), Ie(o);
71
+ async function Ve(t, e, n) {
72
+ const r = "http://www.w3.org/2000/svg", a = document.createElementNS(r, "svg"), i = document.createElementNS(r, "foreignObject");
73
+ return a.setAttribute("width", `${e}`), a.setAttribute("height", `${n}`), a.setAttribute("viewBox", `0 0 ${e} ${n}`), i.setAttribute("width", "100%"), i.setAttribute("height", "100%"), i.setAttribute("x", "0"), i.setAttribute("y", "0"), i.setAttribute("externalResourcesRequired", "true"), a.appendChild(i), i.appendChild(t), _e(a);
74
74
  }
75
- const E = (t, e) => {
75
+ const x = (t, e) => {
76
76
  if (t instanceof e)
77
77
  return !0;
78
78
  const n = Object.getPrototypeOf(t);
79
- return n === null ? !1 : n.constructor.name === e.name || E(n, e);
79
+ return n === null ? !1 : n.constructor.name === e.name || x(n, e);
80
80
  };
81
- function He(t) {
81
+ function We(t) {
82
82
  const e = t.getPropertyValue("content");
83
83
  return `${t.cssText} content: '${e.replace(/'|"/g, "")}';`;
84
84
  }
85
- function Fe(t, e) {
86
- return Zt(e).map((n) => {
87
- const r = t.getPropertyValue(n), o = t.getPropertyPriority(n);
88
- return `${n}: ${r}${o ? " !important" : ""};`;
85
+ function ze(t, e) {
86
+ return ae(e).map((n) => {
87
+ const r = t.getPropertyValue(n), a = t.getPropertyPriority(n);
88
+ return `${n}: ${r}${a ? " !important" : ""};`;
89
89
  }).join(" ");
90
90
  }
91
- function De(t, e, n, r) {
92
- const o = `.${t}:${e}`, i = n.cssText ? He(n) : Fe(n, r);
93
- return document.createTextNode(`${o}{${i}}`);
91
+ function qe(t, e, n, r) {
92
+ const a = `.${t}:${e}`, i = n.cssText ? We(n) : ze(n, r);
93
+ return document.createTextNode(`${a}{${i}}`);
94
94
  }
95
- function Ot(t, e, n, r) {
96
- const o = window.getComputedStyle(t, n), i = o.getPropertyValue("content");
95
+ function Nt(t, e, n, r) {
96
+ const a = window.getComputedStyle(t, n), i = a.getPropertyValue("content");
97
97
  if (i === "" || i === "none")
98
98
  return;
99
- const a = Re();
99
+ const o = De();
100
100
  try {
101
- e.className = `${e.className} ${a}`;
101
+ e.className = `${e.className} ${o}`;
102
102
  } catch {
103
103
  return;
104
104
  }
105
105
  const c = document.createElement("style");
106
- c.appendChild(De(a, n, o, r)), e.appendChild(c);
106
+ c.appendChild(qe(o, n, a, r)), e.appendChild(c);
107
107
  }
108
- function Be(t, e, n) {
109
- Ot(t, e, ":before", n), Ot(t, e, ":after", n);
108
+ function Ke(t, e, n) {
109
+ Nt(t, e, ":before", n), Nt(t, e, ":after", n);
110
110
  }
111
- const Ht = "application/font-woff", Ft = "image/jpeg", Ue = {
112
- woff: Ht,
113
- woff2: Ht,
111
+ const jt = "application/font-woff", _t = "image/jpeg", Xe = {
112
+ woff: jt,
113
+ woff2: jt,
114
114
  ttf: "application/font-truetype",
115
115
  eot: "application/vnd.ms-fontobject",
116
116
  png: "image/png",
117
- jpg: Ft,
118
- jpeg: Ft,
117
+ jpg: _t,
118
+ jpeg: _t,
119
119
  gif: "image/gif",
120
120
  tiff: "image/tiff",
121
121
  svg: "image/svg+xml",
122
122
  webp: "image/webp"
123
123
  };
124
- function je(t) {
124
+ function Ye(t) {
125
125
  const e = /\.([^./]*?)$/g.exec(t);
126
126
  return e ? e[1] : "";
127
127
  }
128
- function Ct(t) {
129
- const e = je(t).toLowerCase();
130
- return Ue[e] || "";
128
+ function $t(t) {
129
+ const e = Ye(t).toLowerCase();
130
+ return Xe[e] || "";
131
131
  }
132
- function Ne(t) {
132
+ function Ge(t) {
133
133
  return t.split(/,/)[1];
134
134
  }
135
- function mt(t) {
135
+ function vt(t) {
136
136
  return t.search(/^(data:)/) !== -1;
137
137
  }
138
- function _e(t, e) {
138
+ function Je(t, e) {
139
139
  return `data:${e};base64,${t}`;
140
140
  }
141
- async function ee(t, e, n) {
141
+ async function se(t, e, n) {
142
142
  const r = await fetch(t, e);
143
143
  if (r.status === 404)
144
144
  throw new Error(`Resource "${r.url}" not found`);
145
- const o = await r.blob();
146
- return new Promise((i, a) => {
145
+ const a = await r.blob();
146
+ return new Promise((i, o) => {
147
147
  const c = new FileReader();
148
- c.onerror = a, c.onloadend = () => {
148
+ c.onerror = o, c.onloadend = () => {
149
149
  try {
150
150
  i(n({ res: r, result: c.result }));
151
151
  } catch (l) {
152
- a(l);
152
+ o(l);
153
153
  }
154
- }, c.readAsDataURL(o);
154
+ }, c.readAsDataURL(a);
155
155
  });
156
156
  }
157
- const ut = {};
158
- function Ve(t, e, n) {
157
+ const mt = {};
158
+ function Qe(t, e, n) {
159
159
  let r = t.replace(/\?.*/, "");
160
160
  return n && (r = t), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), e ? `[${e}]${r}` : r;
161
161
  }
162
- async function Mt(t, e, n) {
163
- const r = Ve(t, e, n.includeQueryParams);
164
- if (ut[r] != null)
165
- return ut[r];
162
+ async function Tt(t, e, n) {
163
+ const r = Qe(t, e, n.includeQueryParams);
164
+ if (mt[r] != null)
165
+ return mt[r];
166
166
  n.cacheBust && (t += (/\?/.test(t) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
167
- let o;
167
+ let a;
168
168
  try {
169
- const i = await ee(t, n.fetchRequestInit, ({ res: a, result: c }) => (e || (e = a.headers.get("Content-Type") || ""), Ne(c)));
170
- o = _e(i, e);
169
+ const i = await se(t, n.fetchRequestInit, ({ res: o, result: c }) => (e || (e = o.headers.get("Content-Type") || ""), Ge(c)));
170
+ a = Je(i, e);
171
171
  } catch (i) {
172
- o = n.imagePlaceholder || "";
173
- let a = `Failed to fetch resource: ${t}`;
174
- i && (a = typeof i == "string" ? i : i.message), a && console.warn(a);
172
+ a = n.imagePlaceholder || "";
173
+ let o = `Failed to fetch resource: ${t}`;
174
+ i && (o = typeof i == "string" ? i : i.message), o && console.warn(o);
175
175
  }
176
- return ut[r] = o, o;
176
+ return mt[r] = a, a;
177
177
  }
178
- async function ze(t) {
178
+ async function Ze(t) {
179
179
  const e = t.toDataURL();
180
- return e === "data:," ? t.cloneNode(!1) : tt(e);
180
+ return e === "data:," ? t.cloneNode(!1) : it(e);
181
181
  }
182
- async function qe(t, e) {
182
+ async function tn(t, e) {
183
183
  if (t.currentSrc) {
184
- const i = document.createElement("canvas"), a = i.getContext("2d");
185
- i.width = t.clientWidth, i.height = t.clientHeight, a == null || a.drawImage(t, 0, 0, i.width, i.height);
184
+ const i = document.createElement("canvas"), o = i.getContext("2d");
185
+ i.width = t.clientWidth, i.height = t.clientHeight, o == null || o.drawImage(t, 0, 0, i.width, i.height);
186
186
  const c = i.toDataURL();
187
- return tt(c);
187
+ return it(c);
188
188
  }
189
- const n = t.poster, r = Ct(n), o = await Mt(n, r, e);
190
- return tt(o);
189
+ const n = t.poster, r = $t(n), a = await Tt(n, r, e);
190
+ return it(a);
191
191
  }
192
- async function We(t, e) {
192
+ async function en(t, e) {
193
193
  var n;
194
194
  try {
195
195
  if (!((n = t == null ? void 0 : t.contentDocument) === null || n === void 0) && n.body)
196
- return await ot(t.contentDocument.body, e, !0);
196
+ return await ut(t.contentDocument.body, e, !0);
197
197
  } catch {
198
198
  }
199
199
  return t.cloneNode(!1);
200
200
  }
201
- async function Ke(t, e) {
202
- return E(t, HTMLCanvasElement) ? ze(t) : E(t, HTMLVideoElement) ? qe(t, e) : E(t, HTMLIFrameElement) ? We(t, e) : t.cloneNode(ne(t));
201
+ async function nn(t, e) {
202
+ return x(t, HTMLCanvasElement) ? Ze(t) : x(t, HTMLVideoElement) ? tn(t, e) : x(t, HTMLIFrameElement) ? en(t, e) : t.cloneNode(ce(t));
203
203
  }
204
- const Xe = (t) => t.tagName != null && t.tagName.toUpperCase() === "SLOT", ne = (t) => t.tagName != null && t.tagName.toUpperCase() === "SVG";
205
- async function Ye(t, e, n) {
206
- var r, o;
207
- if (ne(e))
204
+ const rn = (t) => t.tagName != null && t.tagName.toUpperCase() === "SLOT", ce = (t) => t.tagName != null && t.tagName.toUpperCase() === "SVG";
205
+ async function an(t, e, n) {
206
+ var r, a;
207
+ if (ce(e))
208
208
  return e;
209
209
  let i = [];
210
- return Xe(t) && t.assignedNodes ? i = F(t.assignedNodes()) : E(t, HTMLIFrameElement) && (!((r = t.contentDocument) === null || r === void 0) && r.body) ? i = F(t.contentDocument.body.childNodes) : i = F(((o = t.shadowRoot) !== null && o !== void 0 ? o : t).childNodes), i.length === 0 || E(t, HTMLVideoElement) || await i.reduce((a, c) => a.then(() => ot(c, n)).then((l) => {
210
+ return rn(t) && t.assignedNodes ? i = H(t.assignedNodes()) : x(t, HTMLIFrameElement) && (!((r = t.contentDocument) === null || r === void 0) && r.body) ? i = H(t.contentDocument.body.childNodes) : i = H(((a = t.shadowRoot) !== null && a !== void 0 ? a : t).childNodes), i.length === 0 || x(t, HTMLVideoElement) || await i.reduce((o, c) => o.then(() => ut(c, n)).then((l) => {
211
211
  l && e.appendChild(l);
212
212
  }), Promise.resolve()), e;
213
213
  }
214
- function Ge(t, e, n) {
214
+ function on(t, e, n) {
215
215
  const r = e.style;
216
216
  if (!r)
217
217
  return;
218
- const o = window.getComputedStyle(t);
219
- o.cssText ? (r.cssText = o.cssText, r.transformOrigin = o.transformOrigin) : Zt(n).forEach((i) => {
220
- let a = o.getPropertyValue(i);
221
- i === "font-size" && a.endsWith("px") && (a = `${Math.floor(parseFloat(a.substring(0, a.length - 2))) - 0.1}px`), E(t, HTMLIFrameElement) && i === "display" && a === "inline" && (a = "block"), i === "d" && e.getAttribute("d") && (a = `path(${e.getAttribute("d")})`), r.setProperty(i, a, o.getPropertyPriority(i));
218
+ const a = window.getComputedStyle(t);
219
+ a.cssText ? (r.cssText = a.cssText, r.transformOrigin = a.transformOrigin) : ae(n).forEach((i) => {
220
+ let o = a.getPropertyValue(i);
221
+ i === "font-size" && o.endsWith("px") && (o = `${Math.floor(parseFloat(o.substring(0, o.length - 2))) - 0.1}px`), x(t, HTMLIFrameElement) && i === "display" && o === "inline" && (o = "block"), i === "d" && e.getAttribute("d") && (o = `path(${e.getAttribute("d")})`), r.setProperty(i, o, a.getPropertyPriority(i));
222
222
  });
223
223
  }
224
- function Je(t, e) {
225
- E(t, HTMLTextAreaElement) && (e.innerHTML = t.value), E(t, HTMLInputElement) && e.setAttribute("value", t.value);
224
+ function sn(t, e) {
225
+ x(t, HTMLTextAreaElement) && (e.innerHTML = t.value), x(t, HTMLInputElement) && e.setAttribute("value", t.value);
226
226
  }
227
- function Qe(t, e) {
228
- if (E(t, HTMLSelectElement)) {
229
- const r = Array.from(e.children).find((o) => t.value === o.getAttribute("value"));
227
+ function cn(t, e) {
228
+ if (x(t, HTMLSelectElement)) {
229
+ const r = Array.from(e.children).find((a) => t.value === a.getAttribute("value"));
230
230
  r && r.setAttribute("selected", "");
231
231
  }
232
232
  }
233
- function Ze(t, e, n) {
234
- return E(e, Element) && (Ge(t, e, n), Be(t, e, n), Je(t, e), Qe(t, e)), e;
233
+ function ln(t, e, n) {
234
+ return x(e, Element) && (on(t, e, n), Ke(t, e, n), sn(t, e), cn(t, e)), e;
235
235
  }
236
- async function tn(t, e) {
236
+ async function un(t, e) {
237
237
  const n = t.querySelectorAll ? t.querySelectorAll("use") : [];
238
238
  if (n.length === 0)
239
239
  return t;
@@ -242,136 +242,136 @@ async function tn(t, e) {
242
242
  const c = n[i].getAttribute("xlink:href");
243
243
  if (c) {
244
244
  const l = t.querySelector(c), u = document.querySelector(c);
245
- !l && u && !r[c] && (r[c] = await ot(u, e, !0));
245
+ !l && u && !r[c] && (r[c] = await ut(u, e, !0));
246
246
  }
247
247
  }
248
- const o = Object.values(r);
249
- if (o.length) {
250
- const i = "http://www.w3.org/1999/xhtml", a = document.createElementNS(i, "svg");
251
- a.setAttribute("xmlns", i), a.style.position = "absolute", a.style.width = "0", a.style.height = "0", a.style.overflow = "hidden", a.style.display = "none";
248
+ const a = Object.values(r);
249
+ if (a.length) {
250
+ const i = "http://www.w3.org/1999/xhtml", o = document.createElementNS(i, "svg");
251
+ o.setAttribute("xmlns", i), o.style.position = "absolute", o.style.width = "0", o.style.height = "0", o.style.overflow = "hidden", o.style.display = "none";
252
252
  const c = document.createElementNS(i, "defs");
253
- a.appendChild(c);
254
- for (let l = 0; l < o.length; l++)
255
- c.appendChild(o[l]);
256
- t.appendChild(a);
253
+ o.appendChild(c);
254
+ for (let l = 0; l < a.length; l++)
255
+ c.appendChild(a[l]);
256
+ t.appendChild(o);
257
257
  }
258
258
  return t;
259
259
  }
260
- async function ot(t, e, n) {
261
- return !n && e.filter && !e.filter(t) ? null : Promise.resolve(t).then((r) => Ke(r, e)).then((r) => Ye(t, r, e)).then((r) => Ze(t, r, e)).then((r) => tn(r, e));
260
+ async function ut(t, e, n) {
261
+ return !n && e.filter && !e.filter(t) ? null : Promise.resolve(t).then((r) => nn(r, e)).then((r) => an(t, r, e)).then((r) => ln(t, r, e)).then((r) => un(r, e));
262
262
  }
263
- const re = /url\((['"]?)([^'"]+?)\1\)/g, en = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, nn = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
264
- function rn(t) {
263
+ const le = /url\((['"]?)([^'"]+?)\1\)/g, dn = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, fn = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
264
+ function hn(t) {
265
265
  const e = t.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
266
266
  return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`, "g");
267
267
  }
268
- function on(t) {
268
+ function pn(t) {
269
269
  const e = [];
270
- return t.replace(re, (n, r, o) => (e.push(o), n)), e.filter((n) => !mt(n));
270
+ return t.replace(le, (n, r, a) => (e.push(a), n)), e.filter((n) => !vt(n));
271
271
  }
272
- async function an(t, e, n, r, o) {
272
+ async function mn(t, e, n, r, a) {
273
273
  try {
274
- const i = n ? Le(e, n) : e, a = Ct(e);
274
+ const i = n ? He(e, n) : e, o = $t(e);
275
275
  let c;
276
- return o || (c = await Mt(i, a, r)), t.replace(rn(e), `$1${c}$3`);
276
+ return a || (c = await Tt(i, o, r)), t.replace(hn(e), `$1${c}$3`);
277
277
  } catch {
278
278
  }
279
279
  return t;
280
280
  }
281
- function sn(t, { preferredFontFormat: e }) {
282
- return e ? t.replace(nn, (n) => {
281
+ function yn(t, { preferredFontFormat: e }) {
282
+ return e ? t.replace(fn, (n) => {
283
283
  for (; ; ) {
284
- const [r, , o] = en.exec(n) || [];
285
- if (!o)
284
+ const [r, , a] = dn.exec(n) || [];
285
+ if (!a)
286
286
  return "";
287
- if (o === e)
287
+ if (a === e)
288
288
  return `src: ${r};`;
289
289
  }
290
290
  }) : t;
291
291
  }
292
- function ie(t) {
293
- return t.search(re) !== -1;
292
+ function ue(t) {
293
+ return t.search(le) !== -1;
294
294
  }
295
- async function oe(t, e, n) {
296
- if (!ie(t))
295
+ async function de(t, e, n) {
296
+ if (!ue(t))
297
297
  return t;
298
- const r = sn(t, n);
299
- return on(r).reduce((i, a) => i.then((c) => an(c, a, e, n)), Promise.resolve(r));
298
+ const r = yn(t, n);
299
+ return pn(r).reduce((i, o) => i.then((c) => mn(c, o, e, n)), Promise.resolve(r));
300
300
  }
301
- async function z(t, e, n) {
301
+ async function K(t, e, n) {
302
302
  var r;
303
- const o = (r = e.style) === null || r === void 0 ? void 0 : r.getPropertyValue(t);
304
- if (o) {
305
- const i = await oe(o, null, n);
303
+ const a = (r = e.style) === null || r === void 0 ? void 0 : r.getPropertyValue(t);
304
+ if (a) {
305
+ const i = await de(a, null, n);
306
306
  return e.style.setProperty(t, i, e.style.getPropertyPriority(t)), !0;
307
307
  }
308
308
  return !1;
309
309
  }
310
- async function cn(t, e) {
311
- await z("background", t, e) || await z("background-image", t, e), await z("mask", t, e) || await z("-webkit-mask", t, e) || await z("mask-image", t, e) || await z("-webkit-mask-image", t, e);
310
+ async function gn(t, e) {
311
+ await K("background", t, e) || await K("background-image", t, e), await K("mask", t, e) || await K("-webkit-mask", t, e) || await K("mask-image", t, e) || await K("-webkit-mask-image", t, e);
312
312
  }
313
- async function ln(t, e) {
314
- const n = E(t, HTMLImageElement);
315
- if (!(n && !mt(t.src)) && !(E(t, SVGImageElement) && !mt(t.href.baseVal)))
313
+ async function wn(t, e) {
314
+ const n = x(t, HTMLImageElement);
315
+ if (!(n && !vt(t.src)) && !(x(t, SVGImageElement) && !vt(t.href.baseVal)))
316
316
  return;
317
- const r = n ? t.src : t.href.baseVal, o = await Mt(r, Ct(r), e);
318
- await new Promise((i, a) => {
317
+ const r = n ? t.src : t.href.baseVal, a = await Tt(r, $t(r), e);
318
+ await new Promise((i, o) => {
319
319
  t.onload = i, t.onerror = e.onImageErrorHandler ? (...l) => {
320
320
  try {
321
321
  i(e.onImageErrorHandler(...l));
322
322
  } catch (u) {
323
- a(u);
323
+ o(u);
324
324
  }
325
- } : a;
325
+ } : o;
326
326
  const c = t;
327
- c.decode && (c.decode = i), c.loading === "lazy" && (c.loading = "eager"), n ? (t.srcset = "", t.src = o) : t.href.baseVal = o;
327
+ c.decode && (c.decode = i), c.loading === "lazy" && (c.loading = "eager"), n ? (t.srcset = "", t.src = a) : t.href.baseVal = a;
328
328
  });
329
329
  }
330
- async function un(t, e) {
331
- const r = F(t.childNodes).map((o) => ae(o, e));
330
+ async function bn(t, e) {
331
+ const r = H(t.childNodes).map((a) => fe(a, e));
332
332
  await Promise.all(r).then(() => t);
333
333
  }
334
- async function ae(t, e) {
335
- E(t, Element) && (await cn(t, e), await ln(t, e), await un(t, e));
334
+ async function fe(t, e) {
335
+ x(t, Element) && (await gn(t, e), await wn(t, e), await bn(t, e));
336
336
  }
337
- function dn(t, e) {
337
+ function Sn(t, e) {
338
338
  const { style: n } = t;
339
339
  e.backgroundColor && (n.backgroundColor = e.backgroundColor), e.width && (n.width = `${e.width}px`), e.height && (n.height = `${e.height}px`);
340
340
  const r = e.style;
341
- return r != null && Object.keys(r).forEach((o) => {
342
- n[o] = r[o];
341
+ return r != null && Object.keys(r).forEach((a) => {
342
+ n[a] = r[a];
343
343
  }), t;
344
344
  }
345
- const Dt = {};
346
- async function Bt(t) {
347
- let e = Dt[t];
345
+ const Vt = {};
346
+ async function Wt(t) {
347
+ let e = Vt[t];
348
348
  if (e != null)
349
349
  return e;
350
350
  const r = await (await fetch(t)).text();
351
- return e = { url: t, cssText: r }, Dt[t] = e, e;
351
+ return e = { url: t, cssText: r }, Vt[t] = e, e;
352
352
  }
353
- async function Ut(t, e) {
353
+ async function zt(t, e) {
354
354
  let n = t.cssText;
355
- const r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (a) => {
356
- let c = a.replace(r, "$1");
357
- return c.startsWith("https://") || (c = new URL(c, t.url).href), ee(c, e.fetchRequestInit, ({ result: l }) => (n = n.replace(a, `url(${l})`), [a, l]));
355
+ const r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (o) => {
356
+ let c = o.replace(r, "$1");
357
+ return c.startsWith("https://") || (c = new URL(c, t.url).href), se(c, e.fetchRequestInit, ({ result: l }) => (n = n.replace(o, `url(${l})`), [o, l]));
358
358
  });
359
359
  return Promise.all(i).then(() => n);
360
360
  }
361
- function jt(t) {
361
+ function qt(t) {
362
362
  if (t == null)
363
363
  return [];
364
364
  const e = [], n = /(\/\*[\s\S]*?\*\/)/gi;
365
365
  let r = t.replace(n, "");
366
- const o = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
366
+ const a = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
367
367
  for (; ; ) {
368
- const l = o.exec(r);
368
+ const l = a.exec(r);
369
369
  if (l === null)
370
370
  break;
371
371
  e.push(l[0]);
372
372
  }
373
- r = r.replace(o, "");
374
- const i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", c = new RegExp(a, "gi");
373
+ r = r.replace(a, "");
374
+ const i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, o = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", c = new RegExp(o, "gi");
375
375
  for (; ; ) {
376
376
  let l = i.exec(r);
377
377
  if (l === null) {
@@ -384,21 +384,21 @@ function jt(t) {
384
384
  }
385
385
  return e;
386
386
  }
387
- async function fn(t, e) {
387
+ async function vn(t, e) {
388
388
  const n = [], r = [];
389
- return t.forEach((o) => {
390
- if ("cssRules" in o)
389
+ return t.forEach((a) => {
390
+ if ("cssRules" in a)
391
391
  try {
392
- F(o.cssRules || []).forEach((i, a) => {
392
+ H(a.cssRules || []).forEach((i, o) => {
393
393
  if (i.type === CSSRule.IMPORT_RULE) {
394
- let c = a + 1;
395
- const l = i.href, u = Bt(l).then((f) => Ut(f, e)).then((f) => jt(f).forEach((p) => {
394
+ let c = o + 1;
395
+ const l = i.href, u = Wt(l).then((f) => zt(f, e)).then((f) => qt(f).forEach((p) => {
396
396
  try {
397
- o.insertRule(p, p.startsWith("@import") ? c += 1 : o.cssRules.length);
398
- } catch (m) {
397
+ a.insertRule(p, p.startsWith("@import") ? c += 1 : a.cssRules.length);
398
+ } catch (y) {
399
399
  console.error("Error inserting rule from remote css", {
400
400
  rule: p,
401
- error: m
401
+ error: y
402
402
  });
403
403
  }
404
404
  })).catch((f) => {
@@ -408,78 +408,78 @@ async function fn(t, e) {
408
408
  }
409
409
  });
410
410
  } catch (i) {
411
- const a = t.find((c) => c.href == null) || document.styleSheets[0];
412
- o.href != null && r.push(Bt(o.href).then((c) => Ut(c, e)).then((c) => jt(c).forEach((l) => {
413
- a.insertRule(l, a.cssRules.length);
411
+ const o = t.find((c) => c.href == null) || document.styleSheets[0];
412
+ a.href != null && r.push(Wt(a.href).then((c) => zt(c, e)).then((c) => qt(c).forEach((l) => {
413
+ o.insertRule(l, o.cssRules.length);
414
414
  })).catch((c) => {
415
415
  console.error("Error loading remote stylesheet", c);
416
416
  })), console.error("Error inlining remote css file", i);
417
417
  }
418
- }), Promise.all(r).then(() => (t.forEach((o) => {
419
- if ("cssRules" in o)
418
+ }), Promise.all(r).then(() => (t.forEach((a) => {
419
+ if ("cssRules" in a)
420
420
  try {
421
- F(o.cssRules || []).forEach((i) => {
421
+ H(a.cssRules || []).forEach((i) => {
422
422
  n.push(i);
423
423
  });
424
424
  } catch (i) {
425
- console.error(`Error while reading CSS rules from ${o.href}`, i);
425
+ console.error(`Error while reading CSS rules from ${a.href}`, i);
426
426
  }
427
427
  }), n));
428
428
  }
429
- function hn(t) {
430
- return t.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => ie(e.style.getPropertyValue("src")));
429
+ function xn(t) {
430
+ return t.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => ue(e.style.getPropertyValue("src")));
431
431
  }
432
- async function pn(t, e) {
432
+ async function En(t, e) {
433
433
  if (t.ownerDocument == null)
434
434
  throw new Error("Provided element is not within a Document");
435
- const n = F(t.ownerDocument.styleSheets), r = await fn(n, e);
436
- return hn(r);
435
+ const n = H(t.ownerDocument.styleSheets), r = await vn(n, e);
436
+ return xn(r);
437
437
  }
438
- function se(t) {
438
+ function he(t) {
439
439
  return t.trim().replace(/["']/g, "");
440
440
  }
441
- function mn(t) {
441
+ function Cn(t) {
442
442
  const e = /* @__PURE__ */ new Set();
443
443
  function n(r) {
444
444
  (r.style.fontFamily || getComputedStyle(r).fontFamily).split(",").forEach((i) => {
445
- e.add(se(i));
445
+ e.add(he(i));
446
446
  }), Array.from(r.children).forEach((i) => {
447
447
  i instanceof HTMLElement && n(i);
448
448
  });
449
449
  }
450
450
  return n(t), e;
451
451
  }
452
- async function yn(t, e) {
453
- const n = await pn(t, e), r = mn(t);
454
- return (await Promise.all(n.filter((i) => r.has(se(i.style.fontFamily))).map((i) => {
455
- const a = i.parentStyleSheet ? i.parentStyleSheet.href : null;
456
- return oe(i.cssText, a, e);
452
+ async function Mn(t, e) {
453
+ const n = await En(t, e), r = Cn(t);
454
+ return (await Promise.all(n.filter((i) => r.has(he(i.style.fontFamily))).map((i) => {
455
+ const o = i.parentStyleSheet ? i.parentStyleSheet.href : null;
456
+ return de(i.cssText, o, e);
457
457
  }))).join(`
458
458
  `);
459
459
  }
460
- async function gn(t, e) {
461
- const n = e.fontEmbedCSS != null ? e.fontEmbedCSS : e.skipFonts ? null : await yn(t, e);
460
+ async function An(t, e) {
461
+ const n = e.fontEmbedCSS != null ? e.fontEmbedCSS : e.skipFonts ? null : await Mn(t, e);
462
462
  if (n) {
463
- const r = document.createElement("style"), o = document.createTextNode(n);
464
- r.appendChild(o), t.firstChild ? t.insertBefore(r, t.firstChild) : t.appendChild(r);
463
+ const r = document.createElement("style"), a = document.createTextNode(n);
464
+ r.appendChild(a), t.firstChild ? t.insertBefore(r, t.firstChild) : t.appendChild(r);
465
465
  }
466
466
  }
467
- async function wn(t, e = {}) {
468
- const { width: n, height: r } = te(t, e), o = await ot(t, e, !0);
469
- return await gn(o, e), await ae(o, e), dn(o, e), await Oe(o, n, r);
467
+ async function Ln(t, e = {}) {
468
+ const { width: n, height: r } = oe(t, e), a = await ut(t, e, !0);
469
+ return await An(a, e), await fe(a, e), Sn(a, e), await Ve(a, n, r);
470
470
  }
471
- async function bn(t, e = {}) {
472
- const { width: n, height: r } = te(t, e), o = await wn(t, e), i = await tt(o), a = document.createElement("canvas"), c = a.getContext("2d"), l = e.pixelRatio || ke(), u = e.canvasWidth || n, f = e.canvasHeight || r;
473
- return a.width = u * l, a.height = f * l, e.skipAutoScale || Te(a), a.style.width = `${u}`, a.style.height = `${f}`, e.backgroundColor && (c.fillStyle = e.backgroundColor, c.fillRect(0, 0, a.width, a.height)), c.drawImage(i, 0, 0, a.width, a.height), a;
471
+ async function Rn(t, e = {}) {
472
+ const { width: n, height: r } = oe(t, e), a = await Ln(t, e), i = await it(a), o = document.createElement("canvas"), c = o.getContext("2d"), l = e.pixelRatio || Ne(), u = e.canvasWidth || n, f = e.canvasHeight || r;
473
+ return o.width = u * l, o.height = f * l, e.skipAutoScale || je(o), o.style.width = `${u}`, o.style.height = `${f}`, e.backgroundColor && (c.fillStyle = e.backgroundColor, c.fillRect(0, 0, o.width, o.height)), c.drawImage(i, 0, 0, o.width, o.height), o;
474
474
  }
475
- async function Nt(t, e = {}) {
476
- return (await bn(t, e)).toDataURL();
475
+ async function Kt(t, e = {}) {
476
+ return (await Rn(t, e)).toDataURL();
477
477
  }
478
- const et = "data-nf-capture-chrome", Sn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";
479
- function vn(t) {
480
- return t instanceof Element && (t.hasAttribute(et) || t.hasAttribute("data-nf-mask-cover") || t.id === "notefully");
478
+ const at = "data-nf-capture-chrome", $n = "data-nf-canvas-snap", Tn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";
479
+ function pe(t) {
480
+ return t instanceof Element && (t.hasAttribute(at) || t.hasAttribute("data-nf-mask-cover") || t.id === "notefully");
481
481
  }
482
- function xn() {
482
+ function Pn() {
483
483
  const t = [];
484
484
  return Array.from(document.styleSheets).forEach((e) => {
485
485
  try {
@@ -503,11 +503,11 @@ function xn() {
503
503
  });
504
504
  };
505
505
  }
506
- function En() {
506
+ function kn() {
507
507
  const t = [];
508
508
  return document.querySelectorAll('input[type="password"], [data-notefully-mask]').forEach((n) => {
509
- const r = n.getBoundingClientRect(), o = document.createElement("div");
510
- o.setAttribute("data-nf-mask-cover", "1"), o.style.cssText = [
509
+ const r = n.getBoundingClientRect(), a = document.createElement("div");
510
+ a.setAttribute("data-nf-mask-cover", "1"), a.style.cssText = [
511
511
  "position:fixed",
512
512
  `left:${r.left}px`,
513
513
  `top:${r.top}px`,
@@ -516,59 +516,185 @@ function En() {
516
516
  "background:#111",
517
517
  "z-index:2147483646",
518
518
  "pointer-events:none"
519
- ].join(";"), document.body.appendChild(o), t.push(o);
519
+ ].join(";"), document.body.appendChild(a), t.push(a);
520
520
  }), () => t.forEach((n) => n.remove());
521
521
  }
522
- function Cn() {
523
- const t = document.querySelector(`[${et}]`);
522
+ function In() {
523
+ const t = document.querySelector(`[${at}]`);
524
524
  if (t)
525
525
  return t;
526
526
  const e = document.createElement("div");
527
- return e.setAttribute(et, "1"), e.className = "nf-capture-chrome", e.setAttribute("role", "status"), e.setAttribute("aria-live", "polite"), e.innerHTML = '<span class="nf-capture-chrome-pill">Capturing…</span>', document.body.appendChild(e), e;
528
- }
529
- function Mn() {
530
- document.querySelectorAll(`[${et}]`).forEach((t) => t.remove());
531
- }
532
- async function An() {
533
- const t = document.getElementById("notefully"), e = t ? t.style.display : "", n = Cn(), r = xn();
534
- t && (t.style.display = "none");
535
- const o = En();
536
- await new Promise((a) => requestAnimationFrame(() => requestAnimationFrame(a)));
537
- const i = {
538
- cacheBust: !0,
539
- pixelRatio: Math.min(window.devicePixelRatio || 1, 2),
540
- filter: (a) => !vn(a),
541
- // 404 / CORS images must not abort the whole capture.
542
- imagePlaceholder: Sn,
543
- onImageErrorHandler: () => {
527
+ return e.setAttribute(at, "1"), e.className = "nf-capture-chrome", e.setAttribute("role", "status"), e.setAttribute("aria-live", "polite"), e.innerHTML = '<span class="nf-capture-chrome-pill">Capturing…</span>', document.body.appendChild(e), e;
528
+ }
529
+ function On() {
530
+ document.querySelectorAll(`[${at}]`).forEach((t) => t.remove());
531
+ }
532
+ function xt() {
533
+ return new Promise((t) => {
534
+ requestAnimationFrame(() => requestAnimationFrame(t));
535
+ });
536
+ }
537
+ function D(t) {
538
+ if (typeof t != "string" || !t.startsWith("data:image/"))
539
+ return !1;
540
+ const e = t.indexOf(",");
541
+ return e > 0 && e < t.length - 1;
542
+ }
543
+ function Bn() {
544
+ const t = document.documentElement, e = document.body, n = Math.max(
545
+ window.innerWidth || 0,
546
+ (t == null ? void 0 : t.clientWidth) || 0,
547
+ (t == null ? void 0 : t.scrollWidth) || 0,
548
+ (e == null ? void 0 : e.scrollWidth) || 0,
549
+ 1
550
+ ), r = Math.max(
551
+ window.innerHeight || 0,
552
+ (t == null ? void 0 : t.clientHeight) || 0,
553
+ (t == null ? void 0 : t.scrollHeight) || 0,
554
+ (e == null ? void 0 : e.scrollHeight) || 0,
555
+ 1
556
+ );
557
+ return { width: n, height: r };
558
+ }
559
+ async function Hn() {
560
+ const t = [], e = Array.from(document.querySelectorAll("canvas"));
561
+ for (const n of e) {
562
+ if (n.closest("#notefully") || pe(n))
563
+ continue;
564
+ let r = "";
565
+ try {
566
+ r = n.toDataURL("image/png");
567
+ } catch {
568
+ continue;
569
+ }
570
+ if (!r || r === "data:,")
571
+ continue;
572
+ const a = document.createElement("img"), i = getComputedStyle(n);
573
+ a.setAttribute($n, "1"), a.alt = "", a.src = r, a.className = n.className, a.style.cssText = n.style.cssText, a.style.width = i.width, a.style.height = i.height, a.style.maxWidth = i.maxWidth, a.style.maxHeight = i.maxHeight, a.style.objectFit = "fill", a.style.display = i.display === "inline" ? "inline-block" : i.display, n.replaceWith(a), t.push({ canvas: n, img: a });
574
+ }
575
+ return await Promise.all(t.map(({ img: n }) => {
576
+ if (!n.complete)
577
+ return new Promise((r) => {
578
+ n.onload = () => r(), n.onerror = () => r();
579
+ });
580
+ })), () => {
581
+ t.forEach(({ canvas: n, img: r }) => {
582
+ try {
583
+ r.parentNode && r.replaceWith(n);
584
+ } catch {
585
+ }
586
+ });
587
+ };
588
+ }
589
+ async function Dn(t) {
590
+ if (!t)
591
+ return null;
592
+ if (typeof t == "string")
593
+ return D(t) ? t : null;
594
+ if (typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement)
595
+ try {
596
+ const e = t.toDataURL("image/png");
597
+ return D(e) ? e : null;
598
+ } catch {
599
+ return null;
544
600
  }
601
+ if (typeof Blob < "u" && t instanceof Blob) {
602
+ const e = await Fn(t);
603
+ return D(e) ? e : null;
604
+ }
605
+ return null;
606
+ }
607
+ async function Fn(t) {
608
+ if (typeof FileReader == "function")
609
+ return new Promise((r, a) => {
610
+ const i = new FileReader();
611
+ i.onload = () => r(String(i.result || "")), i.onerror = () => a(i.error || new Error("Could not read capture blob")), i.readAsDataURL(t);
612
+ });
613
+ const e = Buffer.from(await t.arrayBuffer());
614
+ return `data:${t.type || "application/octet-stream"};base64,${e.toString("base64")}`;
615
+ }
616
+ async function Un() {
617
+ var e;
618
+ if (!((e = navigator.mediaDevices) != null && e.getDisplayMedia))
619
+ throw new Error("Screen capture is not supported in this browser.");
620
+ const t = await navigator.mediaDevices.getDisplayMedia({
621
+ video: { displaySurface: "browser" },
622
+ audio: !1,
623
+ preferCurrentTab: !0,
624
+ selfBrowserSurface: "include"
625
+ });
626
+ try {
627
+ const n = document.createElement("video");
628
+ n.muted = !0, n.playsInline = !0, n.srcObject = t, await n.play(), n.videoWidth || await new Promise((c) => {
629
+ n.onloadedmetadata = () => c();
630
+ }), await xt();
631
+ const r = n.videoWidth || 1, a = n.videoHeight || 1, i = document.createElement("canvas");
632
+ i.width = r, i.height = a, i.getContext("2d").drawImage(n, 0, 0, r, a);
633
+ const o = i.toDataURL("image/png");
634
+ if (!D(o))
635
+ throw new Error("Screen capture produced an empty image.");
636
+ return o;
637
+ } finally {
638
+ t.getTracks().forEach((n) => n.stop());
639
+ }
640
+ }
641
+ async function me(t = {}) {
642
+ const e = document.getElementById("notefully"), n = e ? e.style.display : "", r = In(), a = Pn();
643
+ let i = () => {
545
644
  };
645
+ e && (e.style.display = "none");
646
+ const o = kn();
546
647
  try {
648
+ if (typeof t.onBeforeCapture == "function" && await t.onBeforeCapture(), await xt(), typeof t.capture == "function") {
649
+ const p = await Dn(await t.capture());
650
+ if (p)
651
+ return p;
652
+ }
653
+ i = await Hn(), await xt();
654
+ const { width: c, height: l } = Bn(), u = {
655
+ cacheBust: !0,
656
+ width: c,
657
+ height: l,
658
+ pixelRatio: Math.min(window.devicePixelRatio || 1, 2),
659
+ filter: (p) => !pe(p),
660
+ // 404 / CORS images must not abort the whole capture.
661
+ imagePlaceholder: Tn,
662
+ onImageErrorHandler: () => {
663
+ }
664
+ };
665
+ let f = "";
547
666
  try {
548
- return await Nt(document.body, i);
667
+ f = await Kt(document.body, u);
549
668
  } catch {
550
- return await Nt(document.body, { ...i, skipFonts: !0 });
669
+ f = await Kt(document.body, { ...u, skipFonts: !0 });
551
670
  }
671
+ if (!D(f))
672
+ throw new Error("Screenshot capture produced an empty image.");
673
+ return f;
552
674
  } finally {
553
- o(), r(), n.remove(), Mn(), t && (t.style.display = e);
675
+ try {
676
+ i();
677
+ } catch {
678
+ }
679
+ o(), a(), r.remove(), On(), e && (e.style.display = n);
554
680
  }
555
681
  }
556
- function Ln(t = "") {
682
+ function Nn(t = "") {
557
683
  const e = String(t || "");
558
684
  return e ? /Windows NT/i.test(e) ? "Windows" : /iPhone|iPad|iPod/i.test(e) ? "iOS" : /Mac OS X|Macintosh/i.test(e) ? "macOS" : /Android/i.test(e) ? "Android" : /CrOS/i.test(e) ? "ChromeOS" : /Linux/i.test(e) ? "Linux" : "Other" : "";
559
685
  }
560
- function Rn(t = "") {
686
+ function jn(t = "") {
561
687
  const e = String(t || "");
562
688
  return e ? /Edg\//i.test(e) ? "Edge" : /OPR\/|Opera/i.test(e) ? "Opera" : /Firefox\//i.test(e) ? "Firefox" : /Chrome\//i.test(e) || /CriOS\//i.test(e) ? "Chrome" : /Safari\//i.test(e) ? "Safari" : "Other" : "";
563
689
  }
564
- function $n(t = {}) {
690
+ function _n(t = {}) {
565
691
  const e = navigator.userAgent;
566
692
  return {
567
693
  url: location.href,
568
694
  title: document.title,
569
695
  userAgent: e,
570
- os: Ln(e),
571
- browser: Rn(e),
696
+ os: Nn(e),
697
+ browser: jn(e),
572
698
  language: navigator.language,
573
699
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
574
700
  viewport: {
@@ -583,11 +709,11 @@ function $n(t = {}) {
583
709
  }
584
710
  };
585
711
  }
586
- const _t = /* @__PURE__ */ new Set(["userId", "email", "displayName"]), Vt = {
712
+ const Xt = /* @__PURE__ */ new Set(["userId", "email", "displayName"]), Yt = {
587
713
  id: "userId",
588
714
  username: "displayName",
589
715
  name: "displayName"
590
- }, zt = /* @__PURE__ */ new Set([
716
+ }, Gt = /* @__PURE__ */ new Set([
591
717
  "endpoint",
592
718
  "projectKey",
593
719
  "version",
@@ -597,8 +723,10 @@ const _t = /* @__PURE__ */ new Set(["userId", "email", "displayName"]), Vt = {
597
723
  "theme",
598
724
  "video",
599
725
  "consoleLogLimit",
600
- "kinds"
601
- ]), qt = {
726
+ "kinds",
727
+ "capture",
728
+ "onBeforeCapture"
729
+ ]), Jt = {
602
730
  slug: "Use init({ name }) for a per-app report prefix (same idea as package.json name). slug is not a widget option.",
603
731
  projectSlug: "Use init({ name }) for a per-app report prefix. projectSlug is not a widget option.",
604
732
  project: "Pass projectKey (nfk_…) from Showfully Notefully settings — there is no project option on the widget.",
@@ -607,60 +735,60 @@ const _t = /* @__PURE__ */ new Set(["userId", "email", "displayName"]), Vt = {
607
735
  email: "Pass people via Notefully.identify({ userId, email, displayName }), not init().",
608
736
  displayName: "Pass people via Notefully.identify({ userId, email, displayName }), not init()."
609
737
  };
610
- function Pn(t = {}, e = {}) {
611
- const n = e.warn || ce, r = t && typeof t == "object" ? t : {}, o = {}, i = [];
612
- for (const a of _t)
613
- Object.prototype.hasOwnProperty.call(r, a) && (o[a] = r[a]);
614
- for (const [a, c] of Object.entries(Vt))
615
- Object.prototype.hasOwnProperty.call(r, a) && (Object.prototype.hasOwnProperty.call(o, c) || (o[c] = r[a]));
616
- for (const a of Object.keys(r))
617
- _t.has(a) || Object.prototype.hasOwnProperty.call(Vt, a) || i.push(a);
738
+ function Vn(t = {}, e = {}) {
739
+ const n = e.warn || ye, r = t && typeof t == "object" ? t : {}, a = {}, i = [];
740
+ for (const o of Xt)
741
+ Object.prototype.hasOwnProperty.call(r, o) && (a[o] = r[o]);
742
+ for (const [o, c] of Object.entries(Yt))
743
+ Object.prototype.hasOwnProperty.call(r, o) && (Object.prototype.hasOwnProperty.call(a, c) || (a[c] = r[o]));
744
+ for (const o of Object.keys(r))
745
+ Xt.has(o) || Object.prototype.hasOwnProperty.call(Yt, o) || i.push(o);
618
746
  if (i.length) {
619
- const a = i.some((c) => c === "name" || c === "slug" || c === "projectSlug") ? " Pass the package/report name via Notefully.init({ name }), not identify()." : "";
747
+ const o = i.some((c) => c === "name" || c === "slug" || c === "projectSlug") ? " Pass the package/report name via Notefully.init({ name }), not identify()." : "";
620
748
  n(
621
- `Notefully.identify: ignoring unknown key(s): ${i.join(", ")}. Supported: userId, email, displayName (aliases: id → userId; username/name → displayName).` + a
749
+ `Notefully.identify: ignoring unknown key(s): ${i.join(", ")}. Supported: userId, email, displayName (aliases: id → userId; username/name → displayName).` + o
622
750
  );
623
751
  }
624
- return o;
625
- }
626
- function kn(t = {}, e = {}) {
627
- const n = e.warn || ce, r = t && typeof t == "object" ? t : {}, o = Object.keys(r).filter((i) => !zt.has(i));
628
- if (o.length)
629
- for (const i of o) {
630
- if (qt[i]) {
631
- n(`Notefully.init: ignoring "${i}". ${qt[i]}`);
752
+ return a;
753
+ }
754
+ function Wn(t = {}, e = {}) {
755
+ const n = e.warn || ye, r = t && typeof t == "object" ? t : {}, a = Object.keys(r).filter((i) => !Gt.has(i));
756
+ if (a.length)
757
+ for (const i of a) {
758
+ if (Jt[i]) {
759
+ n(`Notefully.init: ignoring "${i}". ${Jt[i]}`);
632
760
  continue;
633
761
  }
634
762
  n(
635
- `Notefully.init: ignoring unknown key "${i}". Supported: ${[...zt].join(", ")}.`
763
+ `Notefully.init: ignoring unknown key "${i}". Supported: ${[...Gt].join(", ")}.`
636
764
  );
637
765
  }
638
766
  }
639
- function ce(t) {
767
+ function ye(t) {
640
768
  typeof console < "u" && typeof console.warn == "function" && console.warn(t);
641
769
  }
642
- const Tn = 80;
643
- function In() {
770
+ const zn = 80;
771
+ function qn() {
644
772
  const t = [], e = {};
645
773
  let n = !1;
646
- const r = (i, a) => {
774
+ const r = (i, o) => {
647
775
  let c = "";
648
776
  try {
649
- c = a.map((l) => l instanceof Error ? l.stack || l.message : typeof l == "string" ? l : JSON.stringify(l)).join(" ");
777
+ c = o.map((l) => l instanceof Error ? l.stack || l.message : typeof l == "string" ? l : JSON.stringify(l)).join(" ");
650
778
  } catch {
651
- c = String(a[0]);
779
+ c = String(o[0]);
652
780
  }
653
781
  t.push({
654
782
  level: i,
655
783
  text: c.slice(0, 2e3),
656
784
  at: Date.now()
657
- }), t.length > Tn && t.shift();
785
+ }), t.length > zn && t.shift();
658
786
  };
659
787
  return {
660
788
  hook: () => {
661
789
  n || typeof window > "u" || (n = !0, ["log", "info", "warn", "error"].forEach((i) => {
662
- e[i] = console[i].bind(console), console[i] = (...a) => {
663
- r(i, a), e[i](...a);
790
+ e[i] = console[i].bind(console), console[i] = (...o) => {
791
+ r(i, o), e[i](...o);
664
792
  };
665
793
  }), window.addEventListener("error", (i) => {
666
794
  r("error", [i.message || "window.error"]);
@@ -673,10 +801,10 @@ function In() {
673
801
  }
674
802
  };
675
803
  }
676
- function On(t) {
804
+ function Kn(t) {
677
805
  const e = window.SpeechRecognition || window.webkitSpeechRecognition;
678
806
  let n = null, r = !1;
679
- const o = () => {
807
+ const a = () => {
680
808
  if (r = !1, n)
681
809
  try {
682
810
  n.stop();
@@ -687,10 +815,10 @@ function On(t) {
687
815
  start: () => {
688
816
  if (!e)
689
817
  throw new Error("Speech recognition is not supported in this browser.");
690
- return r ? (o(), !1) : (n = new e(), n.continuous = !0, n.interimResults = !0, n.lang = navigator.language || "en-US", n.onresult = (a) => {
818
+ return r ? (a(), !1) : (n = new e(), n.continuous = !0, n.interimResults = !0, n.lang = navigator.language || "en-US", n.onresult = (o) => {
691
819
  let c = "";
692
- for (let l = a.resultIndex; l < a.results.length; l += 1)
693
- a.results[l].isFinal && (c += a.results[l][0].transcript);
820
+ for (let l = o.resultIndex; l < o.results.length; l += 1)
821
+ o.results[l].isFinal && (c += o.results[l][0].transcript);
694
822
  c && t(c);
695
823
  }, n.onerror = () => {
696
824
  r = !1;
@@ -698,24 +826,24 @@ function On(t) {
698
826
  r = !1;
699
827
  }, n.start(), r = !0, !0);
700
828
  },
701
- stop: o,
829
+ stop: a,
702
830
  isSupported: () => !!e,
703
831
  isActive: () => r
704
832
  };
705
833
  }
706
- const Hn = 60 * 1e3;
707
- function Fn({ onStart: t, onStop: e, onError: n }) {
708
- let r = null, o = null, i = [], a = null;
834
+ const Xn = 60 * 1e3;
835
+ function Yn({ onStart: t, onStop: e, onError: n }) {
836
+ let r = null, a = null, i = [], o = null;
709
837
  const c = () => {
710
- if (a && (clearTimeout(a), a = null), o && o.state !== "inactive")
838
+ if (o && (clearTimeout(o), o = null), a && a.state !== "inactive")
711
839
  try {
712
- o.stop();
840
+ a.stop();
713
841
  } catch {
714
842
  }
715
843
  r && (r.getTracks().forEach((f) => f.stop()), r = null);
716
844
  }, l = () => {
717
- if (o && o.state === "recording") {
718
- o.stop();
845
+ if (a && a.state === "recording") {
846
+ a.stop();
719
847
  return;
720
848
  }
721
849
  c(), e(null);
@@ -729,17 +857,17 @@ function Fn({ onStart: t, onStop: e, onError: n }) {
729
857
  audio: !1,
730
858
  preferCurrentTab: !0,
731
859
  selfBrowserSurface: "include"
732
- }), i = [], o = new MediaRecorder(r, {
860
+ }), i = [], a = new MediaRecorder(r, {
733
861
  mimeType: MediaRecorder.isTypeSupported("video/webm;codecs=vp9") ? "video/webm;codecs=vp9" : "video/webm"
734
- }), o.ondataavailable = (m) => {
735
- m.data && m.data.size && i.push(m.data);
736
- }, o.onstop = () => {
737
- const m = i.length ? new Blob(i, { type: o.mimeType || "video/webm" }) : null;
738
- c(), e(m);
739
- }, (p = r.getVideoTracks()[0]) == null || p.addEventListener("ended", () => l()), o.start(), a = setTimeout(l, Hn);
862
+ }), a.ondataavailable = (y) => {
863
+ y.data && y.data.size && i.push(y.data);
864
+ }, a.onstop = () => {
865
+ const y = i.length ? new Blob(i, { type: a.mimeType || "video/webm" }) : null;
866
+ c(), e(y);
867
+ }, (p = r.getVideoTracks()[0]) == null || p.addEventListener("ended", () => l()), a.start(), o = setTimeout(l, Xn);
740
868
  }, stop: l };
741
869
  }
742
- function Dn() {
870
+ function Gn() {
743
871
  const t = /* @__PURE__ */ new Set();
744
872
  return {
745
873
  alloc() {
@@ -757,24 +885,24 @@ function Dn() {
757
885
  }
758
886
  };
759
887
  }
760
- const dt = { x: 0, y: 0, w: 1, h: 1 };
761
- function le() {
762
- const t = Dn();
763
- let e = [], n = { ...dt }, r = 1;
888
+ const yt = { x: 0, y: 0, w: 1, h: 1 };
889
+ function Pt() {
890
+ const t = Gn();
891
+ let e = [], n = { ...yt }, r = 1;
764
892
  return {
765
- list: () => e.filter((i) => Un(i, n)),
893
+ list: () => e.filter((i) => Qn(i, n)),
766
894
  all: () => e.slice(),
767
895
  crop: () => ({ ...n }),
768
896
  setCrop(i) {
769
- return n = Bn(i), n;
897
+ return n = Jn(i), n;
770
898
  },
771
899
  resetCrop() {
772
- return n = { ...dt }, n;
900
+ return n = { ...yt }, n;
773
901
  },
774
902
  isCropped() {
775
903
  return n.x > 1e-6 || n.y > 1e-6 || n.w < 1 - 1e-6 || n.h < 1 - 1e-6;
776
904
  },
777
- add(i, a) {
905
+ add(i, o) {
778
906
  const c = {
779
907
  id: `s${r++}`,
780
908
  type: i,
@@ -785,36 +913,36 @@ function le() {
785
913
  h: i === "arrow" ? 0.05 : 0.16,
786
914
  x2: 0.4,
787
915
  y2: 0.28,
788
- ...a
916
+ ...o
789
917
  };
790
918
  return e.push(c), c;
791
919
  },
792
- update(i, a) {
920
+ update(i, o) {
793
921
  const c = e.find((l) => l.id === i);
794
- return c ? (Object.assign(c, a), c) : null;
922
+ return c ? (Object.assign(c, o), c) : null;
795
923
  },
796
924
  remove(i) {
797
- const a = e.findIndex((l) => l.id === i);
798
- if (a < 0)
925
+ const o = e.findIndex((l) => l.id === i);
926
+ if (o < 0)
799
927
  return null;
800
- const [c] = e.splice(a, 1);
928
+ const [c] = e.splice(o, 1);
801
929
  return t.free(c.number), c;
802
930
  },
803
931
  reset() {
804
- for (e = [], n = { ...dt }, r = 1; t.peekUsed().length; )
932
+ for (e = [], n = { ...yt }, r = 1; t.peekUsed().length; )
805
933
  t.free(t.peekUsed()[0]);
806
934
  }
807
935
  };
808
936
  }
809
- function Bn(t) {
810
- const e = Math.min(Math.max(t.x, 0), 0.95), n = Math.min(Math.max(t.y, 0), 0.95), r = Math.min(Math.max(t.w, 0.05), 1 - e), o = Math.min(Math.max(t.h, 0.05), 1 - n);
811
- return { x: e, y: n, w: r, h: o };
937
+ function Jn(t) {
938
+ const e = Math.min(Math.max(t.x, 0), 0.95), n = Math.min(Math.max(t.y, 0), 0.95), r = Math.min(Math.max(t.w, 0.05), 1 - e), a = Math.min(Math.max(t.h, 0.05), 1 - n);
939
+ return { x: e, y: n, w: r, h: a };
812
940
  }
813
- function Un(t, e) {
941
+ function Qn(t, e) {
814
942
  const n = t.type === "arrow" ? (t.x + (t.x2 ?? t.x)) / 2 : t.x + (t.w || 0) / 2, r = t.type === "arrow" ? (t.y + (t.y2 ?? t.y)) / 2 : t.y + (t.h || 0) / 2;
815
943
  return n >= e.x && r >= e.y && n <= e.x + e.w && r <= e.y + e.h;
816
944
  }
817
- function At(t) {
945
+ function kt(t) {
818
946
  const e = Math.max(1, Number(t) || 1);
819
947
  return {
820
948
  stroke: Math.max(2, e * 75e-4),
@@ -824,147 +952,148 @@ function At(t) {
824
952
  arrowHeadAngle: 0.4
825
953
  };
826
954
  }
827
- function jn(t, {
955
+ function Zn(t, {
828
956
  stickers: e = [],
829
957
  crop: n = { x: 0, y: 0, w: 1, h: 1 },
830
958
  width: r,
831
- height: o,
959
+ height: a,
832
960
  colors: i = {}
833
961
  }) {
834
- const a = i.mark || "#fdd341", c = i.markText || "#2a2140", l = At(r);
835
- t.save(), t.lineWidth = l.stroke, t.lineCap = "round", t.lineJoin = "round", t.strokeStyle = a, t.fillStyle = a, t.font = `700 ${Math.round(l.fontSize)}px ui-sans-serif, system-ui, sans-serif`, e.forEach((u) => {
836
- const f = yt(u.x, n, r), p = gt(u.y, n, o), m = u.w / n.w * r, x = u.h / n.h * o, A = l.stroke / 2;
962
+ const o = i.mark || "#fdd341", c = i.markText || "#2a2140", l = kt(r);
963
+ t.save(), t.lineWidth = l.stroke, t.lineCap = "round", t.lineJoin = "round", t.strokeStyle = o, t.fillStyle = o, t.font = `700 ${Math.round(l.fontSize)}px ui-sans-serif, system-ui, sans-serif`, e.forEach((u) => {
964
+ const f = Et(u.x, n, r), p = Ct(u.y, n, a), y = u.w / n.w * r, v = u.h / n.h * a, A = l.stroke / 2;
837
965
  if (u.type === "rect")
838
966
  t.strokeRect(
839
967
  f + A,
840
968
  p + A,
841
- Math.max(0, m - l.stroke),
842
- Math.max(0, x - l.stroke)
969
+ Math.max(0, y - l.stroke),
970
+ Math.max(0, v - l.stroke)
843
971
  );
844
972
  else if (u.type === "circle")
845
973
  t.beginPath(), t.ellipse(
846
- f + m / 2,
847
- p + x / 2,
848
- Math.max(0.5, m / 2 - A),
849
- Math.max(0.5, x / 2 - A),
974
+ f + y / 2,
975
+ p + v / 2,
976
+ Math.max(0.5, y / 2 - A),
977
+ Math.max(0.5, v / 2 - A),
850
978
  0,
851
979
  0,
852
980
  Math.PI * 2
853
981
  ), t.stroke();
854
982
  else if (u.type === "arrow") {
855
- const j = yt(u.x2 ?? u.x + u.w, n, r), N = gt(u.y2 ?? u.y, n, o);
856
- _n(t, f, p, j, N, l);
983
+ const V = Et(u.x2 ?? u.x + u.w, n, r), W = Ct(u.y2 ?? u.y, n, a);
984
+ er(t, f, p, V, W, l);
857
985
  }
858
986
  if (u.number == null || u.number === "")
859
987
  return;
860
- const k = Nn(u, n, r, o, f, p, m), q = String(u.number);
861
- t.beginPath(), t.arc(k.x, k.y, l.badgeRadius, 0, Math.PI * 2), t.fillStyle = a, t.fill(), t.fillStyle = c, t.textAlign = "center", t.textBaseline = "middle", t.fillText(q, k.x, k.y + 0.5), t.fillStyle = a;
988
+ const I = tr(u, n, r, a, f, p, y), Y = String(u.number);
989
+ t.beginPath(), t.arc(I.x, I.y, l.badgeRadius, 0, Math.PI * 2), t.fillStyle = o, t.fill(), t.fillStyle = c, t.textAlign = "center", t.textBaseline = "middle", t.fillText(Y, I.x, I.y + 0.5), t.fillStyle = o;
862
990
  }), t.restore();
863
991
  }
864
- function yt(t, e, n) {
992
+ function Et(t, e, n) {
865
993
  return (t - e.x) / e.w * n;
866
994
  }
867
- function gt(t, e, n) {
995
+ function Ct(t, e, n) {
868
996
  return (t - e.y) / e.h * n;
869
997
  }
870
- function Nn(t, e, n, r, o, i, a) {
998
+ function tr(t, e, n, r, a, i, o) {
871
999
  if (t.type === "arrow") {
872
- const c = yt(t.x2 ?? t.x + t.w, e, n), l = gt(t.y2 ?? t.y, e, r);
1000
+ const c = Et(t.x2 ?? t.x + t.w, e, n), l = Ct(t.y2 ?? t.y, e, r);
873
1001
  return {
874
- x: (o + c) / 2,
1002
+ x: (a + c) / 2,
875
1003
  y: (i + l) / 2
876
1004
  };
877
1005
  }
878
- return { x: o + a / 2, y: i };
879
- }
880
- function ue(t, e, n, r, o) {
881
- const i = Math.atan2(r - e, n - t), a = o.arrowHead, c = Math.min(o.stroke, a * 0.2), l = n, u = r, f = n - Math.cos(i) * a, p = r - Math.sin(i) * a, m = {
882
- x: l - a * Math.cos(i - o.arrowHeadAngle),
883
- y: u - a * Math.sin(i - o.arrowHeadAngle)
884
- }, x = {
885
- x: l - a * Math.cos(i + o.arrowHeadAngle),
886
- y: u - a * Math.sin(i + o.arrowHeadAngle)
1006
+ return { x: a + o / 2, y: i };
1007
+ }
1008
+ function ge(t, e, n, r, a) {
1009
+ const i = Math.atan2(r - e, n - t), o = a.arrowHead, c = Math.min(a.stroke, o * 0.2), l = n, u = r, f = n - Math.cos(i) * o, p = r - Math.sin(i) * o, y = {
1010
+ x: l - o * Math.cos(i - a.arrowHeadAngle),
1011
+ y: u - o * Math.sin(i - a.arrowHeadAngle)
1012
+ }, v = {
1013
+ x: l - o * Math.cos(i + a.arrowHeadAngle),
1014
+ y: u - o * Math.sin(i + a.arrowHeadAngle)
887
1015
  }, A = {
888
1016
  x: n - Math.cos(i) * c,
889
1017
  y: r - Math.sin(i) * c
890
1018
  };
891
- return { angle: i, tipX: l, tipY: u, baseX: f, baseY: p, left: m, right: x, shaftEnd: A };
1019
+ return { angle: i, tipX: l, tipY: u, baseX: f, baseY: p, left: y, right: v, shaftEnd: A };
892
1020
  }
893
- function _n(t, e, n, r, o, i) {
894
- const a = ue(e, n, r, o, i);
895
- t.beginPath(), t.moveTo(e, n), t.lineTo(a.shaftEnd.x, a.shaftEnd.y), t.stroke(), t.beginPath(), t.moveTo(a.tipX, a.tipY), t.lineTo(a.left.x, a.left.y), t.lineTo(a.right.x, a.right.y), t.closePath(), t.fill();
1021
+ function er(t, e, n, r, a, i) {
1022
+ const o = ge(e, n, r, a, i);
1023
+ t.beginPath(), t.moveTo(e, n), t.lineTo(o.shaftEnd.x, o.shaftEnd.y), t.stroke(), t.beginPath(), t.moveTo(o.tipX, o.tipY), t.lineTo(o.left.x, o.left.y), t.lineTo(o.right.x, o.right.y), t.closePath(), t.fill();
896
1024
  }
897
- function Vn(t, e, n, r = {}) {
898
- return new Promise((o, i) => {
899
- const a = new Image();
900
- a.onload = () => {
901
- const c = Math.round(e.x * a.width), l = Math.round(e.y * a.height), u = Math.max(1, Math.round(e.w * a.width)), f = Math.max(1, Math.round(e.h * a.height)), p = document.createElement("canvas");
1025
+ function nr(t, e, n, r = {}) {
1026
+ return new Promise((a, i) => {
1027
+ const o = new Image();
1028
+ o.onload = () => {
1029
+ const c = Math.round(e.x * o.width), l = Math.round(e.y * o.height), u = Math.max(1, Math.round(e.w * o.width)), f = Math.max(1, Math.round(e.h * o.height)), p = document.createElement("canvas");
902
1030
  p.width = u, p.height = f;
903
- const m = p.getContext("2d");
904
- m.drawImage(a, c, l, u, f, 0, 0, u, f), jn(m, {
1031
+ const y = p.getContext("2d");
1032
+ y.drawImage(o, c, l, u, f, 0, 0, u, f), Zn(y, {
905
1033
  stickers: n,
906
1034
  crop: e,
907
1035
  width: u,
908
1036
  height: f,
909
1037
  colors: r
910
- }), p.toBlob((x) => {
911
- if (!x) {
1038
+ }), p.toBlob((v) => {
1039
+ if (!v) {
912
1040
  i(new Error("Could not encode screenshot"));
913
1041
  return;
914
1042
  }
915
- o(x);
1043
+ a(v);
916
1044
  }, "image/png");
917
- }, a.onerror = () => i(new Error("Could not load screenshot")), a.src = t;
1045
+ }, o.onerror = () => i(new Error("Could not load screenshot")), o.src = t;
918
1046
  });
919
1047
  }
920
- const B = [
1048
+ const N = [
921
1049
  { id: "bug", label: "Bug" },
922
1050
  { id: "idea", label: "Idea" },
923
1051
  { id: "other", label: "Other" }
924
1052
  ];
925
- function Wt(t) {
1053
+ function Qt(t) {
926
1054
  return String(t || "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32);
927
1055
  }
928
- function ft(t) {
1056
+ function gt(t) {
929
1057
  const e = String(t || "").trim();
930
1058
  return e ? e.split(/[-_\s]+/).filter(Boolean).map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ") : "";
931
1059
  }
932
- function zn(t) {
1060
+ function rr(t) {
933
1061
  if (!Array.isArray(t) || !t.length)
934
- return B.map((r) => ({ ...r }));
1062
+ return N.map((r) => ({ ...r }));
935
1063
  const e = /* @__PURE__ */ new Set(), n = [];
936
1064
  for (const r of t) {
937
- let o = "", i = "";
938
- typeof r == "string" || typeof r == "number" ? (o = Wt(r), i = ft(o)) : r && typeof r == "object" && (o = Wt(r.id ?? r.value ?? r.kind), i = String(r.label || r.name || ft(o)).trim() || ft(o)), !(!o || e.has(o)) && (e.add(o), n.push({ id: o, label: i }));
1065
+ let a = "", i = "";
1066
+ typeof r == "string" || typeof r == "number" ? (a = Qt(r), i = gt(a)) : r && typeof r == "object" && (a = Qt(r.id ?? r.value ?? r.kind), i = String(r.label || r.name || gt(a)).trim() || gt(a)), !(!a || e.has(a)) && (e.add(a), n.push({ id: a, label: i }));
939
1067
  }
940
- return n.length ? n : B.map((r) => ({ ...r }));
1068
+ return n.length ? n : N.map((r) => ({ ...r }));
941
1069
  }
942
- function at(t) {
1070
+ function dt(t) {
943
1071
  var n;
944
- const e = Array.isArray(t) && t.length ? t : B;
1072
+ const e = Array.isArray(t) && t.length ? t : N;
945
1073
  return e.some((r) => r.id === "bug") ? "bug" : ((n = e[0]) == null ? void 0 : n.id) || "other";
946
1074
  }
947
- const qn = ["maker", "all-business", "brighter-day", "quiet-night"], de = "maker", Wn = /* @__PURE__ */ new Set(["crop", "arrow", "rect", "circle"]), wt = 0.02, Kt = 0.05, Kn = `
1075
+ const ir = ["maker", "all-business", "brighter-day", "quiet-night"], we = "maker", ar = /* @__PURE__ */ new Set(["crop", "arrow", "rect", "circle"]), Mt = 0.02, Zt = 0.05, or = `
948
1076
  <svg class="nf-launcher-icon" viewBox="0 0 24 24" aria-hidden="true">
949
1077
  <path fill="currentColor" d="M5.2 2.8h9.1A2.7 2.7 0 0 1 17 5.5v8.2c0 .4-.3.7-.7.7h-.1a.7.7 0 0 1-.7-.7V5.5c0-.7-.6-1.3-1.3-1.3H5.2c-.7 0-1.3.6-1.3 1.3v12.2c0 .7.6 1.3 1.3 1.3h6.4a.7.7 0 0 1 0 1.4H5.2A2.7 2.7 0 0 1 2.5 17.7V5.5A2.7 2.7 0 0 1 5.2 2.8zm1.6 4.2a.7.7 0 0 0 0 1.4h6.2a.7.7 0 0 0 0-1.4H6.8zm0 3.2a.7.7 0 0 0 0 1.4h6.2a.7.7 0 0 0 0-1.4H6.8zm0 3.2a.7.7 0 0 0 0 1.4h3.6a.7.7 0 0 0 0-1.4H6.8z"/>
950
1078
  <path fill="currentColor" d="M14.7 13.05 20.2 7.55a1.55 1.55 0 0 1 2.2 2.2l-5.5 5.5-.45 1.9a.6.6 0 0 1-.72.45l-1.9-.45.87-1.9z"/>
951
1079
  </svg>
952
1080
  `;
953
- function I(t) {
1081
+ function P(t) {
954
1082
  return `<svg class="nf-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`;
955
1083
  }
956
- const $ = {
957
- crop: I('<path d="M6 3v5H1M18 21v-5h5M8 5h8a2 2 0 0 1 2 2v8M16 19H8a2 2 0 0 1-2-2V8"/>'),
958
- resetCrop: I('<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>'),
959
- arrow: I('<path d="M5 19 19 5"/><path d="M9 5h10v10"/>'),
960
- rect: I('<rect x="4" y="6" width="16" height="12" rx="1.5"/>'),
961
- circle: I('<circle cx="12" cy="12" r="8"/>'),
962
- discard: I('<path d="M4 7h16"/><path d="M9 7V5h6v2"/><path d="M6 7l1 13h10l1-13"/>'),
963
- audio: I('<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/>'),
964
- video: I('<rect x="3" y="7" width="13" height="10" rx="2"/><path d="M16 10.5 21 8v8l-5-2.5z"/>')
965
- }, fe = In();
966
- fe.hook();
967
- const he = 10, Xn = 80, pe = "notefully.author", bt = "Anonymous";
1084
+ const L = {
1085
+ crop: P('<path d="M6 3v5H1M18 21v-5h5M8 5h8a2 2 0 0 1 2 2v8M16 19H8a2 2 0 0 1-2-2V8"/>'),
1086
+ resetCrop: P('<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>'),
1087
+ arrow: P('<path d="M5 19 19 5"/><path d="M9 5h10v10"/>'),
1088
+ rect: P('<rect x="4" y="6" width="16" height="12" rx="1.5"/>'),
1089
+ circle: P('<circle cx="12" cy="12" r="8"/>'),
1090
+ discard: P('<path d="M4 7h16"/><path d="M9 7V5h6v2"/><path d="M6 7l1 13h10l1-13"/>'),
1091
+ recapture: P('<path d="M4 8h3l2-2h6l2 2h3v11H4z"/><circle cx="12" cy="13" r="3.5"/>'),
1092
+ audio: P('<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/>'),
1093
+ video: P('<rect x="3" y="7" width="13" height="10" rx="2"/><path d="M16 10.5 21 8v8l-5-2.5z"/>')
1094
+ }, be = qn();
1095
+ be.hook();
1096
+ const Se = 10, sr = 80, ve = "notefully.author", At = "Anonymous";
968
1097
  let d = {
969
1098
  endpoint: "",
970
1099
  projectKey: "",
@@ -972,43 +1101,46 @@ let d = {
972
1101
  name: "",
973
1102
  targets: null,
974
1103
  hideLauncher: !1,
975
- theme: de,
1104
+ theme: we,
976
1105
  video: !1,
977
- consoleLogLimit: he,
978
- kinds: B.map((t) => ({ ...t }))
979
- }, R = {}, h = null, s = {}, y = le(), S = "", K = "", P = null, U = at(B), H = null, L = null, b = null, w = null, Q = null, D = null, W = null, O = { w: 0, h: 0 }, ht = !1, Lt = !1;
1106
+ consoleLogLimit: Se,
1107
+ kinds: N.map((t) => ({ ...t })),
1108
+ capture: null,
1109
+ onBeforeCapture: null
1110
+ }, wt = !1, R = {}, h = null, s = {}, m = Pt(), T = "", X = "", $ = null, j = dt(N), B = null, M = null, b = null, w = null, nt = null, U = null, G = null, k = { w: 0, h: 0 }, bt = !1, It = !1;
980
1111
  function g(t) {
981
1112
  return h.querySelector(t);
982
1113
  }
983
- function me(t) {
1114
+ function xe(t) {
984
1115
  const e = String(t || "").trim().toLowerCase().replace(/\s+/g, "-");
985
- return qn.includes(e) ? e : de;
1116
+ return ir.includes(e) ? e : we;
986
1117
  }
987
- function Xt(t, e) {
1118
+ function te(t, e) {
988
1119
  return h && getComputedStyle(h).getPropertyValue(t).trim() || e;
989
1120
  }
990
- async function Yn(t) {
1121
+ async function cr(t) {
991
1122
  return (await fetch(t)).blob();
992
1123
  }
993
- function v(t, e = !1) {
994
- s.status && (s.status.textContent = t || "", Q && (clearTimeout(Q), Q = null), t && !e && (Q = setTimeout(() => {
1124
+ function S(t, e = !1) {
1125
+ s.status && (s.status.textContent = t || "", nt && (clearTimeout(nt), nt = null), t && !e && (nt = setTimeout(() => {
995
1126
  s.status.textContent = "";
996
1127
  }, 4e3)));
997
1128
  }
998
- function Rt() {
1129
+ function Ot() {
999
1130
  return h && document.body.contains(h) || (h = document.createElement("div"), h.id = "notefully", h.innerHTML = `
1000
- <button class="nf-launcher" type="button" title="Leave a note…" aria-label="Leave a note…">${Kn}</button>
1131
+ <button class="nf-launcher" type="button" title="Leave a note…" aria-label="Leave a note…">${or}</button>
1001
1132
  <div class="nf-dialog" hidden>
1002
1133
  <div class="nf-panel">
1003
1134
  <div class="nf-panel-body">
1004
- <div class="nf-stage">
1135
+ <div class="nf-stage" hidden>
1005
1136
  <div class="nf-palette">
1006
- <button class="nf-tool nf-icon-btn" type="button" data-tool="crop" title="Crop" aria-label="Crop">${$.crop}</button>
1007
- <button class="nf-reset-crop nf-icon-btn" type="button" title="Reset crop" aria-label="Reset crop" hidden>${$.resetCrop}</button>
1008
- <button class="nf-tool nf-icon-btn" type="button" data-tool="arrow" title="Arrow" aria-label="Arrow">${$.arrow}</button>
1009
- <button class="nf-tool nf-icon-btn" type="button" data-tool="rect" title="Rectangle" aria-label="Rectangle">${$.rect}</button>
1010
- <button class="nf-tool nf-icon-btn" type="button" data-tool="circle" title="Circle" aria-label="Circle">${$.circle}</button>
1011
- <button class="nf-discard-shot nf-icon-btn" type="button" title="Discard screenshot" aria-label="Discard screenshot">${$.discard}</button>
1137
+ <button class="nf-tool nf-icon-btn" type="button" data-tool="crop" title="Crop" aria-label="Crop">${L.crop}</button>
1138
+ <button class="nf-reset-crop nf-icon-btn" type="button" title="Reset crop" aria-label="Reset crop" hidden>${L.resetCrop}</button>
1139
+ <button class="nf-tool nf-icon-btn" type="button" data-tool="arrow" title="Arrow" aria-label="Arrow">${L.arrow}</button>
1140
+ <button class="nf-tool nf-icon-btn" type="button" data-tool="rect" title="Rectangle" aria-label="Rectangle">${L.rect}</button>
1141
+ <button class="nf-tool nf-icon-btn" type="button" data-tool="circle" title="Circle" aria-label="Circle">${L.circle}</button>
1142
+ <button class="nf-discard-shot nf-icon-btn" type="button" title="Discard screenshot" aria-label="Discard screenshot">${L.discard}</button>
1143
+ <button class="nf-recapture nf-icon-btn" type="button" title="Recapture screenshot" aria-label="Recapture screenshot">${L.recapture}</button>
1012
1144
  </div>
1013
1145
  <div class="nf-canvas"></div>
1014
1146
  </div>
@@ -1016,9 +1148,9 @@ function Rt() {
1016
1148
  <input class="nf-author" type="text" name="author" autocomplete="nickname" placeholder="Anonymous" aria-label="Author">
1017
1149
  <div class="nf-kind"></div>
1018
1150
  <div class="nf-actions">
1019
- <button class="nf-restore nf-icon-btn" type="button" title="Restore screenshot" aria-label="Restore screenshot" hidden>${$.resetCrop}</button>
1020
- <button class="nf-audio nf-icon-btn" type="button" title="Record audio" aria-label="Record audio">${$.audio}</button>
1021
- <button class="nf-video nf-icon-btn" type="button" title="Record video" aria-label="Record video">${$.video}</button>
1151
+ <button class="nf-restore nf-icon-btn" type="button" title="Restore screenshot" aria-label="Restore screenshot" hidden>${L.resetCrop}</button>
1152
+ <button class="nf-audio nf-icon-btn" type="button" title="Record audio" aria-label="Record audio">${L.audio}</button>
1153
+ <button class="nf-video nf-icon-btn" type="button" title="Record video" aria-label="Record video">${L.video}</button>
1022
1154
  <button class="nf-submit" type="button">Submit</button>
1023
1155
  </div>
1024
1156
  <div class="nf-status"></div>
@@ -1034,154 +1166,159 @@ function Rt() {
1034
1166
  panelBody: g(".nf-panel-body"),
1035
1167
  successMsg: g(".nf-success-msg"),
1036
1168
  stage: g(".nf-stage"),
1169
+ palette: g(".nf-palette"),
1037
1170
  canvas: g(".nf-canvas"),
1038
1171
  text: g(".nf-text"),
1039
1172
  author: g(".nf-author"),
1173
+ actions: g(".nf-actions"),
1040
1174
  restore: g(".nf-restore"),
1041
1175
  status: g(".nf-status"),
1042
1176
  audio: g(".nf-audio"),
1043
1177
  video: g(".nf-video"),
1044
1178
  discard: g(".nf-discard-shot"),
1179
+ recapture: g(".nf-recapture"),
1045
1180
  stop: g(".nf-stop-video"),
1046
1181
  resetCrop: g(".nf-reset-crop"),
1047
1182
  submit: g(".nf-submit"),
1048
1183
  shot: null
1049
- }, Gn(), X()), h;
1184
+ }, lr(), Q()), h;
1050
1185
  }
1051
- function X() {
1186
+ function Q() {
1052
1187
  var t;
1053
- h && (h.dataset.theme = me(d.theme), d.hideLauncher ? h.setAttribute("data-nf-hidden-launcher", "") : h.removeAttribute("data-nf-hidden-launcher"), s.video && (s.video.hidden = !d.video), ye(), (t = s.dialog) != null && t.hidden && nt());
1188
+ h && (h.dataset.theme = xe(d.theme), d.hideLauncher ? h.setAttribute("data-nf-hidden-launcher", "") : h.removeAttribute("data-nf-hidden-launcher"), s.video && (s.video.hidden = !d.video), Ee(), (t = s.dialog) != null && t.hidden && ot());
1054
1189
  }
1055
- function nt() {
1190
+ function ot() {
1056
1191
  s.launcher && (s.launcher.hidden = !!d.hideLauncher);
1057
1192
  }
1058
- function Gn() {
1059
- s.launcher.addEventListener("click", () => Ce()), g(".nf-dialog").addEventListener("click", (e) => {
1060
- Lt || e.target === s.dialog && J();
1193
+ function lr() {
1194
+ s.launcher.addEventListener("click", () => Ie()), g(".nf-dialog").addEventListener("click", (e) => {
1195
+ It || e.target === s.dialog && et();
1061
1196
  }), h.querySelectorAll(".nf-tool").forEach((e) => {
1062
- e.addEventListener("click", () => St(e.dataset.tool));
1063
- }), s.resetCrop.addEventListener("click", rr), s.canvas.addEventListener("pointerdown", Qn), s.canvas.addEventListener("dragstart", (e) => e.preventDefault());
1197
+ e.addEventListener("click", () => J(e.dataset.tool));
1198
+ }), s.resetCrop.addEventListener("click", yr), s.canvas.addEventListener("pointerdown", dr), s.canvas.addEventListener("dragstart", (e) => e.preventDefault());
1064
1199
  const t = g(".nf-kind");
1065
1200
  t && t.addEventListener("click", (e) => {
1066
1201
  const n = e.target.closest("[data-kind]");
1067
- n && $t(n.dataset.kind);
1068
- }), s.discard.addEventListener("click", ir), s.restore.addEventListener("click", or), s.audio.addEventListener("click", ar), s.video.addEventListener("click", sr), s.stop.addEventListener("click", () => W == null ? void 0 : W.stop()), g(".nf-submit").addEventListener("click", () => {
1069
- Ae().catch((e) => v(e.message || "Submit failed."));
1070
- }), ye(), St(null);
1071
- }
1072
- function Yt(t) {
1202
+ n && Bt(n.dataset.kind);
1203
+ }), s.discard.addEventListener("click", gr), s.recapture.addEventListener("click", () => {
1204
+ br().catch((e) => S(e.message || "Recapture failed."));
1205
+ }), s.restore.addEventListener("click", wr), s.audio.addEventListener("click", Sr), s.video.addEventListener("click", vr), s.stop.addEventListener("click", () => G == null ? void 0 : G.stop()), g(".nf-submit").addEventListener("click", () => {
1206
+ Be().catch((e) => S(e.message || "Submit failed."));
1207
+ }), Ee(), J(null);
1208
+ }
1209
+ function ee(t) {
1073
1210
  return String(t || "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1074
1211
  }
1075
- function ye() {
1212
+ function Ee() {
1076
1213
  const t = h == null ? void 0 : h.querySelector(".nf-kind");
1077
1214
  if (!t)
1078
1215
  return;
1079
- const e = Array.isArray(d.kinds) && d.kinds.length ? d.kinds : B;
1080
- t.innerHTML = e.map((o) => `<button type="button" data-kind="${Yt(o.id)}">${Yt(o.label)}</button>`).join("");
1081
- const r = e.map((o) => o.id).includes(U) ? U : at(e);
1082
- $t(r);
1083
- }
1084
- function $t(t) {
1085
- U = (d.kinds || B).map((n) => n.id).includes(t) ? t : at(d.kinds), h == null || h.querySelectorAll("[data-kind]").forEach((n) => {
1086
- n.dataset.active = String(n.dataset.kind === U);
1216
+ const e = Array.isArray(d.kinds) && d.kinds.length ? d.kinds : N;
1217
+ t.innerHTML = e.map((a) => `<button type="button" data-kind="${ee(a.id)}">${ee(a.label)}</button>`).join("");
1218
+ const r = e.map((a) => a.id).includes(j) ? j : dt(e);
1219
+ Bt(r);
1220
+ }
1221
+ function Bt(t) {
1222
+ j = (d.kinds || N).map((n) => n.id).includes(t) ? t : dt(d.kinds), h == null || h.querySelectorAll("[data-kind]").forEach((n) => {
1223
+ n.dataset.active = String(n.dataset.kind === j);
1087
1224
  });
1088
1225
  }
1089
- function St(t) {
1090
- H = Wn.has(t) ? t : null, L = null, h.querySelectorAll(".nf-tool").forEach((e) => {
1091
- e.dataset.active = String(e.dataset.tool === H);
1092
- }), s.canvas && (s.canvas.dataset.draw = H ? "true" : "false"), S && M();
1226
+ function J(t) {
1227
+ B = ar.has(t) ? t : null, M = null, h.querySelectorAll(".nf-tool").forEach((e) => {
1228
+ e.dataset.active = String(e.dataset.tool === B);
1229
+ }), s.canvas && (s.canvas.dataset.draw = B ? "true" : "false"), F() && C();
1093
1230
  }
1094
- function Gt(t) {
1231
+ function ne(t) {
1095
1232
  return Math.min(1, Math.max(0, t));
1096
1233
  }
1097
- function Y() {
1234
+ function Z() {
1098
1235
  return s.shot || s.canvas;
1099
1236
  }
1100
- function rt(t) {
1101
- const e = Y().getBoundingClientRect();
1237
+ function st(t) {
1238
+ const e = Z().getBoundingClientRect();
1102
1239
  return {
1103
- x: Gt((t.clientX - e.left) / Math.max(e.width, 1)),
1104
- y: Gt((t.clientY - e.top) / Math.max(e.height, 1))
1240
+ x: ne((t.clientX - e.left) / Math.max(e.width, 1)),
1241
+ y: ne((t.clientY - e.top) / Math.max(e.height, 1))
1105
1242
  };
1106
1243
  }
1107
- function Jn(t) {
1108
- const e = Y().getBoundingClientRect();
1244
+ function ur(t) {
1245
+ const e = Z().getBoundingClientRect();
1109
1246
  return t.clientX >= e.left && t.clientX <= e.right && t.clientY >= e.top && t.clientY <= e.bottom;
1110
1247
  }
1111
- function ge(t) {
1112
- const e = rt(t), n = y.crop();
1248
+ function Ce(t) {
1249
+ const e = st(t), n = m.crop();
1113
1250
  return {
1114
1251
  x: n.x + e.x * n.w,
1115
1252
  y: n.y + e.y * n.h
1116
1253
  };
1117
1254
  }
1118
- function st(t, e) {
1255
+ function ft(t, e) {
1119
1256
  const n = Math.min(t.x, e.x), r = Math.min(t.y, e.y);
1120
1257
  return {
1121
1258
  x: n,
1122
1259
  y: r,
1123
- w: Math.max(wt, Math.abs(e.x - t.x)),
1124
- h: Math.max(wt, Math.abs(e.y - t.y))
1260
+ w: Math.max(Mt, Math.abs(e.x - t.x)),
1261
+ h: Math.max(Mt, Math.abs(e.y - t.y))
1125
1262
  };
1126
1263
  }
1127
- function Pt(t) {
1264
+ function Ht(t) {
1128
1265
  h && (t ? h.dataset.grabbing = "true" : delete h.dataset.grabbing);
1129
1266
  }
1130
- function pt(t) {
1267
+ function St(t) {
1131
1268
  try {
1132
1269
  s.canvas.setPointerCapture(t.pointerId);
1133
1270
  } catch {
1134
1271
  }
1135
1272
  }
1136
- function vt() {
1137
- window.addEventListener("pointermove", be), window.addEventListener("pointerup", it), window.addEventListener("pointercancel", it);
1273
+ function Lt() {
1274
+ window.addEventListener("pointermove", Ae), window.addEventListener("pointerup", ct), window.addEventListener("pointercancel", ct);
1138
1275
  }
1139
- function we() {
1140
- window.removeEventListener("pointermove", be), window.removeEventListener("pointerup", it), window.removeEventListener("pointercancel", it);
1276
+ function Me() {
1277
+ window.removeEventListener("pointermove", Ae), window.removeEventListener("pointerup", ct), window.removeEventListener("pointercancel", ct);
1141
1278
  }
1142
- function Qn(t) {
1143
- if (t.button !== 0 || !S)
1279
+ function dr(t) {
1280
+ if (t.button !== 0 || !F())
1144
1281
  return;
1145
- if (!t.target.closest(".nf-sticker") && !Jn(t)) {
1146
- L = null, M();
1282
+ if (!t.target.closest(".nf-sticker") && !ur(t)) {
1283
+ M = null, C();
1147
1284
  return;
1148
1285
  }
1149
1286
  const e = t.target.closest(".nf-handle"), n = t.target.closest(".nf-sticker");
1150
1287
  if (n && n.dataset.preview !== "true") {
1151
- t.preventDefault(), t.stopPropagation(), L = n.dataset.id, pt(t), Zn({
1288
+ t.preventDefault(), t.stopPropagation(), M = n.dataset.id, St(t), fr({
1152
1289
  kind: "sticker",
1153
- id: L,
1290
+ id: M,
1154
1291
  dir: (e == null ? void 0 : e.dataset.dir) || "move"
1155
- }, t), M();
1292
+ }, t), C();
1156
1293
  return;
1157
1294
  }
1158
- if (L = null, H === "crop") {
1159
- t.preventDefault(), pt(t), b = { kind: "crop", start: rt(t), current: rt(t) }, vt(), M();
1295
+ if (M = null, B === "crop") {
1296
+ t.preventDefault(), St(t), b = { kind: "crop", start: st(t), current: st(t) }, Lt(), C();
1160
1297
  return;
1161
1298
  }
1162
- if (H === "arrow" || H === "rect" || H === "circle") {
1163
- t.preventDefault(), pt(t);
1164
- const r = ge(t);
1165
- b = { kind: "sticker", type: H, start: r, current: r }, vt(), M();
1299
+ if (B === "arrow" || B === "rect" || B === "circle") {
1300
+ t.preventDefault(), St(t);
1301
+ const r = Ce(t);
1302
+ b = { kind: "sticker", type: B, start: r, current: r }, Lt(), C();
1166
1303
  return;
1167
1304
  }
1168
- M();
1305
+ C();
1169
1306
  }
1170
- function Zn(t, e) {
1307
+ function fr(t, e) {
1171
1308
  e.preventDefault(), e.stopPropagation();
1172
- const n = Y().getBoundingClientRect(), r = y.list().find((o) => o.id === t.id);
1309
+ const n = Z().getBoundingClientRect(), r = m.list().find((a) => a.id === t.id);
1173
1310
  w = {
1174
1311
  ...t,
1175
1312
  startX: e.clientX,
1176
1313
  startY: e.clientY,
1177
- crop: y.crop(),
1314
+ crop: m.crop(),
1178
1315
  sticker: r ? { ...r } : null,
1179
1316
  rect: n
1180
- }, Pt(t.dir === "move" || t.dir === "start" || t.dir === "end"), vt();
1317
+ }, Ht(t.dir === "move" || t.dir === "start" || t.dir === "end"), Lt();
1181
1318
  }
1182
- function be(t) {
1319
+ function Ae(t) {
1183
1320
  if (b) {
1184
- b.current = b.kind === "crop" ? rt(t) : ge(t), M();
1321
+ b.current = b.kind === "crop" ? st(t) : Ce(t), C();
1185
1322
  return;
1186
1323
  }
1187
1324
  if (!w)
@@ -1189,85 +1326,85 @@ function be(t) {
1189
1326
  const e = (t.clientX - w.startX) / w.rect.width * w.crop.w, n = (t.clientY - w.startY) / w.rect.height * w.crop.h, r = w.sticker;
1190
1327
  if (r) {
1191
1328
  if (w.dir === "end")
1192
- y.update(r.id, {
1329
+ m.update(r.id, {
1193
1330
  x2: r.x2 + e,
1194
1331
  y2: r.y2 + n
1195
1332
  });
1196
1333
  else if (w.dir === "start")
1197
- y.update(r.id, {
1334
+ m.update(r.id, {
1198
1335
  x: r.x + e,
1199
1336
  y: r.y + n
1200
1337
  });
1201
1338
  else if (w.dir === "move")
1202
- y.update(r.id, {
1339
+ m.update(r.id, {
1203
1340
  x: r.x + e,
1204
1341
  y: r.y + n,
1205
1342
  x2: (r.x2 || r.x) + e,
1206
1343
  y2: (r.y2 || r.y) + n
1207
1344
  });
1208
1345
  else {
1209
- const o = { x: r.x, y: r.y, w: r.w, h: r.h };
1210
- tr(o, w.dir, e, n), y.update(r.id, o);
1346
+ const a = { x: r.x, y: r.y, w: r.w, h: r.h };
1347
+ hr(a, w.dir, e, n), m.update(r.id, a);
1211
1348
  }
1212
- M();
1349
+ C();
1213
1350
  }
1214
1351
  }
1215
- function tr(t, e, n, r) {
1352
+ function hr(t, e, n, r) {
1216
1353
  if (e.includes("e") && (t.w = Math.max(0.04, t.w + n)), e.includes("s") && (t.h = Math.max(0.04, t.h + r)), e.includes("w")) {
1217
- const o = Math.max(0.04, t.w - n);
1218
- t.x += t.w - o, t.w = o;
1354
+ const a = Math.max(0.04, t.w - n);
1355
+ t.x += t.w - a, t.w = a;
1219
1356
  }
1220
1357
  if (e.includes("n")) {
1221
- const o = Math.max(0.04, t.h - r);
1222
- t.y += t.h - o, t.h = o;
1358
+ const a = Math.max(0.04, t.h - r);
1359
+ t.y += t.h - a, t.h = a;
1223
1360
  }
1224
1361
  }
1225
- function it(t) {
1226
- if (we(), Pt(!1), b) {
1227
- er();
1362
+ function ct(t) {
1363
+ if (Me(), Ht(!1), b) {
1364
+ pr();
1228
1365
  return;
1229
1366
  }
1230
1367
  if (w) {
1231
1368
  if (w.kind === "sticker") {
1232
1369
  const e = s.canvas.getBoundingClientRect();
1233
- (t.clientX < e.left - 24 || t.clientX > e.right + 24 || t.clientY < e.top - 24 || t.clientY > e.bottom + 24) && (y.remove(w.id), L = null);
1370
+ (t.clientX < e.left - 24 || t.clientX > e.right + 24 || t.clientY < e.top - 24 || t.clientY > e.bottom + 24) && (m.remove(w.id), M = null);
1234
1371
  }
1235
- w = null, M();
1372
+ w = null, C();
1236
1373
  }
1237
1374
  }
1238
- function er() {
1375
+ function pr() {
1239
1376
  const t = b;
1240
1377
  if (b = null, !t)
1241
1378
  return;
1242
1379
  if (t.kind === "crop") {
1243
- const n = st(t.start, t.current);
1244
- if (Math.abs(t.current.x - t.start.x) < Kt || Math.abs(t.current.y - t.start.y) < Kt) {
1245
- M();
1380
+ const n = ft(t.start, t.current);
1381
+ if (Math.abs(t.current.x - t.start.x) < Zt || Math.abs(t.current.y - t.start.y) < Zt) {
1382
+ C();
1246
1383
  return;
1247
1384
  }
1248
- const o = y.crop();
1249
- y.setCrop({
1250
- x: o.x + n.x * o.w,
1251
- y: o.y + n.y * o.h,
1252
- w: n.w * o.w,
1253
- h: n.h * o.h
1254
- }), G();
1385
+ const a = m.crop();
1386
+ m.setCrop({
1387
+ x: a.x + n.x * a.w,
1388
+ y: a.y + n.y * a.h,
1389
+ w: n.w * a.w,
1390
+ h: n.h * a.h
1391
+ }), _();
1255
1392
  return;
1256
1393
  }
1257
- const e = nr(t);
1258
- e && (L = e.id), M();
1394
+ const e = mr(t);
1395
+ e && (M = e.id), C();
1259
1396
  }
1260
- function nr(t) {
1397
+ function mr(t) {
1261
1398
  if (t.type === "arrow") {
1262
1399
  const e = t.current.x - t.start.x, n = t.current.y - t.start.y;
1263
- return Math.hypot(e, n) < wt ? y.add("arrow", {
1400
+ return Math.hypot(e, n) < Mt ? m.add("arrow", {
1264
1401
  x: t.start.x,
1265
1402
  y: t.start.y,
1266
1403
  x2: t.start.x + 0.12,
1267
1404
  y2: t.start.y,
1268
1405
  w: 0.12,
1269
1406
  h: 0.02
1270
- }) : y.add("arrow", {
1407
+ }) : m.add("arrow", {
1271
1408
  x: t.start.x,
1272
1409
  y: t.start.y,
1273
1410
  x2: t.current.x,
@@ -1276,83 +1413,121 @@ function nr(t) {
1276
1413
  h: Math.abs(n)
1277
1414
  });
1278
1415
  }
1279
- return y.add(t.type, st(t.start, t.current));
1416
+ return m.add(t.type, ft(t.start, t.current));
1280
1417
  }
1281
- function rr() {
1282
- y.resetCrop(), L = null, G();
1418
+ function yr() {
1419
+ m.resetCrop(), M = null, _();
1283
1420
  }
1284
- function xt() {
1285
- s.resetCrop && (s.resetCrop.hidden = !y.isCropped());
1421
+ function lt() {
1422
+ s.resetCrop && (s.resetCrop.hidden = !m.isCropped());
1286
1423
  }
1287
- function kt(t) {
1424
+ function Dt(t) {
1288
1425
  if (!s.audio)
1289
1426
  return;
1290
1427
  const e = t ? "Stop audio" : "Record audio";
1291
1428
  s.audio.title = e, s.audio.setAttribute("aria-label", e), s.audio.dataset.active = String(!!t);
1292
1429
  }
1293
- function ir() {
1294
- S && (K = S), S = "", s.stage.hidden = !0, s.restore.hidden = !K;
1430
+ function F() {
1431
+ return D(T);
1295
1432
  }
1296
- function or() {
1297
- K && (S = K, s.stage.hidden = !1, s.restore.hidden = !0, G());
1433
+ function tt() {
1434
+ if (!s.stage || !s.palette || !s.actions || !s.recapture)
1435
+ return;
1436
+ const t = F();
1437
+ s.stage.hidden = !t && !$, s.palette.hidden = !t, s.discard && (s.discard.hidden = !t), s.restore && (s.restore.hidden = t || !X), t ? (s.palette.appendChild(s.discard), s.palette.appendChild(s.recapture)) : s.audio ? s.audio.after(s.recapture) : s.actions.insertBefore(s.recapture, s.submit || null), s.recapture.hidden = !1;
1298
1438
  }
1299
- function ar() {
1439
+ function gr() {
1440
+ F() && (X = T), T = "", J(null), tt(), _();
1441
+ }
1442
+ function wr() {
1443
+ D(X) && (T = X, tt(), _());
1444
+ }
1445
+ function Le() {
1446
+ return {
1447
+ capture: typeof d.capture == "function" ? d.capture : void 0,
1448
+ onBeforeCapture: typeof d.onBeforeCapture == "function" ? d.onBeforeCapture : void 0
1449
+ };
1450
+ }
1451
+ function Re(t) {
1452
+ if (!D(t))
1453
+ throw new Error("Screenshot failed; you can still send text.");
1454
+ T = t, X = t, m = Pt(), k = { w: 0, h: 0 }, M = null, b = null, w = null, J(null);
1455
+ }
1456
+ async function br() {
1457
+ if (!(wt || !s.dialog || s.dialog.hidden)) {
1458
+ wt = !0, s.recapture.disabled = !0, S("Capturing…", !0), s.dialog.hidden = !0;
1459
+ try {
1460
+ let t = "";
1461
+ try {
1462
+ t = await Un();
1463
+ } catch {
1464
+ t = await me(Le());
1465
+ }
1466
+ Re(t), S("");
1467
+ } catch (t) {
1468
+ S((t == null ? void 0 : t.message) || "Screenshot failed; you can still send text.");
1469
+ } finally {
1470
+ s.dialog.hidden = !1, s.recapture.disabled = !1, wt = !1, tt(), _();
1471
+ }
1472
+ }
1473
+ }
1474
+ function Sr() {
1300
1475
  try {
1301
- if (D || (D = On((e) => {
1476
+ if (U || (U = Kn((e) => {
1302
1477
  const n = s.text.value.trim();
1303
1478
  s.text.value = n ? `${n} ${e}` : e;
1304
- })), !D.isSupported()) {
1305
- v("Audio-to-text is not supported in this browser.");
1479
+ })), !U.isSupported()) {
1480
+ S("Audio-to-text is not supported in this browser.");
1306
1481
  return;
1307
1482
  }
1308
- const t = D.start();
1309
- kt(t), v(t ? "Listening…" : "");
1483
+ const t = U.start();
1484
+ Dt(t), S(t ? "Listening…" : "");
1310
1485
  } catch (t) {
1311
- v(t.message);
1486
+ S(t.message);
1312
1487
  }
1313
1488
  }
1314
- async function sr() {
1489
+ async function vr() {
1315
1490
  if (!d.video) {
1316
- v("Video is disabled on this host.");
1491
+ S("Video is disabled on this host.");
1317
1492
  return;
1318
1493
  }
1319
- s.dialog.hidden = !0, s.stop.hidden = !1, X(), s.launcher.hidden = !0, W = Fn({
1494
+ s.dialog.hidden = !0, s.stop.hidden = !1, Q(), s.launcher.hidden = !0, G = Yn({
1320
1495
  onStart() {
1321
1496
  },
1322
1497
  onStop(t) {
1323
- P = t, s.stop.hidden = !0, nt(), s.dialog.hidden = !1, G(), v(t ? "Video attached." : "Recording cancelled.");
1498
+ $ = t, s.stop.hidden = !0, ot(), s.dialog.hidden = !1, tt(), _(), S(t ? "Video attached." : "Recording cancelled.");
1324
1499
  },
1325
1500
  onError(t) {
1326
- v(t.message);
1501
+ S(t.message);
1327
1502
  }
1328
1503
  });
1329
1504
  try {
1330
- await W.start();
1505
+ await G.start();
1331
1506
  } catch (t) {
1332
- s.stop.hidden = !0, nt(), s.dialog.hidden = !1, v(t.message);
1507
+ s.stop.hidden = !0, ot(), s.dialog.hidden = !1, S(t.message);
1333
1508
  }
1334
1509
  }
1335
- function G() {
1336
- if (s.shot = null, !S) {
1337
- s.canvas.style.removeProperty("--nf-shot-aspect"), s.canvas.style.removeProperty("aspect-ratio"), s.canvas.innerHTML = P ? `<video class="nf-recording-preview" controls src="${URL.createObjectURL(P)}"></video>` : "", xt();
1510
+ function _() {
1511
+ if (s.shot = null, !F()) {
1512
+ s.canvas.style.removeProperty("--nf-shot-aspect"), s.canvas.style.removeProperty("aspect-ratio"), s.canvas.innerHTML = $ ? `<video class="nf-recording-preview" controls src="${URL.createObjectURL($)}"></video>` : "", lt();
1338
1513
  return;
1339
1514
  }
1340
- s.canvas.innerHTML = `<div class="nf-shot"><img alt="Screenshot" src="${S}" draggable="false"></div>`, s.shot = s.canvas.querySelector(".nf-shot");
1515
+ s.canvas.innerHTML = `<div class="nf-shot"><img alt="Screenshot" src="${T}" draggable="false"></div>`, s.shot = s.canvas.querySelector(".nf-shot");
1341
1516
  const t = s.shot.querySelector("img");
1342
1517
  t.draggable = !1, t.addEventListener("dragstart", (n) => n.preventDefault());
1343
1518
  const e = () => {
1344
- cr(t), M();
1519
+ xr(t), C();
1345
1520
  };
1346
- t.addEventListener("load", e), t.complete && t.naturalWidth && e();
1521
+ t.addEventListener("load", e), t.complete && t.naturalWidth && e(), lt();
1347
1522
  }
1348
- function cr(t) {
1349
- const e = t.naturalWidth || O.w, n = t.naturalHeight || O.h;
1350
- if (e && n && (O = { w: e, h: n }, s.canvas.style.setProperty("--nf-shot-aspect", String(e / n)), s.canvas.style.aspectRatio = `${e} / ${n}`), !s.shot || !O.w || !O.h)
1523
+ function xr(t) {
1524
+ const e = t.naturalWidth || k.w, n = t.naturalHeight || k.h;
1525
+ if (e && n && (k = { w: e, h: n }, s.canvas.style.setProperty("--nf-shot-aspect", String(e / n)), s.canvas.style.aspectRatio = `${e} / ${n}`), !s.shot || !k.w || !k.h)
1351
1526
  return;
1352
- const r = y.crop(), o = O.w / O.h, i = r.w / r.h * o, a = Math.min(1, i / o), c = Math.min(1, o / i);
1353
- s.shot.style.left = `${(1 - a) / 2 * 100}%`, s.shot.style.top = `${(1 - c) / 2 * 100}%`, s.shot.style.width = `${a * 100}%`, s.shot.style.height = `${c * 100}%`, t.style.width = `${100 / r.w}%`, t.style.height = `${100 / r.h}%`, t.style.left = `${-r.x / r.w * 100}%`, t.style.top = `${-r.y / r.h * 100}%`;
1527
+ const r = m.crop(), a = k.w / k.h, i = r.w / r.h * a, o = Math.min(1, i / a), c = Math.min(1, a / i);
1528
+ s.shot.style.left = `${(1 - o) / 2 * 100}%`, s.shot.style.top = `${(1 - c) / 2 * 100}%`, s.shot.style.width = `${o * 100}%`, s.shot.style.height = `${c * 100}%`, t.style.width = `${100 / r.w}%`, t.style.height = `${100 / r.h}%`, t.style.left = `${-r.x / r.w * 100}%`, t.style.top = `${-r.y / r.h * 100}%`;
1354
1529
  }
1355
- function lr(t) {
1530
+ function Er(t) {
1356
1531
  return t.type === "arrow" ? {
1357
1532
  id: "preview",
1358
1533
  type: "arrow",
@@ -1367,94 +1542,94 @@ function lr(t) {
1367
1542
  id: "preview",
1368
1543
  type: t.type,
1369
1544
  number: "",
1370
- ...st(t.start, t.current)
1545
+ ...ft(t.start, t.current)
1371
1546
  };
1372
1547
  }
1373
- function M() {
1374
- if ((s.shot || s.canvas).querySelectorAll(".nf-sticker, .nf-crop").forEach((i) => i.remove()), !S || !s.shot) {
1375
- xt();
1548
+ function C() {
1549
+ if ((s.shot || s.canvas).querySelectorAll(".nf-sticker, .nf-crop").forEach((i) => i.remove()), !F() || !s.shot) {
1550
+ lt();
1376
1551
  return;
1377
1552
  }
1378
- const e = y.crop(), n = Y(), r = At(n.clientWidth || 400);
1553
+ const e = m.crop(), n = Z(), r = kt(n.clientWidth || 400);
1379
1554
  if (s.shot.style.setProperty("--nf-anno-stroke", `${r.stroke}px`), s.shot.style.setProperty("--nf-anno-badge", `${r.badgeRadius * 2}px`), s.shot.style.setProperty("--nf-anno-badge-font", `${r.fontSize}px`), s.shot.style.setProperty("--nf-anno-handle", `${Math.max(8, r.stroke * 2.5)}px`), (b == null ? void 0 : b.kind) === "crop") {
1380
1555
  const i = document.createElement("div");
1381
- i.className = "nf-crop", Jt(i, st(b.start, b.current), { x: 0, y: 0, w: 1, h: 1 }), s.shot.appendChild(i);
1556
+ i.className = "nf-crop", re(i, ft(b.start, b.current), { x: 0, y: 0, w: 1, h: 1 }), s.shot.appendChild(i);
1382
1557
  }
1383
- const o = y.list().slice();
1384
- if ((b == null ? void 0 : b.kind) === "sticker" && o.push(lr(b)), o.forEach((i) => {
1385
- const a = i.id === "preview", c = !a && i.id === L, l = document.createElement("div");
1386
- if (l.className = `nf-sticker nf-${i.type}`, l.dataset.id = i.id, c && (l.dataset.selected = "true"), a && (l.dataset.preview = "true"), i.type === "arrow" ? ur(l, i, e, c, r) : (Jt(l, i, e), c && ["nw", "ne", "sw", "se"].forEach((u) => Et(l, u))), !a && i.number) {
1558
+ const a = m.list().slice();
1559
+ if ((b == null ? void 0 : b.kind) === "sticker" && a.push(Er(b)), a.forEach((i) => {
1560
+ const o = i.id === "preview", c = !o && i.id === M, l = document.createElement("div");
1561
+ if (l.className = `nf-sticker nf-${i.type}`, l.dataset.id = i.id, c && (l.dataset.selected = "true"), o && (l.dataset.preview = "true"), i.type === "arrow" ? Cr(l, i, e, c, r) : (re(l, i, e), c && ["nw", "ne", "sw", "se"].forEach((u) => Rt(l, u))), !o && i.number) {
1387
1562
  const u = document.createElement("span");
1388
1563
  u.className = "nf-badge", u.textContent = String(i.number), l.appendChild(u);
1389
1564
  }
1390
1565
  s.shot.appendChild(l);
1391
- }), s.canvas.querySelectorAll(":scope > .nf-recording-preview").forEach((i) => i.remove()), P) {
1566
+ }), s.canvas.querySelectorAll(":scope > .nf-recording-preview").forEach((i) => i.remove()), $) {
1392
1567
  const i = document.createElement("video");
1393
- i.className = "nf-recording-preview", i.controls = !0, i.src = URL.createObjectURL(P), i.style.position = "absolute", i.style.right = "8px", i.style.bottom = "8px", i.style.width = "160px", s.canvas.appendChild(i);
1568
+ i.className = "nf-recording-preview", i.controls = !0, i.src = URL.createObjectURL($), i.style.position = "absolute", i.style.right = "8px", i.style.bottom = "8px", i.style.width = "160px", s.canvas.appendChild(i);
1394
1569
  }
1395
- xt();
1570
+ lt();
1396
1571
  }
1397
- function ur(t, e, n, r, o = At(400)) {
1398
- const i = Y(), a = i.clientWidth, c = i.clientHeight, l = (e.x - n.x) / n.w * a, u = (e.y - n.y) / n.h * c, f = ((e.x2 ?? e.x + e.w) - n.x) / n.w * a, p = ((e.y2 ?? e.y) - n.y) / n.h * c, m = Math.max(18, o.arrowHead + o.stroke * 2), x = Math.min(l, f) - m, A = Math.min(u, p) - m, k = Math.max(2, Math.abs(f - l)) + m * 2, q = Math.max(2, Math.abs(p - u)) + m * 2, j = l - x, N = u - A, ct = f - x, lt = p - A, T = ue(j, N, ct, lt, o), _ = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1399
- t.style.left = `${x}px`, t.style.top = `${A}px`, t.style.width = `${k}px`, t.style.height = `${q}px`, _.setAttribute("class", "nf-arrow-svg"), _.setAttribute("viewBox", `0 0 ${k} ${q}`), _.setAttribute("width", String(k)), _.setAttribute("height", String(q)), _.innerHTML = `
1400
- <line class="nf-arrow-hit" x1="${j}" y1="${N}" x2="${ct}" y2="${lt}" />
1401
- <line class="nf-arrow-shaft" x1="${j}" y1="${N}" x2="${T.shaftEnd.x}" y2="${T.shaftEnd.y}" />
1402
- <polygon class="nf-arrow-head" points="${T.tipX},${T.tipY} ${T.left.x},${T.left.y} ${T.right.x},${T.right.y}" />
1403
- `, t.appendChild(_), r && (Et(t, "start", { left: j - 5, top: N - 5 }), Et(t, "end", { left: ct - 5, top: lt - 5 }));
1572
+ function Cr(t, e, n, r, a = kt(400)) {
1573
+ const i = Z(), o = i.clientWidth, c = i.clientHeight, l = (e.x - n.x) / n.w * o, u = (e.y - n.y) / n.h * c, f = ((e.x2 ?? e.x + e.w) - n.x) / n.w * o, p = ((e.y2 ?? e.y) - n.y) / n.h * c, y = Math.max(18, a.arrowHead + a.stroke * 2), v = Math.min(l, f) - y, A = Math.min(u, p) - y, I = Math.max(2, Math.abs(f - l)) + y * 2, Y = Math.max(2, Math.abs(p - u)) + y * 2, V = l - v, W = u - A, ht = f - v, pt = p - A, O = ge(V, W, ht, pt, a), z = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1574
+ t.style.left = `${v}px`, t.style.top = `${A}px`, t.style.width = `${I}px`, t.style.height = `${Y}px`, z.setAttribute("class", "nf-arrow-svg"), z.setAttribute("viewBox", `0 0 ${I} ${Y}`), z.setAttribute("width", String(I)), z.setAttribute("height", String(Y)), z.innerHTML = `
1575
+ <line class="nf-arrow-hit" x1="${V}" y1="${W}" x2="${ht}" y2="${pt}" />
1576
+ <line class="nf-arrow-shaft" x1="${V}" y1="${W}" x2="${O.shaftEnd.x}" y2="${O.shaftEnd.y}" />
1577
+ <polygon class="nf-arrow-head" points="${O.tipX},${O.tipY} ${O.left.x},${O.left.y} ${O.right.x},${O.right.y}" />
1578
+ `, t.appendChild(z), r && (Rt(t, "start", { left: V - 5, top: W - 5 }), Rt(t, "end", { left: ht - 5, top: pt - 5 }));
1404
1579
  }
1405
- function Et(t, e, n) {
1580
+ function Rt(t, e, n) {
1406
1581
  const r = document.createElement("span");
1407
1582
  r.className = "nf-handle", r.dataset.dir = e, n && (r.style.left = `${n.left}px`, r.style.top = `${n.top}px`), t.appendChild(r);
1408
1583
  }
1409
- function Jt(t, e, n) {
1584
+ function re(t, e, n) {
1410
1585
  t.style.left = `${(e.x - n.x) / n.w * 100}%`, t.style.top = `${(e.y - n.y) / n.h * 100}%`, t.style.width = `${e.w / n.w * 100}%`, t.style.height = `${e.h / n.h * 100}%`;
1411
1586
  }
1412
- function dr() {
1587
+ function Mr() {
1413
1588
  try {
1414
- return String(localStorage.getItem(pe) || "").trim();
1589
+ return String(localStorage.getItem(ve) || "").trim();
1415
1590
  } catch {
1416
1591
  return "";
1417
1592
  }
1418
1593
  }
1419
- function fr(t) {
1594
+ function Ar(t) {
1420
1595
  const e = String(t || "").trim();
1421
- if (!(!e || e === bt))
1596
+ if (!(!e || e === At))
1422
1597
  try {
1423
- localStorage.setItem(pe, e);
1598
+ localStorage.setItem(ve, e);
1424
1599
  } catch {
1425
1600
  }
1426
1601
  }
1427
- function Se() {
1602
+ function $e() {
1428
1603
  return !!(String(R.userId || "").trim() || String(R.email || "").trim() || String(R.displayName || "").trim());
1429
1604
  }
1430
- function hr() {
1605
+ function Lr() {
1431
1606
  return String(
1432
1607
  R.displayName || R.email || R.userId || ""
1433
1608
  ).trim();
1434
1609
  }
1435
- function pr() {
1610
+ function Rr() {
1436
1611
  var e;
1437
- if (Se())
1438
- return hr() || bt;
1612
+ if ($e())
1613
+ return Lr() || At;
1439
1614
  const t = String(((e = s.author) == null ? void 0 : e.value) || "").trim();
1440
- return t ? (fr(t), t) : bt;
1615
+ return t ? (Ar(t), t) : At;
1441
1616
  }
1442
- function ve() {
1617
+ function Te() {
1443
1618
  if (!s.author)
1444
1619
  return;
1445
- const t = Se();
1620
+ const t = $e();
1446
1621
  if (s.author.hidden = t, t) {
1447
1622
  s.author.value = "";
1448
1623
  return;
1449
1624
  }
1450
- s.author.value = dr();
1625
+ s.author.value = Mr();
1451
1626
  }
1452
- function xe(t, e = he) {
1627
+ function Pe(t, e = Se) {
1453
1628
  const n = Number(t);
1454
- return Number.isFinite(n) ? Math.min(Xn, Math.max(0, Math.floor(n))) : e;
1629
+ return Number.isFinite(n) ? Math.min(sr, Math.max(0, Math.floor(n))) : e;
1455
1630
  }
1456
- function Ee(t = {}) {
1457
- kn(t);
1631
+ function ke(t = {}) {
1632
+ Wn(t);
1458
1633
  const e = Object.prototype.hasOwnProperty.call(t, "kinds");
1459
1634
  d = {
1460
1635
  ...d,
@@ -1464,102 +1639,104 @@ function Ee(t = {}) {
1464
1639
  name: t.name == null ? d.name : String(t.name || ""),
1465
1640
  targets: t.targets === void 0 ? d.targets : t.targets,
1466
1641
  hideLauncher: t.hideLauncher == null ? d.hideLauncher : !!t.hideLauncher,
1467
- theme: me(t.theme ?? d.theme),
1642
+ theme: xe(t.theme ?? d.theme),
1468
1643
  video: t.video == null ? d.video : !!t.video,
1469
- consoleLogLimit: t.consoleLogLimit == null ? d.consoleLogLimit : xe(t.consoleLogLimit, d.consoleLogLimit),
1470
- kinds: e ? zn(t.kinds) : d.kinds
1644
+ consoleLogLimit: t.consoleLogLimit == null ? d.consoleLogLimit : Pe(t.consoleLogLimit, d.consoleLogLimit),
1645
+ kinds: e ? rr(t.kinds) : d.kinds,
1646
+ capture: t.capture === void 0 ? d.capture : t.capture,
1647
+ onBeforeCapture: t.onBeforeCapture === void 0 ? d.onBeforeCapture : t.onBeforeCapture
1471
1648
  };
1472
1649
  }
1473
- function Tt(t = {}) {
1474
- return Ee(t), h && X(), It;
1650
+ function Ft(t = {}) {
1651
+ return ke(t), h && Q(), Ut;
1475
1652
  }
1476
- function mr(t = {}) {
1477
- return Ee(t), Rt(), X(), It;
1653
+ function $r(t = {}) {
1654
+ return ke(t), Ot(), Q(), Ut;
1478
1655
  }
1479
- function yr(t) {
1480
- return Tt({ theme: t });
1656
+ function Tr(t) {
1657
+ return Ft({ theme: t });
1481
1658
  }
1482
- function gr(t) {
1659
+ function Pr(t) {
1483
1660
  const e = !!t;
1484
- return !e && h && s.dialog && !s.dialog.hidden && J(), Tt({ hideLauncher: !e });
1661
+ return !e && h && s.dialog && !s.dialog.hidden && et(), Ft({ hideLauncher: !e });
1485
1662
  }
1486
- async function Ce() {
1487
- Rt(), Me(), X(), s.launcher.hidden = !0, y = le(), O = { w: 0, h: 0 }, P = null, L = null, b = null, w = null, U = at(d.kinds), $t(U), St(null), kt(!1), s.text.value = "", ve(), v("");
1663
+ async function Ie() {
1664
+ Ot(), Oe(), Q(), s.launcher.hidden = !0, m = Pt(), k = { w: 0, h: 0 }, $ = null, T = "", X = "", M = null, b = null, w = null, j = dt(d.kinds), Bt(j), J(null), Dt(!1), s.text.value = "", Te(), S("");
1488
1665
  try {
1489
- S = await An(), K = S, s.stage.hidden = !1, s.restore.hidden = !0, v("");
1490
- } catch {
1491
- S = "", v("Screenshot failed; you can still send text.");
1666
+ Re(await me(Le())), S("");
1667
+ } catch (t) {
1668
+ T = "", S((t == null ? void 0 : t.message) || "Screenshot failed; you can still send text.");
1492
1669
  }
1493
- s.dialog.hidden = !1, G(), s.text.focus();
1670
+ tt(), s.dialog.hidden = !1, _(), s.text.focus();
1494
1671
  }
1495
- function J() {
1496
- h && (D == null || D.stop(), kt(!1), we(), b = null, w = null, Pt(!1), Me(), s.dialog.hidden = !0, s.stop.hidden = !0, nt());
1672
+ function et() {
1673
+ h && (U == null || U.stop(), Dt(!1), Me(), b = null, w = null, Ht(!1), Oe(), s.dialog.hidden = !0, s.stop.hidden = !0, ot());
1497
1674
  }
1498
- function wr() {
1675
+ function kr() {
1499
1676
  const t = s.dialog, e = s.panel, n = s.panelBody, r = s.successMsg;
1500
1677
  if (!t || !e || !n || !r)
1501
1678
  return Promise.resolve();
1502
- Lt = !0, v("");
1503
- const o = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, i = e.getBoundingClientRect();
1504
- if (n.hidden = !0, r.hidden = !1, t.classList.add("nf-success"), t.style.opacity = "1", o)
1679
+ It = !0, S("");
1680
+ const a = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, i = e.getBoundingClientRect();
1681
+ if (n.hidden = !0, r.hidden = !1, t.classList.add("nf-success"), t.style.opacity = "1", a)
1505
1682
  return new Promise((u) => {
1506
1683
  window.setTimeout(() => u(), 1e3);
1507
1684
  });
1508
- const a = e.getBoundingClientRect(), c = a.width > 0 ? i.width / a.width : 1, l = a.height > 0 ? i.height / a.height : 1;
1685
+ const o = e.getBoundingClientRect(), c = o.width > 0 ? i.width / o.width : 1, l = o.height > 0 ? i.height / o.height : 1;
1509
1686
  return e.style.transformOrigin = "center center", e.style.transition = "none", e.style.transform = `scale(${c}, ${l})`, e.getBoundingClientRect(), new Promise((u) => {
1510
1687
  let f = !1;
1511
1688
  const p = () => {
1512
- f || (f = !0, e.removeEventListener("transitionend", m), window.setTimeout(() => {
1689
+ f || (f = !0, e.removeEventListener("transitionend", y), window.setTimeout(() => {
1513
1690
  t.style.transition = "opacity 0.28s ease", t.style.opacity = "0", window.setTimeout(() => u(), 280);
1514
1691
  }, 1e3));
1515
- }, m = (x) => {
1516
- x.target !== e || x.propertyName !== "transform" || p();
1692
+ }, y = (v) => {
1693
+ v.target !== e || v.propertyName !== "transform" || p();
1517
1694
  };
1518
- e.addEventListener("transitionend", m), requestAnimationFrame(() => {
1695
+ e.addEventListener("transitionend", y), requestAnimationFrame(() => {
1519
1696
  e.style.transition = "transform 0.48s cubic-bezier(0.22, 1, 0.36, 1)", e.style.transform = "scale(1)";
1520
1697
  }), window.setTimeout(p, 700);
1521
1698
  });
1522
1699
  }
1523
- function Me() {
1524
- Lt = !1, s.dialog && (s.dialog.classList.remove("nf-success"), s.dialog.style.opacity = "", s.dialog.style.transition = "", s.panel && (s.panel.style.transform = "", s.panel.style.transition = "", s.panel.style.transformOrigin = ""), s.panelBody && (s.panelBody.hidden = !1), s.successMsg && (s.successMsg.hidden = !0));
1700
+ function Oe() {
1701
+ It = !1, s.dialog && (s.dialog.classList.remove("nf-success"), s.dialog.style.opacity = "", s.dialog.style.transition = "", s.panel && (s.panel.style.transform = "", s.panel.style.transition = "", s.panel.style.transformOrigin = ""), s.panelBody && (s.panelBody.hidden = !1), s.successMsg && (s.successMsg.hidden = !0));
1525
1702
  }
1526
- function br(t = {}) {
1527
- R = { ...R, ...Pn(t) }, ve();
1703
+ function Ir(t = {}) {
1704
+ R = { ...R, ...Vn(t) }, Te();
1528
1705
  }
1529
- async function Ae() {
1530
- if (Rt(), ht)
1706
+ async function Be() {
1707
+ if (Ot(), bt)
1531
1708
  return null;
1532
1709
  const t = s.text.value.trim();
1533
- if (!t && !S && !P)
1534
- return v("Add a note, screenshot, or video first."), null;
1710
+ if (!t && !F() && !$)
1711
+ return S("Add a note, screenshot, or video first."), null;
1535
1712
  if (!d.endpoint || !d.projectKey)
1536
- return v("Notefully is missing endpoint or projectKey."), null;
1537
- ht = !0, Qt(!0), v("Submitting…", !0);
1713
+ return S("Notefully is missing endpoint or projectKey."), null;
1714
+ bt = !0, ie(!0), S("Submitting…", !0);
1538
1715
  try {
1539
- const e = pr(), n = new FormData();
1540
- if (n.append("message", t), n.append("kind", U), n.append("version", d.version || "0.0.0"), n.append("author", e), d.name && n.append("name", d.name), n.append("context", JSON.stringify({
1541
- ...$n({
1716
+ const e = Rr(), n = new FormData();
1717
+ if (n.append("message", t), n.append("kind", j), n.append("version", d.version || "0.0.0"), n.append("author", e), d.name && n.append("name", d.name), n.append("context", JSON.stringify({
1718
+ ..._n({
1542
1719
  ...R,
1543
1720
  displayName: R.displayName || e
1544
1721
  }),
1545
1722
  author: e,
1546
- console: fe.snapshot().slice(-xe(d.consoleLogLimit))
1547
- })), n.append("annotations", JSON.stringify(y.list())), n.append("crop", JSON.stringify(y.crop())), Array.isArray(d.targets) && n.append("targets", JSON.stringify(d.targets)), S) {
1548
- const i = await Yn(S);
1549
- if (n.append("screenshot", i, "screenshot.png"), y.list().length || y.isCropped()) {
1550
- const a = await Vn(
1551
- S,
1552
- y.crop(),
1553
- y.list(),
1723
+ console: be.snapshot().slice(-Pe(d.consoleLogLimit))
1724
+ })), n.append("annotations", JSON.stringify(m.list())), n.append("crop", JSON.stringify(m.crop())), Array.isArray(d.targets) && n.append("targets", JSON.stringify(d.targets)), F()) {
1725
+ const i = await cr(T);
1726
+ if (n.append("screenshot", i, "screenshot.png"), m.list().length || m.isCropped()) {
1727
+ const o = await nr(
1728
+ T,
1729
+ m.crop(),
1730
+ m.list(),
1554
1731
  {
1555
- mark: Xt("--nf-mark", "#fdd341"),
1556
- markText: Xt("--nf-mark-text", "#2a2140")
1732
+ mark: te("--nf-mark", "#fdd341"),
1733
+ markText: te("--nf-mark-text", "#2a2140")
1557
1734
  }
1558
1735
  );
1559
- n.append("screenshotBaked", a, "screenshot.baked.png");
1736
+ n.append("screenshotBaked", o, "screenshot.baked.png");
1560
1737
  }
1561
1738
  }
1562
- P && n.append("recording", P, "recording.webm");
1739
+ $ && n.append("recording", $, "recording.webm");
1563
1740
  const r = await fetch(`${d.endpoint}/v1/reports`, {
1564
1741
  method: "POST",
1565
1742
  headers: {
@@ -1567,36 +1744,36 @@ async function Ae() {
1567
1744
  },
1568
1745
  body: n
1569
1746
  });
1570
- let o = null;
1747
+ let a = null;
1571
1748
  try {
1572
- o = await r.json();
1749
+ a = await r.json();
1573
1750
  } catch {
1574
- o = null;
1751
+ a = null;
1575
1752
  }
1576
1753
  if (!r.ok)
1577
- throw v((o == null ? void 0 : o.error) || "Submit failed."), new Error((o == null ? void 0 : o.error) || `Submit failed (${r.status})`);
1578
- return await wr(), J(), o;
1754
+ throw S((a == null ? void 0 : a.error) || "Submit failed."), new Error((a == null ? void 0 : a.error) || `Submit failed (${r.status})`);
1755
+ return await kr(), et(), a;
1579
1756
  } finally {
1580
- ht = !1, Qt(!1);
1757
+ bt = !1, ie(!1);
1581
1758
  }
1582
1759
  }
1583
- function Qt(t) {
1760
+ function ie(t) {
1584
1761
  s.submit && (s.submit.disabled = !!t, s.submit.setAttribute("aria-busy", t ? "true" : "false"));
1585
1762
  }
1586
- function Sr() {
1587
- J(), h == null || h.remove(), h = null, s = {};
1763
+ function Or() {
1764
+ et(), h == null || h.remove(), h = null, s = {};
1588
1765
  }
1589
- const It = { init: mr, configure: Tt, setTheme: yr, setVisible: gr, open: Ce, close: J, identify: br, submit: Ae, destroy: Sr };
1590
- typeof window < "u" && (window.Notefully = It);
1766
+ const Ut = { init: $r, configure: Ft, setTheme: Tr, setVisible: Pr, open: Ie, close: et, identify: Ir, submit: Be, destroy: Or };
1767
+ typeof window < "u" && (window.Notefully = Ut);
1591
1768
  export {
1592
- J as close,
1593
- Tt as configure,
1594
- It as default,
1595
- Sr as destroy,
1596
- br as identify,
1597
- mr as init,
1598
- Ce as open,
1599
- yr as setTheme,
1600
- gr as setVisible,
1601
- Ae as submit
1769
+ et as close,
1770
+ Ft as configure,
1771
+ Ut as default,
1772
+ Or as destroy,
1773
+ Ir as identify,
1774
+ $r as init,
1775
+ Ie as open,
1776
+ Tr as setTheme,
1777
+ Pr as setVisible,
1778
+ Be as submit
1602
1779
  };