@vitrinka/web 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # @vitrinka/web
2
2
 
3
+ ## 0.10.1
4
+
5
+ - Rebuilt from the cleaned repository history, with no behaviour change.
6
+ 0.10.0 is withdrawn from npm; upgrade to 0.10.1.
7
+
3
8
  ## 0.10.0
4
9
 
5
10
  - **A report says where it came from.** Report a problem takes a
6
11
  `context` option and a `setContext(map)` method on the handle and the
7
12
  element: a small map your app declares (`{environment: 'demo',
8
- organization: {id: 'org_42', label: 'Turena'}}`) that the next report
13
+ organization: {id: 'org_42', label: 'Acme'}}`) that the next report
9
14
  carries as `context` on `POST /api/v1/reports`. At most 8 keys of
10
15
  `[a-z0-9_]` (1 to 32 characters); each value a string of 1 to 100
11
16
  characters or `{id, label?}`, trimmed before it is counted and sent
@@ -77,7 +82,7 @@ Upgrading:
77
82
  shortcut put its chord on the button, and the chord became part of the
78
83
  button's accessible name: "Report a problem Alt+Shift+A" (cs "Nahlásit
79
84
  problém Alt+Shift+A"). A screen reader read the glyphs as the name, and a
80
- host test that found the button by name — Voke's did — found nothing. The
85
+ host test that found the button by name — Example Platform's did — found nothing. The
81
86
  chord is now painted for the eye only, and assistive technology hears it
82
87
  from `aria-keyshortcuts` (`Alt+Shift+A` beside the button's Alt+arrow
83
88
  moves). Since 0.9.0.
package/README.md CHANGED
@@ -401,7 +401,7 @@ const b64 = (v: string | Buffer) => Buffer.from(v).toString('base64url');
401
401
  export function reporterToken(user: { id: string; email: string; name?: string }): string {
402
402
  const now = Math.floor(Date.now() / 1000);
403
403
  const head = b64(JSON.stringify({ alg: 'HS256', typ: 'JWT' }));
404
- const body = b64(JSON.stringify({ sub: user.id, email: user.email, name: user.name, iat: now, exp: now + 3600, aud: 'acme/voke' }));
404
+ const body = b64(JSON.stringify({ sub: user.id, email: user.email, name: user.name, iat: now, exp: now + 3600, aud: 'acme/example-platform' }));
405
405
  const sig = b64(createHmac('sha256', process.env.VITRINKA_REPORT_HOST_SECRET!).update(`${head}.${body}`).digest());
406
406
  return `${head}.${body}.${sig}`;
407
407
  }
@@ -430,7 +430,7 @@ filed task's environment, over the project's host rule.
430
430
  import { mountReport, type ReportContext } from '@vitrinka/web/report';
431
431
 
432
432
  const report = mountReport({ key: 'vkb_…', context: { environment: 'demo' } });
433
- const context: ReportContext = { environment: 'demo', organization: { id: 'org_42', label: 'Turena' } };
433
+ const context: ReportContext = { environment: 'demo', organization: { id: 'org_42', label: 'Acme' } };
434
434
  report.setContext(context); // replaces the whole map for the next report
435
435
  report.setContext(null); // clears it ({} too): nothing is sent
436
436
  ```
@@ -9,7 +9,7 @@
9
9
  import { type ReactElement, type RefObject } from 'react';
10
10
  import type { HudAccount, HudSize, HudSnapshot } from './controller';
11
11
  import { type Place } from './spots';
12
- /** The account line: `lukas@… · ADF`, or the key build's `Recorder key · <name> · project <p>`. */
12
+ /** The account line: `lukas@… · Client`, or the key build's `Recorder key · <name> · project <p>`. */
13
13
  export declare function accountLines(account: HudAccount | null, linked: boolean): {
14
14
  who: string;
15
15
  ws: string;
@@ -8,7 +8,7 @@ const SIZES = [
8
8
  { size: 'lg', label: 'L', name: 'Large' },
9
9
  ];
10
10
  const STATUS_WORDS = { recording: 'recording', saved: 'saved', unsaved: 'not stopped', deleted: 'deleted' };
11
- /** The account line: `lukas@… · ADF`, or the key build's `Recorder key · <name> · project <p>`. */
11
+ /** The account line: `lukas@… · Client`, or the key build's `Recorder key · <name> · project <p>`. */
12
12
  export function accountLines(account, linked) {
13
13
  if (!linked)
14
14
  return { who: 'Not linked', ws: '', sub: 'Link this device to record' };
@@ -8,7 +8,7 @@
8
8
  * to its worker, never to the page, and the worker relays them as a
9
9
  * synthetic keydown — `isTrusted: false` (D10). A taken chord is
10
10
  * `preventDefault`ed, never stopped, so a host that skips `defaultPrevented`
11
- * keys (forge-studio's CommandProvider) leaves it alone.
11
+ * keys (example-app-studio's CommandProvider) leaves it alone.
12
12
  */
13
13
  import { listen } from './listen';
14
14
  const BY_CODE = { KeyA: 'annotate', KeyN: 'note', KeyP: 'pause', KeyS: 'stop' };
@@ -29,7 +29,7 @@ export function shield(el) {
29
29
  /**
30
30
  * The KEY GUARD (vt-8020 S14): the bubble-phase shield above comes too late
31
31
  * for a host that listens in the CAPTURE phase on window or document (the
32
- * PWF designer's BPMN modeler binds 'e' that way) — and shadow retargeting
32
+ * example-app designer's BPMN modeler binds 'e' that way) — and shadow retargeting
33
33
  * shows that listener our host element as `event.target`, never the field,
34
34
  * so its "ignore keys while typing" check fails and typing 'e' in a note
35
35
  * fires the host's tool. One window capture listener runs ahead of every
@@ -1,3 +1,3 @@
1
1
  /** Sent as `meta.recorder` and written as `data-vitrinka-page`; bumped with the package version. */
2
- export declare const RECORDER_VERSION = "0.10.0";
3
- export declare const RECORDER_ID = "web/0.10.0";
2
+ export declare const RECORDER_VERSION = "0.10.1";
3
+ export declare const RECORDER_ID = "web/0.10.1";
@@ -1,3 +1,3 @@
1
1
  /** Sent as `meta.recorder` and written as `data-vitrinka-page`; bumped with the package version. */
2
- export const RECORDER_VERSION = '0.10.0';
2
+ export const RECORDER_VERSION = '0.10.1';
3
3
  export const RECORDER_ID = `web/${RECORDER_VERSION}`;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The context a host app declares on a report (vt-9515): a small map the
3
3
  * server files with it, e.g. `{environment: 'demo', organization: {id:
4
- * 'org_42', label: 'Turena'}}`. The contract is frozen and the server checks
4
+ * 'org_42', label: 'Acme'}}`. The contract is frozen and the server checks
5
5
  * the same limits: at most 8 keys; a key is 1 to 32 characters of
6
6
  * [a-z0-9_]; a value is a string of 1 to 100 characters, or `{id, label?}`
7
7
  * with an id of 1 to 100 characters and a label of at most 100. A value, id
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The context a host app declares on a report (vt-9515): a small map the
3
3
  * server files with it, e.g. `{environment: 'demo', organization: {id:
4
- * 'org_42', label: 'Turena'}}`. The contract is frozen and the server checks
4
+ * 'org_42', label: 'Acme'}}`. The contract is frozen and the server checks
5
5
  * the same limits: at most 8 keys; a key is 1 to 32 characters of
6
6
  * [a-z0-9_]; a value is a string of 1 to 100 characters, or `{id, label?}`
7
7
  * with an id of 1 to 100 characters and a label of at most 100. A value, id
@@ -6,7 +6,7 @@ function L(e,t,n,r={}){let o=e,i=o.__zone_symbol__addEventListener??e.addEventLi
6
6
  ${p}\r
7
7
  \r
8
8
  ${g}\r
9
- `)}return s.push(i[i.length-1]),s.join(o)}var is=262144;function Ji(e,t,n){if(e.full||!t)return t;try{if(vn(t)){if(t.length<=is)try{return JSON.stringify(St(e,JSON.parse(t),0))}catch{}return xe(e,Oc(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return xt(e,os(e,G,t));if(r.includes("multipart/form-data")){let o=_c(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return xt(e,t)}catch{return"[redacted]"}}function ss(e,t){if(t===void 0)return;if(e.full)return t;if(vn(t))try{return JSON.stringify(St(e,JSON.parse(t),0))}catch{}try{return xt(e,t)}catch{return"[redacted]"}}function as(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(vn(t)&&t.length<=is){let i=Ji(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 Ji(e,o,r)}function ls(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):es(e,s)?"[redacted]":xe(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function cs(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var Se=yn(null);function us(e){Se=yn(e??null)}function ps(e){return ss(Se,e)}function wn(e,t,n){return as(Se,e,t,n)}var ds=null,fs=null;function xn(e){fs=e??null}function Dc(e){let t=fs??We().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(ds!==t)ds=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return Bc(e)??Zi}function Bc(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function le(e){return kn(Se,Dc(e))}var Nc=4;function Sn(e){return e.type===Nc}function Rn(e){if(!Sn(e))return e;return{...e,data:{...e.data,href:le(e.data.href)}}}function je(e){return ls(Se,e)}function hs(){return cs(Se)}var gs=30000,Hc=4194304,Fc=20000,Tn=500,$c=2000,zc=2,ms={windowMs:gs,checkoutMs:gs,maxBytes:Hc,maxEvents:Fc,maxLaneEvents:Tn},Z=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function An(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var Kc=new TextEncoder,ee=!1,bs=0,P=ms,v=[],D=[],W=[],J=[],qc=0,Ee=[],Ce=new Map,Te=null,Re=null,Ve=!1,Wc=0,Q=null,Rt=null,Cn=Promise.resolve();function ys(e=ms){if(Ln(),ee=!0,bs++,P=e,Q=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})),D=(e.priorLanes??[]).slice(-e.maxLaneEvents),W=[],J=[],Ee=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),Ce.clear(),Te=null,Ct(Date.now()),Q)Rt=setInterval(Et,$c)}function ks(){Et(),Ln(),ee=!1,Q=null,v=[],D=[],W=[],J=[],Ee=[],Ce.clear(),Te=null}function vs(){return P}function Mn(e){Re=e}function ws(){if(!ee)return;v=[],D=[],W=[],J=[],Ee=[],Ce.clear(),Te=null;let e=x.tabId;ce((t)=>t.clear(e)),Re?.()}function xs(){return Cn}function Et(){if(!ee||!Q)return;let e=Date.now();Ct(e),Pn(e);for(let t of v){if(t.stored)continue;let n=Ce.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;Ce.set(t.id,{events:t.events.length,parts:o+1});let i=Ss(t);ce((s)=>s.putWindowChunk(i,o,r,[]))}Uc(e)}function Uc(e){let t=e-P.windowMs;while(J.length>0&&J[0].lastMs<=t){let[a]=J.splice(0,1);if(a)ce((l)=>l.dropWindow(a.id))}for(let a of Ee.filter((l)=>l.lastMs<=t))ce((l)=>l.dropWindow(a.id));Ee=Ee.filter((a)=>a.lastMs>t);let n=W;if(!n.length)return;W=[];let r=J.at(-1);if(!r||r.startMs<=t)r={id:`${Z}.lanes.${++qc}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},J.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:x.tabId,scope:P.scope??"",kind:"lanes",load:Z,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};ce((a)=>a.putWindowChunk(s,o,"[]",n))}function Ln(){if(Rt)clearInterval(Rt);Rt=null}function Ss(e){return{id:e.id,tab:x.tabId,scope:P.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function ce(e){let t=Q;if(!t)return;Cn=Cn.then(()=>e(t)).catch((n)=>{if(Q!==t)return;Q=null,Ln(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function En(e){let[t]=v.splice(e,1);if(!t)return;Ce.delete(t.id),ce((n)=>n.dropWindow(t.id))}function Ct(e){while(v.length>0){let r=v[0],o=v[1];if(!o&&r.load===Z)break;if(An(r,o)>e-P.windowMs)break;En(0)}if(Ve)return;let t=v.at(-1);if(t&&t.load===Z&&Re&&t.lastMs<=e-P.windowMs){Ve=!0;try{Re()}finally{Ve=!1}let r=v.indexOf(t);if(r>=0&&r<v.length-1)for(let o=r;o>=0;o--)En(o)}let n=!1;while(v.length>0&&jc()){if(v.length===1&&v[0].load===Z&&!n&&Re){n=!0,Ve=!0;try{Re()}finally{Ve=!1}if(v.length>1)continue}En(0),Te=v[0]?.startMs??e}}function Rs(){return ee?`flight:${bs}`:null}function Pn(e){let t=Math.min(v[0]?.startMs??Number.POSITIVE_INFINITY,e-P.windowMs),n=D.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)D=[];else if(n>0)D=D.slice(n)}function jc(){let e=0,t=0;for(let n of v)e+=n.bytes,t+=n.count;return e>P.maxBytes||t>P.maxEvents}function Es(e){if(!ee)return;let t=v[0];if(Sn(e)){let r=globalThis.location?.pathname??x.pathname,o={id:`${Z}.${++Wc}`,load:Z,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:le(r)};v.push(o);let i=Ss(o);ce((s)=>s.putWindow(i))}let n=v.at(-1);if(!n||n.load!==Z)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=Kc.encode(JSON.stringify(e)).length,Ct(e.timestamp),v[0]!==t)Pn(e.timestamp)}function Cs(e,t,n){if(!ee)return null;let r=P.keepLane?P.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=P.maxLaneEvents;if(D.push(i),D.length>s)D.splice(0,D.length-s);if(Q){if(W.push(i),W.length>s)W.splice(0,W.length-s)}return o}function Tt(){if(!ee)return null;let e=Date.now();return Ct(e),Pn(e),{windows:v.map((t)=>({...t,events:t.events.slice()})),lanes:D.slice(),truncated:Te!==null&&Te>e-P.windowMs}}function In(e){return e.windows.some((t)=>t.events[1]?.type===zc)}var On=null;function Ye(){if(!On)On=typeof indexedDB>"u"?Vc():Yc();return On}function Vc(){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 Yc(){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 Xc=2000,Nn=20000,Ds=200,Gc=4194304,Jc=3145728,Ot=500,Zc=Gc-1024,Qc=12582912,ed=10485760,td=Qc-64,nd=1048576,rd=new TextEncoder;function Oe(e){return rd.encode(e).length}var E=()=>A();function j(e,t){let n=E().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var Ts=!1;function V(e,t){try{return E().set(e,t),!0}catch(n){if(!Ts)Ts=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var Mt="rec",pe;function S(){if(pe===void 0)pe=j(Mt,null);return pe}function _t(e){if(pe=e,e===null)E().remove(Mt),E().remove(od);else V(Mt,JSON.stringify(id(e)))}var od="notes";var Ge=null;function id(e){if(Ge?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:Ge.activeMs,resumeAt:null,stopping:Ge.at}}var sd=new Set;function ad(){for(let e of sd)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function ld(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&&Ge?.sessionId!==t.sessionId)ad();if(!t){if(!n)return"unchanged";return pe=null,_s(),yd(),"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(Ge?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return pe=t,"updated"}return pe=t,_s(),"joined"}var cd=700,fe,U=null,oe=!1;function Me(){if(fe===void 0)fe=j("buffer",[]);return fe}function Dt(){if(U)clearTimeout(U),U=null;if(fe!==void 0&&!oe)V("buffer",JSON.stringify(fe))}function Bs(){if(oe=!1,U)return;U=setTimeout(()=>{U=null,Dt(),Ns()},cd)}function Hn(e){fe=e,oe=!1,Dt()}var Ae,Le=0;function de(){if(Ae===void 0)Ae=j("chunks",[]),Le=Ae.reduce((e,t)=>e+t.body.length,0);return Ae}function Ns(){if(oe)return;let e=de();if(e.length===0){E().remove("chunks");return}if(Le>nd){E().remove("chunks");return}V("chunks",JSON.stringify(e))}function Hs(e){Ae=e,Le=e.reduce((t,n)=>t+n.body.length,0),oe=!1,Ns()}var Lt,ge=new Map,he=new Set,me=new Map,Je=new Map,As=5,dd=200,ud=67108864,pd=0,Ms=!1,Fn="blobs";function B(){return Lt??=j("images",[]),Lt}function Fs(){if(oe)return;let e=B().filter((t)=>!he.has(t.blob));if(e.length===0)E().remove("images");else V("images",JSON.stringify(e))}function $n(e){Lt=e,oe=!1,Fs()}function fd(e,t){let n=Ye();if(!n.durable&&!Ms)Ms=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");V(Fn,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${Ws}.${++pd}`;return ge.set(a,i),he.add(a),r.push(n.put(a,i).then(()=>{if(!(ge.has(a)||B().some((d)=>d.blob===a)||[...me.values()].includes(a)))return he.delete(a),zn(a),!1;if(!n.durable)return!1;if(he.delete(a),B().some((d)=>d.blob===a))Fs();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 zn(e){Ye().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function Pe(e,t){for(let n of e)if(ge.delete(n),he.delete(n),Je.delete(n),t)zn(n)}var Pt=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];async function $s(e){if(!E().getString(Fn))return;let t=Ye(),n=S()?.sessionId;try{let r=await t.keys(),o=0;for(let i of r)if(e?i.startsWith(`${e}/`):!n||!i.startsWith(`${n}/`))await t.delete(i);else o++;if(o===0&&!S())E().remove(Fn)}catch(r){console.warn("vitrinka: blob journal cleanup failed",r)}}var hd=0,zs="",Ks=0,Ls=-1;function Kn(){hd=Date.now(),Ks=0,zs=""}function Ie(e){Ks++,zs=String(e instanceof Error?e.message:e).slice(0,200)}var Ps={actions:0,pages:0,frames:0,notes:0},gd=new Set;function md(e){let t={...Ps};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")gd.add(n.payload.cid)}Ps=t}function bd(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;_t(t),console.warn("vitrinka: session marked dead —",e),_()}var _n=null;function yd(){if(_n)clearInterval(_n);_n=null}function qs(e){let t=S();if(!t||t.dead||e<1)return null;let n=j("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return E().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,_t(t),{seq:r,sessionId:t.sessionId}}var Ws=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,It="allocation.",kd=0,I=new Set,vd=16777216,Ze=0,Qe=0,re=new Map;function Bt(e){return e.kind==="event"?1+(e.images?.length??0):1}function wd(e,t){return new Set(Array.from({length:Bt(t)},(n,r)=>e+r))}function qn(e,t,n){return JSON.stringify(n&&n.size<Bt(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var Is=!1,Xe=null;function At(e){if(!I.delete(e))return;if(Ze-=e.bytes,e.draft.kind==="chunk")Qe--}function Us(e){if(I.add(e),Ze+=e.bytes,e.draft.kind==="chunk")Qe++;while(I.size>Nn||Ze>vd||Qe>Ds){let t=I.values().next().value;At(t),E().remove(t.key),Pe(Pt(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");Ie(n),console.warn(n.message)}}function js(e=!1){if(Is&&!e)return;Is=!0;let t=E();if(!t.withLock)return;let n=new Set([...I].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(It)||n.has(r)||re.has(r))continue;let o=j(r,null);if(o&&o.draft&&o.draft.sessionId===S()?.sessionId)Us({...o,key:r,persisted:!0,bytes:Oe(JSON.stringify(o))})}}function Vs(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,p=l.length?{...e.event,payload:{...e.event.payload,attachments:l.map((u,f)=>t+f)}}:e.event,h=Me();if(a(d)&&!h.some((u)=>u.seq===d))h.push({seq:d,ts:r,tabId:o,tabHost:i,...p});if(l.length){let u=B();l.forEach((g,y)=>{let b=t+y;if(!a(b)||u.some((k)=>k.seq===b))return;if(h.some((k)=>k.seq===b)){me.set(b,g.blob);return}u.push({seq:b,ts:r,tabId:o,tabHost:i,sessionId:s,blob:g.blob,payload:g.payload})});let f=u.reduce((g,y)=>g+y.payload.bytes,0);while(u.length>dd||f>ud){let g=u.shift();f-=g.payload.bytes,ne(g.sessionId,new Set([g.seq])),Pe([g.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${g.payload.name} (seq ${g.seq}); its note lands without it`)}$n(u)}if(h.length>Nn){let u=h.splice(0,h.length-Nn);ne(s,new Set(u.map((f)=>f.seq))),console.warn(`vitrinka: retry buffer full — dropped ${u.length} oldest events`)}}else{let l=de();if(!l.some((d)=>d.seq===t)&&!Me().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),Le+=e.part.body.length;while(l.length>Ds){let d=l.shift();Le-=d.body.length,ne(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}Bs(),ue()}function ne(e,t){for(let[n,r]of re){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?j(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)V(n,qn(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){E().remove(n),re.delete(n);let s=n.slice(It.length,n.lastIndexOf(".")),a=`tab.${s}`,l=j(a,null);if(l?.departed&&l.recoverable&&!E().keys?.().some((d)=>d.startsWith(`${It}${s}.`)))E().remove(a)}}}function Ys(){if(Xe)return Xe;let e=E();return Xe=Wn(Promise.resolve().then(async()=>{for(let t of I)await e.withLock("seq",()=>{if(!I.has(t))return;if(t.persisted){let o=j(t.key,null);if(!o){At(t),Pe(Pt(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(ld(e.getString(Mt)??null),S()?.sessionId!==t.draft.sessionId){At(t),Pe(Pt(t.draft),!0);return}let n=t.seq??qs(Bt(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):wd(n,t.draft);if(t.persisted)e.set(t.key,qn(t.draft,n,r));re.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),Vs(t.draft,n,r),At(t)})}).catch((t)=>{throw Ie(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),ue(),_(),t})).finally(()=>{Xe=null}),Xe}function Xs(e,t){let n=S(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(js(),E().withLock){let o=`${It}${Ws}.${++kd}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&V(o,i),bytes:Oe(i)};Us(s),Ys(),t?.then((a)=>{if(a)xd(s)})}else{let o=qs(Bt(e));if(o)Vs(e,o.seq);else Pe(Pt(e),!0)}return!0}function xd(e){let t=re.get(e.key);if(t)t.persisted=V(e.key,qn(e.draft,e.seq,t.seqs));else if(I.has(e))e.persisted=V(e.key,JSON.stringify({draft:e.draft}))}var Os=new Set;function Wn(e){return Os.add(e),e.catch(()=>{return}).finally(()=>{Os.delete(e)})}function te(e){return S()?.sessionId!==e.sessionId}function et(e,t,n,r=[]){if(Ke.following)return null;let o=S();if(!o)return Cs(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?fd(o.sessionId,r):null;return Xs({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),Un(),i}function Gs(e){Me().push(e),Un(),Bs(),ue()}var Sd=Date.now();function Un(){Sd=Date.now()}function jn(e,t=ed,n=td){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),p=Oe(d)+1;if(p>n){o.push(p);continue}if(p>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+p>t)a();i.push(d),s+=p}return a(),{parts:r,dropped:o}}function Js(e,t){if(!e.length)return 0;let n=S();if(!n||n.paused||n.dead||Ke.following)return 0;let{parts:r,dropped:o}=jn(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),et("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(!Xs({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return Un(),r.length}async function Rd(e=5){let t=de();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 Vi(n.sessionId,i.seq,i.body);if(te(n))return de().length===0;Gs({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),Kn(),o.add(i.seq)}catch(s){if(te(n))return de().length===0;if(s instanceof C&&q(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),ne(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}Ie(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Hs(de().filter((i)=>!o.has(i.seq)));return de().length===0}async function Ed(e=4){let t=B();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=ge.get(s.blob)??null;if(!a){try{a=await Ye().get(s.blob),Je.delete(s.blob)}catch(l){if(te(n))return B().length===0;let d=(Je.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${As})`,l),d<As){Je.set(s.blob,d),Ie(l);break}}if(te(n))return B().length===0}if(!a){console.warn(`vitrinka: attachment seq ${s.seq} (${s.payload.name}) lost its bytes — its note lands without it`),ne(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await Yi(n.sessionId,s.seq,a);if(te(n))return B().length===0;Gs({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),ge.delete(s.blob),me.set(s.seq,s.blob),Kn(),o.add(s.seq)}catch(l){if(te(n))return B().length===0;if(l instanceof C&&q(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),ne(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}Ie(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)Dt(),$n(B().filter((s)=>!o.has(s.seq)));return Pe(i,!0),B().length===0}var Dn=null;function ue(){if(Dn)return;Dn=setTimeout(()=>{Dn=null,Cd()},Xc)}var Bn=!1;async function Cd(e={}){if(Bn)return!1;Bn=!0;try{return await Td(e)}finally{Bn=!1}}async function Td(e){if(S()?.dead)return!1;if(js(!0),I.size)await Ys();if(I.size)return!1;let t=await Rd(),n=e.keepalive?B().length===0:await Ed(),r=t&&n;if(!r)ue();let o=S(),i=Me();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:Jc;for(let u of i){if(s.length>=Ot)break;let f=Oe(JSON.stringify(u))+1;if(f>Zc){console.warn(`vitrinka: event seq ${u.seq} (${f} bytes) exceeds the wire cap — dropped`),a.add(u.seq);continue}if(f>d){if(e.keepalive)break;if(s.length===0)s.push(u),l=f;break}if(s.length>0&&l+f>d)break;s.push(u),l+=f}if(a.size){if(ne(o.sessionId,a),Hn(Me().filter((u)=>!a.has(u.seq))),!s.length)return ue(),!1}if(!s.length)return!1;Dt();try{await X("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(u){if(te(o))return!1;if(u instanceof C&&q(u.status))return bd(`server rejected this session (${u.status})`),!1;return Ie(u),_(),console.warn("vitrinka: flush failed, retrying",u),ue(),!1}if(te(o))return!0;Kn(),Ls=Math.max(Ls,...s.map((u)=>u.seq)),md(s);let p=new Set(s.map((u)=>u.seq));ne(o.sessionId,p);let h=Me().filter((u)=>!p.has(u.seq));Hn(h),_();for(let u of p){let f=me.get(u);if(f===void 0)continue;me.delete(u),zn(f)}if(h.length)ue();return!0}function Zs(){for(let e of re.keys())E().remove(e);for(let e of I)E().remove(e.key);re.clear(),I.clear(),Ze=Qe=0,Hn([]),Hs([]),ge.clear(),he.clear(),me.clear(),Je.clear(),$n([])}function _s(){if(U)clearTimeout(U),U=null;fe=[],Ae=[],Le=0,Lt=[],ge.clear(),he.clear(),me.clear(),I.clear(),Ze=Qe=0,re.clear(),oe=!0}var Qs="0.10.0";var Xp={from:"page",inst:Wi("p")};var Ad=!1;function ea(){return Ad}var na="vitrinka.report.face",ta=(e)=>e.trim().replace(/\/+$/,"");function Nt(){try{return globalThis.localStorage??null}catch{return null}}function _e(e){let t=ae();if(!t)return!1;if(t.base)return ta(t.base)===ta(e);try{let n=kt(e);return n===void 0||n===t.workspace}catch{return!1}}function be(e){return _e(e)?ae()?.token??"":""}function ra(e){return/revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(e)}function Md(){let e=Nt()?.getItem(na);return e==="recorder"||e==="report"?e:null}function Vn(e){try{Nt()?.setItem(na,e)}catch(t){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",t)}}var oa="vitrinka.report.mode";function ia(e){try{if(e==="dev"||e==="regular")Nt()?.setItem(oa,e)}catch(t){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",t)}}function sa(e){if(!_e(e))return"report";let t=Md();if(t)return t;return Nt()?.getItem(oa)==="dev"?"recorder":"report"}function aa(){return S()!==null||ea()}function Ht(e){let t=A().watch?.(Ue,()=>e()),n=Hi(e);return()=>{t?.(),n()}}var la=["bug","suggestion","question","other"];function De(e,t,n,r){if(e===1)return t;if(e>=2&&e<=4)return n;return r}var Ld={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",kinds:{bug:"Bug",suggestion:"Suggestion",question:"Question",other:"Other"},kindsLabel:"What is it?",linesEmpty:"Each place you mark gets a line here for its note.",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:"Cover"},toolbar:"Marking tools",barLead:"Mark where the problem is",barLeadHide:"Cover what the team shouldn’t see",cancelMarking:"Cancel",discardMarks:(e)=>e===1?"Discard 1 mark?":`Discard ${e} marks?`,discard:"Discard",keep:"Keep",coach:{box:"Click, hold and move across the problem.",circle:"Click, hold and move around the problem.",arrow:"Click, hold and move from a clear spot to the problem.",hide:"Click, hold and move across anything private — it stays blank in what you send."},coachMore:"You can mark more than one place.",coachDismiss:"Got it, don’t show again",coachSetting:"Marking tips",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Covered — not sent",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",account:"Your account",menu:"Menu",anonymous:"Not signed in",anonymousHint:"The team checks your report before it’s filed.",signedInByApp:"Signed in by this app",linkVitrinka:"Link your vitrinka account",linkedAs:(e)=>`Linked to vitrinka as ${e}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(e)=>`Remove ${e}`,fileTooBig:(e,t)=>`${e} is over the ${t} limit`,tooManyFiles:(e)=>e===1?"Up to 1 file per report":`Up to ${e} files per report`,fileType:(e,t)=>`${e} can’t be attached — ${t} only`,typeNames:{image:"images",pdf:"PDF",text:"text files",office:"office documents"},incFiles:"The files you attached",errorFiles:"Your report arrived, a file not yet — try again to attach it",moveHint:"Click, hold and move it to another corner, or press Alt and an arrow key.",size:"Size",sizes:{sm:"Small",md:"Medium",lg:"Large"},techDetails:"Technical details",techVersion:"Version",techWindow:"Capture window",techCapture:"Capture",techBuffer:"Buffer",techServer:"Server",captureOn:"Running",captureOff:"Off",captureStarting:"Starting…",bufferMemory:"In memory",bufferBrowser:"In this browser",windowLength:(e)=>{if(e<60)return e===1?"1 second":`${e} seconds`;let t=Math.round(e/60);return t===1?"1 minute":`${t} minutes`}},Pd={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 De(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 De(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",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Dotaz",other:"Jiné"},kindsLabel:"Co to je?",linesEmpty:"Každé označené místo tu dostane řádek pro poznámku.",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:"Zakrýt"},toolbar:"Nástroje pro označení",barLead:"Označte, kde je problém",barLeadHide:"Zakryjte, co tým nemá vidět",cancelMarking:"Zrušit",discardMarks:(e)=>De(e,"Zahodit 1 značku?",`Zahodit ${e} značky?`,`Zahodit ${e} značek?`),discard:"Zahodit",keep:"Ponechat",coach:{box:"Klikněte, podržte a veďte přes problém.",circle:"Klikněte, podržte a veďte kolem problému.",arrow:"Klikněte, podržte a veďte z volného místa k problému.",hide:"Klikněte, podržte a veďte přes vše soukromé — v hlášení zůstane prázdné."},coachMore:"Označit můžete i více míst.",coachDismiss:"Chápu, už nezobrazovat",coachSetting:"Nápověda při označování",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Zakryto — neodešle se",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",account:"Váš účet",menu:"Nabídka",anonymous:"Nepřihlášeno",anonymousHint:"Hlášení nejdřív zkontroluje tým.",signedInByApp:"Přihlášen touto aplikací",linkVitrinka:"Propojit s vitrinkou",linkedAs:(e)=>`Propojeno s vitrinkou jako ${e}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(e)=>`Odebrat ${e}`,fileTooBig:(e,t)=>`${e} přesahuje limit ${t}`,tooManyFiles:(e)=>De(e,"Nejvýš 1 soubor na hlášení",`Nejvýš ${e} soubory na hlášení`,`Nejvýš ${e} souborů na hlášení`),fileType:(e,t)=>`${e} nelze přiložit — jen ${t}`,typeNames:{image:"obrázky",pdf:"PDF",text:"textové soubory",office:"kancelářské dokumenty"},incFiles:"Soubory, které jste přiložili",errorFiles:"Hlášení dorazilo, soubor zatím ne — zkuste to znovu a přiložíme ho",moveHint:"Klikněte, podržte a veďte ho do jiného rohu, nebo stiskněte Alt a šipku.",size:"Velikost",sizes:{sm:"Malá",md:"Střední",lg:"Velká"},techDetails:"Technické údaje",techVersion:"Verze",techWindow:"Okno záznamu",techCapture:"Záznam",techBuffer:"Vyrovnávací paměť",techServer:"Server",captureOn:"Běží",captureOff:"Vypnutý",captureStarting:"Spouští se…",bufferMemory:"V paměti",bufferBrowser:"V tomto prohlížeči",windowLength:(e)=>{if(e<60)return De(e,"1 sekunda",`${e} sekundy`,`${e} sekund`);let t=Math.round(e/60);return De(t,"1 minuta",`${t} minuty`,`${t} minut`)}},Id={cs:Pd,en:Ld};function Yn(e){return Id[e]}function tt(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"?t:null}function Xn(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=tt(n);if(r)return r}return"en"}var ca="recents",da=5,Od=["recording","saved","unsaved","deleted"];function _d(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.sessionId==="string"&&typeof t.title==="string"&&typeof t.startedAt==="number"&&Od.includes(t.status)}var Be;function Gn(){if(Be===void 0)try{let e=JSON.parse(A().getString(ca)??"[]");Be=Array.isArray(e)?e.filter(_d).slice(0,da):[]}catch{Be=[]}return Be}function Dd(e){Be=e.slice(0,da);try{A().set(ca,JSON.stringify(Be))}catch(t){console.warn("vitrinka: could not store recent recordings",t)}_()}function ua(e,t){let n=Gn();if(!n.some((r)=>r.sessionId===e))return;Dd(n.map((r)=>r.sessionId===e?{...r,...t}:r))}var nt="data-vitrinka-recorder";var Jn="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;",pa=Jn;var Bd=["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 ma(e){for(let t of Bd)e.addEventListener(t,(n)=>n.stopPropagation())}var Nd=["keydown","keyup","keypress"],Hd=["vitrinkaHud","vitrinkaSheet"],fa=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Fd=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),$d=new Set(["text","search","email","url","tel","password","number"]);function zd(e){let t=e.key.length===1;if(t&&e.getModifierState?.("AltGraph"))return!0;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return t||fa.has(e.key);if(fa.has(e.key))return!0;return(e.ctrlKey||e.metaKey)&&!e.altKey&&Fd.has(e.code)}function Kd(e){if(typeof e!=="object"||e===null)return!1;if("isContentEditable"in e&&e.isContentEditable===!0)return!0;let t="tagName"in e&&typeof e.tagName==="string"?e.tagName:"";if(t==="TEXTAREA")return!0;return t==="INPUT"&&"type"in e&&typeof e.type==="string"&&$d.has(e.type)}function qd(e){if(typeof e!=="object"||e===null||!("dataset"in e))return!1;let t=e.dataset;return typeof t==="object"&&t!==null&&Hd.some((n)=>(n in t))}function Wd(e){if(!zd(e))return!1;let t=e.composedPath();return Kd(t[0])&&t.some(qd)}var ha=0,Ft=null;function ba(){if(ha++,!Ft&&typeof window<"u"){let t=(r)=>{if(Wd(r))r.stopImmediatePropagation()},n=Nd.map((r)=>L(window,r,t,{capture:!0}));Ft=()=>{for(let r of n)r()}}let e=!0;return()=>{if(!e)return;if(e=!1,--ha>0)return;Ft?.(),Ft=null}}function ya(){let e=document.createElement("div");e.setAttribute(nt,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=Jn;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),ma(e);let r=ba();document.documentElement.append(e);let o=typeof e.showPopover==="function",i=()=>{if(!o||!e.isConnected)return;try{e.hidePopover?.()}catch{}try{e.showPopover?.()}catch{}};if(o)e.popover="manual";i();let s=!1,a=()=>{if(s)return;s=!0,queueMicrotask(()=>{s=!1,i()})},l=(f)=>{if(f.type==="attributes")return f.target instanceof Element&&ga(f.target);for(let g of[f.addedNodes,f.removedNodes])for(let y of g){if(!(y instanceof Element))continue;if(ga(y))return!0;if(y.childElementCount>0&&y.querySelector(ka))return!0}return!1},d=[],p=0,h=()=>{p=0;let f=d;if(d=[],f.some(l))a()},u=new MutationObserver((f)=>{for(let g of f)d.push(g);if(p===0)p=typeof requestAnimationFrame==="function"?requestAnimationFrame(h):setTimeout(h,16)});return u.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:e,mount:n,destroy:()=>{if(r(),u.disconnect(),p!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(p);d=[];try{e.hidePopover?.()}catch{}e.remove()}}}var ka='dialog,[role="dialog"]';function ga(e){return e.matches(ka)}function va(){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 wa(e){let t=document.createElement("div");t.setAttribute(nt,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=pa;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");n.append(r),ma(t);let o=ba();if(typeof t.showPopover==="function")t.popover="manual";return e.append(t),t.showPopover?.(),{mount:r,destroy:()=>{o(),t.remove()}}}function xa(e){if(!(e instanceof Node))return!1;let t=e instanceof Element?e:e.parentElement;return Boolean(t?.closest("[data-vitrinka-hud],[data-vitrinka-sheet]"))}var Ud="me";var jd;function Sa(){jd=null,A().remove(Ud)}function Ra(e){if(!e)return 0;let t=e.activeMs||0;if(!e.paused&&e.resumeAt)t+=Date.now()-Date.parse(e.resumeAt);return t}function Ea(){vt(),Sa();let e=S();if(e)ua(e.sessionId,{status:"unsaved",durationMs:Ra(e)}),_t(null),Zs(),$s(e.sessionId);_()}var ie={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function Vd(e,t){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:t}function Ca(e){if(typeof e!=="object"||e===null)return ie;let t={...e},n=Array.isArray(t.types)?t.types.filter((r)=>typeof r==="string"&&r.trim()!=="").map((r)=>r.trim().toLowerCase()):[];return{maxBytes:Vd(t.maxBytes,ie.maxBytes),maxCount:typeof t.maxCount==="number"&&Number.isInteger(t.maxCount)&&t.maxCount>=0?t.maxCount:ie.maxCount,types:n.length?n:ie.types}}function Yd(e,t){let n=e.type.toLowerCase(),r=e.name.toLowerCase();return t.some((o)=>{if(o==="*"||o==="*/*")return!0;if(o.startsWith("."))return r.endsWith(o);if(o.endsWith("/*"))return n.startsWith(o.slice(0,-1));return n===o})}function Xd(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}function Ta(e,t,n){let r=[],o=null;for(let i of t){if([...e,...r].some((s)=>Xd(s,i)))continue;if(!Yd(i,n.types))o??={kind:"type",name:i.name};else if(i.size>n.maxBytes)o??={kind:"size",name:i.name,cap:n.maxBytes};else if(e.length+r.length>=n.maxCount)o??={kind:"count",cap:n.maxCount};else r.push(i)}return{files:r,refusal:o}}function rt(e,t){let n=(r,o,i)=>`${new Intl.NumberFormat(t,{maximumFractionDigits:i}).format(r)} ${o}`;if(e<1024)return n(e,"B",0);if(e<1048576)return n(e/1024,"kB",0);return n(e/1048576,"MB",e<10485760?1:0)}function Aa(e,t,n){let r=(i)=>{if(i.startsWith("image/"))return t.image;if(i==="application/pdf"||i===".pdf")return t.pdf;if(i.startsWith("text/"))return t.text;if(/officedocument|msword|ms-excel|ms-powerpoint|opendocument/.test(i))return t.office;return i.startsWith(".")?i:i.split("/")[1]??i},o=e.map(r);return new Intl.ListFormat(n,{type:"conjunction"}).format([...new Set(o)])}function Ma(e,t){let n=/^image\.(\w+)$/i.exec(e);return n?`pasted-${t}.${n[1]}`:e}var Zn=["sm","md","lg"],ot={sm:0.88,md:1,lg:1.18},Qn="vitrinka.report.size";function La(){try{return globalThis.localStorage??null}catch{return null}}function $t(e){return La()?.getItem(e)??null}function it(e,t){try{La()?.setItem(e,t)}catch(n){console.warn(`vitrinka: could not remember ${e} on this browser`,n)}}function Pa(){let e=$t(Qn);return Zn.find((t)=>t===e)??"md"}var er="vitrinka.report.coach";function Ia(){return $t(er)!=="off"}function Oa(e,t){let n=e.config,r=!e.engine||n?.capturing===!1?t.captureOff:n?t.captureOn:t.captureStarting,o=e.base;try{o=new URL(e.base).host}catch{}return[[t.techVersion,`@vitrinka/web ${e.version}`],[t.techWindow,n?t.windowLength(n.profile.windowSec):"—"],[t.techCapture,r],[t.techBuffer,n?`${n.profile.storage==="browser"?t.bufferBrowser:t.bufferMemory} · ${rt(n.profile.maxBytes,e.locale)}`:"—"],[t.techServer,o]]}var _a="vitrinka.report.dock",Da=6,tr={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},Gd=["br","bl","tr","tl"];function Jd(e){return e==="tl"||e==="tr"?"t":"b"}function Zd(e){return e==="tl"||e==="bl"?"l":"r"}function Ba(){let e=$t(_a);return Gd.find((t)=>t===e)??"br"}function Na(e){it(_a,e)}function Ha(e,t,n){return tr[e.y<n/2?"t":"b"][e.x<t/2?"l":"r"]}function Fa(e,t){if(t==="ArrowLeft"||t==="ArrowRight")return tr[Jd(e)][t==="ArrowLeft"?"l":"r"];if(t==="ArrowUp"||t==="ArrowDown")return tr[t==="ArrowUp"?"t":"b"][Zd(e)];return null}var Qd=8192,st="__vitrinkaRecorderConsolePatched";function zt(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,Qd)}function Kt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;et("console",{level:t,text:ps(e)},{tabId:x.tabId,tabHost:x.tabHost})}var nr="__vitrinkaRecorderConsoleUnpatch",$a={};function za(){let e=globalThis;if(e[st]!==void 0&&e[st]!==$a)return;e[nr]?.()}function Ka(e={}){let t=globalThis;if(t[st])return;t[st]=$a;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{Kt(zt(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let p=console[d],h=p.bind(console),u=(...f)=>{h(...f);try{Kt(zt(f),d)}catch{}};return console[d]=u,()=>{if(console[d]===u)console[d]=p}}),s=(d)=>{try{Kt(zt([d.error??d.message]))}catch{}},a=(d)=>{try{Kt(`unhandled rejection: ${zt([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[nr]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[st],delete t[nr]}}var qa=65536,at=524288,Wa=3000;var rr="full";function ir(){if(Ke.following)return null;let e=S();if(e)return!e.paused&&!e.dead?e.sessionId:null;return Rs()}function lt(e){return e!==null&&ir()===e}function qt(e,t){if(typeof e==="string")return wn(e,qa,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return wn(e.toString(),qa,"application/x-www-form-urlencoded");return eu(e)}function eu(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 or(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function sr(e){return typeof e==="string"||e instanceof URL?{}:e}function ct(e){let t=typeof e.url==="string"?le(e.url):e.url;et("net",{...e,url:t},{tabId:x.tabId,tabHost:x.tabHost})}function ar(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 tu(e,t){let n=ar(t?.headers);if(n)return n;let r=sr(e);return ar(r.headers)}function nu(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 lr(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function ru(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function ou(e,t){let n=await iu(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return qt(n,r)}async function iu(e,t){let n=ru(t);if(n!==null&&n>at)return lr(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()+Wa;try{while(s<at){let f=d-Date.now();if(f<=0){l=!0;break}let g,y=await Promise.race([o.read(),new Promise((w)=>{g=setTimeout(()=>w("timeout"),f)})]).finally(()=>{if(g!==void 0)clearTimeout(g)});if(y==="timeout"){l=!0;break}let{done:b,value:k}=y;if(b)break;if(k){let w=at-s,m=k.byteLength>w?k.subarray(0,w):k;i.push(m),s+=m.byteLength}}a=s>=at,o.cancel().catch(()=>{return})}catch{return}let p=new Uint8Array(s),h=0;for(let f of i)p.set(f,h),h+=f.byteLength;let u;try{u=new TextDecoder().decode(p)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${u}…[body read timed out after ${Wa}ms]`;return a?`${u}…[truncated at ${at} bytes]`:u}if(n===null)return lr(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var dt="__vitrinkaRecorderNetPatched",cr="__vitrinkaRecorderNetUnpatch",Ua={};function ja(){let e=globalThis;if(e[dt]!==void 0&&e[dt]!==Ua)return;e[cr]?.()}function Va(e={}){let t=globalThis;if(t[dt])return;t[dt]=Ua,rr=e.detail??"full";let n=[];t[cr]=()=>{for(let u of n.splice(0))u();delete t[dt],delete t[cr]};let r=globalThis.fetch,o=async(u,f)=>{let g=typeof u==="string"?u:u instanceof URL?u.href:u.url,y=ir();if(fn(g)||y===null)return r(u,f);let b=f?.method??("method"in sr(u)?sr(u).method:"GET"),k=Date.now();try{let w=await r(u,f),m=Date.now()-k;if(rr==="meta"){if(lt(y))ct({method:b,url:g,status:w.status,ms:m,via:"fetch"});return w}let M;try{M=w.clone()}catch{M=void 0}let{headers:Ne,status:He}=w;return Wn((async()=>{if(!lt(y)){if(M)lr(M);return}let mt=M?await ou(M,Ne):void 0;if(!lt(y))return;let Fe=tu(u,f);ct({method:b,url:g,status:He,ms:m,reqHeaders:je(Fe),resHeaders:je(ar(Ne)),reqBody:qt(f?.body,or(Fe)),resBody:mt,via:"fetch"})})()),w}catch(w){if(lt(y))ct({method:b,url:g,error:String(w),ms:Date.now()-k,via:"fetch"});throw w}};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 u=i.prototype;if(u.open===d)u.open=s;if(u.send===h)u.send=a;if(u.setRequestHeader===p)u.setRequestHeader=l});let d=i.prototype.open=function(...u){return this.__vt={method:u[0],url:String(u[1])},s.apply(this,u)},p=i.prototype.setRequestHeader=function(u,f){let g=this.__vt;if(g)(g.reqHeaders??={})[u]=f;return l?.call(this,u,f)},h=i.prototype.send=function(u){let f=this.__vt,g=ir();if(f&&!fn(f.url)&&g!==null){let y=Date.now();this.addEventListener("loadend",()=>{if(!lt(g))return;if(rr==="meta"){ct({method:f.method,url:f.url,status:this.status,ms:Date.now()-y,via:"xhr"});return}let b;try{b=nu(this.getAllResponseHeaders())}catch{b=void 0}let k;try{k=this.responseType===""||this.responseType==="text"?qt(this.responseText,or(b)):void 0}catch{k=void 0}ct({method:f.method,url:f.url,status:this.status,ms:Date.now()-y,reqHeaders:je(f.reqHeaders),resHeaders:je(b),reqBody:qt(u,or(f.reqHeaders)),resBody:k,via:"xhr"})})}return a.call(this,u)}}var su=2000,au=300000,pt=null,ft=null,ut=[],Wt=null;function Ya(){if(!ut.length)return;let e=ut;ut=[],Js(e,{tabId:x.tabId,tabHost:x.tabHost})}function ht(){return ft}function Xa(e,t,n={}){if(pt)return;let r=hs(),o=n.unmaskSelector;try{pt=e({emit:t==="flight"?(s)=>Es(Rn(s)):(s)=>{ut.push(Rn(s))},checkoutEveryNms:t==="flight"?vs().checkoutMs:au,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:`[${nt}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(ft=e,t==="flight")Mn(Ut);if(t==="session")Wt=setInterval(Ya,su)}function Ga(){if(Wt)clearInterval(Wt);Wt=null,Ya();try{pt?.()}catch{}pt=null,ft=null,Mn(null),ut=[]}function Ut(){if(!pt||!ft)return;try{ft.takeFullSnapshot?.(!0)}catch{}}var Qa="vitrinka.capture",N="windows",H="chunks";function ye(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function dr(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function Ja(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function Za(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 el(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(Qa,1);r.onupgradeneeded=()=>{r.result.createObjectStore(N,{keyPath:"id"}),r.result.createObjectStore(H)},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(N).delete(i),o.objectStore(H).delete(Ja(i))};return{async putWindow(o){let i=t.transaction(N,"readwrite");i.objectStore(N).put(o),await ye(i)},async putChunk(o,i,s,a){let l=t.transaction(H,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(H).put(d,[o,i]),await ye(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([N,H],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(H).put(d,[o.id,i]),l.objectStore(N).put(o)}catch(p){throw l.abort(),p}await ye(l)},async dropWindow(o){let i=t.transaction([N,H],"readwrite");n(i,o),await ye(i)},async clear(o){let i=t.transaction([N,H],"readwrite"),s=await dr(i.objectStore(N).getAll());for(let a of s)if(Za(a)&&a.tab===o)n(i,a.id);await ye(i)},async sweep(o,i,s,a){let l=t.transaction([N,H],"readwrite"),d=(await dr(l.objectStore(N).getAll())).filter(Za),p=[],h=new Map;for(let u of d)h.set(u.tab,[...h.get(u.tab)??[],u]);for(let[u,f]of h){let g=f.filter((b)=>b.kind!=="lanes").sort((b,k)=>b.startMs-k.startMs),y=(b)=>b.kind==="lanes"?b.lastMs:An(b,g[g.indexOf(b)+1]);for(let b of f.sort((k,w)=>k.startMs-w.startMs))if(y(b)<=o-i||u===s&&b.scope!==a)n(l,b.id);else if(u===s)p.push(b)}return await ye(l),p},async read(o){let i=t.transaction(H,"readonly"),s=await dr(i.objectStore(H).getAll(Ja(o)));await ye(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 tl(e=globalThis.indexedDB){try{e?.deleteDatabase(Qa)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function ur(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 pr(e,t){return`${t.y<e.y?"n":"s"}${t.x<e.x?"w":"e"}`}function fr(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 nl(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 rl(e){return e.map((t,n)=>({...t,n:n+1}))}function ol(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 lu=2,cu=3,du=0,uu=5,hr=2,pu=3,fu=2000000000,hu="data-vitrinka-hidden",gu="#1b1b1f";function mu(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:${gu};z-index:2147483647;pointer-events:none;`;return{type:hr,id:fu+t,tagName:"div",attributes:{[hu]:"",style:n},childNodes:[]}}function gr(e,t,n,r){let o={...e};if(e.type===pu&&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)=>gr(i,t,n,r)),!r.done&&e.type===hr&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function bu(e,t){(e.childNodes?.find((r)=>r.type===hr)??e).childNodes?.push(...t)}function yu(e,t){return gr(e,t,[],{done:!0})}function il(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map(mu);return e.map((o)=>{let i=o.data;if(o.type===lu&&i.node){let s={done:!1},a=gr(i.node,n,r,s);if(!s.done)bu(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==cu||!n.size)return o;if(i.source===du){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:yu(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===uu){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function ku(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function vu(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function mr(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)=>ku(vu(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 wu=["errors","interactions","full","console","network"];var jt={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function Xt(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function Vt(e,t,n){return Math.min(n,Math.max(t,e))}function xu(e){if(!Array.isArray(e))return null;return wu.filter((t)=>e.includes(t))}function sl(e,t){if(typeof e!=="object"||e===null)return Xt(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":jt.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?Vt(Math.round(n.windowSec),10,3600):jt.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?Vt(Math.round(n.maxBytes),262144,67108864):jt.maxBytes,classes:xu(n.classes)??jt.classes}}function Yt(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 Su(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 al(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=Yt(e.classes),s=Yt(t.classes);o=Su({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:Vt(n,10,3600),maxBytes:Vt(r,262144,67108864),classes:o}}function ll(e){return e==="balanced"||e==="full"?e:"strict"}function cl(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var dl="[data-vitrinka-unmask]";var Ru=3670016,ul=4194240,Eu=2000,pl=500,Cu=60000,Tu=/[A-Za-z0-9_-]{20,}/g;function Y(e,t=""){return typeof e==="string"?e:t}function Au(e){let t=Y(e),n;try{n=new URL(t,globalThis.location?.href??"http://localhost").pathname}catch{n=t.split(/[?#]/)[0]??""}return n.replace(Tu,"•••").slice(0,300)}var Mu=4;function Lu(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===Mu&&o.length)s();if(!i&&Oe(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}function Pu(e){return(t,n)=>{if(t==="console"){let r=Y(n?.level,"error");if(r==="error"?!(e.errors||e.console):!e.console)return null;return{level:r,text:Y(n?.text).slice(0,Eu)}}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:Y(n?.method,"GET").toUpperCase(),path:Au(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}async function Iu(e){try{let t=await X("GET","/api/v1/report-config",void 0,{target:e}),n=typeof t.flightRecorder==="boolean"?t.flightRecorder:void 0;return{project:Y(t.project),profile:t.captureProfile==null?Xt(n):sl(t.captureProfile,n),masking:ll(t.profile),reachable:!0,attachments:Ca(typeof t.captureProfile==="object"&&t.captureProfile!==null&&"attachments"in t.captureProfile?t.captureProfile.attachments:t.attachments)}}catch(t){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",t),{project:"",profile:Xt(),masking:"strict",reachable:!1,attachments:ie}}}function fl(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 hl{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(Ki(e.base));let t=await Iu({url:e.base,key:e.key}),n=al(t.profile,e.capture),r=Yt(n.classes),o={project:t.project,profile:n,lanes:r,masking:t.masking,reachable:t.reachable,capturing:!1,attachments:t.attachments};if(this.stopped)return o;if(this.config=o,this.claim=Bi("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,Di(_i(),globalThis.location?.host??""),x.pathname=globalThis.location?.pathname??"/",us(cl(o.masking)),xn(e.sanitizeUrl),this.capture.push(()=>xn(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 el();let d=await this.store.sweep(Date.now(),i,x.tabId,s);a=d;let p=this.store;l=(await Promise.all(d.filter((u)=>u.kind==="lanes").map((u)=>p.read(u.id)))).flatMap((u)=>u.lanes).sort((u,f)=>Date.parse(u.ts)-Date.parse(f.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else tl();if(!this.capturing)return this.store?.close(),this.store=null,o;if(ys({windowMs:i,checkoutMs:Math.min(Cu,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:Tn,keepLane:Pu(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(ks),this.store&&typeof window<"u"){let d=()=>Et();this.capture.push(L(window,"pagehide",d),L(document,"visibilitychange",d))}if(r.errors||r.console)Ka({levels:r.console?["warn","info","log"]:[]}),this.capture.push(za);if(r.errors||r.network)Va({detail:"meta"}),this.capture.push(ja);if(r.replay){let d=await e.loadRecord(e.base).catch((p)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",p),null));if(d&&this.capturing)Xa(d,"flight",{unmaskSelector:dl}),this.capture.push(Ga)}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)xs().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};x.pathname=globalThis.location?.pathname??x.pathname;let e=Tt();if(e&&ht()&&!In(e))Ut(),e=Tt();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}}withScreen(e){if(!this.capturing||!ht()||e&&In(e))return e;Ut();let t=Tt();if(!t)return e;return{windows:[...e?.windows.filter((n)=>n.stored)??[],...t.windows.filter((n)=>!n.stored)],lanes:e?.lanes??t.lanes,truncated:e?.truncated??t.truncated}}hiddenIdsAt(e){if(!this.capturing)return null;let t=fl(ht());return t?mr([e],t):null}async build(e,t,n=new Set){let r=t.filter((m)=>m.shape==="hide").map((m)=>m.rect),o=fl(ht()),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 m of mr(r,o))s.add(m);let a=[],l=this.withScreen(e.clip),d=l?.truncated??!1,p=await e.stored.catch((m)=>(console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",m),null));for(let m of l?.windows??[]){if(!m.stored){a.push(...m.events);continue}let M=p?.get(m.id);if(!M?.events.length)d=!0;else a.push(...M.events)}let h=l?.lanes??[],u=i?{events:[],dropped:!1}:Lu(il(a,r,s),ul);if(u.dropped)d=!0;let{parts:f,dropped:g}=jn(u.events,Ru,ul),y=[],b=0;for(let m of f){b+=m.count;let M=u.events[b-1]?.timestamp??Date.now();y.push({seq:y.length+1,ts:new Date(M).toISOString(),count:m.count,body:m.body})}let k=h.filter((m)=>m.kind==="console").slice(-pl).map((m)=>({level:Y(m.payload?.level,"error"),ts:m.ts,text:Y(m.payload?.text)})),w=h.filter((m)=>m.kind==="net").slice(-pl).map((m)=>({method:Y(m.payload?.method,"GET"),path:Y(m.payload?.path),status:typeof m.payload?.status==="number"?m.payload.status:0,ms:typeof m.payload?.ms==="number"?m.payload.ms:0}));return{chunks:y,truncated:d||g.length>0,console:k,network:w}}clear(){if(this.capturing)ws()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),Ni(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var z=null;function gl(e){if(z){let t=z.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 z.refs++,z.engine}return z={engine:new hl(e),refs:1},z.engine}function ml(e){if(!e||!z||z.engine!==e)return;if(--z.refs>0)return;z=null,e.stop()}var Ou=/^[\w-]+\.[\w-]+\.[\w-]+$/;function Gt(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!Ou.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 bl=null,br=new Set;function _u(e){bl=Gt(e);for(let t of br)t()}function yl(){return bl}function kl(e){return br.add(e),()=>br.delete(e)}var Du=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),yr="report.keybind";function vl(e){if(Du.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 wl(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var Bu={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function xl(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 Bu[e]??e}function Nu(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function Jt(e,t=Nu()){let n=xl(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 Sl(e){return[e.ctrl&&"Control",e.alt&&"Alt",e.shift&&"Shift",e.meta&&"Meta",xl(e.code)].filter(Boolean).join("+")}function Hu(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}}var Fu={code:"KeyA",alt:!0,ctrl:!1,meta:!1,shift:!0},Rl="off";function El(e){if(e===Rl)return null;return Hu(e)??Fu}function Cl(){return El(A().getString(yr))}function kr(e){A().set(yr,e?JSON.stringify(e):Rl)}function Tl(e){let t=A();return t.watch?t.watch(yr,(n)=>e(El(n))):()=>{return}}var $u=["br","bl","tr","tl"];function vr(e,t){let n=e==="br"||e==="tr"?t.vw-t.w-t.edge:t.edge,r=e==="br"||e==="bl"?t.vh-t.h-t.bottom:t.top;return{x:Math.max(t.edge,n),y:Math.max(t.top,r),w:t.w,h:t.h}}function zu(e,t){let n=Math.min(e.x+e.w,t.x+t.w+12)-Math.max(e.x,t.x-12),r=Math.min(e.y+e.h,t.y+t.h+12)-Math.max(e.y,t.y-12);return n>0&&r>0?n*r:0}function Al(e,t,n){let r=vr(e,n);return t.reduce((o,i)=>o+zu(r,i),0)}function Ml(e,t,n){let r=Al(e,t,n);if(r===0)return e;let o=e,i=r;for(let s of $u){let a=Al(s,t,n);if(a<i)o=s,i=a}return o}function Ll(e,t,n,r){let o=e==="br"||e==="bl";if(t.vh-t.top-t.h-t.bottom>=n.h+r)return o?"above":"below";if(t.vw-2*t.edge-t.w>=n.w+r)return e==="br"||e==="tr"?"left":"right";return"over"}function xr(e){if(!(e instanceof C)||e.status!==400)return"";return/unknown field \\?"(\w+)\\?"/.exec(e.message)?.[1]??""}var Pl={ms:30000,bytesPerMs:32};class Il extends Error{constructor(e,t){super(`vitrinka: ${e} got no answer in ${Math.round(t/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function wr(e,t,n){let r=new AbortController,o,i=new Promise((s,a)=>{o=setTimeout(()=>{let l=new Il(e,t);r.abort(l),a(l)},t)});try{return await Promise.race([n(r.signal),i])}finally{clearTimeout(o)}}var Sr={chunks:[],truncated:!1,console:[],network:[]};function Ol(e,t=Pl.ms){return wr("preparing the capture",t,e).catch((n)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",n),Sr))}class Rr{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(e,t,n,r=[],o=Pl){this.capture=e;this.tabHost=t;this.target=n;this.files=r;this.limits=o}call(e,t,n){return wr(`${e} ${t}`,this.limits.ms,(r)=>X(e,t,n,{target:this.target,signal:r}))}upload(e,t,n){let r=typeof n==="string"?new TextEncoder().encode(n).byteLength:n.size,o=this.limits.ms+Math.ceil(r/this.limits.bytesPerMs);return wr(`POST ${e}`,o,(i)=>mn(e,t,n,this.target,i))}get filesPending(){return this.filesDone.size<this.files.length}async run(e,t){let n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let{res:i,memberSent:s}=await this.create(e);if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");if(this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r,typeof i.memberError==="string"&&i.memberError)t?.(i.memberError,s)}else if(this.sent!==r)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n),this.sent=r;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof C)||!q(i.status))throw i;console.warn("vitrinka: the server refused the recording — the report goes without it",i),this.skipCapture=!0}let o=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async create(e){let t=e;for(;;)try{return{res:await this.call("POST","/api/v1/reports",t),memberSent:t.memberToken??""}}catch(n){let r=xr(n);if(r==="type"&&t.type!==void 0){console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:o,...i}=t;t=i}else if(r==="memberToken"&&t.memberToken!==void 0){console.warn("vitrinka: this server takes no member link yet — sending the report without it");let{memberToken:o,...i}=t;t=i}else if(r==="context"&&t.context!==void 0){console.warn("vitrinka: this server takes no report context yet; sending the report without it");let{context:o,...i}=t;t=i}else throw n}}async sendFiles(){let e=encodeURIComponent(this.id);for(let[t,n]of this.files.entries()){if(this.filesDone.has(t))continue;try{await this.upload(`/api/v1/reports/${e}/attachment?name=${encodeURIComponent(n.name)}`,n.type||"application/octet-stream",n)}catch(r){if(!(r instanceof C)||!q(r.status))throw r;console.warn(`vitrinka: the server refused ${n.name} — the report goes without it`,r)}this.filesDone.add(t)}}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 this.upload(`/api/v1/reports/${e}/chunk?seq=${o.seq}`,"application/json",o.body);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+Ot);await this.call("POST",`/api/v1/reports/${e}/events`,{events:o}),this.rowsPosted+=o.length}}}async function Zt(e,t,n,r,o){let i=await fetch(n.url+t,{method:e,mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${n.key}`,...o?{"x-vitrinka-reporter":o}:{},...r!==void 0?{"content-type":"application/json"}:{}},body:r===void 0?void 0:JSON.stringify(r)}),s=await i.text();if(!i.ok)throw new C(`${e} ${t} → ${i.status}: ${s}`,i.status);return s?JSON.parse(s):{}}async function _l(e,t,n=""){if(!n)return Zt("POST","/api/v1/report/session",e,{token:t});try{return await Zt("POST","/api/v1/report/session",e,{token:t,memberToken:n})}catch(o){if(xr(o)!=="memberToken")throw o;return console.warn("vitrinka: this server takes no member link yet — the reporter session opens without it"),Zt("POST","/api/v1/report/session",e,{token:t})}}function Er(e,t){return e?JSON.stringify([e,t]):""}function Dl(e,t=Date.now()){return e!==null&&Date.parse(e.expiresAt)-t>60000}function Cr(e,t,n){let r=n?`?cursor=${encodeURIComponent(n)}`:"";return Zt("GET",`/api/v1/report/mine${r}`,e,void 0,t)}function Bl(e,t){return`vitrinka.report.sent:${e}|${t}`}function Nl(){try{return globalThis.localStorage??null}catch{return null}}function Tr(e,t){let n=Nl()?.getItem(Bl(e,t));if(!n)return[];try{let r=JSON.parse(n);if(!Array.isArray(r))return[];return r.filter((o)=>typeof o?.title==="string"&&typeof o?.at==="number"&&(o.status==="filed"||o.status==="quarantined"))}catch{return[]}}function Hl(e,t,n){let r=Nl();if(!r)return;let o=[n,...Tr(e,t)].slice(0,20);try{r.setItem(Bl(e,t),JSON.stringify(o))}catch(i){console.warn("vitrinka: could not remember the sent report on this browser",i)}}var Fl=`
9
+ `)}return s.push(i[i.length-1]),s.join(o)}var is=262144;function Ji(e,t,n){if(e.full||!t)return t;try{if(vn(t)){if(t.length<=is)try{return JSON.stringify(St(e,JSON.parse(t),0))}catch{}return xe(e,Oc(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return xt(e,os(e,G,t));if(r.includes("multipart/form-data")){let o=_c(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return xt(e,t)}catch{return"[redacted]"}}function ss(e,t){if(t===void 0)return;if(e.full)return t;if(vn(t))try{return JSON.stringify(St(e,JSON.parse(t),0))}catch{}try{return xt(e,t)}catch{return"[redacted]"}}function as(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(vn(t)&&t.length<=is){let i=Ji(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 Ji(e,o,r)}function ls(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):es(e,s)?"[redacted]":xe(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function cs(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var Se=yn(null);function us(e){Se=yn(e??null)}function ps(e){return ss(Se,e)}function wn(e,t,n){return as(Se,e,t,n)}var ds=null,fs=null;function xn(e){fs=e??null}function Dc(e){let t=fs??We().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(ds!==t)ds=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return Bc(e)??Zi}function Bc(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function le(e){return kn(Se,Dc(e))}var Nc=4;function Sn(e){return e.type===Nc}function Rn(e){if(!Sn(e))return e;return{...e,data:{...e.data,href:le(e.data.href)}}}function je(e){return ls(Se,e)}function hs(){return cs(Se)}var gs=30000,Hc=4194304,Fc=20000,Tn=500,$c=2000,zc=2,ms={windowMs:gs,checkoutMs:gs,maxBytes:Hc,maxEvents:Fc,maxLaneEvents:Tn},Z=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function An(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var Kc=new TextEncoder,ee=!1,bs=0,P=ms,v=[],D=[],W=[],J=[],qc=0,Ee=[],Ce=new Map,Te=null,Re=null,Ve=!1,Wc=0,Q=null,Rt=null,Cn=Promise.resolve();function ys(e=ms){if(Ln(),ee=!0,bs++,P=e,Q=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})),D=(e.priorLanes??[]).slice(-e.maxLaneEvents),W=[],J=[],Ee=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),Ce.clear(),Te=null,Ct(Date.now()),Q)Rt=setInterval(Et,$c)}function ks(){Et(),Ln(),ee=!1,Q=null,v=[],D=[],W=[],J=[],Ee=[],Ce.clear(),Te=null}function vs(){return P}function Mn(e){Re=e}function ws(){if(!ee)return;v=[],D=[],W=[],J=[],Ee=[],Ce.clear(),Te=null;let e=x.tabId;ce((t)=>t.clear(e)),Re?.()}function xs(){return Cn}function Et(){if(!ee||!Q)return;let e=Date.now();Ct(e),Pn(e);for(let t of v){if(t.stored)continue;let n=Ce.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;Ce.set(t.id,{events:t.events.length,parts:o+1});let i=Ss(t);ce((s)=>s.putWindowChunk(i,o,r,[]))}Uc(e)}function Uc(e){let t=e-P.windowMs;while(J.length>0&&J[0].lastMs<=t){let[a]=J.splice(0,1);if(a)ce((l)=>l.dropWindow(a.id))}for(let a of Ee.filter((l)=>l.lastMs<=t))ce((l)=>l.dropWindow(a.id));Ee=Ee.filter((a)=>a.lastMs>t);let n=W;if(!n.length)return;W=[];let r=J.at(-1);if(!r||r.startMs<=t)r={id:`${Z}.lanes.${++qc}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},J.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:x.tabId,scope:P.scope??"",kind:"lanes",load:Z,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};ce((a)=>a.putWindowChunk(s,o,"[]",n))}function Ln(){if(Rt)clearInterval(Rt);Rt=null}function Ss(e){return{id:e.id,tab:x.tabId,scope:P.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function ce(e){let t=Q;if(!t)return;Cn=Cn.then(()=>e(t)).catch((n)=>{if(Q!==t)return;Q=null,Ln(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function En(e){let[t]=v.splice(e,1);if(!t)return;Ce.delete(t.id),ce((n)=>n.dropWindow(t.id))}function Ct(e){while(v.length>0){let r=v[0],o=v[1];if(!o&&r.load===Z)break;if(An(r,o)>e-P.windowMs)break;En(0)}if(Ve)return;let t=v.at(-1);if(t&&t.load===Z&&Re&&t.lastMs<=e-P.windowMs){Ve=!0;try{Re()}finally{Ve=!1}let r=v.indexOf(t);if(r>=0&&r<v.length-1)for(let o=r;o>=0;o--)En(o)}let n=!1;while(v.length>0&&jc()){if(v.length===1&&v[0].load===Z&&!n&&Re){n=!0,Ve=!0;try{Re()}finally{Ve=!1}if(v.length>1)continue}En(0),Te=v[0]?.startMs??e}}function Rs(){return ee?`flight:${bs}`:null}function Pn(e){let t=Math.min(v[0]?.startMs??Number.POSITIVE_INFINITY,e-P.windowMs),n=D.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)D=[];else if(n>0)D=D.slice(n)}function jc(){let e=0,t=0;for(let n of v)e+=n.bytes,t+=n.count;return e>P.maxBytes||t>P.maxEvents}function Es(e){if(!ee)return;let t=v[0];if(Sn(e)){let r=globalThis.location?.pathname??x.pathname,o={id:`${Z}.${++Wc}`,load:Z,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:le(r)};v.push(o);let i=Ss(o);ce((s)=>s.putWindow(i))}let n=v.at(-1);if(!n||n.load!==Z)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=Kc.encode(JSON.stringify(e)).length,Ct(e.timestamp),v[0]!==t)Pn(e.timestamp)}function Cs(e,t,n){if(!ee)return null;let r=P.keepLane?P.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=P.maxLaneEvents;if(D.push(i),D.length>s)D.splice(0,D.length-s);if(Q){if(W.push(i),W.length>s)W.splice(0,W.length-s)}return o}function Tt(){if(!ee)return null;let e=Date.now();return Ct(e),Pn(e),{windows:v.map((t)=>({...t,events:t.events.slice()})),lanes:D.slice(),truncated:Te!==null&&Te>e-P.windowMs}}function In(e){return e.windows.some((t)=>t.events[1]?.type===zc)}var On=null;function Ye(){if(!On)On=typeof indexedDB>"u"?Vc():Yc();return On}function Vc(){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 Yc(){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 Xc=2000,Nn=20000,Ds=200,Gc=4194304,Jc=3145728,Ot=500,Zc=Gc-1024,Qc=12582912,ed=10485760,td=Qc-64,nd=1048576,rd=new TextEncoder;function Oe(e){return rd.encode(e).length}var E=()=>A();function j(e,t){let n=E().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var Ts=!1;function V(e,t){try{return E().set(e,t),!0}catch(n){if(!Ts)Ts=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var Mt="rec",pe;function S(){if(pe===void 0)pe=j(Mt,null);return pe}function _t(e){if(pe=e,e===null)E().remove(Mt),E().remove(od);else V(Mt,JSON.stringify(id(e)))}var od="notes";var Ge=null;function id(e){if(Ge?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:Ge.activeMs,resumeAt:null,stopping:Ge.at}}var sd=new Set;function ad(){for(let e of sd)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function ld(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&&Ge?.sessionId!==t.sessionId)ad();if(!t){if(!n)return"unchanged";return pe=null,_s(),yd(),"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(Ge?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return pe=t,"updated"}return pe=t,_s(),"joined"}var cd=700,fe,U=null,oe=!1;function Me(){if(fe===void 0)fe=j("buffer",[]);return fe}function Dt(){if(U)clearTimeout(U),U=null;if(fe!==void 0&&!oe)V("buffer",JSON.stringify(fe))}function Bs(){if(oe=!1,U)return;U=setTimeout(()=>{U=null,Dt(),Ns()},cd)}function Hn(e){fe=e,oe=!1,Dt()}var Ae,Le=0;function de(){if(Ae===void 0)Ae=j("chunks",[]),Le=Ae.reduce((e,t)=>e+t.body.length,0);return Ae}function Ns(){if(oe)return;let e=de();if(e.length===0){E().remove("chunks");return}if(Le>nd){E().remove("chunks");return}V("chunks",JSON.stringify(e))}function Hs(e){Ae=e,Le=e.reduce((t,n)=>t+n.body.length,0),oe=!1,Ns()}var Lt,ge=new Map,he=new Set,me=new Map,Je=new Map,As=5,dd=200,ud=67108864,pd=0,Ms=!1,Fn="blobs";function B(){return Lt??=j("images",[]),Lt}function Fs(){if(oe)return;let e=B().filter((t)=>!he.has(t.blob));if(e.length===0)E().remove("images");else V("images",JSON.stringify(e))}function $n(e){Lt=e,oe=!1,Fs()}function fd(e,t){let n=Ye();if(!n.durable&&!Ms)Ms=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");V(Fn,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${Ws}.${++pd}`;return ge.set(a,i),he.add(a),r.push(n.put(a,i).then(()=>{if(!(ge.has(a)||B().some((d)=>d.blob===a)||[...me.values()].includes(a)))return he.delete(a),zn(a),!1;if(!n.durable)return!1;if(he.delete(a),B().some((d)=>d.blob===a))Fs();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 zn(e){Ye().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function Pe(e,t){for(let n of e)if(ge.delete(n),he.delete(n),Je.delete(n),t)zn(n)}var Pt=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];async function $s(e){if(!E().getString(Fn))return;let t=Ye(),n=S()?.sessionId;try{let r=await t.keys(),o=0;for(let i of r)if(e?i.startsWith(`${e}/`):!n||!i.startsWith(`${n}/`))await t.delete(i);else o++;if(o===0&&!S())E().remove(Fn)}catch(r){console.warn("vitrinka: blob journal cleanup failed",r)}}var hd=0,zs="",Ks=0,Ls=-1;function Kn(){hd=Date.now(),Ks=0,zs=""}function Ie(e){Ks++,zs=String(e instanceof Error?e.message:e).slice(0,200)}var Ps={actions:0,pages:0,frames:0,notes:0},gd=new Set;function md(e){let t={...Ps};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")gd.add(n.payload.cid)}Ps=t}function bd(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;_t(t),console.warn("vitrinka: session marked dead —",e),_()}var _n=null;function yd(){if(_n)clearInterval(_n);_n=null}function qs(e){let t=S();if(!t||t.dead||e<1)return null;let n=j("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return E().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,_t(t),{seq:r,sessionId:t.sessionId}}var Ws=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,It="allocation.",kd=0,I=new Set,vd=16777216,Ze=0,Qe=0,re=new Map;function Bt(e){return e.kind==="event"?1+(e.images?.length??0):1}function wd(e,t){return new Set(Array.from({length:Bt(t)},(n,r)=>e+r))}function qn(e,t,n){return JSON.stringify(n&&n.size<Bt(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var Is=!1,Xe=null;function At(e){if(!I.delete(e))return;if(Ze-=e.bytes,e.draft.kind==="chunk")Qe--}function Us(e){if(I.add(e),Ze+=e.bytes,e.draft.kind==="chunk")Qe++;while(I.size>Nn||Ze>vd||Qe>Ds){let t=I.values().next().value;At(t),E().remove(t.key),Pe(Pt(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");Ie(n),console.warn(n.message)}}function js(e=!1){if(Is&&!e)return;Is=!0;let t=E();if(!t.withLock)return;let n=new Set([...I].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(It)||n.has(r)||re.has(r))continue;let o=j(r,null);if(o&&o.draft&&o.draft.sessionId===S()?.sessionId)Us({...o,key:r,persisted:!0,bytes:Oe(JSON.stringify(o))})}}function Vs(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,p=l.length?{...e.event,payload:{...e.event.payload,attachments:l.map((u,f)=>t+f)}}:e.event,h=Me();if(a(d)&&!h.some((u)=>u.seq===d))h.push({seq:d,ts:r,tabId:o,tabHost:i,...p});if(l.length){let u=B();l.forEach((g,y)=>{let b=t+y;if(!a(b)||u.some((k)=>k.seq===b))return;if(h.some((k)=>k.seq===b)){me.set(b,g.blob);return}u.push({seq:b,ts:r,tabId:o,tabHost:i,sessionId:s,blob:g.blob,payload:g.payload})});let f=u.reduce((g,y)=>g+y.payload.bytes,0);while(u.length>dd||f>ud){let g=u.shift();f-=g.payload.bytes,ne(g.sessionId,new Set([g.seq])),Pe([g.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${g.payload.name} (seq ${g.seq}); its note lands without it`)}$n(u)}if(h.length>Nn){let u=h.splice(0,h.length-Nn);ne(s,new Set(u.map((f)=>f.seq))),console.warn(`vitrinka: retry buffer full — dropped ${u.length} oldest events`)}}else{let l=de();if(!l.some((d)=>d.seq===t)&&!Me().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),Le+=e.part.body.length;while(l.length>Ds){let d=l.shift();Le-=d.body.length,ne(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}Bs(),ue()}function ne(e,t){for(let[n,r]of re){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?j(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)V(n,qn(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){E().remove(n),re.delete(n);let s=n.slice(It.length,n.lastIndexOf(".")),a=`tab.${s}`,l=j(a,null);if(l?.departed&&l.recoverable&&!E().keys?.().some((d)=>d.startsWith(`${It}${s}.`)))E().remove(a)}}}function Ys(){if(Xe)return Xe;let e=E();return Xe=Wn(Promise.resolve().then(async()=>{for(let t of I)await e.withLock("seq",()=>{if(!I.has(t))return;if(t.persisted){let o=j(t.key,null);if(!o){At(t),Pe(Pt(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(ld(e.getString(Mt)??null),S()?.sessionId!==t.draft.sessionId){At(t),Pe(Pt(t.draft),!0);return}let n=t.seq??qs(Bt(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):wd(n,t.draft);if(t.persisted)e.set(t.key,qn(t.draft,n,r));re.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),Vs(t.draft,n,r),At(t)})}).catch((t)=>{throw Ie(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),ue(),_(),t})).finally(()=>{Xe=null}),Xe}function Xs(e,t){let n=S(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(js(),E().withLock){let o=`${It}${Ws}.${++kd}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&V(o,i),bytes:Oe(i)};Us(s),Ys(),t?.then((a)=>{if(a)xd(s)})}else{let o=qs(Bt(e));if(o)Vs(e,o.seq);else Pe(Pt(e),!0)}return!0}function xd(e){let t=re.get(e.key);if(t)t.persisted=V(e.key,qn(e.draft,e.seq,t.seqs));else if(I.has(e))e.persisted=V(e.key,JSON.stringify({draft:e.draft}))}var Os=new Set;function Wn(e){return Os.add(e),e.catch(()=>{return}).finally(()=>{Os.delete(e)})}function te(e){return S()?.sessionId!==e.sessionId}function et(e,t,n,r=[]){if(Ke.following)return null;let o=S();if(!o)return Cs(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?fd(o.sessionId,r):null;return Xs({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),Un(),i}function Gs(e){Me().push(e),Un(),Bs(),ue()}var Sd=Date.now();function Un(){Sd=Date.now()}function jn(e,t=ed,n=td){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),p=Oe(d)+1;if(p>n){o.push(p);continue}if(p>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+p>t)a();i.push(d),s+=p}return a(),{parts:r,dropped:o}}function Js(e,t){if(!e.length)return 0;let n=S();if(!n||n.paused||n.dead||Ke.following)return 0;let{parts:r,dropped:o}=jn(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),et("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(!Xs({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return Un(),r.length}async function Rd(e=5){let t=de();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 Vi(n.sessionId,i.seq,i.body);if(te(n))return de().length===0;Gs({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),Kn(),o.add(i.seq)}catch(s){if(te(n))return de().length===0;if(s instanceof C&&q(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),ne(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}Ie(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Hs(de().filter((i)=>!o.has(i.seq)));return de().length===0}async function Ed(e=4){let t=B();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=ge.get(s.blob)??null;if(!a){try{a=await Ye().get(s.blob),Je.delete(s.blob)}catch(l){if(te(n))return B().length===0;let d=(Je.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${As})`,l),d<As){Je.set(s.blob,d),Ie(l);break}}if(te(n))return B().length===0}if(!a){console.warn(`vitrinka: attachment seq ${s.seq} (${s.payload.name}) lost its bytes — its note lands without it`),ne(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await Yi(n.sessionId,s.seq,a);if(te(n))return B().length===0;Gs({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),ge.delete(s.blob),me.set(s.seq,s.blob),Kn(),o.add(s.seq)}catch(l){if(te(n))return B().length===0;if(l instanceof C&&q(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),ne(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}Ie(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)Dt(),$n(B().filter((s)=>!o.has(s.seq)));return Pe(i,!0),B().length===0}var Dn=null;function ue(){if(Dn)return;Dn=setTimeout(()=>{Dn=null,Cd()},Xc)}var Bn=!1;async function Cd(e={}){if(Bn)return!1;Bn=!0;try{return await Td(e)}finally{Bn=!1}}async function Td(e){if(S()?.dead)return!1;if(js(!0),I.size)await Ys();if(I.size)return!1;let t=await Rd(),n=e.keepalive?B().length===0:await Ed(),r=t&&n;if(!r)ue();let o=S(),i=Me();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:Jc;for(let u of i){if(s.length>=Ot)break;let f=Oe(JSON.stringify(u))+1;if(f>Zc){console.warn(`vitrinka: event seq ${u.seq} (${f} bytes) exceeds the wire cap — dropped`),a.add(u.seq);continue}if(f>d){if(e.keepalive)break;if(s.length===0)s.push(u),l=f;break}if(s.length>0&&l+f>d)break;s.push(u),l+=f}if(a.size){if(ne(o.sessionId,a),Hn(Me().filter((u)=>!a.has(u.seq))),!s.length)return ue(),!1}if(!s.length)return!1;Dt();try{await X("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(u){if(te(o))return!1;if(u instanceof C&&q(u.status))return bd(`server rejected this session (${u.status})`),!1;return Ie(u),_(),console.warn("vitrinka: flush failed, retrying",u),ue(),!1}if(te(o))return!0;Kn(),Ls=Math.max(Ls,...s.map((u)=>u.seq)),md(s);let p=new Set(s.map((u)=>u.seq));ne(o.sessionId,p);let h=Me().filter((u)=>!p.has(u.seq));Hn(h),_();for(let u of p){let f=me.get(u);if(f===void 0)continue;me.delete(u),zn(f)}if(h.length)ue();return!0}function Zs(){for(let e of re.keys())E().remove(e);for(let e of I)E().remove(e.key);re.clear(),I.clear(),Ze=Qe=0,Hn([]),Hs([]),ge.clear(),he.clear(),me.clear(),Je.clear(),$n([])}function _s(){if(U)clearTimeout(U),U=null;fe=[],Ae=[],Le=0,Lt=[],ge.clear(),he.clear(),me.clear(),I.clear(),Ze=Qe=0,re.clear(),oe=!0}var Qs="0.10.1";var Xp={from:"page",inst:Wi("p")};var Ad=!1;function ea(){return Ad}var na="vitrinka.report.face",ta=(e)=>e.trim().replace(/\/+$/,"");function Nt(){try{return globalThis.localStorage??null}catch{return null}}function _e(e){let t=ae();if(!t)return!1;if(t.base)return ta(t.base)===ta(e);try{let n=kt(e);return n===void 0||n===t.workspace}catch{return!1}}function be(e){return _e(e)?ae()?.token??"":""}function ra(e){return/revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(e)}function Md(){let e=Nt()?.getItem(na);return e==="recorder"||e==="report"?e:null}function Vn(e){try{Nt()?.setItem(na,e)}catch(t){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",t)}}var oa="vitrinka.report.mode";function ia(e){try{if(e==="dev"||e==="regular")Nt()?.setItem(oa,e)}catch(t){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",t)}}function sa(e){if(!_e(e))return"report";let t=Md();if(t)return t;return Nt()?.getItem(oa)==="dev"?"recorder":"report"}function aa(){return S()!==null||ea()}function Ht(e){let t=A().watch?.(Ue,()=>e()),n=Hi(e);return()=>{t?.(),n()}}var la=["bug","suggestion","question","other"];function De(e,t,n,r){if(e===1)return t;if(e>=2&&e<=4)return n;return r}var Ld={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",kinds:{bug:"Bug",suggestion:"Suggestion",question:"Question",other:"Other"},kindsLabel:"What is it?",linesEmpty:"Each place you mark gets a line here for its note.",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:"Cover"},toolbar:"Marking tools",barLead:"Mark where the problem is",barLeadHide:"Cover what the team shouldn’t see",cancelMarking:"Cancel",discardMarks:(e)=>e===1?"Discard 1 mark?":`Discard ${e} marks?`,discard:"Discard",keep:"Keep",coach:{box:"Click, hold and move across the problem.",circle:"Click, hold and move around the problem.",arrow:"Click, hold and move from a clear spot to the problem.",hide:"Click, hold and move across anything private — it stays blank in what you send."},coachMore:"You can mark more than one place.",coachDismiss:"Got it, don’t show again",coachSetting:"Marking tips",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Covered — not sent",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",account:"Your account",menu:"Menu",anonymous:"Not signed in",anonymousHint:"The team checks your report before it’s filed.",signedInByApp:"Signed in by this app",linkVitrinka:"Link your vitrinka account",linkedAs:(e)=>`Linked to vitrinka as ${e}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(e)=>`Remove ${e}`,fileTooBig:(e,t)=>`${e} is over the ${t} limit`,tooManyFiles:(e)=>e===1?"Up to 1 file per report":`Up to ${e} files per report`,fileType:(e,t)=>`${e} can’t be attached — ${t} only`,typeNames:{image:"images",pdf:"PDF",text:"text files",office:"office documents"},incFiles:"The files you attached",errorFiles:"Your report arrived, a file not yet — try again to attach it",moveHint:"Click, hold and move it to another corner, or press Alt and an arrow key.",size:"Size",sizes:{sm:"Small",md:"Medium",lg:"Large"},techDetails:"Technical details",techVersion:"Version",techWindow:"Capture window",techCapture:"Capture",techBuffer:"Buffer",techServer:"Server",captureOn:"Running",captureOff:"Off",captureStarting:"Starting…",bufferMemory:"In memory",bufferBrowser:"In this browser",windowLength:(e)=>{if(e<60)return e===1?"1 second":`${e} seconds`;let t=Math.round(e/60);return t===1?"1 minute":`${t} minutes`}},Pd={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 De(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 De(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",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Dotaz",other:"Jiné"},kindsLabel:"Co to je?",linesEmpty:"Každé označené místo tu dostane řádek pro poznámku.",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:"Zakrýt"},toolbar:"Nástroje pro označení",barLead:"Označte, kde je problém",barLeadHide:"Zakryjte, co tým nemá vidět",cancelMarking:"Zrušit",discardMarks:(e)=>De(e,"Zahodit 1 značku?",`Zahodit ${e} značky?`,`Zahodit ${e} značek?`),discard:"Zahodit",keep:"Ponechat",coach:{box:"Klikněte, podržte a veďte přes problém.",circle:"Klikněte, podržte a veďte kolem problému.",arrow:"Klikněte, podržte a veďte z volného místa k problému.",hide:"Klikněte, podržte a veďte přes vše soukromé — v hlášení zůstane prázdné."},coachMore:"Označit můžete i více míst.",coachDismiss:"Chápu, už nezobrazovat",coachSetting:"Nápověda při označování",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Zakryto — neodešle se",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",account:"Váš účet",menu:"Nabídka",anonymous:"Nepřihlášeno",anonymousHint:"Hlášení nejdřív zkontroluje tým.",signedInByApp:"Přihlášen touto aplikací",linkVitrinka:"Propojit s vitrinkou",linkedAs:(e)=>`Propojeno s vitrinkou jako ${e}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(e)=>`Odebrat ${e}`,fileTooBig:(e,t)=>`${e} přesahuje limit ${t}`,tooManyFiles:(e)=>De(e,"Nejvýš 1 soubor na hlášení",`Nejvýš ${e} soubory na hlášení`,`Nejvýš ${e} souborů na hlášení`),fileType:(e,t)=>`${e} nelze přiložit — jen ${t}`,typeNames:{image:"obrázky",pdf:"PDF",text:"textové soubory",office:"kancelářské dokumenty"},incFiles:"Soubory, které jste přiložili",errorFiles:"Hlášení dorazilo, soubor zatím ne — zkuste to znovu a přiložíme ho",moveHint:"Klikněte, podržte a veďte ho do jiného rohu, nebo stiskněte Alt a šipku.",size:"Velikost",sizes:{sm:"Malá",md:"Střední",lg:"Velká"},techDetails:"Technické údaje",techVersion:"Verze",techWindow:"Okno záznamu",techCapture:"Záznam",techBuffer:"Vyrovnávací paměť",techServer:"Server",captureOn:"Běží",captureOff:"Vypnutý",captureStarting:"Spouští se…",bufferMemory:"V paměti",bufferBrowser:"V tomto prohlížeči",windowLength:(e)=>{if(e<60)return De(e,"1 sekunda",`${e} sekundy`,`${e} sekund`);let t=Math.round(e/60);return De(t,"1 minuta",`${t} minuty`,`${t} minut`)}},Id={cs:Pd,en:Ld};function Yn(e){return Id[e]}function tt(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"?t:null}function Xn(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=tt(n);if(r)return r}return"en"}var ca="recents",da=5,Od=["recording","saved","unsaved","deleted"];function _d(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.sessionId==="string"&&typeof t.title==="string"&&typeof t.startedAt==="number"&&Od.includes(t.status)}var Be;function Gn(){if(Be===void 0)try{let e=JSON.parse(A().getString(ca)??"[]");Be=Array.isArray(e)?e.filter(_d).slice(0,da):[]}catch{Be=[]}return Be}function Dd(e){Be=e.slice(0,da);try{A().set(ca,JSON.stringify(Be))}catch(t){console.warn("vitrinka: could not store recent recordings",t)}_()}function ua(e,t){let n=Gn();if(!n.some((r)=>r.sessionId===e))return;Dd(n.map((r)=>r.sessionId===e?{...r,...t}:r))}var nt="data-vitrinka-recorder";var Jn="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;",pa=Jn;var Bd=["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 ma(e){for(let t of Bd)e.addEventListener(t,(n)=>n.stopPropagation())}var Nd=["keydown","keyup","keypress"],Hd=["vitrinkaHud","vitrinkaSheet"],fa=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Fd=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),$d=new Set(["text","search","email","url","tel","password","number"]);function zd(e){let t=e.key.length===1;if(t&&e.getModifierState?.("AltGraph"))return!0;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return t||fa.has(e.key);if(fa.has(e.key))return!0;return(e.ctrlKey||e.metaKey)&&!e.altKey&&Fd.has(e.code)}function Kd(e){if(typeof e!=="object"||e===null)return!1;if("isContentEditable"in e&&e.isContentEditable===!0)return!0;let t="tagName"in e&&typeof e.tagName==="string"?e.tagName:"";if(t==="TEXTAREA")return!0;return t==="INPUT"&&"type"in e&&typeof e.type==="string"&&$d.has(e.type)}function qd(e){if(typeof e!=="object"||e===null||!("dataset"in e))return!1;let t=e.dataset;return typeof t==="object"&&t!==null&&Hd.some((n)=>(n in t))}function Wd(e){if(!zd(e))return!1;let t=e.composedPath();return Kd(t[0])&&t.some(qd)}var ha=0,Ft=null;function ba(){if(ha++,!Ft&&typeof window<"u"){let t=(r)=>{if(Wd(r))r.stopImmediatePropagation()},n=Nd.map((r)=>L(window,r,t,{capture:!0}));Ft=()=>{for(let r of n)r()}}let e=!0;return()=>{if(!e)return;if(e=!1,--ha>0)return;Ft?.(),Ft=null}}function ya(){let e=document.createElement("div");e.setAttribute(nt,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=Jn;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),ma(e);let r=ba();document.documentElement.append(e);let o=typeof e.showPopover==="function",i=()=>{if(!o||!e.isConnected)return;try{e.hidePopover?.()}catch{}try{e.showPopover?.()}catch{}};if(o)e.popover="manual";i();let s=!1,a=()=>{if(s)return;s=!0,queueMicrotask(()=>{s=!1,i()})},l=(f)=>{if(f.type==="attributes")return f.target instanceof Element&&ga(f.target);for(let g of[f.addedNodes,f.removedNodes])for(let y of g){if(!(y instanceof Element))continue;if(ga(y))return!0;if(y.childElementCount>0&&y.querySelector(ka))return!0}return!1},d=[],p=0,h=()=>{p=0;let f=d;if(d=[],f.some(l))a()},u=new MutationObserver((f)=>{for(let g of f)d.push(g);if(p===0)p=typeof requestAnimationFrame==="function"?requestAnimationFrame(h):setTimeout(h,16)});return u.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:e,mount:n,destroy:()=>{if(r(),u.disconnect(),p!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(p);d=[];try{e.hidePopover?.()}catch{}e.remove()}}}var ka='dialog,[role="dialog"]';function ga(e){return e.matches(ka)}function va(){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 wa(e){let t=document.createElement("div");t.setAttribute(nt,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=pa;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");n.append(r),ma(t);let o=ba();if(typeof t.showPopover==="function")t.popover="manual";return e.append(t),t.showPopover?.(),{mount:r,destroy:()=>{o(),t.remove()}}}function xa(e){if(!(e instanceof Node))return!1;let t=e instanceof Element?e:e.parentElement;return Boolean(t?.closest("[data-vitrinka-hud],[data-vitrinka-sheet]"))}var Ud="me";var jd;function Sa(){jd=null,A().remove(Ud)}function Ra(e){if(!e)return 0;let t=e.activeMs||0;if(!e.paused&&e.resumeAt)t+=Date.now()-Date.parse(e.resumeAt);return t}function Ea(){vt(),Sa();let e=S();if(e)ua(e.sessionId,{status:"unsaved",durationMs:Ra(e)}),_t(null),Zs(),$s(e.sessionId);_()}var ie={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function Vd(e,t){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:t}function Ca(e){if(typeof e!=="object"||e===null)return ie;let t={...e},n=Array.isArray(t.types)?t.types.filter((r)=>typeof r==="string"&&r.trim()!=="").map((r)=>r.trim().toLowerCase()):[];return{maxBytes:Vd(t.maxBytes,ie.maxBytes),maxCount:typeof t.maxCount==="number"&&Number.isInteger(t.maxCount)&&t.maxCount>=0?t.maxCount:ie.maxCount,types:n.length?n:ie.types}}function Yd(e,t){let n=e.type.toLowerCase(),r=e.name.toLowerCase();return t.some((o)=>{if(o==="*"||o==="*/*")return!0;if(o.startsWith("."))return r.endsWith(o);if(o.endsWith("/*"))return n.startsWith(o.slice(0,-1));return n===o})}function Xd(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}function Ta(e,t,n){let r=[],o=null;for(let i of t){if([...e,...r].some((s)=>Xd(s,i)))continue;if(!Yd(i,n.types))o??={kind:"type",name:i.name};else if(i.size>n.maxBytes)o??={kind:"size",name:i.name,cap:n.maxBytes};else if(e.length+r.length>=n.maxCount)o??={kind:"count",cap:n.maxCount};else r.push(i)}return{files:r,refusal:o}}function rt(e,t){let n=(r,o,i)=>`${new Intl.NumberFormat(t,{maximumFractionDigits:i}).format(r)} ${o}`;if(e<1024)return n(e,"B",0);if(e<1048576)return n(e/1024,"kB",0);return n(e/1048576,"MB",e<10485760?1:0)}function Aa(e,t,n){let r=(i)=>{if(i.startsWith("image/"))return t.image;if(i==="application/pdf"||i===".pdf")return t.pdf;if(i.startsWith("text/"))return t.text;if(/officedocument|msword|ms-excel|ms-powerpoint|opendocument/.test(i))return t.office;return i.startsWith(".")?i:i.split("/")[1]??i},o=e.map(r);return new Intl.ListFormat(n,{type:"conjunction"}).format([...new Set(o)])}function Ma(e,t){let n=/^image\.(\w+)$/i.exec(e);return n?`pasted-${t}.${n[1]}`:e}var Zn=["sm","md","lg"],ot={sm:0.88,md:1,lg:1.18},Qn="vitrinka.report.size";function La(){try{return globalThis.localStorage??null}catch{return null}}function $t(e){return La()?.getItem(e)??null}function it(e,t){try{La()?.setItem(e,t)}catch(n){console.warn(`vitrinka: could not remember ${e} on this browser`,n)}}function Pa(){let e=$t(Qn);return Zn.find((t)=>t===e)??"md"}var er="vitrinka.report.coach";function Ia(){return $t(er)!=="off"}function Oa(e,t){let n=e.config,r=!e.engine||n?.capturing===!1?t.captureOff:n?t.captureOn:t.captureStarting,o=e.base;try{o=new URL(e.base).host}catch{}return[[t.techVersion,`@vitrinka/web ${e.version}`],[t.techWindow,n?t.windowLength(n.profile.windowSec):"—"],[t.techCapture,r],[t.techBuffer,n?`${n.profile.storage==="browser"?t.bufferBrowser:t.bufferMemory} · ${rt(n.profile.maxBytes,e.locale)}`:"—"],[t.techServer,o]]}var _a="vitrinka.report.dock",Da=6,tr={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},Gd=["br","bl","tr","tl"];function Jd(e){return e==="tl"||e==="tr"?"t":"b"}function Zd(e){return e==="tl"||e==="bl"?"l":"r"}function Ba(){let e=$t(_a);return Gd.find((t)=>t===e)??"br"}function Na(e){it(_a,e)}function Ha(e,t,n){return tr[e.y<n/2?"t":"b"][e.x<t/2?"l":"r"]}function Fa(e,t){if(t==="ArrowLeft"||t==="ArrowRight")return tr[Jd(e)][t==="ArrowLeft"?"l":"r"];if(t==="ArrowUp"||t==="ArrowDown")return tr[t==="ArrowUp"?"t":"b"][Zd(e)];return null}var Qd=8192,st="__vitrinkaRecorderConsolePatched";function zt(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,Qd)}function Kt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;et("console",{level:t,text:ps(e)},{tabId:x.tabId,tabHost:x.tabHost})}var nr="__vitrinkaRecorderConsoleUnpatch",$a={};function za(){let e=globalThis;if(e[st]!==void 0&&e[st]!==$a)return;e[nr]?.()}function Ka(e={}){let t=globalThis;if(t[st])return;t[st]=$a;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{Kt(zt(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let p=console[d],h=p.bind(console),u=(...f)=>{h(...f);try{Kt(zt(f),d)}catch{}};return console[d]=u,()=>{if(console[d]===u)console[d]=p}}),s=(d)=>{try{Kt(zt([d.error??d.message]))}catch{}},a=(d)=>{try{Kt(`unhandled rejection: ${zt([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[nr]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[st],delete t[nr]}}var qa=65536,at=524288,Wa=3000;var rr="full";function ir(){if(Ke.following)return null;let e=S();if(e)return!e.paused&&!e.dead?e.sessionId:null;return Rs()}function lt(e){return e!==null&&ir()===e}function qt(e,t){if(typeof e==="string")return wn(e,qa,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return wn(e.toString(),qa,"application/x-www-form-urlencoded");return eu(e)}function eu(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 or(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function sr(e){return typeof e==="string"||e instanceof URL?{}:e}function ct(e){let t=typeof e.url==="string"?le(e.url):e.url;et("net",{...e,url:t},{tabId:x.tabId,tabHost:x.tabHost})}function ar(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 tu(e,t){let n=ar(t?.headers);if(n)return n;let r=sr(e);return ar(r.headers)}function nu(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 lr(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function ru(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function ou(e,t){let n=await iu(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return qt(n,r)}async function iu(e,t){let n=ru(t);if(n!==null&&n>at)return lr(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()+Wa;try{while(s<at){let f=d-Date.now();if(f<=0){l=!0;break}let g,y=await Promise.race([o.read(),new Promise((w)=>{g=setTimeout(()=>w("timeout"),f)})]).finally(()=>{if(g!==void 0)clearTimeout(g)});if(y==="timeout"){l=!0;break}let{done:b,value:k}=y;if(b)break;if(k){let w=at-s,m=k.byteLength>w?k.subarray(0,w):k;i.push(m),s+=m.byteLength}}a=s>=at,o.cancel().catch(()=>{return})}catch{return}let p=new Uint8Array(s),h=0;for(let f of i)p.set(f,h),h+=f.byteLength;let u;try{u=new TextDecoder().decode(p)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${u}…[body read timed out after ${Wa}ms]`;return a?`${u}…[truncated at ${at} bytes]`:u}if(n===null)return lr(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var dt="__vitrinkaRecorderNetPatched",cr="__vitrinkaRecorderNetUnpatch",Ua={};function ja(){let e=globalThis;if(e[dt]!==void 0&&e[dt]!==Ua)return;e[cr]?.()}function Va(e={}){let t=globalThis;if(t[dt])return;t[dt]=Ua,rr=e.detail??"full";let n=[];t[cr]=()=>{for(let u of n.splice(0))u();delete t[dt],delete t[cr]};let r=globalThis.fetch,o=async(u,f)=>{let g=typeof u==="string"?u:u instanceof URL?u.href:u.url,y=ir();if(fn(g)||y===null)return r(u,f);let b=f?.method??("method"in sr(u)?sr(u).method:"GET"),k=Date.now();try{let w=await r(u,f),m=Date.now()-k;if(rr==="meta"){if(lt(y))ct({method:b,url:g,status:w.status,ms:m,via:"fetch"});return w}let M;try{M=w.clone()}catch{M=void 0}let{headers:Ne,status:He}=w;return Wn((async()=>{if(!lt(y)){if(M)lr(M);return}let mt=M?await ou(M,Ne):void 0;if(!lt(y))return;let Fe=tu(u,f);ct({method:b,url:g,status:He,ms:m,reqHeaders:je(Fe),resHeaders:je(ar(Ne)),reqBody:qt(f?.body,or(Fe)),resBody:mt,via:"fetch"})})()),w}catch(w){if(lt(y))ct({method:b,url:g,error:String(w),ms:Date.now()-k,via:"fetch"});throw w}};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 u=i.prototype;if(u.open===d)u.open=s;if(u.send===h)u.send=a;if(u.setRequestHeader===p)u.setRequestHeader=l});let d=i.prototype.open=function(...u){return this.__vt={method:u[0],url:String(u[1])},s.apply(this,u)},p=i.prototype.setRequestHeader=function(u,f){let g=this.__vt;if(g)(g.reqHeaders??={})[u]=f;return l?.call(this,u,f)},h=i.prototype.send=function(u){let f=this.__vt,g=ir();if(f&&!fn(f.url)&&g!==null){let y=Date.now();this.addEventListener("loadend",()=>{if(!lt(g))return;if(rr==="meta"){ct({method:f.method,url:f.url,status:this.status,ms:Date.now()-y,via:"xhr"});return}let b;try{b=nu(this.getAllResponseHeaders())}catch{b=void 0}let k;try{k=this.responseType===""||this.responseType==="text"?qt(this.responseText,or(b)):void 0}catch{k=void 0}ct({method:f.method,url:f.url,status:this.status,ms:Date.now()-y,reqHeaders:je(f.reqHeaders),resHeaders:je(b),reqBody:qt(u,or(f.reqHeaders)),resBody:k,via:"xhr"})})}return a.call(this,u)}}var su=2000,au=300000,pt=null,ft=null,ut=[],Wt=null;function Ya(){if(!ut.length)return;let e=ut;ut=[],Js(e,{tabId:x.tabId,tabHost:x.tabHost})}function ht(){return ft}function Xa(e,t,n={}){if(pt)return;let r=hs(),o=n.unmaskSelector;try{pt=e({emit:t==="flight"?(s)=>Es(Rn(s)):(s)=>{ut.push(Rn(s))},checkoutEveryNms:t==="flight"?vs().checkoutMs:au,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:`[${nt}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(ft=e,t==="flight")Mn(Ut);if(t==="session")Wt=setInterval(Ya,su)}function Ga(){if(Wt)clearInterval(Wt);Wt=null,Ya();try{pt?.()}catch{}pt=null,ft=null,Mn(null),ut=[]}function Ut(){if(!pt||!ft)return;try{ft.takeFullSnapshot?.(!0)}catch{}}var Qa="vitrinka.capture",N="windows",H="chunks";function ye(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function dr(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function Ja(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function Za(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 el(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(Qa,1);r.onupgradeneeded=()=>{r.result.createObjectStore(N,{keyPath:"id"}),r.result.createObjectStore(H)},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(N).delete(i),o.objectStore(H).delete(Ja(i))};return{async putWindow(o){let i=t.transaction(N,"readwrite");i.objectStore(N).put(o),await ye(i)},async putChunk(o,i,s,a){let l=t.transaction(H,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(H).put(d,[o,i]),await ye(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([N,H],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(H).put(d,[o.id,i]),l.objectStore(N).put(o)}catch(p){throw l.abort(),p}await ye(l)},async dropWindow(o){let i=t.transaction([N,H],"readwrite");n(i,o),await ye(i)},async clear(o){let i=t.transaction([N,H],"readwrite"),s=await dr(i.objectStore(N).getAll());for(let a of s)if(Za(a)&&a.tab===o)n(i,a.id);await ye(i)},async sweep(o,i,s,a){let l=t.transaction([N,H],"readwrite"),d=(await dr(l.objectStore(N).getAll())).filter(Za),p=[],h=new Map;for(let u of d)h.set(u.tab,[...h.get(u.tab)??[],u]);for(let[u,f]of h){let g=f.filter((b)=>b.kind!=="lanes").sort((b,k)=>b.startMs-k.startMs),y=(b)=>b.kind==="lanes"?b.lastMs:An(b,g[g.indexOf(b)+1]);for(let b of f.sort((k,w)=>k.startMs-w.startMs))if(y(b)<=o-i||u===s&&b.scope!==a)n(l,b.id);else if(u===s)p.push(b)}return await ye(l),p},async read(o){let i=t.transaction(H,"readonly"),s=await dr(i.objectStore(H).getAll(Ja(o)));await ye(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 tl(e=globalThis.indexedDB){try{e?.deleteDatabase(Qa)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function ur(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 pr(e,t){return`${t.y<e.y?"n":"s"}${t.x<e.x?"w":"e"}`}function fr(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 nl(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 rl(e){return e.map((t,n)=>({...t,n:n+1}))}function ol(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 lu=2,cu=3,du=0,uu=5,hr=2,pu=3,fu=2000000000,hu="data-vitrinka-hidden",gu="#1b1b1f";function mu(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:${gu};z-index:2147483647;pointer-events:none;`;return{type:hr,id:fu+t,tagName:"div",attributes:{[hu]:"",style:n},childNodes:[]}}function gr(e,t,n,r){let o={...e};if(e.type===pu&&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)=>gr(i,t,n,r)),!r.done&&e.type===hr&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function bu(e,t){(e.childNodes?.find((r)=>r.type===hr)??e).childNodes?.push(...t)}function yu(e,t){return gr(e,t,[],{done:!0})}function il(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map(mu);return e.map((o)=>{let i=o.data;if(o.type===lu&&i.node){let s={done:!1},a=gr(i.node,n,r,s);if(!s.done)bu(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==cu||!n.size)return o;if(i.source===du){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:yu(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===uu){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function ku(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function vu(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function mr(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)=>ku(vu(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 wu=["errors","interactions","full","console","network"];var jt={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function Xt(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function Vt(e,t,n){return Math.min(n,Math.max(t,e))}function xu(e){if(!Array.isArray(e))return null;return wu.filter((t)=>e.includes(t))}function sl(e,t){if(typeof e!=="object"||e===null)return Xt(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":jt.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?Vt(Math.round(n.windowSec),10,3600):jt.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?Vt(Math.round(n.maxBytes),262144,67108864):jt.maxBytes,classes:xu(n.classes)??jt.classes}}function Yt(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 Su(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 al(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=Yt(e.classes),s=Yt(t.classes);o=Su({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:Vt(n,10,3600),maxBytes:Vt(r,262144,67108864),classes:o}}function ll(e){return e==="balanced"||e==="full"?e:"strict"}function cl(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var dl="[data-vitrinka-unmask]";var Ru=3670016,ul=4194240,Eu=2000,pl=500,Cu=60000,Tu=/[A-Za-z0-9_-]{20,}/g;function Y(e,t=""){return typeof e==="string"?e:t}function Au(e){let t=Y(e),n;try{n=new URL(t,globalThis.location?.href??"http://localhost").pathname}catch{n=t.split(/[?#]/)[0]??""}return n.replace(Tu,"•••").slice(0,300)}var Mu=4;function Lu(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===Mu&&o.length)s();if(!i&&Oe(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}function Pu(e){return(t,n)=>{if(t==="console"){let r=Y(n?.level,"error");if(r==="error"?!(e.errors||e.console):!e.console)return null;return{level:r,text:Y(n?.text).slice(0,Eu)}}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:Y(n?.method,"GET").toUpperCase(),path:Au(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}async function Iu(e){try{let t=await X("GET","/api/v1/report-config",void 0,{target:e}),n=typeof t.flightRecorder==="boolean"?t.flightRecorder:void 0;return{project:Y(t.project),profile:t.captureProfile==null?Xt(n):sl(t.captureProfile,n),masking:ll(t.profile),reachable:!0,attachments:Ca(typeof t.captureProfile==="object"&&t.captureProfile!==null&&"attachments"in t.captureProfile?t.captureProfile.attachments:t.attachments)}}catch(t){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",t),{project:"",profile:Xt(),masking:"strict",reachable:!1,attachments:ie}}}function fl(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 hl{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(Ki(e.base));let t=await Iu({url:e.base,key:e.key}),n=al(t.profile,e.capture),r=Yt(n.classes),o={project:t.project,profile:n,lanes:r,masking:t.masking,reachable:t.reachable,capturing:!1,attachments:t.attachments};if(this.stopped)return o;if(this.config=o,this.claim=Bi("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,Di(_i(),globalThis.location?.host??""),x.pathname=globalThis.location?.pathname??"/",us(cl(o.masking)),xn(e.sanitizeUrl),this.capture.push(()=>xn(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 el();let d=await this.store.sweep(Date.now(),i,x.tabId,s);a=d;let p=this.store;l=(await Promise.all(d.filter((u)=>u.kind==="lanes").map((u)=>p.read(u.id)))).flatMap((u)=>u.lanes).sort((u,f)=>Date.parse(u.ts)-Date.parse(f.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else tl();if(!this.capturing)return this.store?.close(),this.store=null,o;if(ys({windowMs:i,checkoutMs:Math.min(Cu,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:Tn,keepLane:Pu(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(ks),this.store&&typeof window<"u"){let d=()=>Et();this.capture.push(L(window,"pagehide",d),L(document,"visibilitychange",d))}if(r.errors||r.console)Ka({levels:r.console?["warn","info","log"]:[]}),this.capture.push(za);if(r.errors||r.network)Va({detail:"meta"}),this.capture.push(ja);if(r.replay){let d=await e.loadRecord(e.base).catch((p)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",p),null));if(d&&this.capturing)Xa(d,"flight",{unmaskSelector:dl}),this.capture.push(Ga)}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)xs().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};x.pathname=globalThis.location?.pathname??x.pathname;let e=Tt();if(e&&ht()&&!In(e))Ut(),e=Tt();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}}withScreen(e){if(!this.capturing||!ht()||e&&In(e))return e;Ut();let t=Tt();if(!t)return e;return{windows:[...e?.windows.filter((n)=>n.stored)??[],...t.windows.filter((n)=>!n.stored)],lanes:e?.lanes??t.lanes,truncated:e?.truncated??t.truncated}}hiddenIdsAt(e){if(!this.capturing)return null;let t=fl(ht());return t?mr([e],t):null}async build(e,t,n=new Set){let r=t.filter((m)=>m.shape==="hide").map((m)=>m.rect),o=fl(ht()),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 m of mr(r,o))s.add(m);let a=[],l=this.withScreen(e.clip),d=l?.truncated??!1,p=await e.stored.catch((m)=>(console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",m),null));for(let m of l?.windows??[]){if(!m.stored){a.push(...m.events);continue}let M=p?.get(m.id);if(!M?.events.length)d=!0;else a.push(...M.events)}let h=l?.lanes??[],u=i?{events:[],dropped:!1}:Lu(il(a,r,s),ul);if(u.dropped)d=!0;let{parts:f,dropped:g}=jn(u.events,Ru,ul),y=[],b=0;for(let m of f){b+=m.count;let M=u.events[b-1]?.timestamp??Date.now();y.push({seq:y.length+1,ts:new Date(M).toISOString(),count:m.count,body:m.body})}let k=h.filter((m)=>m.kind==="console").slice(-pl).map((m)=>({level:Y(m.payload?.level,"error"),ts:m.ts,text:Y(m.payload?.text)})),w=h.filter((m)=>m.kind==="net").slice(-pl).map((m)=>({method:Y(m.payload?.method,"GET"),path:Y(m.payload?.path),status:typeof m.payload?.status==="number"?m.payload.status:0,ms:typeof m.payload?.ms==="number"?m.payload.ms:0}));return{chunks:y,truncated:d||g.length>0,console:k,network:w}}clear(){if(this.capturing)ws()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),Ni(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var z=null;function gl(e){if(z){let t=z.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 z.refs++,z.engine}return z={engine:new hl(e),refs:1},z.engine}function ml(e){if(!e||!z||z.engine!==e)return;if(--z.refs>0)return;z=null,e.stop()}var Ou=/^[\w-]+\.[\w-]+\.[\w-]+$/;function Gt(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!Ou.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 bl=null,br=new Set;function _u(e){bl=Gt(e);for(let t of br)t()}function yl(){return bl}function kl(e){return br.add(e),()=>br.delete(e)}var Du=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),yr="report.keybind";function vl(e){if(Du.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 wl(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var Bu={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function xl(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 Bu[e]??e}function Nu(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function Jt(e,t=Nu()){let n=xl(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 Sl(e){return[e.ctrl&&"Control",e.alt&&"Alt",e.shift&&"Shift",e.meta&&"Meta",xl(e.code)].filter(Boolean).join("+")}function Hu(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}}var Fu={code:"KeyA",alt:!0,ctrl:!1,meta:!1,shift:!0},Rl="off";function El(e){if(e===Rl)return null;return Hu(e)??Fu}function Cl(){return El(A().getString(yr))}function kr(e){A().set(yr,e?JSON.stringify(e):Rl)}function Tl(e){let t=A();return t.watch?t.watch(yr,(n)=>e(El(n))):()=>{return}}var $u=["br","bl","tr","tl"];function vr(e,t){let n=e==="br"||e==="tr"?t.vw-t.w-t.edge:t.edge,r=e==="br"||e==="bl"?t.vh-t.h-t.bottom:t.top;return{x:Math.max(t.edge,n),y:Math.max(t.top,r),w:t.w,h:t.h}}function zu(e,t){let n=Math.min(e.x+e.w,t.x+t.w+12)-Math.max(e.x,t.x-12),r=Math.min(e.y+e.h,t.y+t.h+12)-Math.max(e.y,t.y-12);return n>0&&r>0?n*r:0}function Al(e,t,n){let r=vr(e,n);return t.reduce((o,i)=>o+zu(r,i),0)}function Ml(e,t,n){let r=Al(e,t,n);if(r===0)return e;let o=e,i=r;for(let s of $u){let a=Al(s,t,n);if(a<i)o=s,i=a}return o}function Ll(e,t,n,r){let o=e==="br"||e==="bl";if(t.vh-t.top-t.h-t.bottom>=n.h+r)return o?"above":"below";if(t.vw-2*t.edge-t.w>=n.w+r)return e==="br"||e==="tr"?"left":"right";return"over"}function xr(e){if(!(e instanceof C)||e.status!==400)return"";return/unknown field \\?"(\w+)\\?"/.exec(e.message)?.[1]??""}var Pl={ms:30000,bytesPerMs:32};class Il extends Error{constructor(e,t){super(`vitrinka: ${e} got no answer in ${Math.round(t/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function wr(e,t,n){let r=new AbortController,o,i=new Promise((s,a)=>{o=setTimeout(()=>{let l=new Il(e,t);r.abort(l),a(l)},t)});try{return await Promise.race([n(r.signal),i])}finally{clearTimeout(o)}}var Sr={chunks:[],truncated:!1,console:[],network:[]};function Ol(e,t=Pl.ms){return wr("preparing the capture",t,e).catch((n)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",n),Sr))}class Rr{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(e,t,n,r=[],o=Pl){this.capture=e;this.tabHost=t;this.target=n;this.files=r;this.limits=o}call(e,t,n){return wr(`${e} ${t}`,this.limits.ms,(r)=>X(e,t,n,{target:this.target,signal:r}))}upload(e,t,n){let r=typeof n==="string"?new TextEncoder().encode(n).byteLength:n.size,o=this.limits.ms+Math.ceil(r/this.limits.bytesPerMs);return wr(`POST ${e}`,o,(i)=>mn(e,t,n,this.target,i))}get filesPending(){return this.filesDone.size<this.files.length}async run(e,t){let n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let{res:i,memberSent:s}=await this.create(e);if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");if(this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r,typeof i.memberError==="string"&&i.memberError)t?.(i.memberError,s)}else if(this.sent!==r)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n),this.sent=r;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof C)||!q(i.status))throw i;console.warn("vitrinka: the server refused the recording — the report goes without it",i),this.skipCapture=!0}let o=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async create(e){let t=e;for(;;)try{return{res:await this.call("POST","/api/v1/reports",t),memberSent:t.memberToken??""}}catch(n){let r=xr(n);if(r==="type"&&t.type!==void 0){console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:o,...i}=t;t=i}else if(r==="memberToken"&&t.memberToken!==void 0){console.warn("vitrinka: this server takes no member link yet — sending the report without it");let{memberToken:o,...i}=t;t=i}else if(r==="context"&&t.context!==void 0){console.warn("vitrinka: this server takes no report context yet; sending the report without it");let{context:o,...i}=t;t=i}else throw n}}async sendFiles(){let e=encodeURIComponent(this.id);for(let[t,n]of this.files.entries()){if(this.filesDone.has(t))continue;try{await this.upload(`/api/v1/reports/${e}/attachment?name=${encodeURIComponent(n.name)}`,n.type||"application/octet-stream",n)}catch(r){if(!(r instanceof C)||!q(r.status))throw r;console.warn(`vitrinka: the server refused ${n.name} — the report goes without it`,r)}this.filesDone.add(t)}}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 this.upload(`/api/v1/reports/${e}/chunk?seq=${o.seq}`,"application/json",o.body);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+Ot);await this.call("POST",`/api/v1/reports/${e}/events`,{events:o}),this.rowsPosted+=o.length}}}async function Zt(e,t,n,r,o){let i=await fetch(n.url+t,{method:e,mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${n.key}`,...o?{"x-vitrinka-reporter":o}:{},...r!==void 0?{"content-type":"application/json"}:{}},body:r===void 0?void 0:JSON.stringify(r)}),s=await i.text();if(!i.ok)throw new C(`${e} ${t} → ${i.status}: ${s}`,i.status);return s?JSON.parse(s):{}}async function _l(e,t,n=""){if(!n)return Zt("POST","/api/v1/report/session",e,{token:t});try{return await Zt("POST","/api/v1/report/session",e,{token:t,memberToken:n})}catch(o){if(xr(o)!=="memberToken")throw o;return console.warn("vitrinka: this server takes no member link yet — the reporter session opens without it"),Zt("POST","/api/v1/report/session",e,{token:t})}}function Er(e,t){return e?JSON.stringify([e,t]):""}function Dl(e,t=Date.now()){return e!==null&&Date.parse(e.expiresAt)-t>60000}function Cr(e,t,n){let r=n?`?cursor=${encodeURIComponent(n)}`:"";return Zt("GET",`/api/v1/report/mine${r}`,e,void 0,t)}function Bl(e,t){return`vitrinka.report.sent:${e}|${t}`}function Nl(){try{return globalThis.localStorage??null}catch{return null}}function Tr(e,t){let n=Nl()?.getItem(Bl(e,t));if(!n)return[];try{let r=JSON.parse(n);if(!Array.isArray(r))return[];return r.filter((o)=>typeof o?.title==="string"&&typeof o?.at==="number"&&(o.status==="filed"||o.status==="quarantined"))}catch{return[]}}function Hl(e,t,n){let r=Nl();if(!r)return;let o=[n,...Tr(e,t)].slice(0,20);try{r.setItem(Bl(e,t),JSON.stringify(o))}catch(i){console.warn("vitrinka: could not remember the sent report on this browser",i)}}var Fl=`
10
10
  :host { all: initial; }
11
11
  .vr {
12
12
  --ink: #f2f1ef;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrinka/web",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "vitrinka toolkit for React DOM apps — the journey recorder (capture manual-testing sessions: rrweb DOM stream, clicks, navigation, network, console, notes) and Report a problem (a reporter's button, marks and the last minutes, cs/en), straight into vitrinka.",
5
5
  "license": "Elastic-2.0",
6
6
  "repository": {