@vitrinka/web 0.5.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +113 -0
- package/README.md +145 -20
- package/build/hud.iife.js +150 -28
- package/build/index.d.ts +1 -0
- package/build/protocol/index.d.ts +10 -0
- package/build/recorder/RecorderProvider.js +5 -18
- package/build/recorder/api.d.ts +20 -0
- package/build/recorder/api.js +21 -9
- package/build/recorder/capture/console.d.ts +6 -1
- package/build/recorder/capture/console.js +28 -5
- package/build/recorder/capture/net.d.ts +10 -1
- package/build/recorder/capture/net.js +14 -1
- package/build/recorder/capture/redact.d.ts +1 -0
- package/build/recorder/capture/redact.js +6 -1
- package/build/recorder/capture/rrweb-lane.d.ts +19 -0
- package/build/recorder/capture/rrweb-lane.js +109 -0
- package/build/recorder/capture/rrweb.d.ts +2 -9
- package/build/recorder/capture/rrweb.js +11 -86
- package/build/recorder/config.d.ts +3 -1
- package/build/recorder/config.js +15 -2
- package/build/recorder/flight.d.ts +141 -22
- package/build/recorder/flight.js +312 -27
- package/build/recorder/hud/Hud.js +206 -31
- package/build/recorder/hud/NotesSheet.d.ts +24 -0
- package/build/recorder/hud/NotesSheet.js +147 -0
- package/build/recorder/hud/RecorderPill.d.ts +34 -12
- package/build/recorder/hud/RecorderPill.js +52 -14
- package/build/recorder/hud/Sheet.d.ts +18 -15
- package/build/recorder/hud/Sheet.js +13 -13
- package/build/recorder/hud/controller.d.ts +81 -4
- package/build/recorder/hud/drop.d.ts +26 -0
- package/build/recorder/hud/drop.js +35 -0
- package/build/recorder/hud/host-style.d.ts +14 -0
- package/build/recorder/hud/host-style.js +15 -0
- package/build/recorder/hud/host.js +1 -1
- package/build/recorder/hud/icons.d.ts +6 -0
- package/build/recorder/hud/icons.js +12 -0
- package/build/recorder/hud/notes-rows.d.ts +39 -0
- package/build/recorder/hud/notes-rows.js +49 -0
- package/build/recorder/hud/resize.d.ts +6 -3
- package/build/recorder/hud/resize.js +8 -4
- package/build/recorder/hud/styles.d.ts +2 -30
- package/build/recorder/hud/styles.js +63 -31
- package/build/recorder/page-controller.js +13 -7
- package/build/recorder/queue.d.ts +22 -1
- package/build/recorder/queue.js +84 -5
- package/build/recorder/recents.d.ts +20 -4
- package/build/recorder/recents.js +41 -6
- package/build/recorder/session.d.ts +25 -6
- package/build/recorder/session.js +50 -8
- package/build/recorder/state.d.ts +18 -1
- package/build/recorder/state.js +40 -1
- package/build/recorder/storage/capture.d.ts +44 -0
- package/build/recorder/storage/capture.js +136 -0
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/bundle.d.ts +4 -0
- package/build/report/bundle.js +30 -0
- package/build/report/element.d.ts +86 -0
- package/build/report/element.js +146 -0
- package/build/report/engine.d.ts +144 -0
- package/build/report/engine.js +402 -0
- package/build/report/i18n.d.ts +78 -0
- package/build/report/i18n.js +151 -0
- package/build/report/identity.d.ts +26 -0
- package/build/report/identity.js +36 -0
- package/build/report/index.d.ts +12 -0
- package/build/report/index.js +15 -0
- package/build/report/keybind.d.ts +29 -0
- package/build/report/keybind.js +99 -0
- package/build/report/markers.d.ts +77 -0
- package/build/report/markers.js +162 -0
- package/build/report/profile.d.ts +62 -0
- package/build/report/profile.js +115 -0
- package/build/report/recorder-face.d.ts +2 -0
- package/build/report/recorder-face.js +20 -0
- package/build/report/styles.d.ts +7 -0
- package/build/report/styles.js +226 -0
- package/build/report/widget.d.ts +109 -0
- package/build/report/widget.js +907 -0
- package/build/report/wire.d.ts +68 -0
- package/build/report/wire.js +96 -0
- package/build/report-widget.mjs +229 -0
- package/package.json +11 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The report wire (vitrinka `docs/architecture/qa-studio.md` § "The report
|
|
3
|
+
* wire"), under `Authorization: Bearer <vkb_ key>`:
|
|
4
|
+
*
|
|
5
|
+
* POST /api/v1/reports envelope → {id, custody}
|
|
6
|
+
* PATCH /api/v1/reports/{id} {title?, description?, markers?, notify?}
|
|
7
|
+
* POST /api/v1/reports/{id}/chunk?seq=N raw rrweb event array (≤ 4 MiB, N from 1) → {blobKey}
|
|
8
|
+
* POST /api/v1/reports/{id}/events {events: [{seq, ts, tabHost, kind: "rrweb", payload, blobKey}]}
|
|
9
|
+
* POST /api/v1/reports/{id}/submit {} → {status: "filed" | "quarantined", reportUrl?}
|
|
10
|
+
*
|
|
11
|
+
* LEG-RESUMABLE: a job remembers which legs landed, so a retry resumes the
|
|
12
|
+
* failed one — one report, never a duplicate. Text the reporter changed
|
|
13
|
+
* after the report was created rides a PATCH. A capture leg the server
|
|
14
|
+
* refuses for good (a permanent 4xx) is skipped with a warning: the report
|
|
15
|
+
* still files, without its replay. `reportUrl` is the server's — shown as
|
|
16
|
+
* returned, never composed.
|
|
17
|
+
*/
|
|
18
|
+
import { type ApiTarget } from '../recorder/api';
|
|
19
|
+
import { type BuiltCapture, type ConsoleEntry, type NetEntry } from './engine';
|
|
20
|
+
import type { Locale } from './i18n';
|
|
21
|
+
import type { Identity } from './identity';
|
|
22
|
+
import type { WireMarker } from './markers';
|
|
23
|
+
export interface ReportEnv {
|
|
24
|
+
/** Origin + path of the page, through the redaction engine; never a query. */
|
|
25
|
+
url: string;
|
|
26
|
+
ua: string;
|
|
27
|
+
viewport: {
|
|
28
|
+
w: number;
|
|
29
|
+
h: number;
|
|
30
|
+
dpr: number;
|
|
31
|
+
};
|
|
32
|
+
appVersion: string;
|
|
33
|
+
/** The browser's language. */
|
|
34
|
+
locale: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ReportEnvelope {
|
|
37
|
+
title?: string;
|
|
38
|
+
description: string;
|
|
39
|
+
env: ReportEnv;
|
|
40
|
+
console: ConsoleEntry[];
|
|
41
|
+
network: NetEntry[];
|
|
42
|
+
identity?: Identity;
|
|
43
|
+
markers: WireMarker[];
|
|
44
|
+
/** The widget's language (the reporter reads mail and the portal in it). */
|
|
45
|
+
locale: Locale;
|
|
46
|
+
notify?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface SubmitReply {
|
|
49
|
+
status: 'filed' | 'quarantined';
|
|
50
|
+
reportUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
export declare class ReportJob {
|
|
53
|
+
readonly capture: BuiltCapture;
|
|
54
|
+
private readonly tabHost;
|
|
55
|
+
private readonly target;
|
|
56
|
+
id: string;
|
|
57
|
+
custody: 'direct' | 'quarantined' | '';
|
|
58
|
+
/** The editable fields as the server last received them. */
|
|
59
|
+
private sent;
|
|
60
|
+
private readonly blobKeys;
|
|
61
|
+
private rowsPosted;
|
|
62
|
+
private skipCapture;
|
|
63
|
+
/** `target`: the widget's own base and key — never whatever another widget configured. */
|
|
64
|
+
constructor(capture: BuiltCapture, tabHost: string, target: ApiTarget);
|
|
65
|
+
/** Run the legs from wherever the last run stopped; rejects with the failing leg's error. */
|
|
66
|
+
run(env: ReportEnvelope): Promise<SubmitReply>;
|
|
67
|
+
private sendCapture;
|
|
68
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The report wire (vitrinka `docs/architecture/qa-studio.md` § "The report
|
|
3
|
+
* wire"), under `Authorization: Bearer <vkb_ key>`:
|
|
4
|
+
*
|
|
5
|
+
* POST /api/v1/reports envelope → {id, custody}
|
|
6
|
+
* PATCH /api/v1/reports/{id} {title?, description?, markers?, notify?}
|
|
7
|
+
* POST /api/v1/reports/{id}/chunk?seq=N raw rrweb event array (≤ 4 MiB, N from 1) → {blobKey}
|
|
8
|
+
* POST /api/v1/reports/{id}/events {events: [{seq, ts, tabHost, kind: "rrweb", payload, blobKey}]}
|
|
9
|
+
* POST /api/v1/reports/{id}/submit {} → {status: "filed" | "quarantined", reportUrl?}
|
|
10
|
+
*
|
|
11
|
+
* LEG-RESUMABLE: a job remembers which legs landed, so a retry resumes the
|
|
12
|
+
* failed one — one report, never a duplicate. Text the reporter changed
|
|
13
|
+
* after the report was created rides a PATCH. A capture leg the server
|
|
14
|
+
* refuses for good (a permanent 4xx) is skipped with a warning: the report
|
|
15
|
+
* still files, without its replay. `reportUrl` is the server's — shown as
|
|
16
|
+
* returned, never composed.
|
|
17
|
+
*/
|
|
18
|
+
import { api, permanentStatus, uploadTo, VitrinkaApiError } from '../recorder/api';
|
|
19
|
+
import { EVENTS_PER_POST } from './engine';
|
|
20
|
+
export class ReportJob {
|
|
21
|
+
capture;
|
|
22
|
+
tabHost;
|
|
23
|
+
target;
|
|
24
|
+
id = '';
|
|
25
|
+
custody = '';
|
|
26
|
+
/** The editable fields as the server last received them. */
|
|
27
|
+
sent = '';
|
|
28
|
+
blobKeys = new Map();
|
|
29
|
+
rowsPosted = 0;
|
|
30
|
+
skipCapture = false;
|
|
31
|
+
/** `target`: the widget's own base and key — never whatever another widget configured. */
|
|
32
|
+
constructor(capture, tabHost, target) {
|
|
33
|
+
this.capture = capture;
|
|
34
|
+
this.tabHost = tabHost;
|
|
35
|
+
this.target = target;
|
|
36
|
+
}
|
|
37
|
+
/** Run the legs from wherever the last run stopped; rejects with the failing leg's error. */
|
|
38
|
+
async run(env) {
|
|
39
|
+
const to = { target: this.target };
|
|
40
|
+
const edits = { title: env.title, description: env.description, markers: env.markers, notify: env.notify ?? false };
|
|
41
|
+
const editsKey = JSON.stringify(edits);
|
|
42
|
+
if (!this.id) {
|
|
43
|
+
const res = await api('POST', '/api/v1/reports', env, to);
|
|
44
|
+
if (typeof res.id !== 'string' || !res.id)
|
|
45
|
+
throw new Error('vitrinka: the server filed the report without an id');
|
|
46
|
+
this.id = res.id;
|
|
47
|
+
this.custody = res.custody === 'direct' ? 'direct' : 'quarantined';
|
|
48
|
+
this.sent = editsKey;
|
|
49
|
+
}
|
|
50
|
+
else if (this.sent !== editsKey) {
|
|
51
|
+
await api('PATCH', `/api/v1/reports/${encodeURIComponent(this.id)}`, edits, to);
|
|
52
|
+
this.sent = editsKey;
|
|
53
|
+
}
|
|
54
|
+
if (!this.skipCapture) {
|
|
55
|
+
try {
|
|
56
|
+
await this.sendCapture();
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (!(e instanceof VitrinkaApiError) || !permanentStatus(e.status))
|
|
60
|
+
throw e;
|
|
61
|
+
console.warn('vitrinka: the server refused the recording — the report goes without it', e);
|
|
62
|
+
this.skipCapture = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const reply = await api('POST', `/api/v1/reports/${encodeURIComponent(this.id)}/submit`, {}, to);
|
|
66
|
+
return {
|
|
67
|
+
status: reply.status === 'filed' ? 'filed' : 'quarantined',
|
|
68
|
+
...(typeof reply.reportUrl === 'string' && reply.reportUrl ? { reportUrl: reply.reportUrl } : {}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async sendCapture() {
|
|
72
|
+
const id = encodeURIComponent(this.id);
|
|
73
|
+
const { chunks, truncated } = this.capture;
|
|
74
|
+
for (const c of chunks) {
|
|
75
|
+
if (this.blobKeys.has(c.seq))
|
|
76
|
+
continue;
|
|
77
|
+
const up = await uploadTo(`/api/v1/reports/${id}/chunk?seq=${c.seq}`, 'application/json', c.body, this.target);
|
|
78
|
+
if (!up.blobKey)
|
|
79
|
+
throw new Error(`vitrinka: chunk ${c.seq} came back without a blob key`);
|
|
80
|
+
this.blobKeys.set(c.seq, up.blobKey);
|
|
81
|
+
}
|
|
82
|
+
const rows = chunks.map((c) => ({
|
|
83
|
+
seq: c.seq,
|
|
84
|
+
ts: c.ts,
|
|
85
|
+
tabHost: this.tabHost,
|
|
86
|
+
kind: 'rrweb',
|
|
87
|
+
payload: { count: c.count, source: 'replay', truncated },
|
|
88
|
+
blobKey: this.blobKeys.get(c.seq) ?? '',
|
|
89
|
+
}));
|
|
90
|
+
while (this.rowsPosted < rows.length) {
|
|
91
|
+
const batch = rows.slice(this.rowsPosted, this.rowsPosted + EVENTS_PER_POST);
|
|
92
|
+
await api('POST', `/api/v1/reports/${id}/events`, { events: batch }, { target: this.target });
|
|
93
|
+
this.rowsPosted += batch.length;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
function Lt(e,t,n,r){if(e===1)return t;if(e>=2&&e<=4)return n;return r}var Ai={button:"Report a problem",title:"Report a problem",close:"Close",settings:"Settings",prompt:"What went wrong?",placeholder:"Tell us what happened and what you expected",attached:(e)=>{if(e<60)return`The last ${e} seconds are attached`;let t=Math.round(e/60);return t===1?"The last minute is attached":`The last ${t} minutes are attached`},included:"What’s included",incReplay:"A replay of what happened on this page",incReplayMasked:{strict:"Text on the page and anything you typed are hidden in it",balanced:"Anything you typed is hidden in it",full:"It shows the page as you saw it"},incErrors:"Errors the page ran into",incConsole:"Messages from the browser console",incNetwork:"Which addresses the page loaded, with their status",incFailedRequests:"Requests that failed — address and status only",incEnv:"Your browser, screen size, language and this page’s address",incIdentity:"Your name and email from this app",incMarks:"The places you marked, with your notes",showWhere:"Show us where",marked:(e)=>e===1?"1 place marked":`${e} places marked`,notify:"Email me when it’s fixed",send:"Send",sending:"Sending…",retry:"Try again",errorCreate:"Couldn’t send — your text is safe, try again",errorCapture:"Your report arrived, the recording not yet — try again to attach it",sentTitle:"Thanks — we’ve got it",sentBody:"The team will take a look.",sentNotify:"We’ll email you when it’s fixed.",seeReport:"See your report",tools:{circle:"Circle",box:"Box",arrow:"Arrow",hide:"Hide"},toolbar:"Marking tools",undo:"Undo",done:"Done",coach:"Click, hold and move around the problem.",coachMore:"You can mark more than one place.",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Hidden",notePlaceholder:"Add a note (optional)",mark:(e)=>`Mark ${e}`,removeMark:(e)=>`Remove mark ${e}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back"},Pi={button:"Nahlásit problém",title:"Nahlásit problém",close:"Zavřít",settings:"Nastavení",prompt:"Co se pokazilo?",placeholder:"Napište, co se stalo a co jste čekali",attached:(e)=>{if(e<60)return Lt(e,"Poslední sekunda je přiložena",`Poslední ${e} sekundy jsou přiloženy`,`Posledních ${e} sekund je přiloženo`);let t=Math.round(e/60);return Lt(t,"Poslední minuta je přiložena",`Poslední ${t} minuty jsou přiloženy`,`Posledních ${t} minut je přiloženo`)},included:"Co je přiloženo",incReplay:"Záznam toho, co se na stránce dělo",incReplayMasked:{strict:"Texty stránky i vše, co jste napsali, jsou v něm skryté",balanced:"Vše, co jste napsali, je v něm skryté",full:"Ukazuje stránku tak, jak jste ji viděli"},incErrors:"Chyby, na které stránka narazila",incConsole:"Zprávy z konzole prohlížeče",incNetwork:"Které adresy stránka načítala a s jakým výsledkem",incFailedRequests:"Požadavky, které selhaly — jen adresa a výsledek",incEnv:"Váš prohlížeč, velikost obrazovky, jazyk a adresa stránky",incIdentity:"Vaše jméno a e-mail z této aplikace",incMarks:"Místa, která jste označili, i s poznámkami",showWhere:"Ukažte nám kde",marked:(e)=>Lt(e,"1 označené místo",`${e} označená místa`,`${e} označených míst`),notify:"Pošlete mi e-mail, až to bude opravené",send:"Odeslat",sending:"Odesílám…",retry:"Zkusit znovu",errorCreate:"Nepodařilo se odeslat — váš text zůstal, zkuste to znovu",errorCapture:"Hlášení dorazilo, záznam zatím ne — zkuste to znovu a přiložíme ho",sentTitle:"Díky — máme to",sentBody:"Tým se na to podívá.",sentNotify:"Až to bude opravené, pošleme vám e-mail.",seeReport:"Zobrazit hlášení",tools:{circle:"Kruh",box:"Obdélník",arrow:"Šipka",hide:"Skrýt"},toolbar:"Nástroje pro označení",undo:"Zpět",done:"Hotovo",coach:"Klikněte, podržte a veďte kolem problému.",coachMore:"Označit můžete i více míst.",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Skryto",notePlaceholder:"Přidejte poznámku (nepovinné)",mark:(e)=>`Značka ${e}`,removeMark:(e)=>`Odebrat značku ${e}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět"},_i={cs:Pi,en:Ai};function Dt(e){return _i[e]}function Ce(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"?t:null}function Nt(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=Ce(n);if(r)return r}return"en"}var hr="[redacted]",Li=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],Di=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function ce(e){return String(e).toLowerCase().replace(/[-_]/g,"")}var Ot=null;function Bt(e){let t=JSON.stringify(e??null);if(Ot?.src===t)return Ot.rules;let n=new Set(Li),r=new Set(Di),o=[];for(let s of e?.extraHeaders??[]){let a=ce(s);if(a)n.add(a)}for(let s of e?.extraBodyKeys??[]){let a=ce(s);if(a)r.add(a)}for(let s of e?.patterns??[])try{o.push(new RegExp(s,"g"))}catch(a){console.warn("vitrinka redact: unsupported pattern skipped",s,a)}let i={full:e?.fullFidelity===!0,maskAllText:e?.maskAllText===!0,headers:n,bodyKeys:r,patterns:o};return Ot={src:t,rules:i},i}var Ni=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),Oi=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function Bi(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t)=>t.toLowerCase())}function gr(e){let t=Bi(e);if(t.some((n)=>Ni.has(n)))return!0;for(let n=0;n<t.length;n++){let r="";for(let o=n;o<t.length;o++){if(r+=t[o],Oi.includes(r))return!0;if(r.length>24)break}}return!1}function mr(e,t){let n=ce(t);return e.headers.has(n)||n.endsWith("apikey")||n.endsWith("token")||gr(t)}function W(e,t){return e.bodyKeys.has(ce(t))||gr(t)}function br(e,t){if(W(e,t))return!0;let n=ce(t);return n.endsWith("apikey")||n.endsWith("token")}var Hi=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,qi=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function yr(e){return e.includes("PRIVATE KEY-----")?e.replace(Hi,"[redacted]"):e}function de(e,t){let n=yr(t);for(let r of e.patterns)r.lastIndex=0,n=n.replace(r,"[redacted]");return n}function kr(e,t){if(qi.test(t))return!0;for(let n of t.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(W(e,n[1]))return!0;return!1}function Xe(e){let t=e;for(let n=0;n<3;n++){let r=$i(t);if(r===t)break;t=r}return t}function $i(e){if(!e.includes("%"))return e;try{return decodeURIComponent(e)}catch{return e.replace(/(%[0-9A-Fa-f]{2})+/g,(t)=>{try{return decodeURIComponent(t)}catch{return t.replace(/%([0-9A-Fa-f]{2})/g,(n,r)=>{let o=Number.parseInt(r,16);return o<128?String.fromCharCode(o):n})}})}}function vr(e,t,n){let r=!1,o=n.split(/[&;]/).map((i)=>{if(i==="")return i;let s=i.indexOf("="),a=s>=0?i.slice(0,s):i,l=Xe(a.replace(/\+/g," ")),d=l.lastIndexOf("?"),g=d>=0?l.slice(d+1):null;if(t(e,l)||g!==null&&t(e,g))return r=!0,`${a}=[redacted]`;if(s>=0&&kr(e,Xe(i.slice(s+1))))return r=!0,`${a}=[redacted]`;return i});return r?o.join("&"):n}function Ht(e,t){if(e.full||!t)return t;let n=t.search(/[?#]/);if(n<0)return de(e,t);let r=t.slice(n+1).split("#").map((o)=>vr(e,br,o)).join("#");return de(e,t.slice(0,n+1)+r)}var Fi=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,Ki=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,Wi=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,zi=131072;function Je(e,t){if(t.length>zi)return`[body omitted: ${t.length} bytes, unmaskable]`;let n=yr(t).replace(Wi,(r,o)=>mr(e,o)?`${o}: [redacted]`:r).replace(/\b((?:proxy-)?authorization|www-authenticate)(\s*[:=]\s*)[^\r\n]+/gi,(r,o,i)=>`${o}${i}[redacted]`).replace(/\b(Digest|Negotiate|NTLM)\s+(?=[A-Za-z][A-Za-z-]{0,30}\s*=)[^\r\n]+/gi,(r,o)=>`${o} [redacted]`).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9._-]{10,}/g,"[redacted]").replace(Ki,(r,o,i,s)=>{if(br(e,Xe(i)))return`${o}${i}=[redacted]`;if(kr(e,Xe(s)))return`${o}${i}=[redacted]`;return r}).replace(Fi,(r,o,i,s,a)=>{if(a==="[redacted]")return r;return W(e,o)?`${o}${i}${s}[redacted]${s}`:r});return de(e,n)}function ji(e){switch(ce(e)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var Ui=64;function Ge(e,t,n){if(n>Ui)return"[redacted]";if(Array.isArray(t))return t.map((r)=>Ge(e,r,n+1));if(t!==null&&typeof t==="object"){let r={};for(let[o,i]of Object.entries(t))if(W(e,o))r[o]="[redacted]";else if(typeof i==="string"&&ji(o))r[o]=Ht(e,i);else r[o]=Ge(e,i,n+1);return r}return typeof t==="string"?de(e,t):t}function pr(e){if(!e.includes("\\"))return e;return e.replace(/\\u([0-9A-Fa-f]{4})|\\(.)/g,(t,n,r)=>n!==void 0?String.fromCharCode(Number.parseInt(n,16)):r)}function Vi(e,t){for(let n of t.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(W(e,pr(n[1])))return"";return t.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(n,r,o)=>W(e,pr(o))?`${r}"[redacted]"`:n)}function qt(e){let t=e.trimStart();return t.startsWith("{")||t.startsWith("[")}function Yi(e,t,n){let r=/boundary="?([^";]+)"?/i.exec(n);if(!r)return null;let o=`--${r[1]}`,i=t.split(o);if(i.length<3||i[0]!=="")return null;if(!i[i.length-1].startsWith("--"))return null;let s=[i[0]];for(let a=1;a<i.length-1;a++){let l=i[a];if(!l.startsWith(`\r
|
|
2
|
+
`)||!l.endsWith(`\r
|
|
3
|
+
`))return null;let d=l.indexOf(`\r
|
|
4
|
+
\r
|
|
5
|
+
`);if(d<0)return null;let g=l.slice(2,d),b=l.slice(d+4,-2),p=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(g)?.[1]??"",h=p!==""&&W(e,p)?"[redacted]":Je(e,b);s.push(`\r
|
|
6
|
+
${g}\r
|
|
7
|
+
\r
|
|
8
|
+
${h}\r
|
|
9
|
+
`)}return s.push(i[i.length-1]),s.join(o)}var wr=262144;function fr(e,t,n){if(e.full||!t)return t;try{if(qt(t)){if(t.length<=wr)try{return JSON.stringify(Ge(e,JSON.parse(t),0))}catch{}return de(e,Vi(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return Je(e,vr(e,W,t));if(r.includes("multipart/form-data")){let o=Yi(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return Je(e,t)}catch{return"[redacted]"}}function xr(e,t){if(t===void 0)return;if(e.full)return t;if(qt(t))try{return JSON.stringify(Ge(e,JSON.parse(t),0))}catch{}try{return Je(e,t)}catch{return"[redacted]"}}function Sr(e,t,n,r){if(e.full)return t.length>n?`${t.slice(0,n)}…[truncated]`:t;if(t.length>n&&r?.toLowerCase().includes("multipart/form-data"))return`[multipart body omitted: oversized (${t.length} chars)]`;if(qt(t)&&t.length<=wr){let i=fr(e,t,r);return i.length>n?`${i.slice(0,n)}…[truncated]`:i}let o=t.length>n?`${t.slice(0,n)}…[truncated]`:t;return fr(e,o,r)}function Er(e,t,n){if(!t)return;let r=n?.maxValueLen??1024,o=n?.budget??8192,i={};for(let[s,a]of Object.entries(t)){let d=(e.full?String(a):mr(e,s)?"[redacted]":de(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function Rr(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var w={tabId:"root",tabHost:"/",pathname:"/"};function Tr(){try{let e=globalThis.sessionStorage,t=e.getItem("vitrinka.tab");if(t)return t;let n=Math.random().toString(36).slice(2,10);return e.setItem("vitrinka.tab",n),n}catch{return"root"}}function Mr(e,t){w.tabId=e,w.tabHost=t}var Ae={following:null},Ie="__vitrinkaCaptureOwner";function Cr(e,t){let n=globalThis,r=n[Ie];if(r){if(e==="report")return null;if(r.face==="report")n[Ie]=null,r.yieldTo?.()}let o=`${e}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return n[Ie]={face:e,token:o,...t?{yieldTo:t}:{}},o}function Ir(e){let t=globalThis;if(e&&t[Ie]?.token===e)t[Ie]=null}var Xi=new Set;function Pe(){for(let e of Xi)e()}async function Ar(e,t){let n=`vitrinka.recorder.${e}`;if(globalThis.navigator?.locks){await navigator.locks.request(n,{signal:AbortSignal.timeout(5000)},t);return}let r=await Ji();await new Promise((o,i)=>{let s=r.transaction("locks","readwrite");s.oncomplete=()=>o(),s.onabort=()=>i(s.error??Error("vitrinka: recorder lock transaction aborted"));let a=s.objectStore("locks").get(n);a.onsuccess=()=>{try{t()}catch(l){i(l),s.abort()}}})}var _e;function Ji(){if(!_e)_e=new Promise((e,t)=>{let n=indexedDB.open("vitrinka.recorder.locks",1);n.onupgradeneeded=()=>n.result.createObjectStore("locks"),n.onerror=()=>t(n.error),n.onsuccess=()=>{let r=n.result;r.onversionchange=()=>{r.close(),_e=void 0},e(r)}}).catch((e)=>{throw _e=void 0,e});return _e}var ee="vitrinka.recorder.",$t=null,Gi=!1;function z(){if(!$t)$t=Zi()??Qi();return Gi=!0,$t}function Zi(){try{let e=globalThis.localStorage;if(!e)return null;let t=`${ee}probe`;return e.setItem(t,"1"),e.removeItem(t),{getString:(n)=>e.getItem(ee+n),set:(n,r)=>e.setItem(ee+n,r),remove:(n)=>e.removeItem(ee+n),withLock:Ar,keys:()=>Array.from({length:e.length},(n,r)=>e.key(r)).filter((n)=>n!==null&&n.startsWith(ee)).map((n)=>n.slice(ee.length)),watch:(n,r)=>{let o=(i)=>{if(i.storageArea===e&&i.key===ee+n)r(i.newValue)};return globalThis.addEventListener("storage",o),()=>globalThis.removeEventListener("storage",o)}}}catch{return console.warn("vitrinka: localStorage unavailable — the recorder queue will not survive a reload"),null}}function Qi(){let e=new Map;return{getString:(t)=>e.get(t)??null,set:(t,n)=>void e.set(t,n),remove:(t)=>void e.delete(t),keys:()=>[...e.keys()]}}var Ze={url:"",key:""};function Qe(){return Ze}var Ft=new Set;function Pr(e){let t=e.replace(/\/+$/,"");return Ft.add(t),()=>Ft.delete(t)}function Kt(e){if(Ze.url!==""&&e.startsWith(Ze.url))return!0;for(let t of Ft)if(t!==""&&e.startsWith(t))return!0;return!1}var es="link";function ts(){let e=z().getString(es);if(!e)return null;try{let t=JSON.parse(e);return typeof t.token==="string"&&t.token?t:null}catch{return null}}function _r(){return Ze.key||ts()?.token||""}var ue=Bt(null);function Dr(e){ue=Bt(e??null)}function Nr(e){return xr(ue,e)}function Wt(e,t,n){return Sr(ue,e,t,n)}var Lr=null,Or=null;function zt(e){Or=e??null}function ns(e){let t=Or??Qe().sanitizeUrl;if(!t)return e;let n;try{let r=t(e);if(typeof r==="string")return r;n=`returned ${typeof r}`}catch{n="threw"}if(Lr!==t)Lr=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return rs(e)??hr}function rs(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function te(e){return Ht(ue,ns(e))}var os=4;function jt(e){return e.type===os}function Ut(e){if(!jt(e))return e;return{...e,data:{...e.data,href:te(e.data.href)}}}function Le(e){return Er(ue,e)}function Br(){return Rr(ue)}var De="data-vitrinka-recorder";var Vt="all:initial;position:fixed;z-index:2147483647;inset:0 auto auto 0;margin:0;padding:0;border:0;background:transparent;overflow:visible;width:0;height:0;pointer-events:none;color-scheme:normal;",Hr=Vt;var is=["pointerdown","pointerup","pointermove","pointerover","pointerout","pointercancel","mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchmove","touchcancel","wheel","focusin","focusout","keydown","keyup","keypress","paste","dragenter","dragover","dragleave","drop"];function $r(e){for(let t of is)e.addEventListener(t,(n)=>n.stopPropagation())}function Fr(){let e=document.createElement("div");e.setAttribute(De,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=Vt;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),$r(e),document.documentElement.append(e);let r=typeof e.showPopover==="function",o=()=>{if(!r||!e.isConnected)return;try{e.hidePopover?.()}catch{}try{e.showPopover?.()}catch{}};if(r)e.popover="manual";o();let i=!1,s=()=>{if(i)return;i=!0,queueMicrotask(()=>{i=!1,o()})},a=(c)=>{if(c.type==="attributes")return c.target instanceof Element&&qr(c.target);for(let p of[c.addedNodes,c.removedNodes])for(let h of p){if(!(h instanceof Element))continue;if(qr(h))return!0;if(h.childElementCount>0&&h.querySelector(Kr))return!0}return!1},l=[],d=0,g=()=>{d=0;let c=l;if(l=[],c.some(a))s()},b=new MutationObserver((c)=>{for(let p of c)l.push(p);if(d===0)d=typeof requestAnimationFrame==="function"?requestAnimationFrame(g):setTimeout(g,16)});return b.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:e,mount:n,destroy:()=>{if(b.disconnect(),d!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(d);l=[];try{e.hidePopover?.()}catch{}e.remove()}}}var Kr='dialog,[role="dialog"]';function qr(e){return e.matches(Kr)}function Wr(){let e=document.querySelectorAll("dialog[open]"),t=e[e.length-1];if(t)return t;let n=document.querySelectorAll('[role="dialog"][data-state="open"]');return n[n.length-1]??null}function zr(e){let t=document.createElement("div");t.setAttribute(De,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=Hr;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");return n.append(r),$r(t),e.append(t),{mount:r,destroy:()=>t.remove()}}function N(e,t,n,r={}){let o=e,i=o.__zone_symbol__addEventListener??e.addEventListener,s=o.__zone_symbol__removeEventListener??e.removeEventListener,a=r.capture??!1;return i.call(e,t,n,{capture:a,passive:!1}),()=>s.call(e,t,n,a)}class T extends Error{constructor(e,t){super(e);this.status=t,this.name="VitrinkaApiError"}}function j(e){return e>=400&&e<500&&e!==408&&e!==429}function jr(e){return e===401}var ss=null;function Ur(e){if(jr(e))ss?.()}function Vr(e){return e??{url:Qe().url,key:_r()}}async function O(e,t,n,r={}){let{url:o,key:i}=Vr(r.target),s=await fetch(o+t,{method:e,mode:"cors",credentials:"omit",keepalive:r.keepalive??!1,headers:{authorization:`Bearer ${i}`,...n!==void 0?{"content-type":"application/json"}:{}},body:n===void 0?void 0:JSON.stringify(n)}),a=await s.text();if(!s.ok){if(!r.target)Ur(s.status);throw new T(`${e} ${t} → ${s.status}: ${a}`,s.status)}return a?JSON.parse(a):{}}function Yr(e,t,n){return Jr(e,"chunk",t,"application/json",n)}function Xr(e,t,n){return Jr(e,"shot",t,n.type,n)}function Jr(e,t,n,r,o){return Yt(`/api/v1/sessions/${e}/${t}?seq=${n}`,r,o)}async function Yt(e,t,n,r){let{url:o,key:i}=Vr(r),s=await fetch(o+e,{method:"POST",mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${i}`,"content-type":t},body:n}),a=await s.text();if(!s.ok){if(!r)Ur(s.status);throw new T(`POST ${e} → ${s.status}: ${a}`,s.status)}try{return JSON.parse(a)}catch{return{}}}var Gr=30000,as=4194304,ls=20000,Gt=500,cs=2000,ds=2,Zr={windowMs:Gr,checkoutMs:Gr,maxBytes:as,maxEvents:ls,maxLaneEvents:Gt},V=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function Zt(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var us=new TextEncoder,X=!1,Qr=0,E=Zr,v=[],M=[],B=[],U=[],ps=0,fe=[],he=new Map,ge=null,pe=null,Ne=!1,fs=0,Y=null,et=null,Jt=Promise.resolve();function eo(e=Zr){if(en(),X=!0,Qr++,E=e,Y=e.store??null,v=(e.prior??[]).filter((t)=>t.kind!=="lanes").map((t)=>({id:t.id,load:t.load,startMs:t.startMs,lastMs:t.lastMs,events:[],count:t.count,bytes:t.bytes,href:t.href,route:t.route,stored:!0})),M=(e.priorLanes??[]).slice(-e.maxLaneEvents),B=[],U=[],fe=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),he.clear(),ge=null,nt(Date.now()),Y)et=setInterval(tt,cs)}function to(){tt(),en(),X=!1,Y=null,v=[],M=[],B=[],U=[],fe=[],he.clear(),ge=null}function no(){return E}function Qt(e){pe=e}function ro(){if(!X)return;v=[],M=[],B=[],U=[],fe=[],he.clear(),ge=null;let e=w.tabId;ne((t)=>t.clear(e)),pe?.()}function oo(){return Jt}function tt(){if(!X||!Y)return;let e=Date.now();nt(e),tn(e);for(let t of v){if(t.stored)continue;let n=he.get(t.id)??{events:0,parts:0};if(n.events===t.events.length)continue;let r=JSON.stringify(t.events.slice(n.events)),o=n.parts;he.set(t.id,{events:t.events.length,parts:o+1});let i=io(t);ne((s)=>s.putWindowChunk(i,o,r,[]))}hs(e)}function hs(e){let t=e-E.windowMs;while(U.length>0&&U[0].lastMs<=t){let[a]=U.splice(0,1);if(a)ne((l)=>l.dropWindow(a.id))}for(let a of fe.filter((l)=>l.lastMs<=t))ne((l)=>l.dropWindow(a.id));fe=fe.filter((a)=>a.lastMs>t);let n=B;if(!n.length)return;B=[];let r=U.at(-1);if(!r||r.startMs<=t)r={id:`${V}.lanes.${++ps}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},U.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:w.tabId,scope:E.scope??"",kind:"lanes",load:V,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};ne((a)=>a.putWindowChunk(s,o,"[]",n))}function en(){if(et)clearInterval(et);et=null}function io(e){return{id:e.id,tab:w.tabId,scope:E.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function ne(e){let t=Y;if(!t)return;Jt=Jt.then(()=>e(t)).catch((n)=>{if(Y!==t)return;Y=null,en(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function Xt(e){let[t]=v.splice(e,1);if(!t)return;he.delete(t.id),ne((n)=>n.dropWindow(t.id))}function nt(e){while(v.length>0){let r=v[0],o=v[1];if(!o&&r.load===V)break;if(Zt(r,o)>e-E.windowMs)break;Xt(0)}if(Ne)return;let t=v.at(-1);if(t&&t.load===V&&pe&&t.lastMs<=e-E.windowMs){Ne=!0;try{pe()}finally{Ne=!1}let r=v.indexOf(t);if(r>=0&&r<v.length-1)for(let o=r;o>=0;o--)Xt(o)}let n=!1;while(v.length>0&&gs()){if(v.length===1&&v[0].load===V&&!n&&pe){n=!0,Ne=!0;try{pe()}finally{Ne=!1}if(v.length>1)continue}Xt(0),ge=v[0]?.startMs??e}}function so(){return X?`flight:${Qr}`:null}function tn(e){let t=Math.min(v[0]?.startMs??Number.POSITIVE_INFINITY,e-E.windowMs),n=M.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)M=[];else if(n>0)M=M.slice(n)}function gs(){let e=0,t=0;for(let n of v)e+=n.bytes,t+=n.count;return e>E.maxBytes||t>E.maxEvents}function ao(e){if(!X)return;let t=v[0];if(jt(e)){let r=globalThis.location?.pathname??w.pathname,o={id:`${V}.${++fs}`,load:V,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:te(r)};v.push(o);let i=io(o);ne((s)=>s.putWindow(i))}let n=v.at(-1);if(!n||n.load!==V)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=us.encode(JSON.stringify(e)).length,nt(e.timestamp),v[0]!==t)tn(e.timestamp)}function lo(e,t,n){if(!X)return null;let r=E.keepLane?E.keepLane(e,t):t;if(r===null)return null;let o=new Date().toISOString(),i={ts:o,tabId:n.tabId,tabHost:n.tabHost,kind:e,payload:r},s=E.maxLaneEvents;if(M.push(i),M.length>s)M.splice(0,M.length-s);if(Y){if(B.push(i),B.length>s)B.splice(0,B.length-s)}return o}function nn(){if(!X)return null;let e=Date.now();return nt(e),tn(e),{windows:v.map((t)=>({...t,events:t.events.slice()})),lanes:M.slice(),truncated:ge!==null&&ge>e-E.windowMs}}function co(e){return e.windows.some((t)=>t.events[1]?.type===ds)}var rn=null;function rt(){if(!rn)rn=typeof indexedDB>"u"?ms():bs();return rn}function ms(){let e=new Map;return{durable:!1,put:async(t,n)=>void e.set(t,n),get:async(t)=>e.get(t)??null,delete:async(t)=>void e.delete(t),keys:async()=>[...e.keys()]}}function bs(){let e,t=()=>(e??=new Promise((r,o)=>{let i=indexedDB.open("vitrinka.recorder.blobs",1);i.onupgradeneeded=()=>i.result.createObjectStore("blobs"),i.onerror=()=>o(i.error??Error("vitrinka: blob journal did not open")),i.onsuccess=()=>{let s=i.result;s.onversionchange=()=>{s.close(),e=void 0},s.onclose=()=>{e=void 0},r(s)}}).catch((r)=>{throw e=void 0,r}),e),n=async(r,o)=>{let i=t(),s;try{s=(await i).transaction("blobs",r)}catch(l){if(e===i)e=void 0;throw l}let a=o(s.objectStore("blobs"));return new Promise((l,d)=>{s.oncomplete=()=>l(a.result),s.onabort=s.onerror=()=>d(s.error??a.error??Error("vitrinka: blob journal transaction failed"))})};return{durable:!0,put:async(r,o)=>void await n("readwrite",(i)=>i.put(o,r)),get:async(r)=>{let o=await n("readonly",(i)=>i.get(r));return o instanceof Blob?o:null},delete:async(r)=>void await n("readwrite",(o)=>o.delete(r)),keys:async()=>(await n("readonly",(r)=>r.getAllKeys())).filter((r)=>typeof r==="string")}}var ys=2000,ln=20000,vo=200,ks=4194304,vs=3145728,pt=500,ws=ks-1024,xs=12582912,Ss=10485760,Es=xs-64,Rs=1048576,Ts=new TextEncoder;function Re(e){return Ts.encode(e).length}var x=()=>z();function q(e,t){let n=x().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var uo=!1;function F(e,t){try{return x().set(e,t),!0}catch(n){if(!uo)uo=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var st="rec",ie;function S(){if(ie===void 0)ie=q(st,null);return ie}function wo(e){if(ie=e,e===null)x().remove(st),x().remove(Ms);else F(st,JSON.stringify(Cs(e)))}var Ms="notes";var Be=null;function Cs(e){if(Be?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:Be.activeMs,resumeAt:null,stopping:Be.at}}var Is=new Set;function As(){for(let e of Is)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function Ps(e){let t=null;if(e)try{t=JSON.parse(e)}catch{return"unchanged"}let n=S();if(t?.stopping&&t.sessionId===n?.sessionId&&!n.paused&&Be?.sessionId!==t.sessionId)As();if(!t){if(!n)return"unchanged";return ie=null,ko(),Ws(),"ended"}if(n?.sessionId===t.sessionId){if(t.seq=Math.max(t.seq,n.seq),t.policy===void 0&&n.policy!==void 0)t.policy=n.policy;if(t.attachments===void 0&&n.attachments!==void 0)t.attachments=n.attachments;if(Be?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return ie=t,"updated"}return ie=t,ko(),"joined"}var _s=700,se,H=null,Z=!1;function be(){if(se===void 0)se=q("buffer",[]);return se}function ft(){if(H)clearTimeout(H),H=null;if(se!==void 0&&!Z)F("buffer",JSON.stringify(se))}function xo(){if(Z=!1,H)return;H=setTimeout(()=>{H=null,ft(),So()},_s)}function po(e){se=e,Z=!1,ft()}var me,ke=0;function re(){if(me===void 0)me=q("chunks",[]),ke=me.reduce((e,t)=>e+t.body.length,0);return me}function So(){if(Z)return;let e=re();if(e.length===0){x().remove("chunks");return}if(ke>Rs){x().remove("chunks");return}F("chunks",JSON.stringify(e))}function Ls(e){me=e,ke=e.reduce((t,n)=>t+n.body.length,0),Z=!1,So()}var at,ve=new Map,ye=new Set,we=new Map,ot=new Map,fo=5,Ds=200,Ns=67108864,Os=0,ho=!1,Bs="blobs";function C(){return at??=q("images",[]),at}function Eo(){if(Z)return;let e=C().filter((t)=>!ye.has(t.blob));if(e.length===0)x().remove("images");else F("images",JSON.stringify(e))}function Ro(e){at=e,Z=!1,Eo()}function Hs(e,t){let n=rt();if(!n.durable&&!ho)ho=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");F(Bs,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${Io}.${++Os}`;return ve.set(a,i),ye.add(a),r.push(n.put(a,i).then(()=>{if(!(ve.has(a)||C().some((d)=>d.blob===a)||[...we.values()].includes(a)))return ye.delete(a),cn(a),!1;if(!n.durable)return!1;if(ye.delete(a),C().some((d)=>d.blob===a))Eo();return!0},(l)=>(console.warn("vitrinka: an attached image could not be journaled — it will not survive a reload",l),!1))),{blob:a,payload:s}}),journaled:Promise.all(r).then((i)=>i.every(Boolean))}}function cn(e){rt().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function xe(e,t){for(let n of e)if(ve.delete(n),ye.delete(n),ot.delete(n),t)cn(n)}var lt=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];var qs=0,To="",Mo=0,go=-1;function dn(){qs=Date.now(),Mo=0,To=""}function Se(e){Mo++,To=String(e instanceof Error?e.message:e).slice(0,200)}var mo={actions:0,pages:0,frames:0,notes:0},$s=new Set;function Fs(e){let t={...mo};for(let n of e)if(n.kind==="click")t.actions++;else if(n.kind==="nav")t.pages++;else if(n.kind==="rrweb")t.frames+=typeof n.payload?.count==="number"?n.payload.count:1;else if(n.kind==="note"){if(t.notes++,typeof n.payload?.cid==="string")$s.add(n.payload.cid)}mo=t}function Ks(e){let t=S();if(!t||t.dead)return;if(t.dead=!0,t.deadReason=e,!t.paused&&t.resumeAt)t.activeMs=(t.activeMs||0)+(Date.now()-Date.parse(t.resumeAt)),t.resumeAt=null;wo(t),console.warn("vitrinka: session marked dead —",e),Pe()}var on=null;function Ws(){if(on)clearInterval(on);on=null}function Co(e){let t=S();if(!t||t.dead||e<1)return null;let n=q("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return x().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,wo(t),{seq:r,sessionId:t.sessionId}}var Io=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,ct="allocation.",zs=0,I=new Set,js=16777216,dt=0,ut=0,Ee=new Map;function ht(e){return e.kind==="event"?1+(e.images?.length??0):1}function Us(e,t){return new Set(Array.from({length:ht(t)},(n,r)=>e+r))}function un(e,t,n){return JSON.stringify(n&&n.size<ht(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var bo=!1,Oe=null;function it(e){if(!I.delete(e))return;if(dt-=e.bytes,e.draft.kind==="chunk")ut--}function Ao(e){if(I.add(e),dt+=e.bytes,e.draft.kind==="chunk")ut++;while(I.size>ln||dt>js||ut>vo){let t=I.values().next().value;it(t),x().remove(t.key),xe(lt(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");Se(n),console.warn(n.message)}}function Po(e=!1){if(bo&&!e)return;bo=!0;let t=x();if(!t.withLock)return;let n=new Set([...I].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(ct)||n.has(r)||Ee.has(r))continue;let o=q(r,null);if(o&&o.draft&&o.draft.sessionId===S()?.sessionId)Ao({...o,key:r,persisted:!0,bytes:Re(JSON.stringify(o))})}}function _o(e,t,n){let{ts:r,tabId:o,tabHost:i,sessionId:s}=e,a=(l)=>!n||n.has(l);if(e.kind==="event"){let l=e.images??[],d=t+l.length,g=l.length?{...e.event,payload:{...e.event.payload,attachments:l.map((c,p)=>t+p)}}:e.event,b=be();if(a(d)&&!b.some((c)=>c.seq===d))b.push({seq:d,ts:r,tabId:o,tabHost:i,...g});if(l.length){let c=C();l.forEach((h,k)=>{let m=t+k;if(!a(m)||c.some((y)=>y.seq===m))return;if(b.some((y)=>y.seq===m)){we.set(m,h.blob);return}c.push({seq:m,ts:r,tabId:o,tabHost:i,sessionId:s,blob:h.blob,payload:h.payload})});let p=c.reduce((h,k)=>h+k.payload.bytes,0);while(c.length>Ds||p>Ns){let h=c.shift();p-=h.payload.bytes,G(h.sessionId,new Set([h.seq])),xe([h.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${h.payload.name} (seq ${h.seq}); its note lands without it`)}Ro(c)}if(b.length>ln){let c=b.splice(0,b.length-ln);G(s,new Set(c.map((p)=>p.seq))),console.warn(`vitrinka: retry buffer full — dropped ${c.length} oldest events`)}}else{let l=re();if(!l.some((d)=>d.seq===t)&&!be().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),ke+=e.part.body.length;while(l.length>vo){let d=l.shift();ke-=d.body.length,G(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}xo(),oe()}function G(e,t){for(let[n,r]of Ee){if(r.sessionId!==e)continue;let o=r.seqs.size;for(let s of r.seqs)if(t.has(s))r.seqs.delete(s);let i=r.seqs.size&&r.seqs.size<o&&r.persisted?q(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)F(n,un(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){x().remove(n),Ee.delete(n);let s=n.slice(ct.length,n.lastIndexOf(".")),a=`tab.${s}`,l=q(a,null);if(l?.departed&&l.recoverable&&!x().keys?.().some((d)=>d.startsWith(`${ct}${s}.`)))x().remove(a)}}}function Lo(){if(Oe)return Oe;let e=x();return Oe=pn(Promise.resolve().then(async()=>{for(let t of I)await e.withLock("seq",()=>{if(!I.has(t))return;if(t.persisted){let o=q(t.key,null);if(!o){it(t),xe(lt(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(Ps(e.getString(st)??null),S()?.sessionId!==t.draft.sessionId){it(t),xe(lt(t.draft),!0);return}let n=t.seq??Co(ht(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):Us(n,t.draft);if(t.persisted)e.set(t.key,un(t.draft,n,r));Ee.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),_o(t.draft,n,r),it(t)})}).catch((t)=>{throw Se(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),oe(),Pe(),t})).finally(()=>{Oe=null}),Oe}function Do(e,t){let n=S(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(Po(),x().withLock){let o=`${ct}${Io}.${++zs}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&F(o,i),bytes:Re(i)};Ao(s),Lo(),t?.then((a)=>{if(a)Vs(s)})}else{let o=Co(ht(e));if(o)_o(e,o.seq);else xe(lt(e),!0)}return!0}function Vs(e){let t=Ee.get(e.key);if(t)t.persisted=F(e.key,un(e.draft,e.seq,t.seqs));else if(I.has(e))e.persisted=F(e.key,JSON.stringify({draft:e.draft}))}var yo=new Set;function pn(e){return yo.add(e),e.catch(()=>{return}).finally(()=>{yo.delete(e)})}function J(e){return S()?.sessionId!==e.sessionId}function He(e,t,n,r=[]){if(Ae.following)return null;let o=S();if(!o)return lo(e,t,n);if(o.dead||o.paused&&e!=="note")return null;let i=new Date().toISOString(),{tabId:s,tabHost:a}=n,l=r.length?Hs(o.sessionId,r):null;return Do({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),fn(),i}function No(e){be().push(e),fn(),xo(),oe()}var Ys=Date.now();function fn(){Ys=Date.now()}function hn(e,t=Ss,n=Es){let r=[],o=[],i=[],s=2,a=()=>{if(!i.length)return;r.push({count:i.length,body:`[${i.join(",")}]`}),i=[],s=2};for(let l of e){let d=JSON.stringify(l),g=Re(d)+1;if(g>n){o.push(g);continue}if(g>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+g>t)a();i.push(d),s+=g}return a(),{parts:r,dropped:o}}function Oo(e,t){if(!e.length)return 0;let n=S();if(!n||n.paused||n.dead||Ae.following)return 0;let{parts:r,dropped:o}=hn(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),He("note",{text:`⚠ rrweb event dropped (${(l/1048576).toFixed(1)} MiB > chunk cap) — replay may be incomplete from here`},t);let i=new Date().toISOString(),{tabId:s,tabHost:a}=t;for(let l of r)if(!Do({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return fn(),r.length}async function Xs(e=5){let t=re();if(t.length===0)return!0;let n=S(),r=0,o=new Set;for(let i of t){if(r>=e)break;if(r++,!n||i.sessionId!==n.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${i.seq} from ended session ${i.sessionId}`),o.add(i.seq);continue}try{let s=await Yr(n.sessionId,i.seq,i.body);if(J(n))return re().length===0;No({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),dn(),o.add(i.seq)}catch(s){if(J(n))return re().length===0;if(s instanceof T&&j(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),G(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}Se(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Ls(re().filter((i)=>!o.has(i.seq)));return re().length===0}async function Js(e=4){let t=C();if(t.length===0)return!0;let n=S(),r=0,o=new Set,i=[];for(let s of t){if(r>=e)break;if(r++,!n||s.sessionId!==n.sessionId){console.warn(`vitrinka: dropping attachment seq ${s.seq} from ended session ${s.sessionId}`),o.add(s.seq),i.push(s.blob);continue}let a=ve.get(s.blob)??null;if(!a){try{a=await rt().get(s.blob),ot.delete(s.blob)}catch(l){if(J(n))return C().length===0;let d=(ot.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${fo})`,l),d<fo){ot.set(s.blob,d),Se(l);break}}if(J(n))return C().length===0}if(!a){console.warn(`vitrinka: attachment seq ${s.seq} (${s.payload.name}) lost its bytes — its note lands without it`),G(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await Xr(n.sessionId,s.seq,a);if(J(n))return C().length===0;No({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),ve.delete(s.blob),we.set(s.seq,s.blob),dn(),o.add(s.seq)}catch(l){if(J(n))return C().length===0;if(l instanceof T&&j(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),G(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}Se(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)ft(),Ro(C().filter((s)=>!o.has(s.seq)));return xe(i,!0),C().length===0}var sn=null;function oe(){if(sn)return;sn=setTimeout(()=>{sn=null,Gs()},ys)}var an=!1;async function Gs(e={}){if(an)return!1;an=!0;try{return await Zs(e)}finally{an=!1}}async function Zs(e){if(S()?.dead)return!1;if(Po(!0),I.size)await Lo();if(I.size)return!1;let t=await Xs(),n=e.keepalive?C().length===0:await Js(),r=t&&n;if(!r)oe();let o=S(),i=be();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:vs;for(let c of i){if(s.length>=pt)break;let p=Re(JSON.stringify(c))+1;if(p>ws){console.warn(`vitrinka: event seq ${c.seq} (${p} bytes) exceeds the wire cap — dropped`),a.add(c.seq);continue}if(p>d){if(e.keepalive)break;if(s.length===0)s.push(c),l=p;break}if(s.length>0&&l+p>d)break;s.push(c),l+=p}if(a.size){if(G(o.sessionId,a),po(be().filter((c)=>!a.has(c.seq))),!s.length)return oe(),!1}if(!s.length)return!1;ft();try{await O("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(c){if(J(o))return!1;if(c instanceof T&&j(c.status))return Ks(`server rejected this session (${c.status})`),!1;return Se(c),Pe(),console.warn("vitrinka: flush failed, retrying",c),oe(),!1}if(J(o))return!0;dn(),go=Math.max(go,...s.map((c)=>c.seq)),Fs(s);let g=new Set(s.map((c)=>c.seq));G(o.sessionId,g);let b=be().filter((c)=>!g.has(c.seq));po(b),Pe();for(let c of g){let p=we.get(c);if(p===void 0)continue;we.delete(c),cn(p)}if(b.length)oe();return!0}function ko(){if(H)clearTimeout(H),H=null;se=[],me=[],ke=0,at=[],ve.clear(),ye.clear(),we.clear(),I.clear(),dt=ut=0,Ee.clear(),Z=!0}var Qs=8192,qe="__vitrinkaRecorderConsolePatched";function gt(e){return e.map((t)=>{if(typeof t==="string")return t;if(t instanceof Error)return t.stack??t.message;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ").slice(0,Qs)}function mt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;He("console",{level:t,text:Nr(e)},{tabId:w.tabId,tabHost:w.tabHost})}var gn="__vitrinkaRecorderConsoleUnpatch",Bo={};function Ho(){let e=globalThis;if(e[qe]!==void 0&&e[qe]!==Bo)return;e[gn]?.()}function qo(e={}){let t=globalThis;if(t[qe])return;t[qe]=Bo;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{mt(gt(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let g=console[d],b=g.bind(console),c=(...p)=>{b(...p);try{mt(gt(p),d)}catch{}};return console[d]=c,()=>{if(console[d]===c)console[d]=g}}),s=(d)=>{try{mt(gt([d.error??d.message]))}catch{}},a=(d)=>{try{mt(`unhandled rejection: ${gt([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[gn]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[qe],delete t[gn]}}var $o=65536,$e=524288,Fo=3000;var mn="full";function yn(){if(Ae.following)return null;let e=S();if(e)return!e.paused&&!e.dead?e.sessionId:null;return so()}function Fe(e){return e!==null&&yn()===e}function bt(e,t){if(typeof e==="string")return Wt(e,$o,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return Wt(e.toString(),$o,"application/x-www-form-urlencoded");return ea(e)}function ea(e){if(e==null)return;if(typeof FormData<"u"&&e instanceof FormData){let t=0;try{e.forEach(()=>t++)}catch{}return`[formdata body omitted: ${t} field(s)]`}if(typeof Blob<"u"&&e instanceof Blob)return`[blob body omitted: ${e.size} bytes${e.type?`, ${e.type}`:""}]`;if(e instanceof ArrayBuffer)return`[buffer body omitted: ${e.byteLength} bytes]`;if(ArrayBuffer.isView(e))return`[buffer body omitted: ${e.byteLength} bytes]`;if(typeof ReadableStream<"u"&&e instanceof ReadableStream)return"[stream body omitted]";return`[${typeof e} body omitted]`}function bn(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function kn(e){return typeof e==="string"||e instanceof URL?{}:e}function Ke(e){let t=typeof e.url==="string"?te(e.url):e.url;He("net",{...e,url:t},{tabId:w.tabId,tabHost:w.tabHost})}function vn(e){if(!e)return;try{let t={},n=e;if(typeof n.forEach==="function")if(Array.isArray(e)){for(let r of e)if(Array.isArray(r)&&r.length>=2)t[String(r[0])]=String(r[1])}else n.forEach((r,o)=>{t[o]=String(r)});else if(typeof e==="object")for(let[r,o]of Object.entries(e))t[r]=String(o);return Object.keys(t).length>0?t:void 0}catch{return}}function ta(e,t){let n=vn(t?.headers);if(n)return n;let r=kn(e);return vn(r.headers)}function na(e){if(!e)return;let t={};for(let n of e.split(/\r?\n/)){let r=n.indexOf(":");if(r>0)t[n.slice(0,r).trim()]=n.slice(r+1).trim()}return Object.keys(t).length>0?t:void 0}function wn(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function ra(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function oa(e,t){let n=await ia(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return bt(n,r)}async function ia(e,t){let n=ra(t);if(n!==null&&n>$e)return wn(e),`[body omitted: ${n} bytes]`;let r=e.body;if(r?.getReader){let o=r.getReader(),i=[],s=0,a=!1,l=!1,d=Date.now()+Fo;try{while(s<$e){let p=d-Date.now();if(p<=0){l=!0;break}let h,k=await Promise.race([o.read(),new Promise((f)=>{h=setTimeout(()=>f("timeout"),p)})]).finally(()=>{if(h!==void 0)clearTimeout(h)});if(k==="timeout"){l=!0;break}let{done:m,value:y}=k;if(m)break;if(y){let f=$e-s,R=y.byteLength>f?y.subarray(0,f):y;i.push(R),s+=R.byteLength}}a=s>=$e,o.cancel().catch(()=>{return})}catch{return}let g=new Uint8Array(s),b=0;for(let p of i)g.set(p,b),b+=p.byteLength;let c;try{c=new TextDecoder().decode(g)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${c}…[body read timed out after ${Fo}ms]`;return a?`${c}…[truncated at ${$e} bytes]`:c}if(n===null)return wn(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var We="__vitrinkaRecorderNetPatched",xn="__vitrinkaRecorderNetUnpatch",Ko={};function Wo(){let e=globalThis;if(e[We]!==void 0&&e[We]!==Ko)return;e[xn]?.()}function zo(e={}){let t=globalThis;if(t[We])return;t[We]=Ko,mn=e.detail??"full";let n=[];t[xn]=()=>{for(let c of n.splice(0))c();delete t[We],delete t[xn]};let r=globalThis.fetch,o=async(c,p)=>{let h=typeof c==="string"?c:c instanceof URL?c.href:c.url,k=yn();if(Kt(h)||k===null)return r(c,p);let m=p?.method??("method"in kn(c)?kn(c).method:"GET"),y=Date.now();try{let f=await r(c,p),R=Date.now()-y;if(mn==="meta"){if(Fe(k))Ke({method:m,url:h,status:f.status,ms:R,via:"fetch"});return f}let D;try{D=f.clone()}catch{D=void 0}let{headers:Te,status:Ve}=f;return pn((async()=>{if(!Fe(k)){if(D)wn(D);return}let Ye=D?await oa(D,Te):void 0;if(!Fe(k))return;let Me=ta(c,p);Ke({method:m,url:h,status:Ve,ms:R,reqHeaders:Le(Me),resHeaders:Le(vn(Te)),reqBody:bt(p?.body,bn(Me)),resBody:Ye,via:"fetch"})})()),f}catch(f){if(Fe(k))Ke({method:m,url:h,error:String(f),ms:Date.now()-y,via:"fetch"});throw f}};globalThis.fetch=o,n.push(()=>{if(globalThis.fetch===o)globalThis.fetch=r});let i=globalThis.XMLHttpRequest;if(!i?.prototype)return;let s=i.prototype.open,a=i.prototype.send,l=i.prototype.setRequestHeader;n.push(()=>{let c=i.prototype;if(c.open===d)c.open=s;if(c.send===b)c.send=a;if(c.setRequestHeader===g)c.setRequestHeader=l});let d=i.prototype.open=function(...c){return this.__vt={method:c[0],url:String(c[1])},s.apply(this,c)},g=i.prototype.setRequestHeader=function(c,p){let h=this.__vt;if(h)(h.reqHeaders??={})[c]=p;return l?.call(this,c,p)},b=i.prototype.send=function(c){let p=this.__vt,h=yn();if(p&&!Kt(p.url)&&h!==null){let k=Date.now();this.addEventListener("loadend",()=>{if(!Fe(h))return;if(mn==="meta"){Ke({method:p.method,url:p.url,status:this.status,ms:Date.now()-k,via:"xhr"});return}let m;try{m=na(this.getAllResponseHeaders())}catch{m=void 0}let y;try{y=this.responseType===""||this.responseType==="text"?bt(this.responseText,bn(m)):void 0}catch{y=void 0}Ke({method:p.method,url:p.url,status:this.status,ms:Date.now()-k,reqHeaders:Le(p.reqHeaders),resHeaders:Le(m),reqBody:bt(c,bn(p.reqHeaders)),resBody:y,via:"xhr"})})}return a.call(this,c)}}var sa=2000,aa=300000,je=null,Ue=null,ze=[],yt=null;function jo(){if(!ze.length)return;let e=ze;ze=[],Oo(e,{tabId:w.tabId,tabHost:w.tabHost})}function kt(){return Ue}function Uo(e,t,n={}){if(je)return;let r=Br(),o=n.unmaskSelector;try{je=e({emit:t==="flight"?(s)=>ao(Ut(s)):(s)=>{ze.push(Ut(s))},checkoutEveryNms:t==="flight"?no().checkoutMs:aa,inlineImages:!1,collectFonts:!0,maskAllInputs:r.maskAllInputs,...r.maskTextSelector?{maskTextSelector:r.maskTextSelector}:{},...r.maskTextSelector&&o?{maskTextFn:(s,a)=>{try{if(a?.closest(o))return s}catch{}return s.replace(/\S/g,"*")}}:{},blockSelector:`[${De}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(Ue=e,t==="flight")Qt(Sn);if(t==="session")yt=setInterval(jo,sa)}function Vo(){if(yt)clearInterval(yt);yt=null,jo();try{je?.()}catch{}je=null,Ue=null,Qt(null),ze=[]}function Sn(){if(!je||!Ue)return;try{Ue.takeFullSnapshot?.(!0)}catch{}}var Jo="vitrinka.capture",A="windows",P="chunks";function ae(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function En(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function Yo(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function Xo(e){if(typeof e!=="object"||e===null)return!1;let t=e;return typeof t.id==="string"&&typeof t.tab==="string"&&typeof t.startMs==="number"&&typeof t.lastMs==="number"}function Go(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(Jo,1);r.onupgradeneeded=()=>{r.result.createObjectStore(A,{keyPath:"id"}),r.result.createObjectStore(P)},r.onerror=()=>n(r.error??Error("vitrinka: capture store did not open")),r.onblocked=()=>n(Error("vitrinka: capture store is blocked by another tab")),r.onsuccess=()=>t(r.result)}).then((t)=>{t.onversionchange=()=>t.close();let n=(o,i)=>{o.objectStore(A).delete(i),o.objectStore(P).delete(Yo(i))};return{async putWindow(o){let i=t.transaction(A,"readwrite");i.objectStore(A).put(o),await ae(i)},async putChunk(o,i,s,a){let l=t.transaction(P,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(P).put(d,[o,i]),await ae(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([A,P],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(P).put(d,[o.id,i]),l.objectStore(A).put(o)}catch(g){throw l.abort(),g}await ae(l)},async dropWindow(o){let i=t.transaction([A,P],"readwrite");n(i,o),await ae(i)},async clear(o){let i=t.transaction([A,P],"readwrite"),s=await En(i.objectStore(A).getAll());for(let a of s)if(Xo(a)&&a.tab===o)n(i,a.id);await ae(i)},async sweep(o,i,s,a){let l=t.transaction([A,P],"readwrite"),d=(await En(l.objectStore(A).getAll())).filter(Xo),g=[],b=new Map;for(let c of d)b.set(c.tab,[...b.get(c.tab)??[],c]);for(let[c,p]of b){let h=p.filter((m)=>m.kind!=="lanes").sort((m,y)=>m.startMs-y.startMs),k=(m)=>m.kind==="lanes"?m.lastMs:Zt(m,h[h.indexOf(m)+1]);for(let m of p.sort((y,f)=>y.startMs-f.startMs))if(k(m)<=o-i||c===s&&m.scope!==a)n(l,m.id);else if(c===s)g.push(m)}return await ae(l),g},async read(o){let i=t.transaction(P,"readonly"),s=await En(i.objectStore(P).getAll(Yo(o)));await ae(i);let a=[],l=[];for(let d of s)a.push(...JSON.parse(d.events)),l.push(...d.lanes);return{events:a,lanes:l}},close:()=>t.close()}})}function Zo(e=globalThis.indexedDB){try{e?.deleteDatabase(Jo)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function Rn(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}}function Tn(e,t){return`${t.y<e.y?"n":"s"}${t.x<e.x?"w":"e"}`}function Mn(e,t){let n=e.x,r=e.x+e.w,o=e.y,i=e.y+e.h,s={x:t.endsWith("w")?n:r,y:t.startsWith("n")?o:i};return{tail:{x:t.endsWith("w")?r:n,y:t.startsWith("n")?i:o},tip:s}}function Qo(e,t,n){if(e==="arrow")return Math.hypot(n.x-t.x,n.y-t.y)>=16;return Math.abs(n.x-t.x)>=8&&Math.abs(n.y-t.y)>=8}function ei(e){return e.map((t,n)=>({...t,n:n+1}))}function ti(e){return e.map((t)=>({n:t.n,shape:t.shape,rect:{x:Math.round(t.rect.x),y:Math.round(t.rect.y),w:Math.round(t.rect.w),h:Math.round(t.rect.h)},...t.note.trim()?{note:t.note.trim()}:{},...t.shape==="arrow"&&t.head?{head:t.head}:{}}))}var la=2,ca=3,da=0,ua=5,Cn=2,pa=3,fa=2000000000,ha="data-vitrinka-hidden",ga="#1b1b1f";function ma(e,t){let n=`position:fixed;left:${Math.round(e.x)}px;top:${Math.round(e.y)}px;width:${Math.round(e.w)}px;height:${Math.round(e.h)}px;background:${ga};z-index:2147483647;pointer-events:none;`;return{type:Cn,id:fa+t,tagName:"div",attributes:{[ha]:"",style:n},childNodes:[]}}function In(e,t,n,r){let o={...e};if(e.type===pa&&t.has(e.id))o.textContent="";if(e.attributes&&t.has(e.id)&&"value"in e.attributes)o.attributes={...e.attributes,value:""};if(e.childNodes){if(o.childNodes=e.childNodes.map((i)=>In(i,t,n,r)),!r.done&&e.type===Cn&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function ba(e,t){(e.childNodes?.find((r)=>r.type===Cn)??e).childNodes?.push(...t)}function ya(e,t){return In(e,t,[],{done:!0})}function ni(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map(ma);return e.map((o)=>{let i=o.data;if(o.type===la&&i.node){let s={done:!1},a=In(i.node,n,r,s);if(!s.done)ba(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==ca||!n.size)return o;if(i.source===da){let s=o.data,a={...s,...s.texts?{texts:s.texts.map((l)=>n.has(l.id)?{...l,value:""}:l)}:{},...s.adds?{adds:s.adds.map((l)=>({...l,node:ya(l.node,n)}))}:{},...s.attributes?{attributes:s.attributes.map((l)=>n.has(l.id)&&("value"in l.attributes)?{...l,attributes:{...l.attributes,value:""}}:l)}:{}};return{...o,data:a}}if(i.source===ua){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function ka(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function va(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function An(e,t,n=document){let r=new Set;if(!e.length||!t||!n.body)return r;let o=(l)=>l.width>0&&l.height>0&&e.some((d)=>ka(va(l),d)),i=(l)=>{let d=t.getId(l);if(d>0)r.add(d)},s=n.createTreeWalker(n.body,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),a=n.createRange();for(let l=s.nextNode();l;l=s.nextNode())if(l.nodeType===Node.TEXT_NODE){if(!l.textContent?.trim())continue;if(a.selectNodeContents(l),o(a.getBoundingClientRect()))i(l)}else if(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement||l instanceof HTMLSelectElement){if(o(l.getBoundingClientRect()))i(l)}return a.detach(),r}var wa=["errors","interactions","full","console","network"];var vt={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function St(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function wt(e,t,n){return Math.min(n,Math.max(t,e))}function xa(e){if(!Array.isArray(e))return null;return wa.filter((t)=>e.includes(t))}function ri(e,t){if(typeof e!=="object"||e===null)return St(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":vt.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?wt(Math.round(n.windowSec),10,3600):vt.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?wt(Math.round(n.maxBytes),262144,67108864):vt.maxBytes,classes:xa(n.classes)??vt.classes}}function xt(e){let t=e.includes("full");return{replay:t||e.includes("interactions"),errors:t||e.includes("errors"),console:t||e.includes("console"),network:t||e.includes("network")}}function Sa(e){let t=[];if(e.errors)t.push("errors");if(e.replay)t.push("interactions");if(e.console)t.push("console");if(e.network)t.push("network");return t}function oi(e,t){if(!t)return e;let n=typeof t.windowSec==="number"&&t.windowSec>0?Math.min(e.windowSec,t.windowSec):e.windowSec,r=typeof t.maxBytes==="number"&&t.maxBytes>0?Math.min(e.maxBytes,t.maxBytes):e.maxBytes,o=e.classes;if(t.classes){let i=xt(e.classes),s=xt(t.classes);o=Sa({replay:i.replay&&s.replay,errors:i.errors&&s.errors,console:i.console&&s.console,network:i.network&&s.network})}return{storage:t.storage==="memory"?"memory":e.storage,windowSec:wt(n,10,3600),maxBytes:wt(r,262144,67108864),classes:o}}function ii(e){return e==="balanced"||e==="full"?e:"strict"}function si(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var ai="[data-vitrinka-unmask]";var Ea=3670016,li=4194240,Ra=2000,ci=500,Ta=60000,Ma=/[A-Za-z0-9_-]{20,}/g;function K(e,t=""){return typeof e==="string"?e:t}function Ca(e){let t=K(e),n;try{n=new URL(t,globalThis.location?.href??"http://localhost").pathname}catch{n=t.split(/[?#]/)[0]??""}return n.replace(Ma,"•••").slice(0,300)}var Ia=4;function Aa(e,t){let n=[],r=!1,o=[],i=!1,s=()=>{if(i)r=!0;else n.push(...o);o=[],i=!1};for(let a of e){if(a.type===Ia&&o.length)s();if(!i&&Re(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}function Pa(e){return(t,n)=>{if(t==="console"){let r=K(n?.level,"error");if(r==="error"?!(e.errors||e.console):!e.console)return null;return{level:r,text:K(n?.text).slice(0,Ra)}}if(t==="net"){let r=typeof n?.status==="number"?n.status:0,o=r===0||r>=400||n?.error!==void 0;if(!(e.network||e.errors&&o))return null;return{method:K(n?.method,"GET").toUpperCase(),path:Ca(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}async function _a(e){try{let t=await O("GET","/api/v1/report-config",void 0,{target:e}),n=typeof t.flightRecorder==="boolean"?t.flightRecorder:void 0;return{project:K(t.project),profile:t.captureProfile==null?St(n):ri(t.captureProfile,n),masking:ii(t.profile),reachable:!0}}catch(t){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",t),{project:"",profile:St(),masking:"strict",reachable:!1}}}function di(e){let t=e?.mirror;if(typeof t!=="object"||t===null)return null;let n=t.getId;return typeof n==="function"?{getId:(r)=>Number(n.call(t,r))}:null}class ui{opts;ready;store=null;stopped=!1;claim=null;config=null;listeners=new Set;capturing=!1;offs=[];capture=[];constructor(e){this.opts=e;this.ready=this.start()}async start(){let{opts:e}=this;this.offs.push(Pr(e.base));let t=await _a({url:e.base,key:e.key}),n=oi(t.profile,e.capture),r=xt(n.classes),o={project:t.project,profile:n,lanes:r,masking:t.masking,reachable:t.reachable,capturing:!1};if(this.stopped)return o;if(this.config=o,this.claim=Cr("report",()=>this.standDown()),!this.claim)return console.warn("vitrinka: the recorder runs this page’s capture — Report a problem sends without one"),o;this.capturing=!0,o.capturing=!0,Mr(Tr(),globalThis.location?.host??""),w.pathname=globalThis.location?.pathname??"/",Dr(si(o.masking)),zt(e.sanitizeUrl),this.capture.push(()=>zt(null));let i=n.windowSec*1000,s=[e.base,t.project,o.masking,n.classes.join(",")].join("|"),a=[],l=[];if(n.storage==="browser")try{this.store=await Go();let d=await this.store.sweep(Date.now(),i,w.tabId,s);a=d;let g=this.store;l=(await Promise.all(d.filter((c)=>c.kind==="lanes").map((c)=>g.read(c.id)))).flatMap((c)=>c.lanes).sort((c,p)=>Date.parse(c.ts)-Date.parse(p.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else Zo();if(!this.capturing)return this.store?.close(),this.store=null,o;if(eo({windowMs:i,checkoutMs:Math.min(Ta,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:Gt,keepLane:Pa(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(to),this.store&&typeof window<"u"){let d=()=>tt();this.capture.push(N(window,"pagehide",d),N(document,"visibilitychange",d))}if(r.errors||r.console)qo({levels:r.console?["warn","info","log"]:[]}),this.capture.push(Ho);if(r.errors||r.network)zo({detail:"meta"}),this.capture.push(Wo);if(r.replay){let d=await e.loadRecord(e.base).catch((g)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",g),null));if(d&&this.capturing)Uo(d,"flight",{unmaskSelector:ai}),this.capture.push(Vo)}return o}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}standDown(){if(!this.capturing)return;if(this.capturing=!1,this.config)this.config.capturing=!1;for(let t of this.capture.splice(0).reverse())t();let e=this.store;if(this.store=null,e)oo().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};w.pathname=globalThis.location?.pathname??w.pathname;let e=nn();if(e&&kt()&&!co(e))Sn(),e=nn();let t=this.store,n=e?.windows.filter((o)=>o.stored).map((o)=>o.id)??[],r=t&&n.length?Promise.all(n.map(async(o)=>[o,await t.read(o)])).then((o)=>new Map(o)):Promise.resolve(new Map);return r.catch(()=>{return}),{clip:e,stored:r}}hiddenIdsAt(e){if(!this.capturing)return null;let t=di(kt());return t?An([e],t):null}async build(e,t,n=new Set){let r=t.filter((f)=>f.shape==="hide").map((f)=>f.rect),o=di(kt()),i=r.length>0&&!o;if(i)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let s=new Set(n);if(r.length&&o)for(let f of An(r,o))s.add(f);let a=[],l=e.clip?.truncated??!1,d=await e.stored.catch((f)=>(console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",f),null));for(let f of e.clip?.windows??[]){if(!f.stored){a.push(...f.events);continue}let R=d?.get(f.id);if(!R?.events.length)l=!0;else a.push(...R.events)}let g=e.clip?.lanes??[],b=i?{events:[],dropped:!1}:Aa(ni(a,r,s),li);if(b.dropped)l=!0;let{parts:c,dropped:p}=hn(b.events,Ea,li),h=[],k=0;for(let f of c){k+=f.count;let R=b.events[k-1]?.timestamp??Date.now();h.push({seq:h.length+1,ts:new Date(R).toISOString(),count:f.count,body:f.body})}let m=g.filter((f)=>f.kind==="console").slice(-ci).map((f)=>({level:K(f.payload?.level,"error"),ts:f.ts,text:K(f.payload?.text)})),y=g.filter((f)=>f.kind==="net").slice(-ci).map((f)=>({method:K(f.payload?.method,"GET"),path:K(f.payload?.path),status:typeof f.payload?.status==="number"?f.payload.status:0,ms:typeof f.payload?.ms==="number"?f.payload.ms:0}));return{chunks:h,truncated:l||p.length>0,console:m,network:y}}clear(){if(this.capturing)ro()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),Ir(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var L=null;function pi(e){if(L){let t=L.engine.opts;if(!(t.base===e.base&&t.key===e.key&&t.sanitizeUrl===e.sanitizeUrl&&JSON.stringify(t.capture??{})===JSON.stringify(e.capture??{})))return console.warn("vitrinka: one capture engine per page — this widget reports without a capture (another widget’s key, base, capture or sanitizeUrl owns it)"),null;return L.refs++,L.engine}return L={engine:new ui(e),refs:1},L.engine}function fi(e){if(!e||!L||L.engine!==e)return;if(--L.refs>0)return;L=null,e.stop()}var La=/^[\w-]+\.[\w-]+\.[\w-]+$/;function Et(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!La.test(r))return console.warn("vitrinka: identify({token}) needs the compact JWS your server signed — reporting anonymously"),null;return{token:r}}let t=typeof e.email==="string"?e.email.trim().slice(0,254):"";if(!t.includes("@"))return console.warn("vitrinka: identify({email}) needs an email address — reporting anonymously"),null;let n=typeof e.name==="string"?e.name.trim().slice(0,200):"";return n?{email:t,name:n}:{email:t}}var hi=null,Pn=new Set;function Da(e){hi=Et(e);for(let t of Pn)t()}function gi(){return hi}function mi(e){return Pn.add(e),()=>Pn.delete(e)}var Na=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),Rt="report.keybind";function bi(e){if(Na.has(e.key))return{kind:"wait"};if(e.key==="Escape"&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey)return{kind:"cancel"};if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return{kind:"bare"};return{kind:"bind",bind:{code:e.code,alt:e.altKey,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey}}}function yi(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var Oa={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function Ba(e){let t=/^Key([A-Z])$/.exec(e);if(t)return t[1];let n=/^(?:Digit|Numpad)(\d)$/.exec(e);if(n)return n[1];return Oa[e]??e}function Ha(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function Tt(e,t=Ha()){let n=Ba(e.code);if(t)return`${e.ctrl?"⌃":""}${e.alt?"⌥":""}${e.shift?"⇧":""}${e.meta?"⌘":""}${n}`;return[e.ctrl&&"Ctrl",e.alt&&"Alt",e.shift&&"Shift",e.meta&&"Meta",n].filter(Boolean).join("+")}function ki(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;let n=t;if(typeof n.code!=="string"||!n.code)return null;let r={code:n.code,alt:n.alt===!0,ctrl:n.ctrl===!0,meta:n.meta===!0,shift:n.shift===!0};return r.alt||r.ctrl||r.meta?r:null}catch{return null}}function vi(){return ki(z().getString(Rt))}function _n(e){let t=z();if(e)t.set(Rt,JSON.stringify(e));else t.remove(Rt)}function wi(e){let t=z();return t.watch?t.watch(Rt,(n)=>e(ki(n))):()=>{return}}var xi=`
|
|
10
|
+
:host { all: initial; }
|
|
11
|
+
.vr {
|
|
12
|
+
--ink: #f2f1ef;
|
|
13
|
+
--dim: rgba(242, 241, 239, .62);
|
|
14
|
+
--faint: rgba(242, 241, 239, .14);
|
|
15
|
+
--bg: #1a191d;
|
|
16
|
+
--bg-deep: #121115;
|
|
17
|
+
--accent: #dc2f4c;
|
|
18
|
+
--accent-soft: rgba(220, 47, 76, .28);
|
|
19
|
+
font: 400 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
20
|
+
color: var(--ink);
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
letter-spacing: normal;
|
|
23
|
+
text-align: left;
|
|
24
|
+
}
|
|
25
|
+
.vr *, .vr *::before, .vr *::after { box-sizing: border-box; }
|
|
26
|
+
.vr [hidden] { display: none !important; }
|
|
27
|
+
button { font: inherit; color: inherit; cursor: pointer; }
|
|
28
|
+
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
|
|
29
|
+
outline: 2px solid #fff; outline-offset: 2px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* -- the floating button -------------------------------------------------- */
|
|
33
|
+
.fab {
|
|
34
|
+
position: fixed; right: 24px; bottom: 24px;
|
|
35
|
+
display: inline-flex; align-items: center; gap: 12px;
|
|
36
|
+
padding: 15px 22px; border: 0; border-radius: 999px;
|
|
37
|
+
background: #131216; color: #fff;
|
|
38
|
+
font-size: 17px; font-weight: 600; letter-spacing: -.005em;
|
|
39
|
+
box-shadow: 0 12px 32px rgba(0, 0, 0, .28), 0 0 0 1px rgba(255, 255, 255, .08) inset;
|
|
40
|
+
pointer-events: auto;
|
|
41
|
+
transition: transform .14s ease, box-shadow .14s ease;
|
|
42
|
+
}
|
|
43
|
+
.fab:hover { transform: translateY(-1px); box-shadow: 0 16px 36px rgba(0, 0, 0, .32), 0 0 0 1px rgba(255, 255, 255, .12) inset; }
|
|
44
|
+
.fab:active { transform: translateY(0); }
|
|
45
|
+
kbd {
|
|
46
|
+
font: 500 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
47
|
+
padding: 4px 7px; border-radius: 7px;
|
|
48
|
+
border: 1px solid rgba(255, 255, 255, .26); color: rgba(255, 255, 255, .78);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* -- the card --------------------------------------------------------------- */
|
|
52
|
+
.card {
|
|
53
|
+
position: fixed; right: 24px; bottom: 96px;
|
|
54
|
+
width: min(420px, calc(100vw - 32px));
|
|
55
|
+
max-height: calc(100vh - 120px); overflow: auto;
|
|
56
|
+
background: var(--bg); color: var(--ink);
|
|
57
|
+
border: 1px solid rgba(255, 255, 255, .08); border-radius: 16px;
|
|
58
|
+
box-shadow: 0 28px 70px rgba(0, 0, 0, .38), 0 2px 8px rgba(0, 0, 0, .2);
|
|
59
|
+
pointer-events: auto;
|
|
60
|
+
animation: vr-in .16s ease-out;
|
|
61
|
+
}
|
|
62
|
+
.vr.nobutton .card { bottom: 24px; }
|
|
63
|
+
@keyframes vr-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
|
|
64
|
+
.head {
|
|
65
|
+
display: flex; align-items: center; gap: 4px;
|
|
66
|
+
padding: 16px 14px 16px 20px; border-bottom: 1px solid rgba(255, 255, 255, .07);
|
|
67
|
+
}
|
|
68
|
+
.head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
|
|
69
|
+
.icon {
|
|
70
|
+
display: inline-grid; place-items: center; width: 32px; height: 32px;
|
|
71
|
+
border: 0; border-radius: 8px; background: transparent; color: var(--dim);
|
|
72
|
+
}
|
|
73
|
+
.icon:hover { background: var(--faint); color: var(--ink); }
|
|
74
|
+
.icon svg { width: 16px; height: 16px; }
|
|
75
|
+
.pane { padding: 18px 20px 20px; }
|
|
76
|
+
.prompt { display: block; margin: 0 0 8px; font-weight: 600; font-size: 14px; }
|
|
77
|
+
.desc {
|
|
78
|
+
display: block; width: 100%; min-height: 88px; resize: vertical;
|
|
79
|
+
padding: 12px 14px; border-radius: 10px;
|
|
80
|
+
border: 1px solid rgba(255, 255, 255, .2); background: var(--bg-deep); color: var(--ink);
|
|
81
|
+
font-family: inherit; font-size: 15px; font-weight: 400; line-height: 1.45;
|
|
82
|
+
}
|
|
83
|
+
.desc::placeholder { color: rgba(242, 241, 239, .38); }
|
|
84
|
+
.desc:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
|
|
85
|
+
.attached { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; color: var(--dim); font-size: 13px; }
|
|
86
|
+
.attached svg { width: 14px; height: 14px; flex: none; }
|
|
87
|
+
.link {
|
|
88
|
+
display: inline-flex; align-items: center; gap: 3px; padding: 0; border: 0; background: none;
|
|
89
|
+
color: rgba(242, 241, 239, .86); font-weight: 600; font-size: 13px;
|
|
90
|
+
}
|
|
91
|
+
.link:hover { color: #fff; text-decoration: underline; }
|
|
92
|
+
.link svg { width: 12px; height: 12px; transition: transform .14s ease; }
|
|
93
|
+
.link[aria-expanded="true"] svg { transform: rotate(180deg); }
|
|
94
|
+
.included { margin: 10px 0 0; padding: 10px 12px 10px 28px; border-radius: 10px; background: var(--bg-deep); color: var(--dim); font-size: 13px; }
|
|
95
|
+
.included li { margin: 2px 0; }
|
|
96
|
+
.marked { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--dim); }
|
|
97
|
+
.chip {
|
|
98
|
+
display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
|
|
99
|
+
border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
|
|
100
|
+
}
|
|
101
|
+
.chip.hide { background: #3a3940; }
|
|
102
|
+
.notify { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink); cursor: pointer; }
|
|
103
|
+
.notify input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
|
|
104
|
+
.error { margin: 12px 0 0; color: #ff9aa9; font-size: 13px; }
|
|
105
|
+
.actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
|
|
106
|
+
.where {
|
|
107
|
+
display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 9px;
|
|
108
|
+
border: 1px solid rgba(255, 255, 255, .2); background: transparent; color: var(--ink);
|
|
109
|
+
font-size: 13px; font-weight: 600;
|
|
110
|
+
}
|
|
111
|
+
.where:hover:not(:disabled) { background: var(--faint); }
|
|
112
|
+
.where svg { width: 14px; height: 14px; }
|
|
113
|
+
.where:disabled { opacity: .45; cursor: default; }
|
|
114
|
+
.send {
|
|
115
|
+
padding: 10px 22px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
|
|
116
|
+
font-size: 15px; font-weight: 650;
|
|
117
|
+
}
|
|
118
|
+
.send:hover:not(:disabled) { background: #e43a57; }
|
|
119
|
+
.send:disabled { opacity: .45; cursor: default; }
|
|
120
|
+
|
|
121
|
+
/* -- settings --------------------------------------------------------------- */
|
|
122
|
+
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
123
|
+
.row .label { font-weight: 600; }
|
|
124
|
+
.bind {
|
|
125
|
+
min-width: 120px; padding: 8px 12px; border-radius: 9px; text-align: center;
|
|
126
|
+
border: 1px solid rgba(255, 255, 255, .2); background: var(--bg-deep);
|
|
127
|
+
font: 500 13px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
128
|
+
}
|
|
129
|
+
.bind[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--dim); }
|
|
130
|
+
.hint, .reason { margin: 10px 0 0; color: var(--dim); font-size: 13px; }
|
|
131
|
+
.reason { color: #ffc1ca; }
|
|
132
|
+
.settings-foot { display: flex; justify-content: space-between; margin-top: 16px; }
|
|
133
|
+
|
|
134
|
+
/* -- sent ------------------------------------------------------------------- */
|
|
135
|
+
.sent-head { display: flex; align-items: center; gap: 10px; }
|
|
136
|
+
.sent-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
|
|
137
|
+
.sent-head svg { width: 22px; height: 22px; color: #4ade80; flex: none; }
|
|
138
|
+
.sent-body { margin: 8px 0 0 32px; color: var(--dim); }
|
|
139
|
+
.sent-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 0 32px; }
|
|
140
|
+
.see {
|
|
141
|
+
display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 9px;
|
|
142
|
+
background: #fff; color: #131216; font-weight: 650; font-size: 13px; text-decoration: none;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* -- marking: the frozen page ---------------------------------------------- */
|
|
146
|
+
.mark {
|
|
147
|
+
position: fixed; inset: 0; pointer-events: auto;
|
|
148
|
+
background: rgba(14, 13, 16, .16); cursor: crosshair;
|
|
149
|
+
touch-action: none; user-select: none; -webkit-user-select: none;
|
|
150
|
+
}
|
|
151
|
+
.ink { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
|
|
152
|
+
.ink .stroke { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
|
|
153
|
+
.ink .veil { fill: #1b1b1f; }
|
|
154
|
+
.ink .veil-label { fill: rgba(255, 255, 255, .7); font: 600 12px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
155
|
+
.ink .draft { opacity: .85; }
|
|
156
|
+
.pin { position: absolute; display: flex; align-items: center; gap: 6px; cursor: default; }
|
|
157
|
+
.pin .num {
|
|
158
|
+
display: grid; place-items: center; width: 24px; height: 24px; border-radius: 12px;
|
|
159
|
+
background: var(--accent); color: #fff; font-size: 12px; font-weight: 750;
|
|
160
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 0 0 2px #fff;
|
|
161
|
+
}
|
|
162
|
+
.pin .note {
|
|
163
|
+
width: 220px; padding: 6px 10px; border-radius: 9px;
|
|
164
|
+
border: 1px solid rgba(255, 255, 255, .16); background: #151417; color: #fff;
|
|
165
|
+
font-family: inherit; font-size: 13px; font-weight: 400; line-height: 1.3;
|
|
166
|
+
box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
|
|
167
|
+
}
|
|
168
|
+
.pin .note::placeholder { color: rgba(255, 255, 255, .45); }
|
|
169
|
+
.pin .note:focus { outline: none; border-color: var(--accent); }
|
|
170
|
+
.pin .rm {
|
|
171
|
+
display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 12px;
|
|
172
|
+
background: #151417; color: rgba(255, 255, 255, .7); box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
|
|
173
|
+
}
|
|
174
|
+
.pin .rm:hover { color: #fff; }
|
|
175
|
+
.pin .rm svg { width: 12px; height: 12px; }
|
|
176
|
+
.toolbar {
|
|
177
|
+
position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
|
|
178
|
+
display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 15px;
|
|
179
|
+
background: #151417; box-shadow: 0 16px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .08) inset;
|
|
180
|
+
cursor: default;
|
|
181
|
+
}
|
|
182
|
+
.toolbar button {
|
|
183
|
+
padding: 9px 15px; border: 0; border-radius: 10px; background: transparent; color: #f2f1ef;
|
|
184
|
+
font-size: 15px; font-weight: 600;
|
|
185
|
+
}
|
|
186
|
+
.toolbar button:hover { background: rgba(255, 255, 255, .08); }
|
|
187
|
+
.toolbar button[aria-pressed="true"] { background: #e6455f; color: #fff; }
|
|
188
|
+
.toolbar .sep { width: 1px; height: 22px; margin: 0 4px; background: rgba(255, 255, 255, .14); }
|
|
189
|
+
.toolbar .done { background: var(--accent); color: #fff; }
|
|
190
|
+
.toolbar .done:hover { background: #e43a57; }
|
|
191
|
+
.toolbar button:disabled { opacity: .4; cursor: default; background: transparent; }
|
|
192
|
+
|
|
193
|
+
/* -- the coach card (D21): stays beside the pointer until mark 1 exists --- */
|
|
194
|
+
.coach {
|
|
195
|
+
position: fixed; width: 300px; padding: 14px 16px 15px;
|
|
196
|
+
background: #151417; color: #f2f1ef; border-radius: 14px;
|
|
197
|
+
box-shadow: 0 18px 44px rgba(0, 0, 0, .38), 0 0 0 1px rgba(255, 255, 255, .1) inset;
|
|
198
|
+
pointer-events: none;
|
|
199
|
+
transition: opacity .12s ease;
|
|
200
|
+
}
|
|
201
|
+
.coach.pressing { opacity: .55; }
|
|
202
|
+
.coach svg { display: block; width: 100%; height: 64px; border-radius: 9px; background: #222126; }
|
|
203
|
+
.coach p { margin: 11px 0 0; font-size: 15px; line-height: 1.4; }
|
|
204
|
+
.coach p + p { margin-top: 2px; color: rgba(242, 241, 239, .66); font-size: 13px; }
|
|
205
|
+
.coach p.keys { margin-top: 8px; font-size: 12px; color: rgba(242, 241, 239, .5); }
|
|
206
|
+
.mark:focus { outline: none; }
|
|
207
|
+
.mark:focus-visible { outline: 3px solid rgba(230, 69, 95, .65); outline-offset: -3px; }
|
|
208
|
+
.coach .bar { fill: #5b5a61; }
|
|
209
|
+
.coach .loop { fill: none; stroke: #e6455f; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 200; stroke-dashoffset: 200; animation: vr-draw 2.8s ease-in-out infinite; }
|
|
210
|
+
.coach .hold { fill: none; stroke: #fff; stroke-width: 1.5; opacity: 0; animation: vr-hold 2.8s ease-in-out infinite; }
|
|
211
|
+
@keyframes vr-draw { 0%, 18% { stroke-dashoffset: 200; } 72%, 100% { stroke-dashoffset: 0; } 90% { opacity: 1; } 100% { opacity: 0; } }
|
|
212
|
+
@keyframes vr-hold { 0%, 8% { opacity: 0; } 14%, 72% { opacity: .9; } 80%, 100% { opacity: 0; } }
|
|
213
|
+
|
|
214
|
+
@media (max-width: 520px) {
|
|
215
|
+
.fab { right: 16px; bottom: 16px; padding: 13px 18px; font-size: 16px; }
|
|
216
|
+
.card { right: 16px; bottom: 84px; }
|
|
217
|
+
.vr.nobutton .card { bottom: 16px; }
|
|
218
|
+
.toolbar { bottom: 16px; max-width: calc(100vw - 24px); overflow-x: auto; }
|
|
219
|
+
.toolbar button { padding: 8px 11px; font-size: 14px; }
|
|
220
|
+
.coach { width: 260px; }
|
|
221
|
+
}
|
|
222
|
+
@media (prefers-reduced-motion: reduce) {
|
|
223
|
+
.card { animation: none; }
|
|
224
|
+
.fab { transition: none; }
|
|
225
|
+
.coach .loop { animation: none; stroke-dashoffset: 0; }
|
|
226
|
+
.coach .hold { animation: none; opacity: .9; }
|
|
227
|
+
}
|
|
228
|
+
`;class Ln{capture;tabHost;target;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;constructor(e,t,n){this.capture=e;this.tabHost=t;this.target=n}async run(e){let t={target:this.target},n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let i=await O("POST","/api/v1/reports",e,t);if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r}else if(this.sent!==r)await O("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n,t),this.sent=r;if(!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof T)||!j(i.status))throw i;console.warn("vitrinka: the server refused the recording — the report goes without it",i),this.skipCapture=!0}let o=await O("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{},t);return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async sendCapture(){let e=encodeURIComponent(this.id),{chunks:t,truncated:n}=this.capture;for(let o of t){if(this.blobKeys.has(o.seq))continue;let i=await Yt(`/api/v1/reports/${e}/chunk?seq=${o.seq}`,"application/json",o.body,this.target);if(!i.blobKey)throw Error(`vitrinka: chunk ${o.seq} came back without a blob key`);this.blobKeys.set(o.seq,i.blobKey)}let r=t.map((o)=>({seq:o.seq,ts:o.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:o.count,source:"replay",truncated:n},blobKey:this.blobKeys.get(o.seq)??""}));while(this.rowsPosted<r.length){let o=r.slice(this.rowsPosted,this.rowsPosted+pt);await O("POST",`/api/v1/reports/${e}/events`,{events:o},{target:this.target}),this.rowsPosted+=o.length}}}var qa="http://www.w3.org/2000/svg",Si=100,Ei={chunks:[],truncated:!1,console:[],network:[]},$a=["circle","box","arrow","hide"],Dn={w:160,h:80},Ri=16,Fa={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},le={close:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',gear:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="2.2" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.4 3.4l1.4 1.4M11.2 11.2l1.4 1.4M3.4 12.6l1.4-1.4M11.2 4.8l1.4-1.4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',clip:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.5 4.5l-5 5a1.6 1.6 0 002.3 2.3l5.4-5.4a3 3 0 00-4.2-4.2L3.6 7.6a4.4 4.4 0 006.2 6.2l4-4" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',chevron:'<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',pen:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.8 2.7l2.5 2.5-7.6 7.6-3.1 0.6 0.6-3.1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>',check:'<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M7.5 12.3l3 3 6-6.3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>'},Ti="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14";function Ka(e){let t=e?"":`<animateMotion dur="2.8s" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="0;0.18;0.72;1" calcMode="linear" path="${Ti}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true"><rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${Ti}" pathLength="200"/><g class="pointer"${e?' transform="translate(134 14)"':""}><circle class="hold" r="9"/><path d="M0 0 L0 15 L4 11 L7 18 L10 16.6 L7 10 L12.5 10 Z" fill="#fff" stroke="#151417" stroke-width="1"/>${t}</g></svg>`}function u(e,t={},...n){let r=document.createElement(e);for(let[o,i]of Object.entries(t))r.setAttribute(o,i);return r.append(...n),r}function Q(e){let t=document.createElement("template");t.innerHTML=e;let n=t.content.firstElementChild;if(!n)throw Error("vitrinka: icon markup is empty");return n}function _(e,t){let n=document.createElementNS(qa,e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Wa(e){let t=e.split(`
|
|
229
|
+
`)[0]?.trim()??"";return t.length>Si?`${t.slice(0,Si-1)}…`:t}function za(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function ja(e){let t=u("span"),n=u("kbd"),r=u("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},t,n),o=u("h2",{id:"vr-title"}),i=u("button",{class:"icon",type:"button"},Q(le.gear)),s=u("button",{class:"icon",type:"button"},Q(le.close)),a=u("header",{class:"head"},o,i,s),l=u("label",{class:"prompt",for:"vr-desc"}),d=u("textarea",{class:"desc",id:"vr-desc",rows:"3"}),g=u("span"),b=u("span"),c=u("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},b,Q(le.chevron)),p=u("div",{class:"attached"},Q(le.clip),g,u("span",{"aria-hidden":"true"},"·"),c),h=u("ul",{class:"included",id:"vr-included"}),k=u("span",{class:"chips"}),m=u("span"),y=u("div",{class:"marked"},k,m),f=u("input",{type:"checkbox"}),R=u("span"),D=u("label",{class:"notify"},f,R),Te=u("p",{class:"error",role:"alert"}),Ve=u("span"),Ye=u("button",{class:"where",type:"button"},Q(le.pen),Ve),Me=u("button",{class:"send",type:"button"}),Hn=u("div",{class:"pane describe"},l,d,p,h,y,D,Te,u("div",{class:"actions"},Ye,Me)),qn=u("span",{class:"label",id:"vr-bind-label"}),$n=u("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),Fn=u("button",{class:"link",type:"button"}),Kn=u("p",{class:"hint"}),Wn=u("p",{class:"reason",role:"status"}),zn=u("button",{class:"link",type:"button"}),jn=u("div",{class:"pane settings"},u("div",{class:"row"},qn,$n),Wn,Kn,u("div",{class:"settings-foot"},zn,Fn)),Un=u("h3"),Vn=u("p",{class:"sent-body"}),Yn=u("span"),Xn=u("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Yn),Jn=u("button",{class:"link",type:"button"}),Gn=u("div",{class:"pane sent",role:"status"},u("div",{class:"sent-head"},Q(le.check),Un),Vn,u("div",{class:"sent-actions"},Xn,Jn)),Zn=u("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},a,Hn,jn,Gn),Ct=_("svg",{class:"ink","aria-hidden":"true"}),Qn=_("defs",{}),er=_("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});er.append(_("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),Qn.append(er);let tr=_("g",{}),nr=_("g",{class:"draft"});Ct.append(Qn,tr,nr);let rr=u("div",{class:"pins"}),or=u("p"),ir=u("p"),sr=u("p",{class:"keys",id:"vr-keys"}),It=u("div",{class:"coach",role:"status"});It.append(Q(Ka(za())),or,ir,sr);let At=new Map;for(let ur of $a)At.set(ur,u("button",{type:"button","aria-pressed":"false","data-tool":ur}));let ar=u("button",{type:"button"}),lr=u("button",{type:"button",class:"done"}),cr=u("div",{class:"toolbar",role:"toolbar"},...At.values(),u("span",{class:"sep","aria-hidden":"true"}),ar,lr),Pt=u("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},rr,It,cr);Pt.prepend(Ct);let _t=u("div",{class:"vr"},r,Zn,Pt),dr=u("style");return dr.textContent=xi,_t.prepend(dr),e.append(_t),{root:_t,fab:r,fabLabel:t,fabKbd:n,card:Zn,title:o,gear:i,closeBtn:s,describe:Hn,prompt:l,desc:d,attached:p,attachedText:g,disclose:c,discloseText:b,included:h,marked:y,markedChips:k,markedText:m,notify:D,notifyBox:f,notifyText:R,error:Te,where:Ye,whereText:Ve,send:Me,settings:jn,bindLabel:qn,bindBtn:$n,unbind:Fn,bindHint:Kn,bindReason:Wn,back:zn,sent:Gn,sentTitle:Un,sentBody:Vn,see:Xn,seeText:Yn,sentClose:Jn,mark:Pt,ink:Ct,shapes:tr,draft:nr,pins:rr,coach:It,coachText:or,coachMore:ir,coachKeys:sr,toolButtons:At,toolbar:cr,undo:ar,done:lr}}class On{opts;hud;engine;config=null;locale;s;button;openSelector;identity;keybind;isOpen=!1;view="describe";marking=!1;markers=[];nextKey=1;tool="circle";frozen=null;job=null;sending=!1;error="";result=null;notify=!1;sentNotify=!1;includedOpen=!1;recordingBind=!1;bindRefused=!1;noteOpen=null;drawing=null;offs=[];pins=new Map;hideIds=new Map;dialogOrder=[...document.querySelectorAll("dialog[open]")].filter((e)=>e instanceof HTMLDialogElement);activeDialog(){this.dialogOrder=this.dialogOrder.filter((n)=>n.isConnected&&n.open);let e=(n)=>{try{return n.matches(":modal")}catch{return!1}};return[...this.dialogOrder].reverse().find(e)??this.dialogOrder.at(-1)??Wr()}sheet=null;e;constructor(e){this.opts=e;this.locale=e.locale??Nt(),this.s=Dt(this.locale),this.button=e.button,this.openSelector=e.openSelector??null,this.identity=e.identity===void 0?void 0:Et(e.identity),this.keybind=vi(),this.hud=Fr(),this.e=ja(this.hud.mount),this.engine=pi({base:e.base,key:e.key,appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl,loadRecord:e.loadRecord}),this.engine?.ready.then((t)=>{this.config=t,this.paint()}),this.bind(),this.paint(),this.followDialog()}followDialog(){let e=this.activeDialog();if((this.sheet?.target??null)===e)return;let t=this.e.root.getRootNode(),n=t instanceof ShadowRoot&&t.activeElement instanceof HTMLElement?t.activeElement:null,r=this.sheet;if(e){let o=zr(e);o.mount.append(this.e.root),this.sheet={target:e,host:o}}else this.hud.mount.append(this.e.root),this.sheet=null;r?.host.destroy(),n?.focus()}open(){if(this.isOpen)return;if(this.isOpen=!0,this.view!=="describe")this.view="describe";if(this.result=null,!this.job)this.frozen=this.engine?.freeze()??null;this.paint(),requestAnimationFrame(()=>this.e.desc.focus())}close(){if(!this.isOpen)return;if(this.marking)this.endMarking(!1);if(this.stopRecordingBind(),this.isOpen=!1,this.view="describe",this.paint(),this.button)this.e.fab.focus()}setLocale(e){let t=Ce(e)??Nt();if(t===this.locale)return;this.locale=t,this.s=Dt(t),this.paint()}setButton(e){this.button=e,this.paint()}setOpenSelector(e){this.openSelector=e||null}identify(e){this.identity=e===void 0?void 0:Et(e),this.paint()}unmount(){this.stopRecordingBind();for(let e of this.offs.splice(0).reverse())e();fi(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let e=this.e,t=(o,i,s)=>{o.addEventListener(i,s)};t(e.fab,"click",()=>this.isOpen?this.close():this.open()),t(e.closeBtn,"click",()=>this.close()),t(e.gear,"click",()=>this.show(this.view==="settings"?"describe":"settings")),t(e.back,"click",()=>this.show("describe")),t(e.sentClose,"click",()=>this.close()),t(e.desc,"input",()=>this.paint()),t(e.disclose,"click",()=>{this.includedOpen=!this.includedOpen,this.paint()}),t(e.notifyBox,"change",()=>{this.notify=e.notifyBox.checked}),t(e.where,"click",()=>this.startMarking()),t(e.send,"click",()=>void this.send()),t(e.bindBtn,"click",()=>this.recordingBind?this.stopRecordingBind():this.startRecordingBind()),t(e.unbind,"click",()=>{this.keybind=null,_n(null),this.paint()}),t(e.card,"keydown",(o)=>{if(o.key!=="Escape"||this.recordingBind)return;if(o.preventDefault(),this.view==="settings")this.show("describe");else this.close()});for(let[o,i]of e.toolButtons)t(i,"click",(s)=>{if(this.tool=o,this.renderKbDraft(),this.paint(),s.detail===0)e.mark.focus()});if(t(e.mark,"keydown",(o)=>this.markKey(o)),t(e.undo,"click",()=>{this.markers=Nn(this.markers.slice(0,-1)),this.renderMarks(),this.paint()}),t(e.done,"click",()=>this.endMarking(!0)),t(e.mark,"pointerdown",(o)=>this.pointerDown(o)),t(e.mark,"pointermove",(o)=>this.pointerMove(o)),t(e.mark,"pointerup",(o)=>this.pointerUp(o)),t(e.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(N(e.mark,"wheel",(o)=>o.preventDefault())),this.offs.push(N(e.mark,"touchmove",(o)=>o.preventDefault())),this.offs.push(N(window,"keydown",(o)=>{if(this.recordingBind)return;if(this.marking&&o.key==="Escape"){if(o.preventDefault(),this.kbDraft)this.cancelDraft();else this.endMarking(!0);return}if(this.keybind&&yi(o,this.keybind))if(o.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(N(document,"click",(o)=>{let i=this.openSelector,s=o.target;if(!i||!(s instanceof Element))return;let a=null;try{a=s.closest(i)}catch{return}if(!a)return;o.preventDefault(),this.open()})),this.offs.push(wi((o)=>{this.keybind=o,this.paint()})),this.offs.push(mi(()=>this.paint())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let n=0,r=new MutationObserver((o)=>{for(let i of o){if(i.type!=="attributes"||i.attributeName!=="open"||!(i.target instanceof HTMLDialogElement))continue;let s=i.target;if(!s.open)this.dialogOrder=this.dialogOrder.filter((a)=>a!==s);else if(i.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((a)=>a!==s),s]}if(n)return;n=requestAnimationFrame(()=>{n=0,this.followDialog()})});r.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(r.disconnect(),n)cancelAnimationFrame(n)})}show(e){if(this.stopRecordingBind(),this.view=e,this.paint(),e==="describe")requestAnimationFrame(()=>this.e.desc.focus());if(e==="settings")requestAnimationFrame(()=>this.e.bindBtn.focus())}who(){return this.identity!==void 0?this.identity:gi()}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=N(window,"keydown",(e)=>{e.preventDefault(),e.stopPropagation();let t=bi(e);if(t.kind==="wait")return;if(t.kind==="bare"){this.bindRefused=!0,this.paint();return}if(t.kind==="bind")this.keybind=t.bind,_n(t.bind);this.stopRecordingBind()},{capture:!0}),this.paint()}stopRecordingBind(){if(!this.recordingBind)return;this.recordingBind=!1,this.bindRefused=!1,this.stopBindListener?.(),this.stopBindListener=null,this.paint()}startMarking(){if(this.job?.id)return;this.marking=!0,this.noteOpen=null,this.renderMarks(),this.paint();let e=globalThis.innerWidth||800,t=globalThis.innerHeight||600;this.placeCoach({x:e/2-150,y:t-260},!1),this.e.mark.focus()}endMarking(e){if(this.cancelDraft(),this.marking=!1,this.noteOpen=null,this.paint(),e&&this.isOpen)requestAnimationFrame(()=>this.e.desc.focus())}onChrome(e){return e instanceof Node&&(this.e.toolbar.contains(e)||this.e.pins.contains(e))}pointerDown(e){if(this.onChrome(e.target)||e.button!==0||!e.isPrimary)return;e.preventDefault();let t=this.e.root.getRootNode();if(t instanceof ShadowRoot&&t.activeElement instanceof HTMLElement)t.activeElement.blur();this.noteOpen=null,this.drawing={start:{x:e.clientX,y:e.clientY},shape:this.tool,pointer:e.pointerId};try{this.e.mark.setPointerCapture(e.pointerId)}catch{}this.e.coach.classList.add("pressing"),this.renderPins()}pointerMove(e){if(!this.markers.length)this.placeCoach({x:e.clientX,y:e.clientY},!0);let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:t.shape,rect:Rn(t.start,{x:e.clientX,y:e.clientY}),head:Tn(t.start,{x:e.clientX,y:e.clientY})}))}pointerUp(e){let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;let n={x:e.clientX,y:e.clientY};if(this.cancelDraft(),!Qo(t.shape,t.start,n))return;this.addMarker(t.shape,Rn(t.start,n),t.shape==="arrow"?Tn(t.start,n):void 0)}addMarker(e,t,n){let r=this.nextKey++;if(e==="hide"){let o=this.engine?.hiddenIdsAt(t);if(o)this.hideIds.set(r,o)}this.markers=Nn([...this.markers,{key:r,n:this.markers.length+1,shape:e,rect:t,note:"",...n?{head:n}:{}}]),this.noteOpen=r,this.renderMarks(),this.paint(),this.pins.get(r)?.note.focus()}cancelDraft(){this.drawing=null,this.kbDraft=null,this.e.draft.replaceChildren(),this.e.coach.classList.remove("pressing")}kbDraft=null;markKey(e){if(e.target!==this.e.mark)return;let t=globalThis.innerWidth||800,n=globalThis.innerHeight||600;if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),!this.kbDraft){this.kbDraft={x:Math.round(t/2-Dn.w/2),y:Math.round(n/2-Dn.h/2),...Dn},this.renderKbDraft();return}let a=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,a,this.tool==="arrow"?"se":void 0);return}let r=Fa[e.key];if(!r||!this.kbDraft)return;e.preventDefault();let o=this.kbDraft,[i,s]=r;this.kbDraft=e.shiftKey?{...o,w:Math.min(t-o.x,Math.max(Ri,o.w+i)),h:Math.min(n-o.y,Math.max(Ri,o.h+s))}:{...o,x:Math.min(t-o.w,Math.max(0,o.x+i)),y:Math.min(n-o.h,Math.max(0,o.y+s))},this.renderKbDraft()}renderKbDraft(){let e=this.kbDraft;if(!e)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:this.tool,rect:e,head:"se"}))}placeCoach(e,t){let n=globalThis.innerWidth||800,r=globalThis.innerHeight||600,o=this.e.coach.offsetWidth||300,i=this.e.coach.offsetHeight||140,s=t?e.x+20:e.x,a=t?e.y+20:e.y;if(s+o>n-8)s=t?e.x-o-20:n-o-8;if(a+i>r-90)a=t?e.y-i-20:r-i-90;this.e.coach.style.left=`${Math.max(8,s)}px`,this.e.coach.style.top=`${Math.max(8,a)}px`}shapeNodes(e){let{x:t,y:n,w:r,h:o}=e.rect;if(e.shape==="circle")return[_("ellipse",{class:"stroke",cx:t+r/2,cy:n+o/2,rx:Math.max(1,r/2),ry:Math.max(1,o/2)})];if(e.shape==="box")return[_("rect",{class:"stroke",x:t,y:n,width:r,height:o,rx:6})];if(e.shape==="arrow"){let{tail:a,tip:l}=Mn(e.rect,e.head??"se");return[_("line",{class:"stroke",x1:a.x,y1:a.y,x2:l.x,y2:l.y,"marker-end":"url(#vr-head)"})]}let i=_("rect",{class:"veil",x:t,y:n,width:r,height:o,rx:4}),s=_("text",{class:"veil-label",x:t+r/2,y:n+o/2+4,"text-anchor":"middle"});return s.textContent=r>60&&o>20?this.s.hidden:"",[i,s]}renderMarks(){this.e.shapes.replaceChildren(...this.markers.flatMap((t)=>this.shapeNodes(t)));let e=new Set(this.markers.map((t)=>t.key));for(let[t,n]of this.pins){if(e.has(t))continue;n.el.remove(),this.pins.delete(t)}for(let t of this.markers){if(this.pins.has(t.key))continue;let n=u("button",{class:"num",type:"button"}),r=u("input",{class:"note",type:"text",maxlength:"500"}),o=u("button",{class:"rm",type:"button"},Q(le.close)),i=u("div",{class:"pin"},n,r,o);n.addEventListener("click",()=>{this.noteOpen=t.key,this.renderPins(),r.focus()}),r.addEventListener("input",()=>{this.markers=this.markers.map((s)=>s.key===t.key?{...s,note:r.value}:s)}),r.addEventListener("focus",()=>{this.noteOpen=t.key,this.renderPins()}),r.addEventListener("keydown",(s)=>{if(s.key!=="Enter")return;s.preventDefault(),this.e.mark.focus()}),o.addEventListener("click",()=>{this.markers=Nn(this.markers.filter((s)=>s.key!==t.key)),this.renderMarks(),this.paint()}),this.e.pins.append(i),this.pins.set(t.key,{el:i,num:n,note:r,rm:o})}this.renderPins()}renderPins(){let e=globalThis.innerWidth||800;for(let t of this.markers){let n=this.pins.get(t.key);if(!n)continue;let r=t.shape==="arrow"?Mn(t.rect,t.head??"se").tail:{x:t.rect.x,y:t.rect.y},o=this.noteOpen===t.key||t.note.trim()!=="",i=o?290:30;n.el.style.left=`${Math.min(Math.max(4,r.x-12),e-i)}px`,n.el.style.top=`${Math.max(4,r.y-12)}px`,n.num.textContent=String(t.n),n.num.setAttribute("aria-label",this.s.mark(t.n)),n.note.hidden=!o,n.rm.hidden=!o,n.note.placeholder=this.s.notePlaceholder,n.note.setAttribute("aria-label",`${this.s.mark(t.n)} — ${this.s.notePlaceholder}`),n.rm.setAttribute("aria-label",this.s.removeMark(t.n))}}envelope(e,t){let n=this.who(),r=globalThis.location;return{title:Wa(e),description:e,env:{url:te(r?`${r.origin}${r.pathname}`:""),ua:globalThis.navigator?.userAgent??"",viewport:{w:globalThis.innerWidth||0,h:globalThis.innerHeight||0,dpr:globalThis.devicePixelRatio||1},appVersion:this.opts.appVersion??"",locale:globalThis.navigator?.language??""},console:t.console,network:t.network,...n?{identity:n,notify:this.notify}:{},markers:ti(this.markers),locale:this.locale}}async send(){let e=this.e.desc.value.trim();if(this.sending||!e)return;if(this.sending=!0,this.error="",this.paint(),this.job&&!this.job.id)this.job=null;try{if(!this.job){let t=new Set;for(let r of this.markers)for(let o of this.hideIds.get(r.key)??[])t.add(o);let n=this.engine?await this.engine.build(this.frozen??{clip:null,stored:Promise.resolve(new Map)},this.markers,t).catch((r)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",r),Ei)):Ei;this.job=new Ln(n,globalThis.location?.host??"",{url:this.opts.base,key:this.opts.key})}this.result=await this.job.run(this.envelope(e,this.job.capture)),this.sentNotify=this.notify&&this.who()!==null,this.view="sent",this.job=null,this.frozen=null,this.e.desc.value="",this.markers=[],this.hideIds.clear(),this.notify=!1,this.e.notifyBox.checked=!1,this.includedOpen=!1,this.renderMarks(),this.engine?.clear()}catch(t){console.warn("vitrinka: the report did not go through — Retry resumes it",t),this.error=this.job?.id?"capture":"create"}finally{this.sending=!1,this.paint()}if(this.view==="sent")requestAnimationFrame(()=>((this.result?.reportUrl)?this.e.see:this.e.sentClose).focus())}includedItems(){let e=this.s,t=[],n=this.config?.lanes;if(n?.replay)t.push(`${e.incReplay} — ${e.incReplayMasked[this.config?.masking??"strict"].toLowerCase()}`);if(n?.errors)t.push(e.incErrors);if(n?.console)t.push(e.incConsole);if(n?.network)t.push(e.incNetwork);else if(n?.errors)t.push(e.incFailedRequests);if(t.push(e.incEnv),this.who())t.push(e.incIdentity);if(this.markers.length)t.push(e.incMarks);return t}paint(){let{e,s:t}=this,n=this.who();e.root.setAttribute("lang",this.locale),e.root.classList.toggle("nobutton",!this.button),e.fab.hidden=!this.button||this.marking,e.fabLabel.textContent=t.button,e.fab.setAttribute("aria-expanded",String(this.isOpen)),e.fabKbd.hidden=!this.keybind,e.fabKbd.textContent=this.keybind?Tt(this.keybind):"",e.card.hidden=!this.isOpen||this.marking,e.title.textContent=t.title,e.gear.setAttribute("aria-label",t.settings),e.gear.setAttribute("aria-pressed",String(this.view==="settings")),e.closeBtn.setAttribute("aria-label",t.close),e.describe.hidden=this.view!=="describe",e.settings.hidden=this.view!=="settings",e.sent.hidden=this.view!=="sent",e.prompt.textContent=t.prompt,e.desc.placeholder=t.placeholder,e.attachedText.textContent=t.attached(this.config?.profile.windowSec??60),e.attached.hidden=this.engine===null||this.config?.capturing===!1,e.discloseText.textContent=t.included,e.disclose.setAttribute("aria-expanded",String(this.includedOpen)),e.included.hidden=!this.includedOpen,e.included.replaceChildren(...this.includedItems().map((o)=>u("li",{},o))),e.marked.hidden=this.markers.length===0,e.markedChips.replaceChildren(...this.markers.map((o)=>u("span",{class:o.shape==="hide"?"chip hide":"chip","aria-hidden":"true"},String(o.n)))),e.markedText.textContent=t.marked(this.markers.length),e.notify.hidden=n===null,e.notifyText.textContent=t.notify,e.error.hidden=this.error==="",e.error.textContent=this.error==="create"?t.errorCreate:this.error==="capture"?t.errorCapture:"",e.whereText.textContent=t.showWhere,e.where.disabled=this.sending||Boolean(this.job?.id),e.send.textContent=this.sending?t.sending:this.error?t.retry:t.send,e.send.disabled=this.sending||e.desc.value.trim()==="",e.bindLabel.textContent=t.shortcut,e.bindBtn.setAttribute("aria-pressed",String(this.recordingBind)),e.bindBtn.setAttribute("aria-label",`${t.shortcut}: ${this.keybind?Tt(this.keybind):t.notSet} — ${t.recordShortcut}`),e.bindBtn.textContent=this.recordingBind?t.pressKeys:this.keybind?Tt(this.keybind):t.notSet,e.unbind.textContent=t.removeShortcut,e.unbind.hidden=!this.keybind||this.recordingBind,e.bindHint.textContent=t.shortcutHint,e.bindReason.hidden=!this.bindRefused,e.bindReason.textContent=this.bindRefused?t.needModifier:"",e.back.textContent=t.back,e.sentTitle.textContent=t.sentTitle,e.sentBody.textContent=this.sentNotify?t.sentNotify:t.sentBody,e.seeText.textContent=t.seeReport;let r=this.result?.reportUrl;if(e.see.hidden=!r,r)e.see.setAttribute("href",r);else e.see.removeAttribute("href");e.sentClose.textContent=t.close,e.mark.hidden=!this.marking,e.toolbar.setAttribute("aria-label",t.toolbar);for(let[o,i]of e.toolButtons)i.textContent=t.tools[o],i.setAttribute("aria-pressed",String(this.tool===o));if(e.undo.textContent=t.undo,e.undo.disabled=this.markers.length===0,e.done.textContent=t.done,e.coach.hidden=!this.marking||this.markers.length>0,e.coachText.textContent=t.coach,e.coachMore.textContent=t.coachMore,e.coachKeys.textContent=t.keyboardHint,e.mark.setAttribute("aria-label",t.marking),this.marking){for(let o of e.shapes.querySelectorAll(".veil-label"))if(o.textContent)o.textContent=t.hidden;this.renderPins()}}}function Nn(e){return ei(e).map((t,n)=>({...t,key:e[n].key}))}var Mt="vitrinka-report",Ua=["key","base","open-selector","locale","button"];function Mi(e){return e.trim().replace(/\/+$/,"")}function Bn(e){if(typeof customElements>"u"||customElements.get(Mt))return;class t extends HTMLElement{static get observedAttributes(){return Ua}options={};widget=null;pendingIdentity=void 0;connectedCallback(){this.hidden=!0,this.mountWidget()}disconnectedCallback(){this.widget?.unmount(),this.widget=null}attributeChangedCallback(n,r,o){if(r===o)return;if(!this.widget){if(this.isConnected&&(n==="key"||n==="base"))this.mountWidget();return}if(n==="locale")this.widget.setLocale(o);else if(n==="button")this.widget.setButton(o!=="false");else if(n==="open-selector")this.widget.setOpenSelector(o);else this.widget.unmount(),this.widget=null,this.mountWidget()}open(){this.widget?.open()}close(){this.widget?.close()}identify(n){this.pendingIdentity=n,this.widget?.identify(n)}setLocale(n){this.setAttribute("locale",String(n))}mountWidget(){if(this.widget)return;let n=(this.getAttribute("key")??"").trim(),r=Mi(this.getAttribute("base")??e.defaultBase());if(!n||!r){console.warn(`vitrinka: <${Mt}> needs a key${r?"":" and a base"} — nothing mounted`);return}this.widget=new On({base:r,key:n,locale:Ce(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,appVersion:this.options.appVersion,capture:this.options.capture,sanitizeUrl:this.options.sanitizeUrl,loadRecord:e.loadRecord})}}customElements.define(Mt,t)}function Ci(e,t){if(e.face==="recorder")return Va(e,t);Bn(t);let n=document.createElement(Mt);if(n.setAttribute("key",e.key),e.base)n.setAttribute("base",e.base);if(e.locale)n.setAttribute("locale",String(e.locale));if(e.button===!1)n.setAttribute("button","false");if(e.openSelector)n.setAttribute("open-selector",e.openSelector);if(n.options={appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl},e.identity!==void 0)n.identify(e.identity);return(e.parent??document.body).append(n),{face:"report",open:()=>n.open(),close:()=>n.close(),identify:(r)=>n.identify(r),setLocale:(r)=>n.setLocale(r),unmount:()=>n.remove()}}function Va(e,t){let n=Mi(e.base??t.defaultBase()),r=null,o=!1;if(!t.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else t.recorderFace().then((s)=>{if(!o)r=s({base:n,key:e.key,appVersion:e.appVersion,sanitizeUrl:e.sanitizeUrl})}).catch((s)=>console.warn("vitrinka: the recorder face did not load",s));let i=()=>{return};return{face:"recorder",open:i,close:i,identify:i,setLocale:i,unmount:()=>{o=!0,r?.()}}}var Ya=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function Xa(e){let n=await import(`${e}/vendor/rrweb-record-1.min.js`)??{},r=typeof n.default==="object"&&n.default!==null?n.default.record:void 0,o=typeof n.default==="function"?n.default:r??n.record;return typeof o==="function"?o:null}var Ii={loadRecord:Xa,recorderFace:null,defaultBase:()=>Ya};Bn(Ii);function Lc(e){return Ci(e,Ii)}export{Da as identify,Lc as mountReport};
|