@getpinax/widget 0.0.0-stage → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +267 -2
  3. package/dist/api.d.ts +62 -0
  4. package/dist/capture/breadcrumbs.d.ts +49 -0
  5. package/dist/capture/console.d.ts +17 -0
  6. package/dist/capture/env.d.ts +25 -0
  7. package/dist/capture/network.d.ts +23 -0
  8. package/dist/capture/ring.d.ts +14 -0
  9. package/dist/capture/signature.d.ts +2 -0
  10. package/dist/capture/text.d.ts +7 -0
  11. package/dist/capture/ua.d.ts +13 -0
  12. package/dist/chunks/editor-DbHLGwOA.mjs +1368 -0
  13. package/dist/chunks/privacy-DmU6v5Fr.mjs +39 -0
  14. package/dist/chunks/recorder-BUtEB_em.mjs +2859 -0
  15. package/dist/chunks/text-8QYEyRYs.mjs +18 -0
  16. package/dist/chunks/widget-CkR1Ptzb.mjs +961 -0
  17. package/dist/editor/annotator.d.ts +20 -0
  18. package/dist/editor/capture.d.ts +28 -0
  19. package/dist/editor/encode.d.ts +7 -0
  20. package/dist/editor/index.d.ts +5 -0
  21. package/dist/editor/mask.d.ts +29 -0
  22. package/dist/editor/pii.d.ts +22 -0
  23. package/dist/editor/shapes.d.ts +31 -0
  24. package/dist/editor-loader.d.ts +6 -0
  25. package/dist/editor-loader.embed.d.ts +5 -0
  26. package/dist/fixcheck.d.ts +31 -0
  27. package/dist/index.d.ts +46 -0
  28. package/dist/mount.d.ts +8 -0
  29. package/dist/navigation.d.ts +1 -0
  30. package/dist/paths.d.ts +4 -0
  31. package/dist/pinax-editor.js +1417 -0
  32. package/dist/pinax-recorder.js +2902 -0
  33. package/dist/pinax.js +113 -0
  34. package/dist/pinax.mjs +1041 -0
  35. package/dist/preview.d.ts +35 -0
  36. package/dist/preview.mjs +54 -0
  37. package/dist/privacy.d.ts +22 -0
  38. package/dist/queue.d.ts +9 -0
  39. package/dist/replay/buffer.d.ts +40 -0
  40. package/dist/replay/recorder.d.ts +15 -0
  41. package/dist/replay/sanitize.d.ts +13 -0
  42. package/dist/report.d.ts +109 -0
  43. package/dist/segment.d.ts +31 -0
  44. package/dist/settings.d.ts +31 -0
  45. package/dist/types.d.ts +137 -0
  46. package/dist/ui/color.d.ts +7 -0
  47. package/dist/ui/dom.d.ts +14 -0
  48. package/dist/ui/styles.d.ts +3 -0
  49. package/dist/ui/widget.d.ts +161 -0
  50. package/package.json +73 -4
@@ -0,0 +1,1417 @@
1
+ // src/ui/dom.ts
2
+ function e(e, t = {}, ...n) {
3
+ let r = document.createElement(e);
4
+ for (let [e, n] of Object.entries(t)) n != null && n !== !1 && r.setAttribute(e, n === !0 ? "" : String(n));
5
+ for (let e of n) e != null && e !== !1 && r.append(e);
6
+ return r;
7
+ }
8
+ // src/editor/shapes.ts
9
+ var t = "#FF5C35";
10
+ function n(e) {
11
+ return e.type === "arrow" || e.type === "text" ? e : {
12
+ ...e,
13
+ x: Math.min(e.x, e.x + e.w),
14
+ y: Math.min(e.y, e.y + e.h),
15
+ w: Math.abs(e.w),
16
+ h: Math.abs(e.h)
17
+ };
18
+ }
19
+ function r(e, t) {
20
+ return Math.max(3, Math.round(Math.min(e, t) / 220));
21
+ }
22
+ function i(e, t) {
23
+ return Math.max(13, Math.round(Math.min(e, t) / 55));
24
+ }
25
+ function a(e, t, n, r, i, a) {
26
+ let o = Math.min(a, r / 2, i / 2);
27
+ e.beginPath(), e.moveTo(t + o, n), e.arcTo(t + r, n, t + r, n + i, o), e.arcTo(t + r, n + i, t, n + i, o), e.arcTo(t, n + i, t, n, o), e.arcTo(t, n, t + r, n, o), e.closePath();
28
+ }
29
+ function o(e, t, n) {
30
+ e.font = `700 ${n}px Manrope, system-ui, sans-serif`;
31
+ let r = Math.round(n * .6);
32
+ return {
33
+ w: Math.ceil(e.measureText(t).width) + r * 2,
34
+ h: Math.round(n * 1.9),
35
+ pad: r
36
+ };
37
+ }
38
+ function s(e, s, c, l, u) {
39
+ let d = r(l, u), f = n(s);
40
+ if (e.save(), f.type === "box") e.strokeStyle = t, e.lineWidth = d, a(e, f.x, f.y, f.w, f.h, d * 2.5), e.stroke();
41
+ else if (f.type === "blur") {
42
+ let t = Math.max(1, Math.round(f.w)), n = Math.max(1, Math.round(f.h)), r = Math.max(8, Math.round(Math.min(l, u) / 70)), i = c, a = f.x, o = f.y, s = t, d = n, p = Math.max(1, Math.ceil(t / r)), m = Math.max(1, Math.ceil(n / r));
43
+ for (; s > p || d > m;) {
44
+ let e = Math.max(p, Math.ceil(s / 2)), t = Math.max(m, Math.ceil(d / 2)), n = document.createElement("canvas");
45
+ n.width = e, n.height = t;
46
+ let r = n.getContext("2d");
47
+ if (!r) break;
48
+ r.imageSmoothingEnabled = !0, r.imageSmoothingQuality = "high", r.drawImage(i, a, o, s, d, 0, 0, e, t), i = n, a = 0, o = 0, s = e, d = t;
49
+ }
50
+ e.imageSmoothingEnabled = !1, e.drawImage(i, a, o, s, d, f.x, f.y, t, n);
51
+ } else if (f.type === "arrow") {
52
+ let n = f.x + f.w, r = f.y + f.h, i = Math.atan2(f.h, f.w), a = d * 4.5;
53
+ e.strokeStyle = t, e.lineWidth = d, e.lineCap = "round", e.lineJoin = "round", e.beginPath(), e.moveTo(f.x, f.y), e.lineTo(n, r), e.moveTo(n - a * Math.cos(i - Math.PI / 6), r - a * Math.sin(i - Math.PI / 6)), e.lineTo(n, r), e.lineTo(n - a * Math.cos(i + Math.PI / 6), r - a * Math.sin(i + Math.PI / 6)), e.stroke();
54
+ } else if (f.type === "text" && f.text) {
55
+ let t = i(l, u), n = o(e, f.text, t);
56
+ e.fillStyle = "#CC3F1B", a(e, f.x, f.y, n.w, n.h, t * .5), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.fillText(f.text, f.x + n.pad, f.y + n.h / 2);
57
+ }
58
+ e.restore();
59
+ }
60
+ function c(e, t, r) {
61
+ let i = [];
62
+ for (let a of e) {
63
+ let e = n(a), o = e.type === "text" ? r(e) : {
64
+ w: e.w,
65
+ h: e.h
66
+ }, s = Math.min(e.x, e.x + o.w), c = Math.max(e.x, e.x + o.w), l = Math.min(e.y, e.y + o.h), u = Math.max(e.y, e.y + o.h);
67
+ if (c < t.x || s > t.x + t.w || u < t.y || l > t.y + t.h) continue;
68
+ let d = {
69
+ type: e.type,
70
+ x: (e.x - t.x) / t.w,
71
+ y: (e.y - t.y) / t.h,
72
+ w: o.w / t.w,
73
+ h: o.h / t.h
74
+ };
75
+ e.type === "text" && (d.text = e.text), i.push(d);
76
+ }
77
+ return i;
78
+ }
79
+ // src/editor/annotator.ts
80
+ var l = [
81
+ ["box", "Box"],
82
+ ["arrow", "Arrow"],
83
+ ["text", "Text"],
84
+ ["blur", "Blur"]
85
+ ], u = 6;
86
+ function d(t, r, a, d = []) {
87
+ return new Promise((m) => {
88
+ let h = r.width, g = r.height, _ = a ? a.shapes.map((e) => ({ ...e })) : [], v = a?.area ? { ...a.area } : null, y = "box", b = v ? "area" : "full", x = null, S = null, C = null, ee = t.activeElement, w = e("style");
89
+ w.textContent = "\n.ed { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; gap: 12px; padding: 12px; background: rgba(7,11,23,0.92); font-family: Manrope, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; color: #E8ECF7; font-size: 13px; }\n.ed * { box-sizing: border-box; }\n.ed button { font: inherit; cursor: pointer; }\n.ed :focus-visible { outline: 3px solid #B8F35C; outline-offset: 2px; }\n.ed-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-radius: 14px; background: #0E1426; box-shadow: inset 0 0 0 1px rgba(157,180,255,0.16); }\n.ed-grp { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }\n.ed-sep { width: 1px; align-self: stretch; background: rgba(157,180,255,0.16); margin: 0 2px; }\n.ed-t { min-height: 36px; padding: 8px 12px; border: 0; border-radius: 8px; background: rgba(255,255,255,0.06); color: #E8ECF7; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }\n.ed-t:hover { background: rgba(255,255,255,0.1); }\n.ed-t[aria-pressed=true] { background: #B8F35C; color: #0B1300; font-weight: 700; }\n.ed-t:disabled { opacity: .45; cursor: default; }\n.ed-sp { flex: 1; }\n.ed-done { background: #B8F35C; color: #0B1300; font-weight: 800; }\n.ed-done:hover { background: #CFF59A; }\n.ed-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }\n.ed-cv { display: block; max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6); touch-action: none; cursor: crosshair; background: #FFFFFF; }\n.ed-hint { margin: 0; text-align: center; color: #A7B2CC; font-size: 13px; }\n.ed-txt { position: absolute; min-width: 160px; padding: 8px 10px; border: 0; border-radius: 8px; background: #CC3F1B; color: #FFFFFF; font: 700 14px Manrope, system-ui, sans-serif; box-shadow: 0 0 0 3px #FFFFFF; }\n.ed-txt::placeholder { color: rgba(255,255,255,0.85); }\n.ed-txt:focus { outline: none; }\n.ed-auto { margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; color: #CFF59A; font-size: 13px; font-weight: 600; text-align: center; }\n.ed-auto i { flex: none; width: 18px; height: 12px; border-radius: 3px; border: 2px dashed #B8F35C; background: repeating-linear-gradient(90deg, #D8DEE9 0 4px, #C7CFDC 4px 8px); }\n.ed-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@media (max-width: 640px) { .ed { padding: 8px; gap: 8px; } .ed-bar { padding: 8px; gap: 6px; } .ed-t { padding: 8px 10px; } .ed-sep { display: none; } }\n";
90
+ let T = e("div", {
91
+ class: "ed-sr",
92
+ role: "status",
93
+ "aria-live": "polite"
94
+ }), E = (e) => {
95
+ T.textContent = e;
96
+ }, D = e("canvas", {
97
+ class: "ed-cv",
98
+ width: h,
99
+ height: g,
100
+ tabindex: 0,
101
+ role: "img"
102
+ }), O = D.getContext("2d"), k = (t, n = "ed-t", r = {}) => e("button", {
103
+ type: "button",
104
+ class: n,
105
+ ...r
106
+ }, t), A = k("Whole screen", "ed-t", { "aria-pressed": "true" }), j = k("Select area", "ed-t", { "aria-pressed": "false" }), M = l.map(([e, t]) => {
107
+ let n = k(t, "ed-t", {
108
+ "aria-pressed": "false",
109
+ "data-tool": e
110
+ });
111
+ return n.addEventListener("click", () => {
112
+ y = e, L = !1, v || (b = "full"), U();
113
+ }), n;
114
+ }), N = k("Undo"), P = k("Clear"), F = k("Cancel"), I = k("Done", "ed-t ed-done"), te = e("p", {
115
+ class: "ed-hint",
116
+ id: "pnx-ed-hint"
117
+ }), ne = d.length ? e("p", {
118
+ class: "ed-auto",
119
+ id: "pnx-ed-auto"
120
+ }, e("i", { "aria-hidden": "true" }), `${d.length === 1 ? "1 private detail was" : `${d.length} private details were`} blurred automatically (outlined). They stay blurred.`) : null;
121
+ D.setAttribute("aria-describedby", ne ? "pnx-ed-hint pnx-ed-auto" : "pnx-ed-hint");
122
+ let L = !1;
123
+ A.addEventListener("click", () => {
124
+ v = null, b = "full", L = !1, E("Whole screen selected."), U();
125
+ }), j.addEventListener("click", () => {
126
+ b = "area", L = !0, E("Drag over the part of the screenshot to keep."), U(), D.focus();
127
+ }), N.addEventListener("click", () => {
128
+ _.pop() && E("Last mark removed."), U();
129
+ }), P.addEventListener("click", () => {
130
+ _.length = 0, E("All marks cleared."), U();
131
+ });
132
+ let re = e("div", {
133
+ class: "ed-bar",
134
+ role: "toolbar",
135
+ "aria-label": "Screenshot tools"
136
+ }, e("div", {
137
+ class: "ed-grp",
138
+ role: "group",
139
+ "aria-label": "Capture"
140
+ }, A, j), e("span", {
141
+ class: "ed-sep",
142
+ "aria-hidden": "true"
143
+ }), e("div", {
144
+ class: "ed-grp",
145
+ role: "group",
146
+ "aria-label": "Draw"
147
+ }, ...M), e("span", {
148
+ class: "ed-sep",
149
+ "aria-hidden": "true"
150
+ }), e("div", { class: "ed-grp" }, N, P), e("span", { class: "ed-sp" }), e("div", { class: "ed-grp" }, F, I)), R = e("div", { class: "ed-stage" }, D), z = e("div", {
151
+ class: "ed",
152
+ role: "dialog",
153
+ "aria-modal": "true",
154
+ "aria-label": "Mark up screenshot"
155
+ }, re, R, te, ne, T), B = (e) => o(O, e.text ?? "", i(h, g));
156
+ function V() {
157
+ O.clearRect(0, 0, h, g), O.drawImage(r, 0, 0);
158
+ for (let e of _) s(O, e, r, h, g);
159
+ x && s(O, x, r, h, g), H();
160
+ let e = S ? f(S) : v;
161
+ if (e) {
162
+ O.save(), O.fillStyle = "rgba(7,11,23,0.55)", O.beginPath(), O.rect(0, 0, h, g), O.rect(e.x, e.y, e.w, e.h), O.fill("evenodd");
163
+ let t = Math.max(2, Math.round(Math.min(h, g) / 400));
164
+ O.setLineDash([t * 4, t * 3]), O.lineWidth = t, O.strokeStyle = "#7C9CFF", O.strokeRect(e.x, e.y, e.w, e.h), O.restore();
165
+ }
166
+ }
167
+ function H() {
168
+ if (!d.length) return;
169
+ let e = Math.max(2, Math.round(Math.min(h, g) / 450)), t = Math.max(11, Math.round(i(h, g) * .75));
170
+ O.save(), O.lineWidth = e, O.setLineDash([e * 3, e * 2]), O.strokeStyle = "#B8F35C", O.font = `800 ${t}px Manrope, system-ui, sans-serif`, O.textBaseline = "middle";
171
+ for (let e of d) O.strokeRect(e.x, e.y, e.w, e.h);
172
+ let n = d[0], r = "Auto-blurred", a = Math.round(t * .5), o = Math.ceil(O.measureText(r).width) + a * 2, s = Math.round(t * 1.7), c = Math.min(Math.max(0, n.x), h - o), l = n.y - s - e >= 0 ? n.y - s - e : n.y + n.h + e;
173
+ O.setLineDash([]), O.fillStyle = "#B8F35C", O.fillRect(c, l, o, s), O.fillStyle = "#0B1300", O.fillText(r, c + a, l + s / 2), O.restore();
174
+ }
175
+ function U() {
176
+ A.setAttribute("aria-pressed", String(b === "full")), j.setAttribute("aria-pressed", String(b === "area"));
177
+ for (let e of M) e.setAttribute("aria-pressed", String(!L && e.dataset.tool === y));
178
+ N.disabled = _.length === 0, P.disabled = _.length === 0;
179
+ let e = _.length;
180
+ D.setAttribute("aria-label", `Screenshot of the page${e ? `, ${e} ${e === 1 ? "mark" : "marks"}` : ""}${d.length ? `, ${d.length} blurred automatically` : ""}${v ? ", area selected" : ""}`), te.textContent = L ? "Drag over the part you want to send." : y === "text" ? "Tap where the label should go, then type." : `Drag to draw a ${y === "blur" ? "blurred area" : y}, or tap to place one.`, V();
181
+ }
182
+ function W(e) {
183
+ let t = D.getBoundingClientRect();
184
+ return {
185
+ x: (e.clientX - t.left) / t.width * h,
186
+ y: (e.clientY - t.top) / t.height * g
187
+ };
188
+ }
189
+ function G(e, t, n) {
190
+ let r = h * .16, i = g * .12;
191
+ if (e === "arrow") {
192
+ let e = h * .08, r = g * .08, i = t - e < 0 ? 1 : -1, a = n - r < 0 ? 1 : -1;
193
+ return {
194
+ type: "arrow",
195
+ x: t + i * e,
196
+ y: n + a * r,
197
+ w: -i * e,
198
+ h: -a * r
199
+ };
200
+ }
201
+ return {
202
+ type: e,
203
+ x: ie(t - r / 2, r),
204
+ y: ae(n - i / 2, i),
205
+ w: r,
206
+ h: i
207
+ };
208
+ }
209
+ let ie = (e, t) => Math.min(Math.max(0, e), h - t), ae = (e, t) => Math.min(Math.max(0, e), g - t);
210
+ function K(e) {
211
+ _.push(n(e)), E(`${e.type === "blur" ? "Blurred area" : e.type[0].toUpperCase() + e.type.slice(1)} added.`), U();
212
+ }
213
+ function q(t, n) {
214
+ C?.remove();
215
+ let r = e("input", {
216
+ class: "ed-txt",
217
+ type: "text",
218
+ maxlength: 120,
219
+ "aria-label": "Label text",
220
+ placeholder: "Type a label, then Enter",
221
+ autocomplete: "off"
222
+ }), a = D.getBoundingClientRect(), s = R.getBoundingClientRect(), c = a.left - s.left + t / h * a.width, l = a.top - s.top + n / g * a.height;
223
+ r.style.left = `${Math.min(c, s.width - 170)}px`, r.style.top = `${Math.min(l, s.height - 40)}px`;
224
+ let u = !1, d = (e) => {
225
+ if (u) return;
226
+ u = !0;
227
+ let a = r.value.trim();
228
+ if (r.remove(), C = null, e && a) {
229
+ let e = i(h, g), r = o(O, a, e);
230
+ K({
231
+ type: "text",
232
+ x: ie(t, r.w),
233
+ y: ae(n, r.h),
234
+ w: r.w,
235
+ h: r.h,
236
+ text: a
237
+ });
238
+ }
239
+ D.focus();
240
+ };
241
+ r.addEventListener("keydown", (e) => {
242
+ e.stopPropagation(), e.key === "Enter" && d(!0), e.key === "Escape" && d(!1);
243
+ }), r.addEventListener("blur", () => d(!0)), R.append(r), C = r, r.focus();
244
+ }
245
+ let J = null;
246
+ D.addEventListener("pointerdown", (e) => {
247
+ J || e.pointerType === "mouse" && e.button !== 0 || (e.preventDefault(), D.setPointerCapture?.(e.pointerId), J = {
248
+ ...W(e),
249
+ cx: e.clientX,
250
+ cy: e.clientY,
251
+ id: e.pointerId
252
+ });
253
+ }), D.addEventListener("pointermove", (e) => {
254
+ if (!J || e.pointerId !== J.id) return;
255
+ let t = W(e);
256
+ L ? S = {
257
+ x: J.x,
258
+ y: J.y,
259
+ w: t.x - J.x,
260
+ h: t.y - J.y
261
+ } : y !== "text" && (x = {
262
+ type: y,
263
+ x: J.x,
264
+ y: J.y,
265
+ w: t.x - J.x,
266
+ h: t.y - J.y
267
+ }), V();
268
+ });
269
+ let Y = (e, t = !1) => {
270
+ if (!J || e.pointerId !== J.id) return;
271
+ let n = J;
272
+ J = null;
273
+ let r = Math.hypot(e.clientX - n.cx, e.clientY - n.cy) > u, i = W(e);
274
+ if (x = null, t) S = null, V();
275
+ else if (L) {
276
+ S = null;
277
+ let e = p(f({
278
+ x: n.x,
279
+ y: n.y,
280
+ w: i.x - n.x,
281
+ h: i.y - n.y
282
+ }), h, g);
283
+ r && e.w > 8 && e.h > 8 && (v = e, L = !1, E("Area selected.")), U();
284
+ } else y === "text" ? q(n.x, n.y) : K(r ? {
285
+ type: y,
286
+ x: n.x,
287
+ y: n.y,
288
+ w: i.x - n.x,
289
+ h: i.y - n.y
290
+ } : G(y, n.x, n.y));
291
+ };
292
+ D.addEventListener("pointerup", (e) => Y(e)), D.addEventListener("pointercancel", (e) => Y(e, !0)), D.addEventListener("keydown", (e) => {
293
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), L ? (v = {
294
+ x: h * .2,
295
+ y: g * .2,
296
+ w: h * .6,
297
+ h: g * .6
298
+ }, L = !1, E("Middle of the screenshot selected."), U()) : y === "text" ? q(h * .4, g * .45) : K(G(y, h / 2, g / 2)));
299
+ });
300
+ function X(e) {
301
+ z.removeEventListener("keydown", se, !0), z.remove(), w.remove();
302
+ try {
303
+ ee?.focus();
304
+ } catch {}
305
+ m(e);
306
+ }
307
+ function oe() {
308
+ let e = v ?? {
309
+ x: 0,
310
+ y: 0,
311
+ w: h,
312
+ h: g
313
+ }, t = document.createElement("canvas");
314
+ t.width = Math.max(1, Math.round(e.w)), t.height = Math.max(1, Math.round(e.h));
315
+ let n = t.getContext("2d"), i = document.createElement("canvas");
316
+ i.width = h, i.height = g;
317
+ let a = i.getContext("2d");
318
+ a.drawImage(r, 0, 0);
319
+ for (let e of _) s(a, e, r, h, g);
320
+ n.drawImage(i, e.x, e.y, e.w, e.h, 0, 0, t.width, t.height), i.width = 0, i.height = 0, X({
321
+ canvas: t,
322
+ annotations: c(_, e, B),
323
+ state: {
324
+ shapes: _.map((e) => ({ ...e })),
325
+ area: v
326
+ }
327
+ });
328
+ }
329
+ F.addEventListener("click", () => X(null)), I.addEventListener("click", oe);
330
+ function se(e) {
331
+ if (e.key === "Escape") e.preventDefault(), e.stopPropagation(), X(null);
332
+ else if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "z") e.preventDefault(), _.pop() && E("Last mark removed."), U();
333
+ else if (e.key === "Tab") {
334
+ let n = [...z.querySelectorAll("button:not(:disabled), canvas, input")];
335
+ if (!n.length) return;
336
+ let r = n[0], i = n[n.length - 1], a = t.activeElement;
337
+ e.shiftKey && a === r ? (e.preventDefault(), i.focus()) : !e.shiftKey && a === i && (e.preventDefault(), r.focus());
338
+ }
339
+ }
340
+ z.addEventListener("keydown", se, !0), t.append(w, z), U(), M[0].focus();
341
+ });
342
+ }
343
+ function f(e) {
344
+ return {
345
+ x: Math.min(e.x, e.x + e.w),
346
+ y: Math.min(e.y, e.y + e.h),
347
+ w: Math.abs(e.w),
348
+ h: Math.abs(e.h)
349
+ };
350
+ }
351
+ function p(e, t, n) {
352
+ let r = Math.max(0, e.x), i = Math.max(0, e.y);
353
+ return {
354
+ x: r,
355
+ y: i,
356
+ w: Math.max(0, Math.min(t, e.x + e.w) - r),
357
+ h: Math.max(0, Math.min(n, e.y + e.h) - i)
358
+ };
359
+ }
360
+ var m = "[modern-screenshot]", h = typeof window < "u", g = h && "Worker" in window;
361
+ h && "atob" in window, h && "btoa" in window;
362
+ var _ = h ? window.navigator?.userAgent : "", v = _.includes("Chrome"), y = _.includes("AppleWebKit") && !v, b = _.includes("Firefox"), x = (e) => e && "__CONTEXT__" in e, S = (e) => e.constructor.name === "CSSFontFaceRule", C = (e) => e.constructor.name === "CSSImportRule", ee = (e) => e.constructor.name === "CSSLayerBlockRule", w = (e) => e.nodeType === 1, T = (e) => typeof e.className == "object", E = (e) => e.tagName === "image", D = (e) => e.tagName === "use", O = (e) => w(e) && e.style !== void 0 && !T(e), k = (e) => e.nodeType === 8, A = (e) => e.nodeType === 3, j = (e) => e.tagName === "IMG", M = (e) => e.tagName === "VIDEO", N = (e) => e.tagName === "CANVAS", P = (e) => e.tagName === "TEXTAREA", F = (e) => e.tagName === "INPUT", I = (e) => e.tagName === "STYLE", te = (e) => e.tagName === "SCRIPT", ne = (e) => e.tagName === "SELECT", L = (e) => e.tagName === "SLOT", re = (e) => e.tagName === "IFRAME", R = (...e) => console.warn(m, ...e);
363
+ function z(e) {
364
+ let t = e?.createElement?.("canvas");
365
+ return t && (t.height = t.width = 1), !!t && "toDataURL" in t && !!t.toDataURL("image/webp").includes("image/webp");
366
+ }
367
+ var B = (e) => e.startsWith("data:");
368
+ function V(e, t) {
369
+ if (e.match(/^[a-z]+:\/\//i)) return e;
370
+ if (h && e.match(/^\/\//)) return window.location.protocol + e;
371
+ if (e.match(/^[a-z]+:/i) || !h) return e;
372
+ let n = H().implementation.createHTMLDocument(), r = n.createElement("base"), i = n.createElement("a");
373
+ return n.head.appendChild(r), n.body.appendChild(i), t && (r.href = t), i.href = e, i.href;
374
+ }
375
+ function H(e) {
376
+ return (e && w(e) ? e?.ownerDocument : e) ?? window.document;
377
+ }
378
+ var U = "http://www.w3.org/2000/svg";
379
+ function W(e, t, n) {
380
+ let r = H(n).createElementNS(U, "svg");
381
+ return r.setAttributeNS(null, "width", e.toString()), r.setAttributeNS(null, "height", t.toString()), r.setAttributeNS(null, "viewBox", `0 0 ${e} ${t}`), r;
382
+ }
383
+ function G(e, t) {
384
+ let n = new XMLSerializer().serializeToString(e);
385
+ return t && (n = n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu, "")), `data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`;
386
+ }
387
+ function ie(e, t) {
388
+ return new Promise((n, r) => {
389
+ let i = new FileReader();
390
+ i.onload = () => n(i.result), i.onerror = () => r(i.error), i.onabort = () => r(/* @__PURE__ */ Error(`Failed read blob to ${t}`)), t === "dataUrl" ? i.readAsDataURL(e) : t === "arrayBuffer" && i.readAsArrayBuffer(e);
391
+ });
392
+ }
393
+ var ae = (e) => ie(e, "dataUrl");
394
+ function K(e, t) {
395
+ let n = H(t).createElement("img");
396
+ return n.decoding = "sync", n.loading = "eager", n.src = e, n;
397
+ }
398
+ function q(e, t) {
399
+ return new Promise((n) => {
400
+ let { timeout: r, ownerDocument: i, onError: a, onWarn: o } = t ?? {}, s = typeof e == "string" ? K(e, H(i)) : e, c = null, l = null;
401
+ function u() {
402
+ n(s), c && clearTimeout(c), l?.();
403
+ }
404
+ if (r && (c = setTimeout(u, r)), M(s)) {
405
+ let e = s.currentSrc || s.src;
406
+ if (!e) return s.poster ? q(s.poster, t).then(n) : u();
407
+ if (s.readyState >= 2) return u();
408
+ let r = u, i = (t) => {
409
+ o?.("Failed video load", e, t), a?.(t), u();
410
+ };
411
+ l = () => {
412
+ s.removeEventListener("loadeddata", r), s.removeEventListener("error", i);
413
+ }, s.addEventListener("loadeddata", r, { once: !0 }), s.addEventListener("error", i, { once: !0 });
414
+ } else {
415
+ let e = E(s) ? s.href.baseVal : s.currentSrc || s.src;
416
+ if (!e) return u();
417
+ let t = async () => {
418
+ if (j(s) && "decode" in s) try {
419
+ await s.decode();
420
+ } catch (t) {
421
+ o?.("Failed to decode image, trying to render anyway", s.dataset.originalSrc || e, t);
422
+ }
423
+ u();
424
+ }, n = (t) => {
425
+ o?.("Failed image load", s.dataset.originalSrc || e, t), u();
426
+ };
427
+ if (j(s) && s.complete) return t();
428
+ l = () => {
429
+ s.removeEventListener("load", t), s.removeEventListener("error", n);
430
+ }, s.addEventListener("load", t, { once: !0 }), s.addEventListener("error", n, { once: !0 });
431
+ }
432
+ });
433
+ }
434
+ async function J(e, t) {
435
+ O(e) && (j(e) || M(e) ? await q(e, t) : await Promise.all(["img", "video"].flatMap((n) => Array.from(e.querySelectorAll(n)).map((e) => q(e, t)))));
436
+ }
437
+ var Y = /* @__PURE__ */ function() {
438
+ let e = 0, t = () => `0000${(Math.random() * 36 ** 4 | 0).toString(36)}`.slice(-4);
439
+ return () => (e += 1, `u${t()}${e}`);
440
+ }();
441
+ function X(e) {
442
+ return e?.split(",").map((e) => e.trim().replace(/"|'/g, "").toLowerCase()).filter(Boolean);
443
+ }
444
+ var oe = 0;
445
+ function se(e) {
446
+ let t = `${m}[#${oe}]`;
447
+ return oe++, {
448
+ time: (n) => e && console.time(`${t} ${n}`),
449
+ timeEnd: (n) => e && console.timeEnd(`${t} ${n}`),
450
+ warn: (...t) => e && R(...t)
451
+ };
452
+ }
453
+ function ce(e) {
454
+ return { cache: e ? "no-cache" : "force-cache" };
455
+ }
456
+ async function le(e, t) {
457
+ return x(e) ? e : ue(e, {
458
+ ...t,
459
+ autoDestruct: !0
460
+ });
461
+ }
462
+ async function ue(e, t) {
463
+ let { scale: n = 1, workerUrl: r, workerNumber: i = 1 } = t || {}, a = !!t?.debug, o = t?.features ?? !0, s = e.ownerDocument ?? (h ? window.document : void 0), c = e.ownerDocument?.defaultView ?? (h ? window : void 0), l = /* @__PURE__ */ new Map(), u = {
464
+ width: 0,
465
+ height: 0,
466
+ quality: 1,
467
+ type: "image/png",
468
+ scale: n,
469
+ backgroundColor: null,
470
+ style: null,
471
+ filter: null,
472
+ maximumCanvasSize: 0,
473
+ timeout: 3e4,
474
+ progress: null,
475
+ debug: a,
476
+ fetch: {
477
+ requestInit: ce(t?.fetch?.bypassingCache),
478
+ placeholderImage: "data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
479
+ bypassingCache: !1,
480
+ ...t?.fetch
481
+ },
482
+ fetchFn: null,
483
+ font: {},
484
+ drawImageInterval: 100,
485
+ workerUrl: null,
486
+ workerNumber: i,
487
+ onCloneEachNode: null,
488
+ onCloneNode: null,
489
+ onEmbedNode: null,
490
+ onCreateForeignObjectSvg: null,
491
+ includeStyleProperties: null,
492
+ autoDestruct: !1,
493
+ ...t,
494
+ __CONTEXT__: !0,
495
+ log: se(a),
496
+ node: e,
497
+ ownerDocument: s,
498
+ ownerWindow: c,
499
+ dpi: n === 1 ? null : 96 * n,
500
+ svgStyleElement: de(s),
501
+ svgDefsElement: s?.createElementNS(U, "defs"),
502
+ svgStyles: /* @__PURE__ */ new Map(),
503
+ defaultComputedStyles: /* @__PURE__ */ new Map(),
504
+ workers: [...Array.from({ length: g && r && i ? i : 0 })].map(() => {
505
+ try {
506
+ let e = new Worker(r);
507
+ return e.onmessage = async (e) => {
508
+ let { url: t, result: n } = e.data;
509
+ n ? l.get(t)?.resolve?.(n) : l.get(t)?.reject?.(/* @__PURE__ */ Error(`Error receiving message from worker: ${t}`));
510
+ }, e.onmessageerror = (e) => {
511
+ let { url: t } = e.data;
512
+ l.get(t)?.reject?.(/* @__PURE__ */ Error(`Error receiving message from worker: ${t}`));
513
+ }, e;
514
+ } catch (e) {
515
+ return u.log.warn("Failed to new Worker", e), null;
516
+ }
517
+ }).filter(Boolean),
518
+ fontFamilies: /* @__PURE__ */ new Map(),
519
+ fontCssTexts: /* @__PURE__ */ new Map(),
520
+ acceptOfImage: `${[
521
+ z(s) && "image/webp",
522
+ "image/svg+xml",
523
+ "image/*",
524
+ "*/*"
525
+ ].filter(Boolean).join(",")};q=0.8`,
526
+ requests: l,
527
+ drawImageCount: 0,
528
+ tasks: [],
529
+ features: o,
530
+ isEnable: (e) => e === "restoreScrollPosition" ? typeof o == "boolean" ? !1 : o[e] ?? !1 : typeof o == "boolean" ? o : o[e] ?? !0,
531
+ shadowRoots: []
532
+ };
533
+ u.log.time("wait until load"), await J(e, {
534
+ timeout: u.timeout,
535
+ onWarn: u.log.warn
536
+ }), u.log.timeEnd("wait until load");
537
+ let { width: d, height: f } = fe(e, u);
538
+ return u.width = d, u.height = f, u;
539
+ }
540
+ function de(e) {
541
+ if (!e) return;
542
+ let t = e.createElement("style"), n = t.ownerDocument.createTextNode("\n.______background-clip--text {\n background-clip: text;\n -webkit-background-clip: text;\n}\n");
543
+ return t.appendChild(n), t;
544
+ }
545
+ function fe(e, t) {
546
+ let { width: n, height: r } = t;
547
+ if (w(e) && (!n || !r)) {
548
+ let t = e.getBoundingClientRect();
549
+ n = n || t.width || Number(e.getAttribute("width")) || 0, r = r || t.height || Number(e.getAttribute("height")) || 0;
550
+ }
551
+ return {
552
+ width: n,
553
+ height: r
554
+ };
555
+ }
556
+ async function pe(e, t) {
557
+ let { log: n, timeout: r, drawImageCount: i, drawImageInterval: a } = t;
558
+ n.time("image to canvas");
559
+ let o = await q(e, {
560
+ timeout: r,
561
+ onWarn: t.log.warn
562
+ }), { canvas: s, context2d: c } = me(e.ownerDocument, t), l = () => {
563
+ try {
564
+ c?.drawImage(o, 0, 0, s.width, s.height);
565
+ } catch (e) {
566
+ t.log.warn("Failed to drawImage", e);
567
+ }
568
+ };
569
+ if (l(), t.isEnable("fixSvgXmlDecode")) for (let e = 0; e < i; e++) await new Promise((t) => {
570
+ setTimeout(() => {
571
+ c?.clearRect(0, 0, s.width, s.height), l(), t();
572
+ }, e + a);
573
+ });
574
+ return t.drawImageCount = 0, n.timeEnd("image to canvas"), s;
575
+ }
576
+ function me(e, t) {
577
+ let { width: n, height: r, scale: i, backgroundColor: a, maximumCanvasSize: o } = t, s = e.createElement("canvas");
578
+ s.width = Math.floor(n * i), s.height = Math.floor(r * i), s.style.width = `${n}px`, s.style.height = `${r}px`, o && (s.width > o || s.height > o) && (s.width > o && s.height > o ? s.width > s.height ? (s.height *= o / s.width, s.width = o) : (s.width *= o / s.height, s.height = o) : s.width > o ? (s.height *= o / s.width, s.width = o) : (s.width *= o / s.height, s.height = o));
579
+ let c = s.getContext("2d");
580
+ return c && a && (c.fillStyle = a, c.fillRect(0, 0, s.width, s.height)), {
581
+ canvas: s,
582
+ context2d: c
583
+ };
584
+ }
585
+ function he(e, t) {
586
+ if (e.ownerDocument) try {
587
+ let t = e.toDataURL();
588
+ if (t !== "data:,") return K(t, e.ownerDocument);
589
+ } catch (e) {
590
+ t.log.warn("Failed to clone canvas", e);
591
+ }
592
+ let n = e.cloneNode(!1), r = e.getContext("2d"), i = n.getContext("2d");
593
+ try {
594
+ return r && i && i.putImageData(r.getImageData(0, 0, e.width, e.height), 0, 0), n;
595
+ } catch (e) {
596
+ t.log.warn("Failed to clone canvas", e);
597
+ }
598
+ return n;
599
+ }
600
+ function ge(e, t) {
601
+ try {
602
+ if (e?.contentDocument?.documentElement) return Ie(e.contentDocument.documentElement, t);
603
+ } catch (e) {
604
+ t.log.warn("Failed to clone iframe", e);
605
+ }
606
+ return e.cloneNode(!1);
607
+ }
608
+ function _e(e) {
609
+ let t = e.cloneNode(!1);
610
+ return e.currentSrc && e.currentSrc !== e.src && (t.src = e.currentSrc, t.srcset = ""), t.loading === "lazy" && (t.loading = "eager"), t;
611
+ }
612
+ async function ve(e, t) {
613
+ if (e.ownerDocument && !e.currentSrc && e.poster) return K(e.poster, e.ownerDocument);
614
+ let n = e.cloneNode(!1);
615
+ n.crossOrigin = "anonymous", e.currentSrc && e.currentSrc !== e.src && (n.src = e.currentSrc);
616
+ let r = n.ownerDocument;
617
+ if (r) {
618
+ let i = !0;
619
+ if (await q(n, {
620
+ onError: () => i = !1,
621
+ onWarn: t.log.warn
622
+ }), !i) return e.poster ? K(e.poster, e.ownerDocument) : n;
623
+ n.currentTime = e.currentTime, await new Promise((e) => {
624
+ n.addEventListener("seeked", e, { once: !0 });
625
+ });
626
+ let a = r.createElement("canvas");
627
+ a.width = e.offsetWidth, a.height = e.offsetHeight;
628
+ try {
629
+ let e = a.getContext("2d");
630
+ e && e.drawImage(n, 0, 0, a.width, a.height);
631
+ } catch (r) {
632
+ return t.log.warn("Failed to clone video", r), e.poster ? K(e.poster, e.ownerDocument) : n;
633
+ }
634
+ return he(a, t);
635
+ }
636
+ return n;
637
+ }
638
+ function ye(e, t) {
639
+ return N(e) ? he(e, t) : re(e) ? ge(e, t) : j(e) ? _e(e) : M(e) ? ve(e, t) : e.cloneNode(!1);
640
+ }
641
+ function be(e) {
642
+ let t = e.sandbox;
643
+ if (!t) {
644
+ let { ownerDocument: n } = e;
645
+ try {
646
+ n && (t = n.createElement("iframe"), t.id = `__SANDBOX__${Y()}`, t.width = "0", t.height = "0", t.style.visibility = "hidden", t.style.position = "fixed", n.body.appendChild(t), t.srcdoc = "<!DOCTYPE html><meta charset=\"UTF-8\"><title></title><body>", e.sandbox = t);
647
+ } catch (t) {
648
+ e.log.warn("Failed to getSandBox", t);
649
+ }
650
+ }
651
+ return t;
652
+ }
653
+ var xe = [
654
+ "width",
655
+ "height",
656
+ "-webkit-text-fill-color"
657
+ ], Se = ["stroke", "fill"];
658
+ function Ce(e, t, n) {
659
+ let { defaultComputedStyles: r } = n, i = e.nodeName.toLowerCase(), a = T(e) && i !== "svg", o = a ? Se.map((t) => [t, e.getAttribute(t)]).filter(([, e]) => e !== null) : [], s = [
660
+ a && "svg",
661
+ i,
662
+ o.map((e, t) => `${e}=${t}`).join(","),
663
+ t
664
+ ].filter(Boolean).join(":");
665
+ if (r.has(s)) return r.get(s);
666
+ let c = be(n)?.contentWindow;
667
+ if (!c) return /* @__PURE__ */ new Map();
668
+ let l = c?.document, u, d;
669
+ a ? (u = l.createElementNS(U, "svg"), d = u.ownerDocument.createElementNS(u.namespaceURI, i), o.forEach(([e, t]) => {
670
+ d.setAttributeNS(null, e, t);
671
+ }), u.appendChild(d)) : u = d = l.createElement(i), d.textContent = " ", l.body.appendChild(u);
672
+ let f = c.getComputedStyle(d, t), p = /* @__PURE__ */ new Map();
673
+ for (let e = f.length, t = 0; t < e; t++) {
674
+ let e = f.item(t);
675
+ xe.includes(e) || p.set(e, f.getPropertyValue(e));
676
+ }
677
+ return l.body.removeChild(u), r.set(s, p), p;
678
+ }
679
+ function we(e, t, n) {
680
+ let r = /* @__PURE__ */ new Map(), i = [], a = /* @__PURE__ */ new Map();
681
+ if (n) for (let e of n) o(e);
682
+ else for (let t = e.length, n = 0; n < t; n++) o(e.item(n));
683
+ for (let e = i.length, t = 0; t < e; t++) a.get(i[t])?.forEach((e, t) => r.set(t, e));
684
+ function o(n) {
685
+ let o = e.getPropertyValue(n), s = e.getPropertyPriority(n), c = n.lastIndexOf("-"), l = c > -1 ? n.substring(0, c) : void 0;
686
+ if (l) {
687
+ let e = a.get(l);
688
+ e || (e = /* @__PURE__ */ new Map(), a.set(l, e)), e.set(n, [o, s]);
689
+ }
690
+ (t.get(n) !== o || s) && (l ? i.push(l) : r.set(n, [o, s]));
691
+ }
692
+ return r;
693
+ }
694
+ function Te(e, t, n, r) {
695
+ let { ownerWindow: i, includeStyleProperties: a, currentParentNodeStyle: o } = r, s = t.style, c = i.getComputedStyle(e), l = Ce(e, null, r);
696
+ o?.forEach((e, t) => {
697
+ l.delete(t);
698
+ });
699
+ let u = we(c, l, a);
700
+ u.delete("transition-property"), u.delete("all"), u.delete("d"), u.delete("content"), n && (u.delete("position"), u.delete("margin-top"), u.delete("margin-right"), u.delete("margin-bottom"), u.delete("margin-left"), u.delete("margin-block-start"), u.delete("margin-block-end"), u.delete("margin-inline-start"), u.delete("margin-inline-end"), u.set("box-sizing", ["border-box", ""])), u.get("background-clip")?.[0] === "text" && t.classList.add("______background-clip--text"), v && (u.has("font-kerning") || u.set("font-kerning", ["normal", ""]), (u.get("overflow-x")?.[0] === "hidden" || u.get("overflow-y")?.[0] === "hidden") && u.get("text-overflow")?.[0] === "ellipsis" && e.scrollWidth === e.clientWidth && u.set("text-overflow", ["clip", ""]));
701
+ for (let e = s.length, t = 0; t < e; t++) s.removeProperty(s.item(t));
702
+ return u.forEach(([e, t], n) => {
703
+ s.setProperty(n, e, t);
704
+ }), u;
705
+ }
706
+ function Ee(e, t) {
707
+ (P(e) || F(e) || ne(e)) && t.setAttribute("value", e.value);
708
+ }
709
+ var De = ["::before", "::after"], Oe = [
710
+ "::-webkit-scrollbar",
711
+ "::-webkit-scrollbar-button",
712
+ "::-webkit-scrollbar-thumb",
713
+ "::-webkit-scrollbar-track",
714
+ "::-webkit-scrollbar-track-piece",
715
+ "::-webkit-scrollbar-corner",
716
+ "::-webkit-resizer"
717
+ ];
718
+ function ke(e, t, n, r, i) {
719
+ let { ownerWindow: a, svgStyleElement: o, svgStyles: s, currentNodeStyle: c } = r;
720
+ if (!o || !a) return;
721
+ function l(n) {
722
+ let o = a.getComputedStyle(e, n), l = o.getPropertyValue("content");
723
+ if (!l || l === "none") return;
724
+ i?.(l), l = l.replace(/(')|(")|(counter\(.+\))/g, "");
725
+ let u = [Y()], d = Ce(e, n, r);
726
+ c?.forEach((e, t) => {
727
+ d.delete(t);
728
+ });
729
+ let f = we(o, d, r.includeStyleProperties);
730
+ f.delete("content"), f.delete("-webkit-locale"), f.get("background-clip")?.[0] === "text" && t.classList.add("______background-clip--text");
731
+ let p = [`content: '${l}';`];
732
+ if (f.forEach(([e, t], n) => {
733
+ p.push(`${n}: ${e}${t ? " !important" : ""};`);
734
+ }), p.length === 1) return;
735
+ try {
736
+ t.className = [t.className, ...u].join(" ");
737
+ } catch (e) {
738
+ r.log.warn("Failed to copyPseudoClass", e);
739
+ return;
740
+ }
741
+ let m = p.join("\n "), h = s.get(m);
742
+ h || (h = [], s.set(m, h)), h.push(`.${u[0]}${n}`);
743
+ }
744
+ De.forEach(l), n && Oe.forEach(l);
745
+ }
746
+ var Ae = /* @__PURE__ */ new Set(["symbol"]);
747
+ async function je(e, t, n, r, i) {
748
+ if (w(n) && (I(n) || te(n)) || r.filter && !r.filter(n)) return;
749
+ r.currentParentNodeStyle = Ae.has(t.nodeName) || Ae.has(n.nodeName) ? void 0 : r.currentNodeStyle;
750
+ let a = await Ie(n, r, !1, i);
751
+ r.isEnable("restoreScrollPosition") && Ne(e, a), t.appendChild(a);
752
+ }
753
+ async function Me(e, t, n, r) {
754
+ let i = e.firstChild;
755
+ w(e) && e.shadowRoot && (i = e.shadowRoot?.firstChild, n.shadowRoots.push(e.shadowRoot));
756
+ for (let a = i; a; a = a.nextSibling) if (!k(a)) {
757
+ if (w(a) && L(a) && typeof a.assignedNodes == "function") {
758
+ let i = a.assignedNodes();
759
+ for (let a = 0; a < i.length; a++) await je(e, t, i[a], n, r);
760
+ } else await je(e, t, a, n, r);
761
+ }
762
+ }
763
+ function Ne(e, t) {
764
+ if (!O(e) || !O(t)) return;
765
+ let { scrollTop: n, scrollLeft: r } = e;
766
+ if (!n && !r) return;
767
+ let { transform: i } = t.style, a = new DOMMatrix(i), { a: o, b: s, c, d: l } = a;
768
+ a.a = 1, a.b = 0, a.c = 0, a.d = 1, a.translateSelf(-r, -n), a.a = o, a.b = s, a.c = c, a.d = l, t.style.transform = a.toString();
769
+ }
770
+ function Pe(e, t) {
771
+ let { backgroundColor: n, width: r, height: i, style: a } = t, o = e.style;
772
+ if (n && o.setProperty("background-color", n, "important"), r && o.setProperty("width", `${r}px`, "important"), i && o.setProperty("height", `${i}px`, "important"), a) for (let e in a) o[e] = a[e];
773
+ }
774
+ var Fe = /^[\w-:]+$/;
775
+ async function Ie(e, t, n = !1, r) {
776
+ let { ownerDocument: i, ownerWindow: a, fontFamilies: o, onCloneEachNode: s } = t;
777
+ if (i && A(e)) return r && /\S/.test(e.data) && r(e.data), i.createTextNode(e.data);
778
+ if (i && a && w(e) && (O(e) || T(e))) {
779
+ let r = await ye(e, t);
780
+ if (t.isEnable("removeAbnormalAttributes")) {
781
+ let e = r.getAttributeNames();
782
+ for (let t = e.length, n = 0; n < t; n++) {
783
+ let t = e[n];
784
+ Fe.test(t) || r.removeAttribute(t);
785
+ }
786
+ }
787
+ let i = t.currentNodeStyle = Te(e, r, n, t);
788
+ n && Pe(r, t);
789
+ let a = !1;
790
+ if (t.isEnable("copyScrollbar")) {
791
+ let t = [i.get("overflow-x")?.[0], i.get("overflow-y")?.[0]];
792
+ a = t.includes("scroll") || (t.includes("auto") || t.includes("overlay")) && (e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth);
793
+ }
794
+ let c = i.get("text-transform")?.[0], l = X(i.get("font-family")?.[0]), u = l ? (e) => {
795
+ c === "uppercase" ? e = e.toUpperCase() : c === "lowercase" ? e = e.toLowerCase() : c === "capitalize" && (e = e[0].toUpperCase() + e.substring(1)), l.forEach((t) => {
796
+ let n = o.get(t);
797
+ n || o.set(t, n = /* @__PURE__ */ new Set()), e.split("").forEach((e) => n.add(e));
798
+ });
799
+ } : void 0;
800
+ return ke(e, r, a, t, u), Ee(e, r), M(e) || await Me(e, r, t, u), await s?.(r), r;
801
+ }
802
+ let c = e.cloneNode(!1);
803
+ return await Me(e, c, t), await s?.(c), c;
804
+ }
805
+ function Le(e) {
806
+ if (e.ownerDocument = void 0, e.ownerWindow = void 0, e.svgStyleElement = void 0, e.svgDefsElement = void 0, e.svgStyles.clear(), e.defaultComputedStyles.clear(), e.sandbox) {
807
+ try {
808
+ e.sandbox.remove();
809
+ } catch (t) {
810
+ e.log.warn("Failed to destroyContext", t);
811
+ }
812
+ e.sandbox = void 0;
813
+ }
814
+ e.workers = [], e.fontFamilies.clear(), e.fontCssTexts.clear(), e.requests.clear(), e.tasks = [], e.shadowRoots = [];
815
+ }
816
+ function Re(e) {
817
+ let { url: t, timeout: n, responseType: r, ...i } = e, a = new AbortController(), o = n ? setTimeout(() => a.abort(), n) : void 0;
818
+ return fetch(t, {
819
+ signal: a.signal,
820
+ ...i
821
+ }).then((e) => {
822
+ if (!e.ok) throw Error("Failed fetch, not 2xx response", { cause: e });
823
+ switch (r) {
824
+ case "arrayBuffer": return e.arrayBuffer();
825
+ case "dataUrl": return e.blob().then(ae);
826
+ default: return e.text();
827
+ }
828
+ }).finally(() => clearTimeout(o));
829
+ }
830
+ function Z(e, t) {
831
+ let { url: n, requestType: r = "text", responseType: i = "text", imageDom: a } = t, o = n, { timeout: s, acceptOfImage: c, requests: l, fetchFn: u, fetch: { requestInit: d, bypassingCache: f, placeholderImage: p }, font: m, workers: h, fontFamilies: g } = e;
832
+ r === "image" && (y || b) && e.drawImageCount++;
833
+ let _ = l.get(n);
834
+ if (!_) {
835
+ f && f instanceof RegExp && f.test(o) && (o += (/\?/.test(o) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
836
+ let t = r.startsWith("font") && m && m.minify, v = /* @__PURE__ */ new Set();
837
+ t && r.split(";")[1].split(",").forEach((e) => {
838
+ g.has(e) && g.get(e).forEach((e) => v.add(e));
839
+ });
840
+ let b = t && v.size, x = {
841
+ url: o,
842
+ timeout: s,
843
+ responseType: b ? "arrayBuffer" : i,
844
+ headers: r === "image" ? { accept: c } : void 0,
845
+ ...d
846
+ };
847
+ _ = {
848
+ type: r,
849
+ resolve: void 0,
850
+ reject: void 0,
851
+ response: null
852
+ }, _.response = (async () => {
853
+ if (u && r === "image") {
854
+ let e = await u(n);
855
+ if (e) return e;
856
+ }
857
+ return !y && n.startsWith("http") && h.length ? new Promise((e, t) => {
858
+ h[l.size & h.length - 1].postMessage({
859
+ rawUrl: n,
860
+ ...x
861
+ }), _.resolve = e, _.reject = t;
862
+ }) : Re(x);
863
+ })().catch((t) => {
864
+ if (l.delete(n), r === "image" && p) return e.log.warn("Failed to fetch image base64, trying to use placeholder image", o), typeof p == "string" ? p : p(a);
865
+ throw t;
866
+ }), l.set(n, _);
867
+ }
868
+ return _.response;
869
+ }
870
+ async function ze(e, t, n, r) {
871
+ if (!Be(e)) return e;
872
+ for (let [i, a] of He(e, t)) try {
873
+ let t = await Z(n, {
874
+ url: a,
875
+ requestType: r ? "image" : "text",
876
+ responseType: "dataUrl"
877
+ });
878
+ e = e.replace(Ue(i), `$1${t}$3`);
879
+ } catch (e) {
880
+ n.log.warn("Failed to fetch css data url", i, e);
881
+ }
882
+ return e;
883
+ }
884
+ function Be(e) {
885
+ return /url\((['"]?)([^'"]+?)\1\)/.test(e);
886
+ }
887
+ var Ve = /url\((['"]?)([^'"]+?)\1\)/g;
888
+ function He(e, t) {
889
+ let n = [];
890
+ return e.replace(Ve, (e, r, i) => (n.push([i, V(i, t)]), e)), n.filter(([e]) => !B(e));
891
+ }
892
+ function Ue(e) {
893
+ let t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
894
+ return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
895
+ }
896
+ var We = [
897
+ "background-image",
898
+ "border-image-source",
899
+ "-webkit-border-image",
900
+ "-webkit-mask-image",
901
+ "list-style-image"
902
+ ];
903
+ function Ge(e, t) {
904
+ return We.map((n) => {
905
+ let r = e.getPropertyValue(n);
906
+ return !r || r === "none" ? null : ((y || b) && t.drawImageCount++, ze(r, null, t, !0).then((t) => {
907
+ t && r !== t && e.setProperty(n, t, e.getPropertyPriority(n));
908
+ }));
909
+ }).filter(Boolean);
910
+ }
911
+ function Ke(e, t) {
912
+ if (j(e)) {
913
+ let n = e.currentSrc || e.src;
914
+ if (!B(n)) return [Z(t, {
915
+ url: n,
916
+ imageDom: e,
917
+ requestType: "image",
918
+ responseType: "dataUrl"
919
+ }).then((t) => {
920
+ t && (e.srcset = "", e.dataset.originalSrc = n, e.src = t || "");
921
+ })];
922
+ (y || b) && t.drawImageCount++;
923
+ } else if (T(e) && !B(e.href.baseVal)) {
924
+ let n = e.href.baseVal;
925
+ return [Z(t, {
926
+ url: n,
927
+ imageDom: e,
928
+ requestType: "image",
929
+ responseType: "dataUrl"
930
+ }).then((t) => {
931
+ t && (e.dataset.originalSrc = n, e.href.baseVal = t || "");
932
+ })];
933
+ }
934
+ return [];
935
+ }
936
+ function qe(e, t) {
937
+ let { ownerDocument: n, svgDefsElement: r } = t, i = e.getAttribute("href") ?? e.getAttribute("xlink:href");
938
+ if (!i) return [];
939
+ let [a, o] = i.split("#");
940
+ if (o) {
941
+ let i = `#${o}`, s = t.shadowRoots.reduce((e, t) => e ?? t.querySelector(`svg ${i}`), n?.querySelector(`svg ${i}`));
942
+ if (a && e.setAttribute("href", i), r?.querySelector(i)) return [];
943
+ if (s) return r?.appendChild(s.cloneNode(!0)), [];
944
+ if (a) return [Z(t, {
945
+ url: a,
946
+ responseType: "text"
947
+ }).then((e) => {
948
+ r?.insertAdjacentHTML("beforeend", e);
949
+ })];
950
+ }
951
+ return [];
952
+ }
953
+ function Je(e, t) {
954
+ let { tasks: n } = t;
955
+ w(e) && ((j(e) || E(e)) && n.push(...Ke(e, t)), D(e) && n.push(...qe(e, t))), O(e) && n.push(...Ge(e.style, t)), e.childNodes.forEach((e) => {
956
+ Je(e, t);
957
+ });
958
+ }
959
+ async function Ye(e, t) {
960
+ let { ownerDocument: n, svgStyleElement: r, fontFamilies: i, fontCssTexts: a, tasks: o, font: s } = t;
961
+ if (n && r && i.size) {
962
+ if (s && s.cssText) {
963
+ let e = tt(s.cssText, t);
964
+ r.appendChild(n.createTextNode(`${e}
965
+ `));
966
+ } else {
967
+ let e = Array.from(n.styleSheets).filter((e) => {
968
+ try {
969
+ return "cssRules" in e && !!e.cssRules.length;
970
+ } catch (n) {
971
+ return t.log.warn(`Error while reading CSS rules from ${e.href}`, n), !1;
972
+ }
973
+ }), s = n.implementation.createHTMLDocument(""), c = s.createElement("style");
974
+ s.head.appendChild(c);
975
+ let l = c.sheet;
976
+ await Promise.all(e.flatMap((e) => Array.from(e.cssRules).map(async (e) => {
977
+ if (C(e)) {
978
+ let n = e.href, r = "";
979
+ try {
980
+ r = await Z(t, {
981
+ url: n,
982
+ requestType: "text",
983
+ responseType: "text"
984
+ });
985
+ } catch (e) {
986
+ t.log.warn(`Error fetch remote css import from ${n}`, e);
987
+ }
988
+ let i = r.replace(Ve, (e, t, r) => e.replace(r, V(r, n)));
989
+ for (let e of Qe(i)) try {
990
+ l.insertRule(e, l.cssRules.length);
991
+ } catch (n) {
992
+ t.log.warn("Error inserting rule from remote css import", {
993
+ rule: e,
994
+ error: n
995
+ });
996
+ }
997
+ }
998
+ }))), l.cssRules.length && e.push(l);
999
+ let u = [];
1000
+ e.forEach((e) => {
1001
+ nt(e.cssRules, u);
1002
+ }), u.filter((e) => S(e) && Be(e.style.getPropertyValue("src")) && X(e.style.getPropertyValue("font-family"))?.some((e) => i.has(e))).forEach((e) => {
1003
+ let i = e, s = a.get(i.cssText);
1004
+ s ? r.appendChild(n.createTextNode(`${s}
1005
+ `)) : o.push(ze(i.cssText, i.parentStyleSheet ? i.parentStyleSheet.href : null, t).then((e) => {
1006
+ e = tt(e, t), a.set(i.cssText, e), r.appendChild(n.createTextNode(`${e}
1007
+ `));
1008
+ }));
1009
+ });
1010
+ }
1011
+ }
1012
+ }
1013
+ var Xe = /(\/\*[\s\S]*?\*\/)/g, Ze = /((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;
1014
+ function Qe(e) {
1015
+ if (e == null) return [];
1016
+ let t = [], n = e.replace(Xe, "");
1017
+ for (;;) {
1018
+ let e = Ze.exec(n);
1019
+ if (!e) break;
1020
+ t.push(e[0]);
1021
+ }
1022
+ n = n.replace(Ze, "");
1023
+ let r = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, i = /* @__PURE__ */ RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
1024
+ for (;;) {
1025
+ let e = r.exec(n);
1026
+ if (e) i.lastIndex = r.lastIndex;
1027
+ else if (e = i.exec(n), e) r.lastIndex = i.lastIndex;
1028
+ else break;
1029
+ t.push(e[0]);
1030
+ }
1031
+ return t;
1032
+ }
1033
+ var $e = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, et = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
1034
+ function tt(e, t) {
1035
+ let { font: n } = t, r = n ? n?.preferredFormat : void 0;
1036
+ return r ? e.replace(et, (e) => {
1037
+ for (;;) {
1038
+ let [t, , n] = $e.exec(e) || [];
1039
+ if (!n) return "";
1040
+ if (n === r) return `src: ${t};`;
1041
+ }
1042
+ }) : e;
1043
+ }
1044
+ function nt(e, t = []) {
1045
+ for (let n of Array.from(e)) ee(n) ? t.push(...nt(n.cssRules)) : "cssRules" in n ? nt(n.cssRules, t) : t.push(n);
1046
+ return t;
1047
+ }
1048
+ var rt = /\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;
1049
+ function it(e) {
1050
+ return rt.test(e.innerHTML);
1051
+ }
1052
+ async function at(e, t) {
1053
+ let n = await le(e, t);
1054
+ if (w(n.node) && T(n.node) && !it(n.node)) return n.node;
1055
+ let { ownerDocument: r, log: i, tasks: a, svgStyleElement: o, svgDefsElement: s, svgStyles: c, font: l, progress: u, autoDestruct: d, onCloneNode: f, onEmbedNode: p, onCreateForeignObjectSvg: m } = n;
1056
+ i.time("clone node");
1057
+ let h = await Ie(n.node, n, !0);
1058
+ if (o && r) {
1059
+ let e = "";
1060
+ c.forEach((t, n) => {
1061
+ e += `${t.join(",\n")} {
1062
+ ${n}
1063
+ }
1064
+ `;
1065
+ }), o.appendChild(r.createTextNode(e));
1066
+ }
1067
+ i.timeEnd("clone node"), await f?.(h), l !== !1 && w(h) && (i.time("embed web font"), await Ye(h, n), i.timeEnd("embed web font")), i.time("embed node"), Je(h, n);
1068
+ let g = a.length, _ = 0, v = async () => {
1069
+ for (;;) {
1070
+ let e = a.pop();
1071
+ if (!e) break;
1072
+ try {
1073
+ await e;
1074
+ } catch (e) {
1075
+ n.log.warn("Failed to run task", e);
1076
+ }
1077
+ u?.(++_, g);
1078
+ }
1079
+ };
1080
+ u?.(_, g), await Promise.all([...Array.from({ length: 4 })].map(v)), i.timeEnd("embed node"), await p?.(h);
1081
+ let y = ot(h, n);
1082
+ return s && y.insertBefore(s, y.children[0]), o && y.insertBefore(o, y.children[0]), d && Le(n), await m?.(y), y;
1083
+ }
1084
+ function ot(e, t) {
1085
+ let { width: n, height: r } = t, i = W(n, r, e.ownerDocument), a = i.ownerDocument.createElementNS(i.namespaceURI, "foreignObject");
1086
+ return a.setAttributeNS(null, "x", "0%"), a.setAttributeNS(null, "y", "0%"), a.setAttributeNS(null, "width", "100%"), a.setAttributeNS(null, "height", "100%"), a.append(e), i.appendChild(a), i;
1087
+ }
1088
+ async function st(e, t) {
1089
+ let n = await le(e, t), r = await at(n), i = G(r, n.isEnable("removeControlCharacter"));
1090
+ return n.autoDestruct || (n.svgStyleElement = de(n.ownerDocument), n.svgDefsElement = n.ownerDocument?.createElementNS(U, "defs"), n.svgStyles.clear()), await pe(K(i, r.ownerDocument), n);
1091
+ }
1092
+ // src/editor/mask.ts
1093
+ var ct = "input:not([type=hidden]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]),textarea,select,[contenteditable]:not([contenteditable=false]),[data-pinax-mask],.pinax-mask";
1094
+ function lt(e) {
1095
+ try {
1096
+ return e.matches(ct);
1097
+ } catch {
1098
+ return !1;
1099
+ }
1100
+ }
1101
+ function ut(e, t, n) {
1102
+ let r = [];
1103
+ for (let i of e.querySelectorAll(ct)) {
1104
+ if (n?.contains(i)) continue;
1105
+ let e = i.getBoundingClientRect();
1106
+ if (e.width <= 0 || e.height <= 0) continue;
1107
+ let a = Math.max(0, e.left), o = Math.max(0, e.top), s = Math.min(t.w, e.right), c = Math.min(t.h, e.bottom);
1108
+ s <= a || c <= o || r.push({
1109
+ x: a,
1110
+ y: o,
1111
+ w: s - a,
1112
+ h: c - o
1113
+ });
1114
+ }
1115
+ return r;
1116
+ }
1117
+ function dt(e) {
1118
+ if (e.nodeType !== 1) return;
1119
+ let t = e;
1120
+ if (!lt(t)) return;
1121
+ let n = t.tagName;
1122
+ if (n === "INPUT" || n === "TEXTAREA") {
1123
+ let e = t;
1124
+ try {
1125
+ e.value = "";
1126
+ } catch {}
1127
+ e.removeAttribute("value"), e.removeAttribute("placeholder"), n === "TEXTAREA" && (e.textContent = "");
1128
+ }
1129
+ t.style.setProperty("visibility", "hidden", "important");
1130
+ }
1131
+ function ft(e, t, n) {
1132
+ for (let r of t) {
1133
+ let t = r.x * n, i = r.y * n, a = r.w * n, o = r.h * n;
1134
+ e.save(), e.beginPath(), e.rect(t, i, a, o), e.clip(), e.fillStyle = "#D8DEE9", e.fillRect(t, i, a, o), e.fillStyle = "#C7CFDC";
1135
+ let s = 8 * n;
1136
+ for (let n = t; n < t + a; n += s * 2) e.fillRect(n, i, s, o);
1137
+ e.restore();
1138
+ }
1139
+ }
1140
+ // src/privacy.ts
1141
+ var pt = /[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g, mt = /(?<![\w+])(?:\+\d{1,3}|\(?0\d{1,4}\)?|\(?\d{3}\)?)(?:[ .-]?\(?\d{1,5}\)?){1,6}(?![\w])/g, ht = /^\(?\d{3}\)?[ .-]\d{3}[ .-]\d{4}$/;
1142
+ function gt(e) {
1143
+ let t = e.trim(), n = t.replace(/\D/g, "").length;
1144
+ return t.startsWith("+") ? n >= 8 && n <= 15 : /^\(?0/.test(t) ? n >= 10 && n <= 12 : n === 10 && ht.test(t);
1145
+ }
1146
+ function _t(e) {
1147
+ let t = [];
1148
+ if (e.length < 7) return t;
1149
+ if (e.includes("@")) for (let n of e.matchAll(pt)) t.push({
1150
+ start: n.index ?? 0,
1151
+ end: (n.index ?? 0) + n[0].length,
1152
+ kind: "email"
1153
+ });
1154
+ if (/\d{2}/.test(e)) for (let n of e.matchAll(mt)) {
1155
+ let e = n.index ?? 0, r = e + n[0].length;
1156
+ gt(n[0]) && (t.some((t) => e < t.end && r > t.start) || t.push({
1157
+ start: e,
1158
+ end: r,
1159
+ kind: "phone"
1160
+ }));
1161
+ }
1162
+ return t.sort((e, t) => e.start - t.start);
1163
+ }
1164
+ var vt = "(?:(?:full|your|first|last|guest|customer|client|contact|booking|patient|member|account|lead)\\s+name|name|customer|guest|client|booked by|card ?holder|account holder)", yt = RegExp(`^${vt}\\s*[::]?$`, "i"), bt = RegExp(`^${vt}\\s*[::]\\s*`, "i"), xt = /\b(?:signed in as|logged in as|welcome back,?)\s+/i;
1165
+ function St(e) {
1166
+ let t = e.trim();
1167
+ return t.length >= 2 && t.length <= 60 && /\p{L}/u.test(t) && t.split(/\s+/).length <= 5;
1168
+ }
1169
+ // src/editor/pii.ts
1170
+ var Ct = /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE|TEXTAREA|OPTION)$/, wt = "a[href],button,[role=button],[role=link],summary", Tt = "[autocomplete~=name],[autocomplete~=given-name],[autocomplete~=family-name],[autocomplete~=nickname],[autocomplete~=username],[itemtype*=\"schema.org/Person\"] [itemprop=name]", Et = 2e4;
1171
+ function Q(e, t) {
1172
+ if (!e || t?.contains(e) || Ct.test(e.tagName)) return !0;
1173
+ try {
1174
+ return !!e.closest(ct);
1175
+ } catch {
1176
+ return !1;
1177
+ }
1178
+ }
1179
+ function Dt(e) {
1180
+ let t = e.nodeValue ?? "", n = t.length - t.trimStart().length, r = t.trimEnd().length;
1181
+ return r > n ? {
1182
+ node: e,
1183
+ start: n,
1184
+ end: r,
1185
+ reason: "name"
1186
+ } : null;
1187
+ }
1188
+ function Ot(e, t) {
1189
+ let n = e.ownerDocument, r = e.parentElement?.parentElement ?? e.parentElement;
1190
+ if (!r) return null;
1191
+ let i = n.createTreeWalker(r, NodeFilter.SHOW_TEXT);
1192
+ i.currentNode = e;
1193
+ let a = i.nextNode();
1194
+ for (; a && e.contains(a);) a = i.nextNode();
1195
+ for (let e = 0; a && e < 4; e++, a = i.nextNode()) {
1196
+ let e = (a.nodeValue ?? "").trim();
1197
+ if (!e) continue;
1198
+ let n = a.parentElement;
1199
+ return Q(n, t) || n?.closest(wt) ? null : St(e) ? a : null;
1200
+ }
1201
+ return null;
1202
+ }
1203
+ function kt(e, t, n) {
1204
+ let r = e.parentElement;
1205
+ if (!r || r.closest(wt) || r.closest("label")) return;
1206
+ let i = r.closest("th");
1207
+ if (i) {
1208
+ let e = i.closest("table"), r = i.cellIndex;
1209
+ if (!e || r < 0) return;
1210
+ for (let a of e.tBodies) for (let e of a.rows) {
1211
+ let a = e.cells[r];
1212
+ a && a !== i && !Q(a, t) && n.push({
1213
+ element: a,
1214
+ reason: "name"
1215
+ });
1216
+ }
1217
+ return;
1218
+ }
1219
+ let a = r.closest("dt");
1220
+ if (a) {
1221
+ let e = a.nextElementSibling;
1222
+ for (; e && e.tagName === "DD";) Q(e, t) || n.push({
1223
+ element: e,
1224
+ reason: "name"
1225
+ }), e = e.nextElementSibling;
1226
+ return;
1227
+ }
1228
+ let o = Ot(r, t);
1229
+ if (o) {
1230
+ let e = Dt(o);
1231
+ e && n.push(e);
1232
+ }
1233
+ }
1234
+ function At(e, t = null) {
1235
+ let n = [], r = e.body;
1236
+ if (!r) return n;
1237
+ let i = e.createTreeWalker(r, NodeFilter.SHOW_TEXT), a = 0;
1238
+ for (let e = i.nextNode(); e && a < Et; e = i.nextNode(), a++) {
1239
+ let r = e.nodeValue ?? "";
1240
+ if (r.trim().length < 2 || Q(e.parentElement, t)) continue;
1241
+ for (let t of _t(r)) n.push({
1242
+ node: e,
1243
+ start: t.start,
1244
+ end: t.end,
1245
+ reason: t.kind
1246
+ });
1247
+ let i = r.trim(), a = r.length - r.trimStart().length, o = bt.exec(i);
1248
+ if (o && St(i.slice(o[0].length))) {
1249
+ n.push({
1250
+ node: e,
1251
+ start: a + o[0].length,
1252
+ end: a + i.length,
1253
+ reason: "name"
1254
+ });
1255
+ continue;
1256
+ }
1257
+ let s = xt.exec(r);
1258
+ if (s) {
1259
+ let t = s.index + s[0].length, i = r.slice(t), a = i.search(/[!?|•·\n]|\.(?=\s|$)/), o = (a < 0 ? i : i.slice(0, a)).trimEnd();
1260
+ St(o) && n.push({
1261
+ node: e,
1262
+ start: t,
1263
+ end: t + o.length,
1264
+ reason: "name"
1265
+ });
1266
+ } else yt.test(i) && kt(e, t, n);
1267
+ }
1268
+ for (let r of e.querySelectorAll(Tt)) lt(r) || Q(r, t) || n.push({
1269
+ element: r,
1270
+ reason: "name"
1271
+ });
1272
+ return n;
1273
+ }
1274
+ var $ = 2;
1275
+ function jt(e, t, n = null) {
1276
+ let r = [], i = (e) => {
1277
+ if (e.width <= 0 || e.height <= 0) return;
1278
+ let n = Math.max(0, e.left - $), i = Math.max(0, e.top - $), a = Math.min(t.w, e.right + $), o = Math.min(t.h, e.bottom + $);
1279
+ a <= n || o <= i || r.push({
1280
+ x: n,
1281
+ y: i,
1282
+ w: a - n,
1283
+ h: o - i
1284
+ });
1285
+ }, a = (t) => {
1286
+ if (!t) return !1;
1287
+ let n = t.checkVisibility;
1288
+ return typeof n == "function" ? n.call(t) : e.defaultView?.getComputedStyle(t)?.visibility !== "hidden";
1289
+ };
1290
+ for (let t of At(e, n)) try {
1291
+ if ("element" in t) {
1292
+ a(t.element) && i(t.element.getBoundingClientRect());
1293
+ continue;
1294
+ }
1295
+ if (!a(t.node.parentElement)) continue;
1296
+ let n = e.createRange();
1297
+ n.setStart(t.node, t.start), n.setEnd(t.node, t.end);
1298
+ for (let e of n.getClientRects()) i(e);
1299
+ } catch {}
1300
+ return Mt(r);
1301
+ }
1302
+ function Mt(e) {
1303
+ return e.filter((t, n) => !e.some((e, r) => r !== n && e.x <= t.x && e.y <= t.y && e.x + e.w >= t.x + t.w && e.y + e.h >= t.y + t.h && (e.w * e.h > t.w * t.h || r < n)));
1304
+ }
1305
+ // src/editor/capture.ts
1306
+ var Nt = 2560, Pt = 5e6;
1307
+ function Ft(e, t) {
1308
+ let n = Math.max(1, e.w), r = Math.max(1, e.h);
1309
+ return Math.min(t || 1, 2, Nt / Math.max(n, r), Math.sqrt(Pt / (n * r)));
1310
+ }
1311
+ var It = "data:image/gif;base64,R0lGODlhAQABAIAAAMfP3AAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==";
1312
+ async function Lt(e, t = window, n = {}) {
1313
+ let r = t.document, i = {
1314
+ w: t.innerWidth,
1315
+ h: t.innerHeight
1316
+ }, a = Ft(i, t.devicePixelRatio), o = ut(r, i, e), s = [];
1317
+ if (n.autoBlur) try {
1318
+ s = jt(r, i, e);
1319
+ } catch {
1320
+ s = [];
1321
+ }
1322
+ let c = r.documentElement, l = t.scrollX, u = t.scrollY, d = t.getComputedStyle(r.body).backgroundColor || t.getComputedStyle(c).backgroundColor, f = await st(c, {
1323
+ width: i.w,
1324
+ height: i.h,
1325
+ scale: a,
1326
+ backgroundColor: d && d !== "rgba(0, 0, 0, 0)" && d !== "transparent" ? d : "#FFFFFF",
1327
+ filter: (t) => t !== e,
1328
+ onCloneEachNode: (e) => dt(e),
1329
+ style: {
1330
+ transform: `translate(${-l}px, ${-u}px)`,
1331
+ transformOrigin: "0 0"
1332
+ },
1333
+ timeout: 15e3,
1334
+ maximumCanvasSize: Nt,
1335
+ fetch: { placeholderImage: It }
1336
+ }), p = f.getContext("2d"), m = f.width / i.w;
1337
+ return p && ft(p, [...o, ...s], m), {
1338
+ canvas: f,
1339
+ auto: s.map((e) => ({
1340
+ x: e.x * m,
1341
+ y: e.y * m,
1342
+ w: e.w * m,
1343
+ h: e.h * m
1344
+ }))
1345
+ };
1346
+ }
1347
+ // src/report.ts
1348
+ var Rt = {
1349
+ message: 5e3,
1350
+ email: 320,
1351
+ entries: 50,
1352
+ annotations: 200,
1353
+ screenshotChars: 6e6,
1354
+ screenshotBytes: 4718592,
1355
+ breadcrumbs: 20,
1356
+ followUpQuestion: 300,
1357
+ followUpAnswer: 2e3,
1358
+ replayChars: 45e5,
1359
+ fields: 10,
1360
+ fieldId: 40,
1361
+ fieldText: 200,
1362
+ bodyBytes: 11534336
1363
+ }, zt = 1572864;
1364
+ function Bt(e) {
1365
+ return Math.floor((e.length - e.indexOf(",") - 1) * 3 / 4);
1366
+ }
1367
+ function Vt(e, t) {
1368
+ let n = document.createElement("canvas");
1369
+ return n.width = Math.max(1, Math.round(e.width * t)), n.height = Math.max(1, Math.round(e.height * t)), n.getContext("2d")?.drawImage(e, 0, 0, n.width, n.height), n;
1370
+ }
1371
+ function Ht(e, t = zt) {
1372
+ let n = e, r = "";
1373
+ for (let e = 0; e < 6; e++) {
1374
+ for (let e of [
1375
+ .85,
1376
+ .7,
1377
+ .55
1378
+ ]) {
1379
+ let i = n.toDataURL("image/webp", e);
1380
+ if (i.startsWith("data:image/webp") || (i = n.toDataURL("image/jpeg", e)), r = i, Bt(i) <= t) return i;
1381
+ }
1382
+ n = Vt(n, .75);
1383
+ }
1384
+ if (Bt(r) > Rt.screenshotBytes || r.length > Rt.screenshotChars) throw Error("Screenshot too large");
1385
+ return r;
1386
+ }
1387
+ // src/editor/index.ts
1388
+ async function Ut(e, t = {}) {
1389
+ let { canvas: n, auto: r } = await Lt(e, window, t), i = {
1390
+ base: n,
1391
+ auto: r
1392
+ };
1393
+ return {
1394
+ dataUrl: Ht(n),
1395
+ annotations: [],
1396
+ edit: i,
1397
+ autoBlurred: r.length
1398
+ };
1399
+ }
1400
+ async function Wt(e, t) {
1401
+ let n = t.edit;
1402
+ if (!n?.base) return null;
1403
+ let r = await d(e, n.base, n.state, n.auto);
1404
+ return r ? {
1405
+ dataUrl: Ht(r.canvas),
1406
+ annotations: r.annotations,
1407
+ edit: {
1408
+ base: n.base,
1409
+ state: r.state,
1410
+ auto: n.auto
1411
+ },
1412
+ autoBlurred: t.autoBlurred
1413
+ } : null;
1414
+ }
1415
+ export { Wt as markUp, Ut as takeScreenshot };
1416
+
1417
+ //# sourceMappingURL=pinax-editor.js.map