@vitrinka/web 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +117 -19
  3. package/build/hud.iife.js +11 -11
  4. package/build/recorder/config.d.ts +6 -2
  5. package/build/recorder/hud/Hud.d.ts +3 -1
  6. package/build/recorder/hud/Hud.js +2 -2
  7. package/build/recorder/hud/Menu.d.ts +7 -1
  8. package/build/recorder/hud/Menu.js +2 -2
  9. package/build/recorder/hud/host.d.ts +13 -0
  10. package/build/recorder/hud/host.js +96 -1
  11. package/build/recorder/hud/icons.d.ts +2 -0
  12. package/build/recorder/hud/icons.js +4 -0
  13. package/build/recorder/hud/mount.d.ts +2 -0
  14. package/build/recorder/hud/mount.js +1 -0
  15. package/build/recorder/index.d.ts +6 -0
  16. package/build/recorder/index.js +3 -0
  17. package/build/recorder/link.js +1 -1
  18. package/build/recorder/version.d.ts +2 -2
  19. package/build/recorder/version.js +1 -1
  20. package/build/report/attachments.d.ts +56 -0
  21. package/build/report/attachments.js +91 -0
  22. package/build/report/drag.d.ts +18 -0
  23. package/build/report/drag.js +34 -0
  24. package/build/report/element.d.ts +11 -2
  25. package/build/report/element.js +106 -15
  26. package/build/report/engine.d.ts +5 -1
  27. package/build/report/engine.js +7 -1
  28. package/build/report/face.d.ts +23 -0
  29. package/build/report/face.js +92 -0
  30. package/build/report/i18n.d.ts +75 -3
  31. package/build/report/i18n.js +125 -6
  32. package/build/report/place.d.ts +26 -0
  33. package/build/report/place.js +33 -0
  34. package/build/report/reader.d.ts +42 -0
  35. package/build/report/reader.js +39 -0
  36. package/build/report/recorder-face.js +6 -2
  37. package/build/report/sent.d.ts +16 -0
  38. package/build/report/sent.js +39 -0
  39. package/build/report/settings.d.ts +32 -0
  40. package/build/report/settings.js +47 -0
  41. package/build/report/styles.d.ts +1 -1
  42. package/build/report/styles.js +216 -52
  43. package/build/report/widget.d.ts +109 -3
  44. package/build/report/widget.js +1063 -99
  45. package/build/report/wire.d.ts +20 -9
  46. package/build/report/wire.js +44 -9
  47. package/build/report-widget.mjs +223 -59
  48. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
- function Lt(e,t,n,r){if(e===1)return t;if(e>=2&&e<=4)return n;return r}var _i={button:"Report a problem",title:"Report a problem",close:"Close",settings:"Settings",prompt:"What went wrong?",placeholder:"Tell us what happened and what you expected",attached:(e)=>{if(e<60)return`The last ${e} seconds are attached`;let t=Math.round(e/60);return t===1?"The last minute is attached":`The last ${t} minutes are attached`},included:"What’s included",incReplay:"A replay of what happened on this page",incReplayMasked:{strict:"Text on the page and anything you typed are hidden in it",balanced:"Anything you typed is hidden in it",full:"It shows the page as you saw it"},incErrors:"Errors the page ran into",incConsole:"Messages from the browser console",incNetwork:"Which addresses the page loaded, with their status",incFailedRequests:"Requests that failed — address and status only",incEnv:"Your browser, screen size, language and this page’s address",incIdentity:"Your name and email from this app",incMarks:"The places you marked, with your notes",showWhere:"Show us where",marked:(e)=>e===1?"1 place marked":`${e} places marked`,notify:"Email me when it’s fixed",send:"Send",sending:"Sending…",retry:"Try again",errorCreate:"Couldn’t send — your text is safe, try again",errorCapture:"Your report arrived, the recording not yet — try again to attach it",sentTitle:"Thanks — we’ve got it",sentBody:"The team will take a look.",sentNotify:"We’ll email you when it’s fixed.",seeReport:"See your report",tools:{circle:"Circle",box:"Box",arrow:"Arrow",hide:"Hide"},toolbar:"Marking tools",undo:"Undo",done:"Done",coach:"Click, hold and move around the problem.",coachMore:"You can mark more than one place.",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Hidden",notePlaceholder:"Add a note (optional)",mark:(e)=>`Mark ${e}`,removeMark:(e)=>`Remove mark ${e}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back"},Li={button:"Nahlásit problém",title:"Nahlásit problém",close:"Zavřít",settings:"Nastavení",prompt:"Co se pokazilo?",placeholder:"Napište, co se stalo a co jste čekali",attached:(e)=>{if(e<60)return Lt(e,"Poslední sekunda je přiložena",`Poslední ${e} sekundy jsou přiloženy`,`Posledních ${e} sekund je přiloženo`);let t=Math.round(e/60);return Lt(t,"Poslední minuta je přiložena",`Poslední ${t} minuty jsou přiloženy`,`Posledních ${t} minut je přiloženo`)},included:"Co je přiloženo",incReplay:"Záznam toho, co se na stránce dělo",incReplayMasked:{strict:"Texty stránky i vše, co jste napsali, jsou v něm skryté",balanced:"Vše, co jste napsali, je v něm skryté",full:"Ukazuje stránku tak, jak jste ji viděli"},incErrors:"Chyby, na které stránka narazila",incConsole:"Zprávy z konzole prohlížeče",incNetwork:"Které adresy stránka načítala a s jakým výsledkem",incFailedRequests:"Požadavky, které selhaly — jen adresa a výsledek",incEnv:"Váš prohlížeč, velikost obrazovky, jazyk a adresa stránky",incIdentity:"Vaše jméno a e-mail z této aplikace",incMarks:"Místa, která jste označili, i s poznámkami",showWhere:"Ukažte nám kde",marked:(e)=>Lt(e,"1 označené místo",`${e} označená místa`,`${e} označených míst`),notify:"Pošlete mi e-mail, až to bude opravené",send:"Odeslat",sending:"Odesílám…",retry:"Zkusit znovu",errorCreate:"Nepodařilo se odeslat — váš text zůstal, zkuste to znovu",errorCapture:"Hlášení dorazilo, záznam zatím ne — zkuste to znovu a přiložíme ho",sentTitle:"Díky — máme to",sentBody:"Tým se na to podívá.",sentNotify:"Až to bude opravené, pošleme vám e-mail.",seeReport:"Zobrazit hlášení",tools:{circle:"Kruh",box:"Obdélník",arrow:"Šipka",hide:"Skrýt"},toolbar:"Nástroje pro označení",undo:"Zpět",done:"Hotovo",coach:"Klikněte, podržte a veďte kolem problému.",coachMore:"Označit můžete i více míst.",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Skryto",notePlaceholder:"Přidejte poznámku (nepovinné)",mark:(e)=>`Značka ${e}`,removeMark:(e)=>`Odebrat značku ${e}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět"},Di={cs:Li,en:_i};function Dt(e){return Di[e]}function Ce(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"?t:null}function Nt(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=Ce(n);if(r)return r}return"en"}var hr="[redacted]",Ni=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],Oi=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function ce(e){return String(e).toLowerCase().replace(/[-_]/g,"")}var Ot=null;function Bt(e){let t=JSON.stringify(e??null);if(Ot?.src===t)return Ot.rules;let n=new Set(Ni),r=new Set(Oi),o=[];for(let s of e?.extraHeaders??[]){let a=ce(s);if(a)n.add(a)}for(let s of e?.extraBodyKeys??[]){let a=ce(s);if(a)r.add(a)}for(let s of e?.patterns??[])try{o.push(new RegExp(s,"g"))}catch(a){console.warn("vitrinka redact: unsupported pattern skipped",s,a)}let i={full:e?.fullFidelity===!0,maskAllText:e?.maskAllText===!0,headers:n,bodyKeys:r,patterns:o};return Ot={src:t,rules:i},i}var Bi=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),Hi=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function qi(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t)=>t.toLowerCase())}function gr(e){let t=qi(e);if(t.some((n)=>Bi.has(n)))return!0;for(let n=0;n<t.length;n++){let r="";for(let o=n;o<t.length;o++){if(r+=t[o],Hi.includes(r))return!0;if(r.length>24)break}}return!1}function mr(e,t){let n=ce(t);return e.headers.has(n)||n.endsWith("apikey")||n.endsWith("token")||gr(t)}function W(e,t){return e.bodyKeys.has(ce(t))||gr(t)}function br(e,t){if(W(e,t))return!0;let n=ce(t);return n.endsWith("apikey")||n.endsWith("token")}var $i=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,Fi=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function yr(e){return e.includes("PRIVATE KEY-----")?e.replace($i,"[redacted]"):e}function de(e,t){let n=yr(t);for(let r of e.patterns)r.lastIndex=0,n=n.replace(r,"[redacted]");return n}function kr(e,t){if(Fi.test(t))return!0;for(let n of t.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(W(e,n[1]))return!0;return!1}function Xe(e){let t=e;for(let n=0;n<3;n++){let r=Ki(t);if(r===t)break;t=r}return t}function Ki(e){if(!e.includes("%"))return e;try{return decodeURIComponent(e)}catch{return e.replace(/(%[0-9A-Fa-f]{2})+/g,(t)=>{try{return decodeURIComponent(t)}catch{return t.replace(/%([0-9A-Fa-f]{2})/g,(n,r)=>{let o=Number.parseInt(r,16);return o<128?String.fromCharCode(o):n})}})}}function vr(e,t,n){let r=!1,o=n.split(/[&;]/).map((i)=>{if(i==="")return i;let s=i.indexOf("="),a=s>=0?i.slice(0,s):i,l=Xe(a.replace(/\+/g," ")),d=l.lastIndexOf("?"),g=d>=0?l.slice(d+1):null;if(t(e,l)||g!==null&&t(e,g))return r=!0,`${a}=[redacted]`;if(s>=0&&kr(e,Xe(i.slice(s+1))))return r=!0,`${a}=[redacted]`;return i});return r?o.join("&"):n}function Ht(e,t){if(e.full||!t)return t;let n=t.search(/[?#]/);if(n<0)return de(e,t);let r=t.slice(n+1).split("#").map((o)=>vr(e,br,o)).join("#");return de(e,t.slice(0,n+1)+r)}var Wi=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,zi=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,ji=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,Ui=131072;function Ge(e,t){if(t.length>Ui)return`[body omitted: ${t.length} bytes, unmaskable]`;let n=yr(t).replace(ji,(r,o)=>mr(e,o)?`${o}: [redacted]`:r).replace(/\b((?:proxy-)?authorization|www-authenticate)(\s*[:=]\s*)[^\r\n]+/gi,(r,o,i)=>`${o}${i}[redacted]`).replace(/\b(Digest|Negotiate|NTLM)\s+(?=[A-Za-z][A-Za-z-]{0,30}\s*=)[^\r\n]+/gi,(r,o)=>`${o} [redacted]`).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9._-]{10,}/g,"[redacted]").replace(zi,(r,o,i,s)=>{if(br(e,Xe(i)))return`${o}${i}=[redacted]`;if(kr(e,Xe(s)))return`${o}${i}=[redacted]`;return r}).replace(Wi,(r,o,i,s,a)=>{if(a==="[redacted]")return r;return W(e,o)?`${o}${i}${s}[redacted]${s}`:r});return de(e,n)}function Vi(e){switch(ce(e)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var Yi=64;function Je(e,t,n){if(n>Yi)return"[redacted]";if(Array.isArray(t))return t.map((r)=>Je(e,r,n+1));if(t!==null&&typeof t==="object"){let r={};for(let[o,i]of Object.entries(t))if(W(e,o))r[o]="[redacted]";else if(typeof i==="string"&&Vi(o))r[o]=Ht(e,i);else r[o]=Je(e,i,n+1);return r}return typeof t==="string"?de(e,t):t}function pr(e){if(!e.includes("\\"))return e;return e.replace(/\\u([0-9A-Fa-f]{4})|\\(.)/g,(t,n,r)=>n!==void 0?String.fromCharCode(Number.parseInt(n,16)):r)}function Xi(e,t){for(let n of t.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(W(e,pr(n[1])))return"";return t.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(n,r,o)=>W(e,pr(o))?`${r}"[redacted]"`:n)}function qt(e){let t=e.trimStart();return t.startsWith("{")||t.startsWith("[")}function Gi(e,t,n){let r=/boundary="?([^";]+)"?/i.exec(n);if(!r)return null;let o=`--${r[1]}`,i=t.split(o);if(i.length<3||i[0]!=="")return null;if(!i[i.length-1].startsWith("--"))return null;let s=[i[0]];for(let a=1;a<i.length-1;a++){let l=i[a];if(!l.startsWith(`\r
1
+ class _e extends Error{constructor(e="link code expired"){super(e);this.name="LinkExpired"}}class Jo extends Error{constructor(e,t){super(`linked into ${e} — this app records into ${t}; link again and pick ${t}`);this.linked=e,this.expected=t,this.name="LinkWorkspaceMismatch"}}class fe extends Error{constructor(e,t){super(e);this.status=t,this.name="LinkError"}}class S extends Error{constructor(e,t){super(e);this.status=t,this.name="VitrinkaApiError"}}function q(e){return e>=400&&e<500&&e!==408&&e!==429}function Zo(e){return new URL(e).origin}function at(e){let t=/^\/w\/([^/]+)/.exec(new URL(e).pathname);if(!t?.[1])return;try{return decodeURIComponent(t[1])}catch{return t[1]}}function Xo(e,t){if(!t)return e;let n=new URL(e);return n.searchParams.set("workspace",t),n.href}function Qo(e){return e===401}function ei(e){let t=e.fetch??globalThis.fetch;if(typeof t!=="function")throw Error("vitrinka link: no fetch available");return t}function Go(e,t,n,r){let o=(i)=>{if(!i)return;try{let s=new URL(i,e);if(s.protocol!=="http:"&&s.protocol!=="https:")return;if(s.origin===e)return s.href;return e+s.pathname+s.search}catch{return}};return o(t)??o(n)??e+r}function st(e,t,n){let r=e[t];if(typeof r!=="string"||r==="")throw new fe(`link start → malformed payload (${t})`,n);return r}async function ti(e,t){let n=Zo(e),r=await ei(t)(`${n}/api/v1/cli/auth`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"recorder",label:t.label})});if(r.status!==201&&r.status!==200)throw new fe(`link start → ${r.status}`,r.status);let o;try{o=await r.json()}catch{throw new fe("link start → malformed payload (not JSON)",r.status)}if(typeof o!=="object"||o===null)throw new fe("link start → malformed payload",r.status);let i=o,s=st(i,"device_code",r.status),a=st(i,"user_code",r.status),l=st(i,"verify_path",r.status),d=st(i,"qr_path",r.status);return{base:e,device_code:s,user_code:a,verify_path:l,verifyUrl:Xo(Go(n,typeof i.verify_url==="string"?i.verify_url:void 0,l,`/cli-auth?code=${encodeURIComponent(a)}`),t.workspace),qrUrl:Xo(Go(n,d,d,`/cli-auth/qr?code=${encodeURIComponent(a)}`),t.workspace),interval:Math.max(2,Number(i.interval)||2),expires_in:Number(i.expires_in)||0}}var ll=600,cl=30000;function dl(e){return e>=500||e===408||e===429}function ul(e,t){let n=e.headers.get("retry-after");if(!n)return;let r=Number(n);if(Number.isFinite(r)&&r>=0)return r*1000;let o=Date.parse(n);return Number.isNaN(o)?void 0:Math.max(0,o-t)}function pl(e,t){return new Promise((n,r)=>{if(t?.aborted)return r(nn());let o=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e),i=()=>{clearTimeout(o),r(nn())};t?.addEventListener("abort",i,{once:!0})})}function nn(){let e=Error("link polling aborted");return e.name="AbortError",e}async function ni(e,t,n={}){let r=Zo(e),o=ei(n),i=n.sleep??pl,s=n.now??Date.now,a=Math.max(2,n.interval??2),l=s()+(n.expiresIn&&n.expiresIn>0?n.expiresIn:ll)*1000,d=0,f=async(g,u)=>{d++;let p=l-s();if(p<=0)throw new _e(`link code expired (last claim: ${g})`);let m=Math.max(Math.min(cl,a*1000*2**d),u??0);await i(Math.min(m,p),n.signal)};for(;;){if(n.signal?.aborted)throw nn();let g;try{g=await o(`${r}/api/v1/cli/auth/claim`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({device_code:t}),signal:n.signal})}catch(u){if(n.signal?.aborted||!(u instanceof TypeError))throw u;await f(u.message);continue}if(dl(g.status)){await f(String(g.status),ul(g,s()));continue}if(d=0,g.status===200){let u=await g.json();if(n.workspace&&u.workspace!==n.workspace){let p=typeof u.workspace==="string"&&u.workspace?u.workspace:"(no workspace)";throw new Jo(p,n.workspace)}return u}if(g.status===404||g.status===410)throw new _e;if(g.status!==202)throw new fe(`link claim → ${g.status}`,g.status);await i(a*1000,n.signal)}}var w={tabId:"root",tabHost:"/",pathname:"/"};function ri(){try{let e=globalThis.sessionStorage,t=e.getItem("vitrinka.tab");if(t)return t;let n=Math.random().toString(36).slice(2,10);return e.setItem("vitrinka.tab",n),n}catch{return"root"}}function oi(e,t){w.tabId=e,w.tabHost=t}var Ne={following:null},Oe="__vitrinkaCaptureOwner";function ii(e,t){let n=globalThis,r=n[Oe];if(r){if(e==="report")return null;if(r.face==="report")n[Oe]=null,r.yieldTo?.()}let o=`${e}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return n[Oe]={face:e,token:o,...t?{yieldTo:t}:{}},o}function si(e){let t=globalThis;if(e&&t[Oe]?.token===e)t[Oe]=null}var rn=new Set;function ai(e){return rn.add(e),()=>rn.delete(e)}function X(){for(let e of rn)e()}async function li(e,t){let n=`vitrinka.recorder.${e}`;if(globalThis.navigator?.locks){await navigator.locks.request(n,{signal:AbortSignal.timeout(5000)},t);return}let r=await fl();await new Promise((o,i)=>{let s=r.transaction("locks","readwrite");s.oncomplete=()=>o(),s.onabort=()=>i(s.error??Error("vitrinka: recorder lock transaction aborted"));let a=s.objectStore("locks").get(n);a.onsuccess=()=>{try{t()}catch(l){i(l),s.abort()}}})}var Fe;function fl(){if(!Fe)Fe=new Promise((e,t)=>{let n=indexedDB.open("vitrinka.recorder.locks",1);n.onupgradeneeded=()=>n.result.createObjectStore("locks"),n.onerror=()=>t(n.error),n.onsuccess=()=>{let r=n.result;r.onversionchange=()=>{r.close(),Fe=void 0},e(r)}}).catch((e)=>{throw Fe=void 0,e});return Fe}var ie="vitrinka.recorder.",on=null,hl=!1;function M(){if(!on)on=gl()??ml();return hl=!0,on}function gl(){try{let e=globalThis.localStorage;if(!e)return null;let t=`${ie}probe`;return e.setItem(t,"1"),e.removeItem(t),{getString:(n)=>e.getItem(ie+n),set:(n,r)=>e.setItem(ie+n,r),remove:(n)=>e.removeItem(ie+n),withLock:li,keys:()=>Array.from({length:e.length},(n,r)=>e.key(r)).filter((n)=>n!==null&&n.startsWith(ie)).map((n)=>n.slice(ie.length)),watch:(n,r)=>{let o=(i)=>{if(i.storageArea===e&&i.key===ie+n)r(i.newValue)};return globalThis.addEventListener("storage",o),()=>globalThis.removeEventListener("storage",o)}}}catch{return console.warn("vitrinka: localStorage unavailable — the recorder queue will not survive a reload"),null}}function ml(){let e=new Map;return{getString:(t)=>e.get(t)??null,set:(t,n)=>void e.set(t,n),remove:(t)=>void e.delete(t),keys:()=>[...e.keys()]}}var he={url:"",key:""};function lt(){return he}var sn=new Set;function ci(e){let t=e.replace(/\/+$/,"");return sn.add(t),()=>sn.delete(t)}function an(e){if(he.url!==""&&e.startsWith(he.url))return!0;for(let t of sn)if(t!==""&&e.startsWith(t))return!0;return!1}var He="link";function ze(){let e=M().getString(He);if(!e)return null;try{let t=JSON.parse(e);return typeof t.token==="string"&&t.token?t:null}catch{return null}}function di(e){M().set(He,JSON.stringify(e)),X()}function ui(){M().remove(He),X()}function pi(){return he.key||ze()?.token||""}function fi(){if(he.label)return he.label;let e=globalThis.navigator?.userAgent??"",t=/Edg\//.test(e)?"Edge":/OPR\//.test(e)?"Opera":/Chrome\//.test(e)?"Chrome":/Firefox\//.test(e)?"Firefox":/Safari\//.test(e)?"Safari":"Browser",n=/iPhone|iPad/.test(e)?"iOS":/Android/.test(e)?"Android":/Mac OS X/.test(e)?"macOS":/Windows/.test(e)?"Windows":/Linux/.test(e)?"Linux":"unknown OS",r=globalThis.location?.host??"";return`${t} on ${n}${r?` · ${r}`:""}`}var gi="vitrinka.report.face",hi=(e)=>e.trim().replace(/\/+$/,"");function ct(){try{return globalThis.localStorage??null}catch{return null}}function $e(e){let t=ze();if(!t)return!1;if(t.base)return hi(t.base)===hi(e);try{let n=at(e);return n===void 0||n===t.workspace}catch{return!1}}function bl(){let e=ct()?.getItem(gi);return e==="recorder"||e==="report"?e:null}function mi(e){try{ct()?.setItem(gi,e)}catch(t){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",t)}}var bi="vitrinka.report.mode";function yi(e){try{if(e==="dev"||e==="regular")ct()?.setItem(bi,e)}catch(t){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",t)}}function ki(e){if(!$e(e))return"report";let t=bl();if(t)return t;return ct()?.getItem(bi)==="dev"?"recorder":"report"}function vi(e){let t=M().watch?.(He,()=>e()),n=ai(e);return()=>{t?.(),n()}}var wi=["bug","suggestion","question","other"];function ge(e,t,n,r){if(e===1)return t;if(e>=2&&e<=4)return n;return r}var yl={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:"Hide"},toolbar:"Marking tools",barLead:"Mark where the problem is",cancelMarking:"Cancel",discardMarks:(e)=>e===1?"Discard 1 mark?":`Discard ${e} marks?`,discard:"Discard",keep:"Keep",coach:"Click, hold and move around the problem.",coachMore:"You can mark more than one place.",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Hidden",notePlaceholder:"Add a note (optional)",mark:(e)=>`Mark ${e}`,removeMark:(e)=>`Remove mark ${e}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back",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",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`}},kl={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 ge(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 ge(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:"Skrýt"},toolbar:"Nástroje pro označení",barLead:"Označte, kde je problém",cancelMarking:"Zrušit",discardMarks:(e)=>ge(e,"Zahodit 1 značku?",`Zahodit ${e} značky?`,`Zahodit ${e} značek?`),discard:"Zahodit",keep:"Ponechat",coach:"Klikněte, podržte a veďte kolem problému.",coachMore:"Označit můžete i více míst.",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Skryto",notePlaceholder:"Přidejte poznámku (nepovinné)",mark:(e)=>`Značka ${e}`,removeMark:(e)=>`Odebrat značku ${e}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět",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",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)=>ge(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 ge(e,"1 sekunda",`${e} sekundy`,`${e} sekund`);let t=Math.round(e/60);return ge(t,"1 minuta",`${t} minuty`,`${t} minut`)}},vl={cs:kl,en:yl};function ln(e){return vl[e]}function Ke(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"?t:null}function cn(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=Ke(n);if(r)return r}return"en"}var wl=null;function xi(e){if(Qo(e))wl?.()}function Si(e){return e??{url:lt().url,key:pi()}}async function L(e,t,n,r={}){let{url:o,key:i}=Si(r.target),s=await fetch(o+t,{method:e,mode:"cors",credentials:"omit",keepalive:r.keepalive??!1,headers:{authorization:`Bearer ${i}`,...n!==void 0?{"content-type":"application/json"}:{}},body:n===void 0?void 0:JSON.stringify(n)}),a=await s.text();if(!s.ok){if(!r.target)xi(s.status);throw new S(`${e} ${t} → ${s.status}: ${a}`,s.status)}return a?JSON.parse(a):{}}function Ri(e,t,n){return Ti(e,"chunk",t,"application/json",n)}function Ei(e,t,n){return Ti(e,"shot",t,n.type,n)}function Ti(e,t,n,r,o){return dt(`/api/v1/sessions/${e}/${t}?seq=${n}`,r,o)}async function dt(e,t,n,r){let{url:o,key:i}=Si(r),s=await fetch(o+e,{method:"POST",mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${i}`,"content-type":t},body:n}),a=await s.text();if(!s.ok){if(!r)xi(s.status);throw new S(`POST ${e} → ${s.status}: ${a}`,s.status)}try{return JSON.parse(a)}catch{return{}}}var Ai="[redacted]",xl=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],Sl=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function me(e){return String(e).toLowerCase().replace(/[-_]/g,"")}var dn=null;function un(e){let t=JSON.stringify(e??null);if(dn?.src===t)return dn.rules;let n=new Set(xl),r=new Set(Sl),o=[];for(let s of e?.extraHeaders??[]){let a=me(s);if(a)n.add(a)}for(let s of e?.extraBodyKeys??[]){let a=me(s);if(a)r.add(a)}for(let s of e?.patterns??[])try{o.push(new RegExp(s,"g"))}catch(a){console.warn("vitrinka redact: unsupported pattern skipped",s,a)}let i={full:e?.fullFidelity===!0,maskAllText:e?.maskAllText===!0,headers:n,bodyKeys:r,patterns:o};return dn={src:t,rules:i},i}var Rl=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),El=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function Tl(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t)=>t.toLowerCase())}function Pi(e){let t=Tl(e);if(t.some((n)=>Rl.has(n)))return!0;for(let n=0;n<t.length;n++){let r="";for(let o=n;o<t.length;o++){if(r+=t[o],El.includes(r))return!0;if(r.length>24)break}}return!1}function Li(e,t){let n=me(t);return e.headers.has(n)||n.endsWith("apikey")||n.endsWith("token")||Pi(t)}function G(e,t){return e.bodyKeys.has(me(t))||Pi(t)}function Ii(e,t){if(G(e,t))return!0;let n=me(t);return n.endsWith("apikey")||n.endsWith("token")}var Cl=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,Ml=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function Di(e){return e.includes("PRIVATE KEY-----")?e.replace(Cl,"[redacted]"):e}function be(e,t){let n=Di(t);for(let r of e.patterns)r.lastIndex=0,n=n.replace(r,"[redacted]");return n}function Bi(e,t){if(Ml.test(t))return!0;for(let n of t.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(G(e,n[1]))return!0;return!1}function ut(e){let t=e;for(let n=0;n<3;n++){let r=Al(t);if(r===t)break;t=r}return t}function Al(e){if(!e.includes("%"))return e;try{return decodeURIComponent(e)}catch{return e.replace(/(%[0-9A-Fa-f]{2})+/g,(t)=>{try{return decodeURIComponent(t)}catch{return t.replace(/%([0-9A-Fa-f]{2})/g,(n,r)=>{let o=Number.parseInt(r,16);return o<128?String.fromCharCode(o):n})}})}}function _i(e,t,n){let r=!1,o=n.split(/[&;]/).map((i)=>{if(i==="")return i;let s=i.indexOf("="),a=s>=0?i.slice(0,s):i,l=ut(a.replace(/\+/g," ")),d=l.lastIndexOf("?"),f=d>=0?l.slice(d+1):null;if(t(e,l)||f!==null&&t(e,f))return r=!0,`${a}=[redacted]`;if(s>=0&&Bi(e,ut(i.slice(s+1))))return r=!0,`${a}=[redacted]`;return i});return r?o.join("&"):n}function pn(e,t){if(e.full||!t)return t;let n=t.search(/[?#]/);if(n<0)return be(e,t);let r=t.slice(n+1).split("#").map((o)=>_i(e,Ii,o)).join("#");return be(e,t.slice(0,n+1)+r)}var Pl=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,Ll=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,Il=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,Dl=131072;function pt(e,t){if(t.length>Dl)return`[body omitted: ${t.length} bytes, unmaskable]`;let n=Di(t).replace(Il,(r,o)=>Li(e,o)?`${o}: [redacted]`:r).replace(/\b((?:proxy-)?authorization|www-authenticate)(\s*[:=]\s*)[^\r\n]+/gi,(r,o,i)=>`${o}${i}[redacted]`).replace(/\b(Digest|Negotiate|NTLM)\s+(?=[A-Za-z][A-Za-z-]{0,30}\s*=)[^\r\n]+/gi,(r,o)=>`${o} [redacted]`).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9._-]{10,}/g,"[redacted]").replace(Ll,(r,o,i,s)=>{if(Ii(e,ut(i)))return`${o}${i}=[redacted]`;if(Bi(e,ut(s)))return`${o}${i}=[redacted]`;return r}).replace(Pl,(r,o,i,s,a)=>{if(a==="[redacted]")return r;return G(e,o)?`${o}${i}${s}[redacted]${s}`:r});return be(e,n)}function Bl(e){switch(me(e)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var _l=64;function ft(e,t,n){if(n>_l)return"[redacted]";if(Array.isArray(t))return t.map((r)=>ft(e,r,n+1));if(t!==null&&typeof t==="object"){let r={};for(let[o,i]of Object.entries(t))if(G(e,o))r[o]="[redacted]";else if(typeof i==="string"&&Bl(o))r[o]=pn(e,i);else r[o]=ft(e,i,n+1);return r}return typeof t==="string"?be(e,t):t}function Ci(e){if(!e.includes("\\"))return e;return e.replace(/\\u([0-9A-Fa-f]{4})|\\(.)/g,(t,n,r)=>n!==void 0?String.fromCharCode(Number.parseInt(n,16)):r)}function Ol(e,t){for(let n of t.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(G(e,Ci(n[1])))return"";return t.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(n,r,o)=>G(e,Ci(o))?`${r}"[redacted]"`:n)}function fn(e){let t=e.trimStart();return t.startsWith("{")||t.startsWith("[")}function Nl(e,t,n){let r=/boundary="?([^";]+)"?/i.exec(n);if(!r)return null;let o=`--${r[1]}`,i=t.split(o);if(i.length<3||i[0]!=="")return null;if(!i[i.length-1].startsWith("--"))return null;let s=[i[0]];for(let a=1;a<i.length-1;a++){let l=i[a];if(!l.startsWith(`\r
2
2
  `)||!l.endsWith(`\r
3
3
  `))return null;let d=l.indexOf(`\r
4
4
  \r
5
- `);if(d<0)return null;let g=l.slice(2,d),b=l.slice(d+4,-2),p=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(g)?.[1]??"",h=p!==""&&W(e,p)?"[redacted]":Ge(e,b);s.push(`\r
6
- ${g}\r
5
+ `);if(d<0)return null;let f=l.slice(2,d),g=l.slice(d+4,-2),p=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(f)?.[1]??"",m=p!==""&&G(e,p)?"[redacted]":pt(e,g);s.push(`\r
6
+ ${f}\r
7
7
  \r
8
- ${h}\r
9
- `)}return s.push(i[i.length-1]),s.join(o)}var wr=262144;function fr(e,t,n){if(e.full||!t)return t;try{if(qt(t)){if(t.length<=wr)try{return JSON.stringify(Je(e,JSON.parse(t),0))}catch{}return de(e,Xi(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return Ge(e,vr(e,W,t));if(r.includes("multipart/form-data")){let o=Gi(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return Ge(e,t)}catch{return"[redacted]"}}function xr(e,t){if(t===void 0)return;if(e.full)return t;if(qt(t))try{return JSON.stringify(Je(e,JSON.parse(t),0))}catch{}try{return Ge(e,t)}catch{return"[redacted]"}}function Sr(e,t,n,r){if(e.full)return t.length>n?`${t.slice(0,n)}…[truncated]`:t;if(t.length>n&&r?.toLowerCase().includes("multipart/form-data"))return`[multipart body omitted: oversized (${t.length} chars)]`;if(qt(t)&&t.length<=wr){let i=fr(e,t,r);return i.length>n?`${i.slice(0,n)}…[truncated]`:i}let o=t.length>n?`${t.slice(0,n)}…[truncated]`:t;return fr(e,o,r)}function Er(e,t,n){if(!t)return;let r=n?.maxValueLen??1024,o=n?.budget??8192,i={};for(let[s,a]of Object.entries(t)){let d=(e.full?String(a):mr(e,s)?"[redacted]":de(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function Rr(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var w={tabId:"root",tabHost:"/",pathname:"/"};function Tr(){try{let e=globalThis.sessionStorage,t=e.getItem("vitrinka.tab");if(t)return t;let n=Math.random().toString(36).slice(2,10);return e.setItem("vitrinka.tab",n),n}catch{return"root"}}function Mr(e,t){w.tabId=e,w.tabHost=t}var Ae={following:null},Ie="__vitrinkaCaptureOwner";function Cr(e,t){let n=globalThis,r=n[Ie];if(r){if(e==="report")return null;if(r.face==="report")n[Ie]=null,r.yieldTo?.()}let o=`${e}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return n[Ie]={face:e,token:o,...t?{yieldTo:t}:{}},o}function Ir(e){let t=globalThis;if(e&&t[Ie]?.token===e)t[Ie]=null}var Ji=new Set;function Pe(){for(let e of Ji)e()}async function Ar(e,t){let n=`vitrinka.recorder.${e}`;if(globalThis.navigator?.locks){await navigator.locks.request(n,{signal:AbortSignal.timeout(5000)},t);return}let r=await Zi();await new Promise((o,i)=>{let s=r.transaction("locks","readwrite");s.oncomplete=()=>o(),s.onabort=()=>i(s.error??Error("vitrinka: recorder lock transaction aborted"));let a=s.objectStore("locks").get(n);a.onsuccess=()=>{try{t()}catch(l){i(l),s.abort()}}})}var _e;function Zi(){if(!_e)_e=new Promise((e,t)=>{let n=indexedDB.open("vitrinka.recorder.locks",1);n.onupgradeneeded=()=>n.result.createObjectStore("locks"),n.onerror=()=>t(n.error),n.onsuccess=()=>{let r=n.result;r.onversionchange=()=>{r.close(),_e=void 0},e(r)}}).catch((e)=>{throw _e=void 0,e});return _e}var ee="vitrinka.recorder.",$t=null,Qi=!1;function z(){if(!$t)$t=es()??ts();return Qi=!0,$t}function es(){try{let e=globalThis.localStorage;if(!e)return null;let t=`${ee}probe`;return e.setItem(t,"1"),e.removeItem(t),{getString:(n)=>e.getItem(ee+n),set:(n,r)=>e.setItem(ee+n,r),remove:(n)=>e.removeItem(ee+n),withLock:Ar,keys:()=>Array.from({length:e.length},(n,r)=>e.key(r)).filter((n)=>n!==null&&n.startsWith(ee)).map((n)=>n.slice(ee.length)),watch:(n,r)=>{let o=(i)=>{if(i.storageArea===e&&i.key===ee+n)r(i.newValue)};return globalThis.addEventListener("storage",o),()=>globalThis.removeEventListener("storage",o)}}}catch{return console.warn("vitrinka: localStorage unavailable — the recorder queue will not survive a reload"),null}}function ts(){let e=new Map;return{getString:(t)=>e.get(t)??null,set:(t,n)=>void e.set(t,n),remove:(t)=>void e.delete(t),keys:()=>[...e.keys()]}}var Ze={url:"",key:""};function Qe(){return Ze}var Ft=new Set;function Pr(e){let t=e.replace(/\/+$/,"");return Ft.add(t),()=>Ft.delete(t)}function Kt(e){if(Ze.url!==""&&e.startsWith(Ze.url))return!0;for(let t of Ft)if(t!==""&&e.startsWith(t))return!0;return!1}var ns="link";function rs(){let e=z().getString(ns);if(!e)return null;try{let t=JSON.parse(e);return typeof t.token==="string"&&t.token?t:null}catch{return null}}function _r(){return Ze.key||rs()?.token||""}var ue=Bt(null);function Dr(e){ue=Bt(e??null)}function Nr(e){return xr(ue,e)}function Wt(e,t,n){return Sr(ue,e,t,n)}var Lr=null,Or=null;function zt(e){Or=e??null}function os(e){let t=Or??Qe().sanitizeUrl;if(!t)return e;let n;try{let r=t(e);if(typeof r==="string")return r;n=`returned ${typeof r}`}catch{n="threw"}if(Lr!==t)Lr=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return is(e)??hr}function is(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function te(e){return Ht(ue,os(e))}var ss=4;function jt(e){return e.type===ss}function Ut(e){if(!jt(e))return e;return{...e,data:{...e.data,href:te(e.data.href)}}}function Le(e){return Er(ue,e)}function Br(){return Rr(ue)}var De="data-vitrinka-recorder";var Vt="all:initial;position:fixed;z-index:2147483647;inset:0 auto auto 0;margin:0;padding:0;border:0;background:transparent;overflow:visible;width:0;height:0;pointer-events:none;color-scheme:normal;",Hr=Vt;var as=["pointerdown","pointerup","pointermove","pointerover","pointerout","pointercancel","mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchmove","touchcancel","wheel","focusin","focusout","keydown","keyup","keypress","paste","dragenter","dragover","dragleave","drop"];function $r(e){for(let t of as)e.addEventListener(t,(n)=>n.stopPropagation())}function Fr(){let e=document.createElement("div");e.setAttribute(De,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=Vt;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),$r(e),document.documentElement.append(e);let r=typeof e.showPopover==="function",o=()=>{if(!r||!e.isConnected)return;try{e.hidePopover?.()}catch{}try{e.showPopover?.()}catch{}};if(r)e.popover="manual";o();let i=!1,s=()=>{if(i)return;i=!0,queueMicrotask(()=>{i=!1,o()})},a=(c)=>{if(c.type==="attributes")return c.target instanceof Element&&qr(c.target);for(let p of[c.addedNodes,c.removedNodes])for(let h of p){if(!(h instanceof Element))continue;if(qr(h))return!0;if(h.childElementCount>0&&h.querySelector(Kr))return!0}return!1},l=[],d=0,g=()=>{d=0;let c=l;if(l=[],c.some(a))s()},b=new MutationObserver((c)=>{for(let p of c)l.push(p);if(d===0)d=typeof requestAnimationFrame==="function"?requestAnimationFrame(g):setTimeout(g,16)});return b.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:e,mount:n,destroy:()=>{if(b.disconnect(),d!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(d);l=[];try{e.hidePopover?.()}catch{}e.remove()}}}var Kr='dialog,[role="dialog"]';function qr(e){return e.matches(Kr)}function Wr(){let e=document.querySelectorAll("dialog[open]"),t=e[e.length-1];if(t)return t;let n=document.querySelectorAll('[role="dialog"][data-state="open"]');return n[n.length-1]??null}function zr(e){let t=document.createElement("div");t.setAttribute(De,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=Hr;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");return n.append(r),$r(t),e.append(t),{mount:r,destroy:()=>t.remove()}}function jr(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]"))}function N(e,t,n,r={}){let o=e,i=o.__zone_symbol__addEventListener??e.addEventListener,s=o.__zone_symbol__removeEventListener??e.removeEventListener,a=r.capture??!1;return i.call(e,t,n,{capture:a,passive:!1}),()=>s.call(e,t,n,a)}class T extends Error{constructor(e,t){super(e);this.status=t,this.name="VitrinkaApiError"}}function j(e){return e>=400&&e<500&&e!==408&&e!==429}function Ur(e){return e===401}var ls=null;function Vr(e){if(Ur(e))ls?.()}function Yr(e){return e??{url:Qe().url,key:_r()}}async function O(e,t,n,r={}){let{url:o,key:i}=Yr(r.target),s=await fetch(o+t,{method:e,mode:"cors",credentials:"omit",keepalive:r.keepalive??!1,headers:{authorization:`Bearer ${i}`,...n!==void 0?{"content-type":"application/json"}:{}},body:n===void 0?void 0:JSON.stringify(n)}),a=await s.text();if(!s.ok){if(!r.target)Vr(s.status);throw new T(`${e} ${t} → ${s.status}: ${a}`,s.status)}return a?JSON.parse(a):{}}function Xr(e,t,n){return Jr(e,"chunk",t,"application/json",n)}function Gr(e,t,n){return Jr(e,"shot",t,n.type,n)}function Jr(e,t,n,r,o){return Yt(`/api/v1/sessions/${e}/${t}?seq=${n}`,r,o)}async function Yt(e,t,n,r){let{url:o,key:i}=Yr(r),s=await fetch(o+e,{method:"POST",mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${i}`,"content-type":t},body:n}),a=await s.text();if(!s.ok){if(!r)Vr(s.status);throw new T(`POST ${e} → ${s.status}: ${a}`,s.status)}try{return JSON.parse(a)}catch{return{}}}var Zr=30000,cs=4194304,ds=20000,Jt=500,us=2000,ps=2,Qr={windowMs:Zr,checkoutMs:Zr,maxBytes:cs,maxEvents:ds,maxLaneEvents:Jt},V=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function Zt(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var fs=new TextEncoder,X=!1,eo=0,E=Qr,v=[],M=[],B=[],U=[],hs=0,fe=[],he=new Map,ge=null,pe=null,Ne=!1,gs=0,Y=null,et=null,Gt=Promise.resolve();function to(e=Qr){if(en(),X=!0,eo++,E=e,Y=e.store??null,v=(e.prior??[]).filter((t)=>t.kind!=="lanes").map((t)=>({id:t.id,load:t.load,startMs:t.startMs,lastMs:t.lastMs,events:[],count:t.count,bytes:t.bytes,href:t.href,route:t.route,stored:!0})),M=(e.priorLanes??[]).slice(-e.maxLaneEvents),B=[],U=[],fe=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),he.clear(),ge=null,nt(Date.now()),Y)et=setInterval(tt,us)}function no(){tt(),en(),X=!1,Y=null,v=[],M=[],B=[],U=[],fe=[],he.clear(),ge=null}function ro(){return E}function Qt(e){pe=e}function oo(){if(!X)return;v=[],M=[],B=[],U=[],fe=[],he.clear(),ge=null;let e=w.tabId;ne((t)=>t.clear(e)),pe?.()}function io(){return Gt}function tt(){if(!X||!Y)return;let e=Date.now();nt(e),tn(e);for(let t of v){if(t.stored)continue;let n=he.get(t.id)??{events:0,parts:0};if(n.events===t.events.length)continue;let r=JSON.stringify(t.events.slice(n.events)),o=n.parts;he.set(t.id,{events:t.events.length,parts:o+1});let i=so(t);ne((s)=>s.putWindowChunk(i,o,r,[]))}ms(e)}function ms(e){let t=e-E.windowMs;while(U.length>0&&U[0].lastMs<=t){let[a]=U.splice(0,1);if(a)ne((l)=>l.dropWindow(a.id))}for(let a of fe.filter((l)=>l.lastMs<=t))ne((l)=>l.dropWindow(a.id));fe=fe.filter((a)=>a.lastMs>t);let n=B;if(!n.length)return;B=[];let r=U.at(-1);if(!r||r.startMs<=t)r={id:`${V}.lanes.${++hs}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},U.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:w.tabId,scope:E.scope??"",kind:"lanes",load:V,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};ne((a)=>a.putWindowChunk(s,o,"[]",n))}function en(){if(et)clearInterval(et);et=null}function so(e){return{id:e.id,tab:w.tabId,scope:E.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function ne(e){let t=Y;if(!t)return;Gt=Gt.then(()=>e(t)).catch((n)=>{if(Y!==t)return;Y=null,en(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function Xt(e){let[t]=v.splice(e,1);if(!t)return;he.delete(t.id),ne((n)=>n.dropWindow(t.id))}function nt(e){while(v.length>0){let r=v[0],o=v[1];if(!o&&r.load===V)break;if(Zt(r,o)>e-E.windowMs)break;Xt(0)}if(Ne)return;let t=v.at(-1);if(t&&t.load===V&&pe&&t.lastMs<=e-E.windowMs){Ne=!0;try{pe()}finally{Ne=!1}let r=v.indexOf(t);if(r>=0&&r<v.length-1)for(let o=r;o>=0;o--)Xt(o)}let n=!1;while(v.length>0&&bs()){if(v.length===1&&v[0].load===V&&!n&&pe){n=!0,Ne=!0;try{pe()}finally{Ne=!1}if(v.length>1)continue}Xt(0),ge=v[0]?.startMs??e}}function ao(){return X?`flight:${eo}`:null}function tn(e){let t=Math.min(v[0]?.startMs??Number.POSITIVE_INFINITY,e-E.windowMs),n=M.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)M=[];else if(n>0)M=M.slice(n)}function bs(){let e=0,t=0;for(let n of v)e+=n.bytes,t+=n.count;return e>E.maxBytes||t>E.maxEvents}function lo(e){if(!X)return;let t=v[0];if(jt(e)){let r=globalThis.location?.pathname??w.pathname,o={id:`${V}.${++gs}`,load:V,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:te(r)};v.push(o);let i=so(o);ne((s)=>s.putWindow(i))}let n=v.at(-1);if(!n||n.load!==V)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=fs.encode(JSON.stringify(e)).length,nt(e.timestamp),v[0]!==t)tn(e.timestamp)}function co(e,t,n){if(!X)return null;let r=E.keepLane?E.keepLane(e,t):t;if(r===null)return null;let o=new Date().toISOString(),i={ts:o,tabId:n.tabId,tabHost:n.tabHost,kind:e,payload:r},s=E.maxLaneEvents;if(M.push(i),M.length>s)M.splice(0,M.length-s);if(Y){if(B.push(i),B.length>s)B.splice(0,B.length-s)}return o}function nn(){if(!X)return null;let e=Date.now();return nt(e),tn(e),{windows:v.map((t)=>({...t,events:t.events.slice()})),lanes:M.slice(),truncated:ge!==null&&ge>e-E.windowMs}}function uo(e){return e.windows.some((t)=>t.events[1]?.type===ps)}var rn=null;function rt(){if(!rn)rn=typeof indexedDB>"u"?ys():ks();return rn}function ys(){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 ks(){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 vs=2000,ln=20000,wo=200,ws=4194304,xs=3145728,pt=500,Ss=ws-1024,Es=12582912,Rs=10485760,Ts=Es-64,Ms=1048576,Cs=new TextEncoder;function Re(e){return Cs.encode(e).length}var x=()=>z();function q(e,t){let n=x().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var po=!1;function F(e,t){try{return x().set(e,t),!0}catch(n){if(!po)po=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var st="rec",ie;function S(){if(ie===void 0)ie=q(st,null);return ie}function xo(e){if(ie=e,e===null)x().remove(st),x().remove(Is);else F(st,JSON.stringify(As(e)))}var Is="notes";var Be=null;function As(e){if(Be?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:Be.activeMs,resumeAt:null,stopping:Be.at}}var Ps=new Set;function _s(){for(let e of Ps)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function Ls(e){let t=null;if(e)try{t=JSON.parse(e)}catch{return"unchanged"}let n=S();if(t?.stopping&&t.sessionId===n?.sessionId&&!n.paused&&Be?.sessionId!==t.sessionId)_s();if(!t){if(!n)return"unchanged";return ie=null,vo(),js(),"ended"}if(n?.sessionId===t.sessionId){if(t.seq=Math.max(t.seq,n.seq),t.policy===void 0&&n.policy!==void 0)t.policy=n.policy;if(t.attachments===void 0&&n.attachments!==void 0)t.attachments=n.attachments;if(Be?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return ie=t,"updated"}return ie=t,vo(),"joined"}var Ds=700,se,H=null,Z=!1;function be(){if(se===void 0)se=q("buffer",[]);return se}function ft(){if(H)clearTimeout(H),H=null;if(se!==void 0&&!Z)F("buffer",JSON.stringify(se))}function So(){if(Z=!1,H)return;H=setTimeout(()=>{H=null,ft(),Eo()},Ds)}function fo(e){se=e,Z=!1,ft()}var me,ke=0;function re(){if(me===void 0)me=q("chunks",[]),ke=me.reduce((e,t)=>e+t.body.length,0);return me}function Eo(){if(Z)return;let e=re();if(e.length===0){x().remove("chunks");return}if(ke>Ms){x().remove("chunks");return}F("chunks",JSON.stringify(e))}function Ns(e){me=e,ke=e.reduce((t,n)=>t+n.body.length,0),Z=!1,Eo()}var at,ve=new Map,ye=new Set,we=new Map,ot=new Map,ho=5,Os=200,Bs=67108864,Hs=0,go=!1,qs="blobs";function C(){return at??=q("images",[]),at}function Ro(){if(Z)return;let e=C().filter((t)=>!ye.has(t.blob));if(e.length===0)x().remove("images");else F("images",JSON.stringify(e))}function To(e){at=e,Z=!1,Ro()}function $s(e,t){let n=rt();if(!n.durable&&!go)go=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");F(qs,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${Ao}.${++Hs}`;return ve.set(a,i),ye.add(a),r.push(n.put(a,i).then(()=>{if(!(ve.has(a)||C().some((d)=>d.blob===a)||[...we.values()].includes(a)))return ye.delete(a),cn(a),!1;if(!n.durable)return!1;if(ye.delete(a),C().some((d)=>d.blob===a))Ro();return!0},(l)=>(console.warn("vitrinka: an attached image could not be journaled — it will not survive a reload",l),!1))),{blob:a,payload:s}}),journaled:Promise.all(r).then((i)=>i.every(Boolean))}}function cn(e){rt().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function xe(e,t){for(let n of e)if(ve.delete(n),ye.delete(n),ot.delete(n),t)cn(n)}var lt=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];var Fs=0,Mo="",Co=0,mo=-1;function dn(){Fs=Date.now(),Co=0,Mo=""}function Se(e){Co++,Mo=String(e instanceof Error?e.message:e).slice(0,200)}var bo={actions:0,pages:0,frames:0,notes:0},Ks=new Set;function Ws(e){let t={...bo};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")Ks.add(n.payload.cid)}bo=t}function zs(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;xo(t),console.warn("vitrinka: session marked dead —",e),Pe()}var on=null;function js(){if(on)clearInterval(on);on=null}function Io(e){let t=S();if(!t||t.dead||e<1)return null;let n=q("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return x().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,xo(t),{seq:r,sessionId:t.sessionId}}var Ao=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,ct="allocation.",Us=0,I=new Set,Vs=16777216,dt=0,ut=0,Ee=new Map;function ht(e){return e.kind==="event"?1+(e.images?.length??0):1}function Ys(e,t){return new Set(Array.from({length:ht(t)},(n,r)=>e+r))}function un(e,t,n){return JSON.stringify(n&&n.size<ht(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var yo=!1,Oe=null;function it(e){if(!I.delete(e))return;if(dt-=e.bytes,e.draft.kind==="chunk")ut--}function Po(e){if(I.add(e),dt+=e.bytes,e.draft.kind==="chunk")ut++;while(I.size>ln||dt>Vs||ut>wo){let t=I.values().next().value;it(t),x().remove(t.key),xe(lt(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");Se(n),console.warn(n.message)}}function _o(e=!1){if(yo&&!e)return;yo=!0;let t=x();if(!t.withLock)return;let n=new Set([...I].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(ct)||n.has(r)||Ee.has(r))continue;let o=q(r,null);if(o&&o.draft&&o.draft.sessionId===S()?.sessionId)Po({...o,key:r,persisted:!0,bytes:Re(JSON.stringify(o))})}}function Lo(e,t,n){let{ts:r,tabId:o,tabHost:i,sessionId:s}=e,a=(l)=>!n||n.has(l);if(e.kind==="event"){let l=e.images??[],d=t+l.length,g=l.length?{...e.event,payload:{...e.event.payload,attachments:l.map((c,p)=>t+p)}}:e.event,b=be();if(a(d)&&!b.some((c)=>c.seq===d))b.push({seq:d,ts:r,tabId:o,tabHost:i,...g});if(l.length){let c=C();l.forEach((h,k)=>{let m=t+k;if(!a(m)||c.some((y)=>y.seq===m))return;if(b.some((y)=>y.seq===m)){we.set(m,h.blob);return}c.push({seq:m,ts:r,tabId:o,tabHost:i,sessionId:s,blob:h.blob,payload:h.payload})});let p=c.reduce((h,k)=>h+k.payload.bytes,0);while(c.length>Os||p>Bs){let h=c.shift();p-=h.payload.bytes,J(h.sessionId,new Set([h.seq])),xe([h.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${h.payload.name} (seq ${h.seq}); its note lands without it`)}To(c)}if(b.length>ln){let c=b.splice(0,b.length-ln);J(s,new Set(c.map((p)=>p.seq))),console.warn(`vitrinka: retry buffer full — dropped ${c.length} oldest events`)}}else{let l=re();if(!l.some((d)=>d.seq===t)&&!be().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),ke+=e.part.body.length;while(l.length>wo){let d=l.shift();ke-=d.body.length,J(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}So(),oe()}function J(e,t){for(let[n,r]of Ee){if(r.sessionId!==e)continue;let o=r.seqs.size;for(let s of r.seqs)if(t.has(s))r.seqs.delete(s);let i=r.seqs.size&&r.seqs.size<o&&r.persisted?q(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)F(n,un(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){x().remove(n),Ee.delete(n);let s=n.slice(ct.length,n.lastIndexOf(".")),a=`tab.${s}`,l=q(a,null);if(l?.departed&&l.recoverable&&!x().keys?.().some((d)=>d.startsWith(`${ct}${s}.`)))x().remove(a)}}}function Do(){if(Oe)return Oe;let e=x();return Oe=pn(Promise.resolve().then(async()=>{for(let t of I)await e.withLock("seq",()=>{if(!I.has(t))return;if(t.persisted){let o=q(t.key,null);if(!o){it(t),xe(lt(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(Ls(e.getString(st)??null),S()?.sessionId!==t.draft.sessionId){it(t),xe(lt(t.draft),!0);return}let n=t.seq??Io(ht(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):Ys(n,t.draft);if(t.persisted)e.set(t.key,un(t.draft,n,r));Ee.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),Lo(t.draft,n,r),it(t)})}).catch((t)=>{throw Se(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),oe(),Pe(),t})).finally(()=>{Oe=null}),Oe}function No(e,t){let n=S(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(_o(),x().withLock){let o=`${ct}${Ao}.${++Us}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&F(o,i),bytes:Re(i)};Po(s),Do(),t?.then((a)=>{if(a)Xs(s)})}else{let o=Io(ht(e));if(o)Lo(e,o.seq);else xe(lt(e),!0)}return!0}function Xs(e){let t=Ee.get(e.key);if(t)t.persisted=F(e.key,un(e.draft,e.seq,t.seqs));else if(I.has(e))e.persisted=F(e.key,JSON.stringify({draft:e.draft}))}var ko=new Set;function pn(e){return ko.add(e),e.catch(()=>{return}).finally(()=>{ko.delete(e)})}function G(e){return S()?.sessionId!==e.sessionId}function He(e,t,n,r=[]){if(Ae.following)return null;let o=S();if(!o)return co(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?$s(o.sessionId,r):null;return No({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),fn(),i}function Oo(e){be().push(e),fn(),So(),oe()}var Gs=Date.now();function fn(){Gs=Date.now()}function hn(e,t=Rs,n=Ts){let r=[],o=[],i=[],s=2,a=()=>{if(!i.length)return;r.push({count:i.length,body:`[${i.join(",")}]`}),i=[],s=2};for(let l of e){let d=JSON.stringify(l),g=Re(d)+1;if(g>n){o.push(g);continue}if(g>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+g>t)a();i.push(d),s+=g}return a(),{parts:r,dropped:o}}function Bo(e,t){if(!e.length)return 0;let n=S();if(!n||n.paused||n.dead||Ae.following)return 0;let{parts:r,dropped:o}=hn(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),He("note",{text:`⚠ rrweb event dropped (${(l/1048576).toFixed(1)} MiB > chunk cap) — replay may be incomplete from here`},t);let i=new Date().toISOString(),{tabId:s,tabHost:a}=t;for(let l of r)if(!No({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return fn(),r.length}async function Js(e=5){let t=re();if(t.length===0)return!0;let n=S(),r=0,o=new Set;for(let i of t){if(r>=e)break;if(r++,!n||i.sessionId!==n.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${i.seq} from ended session ${i.sessionId}`),o.add(i.seq);continue}try{let s=await Xr(n.sessionId,i.seq,i.body);if(G(n))return re().length===0;Oo({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),dn(),o.add(i.seq)}catch(s){if(G(n))return re().length===0;if(s instanceof T&&j(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),J(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}Se(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Ns(re().filter((i)=>!o.has(i.seq)));return re().length===0}async function Zs(e=4){let t=C();if(t.length===0)return!0;let n=S(),r=0,o=new Set,i=[];for(let s of t){if(r>=e)break;if(r++,!n||s.sessionId!==n.sessionId){console.warn(`vitrinka: dropping attachment seq ${s.seq} from ended session ${s.sessionId}`),o.add(s.seq),i.push(s.blob);continue}let a=ve.get(s.blob)??null;if(!a){try{a=await rt().get(s.blob),ot.delete(s.blob)}catch(l){if(G(n))return C().length===0;let d=(ot.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${ho})`,l),d<ho){ot.set(s.blob,d),Se(l);break}}if(G(n))return C().length===0}if(!a){console.warn(`vitrinka: attachment seq ${s.seq} (${s.payload.name}) lost its bytes — its note lands without it`),J(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await Gr(n.sessionId,s.seq,a);if(G(n))return C().length===0;Oo({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),ve.delete(s.blob),we.set(s.seq,s.blob),dn(),o.add(s.seq)}catch(l){if(G(n))return C().length===0;if(l instanceof T&&j(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),J(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}Se(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)ft(),To(C().filter((s)=>!o.has(s.seq)));return xe(i,!0),C().length===0}var sn=null;function oe(){if(sn)return;sn=setTimeout(()=>{sn=null,Qs()},vs)}var an=!1;async function Qs(e={}){if(an)return!1;an=!0;try{return await ea(e)}finally{an=!1}}async function ea(e){if(S()?.dead)return!1;if(_o(!0),I.size)await Do();if(I.size)return!1;let t=await Js(),n=e.keepalive?C().length===0:await Zs(),r=t&&n;if(!r)oe();let o=S(),i=be();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:xs;for(let c of i){if(s.length>=pt)break;let p=Re(JSON.stringify(c))+1;if(p>Ss){console.warn(`vitrinka: event seq ${c.seq} (${p} bytes) exceeds the wire cap — dropped`),a.add(c.seq);continue}if(p>d){if(e.keepalive)break;if(s.length===0)s.push(c),l=p;break}if(s.length>0&&l+p>d)break;s.push(c),l+=p}if(a.size){if(J(o.sessionId,a),fo(be().filter((c)=>!a.has(c.seq))),!s.length)return oe(),!1}if(!s.length)return!1;ft();try{await O("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(c){if(G(o))return!1;if(c instanceof T&&j(c.status))return zs(`server rejected this session (${c.status})`),!1;return Se(c),Pe(),console.warn("vitrinka: flush failed, retrying",c),oe(),!1}if(G(o))return!0;dn(),mo=Math.max(mo,...s.map((c)=>c.seq)),Ws(s);let g=new Set(s.map((c)=>c.seq));J(o.sessionId,g);let b=be().filter((c)=>!g.has(c.seq));fo(b),Pe();for(let c of g){let p=we.get(c);if(p===void 0)continue;we.delete(c),cn(p)}if(b.length)oe();return!0}function vo(){if(H)clearTimeout(H),H=null;se=[],me=[],ke=0,at=[],ve.clear(),ye.clear(),we.clear(),I.clear(),dt=ut=0,Ee.clear(),Z=!0}var ta=8192,qe="__vitrinkaRecorderConsolePatched";function gt(e){return e.map((t)=>{if(typeof t==="string")return t;if(t instanceof Error)return t.stack??t.message;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ").slice(0,ta)}function mt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;He("console",{level:t,text:Nr(e)},{tabId:w.tabId,tabHost:w.tabHost})}var gn="__vitrinkaRecorderConsoleUnpatch",Ho={};function qo(){let e=globalThis;if(e[qe]!==void 0&&e[qe]!==Ho)return;e[gn]?.()}function $o(e={}){let t=globalThis;if(t[qe])return;t[qe]=Ho;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{mt(gt(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let g=console[d],b=g.bind(console),c=(...p)=>{b(...p);try{mt(gt(p),d)}catch{}};return console[d]=c,()=>{if(console[d]===c)console[d]=g}}),s=(d)=>{try{mt(gt([d.error??d.message]))}catch{}},a=(d)=>{try{mt(`unhandled rejection: ${gt([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[gn]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[qe],delete t[gn]}}var Fo=65536,$e=524288,Ko=3000;var mn="full";function yn(){if(Ae.following)return null;let e=S();if(e)return!e.paused&&!e.dead?e.sessionId:null;return ao()}function Fe(e){return e!==null&&yn()===e}function bt(e,t){if(typeof e==="string")return Wt(e,Fo,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return Wt(e.toString(),Fo,"application/x-www-form-urlencoded");return na(e)}function na(e){if(e==null)return;if(typeof FormData<"u"&&e instanceof FormData){let t=0;try{e.forEach(()=>t++)}catch{}return`[formdata body omitted: ${t} field(s)]`}if(typeof Blob<"u"&&e instanceof Blob)return`[blob body omitted: ${e.size} bytes${e.type?`, ${e.type}`:""}]`;if(e instanceof ArrayBuffer)return`[buffer body omitted: ${e.byteLength} bytes]`;if(ArrayBuffer.isView(e))return`[buffer body omitted: ${e.byteLength} bytes]`;if(typeof ReadableStream<"u"&&e instanceof ReadableStream)return"[stream body omitted]";return`[${typeof e} body omitted]`}function bn(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function kn(e){return typeof e==="string"||e instanceof URL?{}:e}function Ke(e){let t=typeof e.url==="string"?te(e.url):e.url;He("net",{...e,url:t},{tabId:w.tabId,tabHost:w.tabHost})}function vn(e){if(!e)return;try{let t={},n=e;if(typeof n.forEach==="function")if(Array.isArray(e)){for(let r of e)if(Array.isArray(r)&&r.length>=2)t[String(r[0])]=String(r[1])}else n.forEach((r,o)=>{t[o]=String(r)});else if(typeof e==="object")for(let[r,o]of Object.entries(e))t[r]=String(o);return Object.keys(t).length>0?t:void 0}catch{return}}function ra(e,t){let n=vn(t?.headers);if(n)return n;let r=kn(e);return vn(r.headers)}function oa(e){if(!e)return;let t={};for(let n of e.split(/\r?\n/)){let r=n.indexOf(":");if(r>0)t[n.slice(0,r).trim()]=n.slice(r+1).trim()}return Object.keys(t).length>0?t:void 0}function wn(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function ia(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function sa(e,t){let n=await aa(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return bt(n,r)}async function aa(e,t){let n=ia(t);if(n!==null&&n>$e)return wn(e),`[body omitted: ${n} bytes]`;let r=e.body;if(r?.getReader){let o=r.getReader(),i=[],s=0,a=!1,l=!1,d=Date.now()+Ko;try{while(s<$e){let p=d-Date.now();if(p<=0){l=!0;break}let h,k=await Promise.race([o.read(),new Promise((f)=>{h=setTimeout(()=>f("timeout"),p)})]).finally(()=>{if(h!==void 0)clearTimeout(h)});if(k==="timeout"){l=!0;break}let{done:m,value:y}=k;if(m)break;if(y){let f=$e-s,R=y.byteLength>f?y.subarray(0,f):y;i.push(R),s+=R.byteLength}}a=s>=$e,o.cancel().catch(()=>{return})}catch{return}let g=new Uint8Array(s),b=0;for(let p of i)g.set(p,b),b+=p.byteLength;let c;try{c=new TextDecoder().decode(g)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${c}…[body read timed out after ${Ko}ms]`;return a?`${c}…[truncated at ${$e} bytes]`:c}if(n===null)return wn(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var We="__vitrinkaRecorderNetPatched",xn="__vitrinkaRecorderNetUnpatch",Wo={};function zo(){let e=globalThis;if(e[We]!==void 0&&e[We]!==Wo)return;e[xn]?.()}function jo(e={}){let t=globalThis;if(t[We])return;t[We]=Wo,mn=e.detail??"full";let n=[];t[xn]=()=>{for(let c of n.splice(0))c();delete t[We],delete t[xn]};let r=globalThis.fetch,o=async(c,p)=>{let h=typeof c==="string"?c:c instanceof URL?c.href:c.url,k=yn();if(Kt(h)||k===null)return r(c,p);let m=p?.method??("method"in kn(c)?kn(c).method:"GET"),y=Date.now();try{let f=await r(c,p),R=Date.now()-y;if(mn==="meta"){if(Fe(k))Ke({method:m,url:h,status:f.status,ms:R,via:"fetch"});return f}let D;try{D=f.clone()}catch{D=void 0}let{headers:Te,status:Ve}=f;return pn((async()=>{if(!Fe(k)){if(D)wn(D);return}let Ye=D?await sa(D,Te):void 0;if(!Fe(k))return;let Me=ra(c,p);Ke({method:m,url:h,status:Ve,ms:R,reqHeaders:Le(Me),resHeaders:Le(vn(Te)),reqBody:bt(p?.body,bn(Me)),resBody:Ye,via:"fetch"})})()),f}catch(f){if(Fe(k))Ke({method:m,url:h,error:String(f),ms:Date.now()-y,via:"fetch"});throw f}};globalThis.fetch=o,n.push(()=>{if(globalThis.fetch===o)globalThis.fetch=r});let i=globalThis.XMLHttpRequest;if(!i?.prototype)return;let s=i.prototype.open,a=i.prototype.send,l=i.prototype.setRequestHeader;n.push(()=>{let c=i.prototype;if(c.open===d)c.open=s;if(c.send===b)c.send=a;if(c.setRequestHeader===g)c.setRequestHeader=l});let d=i.prototype.open=function(...c){return this.__vt={method:c[0],url:String(c[1])},s.apply(this,c)},g=i.prototype.setRequestHeader=function(c,p){let h=this.__vt;if(h)(h.reqHeaders??={})[c]=p;return l?.call(this,c,p)},b=i.prototype.send=function(c){let p=this.__vt,h=yn();if(p&&!Kt(p.url)&&h!==null){let k=Date.now();this.addEventListener("loadend",()=>{if(!Fe(h))return;if(mn==="meta"){Ke({method:p.method,url:p.url,status:this.status,ms:Date.now()-k,via:"xhr"});return}let m;try{m=oa(this.getAllResponseHeaders())}catch{m=void 0}let y;try{y=this.responseType===""||this.responseType==="text"?bt(this.responseText,bn(m)):void 0}catch{y=void 0}Ke({method:p.method,url:p.url,status:this.status,ms:Date.now()-k,reqHeaders:Le(p.reqHeaders),resHeaders:Le(m),reqBody:bt(c,bn(p.reqHeaders)),resBody:y,via:"xhr"})})}return a.call(this,c)}}var la=2000,ca=300000,je=null,Ue=null,ze=[],yt=null;function Uo(){if(!ze.length)return;let e=ze;ze=[],Bo(e,{tabId:w.tabId,tabHost:w.tabHost})}function kt(){return Ue}function Vo(e,t,n={}){if(je)return;let r=Br(),o=n.unmaskSelector;try{je=e({emit:t==="flight"?(s)=>lo(Ut(s)):(s)=>{ze.push(Ut(s))},checkoutEveryNms:t==="flight"?ro().checkoutMs:ca,inlineImages:!1,collectFonts:!0,maskAllInputs:r.maskAllInputs,...r.maskTextSelector?{maskTextSelector:r.maskTextSelector}:{},...r.maskTextSelector&&o?{maskTextFn:(s,a)=>{try{if(a?.closest(o))return s}catch{}return s.replace(/\S/g,"*")}}:{},blockSelector:`[${De}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(Ue=e,t==="flight")Qt(Sn);if(t==="session")yt=setInterval(Uo,la)}function Yo(){if(yt)clearInterval(yt);yt=null,Uo();try{je?.()}catch{}je=null,Ue=null,Qt(null),ze=[]}function Sn(){if(!je||!Ue)return;try{Ue.takeFullSnapshot?.(!0)}catch{}}var Jo="vitrinka.capture",A="windows",P="chunks";function ae(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function En(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function Xo(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function Go(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 Zo(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(Jo,1);r.onupgradeneeded=()=>{r.result.createObjectStore(A,{keyPath:"id"}),r.result.createObjectStore(P)},r.onerror=()=>n(r.error??Error("vitrinka: capture store did not open")),r.onblocked=()=>n(Error("vitrinka: capture store is blocked by another tab")),r.onsuccess=()=>t(r.result)}).then((t)=>{t.onversionchange=()=>t.close();let n=(o,i)=>{o.objectStore(A).delete(i),o.objectStore(P).delete(Xo(i))};return{async putWindow(o){let i=t.transaction(A,"readwrite");i.objectStore(A).put(o),await ae(i)},async putChunk(o,i,s,a){let l=t.transaction(P,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(P).put(d,[o,i]),await ae(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([A,P],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(P).put(d,[o.id,i]),l.objectStore(A).put(o)}catch(g){throw l.abort(),g}await ae(l)},async dropWindow(o){let i=t.transaction([A,P],"readwrite");n(i,o),await ae(i)},async clear(o){let i=t.transaction([A,P],"readwrite"),s=await En(i.objectStore(A).getAll());for(let a of s)if(Go(a)&&a.tab===o)n(i,a.id);await ae(i)},async sweep(o,i,s,a){let l=t.transaction([A,P],"readwrite"),d=(await En(l.objectStore(A).getAll())).filter(Go),g=[],b=new Map;for(let c of d)b.set(c.tab,[...b.get(c.tab)??[],c]);for(let[c,p]of b){let h=p.filter((m)=>m.kind!=="lanes").sort((m,y)=>m.startMs-y.startMs),k=(m)=>m.kind==="lanes"?m.lastMs:Zt(m,h[h.indexOf(m)+1]);for(let m of p.sort((y,f)=>y.startMs-f.startMs))if(k(m)<=o-i||c===s&&m.scope!==a)n(l,m.id);else if(c===s)g.push(m)}return await ae(l),g},async read(o){let i=t.transaction(P,"readonly"),s=await En(i.objectStore(P).getAll(Xo(o)));await ae(i);let a=[],l=[];for(let d of s)a.push(...JSON.parse(d.events)),l.push(...d.lanes);return{events:a,lanes:l}},close:()=>t.close()}})}function Qo(e=globalThis.indexedDB){try{e?.deleteDatabase(Jo)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function Rn(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}}function Tn(e,t){return`${t.y<e.y?"n":"s"}${t.x<e.x?"w":"e"}`}function Mn(e,t){let n=e.x,r=e.x+e.w,o=e.y,i=e.y+e.h,s={x:t.endsWith("w")?n:r,y:t.startsWith("n")?o:i};return{tail:{x:t.endsWith("w")?r:n,y:t.startsWith("n")?i:o},tip:s}}function ei(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 ti(e){return e.map((t,n)=>({...t,n:n+1}))}function ni(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 da=2,ua=3,pa=0,fa=5,Cn=2,ha=3,ga=2000000000,ma="data-vitrinka-hidden",ba="#1b1b1f";function ya(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:${ba};z-index:2147483647;pointer-events:none;`;return{type:Cn,id:ga+t,tagName:"div",attributes:{[ma]:"",style:n},childNodes:[]}}function In(e,t,n,r){let o={...e};if(e.type===ha&&t.has(e.id))o.textContent="";if(e.attributes&&t.has(e.id)&&"value"in e.attributes)o.attributes={...e.attributes,value:""};if(e.childNodes){if(o.childNodes=e.childNodes.map((i)=>In(i,t,n,r)),!r.done&&e.type===Cn&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function ka(e,t){(e.childNodes?.find((r)=>r.type===Cn)??e).childNodes?.push(...t)}function va(e,t){return In(e,t,[],{done:!0})}function ri(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map(ya);return e.map((o)=>{let i=o.data;if(o.type===da&&i.node){let s={done:!1},a=In(i.node,n,r,s);if(!s.done)ka(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==ua||!n.size)return o;if(i.source===pa){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:va(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===fa){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function wa(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function xa(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function An(e,t,n=document){let r=new Set;if(!e.length||!t||!n.body)return r;let o=(l)=>l.width>0&&l.height>0&&e.some((d)=>wa(xa(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 Sa=["errors","interactions","full","console","network"];var vt={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function St(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function wt(e,t,n){return Math.min(n,Math.max(t,e))}function Ea(e){if(!Array.isArray(e))return null;return Sa.filter((t)=>e.includes(t))}function oi(e,t){if(typeof e!=="object"||e===null)return St(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":vt.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?wt(Math.round(n.windowSec),10,3600):vt.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?wt(Math.round(n.maxBytes),262144,67108864):vt.maxBytes,classes:Ea(n.classes)??vt.classes}}function xt(e){let t=e.includes("full");return{replay:t||e.includes("interactions"),errors:t||e.includes("errors"),console:t||e.includes("console"),network:t||e.includes("network")}}function Ra(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 ii(e,t){if(!t)return e;let n=typeof t.windowSec==="number"&&t.windowSec>0?Math.min(e.windowSec,t.windowSec):e.windowSec,r=typeof t.maxBytes==="number"&&t.maxBytes>0?Math.min(e.maxBytes,t.maxBytes):e.maxBytes,o=e.classes;if(t.classes){let i=xt(e.classes),s=xt(t.classes);o=Ra({replay:i.replay&&s.replay,errors:i.errors&&s.errors,console:i.console&&s.console,network:i.network&&s.network})}return{storage:t.storage==="memory"?"memory":e.storage,windowSec:wt(n,10,3600),maxBytes:wt(r,262144,67108864),classes:o}}function si(e){return e==="balanced"||e==="full"?e:"strict"}function ai(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var li="[data-vitrinka-unmask]";var Ta=3670016,ci=4194240,Ma=2000,di=500,Ca=60000,Ia=/[A-Za-z0-9_-]{20,}/g;function K(e,t=""){return typeof e==="string"?e:t}function Aa(e){let t=K(e),n;try{n=new URL(t,globalThis.location?.href??"http://localhost").pathname}catch{n=t.split(/[?#]/)[0]??""}return n.replace(Ia,"•••").slice(0,300)}var Pa=4;function _a(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===Pa&&o.length)s();if(!i&&Re(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}function La(e){return(t,n)=>{if(t==="console"){let r=K(n?.level,"error");if(r==="error"?!(e.errors||e.console):!e.console)return null;return{level:r,text:K(n?.text).slice(0,Ma)}}if(t==="net"){let r=typeof n?.status==="number"?n.status:0,o=r===0||r>=400||n?.error!==void 0;if(!(e.network||e.errors&&o))return null;return{method:K(n?.method,"GET").toUpperCase(),path:Aa(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}async function Da(e){try{let t=await O("GET","/api/v1/report-config",void 0,{target:e}),n=typeof t.flightRecorder==="boolean"?t.flightRecorder:void 0;return{project:K(t.project),profile:t.captureProfile==null?St(n):oi(t.captureProfile,n),masking:si(t.profile),reachable:!0}}catch(t){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",t),{project:"",profile:St(),masking:"strict",reachable:!1}}}function ui(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 pi{opts;ready;store=null;stopped=!1;claim=null;config=null;listeners=new Set;capturing=!1;offs=[];capture=[];constructor(e){this.opts=e;this.ready=this.start()}async start(){let{opts:e}=this;this.offs.push(Pr(e.base));let t=await Da({url:e.base,key:e.key}),n=ii(t.profile,e.capture),r=xt(n.classes),o={project:t.project,profile:n,lanes:r,masking:t.masking,reachable:t.reachable,capturing:!1};if(this.stopped)return o;if(this.config=o,this.claim=Cr("report",()=>this.standDown()),!this.claim)return console.warn("vitrinka: the recorder runs this page’s capture — Report a problem sends without one"),o;this.capturing=!0,o.capturing=!0,Mr(Tr(),globalThis.location?.host??""),w.pathname=globalThis.location?.pathname??"/",Dr(ai(o.masking)),zt(e.sanitizeUrl),this.capture.push(()=>zt(null));let i=n.windowSec*1000,s=[e.base,t.project,o.masking,n.classes.join(",")].join("|"),a=[],l=[];if(n.storage==="browser")try{this.store=await Zo();let d=await this.store.sweep(Date.now(),i,w.tabId,s);a=d;let g=this.store;l=(await Promise.all(d.filter((c)=>c.kind==="lanes").map((c)=>g.read(c.id)))).flatMap((c)=>c.lanes).sort((c,p)=>Date.parse(c.ts)-Date.parse(p.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else Qo();if(!this.capturing)return this.store?.close(),this.store=null,o;if(to({windowMs:i,checkoutMs:Math.min(Ca,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:Jt,keepLane:La(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(no),this.store&&typeof window<"u"){let d=()=>tt();this.capture.push(N(window,"pagehide",d),N(document,"visibilitychange",d))}if(r.errors||r.console)$o({levels:r.console?["warn","info","log"]:[]}),this.capture.push(qo);if(r.errors||r.network)jo({detail:"meta"}),this.capture.push(zo);if(r.replay){let d=await e.loadRecord(e.base).catch((g)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",g),null));if(d&&this.capturing)Vo(d,"flight",{unmaskSelector:li}),this.capture.push(Yo)}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)io().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};w.pathname=globalThis.location?.pathname??w.pathname;let e=nn();if(e&&kt()&&!uo(e))Sn(),e=nn();let t=this.store,n=e?.windows.filter((o)=>o.stored).map((o)=>o.id)??[],r=t&&n.length?Promise.all(n.map(async(o)=>[o,await t.read(o)])).then((o)=>new Map(o)):Promise.resolve(new Map);return r.catch(()=>{return}),{clip:e,stored:r}}hiddenIdsAt(e){if(!this.capturing)return null;let t=ui(kt());return t?An([e],t):null}async build(e,t,n=new Set){let r=t.filter((f)=>f.shape==="hide").map((f)=>f.rect),o=ui(kt()),i=r.length>0&&!o;if(i)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let s=new Set(n);if(r.length&&o)for(let f of An(r,o))s.add(f);let a=[],l=e.clip?.truncated??!1,d=await e.stored.catch((f)=>(console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",f),null));for(let f of e.clip?.windows??[]){if(!f.stored){a.push(...f.events);continue}let R=d?.get(f.id);if(!R?.events.length)l=!0;else a.push(...R.events)}let g=e.clip?.lanes??[],b=i?{events:[],dropped:!1}:_a(ri(a,r,s),ci);if(b.dropped)l=!0;let{parts:c,dropped:p}=hn(b.events,Ta,ci),h=[],k=0;for(let f of c){k+=f.count;let R=b.events[k-1]?.timestamp??Date.now();h.push({seq:h.length+1,ts:new Date(R).toISOString(),count:f.count,body:f.body})}let m=g.filter((f)=>f.kind==="console").slice(-di).map((f)=>({level:K(f.payload?.level,"error"),ts:f.ts,text:K(f.payload?.text)})),y=g.filter((f)=>f.kind==="net").slice(-di).map((f)=>({method:K(f.payload?.method,"GET"),path:K(f.payload?.path),status:typeof f.payload?.status==="number"?f.payload.status:0,ms:typeof f.payload?.ms==="number"?f.payload.ms:0}));return{chunks:h,truncated:l||p.length>0,console:m,network:y}}clear(){if(this.capturing)oo()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),Ir(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var L=null;function fi(e){if(L){let t=L.engine.opts;if(!(t.base===e.base&&t.key===e.key&&t.sanitizeUrl===e.sanitizeUrl&&JSON.stringify(t.capture??{})===JSON.stringify(e.capture??{})))return console.warn("vitrinka: one capture engine per page — this widget reports without a capture (another widget’s key, base, capture or sanitizeUrl owns it)"),null;return L.refs++,L.engine}return L={engine:new pi(e),refs:1},L.engine}function hi(e){if(!e||!L||L.engine!==e)return;if(--L.refs>0)return;L=null,e.stop()}var Na=/^[\w-]+\.[\w-]+\.[\w-]+$/;function Et(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!Na.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 gi=null,Pn=new Set;function Oa(e){gi=Et(e);for(let t of Pn)t()}function mi(){return gi}function bi(e){return Pn.add(e),()=>Pn.delete(e)}var Ba=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),Rt="report.keybind";function yi(e){if(Ba.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 ki(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var Ha={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function qa(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 Ha[e]??e}function $a(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function Tt(e,t=$a()){let n=qa(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 vi(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;let n=t;if(typeof n.code!=="string"||!n.code)return null;let r={code:n.code,alt:n.alt===!0,ctrl:n.ctrl===!0,meta:n.meta===!0,shift:n.shift===!0};return r.alt||r.ctrl||r.meta?r:null}catch{return null}}function wi(){return vi(z().getString(Rt))}function _n(e){let t=z();if(e)t.set(Rt,JSON.stringify(e));else t.remove(Rt)}function xi(e){let t=z();return t.watch?t.watch(Rt,(n)=>e(vi(n))):()=>{return}}var Si=`
8
+ ${m}\r
9
+ `)}return s.push(i[i.length-1]),s.join(o)}var Oi=262144;function Mi(e,t,n){if(e.full||!t)return t;try{if(fn(t)){if(t.length<=Oi)try{return JSON.stringify(ft(e,JSON.parse(t),0))}catch{}return be(e,Ol(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return pt(e,_i(e,G,t));if(r.includes("multipart/form-data")){let o=Nl(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return pt(e,t)}catch{return"[redacted]"}}function Ni(e,t){if(t===void 0)return;if(e.full)return t;if(fn(t))try{return JSON.stringify(ft(e,JSON.parse(t),0))}catch{}try{return pt(e,t)}catch{return"[redacted]"}}function Fi(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(fn(t)&&t.length<=Oi){let i=Mi(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 Mi(e,o,r)}function Hi(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):Li(e,s)?"[redacted]":be(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function zi(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var ye=un(null);function Ki(e){ye=un(e??null)}function qi(e){return Ni(ye,e)}function hn(e,t,n){return Fi(ye,e,t,n)}var $i=null,Wi=null;function gn(e){Wi=e??null}function Fl(e){let t=Wi??lt().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($i!==t)$i=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return Hl(e)??Ai}function Hl(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function se(e){return pn(ye,Fl(e))}var zl=4;function mn(e){return e.type===zl}function bn(e){if(!mn(e))return e;return{...e,data:{...e.data,href:se(e.data.href)}}}function qe(e){return Hi(ye,e)}function ji(){return zi(ye)}var $l="recents",Kl=5,ql=["recording","saved","unsaved","deleted"];function Wl(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.sessionId==="string"&&typeof t.title==="string"&&typeof t.startedAt==="number"&&ql.includes(t.status)}var ht;function Ui(){if(ht===void 0)try{let e=JSON.parse(M().getString($l)??"[]");ht=Array.isArray(e)?e.filter(Wl).slice(0,Kl):[]}catch{ht=[]}return ht}var We="data-vitrinka-recorder";var yn="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;",Vi=yn;function I(e,t,n,r={}){let o=e,i=o.__zone_symbol__addEventListener??e.addEventListener,s=o.__zone_symbol__removeEventListener??e.removeEventListener,a=r.capture??!1;return i.call(e,t,n,{capture:a,passive:!1}),()=>s.call(e,t,n,a)}var jl=["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 Ji(e){for(let t of jl)e.addEventListener(t,(n)=>n.stopPropagation())}var Ul=["keydown","keyup","keypress"],Vl=["vitrinkaHud","vitrinkaSheet"],Yi=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Yl=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),Xl=new Set(["text","search","email","url","tel","password","number"]);function Gl(e){let t=e.key.length===1;if(t&&e.getModifierState?.("AltGraph"))return!0;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return t||Yi.has(e.key);if(Yi.has(e.key))return!0;return(e.ctrlKey||e.metaKey)&&!e.altKey&&Yl.has(e.code)}function Jl(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"&&Xl.has(e.type)}function Zl(e){if(typeof e!=="object"||e===null||!("dataset"in e))return!1;let t=e.dataset;return typeof t==="object"&&t!==null&&Vl.some((n)=>(n in t))}function Ql(e){if(!Gl(e))return!1;let t=e.composedPath();return Jl(t[0])&&t.some(Zl)}var Xi=0,gt=null;function Zi(){if(Xi++,!gt&&typeof window<"u"){let t=(r)=>{if(Ql(r))r.stopImmediatePropagation()},n=Ul.map((r)=>I(window,r,t,{capture:!0}));gt=()=>{for(let r of n)r()}}let e=!0;return()=>{if(!e)return;if(e=!1,--Xi>0)return;gt?.(),gt=null}}function Qi(){let e=document.createElement("div");e.setAttribute(We,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=yn;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),Ji(e);let r=Zi();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=(p)=>{if(p.type==="attributes")return p.target instanceof Element&&Gi(p.target);for(let m of[p.addedNodes,p.removedNodes])for(let y of m){if(!(y instanceof Element))continue;if(Gi(y))return!0;if(y.childElementCount>0&&y.querySelector(es))return!0}return!1},d=[],f=0,g=()=>{f=0;let p=d;if(d=[],p.some(l))a()},u=new MutationObserver((p)=>{for(let m of p)d.push(m);if(f===0)f=typeof requestAnimationFrame==="function"?requestAnimationFrame(g):setTimeout(g,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(),f!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(f);d=[];try{e.hidePopover?.()}catch{}e.remove()}}}var es='dialog,[role="dialog"]';function Gi(e){return e.matches(es)}function ts(){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 ns(e){let t=document.createElement("div");t.setAttribute(We,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=Vi;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");n.append(r),Ji(t);let o=Zi();return e.append(t),{mount:r,destroy:()=>{o(),t.remove()}}}function rs(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 os="0.8.0";var J={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function ec(e,t){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:t}function is(e){if(typeof e!=="object"||e===null)return J;let t={...e},n=Array.isArray(t.types)?t.types.filter((r)=>typeof r==="string"&&r.trim()!=="").map((r)=>r.trim().toLowerCase()):[];return{maxBytes:ec(t.maxBytes,J.maxBytes),maxCount:typeof t.maxCount==="number"&&Number.isInteger(t.maxCount)&&t.maxCount>=0?t.maxCount:J.maxCount,types:n.length?n:J.types}}function tc(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 nc(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}function ss(e,t,n){let r=[],o=null;for(let i of t){if([...e,...r].some((s)=>nc(s,i)))continue;if(!tc(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 je(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 as(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 ls(e,t){let n=/^image\.(\w+)$/i.exec(e);return n?`pasted-${t}.${n[1]}`:e}var kn=["sm","md","lg"],mt={sm:0.88,md:1,lg:1.18},vn="vitrinka.report.size";function cs(){try{return globalThis.localStorage??null}catch{return null}}function wn(e){return cs()?.getItem(e)??null}function bt(e,t){try{cs()?.setItem(e,t)}catch(n){console.warn(`vitrinka: could not remember ${e} on this browser`,n)}}function ds(){let e=wn(vn);return kn.find((t)=>t===e)??"md"}function us(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} · ${je(n.profile.maxBytes,e.locale)}`:"—"],[t.techServer,o]]}var ps="vitrinka.report.dock",fs=6,xn={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},rc=["br","bl","tr","tl"];function oc(e){return e==="tl"||e==="tr"?"t":"b"}function ic(e){return e==="tl"||e==="bl"?"l":"r"}function hs(){let e=wn(ps);return rc.find((t)=>t===e)??"br"}function gs(e){bt(ps,e)}function ms(e,t,n){return xn[e.y<n/2?"t":"b"][e.x<t/2?"l":"r"]}function bs(e,t){if(t==="ArrowLeft"||t==="ArrowRight")return xn[oc(e)][t==="ArrowLeft"?"l":"r"];if(t==="ArrowUp"||t==="ArrowDown")return xn[t==="ArrowUp"?"t":"b"][ic(e)];return null}var ys=30000,sc=4194304,ac=20000,En=500,lc=2000,cc=2,ks={windowMs:ys,checkoutMs:ys,maxBytes:sc,maxEvents:ac,maxLaneEvents:En},Q=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function Tn(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var dc=new TextEncoder,te=!1,vs=0,A=ks,v=[],D=[],W=[],Z=[],uc=0,ve=[],we=new Map,xe=null,ke=null,Ue=!1,pc=0,ee=null,yt=null,Rn=Promise.resolve();function ws(e=ks){if(Mn(),te=!0,vs++,A=e,ee=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=[],Z=[],ve=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),we.clear(),xe=null,vt(Date.now()),ee)yt=setInterval(kt,lc)}function xs(){kt(),Mn(),te=!1,ee=null,v=[],D=[],W=[],Z=[],ve=[],we.clear(),xe=null}function Ss(){return A}function Cn(e){ke=e}function Rs(){if(!te)return;v=[],D=[],W=[],Z=[],ve=[],we.clear(),xe=null;let e=w.tabId;ae((t)=>t.clear(e)),ke?.()}function Es(){return Rn}function kt(){if(!te||!ee)return;let e=Date.now();vt(e),An(e);for(let t of v){if(t.stored)continue;let n=we.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;we.set(t.id,{events:t.events.length,parts:o+1});let i=Ts(t);ae((s)=>s.putWindowChunk(i,o,r,[]))}fc(e)}function fc(e){let t=e-A.windowMs;while(Z.length>0&&Z[0].lastMs<=t){let[a]=Z.splice(0,1);if(a)ae((l)=>l.dropWindow(a.id))}for(let a of ve.filter((l)=>l.lastMs<=t))ae((l)=>l.dropWindow(a.id));ve=ve.filter((a)=>a.lastMs>t);let n=W;if(!n.length)return;W=[];let r=Z.at(-1);if(!r||r.startMs<=t)r={id:`${Q}.lanes.${++uc}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},Z.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:w.tabId,scope:A.scope??"",kind:"lanes",load:Q,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};ae((a)=>a.putWindowChunk(s,o,"[]",n))}function Mn(){if(yt)clearInterval(yt);yt=null}function Ts(e){return{id:e.id,tab:w.tabId,scope:A.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function ae(e){let t=ee;if(!t)return;Rn=Rn.then(()=>e(t)).catch((n)=>{if(ee!==t)return;ee=null,Mn(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function Sn(e){let[t]=v.splice(e,1);if(!t)return;we.delete(t.id),ae((n)=>n.dropWindow(t.id))}function vt(e){while(v.length>0){let r=v[0],o=v[1];if(!o&&r.load===Q)break;if(Tn(r,o)>e-A.windowMs)break;Sn(0)}if(Ue)return;let t=v.at(-1);if(t&&t.load===Q&&ke&&t.lastMs<=e-A.windowMs){Ue=!0;try{ke()}finally{Ue=!1}let r=v.indexOf(t);if(r>=0&&r<v.length-1)for(let o=r;o>=0;o--)Sn(o)}let n=!1;while(v.length>0&&hc()){if(v.length===1&&v[0].load===Q&&!n&&ke){n=!0,Ue=!0;try{ke()}finally{Ue=!1}if(v.length>1)continue}Sn(0),xe=v[0]?.startMs??e}}function Cs(){return te?`flight:${vs}`:null}function An(e){let t=Math.min(v[0]?.startMs??Number.POSITIVE_INFINITY,e-A.windowMs),n=D.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)D=[];else if(n>0)D=D.slice(n)}function hc(){let e=0,t=0;for(let n of v)e+=n.bytes,t+=n.count;return e>A.maxBytes||t>A.maxEvents}function Ms(e){if(!te)return;let t=v[0];if(mn(e)){let r=globalThis.location?.pathname??w.pathname,o={id:`${Q}.${++pc}`,load:Q,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:se(r)};v.push(o);let i=Ts(o);ae((s)=>s.putWindow(i))}let n=v.at(-1);if(!n||n.load!==Q)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=dc.encode(JSON.stringify(e)).length,vt(e.timestamp),v[0]!==t)An(e.timestamp)}function As(e,t,n){if(!te)return null;let r=A.keepLane?A.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=A.maxLaneEvents;if(D.push(i),D.length>s)D.splice(0,D.length-s);if(ee){if(W.push(i),W.length>s)W.splice(0,W.length-s)}return o}function Pn(){if(!te)return null;let e=Date.now();return vt(e),An(e),{windows:v.map((t)=>({...t,events:t.events.slice()})),lanes:D.slice(),truncated:xe!==null&&xe>e-A.windowMs}}function Ps(e){return e.windows.some((t)=>t.events[1]?.type===cc)}var Ln=null;function wt(){if(!Ln)Ln=typeof indexedDB>"u"?gc():mc();return Ln}function gc(){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 mc(){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 bc=2000,_n=20000,zs=200,yc=4194304,kc=3145728,Pt=500,vc=yc-1024,wc=12582912,xc=10485760,Sc=wc-64,Rc=1048576,Ec=new TextEncoder;function Ie(e){return Ec.encode(e).length}var T=()=>M();function U(e,t){let n=T().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var Ls=!1;function V(e,t){try{return T().set(e,t),!0}catch(n){if(!Ls)Ls=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var Rt="rec",de;function C(){if(de===void 0)de=U(Rt,null);return de}function $s(e){if(de=e,e===null)T().remove(Rt),T().remove(Tc);else V(Rt,JSON.stringify(Cc(e)))}var Tc="notes";var Ye=null;function Cc(e){if(Ye?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:Ye.activeMs,resumeAt:null,stopping:Ye.at}}var Mc=new Set;function Ac(){for(let e of Mc)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function Pc(e){let t=null;if(e)try{t=JSON.parse(e)}catch{return"unchanged"}let n=C();if(t?.stopping&&t.sessionId===n?.sessionId&&!n.paused&&Ye?.sessionId!==t.sessionId)Ac();if(!t){if(!n)return"unchanged";return de=null,Hs(),Kc(),"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(Ye?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return de=t,"updated"}return de=t,Hs(),"joined"}var Lc=700,ue,j=null,oe=!1;function Re(){if(ue===void 0)ue=U("buffer",[]);return ue}function Lt(){if(j)clearTimeout(j),j=null;if(ue!==void 0&&!oe)V("buffer",JSON.stringify(ue))}function Ks(){if(oe=!1,j)return;j=setTimeout(()=>{j=null,Lt(),qs()},Lc)}function Is(e){ue=e,oe=!1,Lt()}var Se,Te=0;function le(){if(Se===void 0)Se=U("chunks",[]),Te=Se.reduce((e,t)=>e+t.body.length,0);return Se}function qs(){if(oe)return;let e=le();if(e.length===0){T().remove("chunks");return}if(Te>Rc){T().remove("chunks");return}V("chunks",JSON.stringify(e))}function Ic(e){Se=e,Te=e.reduce((t,n)=>t+n.body.length,0),oe=!1,qs()}var Et,Ce=new Map,Ee=new Set,Me=new Map,xt=new Map,Ds=5,Dc=200,Bc=67108864,_c=0,Bs=!1,Oc="blobs";function B(){return Et??=U("images",[]),Et}function Ws(){if(oe)return;let e=B().filter((t)=>!Ee.has(t.blob));if(e.length===0)T().remove("images");else V("images",JSON.stringify(e))}function js(e){Et=e,oe=!1,Ws()}function Nc(e,t){let n=wt();if(!n.durable&&!Bs)Bs=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");V(Oc,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${Xs}.${++_c}`;return Ce.set(a,i),Ee.add(a),r.push(n.put(a,i).then(()=>{if(!(Ce.has(a)||B().some((d)=>d.blob===a)||[...Me.values()].includes(a)))return Ee.delete(a),On(a),!1;if(!n.durable)return!1;if(Ee.delete(a),B().some((d)=>d.blob===a))Ws();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 On(e){wt().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function Ae(e,t){for(let n of e)if(Ce.delete(n),Ee.delete(n),xt.delete(n),t)On(n)}var Tt=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];var Fc=0,Us="",Vs=0,_s=-1;function Nn(){Fc=Date.now(),Vs=0,Us=""}function Pe(e){Vs++,Us=String(e instanceof Error?e.message:e).slice(0,200)}var Os={actions:0,pages:0,frames:0,notes:0},Hc=new Set;function zc(e){let t={...Os};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")Hc.add(n.payload.cid)}Os=t}function $c(e){let t=C();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;$s(t),console.warn("vitrinka: session marked dead —",e),X()}var In=null;function Kc(){if(In)clearInterval(In);In=null}function Ys(e){let t=C();if(!t||t.dead||e<1)return null;let n=U("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return T().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,$s(t),{seq:r,sessionId:t.sessionId}}var Xs=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,Ct="allocation.",qc=0,_=new Set,Wc=16777216,Mt=0,At=0,Le=new Map;function It(e){return e.kind==="event"?1+(e.images?.length??0):1}function jc(e,t){return new Set(Array.from({length:It(t)},(n,r)=>e+r))}function Fn(e,t,n){return JSON.stringify(n&&n.size<It(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var Ns=!1,Ve=null;function St(e){if(!_.delete(e))return;if(Mt-=e.bytes,e.draft.kind==="chunk")At--}function Gs(e){if(_.add(e),Mt+=e.bytes,e.draft.kind==="chunk")At++;while(_.size>_n||Mt>Wc||At>zs){let t=_.values().next().value;St(t),T().remove(t.key),Ae(Tt(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");Pe(n),console.warn(n.message)}}function Js(e=!1){if(Ns&&!e)return;Ns=!0;let t=T();if(!t.withLock)return;let n=new Set([..._].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(Ct)||n.has(r)||Le.has(r))continue;let o=U(r,null);if(o&&o.draft&&o.draft.sessionId===C()?.sessionId)Gs({...o,key:r,persisted:!0,bytes:Ie(JSON.stringify(o))})}}function Zs(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,f=l.length?{...e.event,payload:{...e.event.payload,attachments:l.map((u,p)=>t+p)}}:e.event,g=Re();if(a(d)&&!g.some((u)=>u.seq===d))g.push({seq:d,ts:r,tabId:o,tabHost:i,...f});if(l.length){let u=B();l.forEach((m,y)=>{let b=t+y;if(!a(b)||u.some((k)=>k.seq===b))return;if(g.some((k)=>k.seq===b)){Me.set(b,m.blob);return}u.push({seq:b,ts:r,tabId:o,tabHost:i,sessionId:s,blob:m.blob,payload:m.payload})});let p=u.reduce((m,y)=>m+y.payload.bytes,0);while(u.length>Dc||p>Bc){let m=u.shift();p-=m.payload.bytes,re(m.sessionId,new Set([m.seq])),Ae([m.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${m.payload.name} (seq ${m.seq}); its note lands without it`)}js(u)}if(g.length>_n){let u=g.splice(0,g.length-_n);re(s,new Set(u.map((p)=>p.seq))),console.warn(`vitrinka: retry buffer full — dropped ${u.length} oldest events`)}}else{let l=le();if(!l.some((d)=>d.seq===t)&&!Re().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),Te+=e.part.body.length;while(l.length>zs){let d=l.shift();Te-=d.body.length,re(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}Ks(),ce()}function re(e,t){for(let[n,r]of Le){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?U(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)V(n,Fn(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){T().remove(n),Le.delete(n);let s=n.slice(Ct.length,n.lastIndexOf(".")),a=`tab.${s}`,l=U(a,null);if(l?.departed&&l.recoverable&&!T().keys?.().some((d)=>d.startsWith(`${Ct}${s}.`)))T().remove(a)}}}function Qs(){if(Ve)return Ve;let e=T();return Ve=Hn(Promise.resolve().then(async()=>{for(let t of _)await e.withLock("seq",()=>{if(!_.has(t))return;if(t.persisted){let o=U(t.key,null);if(!o){St(t),Ae(Tt(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(Pc(e.getString(Rt)??null),C()?.sessionId!==t.draft.sessionId){St(t),Ae(Tt(t.draft),!0);return}let n=t.seq??Ys(It(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):jc(n,t.draft);if(t.persisted)e.set(t.key,Fn(t.draft,n,r));Le.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),Zs(t.draft,n,r),St(t)})}).catch((t)=>{throw Pe(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),ce(),X(),t})).finally(()=>{Ve=null}),Ve}function ea(e,t){let n=C(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(Js(),T().withLock){let o=`${Ct}${Xs}.${++qc}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&V(o,i),bytes:Ie(i)};Gs(s),Qs(),t?.then((a)=>{if(a)Uc(s)})}else{let o=Ys(It(e));if(o)Zs(e,o.seq);else Ae(Tt(e),!0)}return!0}function Uc(e){let t=Le.get(e.key);if(t)t.persisted=V(e.key,Fn(e.draft,e.seq,t.seqs));else if(_.has(e))e.persisted=V(e.key,JSON.stringify({draft:e.draft}))}var Fs=new Set;function Hn(e){return Fs.add(e),e.catch(()=>{return}).finally(()=>{Fs.delete(e)})}function ne(e){return C()?.sessionId!==e.sessionId}function Xe(e,t,n,r=[]){if(Ne.following)return null;let o=C();if(!o)return As(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?Nc(o.sessionId,r):null;return ea({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),zn(),i}function ta(e){Re().push(e),zn(),Ks(),ce()}var Vc=Date.now();function zn(){Vc=Date.now()}function $n(e,t=xc,n=Sc){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),f=Ie(d)+1;if(f>n){o.push(f);continue}if(f>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+f>t)a();i.push(d),s+=f}return a(),{parts:r,dropped:o}}function na(e,t){if(!e.length)return 0;let n=C();if(!n||n.paused||n.dead||Ne.following)return 0;let{parts:r,dropped:o}=$n(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),Xe("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(!ea({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return zn(),r.length}async function Yc(e=5){let t=le();if(t.length===0)return!0;let n=C(),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 Ri(n.sessionId,i.seq,i.body);if(ne(n))return le().length===0;ta({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),Nn(),o.add(i.seq)}catch(s){if(ne(n))return le().length===0;if(s instanceof S&&q(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),re(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}Pe(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Ic(le().filter((i)=>!o.has(i.seq)));return le().length===0}async function Xc(e=4){let t=B();if(t.length===0)return!0;let n=C(),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=Ce.get(s.blob)??null;if(!a){try{a=await wt().get(s.blob),xt.delete(s.blob)}catch(l){if(ne(n))return B().length===0;let d=(xt.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${Ds})`,l),d<Ds){xt.set(s.blob,d),Pe(l);break}}if(ne(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`),re(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await Ei(n.sessionId,s.seq,a);if(ne(n))return B().length===0;ta({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),Ce.delete(s.blob),Me.set(s.seq,s.blob),Nn(),o.add(s.seq)}catch(l){if(ne(n))return B().length===0;if(l instanceof S&&q(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),re(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}Pe(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)Lt(),js(B().filter((s)=>!o.has(s.seq)));return Ae(i,!0),B().length===0}var Dn=null;function ce(){if(Dn)return;Dn=setTimeout(()=>{Dn=null,Gc()},bc)}var Bn=!1;async function Gc(e={}){if(Bn)return!1;Bn=!0;try{return await Jc(e)}finally{Bn=!1}}async function Jc(e){if(C()?.dead)return!1;if(Js(!0),_.size)await Qs();if(_.size)return!1;let t=await Yc(),n=e.keepalive?B().length===0:await Xc(),r=t&&n;if(!r)ce();let o=C(),i=Re();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:kc;for(let u of i){if(s.length>=Pt)break;let p=Ie(JSON.stringify(u))+1;if(p>vc){console.warn(`vitrinka: event seq ${u.seq} (${p} bytes) exceeds the wire cap — dropped`),a.add(u.seq);continue}if(p>d){if(e.keepalive)break;if(s.length===0)s.push(u),l=p;break}if(s.length>0&&l+p>d)break;s.push(u),l+=p}if(a.size){if(re(o.sessionId,a),Is(Re().filter((u)=>!a.has(u.seq))),!s.length)return ce(),!1}if(!s.length)return!1;Lt();try{await L("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(u){if(ne(o))return!1;if(u instanceof S&&q(u.status))return $c(`server rejected this session (${u.status})`),!1;return Pe(u),X(),console.warn("vitrinka: flush failed, retrying",u),ce(),!1}if(ne(o))return!0;Nn(),_s=Math.max(_s,...s.map((u)=>u.seq)),zc(s);let f=new Set(s.map((u)=>u.seq));re(o.sessionId,f);let g=Re().filter((u)=>!f.has(u.seq));Is(g),X();for(let u of f){let p=Me.get(u);if(p===void 0)continue;Me.delete(u),On(p)}if(g.length)ce();return!0}function Hs(){if(j)clearTimeout(j),j=null;ue=[],Se=[],Te=0,Et=[],Ce.clear(),Ee.clear(),Me.clear(),_.clear(),Mt=At=0,Le.clear(),oe=!0}var Zc=8192,Ge="__vitrinkaRecorderConsolePatched";function Dt(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,Zc)}function Bt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;Xe("console",{level:t,text:qi(e)},{tabId:w.tabId,tabHost:w.tabHost})}var Kn="__vitrinkaRecorderConsoleUnpatch",ra={};function oa(){let e=globalThis;if(e[Ge]!==void 0&&e[Ge]!==ra)return;e[Kn]?.()}function ia(e={}){let t=globalThis;if(t[Ge])return;t[Ge]=ra;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{Bt(Dt(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let f=console[d],g=f.bind(console),u=(...p)=>{g(...p);try{Bt(Dt(p),d)}catch{}};return console[d]=u,()=>{if(console[d]===u)console[d]=f}}),s=(d)=>{try{Bt(Dt([d.error??d.message]))}catch{}},a=(d)=>{try{Bt(`unhandled rejection: ${Dt([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[Kn]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[Ge],delete t[Kn]}}var sa=65536,Je=524288,aa=3000;var qn="full";function jn(){if(Ne.following)return null;let e=C();if(e)return!e.paused&&!e.dead?e.sessionId:null;return Cs()}function Ze(e){return e!==null&&jn()===e}function _t(e,t){if(typeof e==="string")return hn(e,sa,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return hn(e.toString(),sa,"application/x-www-form-urlencoded");return Qc(e)}function Qc(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 Wn(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function Un(e){return typeof e==="string"||e instanceof URL?{}:e}function Qe(e){let t=typeof e.url==="string"?se(e.url):e.url;Xe("net",{...e,url:t},{tabId:w.tabId,tabHost:w.tabHost})}function Vn(e){if(!e)return;try{let t={},n=e;if(typeof n.forEach==="function")if(Array.isArray(e)){for(let r of e)if(Array.isArray(r)&&r.length>=2)t[String(r[0])]=String(r[1])}else n.forEach((r,o)=>{t[o]=String(r)});else if(typeof e==="object")for(let[r,o]of Object.entries(e))t[r]=String(o);return Object.keys(t).length>0?t:void 0}catch{return}}function ed(e,t){let n=Vn(t?.headers);if(n)return n;let r=Un(e);return Vn(r.headers)}function td(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 Yn(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function nd(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function rd(e,t){let n=await od(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return _t(n,r)}async function od(e,t){let n=nd(t);if(n!==null&&n>Je)return Yn(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()+aa;try{while(s<Je){let p=d-Date.now();if(p<=0){l=!0;break}let m,y=await Promise.race([o.read(),new Promise((h)=>{m=setTimeout(()=>h("timeout"),p)})]).finally(()=>{if(m!==void 0)clearTimeout(m)});if(y==="timeout"){l=!0;break}let{done:b,value:k}=y;if(b)break;if(k){let h=Je-s,E=k.byteLength>h?k.subarray(0,h):k;i.push(E),s+=E.byteLength}}a=s>=Je,o.cancel().catch(()=>{return})}catch{return}let f=new Uint8Array(s),g=0;for(let p of i)f.set(p,g),g+=p.byteLength;let u;try{u=new TextDecoder().decode(f)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${u}…[body read timed out after ${aa}ms]`;return a?`${u}…[truncated at ${Je} bytes]`:u}if(n===null)return Yn(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var et="__vitrinkaRecorderNetPatched",Xn="__vitrinkaRecorderNetUnpatch",la={};function ca(){let e=globalThis;if(e[et]!==void 0&&e[et]!==la)return;e[Xn]?.()}function da(e={}){let t=globalThis;if(t[et])return;t[et]=la,qn=e.detail??"full";let n=[];t[Xn]=()=>{for(let u of n.splice(0))u();delete t[et],delete t[Xn]};let r=globalThis.fetch,o=async(u,p)=>{let m=typeof u==="string"?u:u instanceof URL?u.href:u.url,y=jn();if(an(m)||y===null)return r(u,p);let b=p?.method??("method"in Un(u)?Un(u).method:"GET"),k=Date.now();try{let h=await r(u,p),E=Date.now()-k;if(qn==="meta"){if(Ze(y))Qe({method:b,url:m,status:h.status,ms:E,via:"fetch"});return h}let K;try{K=h.clone()}catch{K=void 0}let{headers:De,status:ot}=h;return Hn((async()=>{if(!Ze(y)){if(K)Yn(K);return}let it=K?await rd(K,De):void 0;if(!Ze(y))return;let Be=ed(u,p);Qe({method:b,url:m,status:ot,ms:E,reqHeaders:qe(Be),resHeaders:qe(Vn(De)),reqBody:_t(p?.body,Wn(Be)),resBody:it,via:"fetch"})})()),h}catch(h){if(Ze(y))Qe({method:b,url:m,error:String(h),ms:Date.now()-k,via:"fetch"});throw h}};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===g)u.send=a;if(u.setRequestHeader===f)u.setRequestHeader=l});let d=i.prototype.open=function(...u){return this.__vt={method:u[0],url:String(u[1])},s.apply(this,u)},f=i.prototype.setRequestHeader=function(u,p){let m=this.__vt;if(m)(m.reqHeaders??={})[u]=p;return l?.call(this,u,p)},g=i.prototype.send=function(u){let p=this.__vt,m=jn();if(p&&!an(p.url)&&m!==null){let y=Date.now();this.addEventListener("loadend",()=>{if(!Ze(m))return;if(qn==="meta"){Qe({method:p.method,url:p.url,status:this.status,ms:Date.now()-y,via:"xhr"});return}let b;try{b=td(this.getAllResponseHeaders())}catch{b=void 0}let k;try{k=this.responseType===""||this.responseType==="text"?_t(this.responseText,Wn(b)):void 0}catch{k=void 0}Qe({method:p.method,url:p.url,status:this.status,ms:Date.now()-y,reqHeaders:qe(p.reqHeaders),resHeaders:qe(b),reqBody:_t(u,Wn(p.reqHeaders)),resBody:k,via:"xhr"})})}return a.call(this,u)}}var id=2000,sd=300000,nt=null,rt=null,tt=[],Ot=null;function ua(){if(!tt.length)return;let e=tt;tt=[],na(e,{tabId:w.tabId,tabHost:w.tabHost})}function Nt(){return rt}function pa(e,t,n={}){if(nt)return;let r=ji(),o=n.unmaskSelector;try{nt=e({emit:t==="flight"?(s)=>Ms(bn(s)):(s)=>{tt.push(bn(s))},checkoutEveryNms:t==="flight"?Ss().checkoutMs:sd,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:`[${We}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(rt=e,t==="flight")Cn(Gn);if(t==="session")Ot=setInterval(ua,id)}function fa(){if(Ot)clearInterval(Ot);Ot=null,ua();try{nt?.()}catch{}nt=null,rt=null,Cn(null),tt=[]}function Gn(){if(!nt||!rt)return;try{rt.takeFullSnapshot?.(!0)}catch{}}var ma="vitrinka.capture",O="windows",N="chunks";function pe(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function Jn(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function ha(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function ga(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 ba(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(ma,1);r.onupgradeneeded=()=>{r.result.createObjectStore(O,{keyPath:"id"}),r.result.createObjectStore(N)},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(O).delete(i),o.objectStore(N).delete(ha(i))};return{async putWindow(o){let i=t.transaction(O,"readwrite");i.objectStore(O).put(o),await pe(i)},async putChunk(o,i,s,a){let l=t.transaction(N,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(N).put(d,[o,i]),await pe(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([O,N],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(N).put(d,[o.id,i]),l.objectStore(O).put(o)}catch(f){throw l.abort(),f}await pe(l)},async dropWindow(o){let i=t.transaction([O,N],"readwrite");n(i,o),await pe(i)},async clear(o){let i=t.transaction([O,N],"readwrite"),s=await Jn(i.objectStore(O).getAll());for(let a of s)if(ga(a)&&a.tab===o)n(i,a.id);await pe(i)},async sweep(o,i,s,a){let l=t.transaction([O,N],"readwrite"),d=(await Jn(l.objectStore(O).getAll())).filter(ga),f=[],g=new Map;for(let u of d)g.set(u.tab,[...g.get(u.tab)??[],u]);for(let[u,p]of g){let m=p.filter((b)=>b.kind!=="lanes").sort((b,k)=>b.startMs-k.startMs),y=(b)=>b.kind==="lanes"?b.lastMs:Tn(b,m[m.indexOf(b)+1]);for(let b of p.sort((k,h)=>k.startMs-h.startMs))if(y(b)<=o-i||u===s&&b.scope!==a)n(l,b.id);else if(u===s)f.push(b)}return await pe(l),f},async read(o){let i=t.transaction(N,"readonly"),s=await Jn(i.objectStore(N).getAll(ha(o)));await pe(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 ya(e=globalThis.indexedDB){try{e?.deleteDatabase(ma)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function Zn(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 Qn(e,t){return`${t.y<e.y?"n":"s"}${t.x<e.x?"w":"e"}`}function er(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 ka(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 va(e){return e.map((t,n)=>({...t,n:n+1}))}function wa(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 ad=2,ld=3,cd=0,dd=5,tr=2,ud=3,pd=2000000000,fd="data-vitrinka-hidden",hd="#1b1b1f";function gd(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:${hd};z-index:2147483647;pointer-events:none;`;return{type:tr,id:pd+t,tagName:"div",attributes:{[fd]:"",style:n},childNodes:[]}}function nr(e,t,n,r){let o={...e};if(e.type===ud&&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)=>nr(i,t,n,r)),!r.done&&e.type===tr&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function md(e,t){(e.childNodes?.find((r)=>r.type===tr)??e).childNodes?.push(...t)}function bd(e,t){return nr(e,t,[],{done:!0})}function xa(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map(gd);return e.map((o)=>{let i=o.data;if(o.type===ad&&i.node){let s={done:!1},a=nr(i.node,n,r,s);if(!s.done)md(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==ld||!n.size)return o;if(i.source===cd){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:bd(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===dd){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function yd(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function kd(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function rr(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)=>yd(kd(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 vd=["errors","interactions","full","console","network"];var Ft={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function $t(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function Ht(e,t,n){return Math.min(n,Math.max(t,e))}function wd(e){if(!Array.isArray(e))return null;return vd.filter((t)=>e.includes(t))}function Sa(e,t){if(typeof e!=="object"||e===null)return $t(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":Ft.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?Ht(Math.round(n.windowSec),10,3600):Ft.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?Ht(Math.round(n.maxBytes),262144,67108864):Ft.maxBytes,classes:wd(n.classes)??Ft.classes}}function zt(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 xd(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 Ra(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=zt(e.classes),s=zt(t.classes);o=xd({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:Ht(n,10,3600),maxBytes:Ht(r,262144,67108864),classes:o}}function Ea(e){return e==="balanced"||e==="full"?e:"strict"}function Ta(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var Ca="[data-vitrinka-unmask]";var Sd=3670016,Ma=4194240,Rd=2000,Aa=500,Ed=60000,Td=/[A-Za-z0-9_-]{20,}/g;function Y(e,t=""){return typeof e==="string"?e:t}function Cd(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(Td,"•••").slice(0,300)}var Md=4;function Ad(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===Md&&o.length)s();if(!i&&Ie(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}function Pd(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,Rd)}}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:Cd(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}async function Ld(e){try{let t=await L("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?$t(n):Sa(t.captureProfile,n),masking:Ea(t.profile),reachable:!0,attachments:is(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:$t(),masking:"strict",reachable:!1,attachments:J}}}function Pa(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 La{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(ci(e.base));let t=await Ld({url:e.base,key:e.key}),n=Ra(t.profile,e.capture),r=zt(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=ii("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,oi(ri(),globalThis.location?.host??""),w.pathname=globalThis.location?.pathname??"/",Ki(Ta(o.masking)),gn(e.sanitizeUrl),this.capture.push(()=>gn(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 ba();let d=await this.store.sweep(Date.now(),i,w.tabId,s);a=d;let f=this.store;l=(await Promise.all(d.filter((u)=>u.kind==="lanes").map((u)=>f.read(u.id)))).flatMap((u)=>u.lanes).sort((u,p)=>Date.parse(u.ts)-Date.parse(p.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else ya();if(!this.capturing)return this.store?.close(),this.store=null,o;if(ws({windowMs:i,checkoutMs:Math.min(Ed,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:En,keepLane:Pd(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(xs),this.store&&typeof window<"u"){let d=()=>kt();this.capture.push(I(window,"pagehide",d),I(document,"visibilitychange",d))}if(r.errors||r.console)ia({levels:r.console?["warn","info","log"]:[]}),this.capture.push(oa);if(r.errors||r.network)da({detail:"meta"}),this.capture.push(ca);if(r.replay){let d=await e.loadRecord(e.base).catch((f)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",f),null));if(d&&this.capturing)pa(d,"flight",{unmaskSelector:Ca}),this.capture.push(fa)}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)Es().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};w.pathname=globalThis.location?.pathname??w.pathname;let e=Pn();if(e&&Nt()&&!Ps(e))Gn(),e=Pn();let t=this.store,n=e?.windows.filter((o)=>o.stored).map((o)=>o.id)??[],r=t&&n.length?Promise.all(n.map(async(o)=>[o,await t.read(o)])).then((o)=>new Map(o)):Promise.resolve(new Map);return r.catch(()=>{return}),{clip:e,stored:r}}hiddenIdsAt(e){if(!this.capturing)return null;let t=Pa(Nt());return t?rr([e],t):null}async build(e,t,n=new Set){let r=t.filter((h)=>h.shape==="hide").map((h)=>h.rect),o=Pa(Nt()),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 h of rr(r,o))s.add(h);let a=[],l=e.clip?.truncated??!1,d=await e.stored.catch((h)=>(console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",h),null));for(let h of e.clip?.windows??[]){if(!h.stored){a.push(...h.events);continue}let E=d?.get(h.id);if(!E?.events.length)l=!0;else a.push(...E.events)}let f=e.clip?.lanes??[],g=i?{events:[],dropped:!1}:Ad(xa(a,r,s),Ma);if(g.dropped)l=!0;let{parts:u,dropped:p}=$n(g.events,Sd,Ma),m=[],y=0;for(let h of u){y+=h.count;let E=g.events[y-1]?.timestamp??Date.now();m.push({seq:m.length+1,ts:new Date(E).toISOString(),count:h.count,body:h.body})}let b=f.filter((h)=>h.kind==="console").slice(-Aa).map((h)=>({level:Y(h.payload?.level,"error"),ts:h.ts,text:Y(h.payload?.text)})),k=f.filter((h)=>h.kind==="net").slice(-Aa).map((h)=>({method:Y(h.payload?.method,"GET"),path:Y(h.payload?.path),status:typeof h.payload?.status==="number"?h.payload.status:0,ms:typeof h.payload?.ms==="number"?h.payload.ms:0}));return{chunks:m,truncated:l||p.length>0,console:b,network:k}}clear(){if(this.capturing)Rs()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),si(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var H=null;function Ia(e){if(H){let t=H.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 H.refs++,H.engine}return H={engine:new La(e),refs:1},H.engine}function Da(e){if(!e||!H||H.engine!==e)return;if(--H.refs>0)return;H=null,e.stop()}var Id=/^[\w-]+\.[\w-]+\.[\w-]+$/;function Kt(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!Id.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 Ba=null,or=new Set;function Dd(e){Ba=Kt(e);for(let t of or)t()}function _a(){return Ba}function Oa(e){return or.add(e),()=>or.delete(e)}var Bd=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),qt="report.keybind";function Na(e){if(Bd.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 Fa(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var _d={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function Od(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 _d[e]??e}function Nd(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function Wt(e,t=Nd()){let n=Od(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 Ha(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;let n=t;if(typeof n.code!=="string"||!n.code)return null;let r={code:n.code,alt:n.alt===!0,ctrl:n.ctrl===!0,meta:n.meta===!0,shift:n.shift===!0};return r.alt||r.ctrl||r.meta?r:null}catch{return null}}function za(){return Ha(M().getString(qt))}function ir(e){let t=M();if(e)t.set(qt,JSON.stringify(e));else t.remove(qt)}function $a(e){let t=M();return t.watch?t.watch(qt,(n)=>e(Ha(n))):()=>{return}}var Fd=["br","bl","tr","tl"];function sr(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 Hd(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 Ka(e,t,n){let r=sr(e,n);return t.reduce((o,i)=>o+Hd(r,i),0)}function qa(e,t,n){let r=Ka(e,t,n);if(r===0)return e;let o=e,i=r;for(let s of Fd){let a=Ka(s,t,n);if(a<i)o=s,i=a}return o}async function Wa(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 S(`${e} ${t} → ${i.status}: ${s}`,i.status);return s?JSON.parse(s):{}}function ja(e,t){return Wa("POST","/api/v1/report/session",e,{token:t})}function Ua(e,t=Date.now()){return e!==null&&Date.parse(e.expiresAt)-t>60000}function ar(e,t,n){let r=n?`?cursor=${encodeURIComponent(n)}`:"";return Wa("GET",`/api/v1/report/mine${r}`,e,void 0,t)}function Va(e,t){return`vitrinka.report.sent:${e}|${t}`}function Ya(){try{return globalThis.localStorage??null}catch{return null}}function lr(e,t){let n=Ya()?.getItem(Va(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 Xa(e,t,n){let r=Ya();if(!r)return;let o=[n,...lr(e,t)].slice(0,20);try{r.setItem(Va(e,t),JSON.stringify(o))}catch(i){console.warn("vitrinka: could not remember the sent report on this browser",i)}}var Ga=`
10
10
  :host { all: initial; }
11
11
  .vr {
12
12
  --ink: #f2f1ef;
@@ -16,6 +16,17 @@ ${h}\r
16
16
  --bg-deep: #121115;
17
17
  --accent: #dc2f4c;
18
18
  --accent-soft: rgba(220, 47, 76, .28);
19
+ /* Motion (transitions-dev tokens): a sliding indicator rides --dur-fast, the card's one glide --dur-slow. */
20
+ --dur-quick: 150ms;
21
+ --dur-fast: 250ms;
22
+ --dur-slow: 400ms;
23
+ --ease-smooth-out: cubic-bezier(0.22, 1, 0.36, 1);
24
+ /* Size (vt-8020 D9, settings.ts): ONE factor, written by the widget, scales the button, the card and
25
+ the marking bar — fonts and boxes together — each from its anchored corner. */
26
+ --vr-scale: 1;
27
+ /* The dock: the gap to the viewport edge, and where the card rests — clear of the button above or below it. */
28
+ --edge: 24px;
29
+ --lift: calc(var(--edge) + 72px * var(--vr-scale));
19
30
  font: 400 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
20
31
  color: var(--ink);
21
32
  -webkit-font-smoothing: antialiased;
@@ -24,6 +35,7 @@ ${h}\r
24
35
  }
25
36
  .vr *, .vr *::before, .vr *::after { box-sizing: border-box; }
26
37
  .vr [hidden] { display: none !important; }
38
+ .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
27
39
  button { font: inherit; color: inherit; cursor: pointer; }
28
40
  button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
29
41
  outline: 2px solid #fff; outline-offset: 2px;
@@ -31,7 +43,10 @@ button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visib
31
43
 
32
44
  /* -- the floating button -------------------------------------------------- */
33
45
  .fab {
34
- position: fixed; right: 24px; bottom: 24px;
46
+ position: fixed; right: var(--edge); bottom: var(--edge);
47
+ scale: var(--vr-scale); transform-origin: 100% 100%;
48
+ /* A press can become a drag to another corner: the page never scrolls under it. */
49
+ touch-action: none;
35
50
  display: inline-flex; align-items: center; gap: 12px;
36
51
  padding: 15px 22px; border: 0; border-radius: 999px;
37
52
  background: #131216; color: #fff;
@@ -48,23 +63,50 @@ kbd {
48
63
  border: 1px solid rgba(255, 255, 255, .26); color: rgba(255, 255, 255, .78);
49
64
  }
50
65
 
51
- /* -- the card --------------------------------------------------------------- */
66
+ /* -- the card: ONE size from drafting to thanks (vt-8020 D10) ---------------- */
52
67
  .card {
53
- position: fixed; right: 24px; bottom: 96px;
54
- width: min(420px, calc(100vw - 32px));
55
- max-height: calc(100vh - 120px); overflow: auto;
68
+ position: fixed; right: var(--edge); bottom: var(--lift);
69
+ display: flex; flex-direction: column;
70
+ /* The box is divided by the scale so the painted card (scale × box) still fits the viewport. */
71
+ width: min(380px, calc((100vw - 32px) / var(--vr-scale)));
72
+ height: min(460px, calc((100vh - var(--lift) - var(--edge)) / var(--vr-scale)));
73
+ scale: var(--vr-scale); transform-origin: 100% 100%;
56
74
  background: var(--bg); color: var(--ink);
57
75
  border: 1px solid rgba(255, 255, 255, .08); border-radius: 16px;
58
76
  box-shadow: 0 28px 70px rgba(0, 0, 0, .38), 0 2px 8px rgba(0, 0, 0, .2);
59
77
  pointer-events: auto;
60
78
  animation: vr-in .16s ease-out;
61
79
  }
62
- .vr.nobutton .card { bottom: 24px; }
80
+ .vr.nobutton .card { bottom: var(--edge); }
81
+ /* The dock (vt-8020 D9, drag.ts): the button in any corner; the card rests beside it — above it at the
82
+ bottom, below it at the top — and both scale from that corner. */
83
+ .vr[data-dock$="l"] .fab, .vr[data-dock$="l"] .card { right: auto; left: var(--edge); }
84
+ .vr[data-dock^="t"] .fab { bottom: auto; top: var(--edge); }
85
+ .vr[data-dock^="t"] .card { bottom: auto; top: var(--lift); }
86
+ .vr.nobutton[data-dock^="t"] .card { top: var(--edge); }
87
+ .vr[data-dock="bl"] .fab, .vr[data-dock="bl"] .card { transform-origin: 0 100%; }
88
+ .vr[data-dock="tr"] .fab, .vr[data-dock="tr"] .card { transform-origin: 100% 0; }
89
+ .vr[data-dock="tl"] .fab, .vr[data-dock="tl"] .card { transform-origin: 0 0; }
90
+ /* Dragged, the button rides the pointer by its left/top; dropped, it glides into its corner (FLIP on translate). */
91
+ .vr .fab.dragging { transform-origin: 0 0; transition: none; cursor: grabbing; }
92
+ .fab.gliding { transition: translate var(--dur-slow) var(--ease-smooth-out), transform .14s ease, box-shadow .14s ease; }
93
+ /* Parked by marking: placed by left/top where it already is (place.ts, from its painted box) — the same size,
94
+ so starting to mark never moves it; it glides once to a corner clear of the marks. */
95
+ .card.parked { right: auto; bottom: auto; transition: left var(--dur-slow) var(--ease-smooth-out), top var(--dur-slow) var(--ease-smooth-out); }
96
+ .vr .card.parked { transform-origin: 0 0; }
63
97
  @keyframes vr-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
64
98
  .head {
65
- display: flex; align-items: center; gap: 4px;
66
- padding: 16px 14px 16px 20px; border-bottom: 1px solid rgba(255, 255, 255, .07);
99
+ position: relative; flex: none; display: flex; align-items: center; gap: 4px;
100
+ padding: 12px 10px 12px 18px; border-bottom: 1px solid rgba(255, 255, 255, .07);
67
101
  }
102
+ /* Sending: a quiet sweep along the head's edge, the card's size untouched. */
103
+ .card.busy .head::after {
104
+ content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
105
+ background: linear-gradient(90deg, transparent, rgba(242, 241, 239, .6), transparent) no-repeat;
106
+ background-size: 40% 100%; animation: vr-sweep 1.3s linear infinite;
107
+ }
108
+ @keyframes vr-sweep { from { background-position: -70% 0; } to { background-position: 170% 0; } }
109
+ .body { flex: 1; min-height: 0; overflow: auto; }
68
110
  .head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
69
111
  .icon {
70
112
  display: inline-grid; place-items: center; width: 32px; height: 32px;
@@ -72,10 +114,71 @@ kbd {
72
114
  }
73
115
  .icon:hover { background: var(--faint); color: var(--ink); }
74
116
  .icon svg { width: 16px; height: 16px; }
75
- .pane { padding: 18px 20px 20px; }
117
+ .icon[aria-expanded="true"] { background: var(--faint); color: var(--ink); }
118
+
119
+ /* -- who you are and the menu (vt-8020 D5 A) -------------------------------- */
120
+ .who {
121
+ display: inline-flex; align-items: center; gap: 7px; max-width: 132px; height: 32px; padding: 0 11px 0 5px; margin-right: 2px;
122
+ border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px; background: transparent; color: var(--ink);
123
+ font-size: 13px; font-weight: 600;
124
+ }
125
+ .who:hover, .who[aria-expanded="true"] { background: var(--faint); }
126
+ .who .av {
127
+ display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%;
128
+ background: #3a3940; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
129
+ }
130
+ .who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
131
+ .pop {
132
+ position: absolute; top: 52px; right: 10px; z-index: 2; min-width: 240px; max-width: calc(100% - 20px); padding: 6px;
133
+ background: #222126; border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px;
134
+ box-shadow: 0 18px 44px rgba(0, 0, 0, .42); animation: vr-in .14s ease-out;
135
+ }
136
+ .pop-item {
137
+ display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 8px;
138
+ background: transparent; color: var(--ink); font-size: 13.5px; font-weight: 550; text-decoration: none; text-align: left;
139
+ }
140
+ .pop-item:hover, .pop-item:focus-visible { background: var(--faint); }
141
+ .pop-item svg { width: 15px; height: 15px; flex: none; color: var(--dim); }
142
+ .acc-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; }
143
+ .acc-who strong { font-size: 14px; }
144
+ .acc-mail, .acc-via { color: var(--dim); font-size: 12.5px; margin: 0; }
145
+ .acc-member { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; }
146
+ .acc-member:has(.acc-linked:not([hidden])) { padding: 8px 10px; border-top: 1px solid rgba(255, 255, 255, .07); }
147
+ .acc-linked { margin: 0; font-size: 12.5px; color: var(--ink); }
148
+
149
+ /* -- the lists: My reports, recent recordings — in the card body ------------ */
150
+ .back { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 10px -4px; padding: 4px; border: 0; background: none; color: var(--ink); font-size: 14px; font-weight: 650; }
151
+ .back svg { width: 14px; height: 14px; color: var(--dim); }
152
+ .rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
153
+ .row {
154
+ display: grid; grid-template-columns: 1fr auto; grid-template-areas: "t step" "age step"; column-gap: 10px;
155
+ padding: 9px 10px; border-radius: 10px; background: rgba(242, 241, 239, .045); color: var(--ink); text-decoration: none;
156
+ }
157
+ a.row:hover { background: var(--faint); }
158
+ .row-t { grid-area: t; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
159
+ .age { grid-area: age; color: var(--dim); font-size: 12px; }
160
+ .step { grid-area: step; align-self: center; padding: 3px 9px; border-radius: 999px; background: var(--bg-deep); color: var(--dim); font-size: 12px; font-weight: 600; }
161
+ .step:empty { display: none; }
162
+ .list-status, .list-note { margin: 8px 0; color: var(--dim); font-size: 13px; }
163
+
164
+ /* -- the member link sheet (the pill's flow, vt-8020 D3) ------------------- */
165
+ .code { margin: 6px 0 14px; font: 650 26px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
166
+ .link-go { display: flex; align-items: center; gap: 16px; }
167
+ .qr { width: 104px; height: 104px; border-radius: 8px; background: #fff; padding: 6px; }
168
+ .pane { padding: 14px 16px 16px; }
169
+ /* The reporter's word for it (vt-8020 D11): chips above the input, like the board composer's intents. */
170
+ .kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
171
+ .kinds button {
172
+ height: 28px; padding: 0 11px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px;
173
+ background: transparent; color: rgba(242, 241, 239, .6); font-size: 13px; font-weight: 600;
174
+ transition: background-color var(--dur-quick) ease-out, border-color var(--dur-quick) ease-out, color var(--dur-quick) ease-out;
175
+ }
176
+ .kinds button:hover:not(:disabled) { color: var(--ink); }
177
+ .kinds button[aria-checked="true"] { background: rgba(242, 241, 239, .12); border-color: rgba(242, 241, 239, .26); color: var(--ink); }
178
+ .kinds button:disabled { opacity: .5; cursor: default; }
76
179
  .prompt { display: block; margin: 0 0 8px; font-weight: 600; font-size: 14px; }
77
180
  .desc {
78
- display: block; width: 100%; min-height: 88px; resize: vertical;
181
+ display: block; width: 100%; min-height: 76px; resize: none;
79
182
  padding: 12px 14px; border-radius: 10px;
80
183
  border: 1px solid rgba(255, 255, 255, .2); background: var(--bg-deep); color: var(--ink);
81
184
  font-family: inherit; font-size: 15px; font-weight: 400; line-height: 1.45;
@@ -93,22 +196,54 @@ kbd {
93
196
  .link[aria-expanded="true"] svg { transform: rotate(180deg); }
94
197
  .included { margin: 10px 0 0; padding: 10px 12px 10px 28px; border-radius: 10px; background: var(--bg-deep); color: var(--dim); font-size: 13px; }
95
198
  .included li { margin: 2px 0; }
96
- .marked { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--dim); }
97
- .chip {
98
- display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
99
- border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
199
+ /* One numbered line per mark: its note, typed in the card, never floating on the page. */
200
+ .lines-wrap { margin-top: 10px; }
201
+ .lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
202
+ .ln {
203
+ display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 4px 0 9px;
204
+ border-radius: 10px; background: rgba(242, 241, 239, .045); border: 1px solid transparent;
205
+ }
206
+ .ln:focus-within { background: var(--bg-deep); border-color: rgba(242, 241, 239, .36); }
207
+ .ln-n {
208
+ display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%;
209
+ background: var(--accent); color: #fff; font-size: 11px; font-weight: 750; box-shadow: 0 0 0 1.5px #fff;
210
+ }
211
+ .ln.hide .ln-n { background: #3a3940; }
212
+ .ln-t {
213
+ flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; color: var(--ink);
214
+ font-family: inherit; font-size: 13.5px;
100
215
  }
101
- .chip.hide { background: #3a3940; }
216
+ .ln-t::placeholder { color: rgba(242, 241, 239, .4); }
217
+ .ln-t:focus, .ln-t:focus-visible { outline: none; }
218
+ .ln-x { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 7px; background: transparent; color: rgba(242, 241, 239, .5); }
219
+ .ln-x:hover:not(:disabled) { background: var(--faint); color: var(--ink); }
220
+ .ln-x svg { width: 11px; height: 11px; }
221
+ .ln-empty { margin: 0; padding: 11px 13px; border: 1px dashed rgba(242, 241, 239, .14); border-radius: 10px; color: rgba(242, 241, 239, .46); font-size: 13px; }
102
222
  .notify { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink); cursor: pointer; }
103
223
  .notify input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
104
224
  .error { margin: 12px 0 0; color: #ff9aa9; font-size: 13px; }
105
- .actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
225
+ /* The bottom actions: attachments and Show us where on the left, Send on the right. */
226
+ .foot { flex: none; display: flex; align-items: center; gap: 4px; padding: 10px 12px 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
227
+ .foot .send { margin-left: auto; }
228
+ .icon:disabled { opacity: .45; cursor: default; background: transparent; color: var(--dim); }
229
+ /* Attached files (vt-8020 D9): chips in a tray above the foot — it scrolls, the card never grows. */
230
+ .tray { flex: none; max-height: 84px; overflow: auto; padding: 9px 12px 0; border-top: 1px solid rgba(255, 255, 255, .07); }
231
+ .tray:not([hidden]) + .foot { border-top: 0; }
232
+ .file-note { margin: 0 0 7px; color: #ffc1ca; font-size: 12.5px; }
233
+ .files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
234
+ .file { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; height: 28px; padding: 0 2px 0 10px; border-radius: 8px; background: rgba(242, 241, 239, .07); font-size: 12.5px; }
235
+ .file-name { min-width: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
236
+ .file-size { flex: none; color: var(--dim); }
237
+ .file .ln-x { width: 22px; height: 22px; }
238
+ /* A file dragged over the card: it will land here. */
239
+ .card.dropping { outline: 2px dashed rgba(242, 241, 239, .5); outline-offset: -7px; }
106
240
  .where {
107
241
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 9px;
108
242
  border: 1px solid rgba(255, 255, 255, .2); background: transparent; color: var(--ink);
109
243
  font-size: 13px; font-weight: 600;
110
244
  }
111
245
  .where:hover:not(:disabled) { background: var(--faint); }
246
+ .where[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
112
247
  .where svg { width: 14px; height: 14px; }
113
248
  .where:disabled { opacity: .45; cursor: default; }
114
249
  .send {
@@ -119,8 +254,15 @@ kbd {
119
254
  .send:disabled { opacity: .45; cursor: default; }
120
255
 
121
256
  /* -- settings --------------------------------------------------------------- */
122
- .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
123
- .row .label { font-weight: 600; }
257
+ /* Scoped to the pane: a bare .row would restyle the lists' rows (their grid) above. */
258
+ .settings .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
259
+ .settings .label { font-weight: 600; }
260
+ .size-row { margin-top: 18px; }
261
+ .size-row .seg button { padding: 0 12px; font-size: 13px; }
262
+ .tech-wrap { margin-top: 18px; }
263
+ .tech { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--bg-deep); font-size: 12.5px; }
264
+ .tech dt { color: var(--dim); }
265
+ .tech dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
124
266
  .bind {
125
267
  min-width: 120px; padding: 8px 12px; border-radius: 9px; text-align: center;
126
268
  border: 1px solid rgba(255, 255, 255, .2); background: var(--bg-deep);
@@ -153,42 +295,62 @@ kbd {
153
295
  .ink .veil { fill: #1b1b1f; }
154
296
  .ink .veil-label { fill: rgba(255, 255, 255, .7); font: 600 12px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
155
297
  .ink .draft { opacity: .85; }
156
- .pin { position: absolute; display: flex; align-items: center; gap: 6px; cursor: default; }
298
+ /* A pin is the mark's number on the page; its ✕ shows while the pin is hovered or focused. */
299
+ .pin { position: absolute; display: flex; align-items: center; gap: 4px; cursor: default; }
157
300
  .pin .num {
158
- display: grid; place-items: center; width: 24px; height: 24px; border-radius: 12px;
301
+ display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 12px;
159
302
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 750;
160
303
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 0 0 2px #fff;
161
304
  }
162
- .pin .note {
163
- width: 220px; padding: 6px 10px; border-radius: 9px;
164
- border: 1px solid rgba(255, 255, 255, .16); background: #151417; color: #fff;
165
- font-family: inherit; font-size: 13px; font-weight: 400; line-height: 1.3;
166
- box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
167
- }
168
- .pin .note::placeholder { color: rgba(255, 255, 255, .45); }
169
- .pin .note:focus { outline: none; border-color: var(--accent); }
170
305
  .pin .rm {
171
- display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 12px;
306
+ display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 11px;
172
307
  background: #151417; color: rgba(255, 255, 255, .7); box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
308
+ opacity: 0; transition: opacity var(--dur-quick) ease-out;
173
309
  }
310
+ .pin:hover .rm, .pin:focus-within .rm { opacity: 1; }
174
311
  .pin .rm:hover { color: #fff; }
175
- .pin .rm svg { width: 12px; height: 12px; }
176
- .toolbar {
177
- position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
178
- display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 15px;
179
- background: #151417; box-shadow: 0 16px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .08) inset;
180
- cursor: default;
181
- }
182
- .toolbar button {
183
- padding: 9px 15px; border: 0; border-radius: 10px; background: transparent; color: #f2f1ef;
184
- font-size: 15px; font-weight: 600;
185
- }
186
- .toolbar button:hover { background: rgba(255, 255, 255, .08); }
187
- .toolbar button[aria-pressed="true"] { background: #e6455f; color: #fff; }
188
- .toolbar .sep { width: 1px; height: 22px; margin: 0 4px; background: rgba(255, 255, 255, .14); }
189
- .toolbar .done { background: var(--accent); color: #fff; }
190
- .toolbar .done:hover { background: #e43a57; }
191
- .toolbar button:disabled { opacity: .4; cursor: default; background: transparent; }
312
+ .pin .rm svg { width: 11px; height: 11px; }
313
+
314
+ /* The marking bar (vt-8020 D6): translucent glass at the top, the shape as a segmented control. */
315
+ .tb {
316
+ /* translate (not transform): it applies after the scale, so the scaled bar stays centred. */
317
+ position: fixed; left: 50%; top: 14px; translate: -50% 0;
318
+ scale: var(--vr-scale); transform-origin: 50% 0;
319
+ display: flex; align-items: center; gap: 4px; padding: 5px;
320
+ border-radius: 14px; border: 1px solid rgba(255, 255, 255, .08);
321
+ background: rgba(30, 29, 34, .68);
322
+ -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
323
+ box-shadow: 0 14px 36px rgba(0, 0, 0, .36), 0 2px 6px rgba(0, 0, 0, .18), 0 1px 0 rgba(255, 255, 255, .05) inset;
324
+ color: var(--ink); cursor: default; white-space: nowrap;
325
+ }
326
+ .tb-lead { padding: 0 12px 0 11px; color: rgba(242, 241, 239, .56); font-size: 13.5px; font-weight: 500; }
327
+ .seg { position: relative; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
328
+ .seg button {
329
+ position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px;
330
+ height: 30px; padding: 0 13px 0 11px; border: 0; border-radius: 8px; background: transparent;
331
+ color: rgba(242, 241, 239, .56); font-size: 13.5px; font-weight: 600;
332
+ transition: color var(--dur-fast) var(--ease-smooth-out);
333
+ }
334
+ .seg button svg { width: 15px; height: 15px; flex: none; }
335
+ .seg button:hover { color: rgba(242, 241, 239, .86); }
336
+ .seg button[aria-checked="true"] { color: var(--ink); }
337
+ .seg-ind {
338
+ position: absolute; top: 3px; left: 0; z-index: 0; width: 0; height: 30px; border-radius: 8px;
339
+ background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .115));
340
+ box-shadow: 0 1px 0 rgba(255, 255, 255, .13) inset, 0 2px 7px rgba(0, 0, 0, .38), 0 0 0 1px rgba(0, 0, 0, .22);
341
+ transition: transform var(--dur-fast) var(--ease-smooth-out), width var(--dur-fast) var(--ease-smooth-out);
342
+ pointer-events: none; opacity: 0;
343
+ }
344
+ .seg.measured .seg-ind { opacity: 1; }
345
+ /* Before the indicator is measured, the picked segment carries the raised fill itself. */
346
+ .seg:not(.measured) button[aria-checked="true"] { background: rgba(255, 255, 255, .15); }
347
+ .tb-sep { width: 1px; height: 20px; margin: 0 5px; background: rgba(255, 255, 255, .1); }
348
+ .tb-quiet { height: 32px; padding: 0 13px; border: 0; border-radius: 9px; background: transparent; color: rgba(242, 241, 239, .72); font-size: 13.5px; font-weight: 600; }
349
+ .tb-quiet:hover { background: rgba(255, 255, 255, .07); color: var(--ink); }
350
+ .tb-confirm { display: inline-flex; align-items: center; gap: 4px; }
351
+ .tb-ask { padding: 0 6px 0 4px; font-size: 13.5px; font-weight: 600; }
352
+ .tb-discard { height: 32px; padding: 0 13px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 650; }
353
+ .tb-discard:hover { background: #e43a57; }
192
354
 
193
355
  /* -- the coach card (D21): stays beside the pointer until mark 1 exists --- */
194
356
  .coach {
@@ -212,18 +374,20 @@ kbd {
212
374
  @keyframes vr-hold { 0%, 8% { opacity: 0; } 14%, 72% { opacity: .9; } 80%, 100% { opacity: 0; } }
213
375
 
214
376
  @media (max-width: 520px) {
215
- .fab { right: 16px; bottom: 16px; padding: 13px 18px; font-size: 16px; }
216
- .card { right: 16px; bottom: 84px; }
217
- .vr.nobutton .card { bottom: 16px; }
218
- .toolbar { bottom: 16px; max-width: calc(100vw - 24px); overflow-x: auto; }
219
- .toolbar button { padding: 8px 11px; font-size: 14px; }
377
+ .vr { --edge: 16px; --lift: calc(var(--edge) + 68px * var(--vr-scale)); }
378
+ .fab { padding: 13px 18px; font-size: 16px; }
379
+ .tb { max-width: calc((100vw - 16px) / var(--vr-scale)); overflow-x: auto; }
380
+ .tb-lead { display: none; }
381
+ .seg button { padding: 0 9px; }
220
382
  .coach { width: 260px; }
221
383
  }
222
384
  @media (prefers-reduced-motion: reduce) {
223
385
  .card { animation: none; }
224
- .fab { transition: none; }
386
+ .card.parked, .seg-ind, .seg button, .kinds button, .pin .rm { transition: none; }
387
+ .card.busy .head::after { animation: none; }
388
+ .fab, .fab.gliding { transition: none; }
225
389
  .coach .loop { animation: none; stroke-dashoffset: 0; }
226
390
  .coach .hold { animation: none; opacity: .9; }
227
391
  }
228
- `;class Ln{capture;tabHost;target;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;constructor(e,t,n){this.capture=e;this.tabHost=t;this.target=n}async run(e){let t={target:this.target},n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let i=await O("POST","/api/v1/reports",e,t);if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r}else if(this.sent!==r)await O("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n,t),this.sent=r;if(!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof T)||!j(i.status))throw i;console.warn("vitrinka: the server refused the recording — the report goes without it",i),this.skipCapture=!0}let o=await O("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{},t);return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async sendCapture(){let e=encodeURIComponent(this.id),{chunks:t,truncated:n}=this.capture;for(let o of t){if(this.blobKeys.has(o.seq))continue;let i=await Yt(`/api/v1/reports/${e}/chunk?seq=${o.seq}`,"application/json",o.body,this.target);if(!i.blobKey)throw Error(`vitrinka: chunk ${o.seq} came back without a blob key`);this.blobKeys.set(o.seq,i.blobKey)}let r=t.map((o)=>({seq:o.seq,ts:o.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:o.count,source:"replay",truncated:n},blobKey:this.blobKeys.get(o.seq)??""}));while(this.rowsPosted<r.length){let o=r.slice(this.rowsPosted,this.rowsPosted+pt);await O("POST",`/api/v1/reports/${e}/events`,{events:o},{target:this.target}),this.rowsPosted+=o.length}}}var Fa="http://www.w3.org/2000/svg",Ei=100,Ri={chunks:[],truncated:!1,console:[],network:[]},Ka=["circle","box","arrow","hide"],Dn={w:160,h:80},Ti=16,Wa={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},le={close:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',gear:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="2.2" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.4 3.4l1.4 1.4M11.2 11.2l1.4 1.4M3.4 12.6l1.4-1.4M11.2 4.8l1.4-1.4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',clip:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.5 4.5l-5 5a1.6 1.6 0 002.3 2.3l5.4-5.4a3 3 0 00-4.2-4.2L3.6 7.6a4.4 4.4 0 006.2 6.2l4-4" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',chevron:'<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',pen:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.8 2.7l2.5 2.5-7.6 7.6-3.1 0.6 0.6-3.1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>',check:'<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M7.5 12.3l3 3 6-6.3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>'},Mi="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14";function za(e){let t=e?"":`<animateMotion dur="2.8s" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="0;0.18;0.72;1" calcMode="linear" path="${Mi}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true"><rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${Mi}" pathLength="200"/><g class="pointer"${e?' transform="translate(134 14)"':""}><circle class="hold" r="9"/><path d="M0 0 L0 15 L4 11 L7 18 L10 16.6 L7 10 L12.5 10 Z" fill="#fff" stroke="#151417" stroke-width="1"/>${t}</g></svg>`}function u(e,t={},...n){let r=document.createElement(e);for(let[o,i]of Object.entries(t))r.setAttribute(o,i);return r.append(...n),r}function Q(e){let t=document.createElement("template");t.innerHTML=e;let n=t.content.firstElementChild;if(!n)throw Error("vitrinka: icon markup is empty");return n}function _(e,t){let n=document.createElementNS(Fa,e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function ja(e){let t=e.split(`
229
- `)[0]?.trim()??"";return t.length>Ei?`${t.slice(0,Ei-1)}…`:t}function Ua(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function Ci(){let e=document.activeElement;while(e?.shadowRoot?.activeElement)e=e.shadowRoot.activeElement;if(e===document.body)return null;return e instanceof HTMLElement||e instanceof SVGElement?e:null}function Va(e){let t=u("span"),n=u("kbd"),r=u("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},t,n),o=u("h2",{id:"vr-title"}),i=u("button",{class:"icon",type:"button"},Q(le.gear)),s=u("button",{class:"icon",type:"button"},Q(le.close)),a=u("header",{class:"head"},o,i,s),l=u("label",{class:"prompt",for:"vr-desc"}),d=u("textarea",{class:"desc",id:"vr-desc",rows:"3"}),g=u("span"),b=u("span"),c=u("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},b,Q(le.chevron)),p=u("div",{class:"attached"},Q(le.clip),g,u("span",{"aria-hidden":"true"},"·"),c),h=u("ul",{class:"included",id:"vr-included"}),k=u("span",{class:"chips"}),m=u("span"),y=u("div",{class:"marked"},k,m),f=u("input",{type:"checkbox"}),R=u("span"),D=u("label",{class:"notify"},f,R),Te=u("p",{class:"error",role:"alert"}),Ve=u("span"),Ye=u("button",{class:"where",type:"button"},Q(le.pen),Ve),Me=u("button",{class:"send",type:"button"}),Hn=u("div",{class:"pane describe"},l,d,p,h,y,D,Te,u("div",{class:"actions"},Ye,Me)),qn=u("span",{class:"label",id:"vr-bind-label"}),$n=u("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),Fn=u("button",{class:"link",type:"button"}),Kn=u("p",{class:"hint"}),Wn=u("p",{class:"reason",role:"status"}),zn=u("button",{class:"link",type:"button"}),jn=u("div",{class:"pane settings"},u("div",{class:"row"},qn,$n),Wn,Kn,u("div",{class:"settings-foot"},zn,Fn)),Un=u("h3"),Vn=u("p",{class:"sent-body"}),Yn=u("span"),Xn=u("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Yn),Gn=u("button",{class:"link",type:"button"}),Jn=u("div",{class:"pane sent",role:"status"},u("div",{class:"sent-head"},Q(le.check),Un),Vn,u("div",{class:"sent-actions"},Xn,Gn)),Zn=u("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},a,Hn,jn,Jn),Ct=_("svg",{class:"ink","aria-hidden":"true"}),Qn=_("defs",{}),er=_("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});er.append(_("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),Qn.append(er);let tr=_("g",{}),nr=_("g",{class:"draft"});Ct.append(Qn,tr,nr);let rr=u("div",{class:"pins"}),or=u("p"),ir=u("p"),sr=u("p",{class:"keys",id:"vr-keys"}),It=u("div",{class:"coach",role:"status"});It.append(Q(za(Ua())),or,ir,sr);let At=new Map;for(let ur of Ka)At.set(ur,u("button",{type:"button","aria-pressed":"false","data-tool":ur}));let ar=u("button",{type:"button"}),lr=u("button",{type:"button",class:"done"}),cr=u("div",{class:"toolbar",role:"toolbar"},...At.values(),u("span",{class:"sep","aria-hidden":"true"}),ar,lr),Pt=u("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},rr,It,cr);Pt.prepend(Ct);let _t=u("div",{class:"vr"},r,Zn,Pt),dr=u("style");return dr.textContent=Si,_t.prepend(dr),e.append(_t),{root:_t,fab:r,fabLabel:t,fabKbd:n,card:Zn,title:o,gear:i,closeBtn:s,describe:Hn,prompt:l,desc:d,attached:p,attachedText:g,disclose:c,discloseText:b,included:h,marked:y,markedChips:k,markedText:m,notify:D,notifyBox:f,notifyText:R,error:Te,where:Ye,whereText:Ve,send:Me,settings:jn,bindLabel:qn,bindBtn:$n,unbind:Fn,bindHint:Kn,bindReason:Wn,back:zn,sent:Jn,sentTitle:Un,sentBody:Vn,see:Xn,seeText:Yn,sentClose:Gn,mark:Pt,ink:Ct,shapes:tr,draft:nr,pins:rr,coach:It,coachText:or,coachMore:ir,coachKeys:sr,toolButtons:At,toolbar:cr,undo:ar,done:lr}}class On{opts;hud;engine;config=null;locale;s;button;openSelector;identity;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool="circle";frozen=null;job=null;sending=!1;error="";result=null;notify=!1;sentNotify=!1;includedOpen=!1;recordingBind=!1;bindRefused=!1;noteOpen=null;drawing=null;offs=[];pins=new Map;hideIds=new Map;dialogOrder=[...document.querySelectorAll("dialog[open]")].filter((e)=>e instanceof HTMLDialogElement);activeDialog(){this.dialogOrder=this.dialogOrder.filter((n)=>n.isConnected&&n.open);let e=(n)=>{try{return n.matches(":modal")}catch{return!1}};return[...this.dialogOrder].reverse().find(e)??this.dialogOrder.at(-1)??Wr()}sheet=null;e;constructor(e){this.opts=e;this.locale=e.locale??Nt(),this.s=Dt(this.locale),this.button=e.button,this.openSelector=e.openSelector??null,this.identity=e.identity===void 0?void 0:Et(e.identity),this.keybind=wi(),this.hud=Fr(),this.e=Va(this.hud.mount),this.engine=fi({base:e.base,key:e.key,appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl,loadRecord:e.loadRecord}),this.engine?.ready.then((t)=>{this.config=t,this.paint()}),this.bind(),this.paint(),this.followDialog()}followDialog(){let e=this.activeDialog();if((this.sheet?.target??null)===e)return;let t=this.e.root.getRootNode(),n=t instanceof ShadowRoot&&t.activeElement instanceof HTMLElement?t.activeElement:null,r=this.sheet;if(e){let o=zr(e);o.mount.append(this.e.root),this.sheet={target:e,host:o}}else this.hud.mount.append(this.e.root),this.sheet=null;r?.host.destroy(),n?.focus()}open(){if(this.isOpen)return;if(this.isOpen=!0,this.opener=jr(document.activeElement)?null:Ci(),this.view!=="describe")this.view="describe";if(this.result=null,!this.job)this.frozen=this.engine?.freeze()??null;this.paint(),requestAnimationFrame(()=>this.e.desc.focus())}close(){if(!this.isOpen)return;if(this.marking)this.endMarking(!1);this.stopRecordingBind(),this.isOpen=!1,this.view="describe",this.paint();let e=this.opener;if(this.opener=null,e?.focus(),e&&Ci()===e)return;if(this.button)this.e.fab.focus()}setLocale(e){let t=Ce(e)??Nt();if(t===this.locale)return;this.locale=t,this.s=Dt(t),this.paint()}setButton(e){this.button=e,this.paint()}setOpenSelector(e){this.openSelector=e||null}identify(e){this.identity=e===void 0?void 0:Et(e),this.paint()}unmount(){this.stopRecordingBind();for(let e of this.offs.splice(0).reverse())e();hi(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let e=this.e,t=(o,i,s)=>{o.addEventListener(i,s)};t(e.fab,"click",()=>this.isOpen?this.close():this.open()),t(e.closeBtn,"click",()=>this.close()),t(e.gear,"click",()=>this.show(this.view==="settings"?"describe":"settings")),t(e.back,"click",()=>this.show("describe")),t(e.sentClose,"click",()=>this.close()),t(e.desc,"input",()=>this.paint()),t(e.disclose,"click",()=>{this.includedOpen=!this.includedOpen,this.paint()}),t(e.notifyBox,"change",()=>{this.notify=e.notifyBox.checked}),t(e.where,"click",()=>this.startMarking()),t(e.send,"click",()=>void this.send()),t(e.bindBtn,"click",()=>this.recordingBind?this.stopRecordingBind():this.startRecordingBind()),t(e.unbind,"click",()=>{this.keybind=null,_n(null),this.paint()}),t(e.card,"keydown",(o)=>{if(o.key!=="Escape"||this.recordingBind)return;if(o.preventDefault(),this.view==="settings")this.show("describe");else this.close()});for(let[o,i]of e.toolButtons)t(i,"click",(s)=>{if(this.tool=o,this.renderKbDraft(),this.paint(),s.detail===0)e.mark.focus()});if(t(e.mark,"keydown",(o)=>this.markKey(o)),t(e.undo,"click",()=>{this.markers=Nn(this.markers.slice(0,-1)),this.renderMarks(),this.paint()}),t(e.done,"click",()=>this.endMarking(!0)),t(e.mark,"pointerdown",(o)=>this.pointerDown(o)),t(e.mark,"pointermove",(o)=>this.pointerMove(o)),t(e.mark,"pointerup",(o)=>this.pointerUp(o)),t(e.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(N(e.mark,"wheel",(o)=>o.preventDefault())),this.offs.push(N(e.mark,"touchmove",(o)=>o.preventDefault())),this.offs.push(N(window,"keydown",(o)=>{if(this.recordingBind)return;if(this.marking&&o.key==="Escape"){if(o.preventDefault(),this.kbDraft)this.cancelDraft();else this.endMarking(!0);return}if(this.keybind&&ki(o,this.keybind))if(o.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(N(document,"click",(o)=>{let i=this.openSelector,s=o.target;if(!i||!(s instanceof Element))return;let a=null;try{a=s.closest(i)}catch{return}if(!a)return;o.preventDefault(),this.open()})),this.offs.push(xi((o)=>{this.keybind=o,this.paint()})),this.offs.push(bi(()=>this.paint())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let n=0,r=new MutationObserver((o)=>{for(let i of o){if(i.type!=="attributes"||i.attributeName!=="open"||!(i.target instanceof HTMLDialogElement))continue;let s=i.target;if(!s.open)this.dialogOrder=this.dialogOrder.filter((a)=>a!==s);else if(i.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((a)=>a!==s),s]}if(n)return;n=requestAnimationFrame(()=>{n=0,this.followDialog()})});r.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(r.disconnect(),n)cancelAnimationFrame(n)})}show(e){if(this.stopRecordingBind(),this.view=e,this.paint(),e==="describe")requestAnimationFrame(()=>this.e.desc.focus());if(e==="settings")requestAnimationFrame(()=>this.e.bindBtn.focus())}who(){return this.identity!==void 0?this.identity:mi()}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=N(window,"keydown",(e)=>{e.preventDefault(),e.stopPropagation();let t=yi(e);if(t.kind==="wait")return;if(t.kind==="bare"){this.bindRefused=!0,this.paint();return}if(t.kind==="bind")this.keybind=t.bind,_n(t.bind);this.stopRecordingBind()},{capture:!0}),this.paint()}stopRecordingBind(){if(!this.recordingBind)return;this.recordingBind=!1,this.bindRefused=!1,this.stopBindListener?.(),this.stopBindListener=null,this.paint()}startMarking(){if(this.job?.id)return;this.marking=!0,this.noteOpen=null,this.renderMarks(),this.paint();let e=globalThis.innerWidth||800,t=globalThis.innerHeight||600;this.placeCoach({x:e/2-150,y:t-260},!1),this.e.mark.focus()}endMarking(e){if(this.cancelDraft(),this.marking=!1,this.noteOpen=null,this.paint(),e&&this.isOpen)requestAnimationFrame(()=>this.e.desc.focus())}onChrome(e){return e instanceof Node&&(this.e.toolbar.contains(e)||this.e.pins.contains(e))}pointerDown(e){if(this.onChrome(e.target)||e.button!==0||!e.isPrimary)return;e.preventDefault();let t=this.e.root.getRootNode();if(t instanceof ShadowRoot&&t.activeElement instanceof HTMLElement)t.activeElement.blur();this.noteOpen=null,this.drawing={start:{x:e.clientX,y:e.clientY},shape:this.tool,pointer:e.pointerId};try{this.e.mark.setPointerCapture(e.pointerId)}catch{}this.e.coach.classList.add("pressing"),this.renderPins()}pointerMove(e){if(!this.markers.length)this.placeCoach({x:e.clientX,y:e.clientY},!0);let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:t.shape,rect:Rn(t.start,{x:e.clientX,y:e.clientY}),head:Tn(t.start,{x:e.clientX,y:e.clientY})}))}pointerUp(e){let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;let n={x:e.clientX,y:e.clientY};if(this.cancelDraft(),!ei(t.shape,t.start,n))return;this.addMarker(t.shape,Rn(t.start,n),t.shape==="arrow"?Tn(t.start,n):void 0)}addMarker(e,t,n){let r=this.nextKey++;if(e==="hide"){let o=this.engine?.hiddenIdsAt(t);if(o)this.hideIds.set(r,o)}this.markers=Nn([...this.markers,{key:r,n:this.markers.length+1,shape:e,rect:t,note:"",...n?{head:n}:{}}]),this.noteOpen=r,this.renderMarks(),this.paint(),this.pins.get(r)?.note.focus()}cancelDraft(){this.drawing=null,this.kbDraft=null,this.e.draft.replaceChildren(),this.e.coach.classList.remove("pressing")}kbDraft=null;markKey(e){if(e.target!==this.e.mark)return;let t=globalThis.innerWidth||800,n=globalThis.innerHeight||600;if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),!this.kbDraft){this.kbDraft={x:Math.round(t/2-Dn.w/2),y:Math.round(n/2-Dn.h/2),...Dn},this.renderKbDraft();return}let a=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,a,this.tool==="arrow"?"se":void 0);return}let r=Wa[e.key];if(!r||!this.kbDraft)return;e.preventDefault();let o=this.kbDraft,[i,s]=r;this.kbDraft=e.shiftKey?{...o,w:Math.min(t-o.x,Math.max(Ti,o.w+i)),h:Math.min(n-o.y,Math.max(Ti,o.h+s))}:{...o,x:Math.min(t-o.w,Math.max(0,o.x+i)),y:Math.min(n-o.h,Math.max(0,o.y+s))},this.renderKbDraft()}renderKbDraft(){let e=this.kbDraft;if(!e)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:this.tool,rect:e,head:"se"}))}placeCoach(e,t){let n=globalThis.innerWidth||800,r=globalThis.innerHeight||600,o=this.e.coach.offsetWidth||300,i=this.e.coach.offsetHeight||140,s=t?e.x+20:e.x,a=t?e.y+20:e.y;if(s+o>n-8)s=t?e.x-o-20:n-o-8;if(a+i>r-90)a=t?e.y-i-20:r-i-90;this.e.coach.style.left=`${Math.max(8,s)}px`,this.e.coach.style.top=`${Math.max(8,a)}px`}shapeNodes(e){let{x:t,y:n,w:r,h:o}=e.rect;if(e.shape==="circle")return[_("ellipse",{class:"stroke",cx:t+r/2,cy:n+o/2,rx:Math.max(1,r/2),ry:Math.max(1,o/2)})];if(e.shape==="box")return[_("rect",{class:"stroke",x:t,y:n,width:r,height:o,rx:6})];if(e.shape==="arrow"){let{tail:a,tip:l}=Mn(e.rect,e.head??"se");return[_("line",{class:"stroke",x1:a.x,y1:a.y,x2:l.x,y2:l.y,"marker-end":"url(#vr-head)"})]}let i=_("rect",{class:"veil",x:t,y:n,width:r,height:o,rx:4}),s=_("text",{class:"veil-label",x:t+r/2,y:n+o/2+4,"text-anchor":"middle"});return s.textContent=r>60&&o>20?this.s.hidden:"",[i,s]}renderMarks(){this.e.shapes.replaceChildren(...this.markers.flatMap((t)=>this.shapeNodes(t)));let e=new Set(this.markers.map((t)=>t.key));for(let[t,n]of this.pins){if(e.has(t))continue;n.el.remove(),this.pins.delete(t)}for(let t of this.markers){if(this.pins.has(t.key))continue;let n=u("button",{class:"num",type:"button"}),r=u("input",{class:"note",type:"text",maxlength:"500"}),o=u("button",{class:"rm",type:"button"},Q(le.close)),i=u("div",{class:"pin"},n,r,o);n.addEventListener("click",()=>{this.noteOpen=t.key,this.renderPins(),r.focus()}),r.addEventListener("input",()=>{this.markers=this.markers.map((s)=>s.key===t.key?{...s,note:r.value}:s)}),r.addEventListener("focus",()=>{this.noteOpen=t.key,this.renderPins()}),r.addEventListener("keydown",(s)=>{if(s.key!=="Enter")return;s.preventDefault(),this.e.mark.focus()}),o.addEventListener("click",()=>{this.markers=Nn(this.markers.filter((s)=>s.key!==t.key)),this.renderMarks(),this.paint()}),this.e.pins.append(i),this.pins.set(t.key,{el:i,num:n,note:r,rm:o})}this.renderPins()}renderPins(){let e=globalThis.innerWidth||800;for(let t of this.markers){let n=this.pins.get(t.key);if(!n)continue;let r=t.shape==="arrow"?Mn(t.rect,t.head??"se").tail:{x:t.rect.x,y:t.rect.y},o=this.noteOpen===t.key||t.note.trim()!=="",i=o?290:30;n.el.style.left=`${Math.min(Math.max(4,r.x-12),e-i)}px`,n.el.style.top=`${Math.max(4,r.y-12)}px`,n.num.textContent=String(t.n),n.num.setAttribute("aria-label",this.s.mark(t.n)),n.note.hidden=!o,n.rm.hidden=!o,n.note.placeholder=this.s.notePlaceholder,n.note.setAttribute("aria-label",`${this.s.mark(t.n)} — ${this.s.notePlaceholder}`),n.rm.setAttribute("aria-label",this.s.removeMark(t.n))}}envelope(e,t){let n=this.who(),r=globalThis.location;return{title:ja(e),description:e,env:{url:te(r?`${r.origin}${r.pathname}`:""),ua:globalThis.navigator?.userAgent??"",viewport:{w:globalThis.innerWidth||0,h:globalThis.innerHeight||0,dpr:globalThis.devicePixelRatio||1},appVersion:this.opts.appVersion??"",locale:globalThis.navigator?.language??""},console:t.console,network:t.network,...n?{identity:n,notify:this.notify}:{},markers:ni(this.markers),locale:this.locale}}async send(){let e=this.e.desc.value.trim();if(this.sending||!e)return;if(this.sending=!0,this.error="",this.paint(),this.job&&!this.job.id)this.job=null;try{if(!this.job){let t=new Set;for(let r of this.markers)for(let o of this.hideIds.get(r.key)??[])t.add(o);let n=this.engine?await this.engine.build(this.frozen??{clip:null,stored:Promise.resolve(new Map)},this.markers,t).catch((r)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",r),Ri)):Ri;this.job=new Ln(n,globalThis.location?.host??"",{url:this.opts.base,key:this.opts.key})}this.result=await this.job.run(this.envelope(e,this.job.capture)),this.sentNotify=this.notify&&this.who()!==null,this.view="sent",this.job=null,this.frozen=null,this.e.desc.value="",this.markers=[],this.hideIds.clear(),this.notify=!1,this.e.notifyBox.checked=!1,this.includedOpen=!1,this.renderMarks(),this.engine?.clear()}catch(t){console.warn("vitrinka: the report did not go through — Retry resumes it",t),this.error=this.job?.id?"capture":"create"}finally{this.sending=!1,this.paint()}if(this.view==="sent")requestAnimationFrame(()=>((this.result?.reportUrl)?this.e.see:this.e.sentClose).focus())}includedItems(){let e=this.s,t=[],n=this.config?.lanes;if(n?.replay)t.push(`${e.incReplay} — ${e.incReplayMasked[this.config?.masking??"strict"].toLowerCase()}`);if(n?.errors)t.push(e.incErrors);if(n?.console)t.push(e.incConsole);if(n?.network)t.push(e.incNetwork);else if(n?.errors)t.push(e.incFailedRequests);if(t.push(e.incEnv),this.who())t.push(e.incIdentity);if(this.markers.length)t.push(e.incMarks);return t}paint(){let{e,s:t}=this,n=this.who();e.root.setAttribute("lang",this.locale),e.root.classList.toggle("nobutton",!this.button),e.fab.hidden=!this.button||this.marking,e.fabLabel.textContent=t.button,e.fab.setAttribute("aria-expanded",String(this.isOpen)),e.fabKbd.hidden=!this.keybind,e.fabKbd.textContent=this.keybind?Tt(this.keybind):"",e.card.hidden=!this.isOpen||this.marking,e.title.textContent=t.title,e.gear.setAttribute("aria-label",t.settings),e.gear.setAttribute("aria-pressed",String(this.view==="settings")),e.closeBtn.setAttribute("aria-label",t.close),e.describe.hidden=this.view!=="describe",e.settings.hidden=this.view!=="settings",e.sent.hidden=this.view!=="sent",e.prompt.textContent=t.prompt,e.desc.placeholder=t.placeholder,e.attachedText.textContent=t.attached(this.config?.profile.windowSec??60),e.attached.hidden=this.engine===null||this.config?.capturing===!1,e.discloseText.textContent=t.included,e.disclose.setAttribute("aria-expanded",String(this.includedOpen)),e.included.hidden=!this.includedOpen,e.included.replaceChildren(...this.includedItems().map((o)=>u("li",{},o))),e.marked.hidden=this.markers.length===0,e.markedChips.replaceChildren(...this.markers.map((o)=>u("span",{class:o.shape==="hide"?"chip hide":"chip","aria-hidden":"true"},String(o.n)))),e.markedText.textContent=t.marked(this.markers.length),e.notify.hidden=n===null,e.notifyText.textContent=t.notify,e.error.hidden=this.error==="",e.error.textContent=this.error==="create"?t.errorCreate:this.error==="capture"?t.errorCapture:"",e.whereText.textContent=t.showWhere,e.where.disabled=this.sending||Boolean(this.job?.id),e.send.textContent=this.sending?t.sending:this.error?t.retry:t.send,e.send.disabled=this.sending||e.desc.value.trim()==="",e.bindLabel.textContent=t.shortcut,e.bindBtn.setAttribute("aria-pressed",String(this.recordingBind)),e.bindBtn.setAttribute("aria-label",`${t.shortcut}: ${this.keybind?Tt(this.keybind):t.notSet} — ${t.recordShortcut}`),e.bindBtn.textContent=this.recordingBind?t.pressKeys:this.keybind?Tt(this.keybind):t.notSet,e.unbind.textContent=t.removeShortcut,e.unbind.hidden=!this.keybind||this.recordingBind,e.bindHint.textContent=t.shortcutHint,e.bindReason.hidden=!this.bindRefused,e.bindReason.textContent=this.bindRefused?t.needModifier:"",e.back.textContent=t.back,e.sentTitle.textContent=t.sentTitle,e.sentBody.textContent=this.sentNotify?t.sentNotify:t.sentBody,e.seeText.textContent=t.seeReport;let r=this.result?.reportUrl;if(e.see.hidden=!r,r)e.see.setAttribute("href",r);else e.see.removeAttribute("href");e.sentClose.textContent=t.close,e.mark.hidden=!this.marking,e.toolbar.setAttribute("aria-label",t.toolbar);for(let[o,i]of e.toolButtons)i.textContent=t.tools[o],i.setAttribute("aria-pressed",String(this.tool===o));if(e.undo.textContent=t.undo,e.undo.disabled=this.markers.length===0,e.done.textContent=t.done,e.coach.hidden=!this.marking||this.markers.length>0,e.coachText.textContent=t.coach,e.coachMore.textContent=t.coachMore,e.coachKeys.textContent=t.keyboardHint,e.mark.setAttribute("aria-label",t.marking),this.marking){for(let o of e.shapes.querySelectorAll(".veil-label"))if(o.textContent)o.textContent=t.hidden;this.renderPins()}}}function Nn(e){return ti(e).map((t,n)=>({...t,key:e[n].key}))}var Mt="vitrinka-report",Ya=["key","base","open-selector","locale","button"];function Ii(e){return e.trim().replace(/\/+$/,"")}function Bn(e){if(typeof customElements>"u"||customElements.get(Mt))return;class t extends HTMLElement{static get observedAttributes(){return Ya}options={};widget=null;pendingIdentity=void 0;connectedCallback(){this.hidden=!0,this.mountWidget()}disconnectedCallback(){this.widget?.unmount(),this.widget=null}attributeChangedCallback(n,r,o){if(r===o)return;if(!this.widget){if(this.isConnected&&(n==="key"||n==="base"))this.mountWidget();return}if(n==="locale")this.widget.setLocale(o);else if(n==="button")this.widget.setButton(o!=="false");else if(n==="open-selector")this.widget.setOpenSelector(o);else this.widget.unmount(),this.widget=null,this.mountWidget()}open(){this.widget?.open()}close(){this.widget?.close()}identify(n){this.pendingIdentity=n,this.widget?.identify(n)}setLocale(n){this.setAttribute("locale",String(n))}mountWidget(){if(this.widget)return;let n=(this.getAttribute("key")??"").trim(),r=Ii(this.getAttribute("base")??e.defaultBase());if(!n||!r){console.warn(`vitrinka: <${Mt}> needs a key${r?"":" and a base"} — nothing mounted`);return}this.widget=new On({base:r,key:n,locale:Ce(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,appVersion:this.options.appVersion,capture:this.options.capture,sanitizeUrl:this.options.sanitizeUrl,loadRecord:e.loadRecord})}}customElements.define(Mt,t)}function Ai(e,t){if(e.face==="recorder")return Xa(e,t);Bn(t);let n=document.createElement(Mt);if(n.setAttribute("key",e.key),e.base)n.setAttribute("base",e.base);if(e.locale)n.setAttribute("locale",String(e.locale));if(e.button===!1)n.setAttribute("button","false");if(e.openSelector)n.setAttribute("open-selector",e.openSelector);if(n.options={appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl},e.identity!==void 0)n.identify(e.identity);return(e.parent??document.body).append(n),{face:"report",open:()=>n.open(),close:()=>n.close(),identify:(r)=>n.identify(r),setLocale:(r)=>n.setLocale(r),unmount:()=>n.remove()}}function Xa(e,t){let n=Ii(e.base??t.defaultBase()),r=null,o=!1;if(!t.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else t.recorderFace().then((s)=>{if(!o)r=s({base:n,key:e.key,appVersion:e.appVersion,sanitizeUrl:e.sanitizeUrl})}).catch((s)=>console.warn("vitrinka: the recorder face did not load",s));let i=()=>{return};return{face:"recorder",open:i,close:i,identify:i,setLocale:i,unmount:()=>{o=!0,r?.()}}}var Ga=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function Ja(e){let n=await import(`${e}/vendor/rrweb-record-1.min.js`)??{},r=typeof n.default==="object"&&n.default!==null?n.default.record:void 0,o=typeof n.default==="function"?n.default:r??n.record;return typeof o==="function"?o:null}var Pi={loadRecord:Ja,recorderFace:null,defaultBase:()=>Ga};Bn(Pi);function Nc(e){return Ai(e,Pi)}export{Oa as identify,Nc as mountReport};
392
+ `;class cr{capture;tabHost;target;files;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(e,t,n,r=[]){this.capture=e;this.tabHost=t;this.target=n;this.files=r}get filesPending(){return this.filesDone.size<this.files.length}async run(e){let t={target:this.target},n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let i=await L("POST","/api/v1/reports",e,t).catch((s)=>{if(e.type===void 0||!(s instanceof S)||s.status!==400||!/\btype\b/.test(s.message))throw s;console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:a,...l}=e;return L("POST","/api/v1/reports",l,t)});if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r}else if(this.sent!==r)await L("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n,t),this.sent=r;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof S)||!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 L("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{},t);return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async sendFiles(){let e=encodeURIComponent(this.id);for(let[t,n]of this.files.entries()){if(this.filesDone.has(t))continue;try{await dt(`/api/v1/reports/${e}/attachment?name=${encodeURIComponent(n.name)}`,n.type||"application/octet-stream",n,this.target)}catch(r){if(!(r instanceof S)||!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 dt(`/api/v1/reports/${e}/chunk?seq=${o.seq}`,"application/json",o.body,this.target);if(!i.blobKey)throw Error(`vitrinka: chunk ${o.seq} came back without a blob key`);this.blobKeys.set(o.seq,i.blobKey)}let r=t.map((o)=>({seq:o.seq,ts:o.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:o.count,source:"replay",truncated:n},blobKey:this.blobKeys.get(o.seq)??""}));while(this.rowsPosted<r.length){let o=r.slice(this.rowsPosted,this.rowsPosted+Pt);await L("POST",`/api/v1/reports/${e}/events`,{events:o},{target:this.target}),this.rowsPosted+=o.length}}}var zd="http://www.w3.org/2000/svg",Ja=100,Za={chunks:[],truncated:!1,console:[],network:[]},$d=["circle","box","arrow","hide"],dr={w:160,h:80},Qa=16,el={w:380,h:460},jt=72,ur=16,Kd={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},x={close:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',gear:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.9 1.5h2.2l.35 1.75a5 5 0 011.3.75l1.7-.57 1.1 1.9-1.35 1.18a5 5 0 010 1.5l1.35 1.18-1.1 1.9-1.7-.57a5 5 0 01-1.3.75L9.1 14.5H6.9l-.35-1.75a5 5 0 01-1.3-.75l-1.7.57-1.1-1.9 1.35-1.18a5 5 0 010-1.5L2.45 6.81l1.1-1.9 1.7.57a5 5 0 011.3-.75z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="8" r="2" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>',circle:'<svg viewBox="0 0 16 16" aria-hidden="true"><ellipse cx="8" cy="8" rx="6" ry="4.6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',box:'<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.2" y="3.4" width="11.6" height="9.2" rx="1.8" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',arrow:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 13L12.5 3.5M7 3.5h5.5V9" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',hide:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8s2.3-4 6-4 6 4 6 4-2.3 4-6 4-6-4-6-4z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M3 13L13 3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',dots:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="3.5" cy="8" r="1.3" fill="currentColor"/><circle cx="8" cy="8" r="1.3" fill="currentColor"/><circle cx="12.5" cy="8" r="1.3" fill="currentColor"/></svg>',left:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5L5.5 8l4.5 4.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',ext:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9 3h4v4M13 3L7.5 8.5M11 9.5V13H3V5h3.5" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>',list:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 4h8M5.5 8h8M5.5 12h8M2.5 4h.01M2.5 8h.01M2.5 12h.01" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',clock:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 4.8V8l2.2 1.6" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',rec:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><circle cx="8" cy="8" r="2.8" fill="currentColor"/></svg>',link:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M7 9a3 3 0 004.2 0l2-2a3 3 0 00-4.2-4.2l-.8.8M9 7a3 3 0 00-4.2 0l-2 2a3 3 0 004.2 4.2l.8-.8" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',clip:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.5 4.5l-5 5a1.6 1.6 0 002.3 2.3l5.4-5.4a3 3 0 00-4.2-4.2L3.6 7.6a4.4 4.4 0 006.2 6.2l4-4" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',chevron:'<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',pen:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.8 2.7l2.5 2.5-7.6 7.6-3.1 0.6 0.6-3.1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>',check:'<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M7.5 12.3l3 3 6-6.3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>'},tl="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14";function qd(e){let t=e?"":`<animateMotion dur="2.8s" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="0;0.18;0.72;1" calcMode="linear" path="${tl}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true"><rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${tl}" pathLength="200"/><g class="pointer"${e?' transform="translate(134 14)"':""}><circle class="hold" r="9"/><path d="M0 0 L0 15 L4 11 L7 18 L10 16.6 L7 10 L12.5 10 Z" fill="#fff" stroke="#151417" stroke-width="1"/>${t}</g></svg>`}function c(e,t={},...n){let r=document.createElement(e);for(let[o,i]of Object.entries(t))r.setAttribute(o,i);return r.append(...n),r}function R(e){let t=document.createElement("template");t.innerHTML=e;let n=t.content.firstElementChild;if(!n)throw Error("vitrinka: icon markup is empty");return n}function F(e,t){let n=document.createElementNS(zd,e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function nl(e){let t=e.split(`
393
+ `)[0]?.trim()??"";return t.length>Ja?`${t.slice(0,Ja-1)}…`:t}function ol(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function pr(){let e=document.activeElement;while(e?.shadowRoot?.activeElement)e=e.shadowRoot.activeElement;if(e===document.body)return null;return e instanceof HTMLElement||e instanceof SVGElement?e:null}function Wd(e){return(e.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((n)=>n[0]?.toUpperCase()??"").join("")||"?"}function z(e,t){let n=e.querySelector("span");if(n)n.textContent=t}function rl(e,t,n){if(!n||!n.offsetWidth)return;t.style.width=`${n.offsetWidth}px`,t.style.transform=`translateX(${n.offsetLeft}px)`,e.classList.add("measured")}function jd(){let e=pr();return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Ud(e){let t=c("span"),n=c("kbd"),r=c("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},t,n),o=c("h2",{id:"vr-title"}),i=c("span",{class:"av","aria-hidden":"true"}),s=c("span",{class:"who-name"}),a=c("button",{class:"who",type:"button","aria-haspopup":"dialog","aria-expanded":"false"},i,s),l=c("button",{class:"icon",type:"button","aria-haspopup":"menu","aria-expanded":"false"},R(x.dots)),d=c("button",{class:"icon",type:"button"},R(x.close)),f=c("header",{class:"head"},o,a,l,d),g=c("strong"),u=c("span",{class:"acc-mail"}),p=c("p",{class:"acc-via"}),m=c("p",{class:"acc-linked"}),y=c("button",{class:"link",type:"button"}),b=c("button",{class:"pop-item",type:"button"},R(x.link),c("span")),k=c("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},R(x.ext),c("span")),h=c("div",{class:"pop acc",role:"dialog"},c("div",{class:"acc-who"},g,u,p),c("div",{class:"acc-member"},m,y),b,k),E=(P)=>c("button",{class:"pop-item",type:"button",role:"menuitem"},R(P),c("span")),K=E(x.list),De=E(x.clock),ot=E(x.rec),it=E(x.gear),Be=c("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},R(x.ext),c("span")),gr=c("div",{class:"pop more",role:"menu"},K,De,ot,it,Be),mr=c("span",{class:"sr",id:"vr-kinds"}),Yt=new Map;for(let P of wi)Yt.set(P,c("button",{type:"button",role:"radio","aria-checked":"false","data-kind":P}));let br=c("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},mr,...Yt.values()),yr=c("label",{class:"prompt",for:"vr-desc"}),kr=c("textarea",{class:"desc",id:"vr-desc",rows:"3"}),vr=c("ol",{class:"lines"}),wr=c("p",{class:"ln-empty"}),xr=c("span"),Sr=c("span"),Rr=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},Sr,R(x.chevron)),Er=c("div",{class:"attached"},R(x.clip),xr,c("span",{"aria-hidden":"true"},"·"),Rr),Tr=c("ul",{class:"included",id:"vr-included"}),Cr=c("input",{type:"checkbox"}),Mr=c("span"),Ar=c("label",{class:"notify"},Cr,Mr),Pr=c("p",{class:"error",role:"alert"}),Lr=c("span"),Ir=c("button",{class:"where",type:"button","aria-pressed":"false"},R(x.pen),Lr),Dr=c("button",{class:"send",type:"button"}),Br=c("div",{class:"pane describe"},br,yr,kr,c("div",{class:"lines-wrap"},vr,wr),Er,Tr,Ar,Pr),_r=c("button",{class:"icon",type:"button"},R(x.clip)),Or=c("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),Nr=c("p",{class:"file-note",role:"status"}),Fr=c("ul",{class:"files"}),Hr=c("div",{class:"tray"},Nr,Fr),zr=c("div",{class:"foot"},_r,Or,Ir,Dr),$r=c("span",{class:"label",id:"vr-bind-label"}),Kr=c("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),qr=c("button",{class:"link",type:"button"}),Wr=c("p",{class:"hint"}),jr=c("p",{class:"reason",role:"status"}),Ur=c("button",{class:"link",type:"button"}),Vr=c("span",{class:"label",id:"vr-size-label"}),Xt=new Map;for(let P of kn)Xt.set(P,c("button",{type:"button",role:"radio","aria-checked":"false","data-size":P}));let Yr=c("span",{class:"seg-ind","aria-hidden":"true"}),Xr=c("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},Yr,...Xt.values()),Gr=c("span"),Jr=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},Gr,R(x.chevron)),Zr=c("dl",{class:"tech",id:"vr-tech"}),Qr=c("div",{class:"pane settings"},c("div",{class:"row"},$r,Kr),jr,Wr,c("div",{class:"row size-row"},Vr,Xr),c("div",{class:"tech-wrap"},Jr,Zr),c("div",{class:"settings-foot"},Ur,qr)),eo=c("h3"),to=c("p",{class:"sent-body"}),no=c("span"),ro=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},no),oo=c("button",{class:"link",type:"button"}),io=c("div",{class:"pane sent",role:"status"},c("div",{class:"sent-head"},R(x.check),eo),to,c("div",{class:"sent-actions"},ro,oo)),Gt=()=>c("button",{class:"back",type:"button"},R(x.left),c("span")),so=Gt(),ao=c("p",{class:"list-status"}),lo=c("ul",{class:"rows"}),co=c("p",{class:"list-note"}),uo=c("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),po=c("div",{class:"pane list"},so,ao,lo,co,uo),fo=Gt(),ho=c("p",{class:"list-status"}),go=c("ul",{class:"rows"}),mo=c("div",{class:"pane list"},fo,ho,go),bo=Gt(),yo=c("p",{class:"list-note"}),ko=c("div",{class:"code"}),vo=c("span"),wo=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},vo),xo=c("img",{class:"qr",alt:""}),So=c("p",{class:"hint"}),Ro=c("p",{class:"list-status",role:"status"}),Eo=c("button",{class:"link",type:"button"}),To=c("div",{class:"pane linking"},bo,yo,ko,c("div",{class:"link-go"},wo,xo),So,Ro,Eo),Co=c("div",{class:"body"},Br,Qr,io,po,mo,To),Mo=c("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},f,h,gr,Co,Hr,zr),Jt=F("svg",{class:"ink","aria-hidden":"true"}),Ao=F("defs",{}),Po=F("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});Po.append(F("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),Ao.append(Po);let Lo=F("g",{}),Io=F("g",{class:"draft"});Jt.append(Ao,Lo,Io);let Do=c("div",{class:"pins"}),Bo=c("p"),_o=c("p"),Oo=c("p",{class:"keys",id:"vr-keys"}),Zt=c("div",{class:"coach",role:"status"});Zt.append(R(qd(ol())),Bo,_o,Oo);let Qt=new Map,No=new Map;for(let P of $d){let Yo=c("span");No.set(P,Yo),Qt.set(P,c("button",{type:"button",role:"radio","aria-checked":"false","data-tool":P},R(x[P]),Yo))}let Fo=c("span",{class:"seg-ind","aria-hidden":"true"}),Ho=c("div",{class:"seg",role:"radiogroup"},Fo,...Qt.values()),zo=c("span",{class:"tb-lead"}),$o=c("button",{type:"button",class:"tb-quiet"}),Ko=c("span",{class:"tb-ask"}),qo=c("button",{type:"button",class:"tb-discard"}),Wo=c("button",{type:"button",class:"tb-quiet"}),jo=c("span",{class:"tb-confirm",role:"group"},Ko,qo,Wo),Uo=c("div",{class:"tb",role:"toolbar"},zo,Ho,c("span",{class:"tb-sep","aria-hidden":"true"}),$o,jo),en=c("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},Do,Zt,Uo);en.prepend(Jt);let tn=c("div",{class:"vr"},r,en,Mo),Vo=c("style");return Vo.textContent=Ga,tn.prepend(Vo),e.append(tn),{root:tn,fab:r,fabLabel:t,fabKbd:n,card:Mo,head:f,title:o,whoBtn:a,whoAv:i,whoName:s,more:l,closeBtn:d,body:Co,foot:zr,accountPop:h,accName:g,accMail:u,accVia:p,accLinked:m,accUnlink:y,accLink:b,accPortal:k,morePop:gr,mReports:K,mRecents:De,mRecord:ot,mSettings:it,mOpen:Be,reports:po,repBack:so,repStatus:ao,repRows:lo,repLocal:co,repPortal:uo,recents:mo,recBack:fo,recStatus:ho,recRows:go,linking:To,linkBack:bo,linkLabel:yo,linkCode:ko,linkOpen:wo,linkOpenText:vo,linkQr:xo,linkHint:So,linkWait:Ro,linkRetry:Eo,describe:Br,kinds:br,kindsLabel:mr,kindButtons:Yt,prompt:yr,desc:kr,lines:vr,linesEmpty:wr,attached:Er,attachedText:xr,disclose:Rr,discloseText:Sr,included:Tr,notify:Ar,notifyBox:Cr,notifyText:Mr,error:Pr,where:Ir,whereText:Lr,send:Dr,attach:_r,fileInput:Or,fileNote:Nr,files:Fr,tray:Hr,settings:Qr,bindLabel:$r,bindBtn:Kr,unbind:qr,bindHint:Wr,bindReason:jr,back:Ur,sizeLabel:Vr,sizeButtons:Xt,sizeInd:Yr,sizeSeg:Xr,techText:Gr,techBtn:Jr,tech:Zr,sent:io,sentTitle:eo,sentBody:to,see:ro,seeText:no,sentClose:oo,mark:en,ink:Jt,shapes:Lo,draft:Io,pins:Do,coach:Zt,coachText:Bo,coachMore:_o,coachKeys:Oo,toolbar:Uo,barLead:zo,seg:Ho,segInd:Fo,toolButtons:Qt,toolLabels:No,cancel:$o,ask:jo,askText:Ko,discard:qo,keep:Wo}}class fr{opts;hud;engine;config=null;locale;s;button;openSelector;identity;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool="circle";frozen=null;job=null;sending=!1;error="";result=null;notify=!1;sentNotify=!1;includedOpen=!1;recordingBind=!1;bindRefused=!1;kind=null;passKeys=new Set;confirming=!1;parked=null;parkInsets=null;dock=hs();size=ds();techOpen=!1;fabDrag=null;swallowClick=!1;glide=null;files=[];fileRefusal=null;pastes=0;chips=new Map;recordSwitch=null;menu=null;session=null;sessionToken="";member=null;mine={rows:[],state:"ok"};linkFlow=null;drawing=null;offs=[];pins=new Map;lines=new Map;hideIds=new Map;dialogOrder=[...document.querySelectorAll("dialog[open]")].filter((e)=>e instanceof HTMLDialogElement);activeDialog(){this.dialogOrder=this.dialogOrder.filter((n)=>n.isConnected&&n.open);let e=(n)=>{try{return n.matches(":modal")}catch{return!1}};return[...this.dialogOrder].reverse().find(e)??this.dialogOrder.at(-1)??ts()}sheet=null;e;constructor(e){this.opts=e;this.locale=e.locale??cn(),this.s=ln(this.locale),this.button=e.button,this.openSelector=e.openSelector??null,this.identity=e.identity===void 0?void 0:Kt(e.identity),this.keybind=za(),this.hud=Qi(),this.e=Ud(this.hud.mount),this.engine=Ia({base:e.base,key:e.key,appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl,loadRecord:e.loadRecord}),this.engine?.ready.then((t)=>{this.config=t,this.paint()}),this.bind(),this.paint(),this.followDialog()}followDialog(){let e=this.activeDialog();if((this.sheet?.target??null)===e)return;let t=this.e.root.getRootNode(),n=t instanceof ShadowRoot&&t.activeElement instanceof HTMLElement?t.activeElement:null,r=this.sheet;if(e){let o=ns(e);o.mount.append(this.e.root),this.sheet={target:e,host:o}}else this.hud.mount.append(this.e.root),this.sheet=null;r?.host.destroy(),n?.focus()}open(){if(this.isOpen)return;if(this.isOpen=!0,this.opener=rs(document.activeElement)?null:pr(),this.view!=="describe")this.view="describe";if(this.result=null,!this.job)this.frozen=this.engine?.freeze()??null;this.paint(),requestAnimationFrame(()=>this.e.desc.focus()),this.refreshWho(),this.refreshMember()}close(){if(!this.isOpen)return;if(this.marking)this.endMarking(!1);this.stopRecordingBind(),this.isOpen=!1,this.view="describe",this.unpark(),this.paint();let e=this.opener;if(this.opener=null,e?.focus(),e&&pr()===e)return;if(this.button)this.e.fab.focus()}setLocale(e){let t=Ke(e)??cn();if(t===this.locale)return;this.locale=t,this.s=ln(t),this.paint()}setButton(e){this.button=e,this.paint()}setOpenSelector(e){this.openSelector=e||null}setRecordSwitch(e){this.recordSwitch=e,this.paint()}identify(e){this.identity=e===void 0?void 0:Kt(e),this.whoChanged()}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let e of this.offs.splice(0).reverse())e();Da(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let e=this.e,t=(i,s,a)=>{i.addEventListener(s,a)};t(e.fab,"click",()=>{if(this.swallowClick){this.swallowClick=!1;return}if(this.isOpen)this.close();else this.open()}),t(e.fab,"pointerdown",(i)=>this.fabDown(i)),t(e.fab,"pointermove",(i)=>this.fabMove(i)),t(e.fab,"pointerup",(i)=>this.fabUp(i,!0)),t(e.fab,"pointercancel",(i)=>this.fabUp(i,!1)),t(e.fab,"keydown",(i)=>{if(!i.altKey||i.ctrlKey||i.metaKey||i.shiftKey)return;let s=bs(this.dock,i.key);if(!s)return;if(i.preventDefault(),s!==this.dock)this.moveDock(s)}),t(e.attach,"click",()=>e.fileInput.click()),t(e.fileInput,"change",()=>{this.addFiles([...e.fileInput.files??[]]),e.fileInput.value=""}),t(e.card,"paste",(i)=>{let s=[...i.clipboardData?.files??[]];if(!s.length||!this.canAttach())return;let a=i.clipboardData?.getData("text/plain").trim()??"";if(a&&!s.some((l)=>l.name&&a.includes(l.name)))return;i.preventDefault(),this.addFiles(s.map((l)=>{let d=ls(l.name,++this.pastes);return d===l.name?l:new File([l],d,{type:l.type,lastModified:l.lastModified})}))}),t(e.card,"dragover",(i)=>{if(!i.dataTransfer?.types.includes("Files")||!this.canAttach())return;i.preventDefault(),i.dataTransfer.dropEffect="copy",e.card.classList.add("dropping")}),t(e.card,"dragleave",(i)=>{if(i.relatedTarget instanceof Node&&e.card.contains(i.relatedTarget))return;e.card.classList.remove("dropping")}),t(e.card,"drop",(i)=>{e.card.classList.remove("dropping");let s=[...i.dataTransfer?.files??[]];if(!s.length||!this.canAttach())return;i.preventDefault(),this.addFiles(s)});for(let[i,s]of e.sizeButtons)t(s,"click",()=>{if(this.size=i,bt(vn,i),this.paint(),this.parked)this.placeCard()});t(e.techBtn,"click",()=>{this.techOpen=!this.techOpen,this.paint()}),t(e.closeBtn,"click",()=>this.close()),t(e.whoBtn,"click",()=>this.toggleMenu("account")),t(e.more,"click",()=>this.toggleMenu("more"));let n=(i)=>()=>{this.menu=null,i(),this.paint()};t(e.morePop,"keydown",(i)=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(i.key))return;let s=[...e.morePop.querySelectorAll('[role="menuitem"]')].filter((u)=>!u.hidden&&!(u instanceof HTMLButtonElement&&u.disabled));if(!s.length)return;i.preventDefault();let a=e.morePop.getRootNode(),l=s.indexOf(a.activeElement),d=s.length-1,f=i.key==="ArrowDown",g=i.key==="Home"?0:i.key==="End"?d:l<0?f?0:d:(l+(f?1:-1)+s.length)%s.length;s[g]?.focus()}),t(e.mReports,"click",n(()=>void this.openReports())),t(e.mRecents,"click",n(()=>this.show("recents"))),t(e.mRecord,"click",n(()=>this.recordSwitch?.())),t(e.mSettings,"click",n(()=>this.show("settings"))),t(e.mOpen,"click",n(()=>{return})),t(e.accPortal,"click",n(()=>{return})),t(e.accLink,"click",n(()=>this.startLinkFlow())),t(e.accUnlink,"click",()=>{ui(),this.member=null,this.paint()});for(let i of[e.repBack,e.recBack,e.linkBack])t(i,"click",()=>this.show("describe"));t(e.linkRetry,"click",()=>this.startLinkFlow()),t(e.card,"pointerdown",(i)=>{let s=i.target;if(!this.menu||!(s instanceof Node))return;if([e.accountPop,e.morePop,e.whoBtn,e.more].some((a)=>a.contains(s)))return;this.menu=null,this.paint()}),t(e.back,"click",()=>this.show("describe")),t(e.sentClose,"click",()=>this.close()),t(e.desc,"input",()=>this.paint()),t(e.disclose,"click",()=>{this.includedOpen=!this.includedOpen,this.paint()}),t(e.notifyBox,"change",()=>{this.notify=e.notifyBox.checked}),t(e.where,"click",()=>this.marking?this.endMarking(!0):this.startMarking()),t(e.send,"click",()=>void this.send()),t(e.bindBtn,"click",()=>this.recordingBind?this.stopRecordingBind():this.startRecordingBind()),t(e.unbind,"click",()=>{this.keybind=null,ir(null),this.paint()});for(let[i,s]of e.kindButtons)t(s,"click",()=>{this.kind=this.kind===i?null:i,this.paint()});t(e.card,"keydown",(i)=>{if(i.key!=="Escape"||this.recordingBind||i.defaultPrevented)return;if(i.preventDefault(),this.menu){let s=this.menu==="account"?e.whoBtn:e.more;this.menu=null,this.paint(),s.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close()});for(let[i,s]of e.toolButtons)t(s,"click",(a)=>{if(this.tool=i,this.renderKbDraft(),this.paint(),this.placeSeg(),a.detail===0)e.mark.focus()});if(t(e.mark,"keydown",(i)=>this.markKey(i)),t(e.cancel,"click",()=>this.cancelMarking()),t(e.discard,"click",()=>{this.markers=Ut(this.markers.filter((i)=>this.passKeys.has(i.key))),this.renderMarks(),this.endMarking(!0)}),t(e.keep,"click",()=>{this.confirming=!1,this.paint(),e.cancel.focus()}),t(e.mark,"pointerdown",(i)=>this.pointerDown(i)),t(e.mark,"pointermove",(i)=>this.pointerMove(i)),t(e.mark,"pointerup",(i)=>this.pointerUp(i)),t(e.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(I(e.mark,"wheel",(i)=>i.preventDefault())),this.offs.push(I(e.mark,"touchmove",(i)=>i.preventDefault())),this.offs.push(I(window,"keydown",(i)=>{if(this.recordingBind)return;if(this.marking&&i.key==="Escape"){if(i.preventDefault(),this.confirming)e.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);return}if(this.marking&&(i.metaKey||i.ctrlKey)&&!i.shiftKey&&!i.altKey&&i.key.toLowerCase()==="z"&&!jd()){i.preventDefault(),this.markers=Ut(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&Fa(i,this.keybind))if(i.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(I(document,"click",(i)=>{let s=this.openSelector,a=i.target;if(!s||!(a instanceof Element))return;let l=null;try{l=a.closest(s)}catch{return}if(!l)return;i.preventDefault(),this.open()})),this.offs.push(I(window,"resize",()=>{if(this.parked)this.placeCard();if(this.marking)this.placeSeg()})),this.offs.push($a((i)=>{this.keybind=i,this.paint()})),this.offs.push(Oa(()=>this.whoChanged())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let r=0,o=new MutationObserver((i)=>{for(let s of i){if(s.type!=="attributes"||s.attributeName!=="open"||!(s.target instanceof HTMLDialogElement))continue;let a=s.target;if(!a.open)this.dialogOrder=this.dialogOrder.filter((l)=>l!==a);else if(s.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((l)=>l!==a),a]}if(r)return;r=requestAnimationFrame(()=>{r=0,this.followDialog()})});o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(o.disconnect(),r)cancelAnimationFrame(r)})}show(e){if(this.stopRecordingBind(),e!=="link"&&this.linkFlow)this.linkFlow.abort.abort(),this.linkFlow=null;this.view=e,this.paint();let t={describe:this.e.desc,settings:this.e.bindBtn,sent:null,reports:this.e.repBack,recents:this.e.recBack,link:this.e.linkBack}[e];if(t)requestAnimationFrame(()=>t.focus())}target(){return{url:this.opts.base,key:this.opts.key}}toggleMenu(e){if(this.menu=this.menu===e?null:e,this.menu==="account")this.refreshWho(),this.refreshMember();this.paint(),(this.menu==="account"?this.e.accountPop:this.menu==="more"?this.e.morePop:null)?.querySelector("button:not([hidden]), a:not([hidden])")?.focus()}async refreshWho(){let e=this.who();if(!e||!("token"in e))return this.session=null,this.sessionToken="",null;if(this.sessionToken===e.token&&Ua(this.session))return this.session;this.sessionToken=e.token;let t=null;try{t=await ja(this.target(),e.token)}catch(n){console.warn("vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only",n)}if(this.sessionToken!==e.token)return null;return this.session=t,this.paint(),this.session}whoChanged(){if(this.whoToken()!==this.sessionToken){if(this.session=null,this.sessionToken="",this.mine={rows:[],state:"ok"},this.isOpen)this.view==="reports"?this.loadReports():this.refreshWho()}this.paint()}async refreshMember(){let e=$e(this.opts.base)?ze():null;if(!e){if(this.member)this.member=null,this.paint();return}try{let t=await L("GET","/api/v1/recorder/me",void 0,{target:{url:this.opts.base,key:e.token}});this.member={email:t.user?.email??"",name:t.user?.name??"",workspace:t.workspace?.slug??e.workspace},yi(t.displayMode)}catch(t){console.warn("vitrinka: the linked vitrinka account could not be read",t),this.member={email:"",name:"",workspace:e.workspace}}this.paint()}async openReports(){this.show("reports"),await this.loadReports()}async loadReports(){let e=this.whoToken(),t=await this.refreshWho();if(this.whoToken()!==e)return;if(!t){this.mine={rows:[],state:"ok"},this.paint();return}this.mine={rows:[],state:"loading"},this.paint();let n;try{n={rows:await this.listMineRenewing(t),state:"ok"}}catch(r){console.warn("vitrinka: My reports could not be loaded",r),n={rows:[],state:"failed"}}if(this.whoToken()!==e)return;this.mine=n,this.paint()}async listMineRenewing(e){try{return(await ar(this.target(),e.session)).reports}catch(t){if(!(t instanceof S)||t.status!==401)throw t;this.session=null,this.sessionToken="";let n=await this.refreshWho();if(!n)throw t;return(await ar(this.target(),n.session)).reports}}startLinkFlow(){this.linkFlow?.abort.abort();let e={start:null,state:"starting",abort:new AbortController};this.linkFlow=e,this.show("link");let t=this.opts.base,n=at(t);(async()=>{try{e.start=await ti(t,{label:fi(),workspace:n}),e.state="waiting",this.paint();let r=await ni(t,e.start.device_code,{interval:e.start.interval,expiresIn:e.start.expires_in,workspace:n,signal:e.abort.signal});di({...r,base:t}),this.linkFlow=null,this.show("describe"),await this.refreshMember()}catch(r){if(e.abort.signal.aborted)return;if(e.state=r instanceof _e?"expired":"failed",e.state==="failed")console.warn("vitrinka: linking the vitrinka account failed",r);this.paint()}})()}ago(e){let t=new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}),n=Math.round((e-Date.now())/1000),r=[[60,"second"],[60,"minute"],[24,"hour"],[30,"day"],[12,"month"],[1/0,"year"]],o=n;for(let[i,s]of r){if(Math.abs(o)<i)return t.format(o,s);o=Math.round(o/i)}return t.format(o,"year")}row(e,t,n,r){let o=[c("span",{class:"row-t"},e),c("span",{class:"step"},t),c("span",{class:"age"},this.ago(n))],i=r?c("a",{class:"row",href:r,target:"_blank",rel:"noopener noreferrer"},...o):c("div",{class:"row"},...o);return c("li",{},i)}who(){return this.identity!==void 0?this.identity:_a()}whoToken(){let e=this.who();return e&&"token"in e?e.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=I(window,"keydown",(e)=>{e.preventDefault(),e.stopPropagation();let t=Na(e);if(t.kind==="wait")return;if(t.kind==="bare"){this.bindRefused=!0,this.paint();return}if(t.kind==="bind")this.keybind=t.bind,ir(t.bind);this.stopRecordingBind()},{capture:!0}),this.paint()}stopRecordingBind(){if(!this.recordingBind)return;this.recordingBind=!1,this.bindRefused=!1,this.stopBindListener?.(),this.stopBindListener=null,this.paint()}canAttach(){return this.isOpen&&this.view==="describe"&&!this.sending&&!this.job?.id}caps(){return this.config?.attachments??J}addFiles(e){if(!e.length)return;let{files:t,refusal:n}=ss(this.files,e,this.caps());this.files=[...this.files,...t],this.fileRefusal=n,this.renderFiles(),this.paint()}removeFile(e){this.files=this.files.filter((t)=>t!==e),this.fileRefusal=null,this.renderFiles(),this.paint(),this.e.attach.focus()}renderFiles(){let e=new Set(this.files);for(let[t,n]of this.chips){if(e.has(t))continue;n.el.remove(),this.chips.delete(t)}for(let t of this.files){if(this.chips.has(t))continue;let n=c("span",{class:"file-size"}),r=c("button",{class:"ln-x",type:"button"},R(x.close)),o=c("li",{class:"file"},c("span",{class:"file-name"},t.name),n,r);r.addEventListener("click",()=>this.removeFile(t)),this.e.files.append(o),this.chips.set(t,{el:o,size:n,rm:r})}}refusalText(e){let t=this.s;if(!e)return"";if(e.kind==="size")return t.fileTooBig(e.name,je(e.cap,this.locale));if(e.kind==="count")return t.tooManyFiles(e.cap);return t.fileType(e.name,as(this.caps().types,t.typeNames,this.locale))}fabDown(e){if(this.swallowClick=!1,e.button!==0||!e.isPrimary)return;let t=this.e.fab.getBoundingClientRect();this.fabDrag={pointer:e.pointerId,start:{x:e.clientX,y:e.clientY},grab:{x:e.clientX-t.left,y:e.clientY-t.top},moved:!1};try{this.e.fab.setPointerCapture(e.pointerId)}catch{}}fabMove(e){let t=this.fabDrag;if(!t||e.pointerId!==t.pointer)return;if(!t.moved&&Math.hypot(e.clientX-t.start.x,e.clientY-t.start.y)<fs)return;t.moved=!0;let n=this.e.fab;n.classList.add("dragging");let r=n.getBoundingClientRect(),o=globalThis.innerWidth||800,i=globalThis.innerHeight||600,s=n.style;s.left=`${Math.min(Math.max(0,e.clientX-t.grab.x),o-r.width)}px`,s.top=`${Math.min(Math.max(0,e.clientY-t.grab.y),i-r.height)}px`,s.right="auto",s.bottom="auto"}fabUp(e,t){let n=this.fabDrag;if(!n||e.pointerId!==n.pointer)return;if(this.fabDrag=null,!n.moved)return;let r=this.e.fab,o=r.getBoundingClientRect();r.classList.remove("dragging");for(let a of["left","top","right","bottom"])r.style.removeProperty(a);this.swallowClick=!0,setTimeout(()=>{this.swallowClick=!1},0);let i=globalThis.innerWidth||800,s=globalThis.innerHeight||600;this.moveDock(t?ms({x:o.left+o.width/2,y:o.top+o.height/2},i,s):this.dock,o)}moveDock(e,t){let n=this.e.fab,r=t??n.getBoundingClientRect();if(this.dock=e,gs(e),this.paint(),n.hidden||ol())return;let o=n.getBoundingClientRect(),i=r.left-o.left,s=r.top-o.top;if(!i&&!s)return;this.glide?.abort();let a=new AbortController;this.glide=a,n.classList.remove("gliding"),n.style.setProperty("translate",`${i}px ${s}px`),n.offsetWidth,n.classList.add("gliding"),n.style.setProperty("translate","0px 0px");let l=(d)=>{if(d.propertyName!=="translate")return;a.abort(),n.classList.remove("gliding"),n.style.removeProperty("translate")};n.addEventListener("transitionend",l,{signal:a.signal}),n.addEventListener("transitioncancel",l,{signal:a.signal})}startMarking(){if(this.job?.id)return;this.marking=!0,this.confirming=!1,this.passKeys=new Set(this.markers.map((n)=>n.key));let e=this.parked??this.dock;this.parkInsets=this.insetsAt(e,this.e.card.getBoundingClientRect()),this.parked=e,this.renderMarks(),this.paint(),this.placeCard(),this.placeSeg();let t=globalThis.innerWidth||800;this.placeCoach({x:t/2-150,y:jt+12},!1),this.e.mark.focus()}endMarking(e){if(this.cancelDraft(),this.marking=!1,this.confirming=!1,this.paint(),e&&this.isOpen)requestAnimationFrame(()=>this.e.desc.focus())}cancelMarking(){if(this.markers.filter((t)=>!this.passKeys.has(t.key)).length===0){this.endMarking(!0);return}this.confirming=!0,this.paint(),this.e.discard.focus()}insetsAt(e,t){let n=globalThis.innerWidth||800,r=globalThis.innerHeight||600,o=jt*mt[this.size],i=e==="br"||e==="bl";return{edge:Math.max(0,Math.min(t.left,n-t.right)),top:i?o:Math.max(o,t.top),bottom:i?Math.max(0,r-t.bottom):ur}}frame(){let e=globalThis.innerWidth||800,t=globalThis.innerHeight||600,n=mt[this.size],r=this.parkInsets??{top:jt*n,bottom:ur,edge:ur},o=this.e.card.getBoundingClientRect();return{vw:e,vh:t,w:o.width||Math.min(el.w*n,e-32),h:o.height||Math.min(el.h*n,t-r.top-r.bottom),...r}}placeCard(){if(!this.parked)return;let e=this.frame();this.parked=qa(this.parked,this.markers.map((r)=>r.rect),e);let t=sr(this.parked,e),n=this.e.card.style;this.e.card.classList.add("parked"),n.left=`${t.x}px`,n.top=`${t.y}px`}unpark(){this.parked=null,this.parkInsets=null,this.e.card.classList.remove("parked"),this.e.card.style.removeProperty("left"),this.e.card.style.removeProperty("top")}placeSeg(){rl(this.e.seg,this.e.segInd,this.e.toolButtons.get(this.tool))}onChrome(e){return e instanceof Node&&(this.e.toolbar.contains(e)||this.e.pins.contains(e))}pointerDown(e){if(this.onChrome(e.target)||e.button!==0||!e.isPrimary)return;e.preventDefault();let t=this.e.root.getRootNode();if(t instanceof ShadowRoot&&t.activeElement instanceof HTMLElement)t.activeElement.blur();this.drawing={start:{x:e.clientX,y:e.clientY},shape:this.tool,pointer:e.pointerId};try{this.e.mark.setPointerCapture(e.pointerId)}catch{}this.e.coach.classList.add("pressing")}pointerMove(e){if(!this.markers.length)this.placeCoach({x:e.clientX,y:e.clientY},!0);let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:t.shape,rect:Zn(t.start,{x:e.clientX,y:e.clientY}),head:Qn(t.start,{x:e.clientX,y:e.clientY})}))}pointerUp(e){let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;let n={x:e.clientX,y:e.clientY};if(this.cancelDraft(),!ka(t.shape,t.start,n))return;this.addMarker(t.shape,Zn(t.start,n),t.shape==="arrow"?Qn(t.start,n):void 0)}addMarker(e,t,n){let r=this.nextKey++;if(e==="hide"){let o=this.engine?.hiddenIdsAt(t);if(o)this.hideIds.set(r,o)}this.markers=Ut([...this.markers,{key:r,n:this.markers.length+1,shape:e,rect:t,note:"",...n?{head:n}:{}}]),this.renderMarks(),this.paint(),this.lines.get(r)?.note.focus()}cancelDraft(){this.drawing=null,this.kbDraft=null,this.e.draft.replaceChildren(),this.e.coach.classList.remove("pressing")}kbDraft=null;markKey(e){if(e.target!==this.e.mark)return;let t=globalThis.innerWidth||800,n=globalThis.innerHeight||600;if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),!this.kbDraft){this.kbDraft={x:Math.round(t/2-dr.w/2),y:Math.round(n/2-dr.h/2),...dr},this.renderKbDraft();return}let a=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,a,this.tool==="arrow"?"se":void 0);return}let r=Kd[e.key];if(!r||!this.kbDraft)return;e.preventDefault();let o=this.kbDraft,[i,s]=r;this.kbDraft=e.shiftKey?{...o,w:Math.min(t-o.x,Math.max(Qa,o.w+i)),h:Math.min(n-o.y,Math.max(Qa,o.h+s))}:{...o,x:Math.min(t-o.w,Math.max(0,o.x+i)),y:Math.min(n-o.h,Math.max(0,o.y+s))},this.renderKbDraft()}renderKbDraft(){let e=this.kbDraft;if(!e)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:this.tool,rect:e,head:"se"}))}placeCoach(e,t){let n=globalThis.innerWidth||800,r=globalThis.innerHeight||600,o=this.e.coach.offsetWidth||300,i=this.e.coach.offsetHeight||140,s=t?e.x+20:e.x,a=t?e.y+20:e.y;if(s+o>n-8)s=t?e.x-o-20:n-o-8;if(a+i>r-90)a=t?e.y-i-20:r-i-90;this.e.coach.style.left=`${Math.max(8,s)}px`,this.e.coach.style.top=`${Math.max(8,a)}px`}shapeNodes(e){let{x:t,y:n,w:r,h:o}=e.rect;if(e.shape==="circle")return[F("ellipse",{class:"stroke",cx:t+r/2,cy:n+o/2,rx:Math.max(1,r/2),ry:Math.max(1,o/2)})];if(e.shape==="box")return[F("rect",{class:"stroke",x:t,y:n,width:r,height:o,rx:6})];if(e.shape==="arrow"){let{tail:a,tip:l}=er(e.rect,e.head??"se");return[F("line",{class:"stroke",x1:a.x,y1:a.y,x2:l.x,y2:l.y,"marker-end":"url(#vr-head)"})]}let i=F("rect",{class:"veil",x:t,y:n,width:r,height:o,rx:4}),s=F("text",{class:"veil-label",x:t+r/2,y:n+o/2+4,"text-anchor":"middle"});return s.textContent=r>60&&o>20?this.s.hidden:"",[i,s]}renderMarks(){this.e.shapes.replaceChildren(...this.markers.flatMap((n)=>this.shapeNodes(n)));let e=new Set(this.markers.map((n)=>n.key));for(let[n,r]of this.pins){if(e.has(n))continue;r.el.remove(),this.pins.delete(n)}for(let[n,r]of this.lines){if(e.has(n))continue;r.el.remove(),this.lines.delete(n)}let t=(n)=>{this.markers=Ut(this.markers.filter((r)=>r.key!==n)),this.renderMarks(),this.paint()};for(let n of this.markers){if(this.pins.has(n.key))continue;let r=c("button",{class:"num",type:"button"}),o=c("button",{class:"rm",type:"button"},R(x.close)),i=c("div",{class:"pin"},r,o);r.addEventListener("click",()=>this.lines.get(n.key)?.note.focus()),o.addEventListener("click",()=>t(n.key)),this.e.pins.append(i),this.pins.set(n.key,{el:i,num:r,rm:o});let s=c("span",{class:"ln-n","aria-hidden":"true"}),a=c("input",{class:"ln-t",type:"text",maxlength:"500"}),l=c("button",{class:"ln-x",type:"button"},R(x.close)),d=c("li",{class:"ln"},s,a,l);a.addEventListener("input",()=>{this.markers=this.markers.map((f)=>f.key===n.key?{...f,note:a.value}:f),this.paint()}),a.addEventListener("keydown",(f)=>{if(f.key!=="Enter"||!this.marking)return;f.preventDefault(),this.e.mark.focus()}),l.addEventListener("click",()=>t(n.key)),this.e.lines.append(d),this.lines.set(n.key,{el:d,num:s,note:a,rm:l})}for(let n of this.markers){let r=this.lines.get(n.key);if(r)this.e.lines.append(r.el)}if(this.renderPins(),this.parked)this.placeCard()}renderPins(){let e=globalThis.innerWidth||800;for(let t of this.markers){let n=this.pins.get(t.key),r=this.lines.get(t.key);if(!n||!r)continue;let o=t.shape==="arrow"?er(t.rect,t.head??"se").tail:{x:t.rect.x,y:t.rect.y};n.el.style.left=`${Math.min(Math.max(4,o.x-12),e-60)}px`,n.el.style.top=`${Math.max(jt-12,o.y-12)}px`,n.num.textContent=String(t.n),n.num.setAttribute("aria-label",this.s.mark(t.n)),n.rm.setAttribute("aria-label",this.s.removeMark(t.n)),r.num.textContent=String(t.n),r.el.classList.toggle("hide",t.shape==="hide"),r.note.placeholder=this.s.notePlaceholder,r.note.setAttribute("aria-label",`${this.s.mark(t.n)} — ${this.s.notePlaceholder}`),r.rm.setAttribute("aria-label",this.s.removeMark(t.n))}}envelope(e,t){let n=this.who(),r=globalThis.location;return{title:nl(e),description:e,env:{url:se(r?`${r.origin}${r.pathname}`:""),ua:globalThis.navigator?.userAgent??"",viewport:{w:globalThis.innerWidth||0,h:globalThis.innerHeight||0,dpr:globalThis.devicePixelRatio||1},appVersion:this.opts.appVersion??"",locale:globalThis.navigator?.language??""},console:t.console,network:t.network,...n?{identity:n,notify:this.notify}:{},markers:wa(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{}}}words(){return this.e.desc.value.trim()||(this.markers.find((e)=>e.note.trim())?.note.trim()??"")}async send(){let e=this.words();if(this.sending||!e)return;if(this.marking)this.endMarking(!1);if(this.sending=!0,this.error="",this.paint(),this.job&&!this.job.id)this.job=null;try{if(!this.job){let t=new Set;for(let r of this.markers)for(let o of this.hideIds.get(r.key)??[])t.add(o);let n=this.engine?await this.engine.build(this.frozen??{clip:null,stored:Promise.resolve(new Map)},this.markers,t).catch((r)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",r),Za)):Za;this.job=new cr(n,globalThis.location?.host??"",{url:this.opts.base,key:this.opts.key},this.files)}this.result=await this.job.run(this.envelope(e,this.job.capture)),Xa(this.opts.base,globalThis.location?.host??"",{title:nl(e),at:Date.now(),status:this.result.status,...this.result.reportUrl?{url:this.result.reportUrl}:{}}),this.sentNotify=this.notify&&this.who()!==null,this.view="sent",this.job=null,this.frozen=null,this.e.desc.value="",this.markers=[],this.hideIds.clear(),this.kind=null,this.notify=!1,this.e.notifyBox.checked=!1,this.includedOpen=!1,this.files=[],this.fileRefusal=null,this.renderMarks(),this.renderFiles(),this.engine?.clear()}catch(t){console.warn("vitrinka: the report did not go through — Retry resumes it",t),this.error=!this.job?.id?"create":this.job.filesPending?"files":"capture"}finally{this.sending=!1,this.paint()}if(this.view==="sent")requestAnimationFrame(()=>((this.result?.reportUrl)?this.e.see:this.e.sentClose).focus())}includedItems(){let e=this.s,t=[],n=this.config?.lanes;if(n?.replay)t.push(`${e.incReplay} — ${e.incReplayMasked[this.config?.masking??"strict"].toLowerCase()}`);if(n?.errors)t.push(e.incErrors);if(n?.console)t.push(e.incConsole);if(n?.network)t.push(e.incNetwork);else if(n?.errors)t.push(e.incFailedRequests);if(t.push(e.incEnv),this.who())t.push(e.incIdentity);if(this.markers.length)t.push(e.incMarks);if(this.files.length)t.push(e.incFiles);return t}paintAccount(){let{e,s:t}=this,n=this.who(),r=!n?null:("email"in n)?{name:n.name??"",email:n.email}:this.session?{name:this.session.reporter.name??"",email:this.session.reporter.email}:null,o=r?.name||r?.email||"";e.whoAv.textContent=n?Wd(o):"?",e.whoName.textContent=o.split(/[\s@]/)[0]??"",e.whoName.hidden=!o,e.whoBtn.setAttribute("aria-label",`${t.account}: ${o||(n?"":t.anonymous)}`.replace(/: $/,"")),e.whoBtn.setAttribute("aria-expanded",String(this.menu==="account")),e.more.setAttribute("aria-label",t.menu),e.more.setAttribute("aria-expanded",String(this.menu==="more")),e.accountPop.hidden=this.menu!=="account",e.morePop.hidden=this.menu!=="more",e.accountPop.setAttribute("aria-label",t.account),e.morePop.setAttribute("aria-label",t.menu),e.accName.textContent=n?r?.name||r?.email||"":t.anonymous,e.accMail.textContent=r?.name?r.email:"",e.accMail.hidden=!e.accMail.textContent,e.accVia.textContent=n&&"token"in n?t.signedInByApp:t.anonymousHint;let i=this.member;e.accLinked.hidden=!i,e.accUnlink.hidden=!i,e.accLinked.textContent=i?t.linkedAs(i.email||i.name||i.workspace):"",e.accUnlink.textContent=t.unlink,e.accLink.hidden=Boolean(i),z(e.accLink,t.linkVitrinka);let s=this.session?.portalUrl;if(e.accPortal.hidden=!s,s)e.accPortal.setAttribute("href",s);z(e.accPortal,t.openPortal),z(e.mReports,t.myReports),z(e.mRecents,t.recentRecordings),z(e.mRecord,t.record),z(e.mSettings,t.settings),e.mRecents.hidden=!this.recordSwitch,e.mRecord.hidden=!this.recordSwitch,e.mRecord.disabled=this.sending||this.job!==null;let a=i?this.opts.base:s;if(e.mOpen.hidden=!a,a)e.mOpen.setAttribute("href",a);z(e.mOpen,i?t.openVitrinka:t.openPortal)}paintReports(){let{e,s:t}=this;z(e.repBack,t.myReports);let n=!this.session,r=n?lr(this.opts.base,globalThis.location?.host??"").map((s)=>this.row(s.title,s.status==="quarantined"?t.waiting:t.steps.received??"",s.at,s.url)):this.mine.rows.map((s)=>this.row(s.title,t.steps[s.step]??s.step,Date.parse(s.updatedAt),s.url));e.repRows.replaceChildren(...r);let o=n?"ok":this.mine.state;e.repStatus.hidden=o==="ok"&&r.length>0,e.repStatus.textContent=o==="loading"?t.loading:o==="failed"?t.listFailed:t.noReports,e.repLocal.hidden=!n||r.length===0,e.repLocal.textContent=t.fromThisBrowser;let i=this.session?.portalUrl;if(e.repPortal.hidden=!i,i)e.repPortal.setAttribute("href",i);e.repPortal.textContent=t.openPortal}paintRecents(){let{e,s:t}=this;z(e.recBack,t.recentRecordings);let n=Ui().map((r)=>this.row(r.title,"",r.startedAt,r.boardUrl));e.recRows.replaceChildren(...n),e.recStatus.hidden=n.length>0,e.recStatus.textContent=t.noRecordings}paintLink(){let{e,s:t}=this,n=this.linkFlow;z(e.linkBack,t.linkVitrinka),e.linkLabel.textContent=t.linkCode,e.linkCode.textContent=n?.start?.user_code??"…",e.linkOpenText.textContent=t.openVitrinka;let r=n?.start;if(e.linkOpen.hidden=!r,r)e.linkOpen.setAttribute("href",r.verifyUrl);let o=globalThis.matchMedia?.("(pointer: fine)").matches??!0;if(e.linkQr.hidden=!r||!o,r&&o&&e.linkQr.getAttribute("src")!==r.qrUrl)e.linkQr.setAttribute("src",r.qrUrl);e.linkHint.textContent=t.linkHint;let i=n?.state??"failed";e.linkWait.textContent=i==="expired"?t.linkExpired:i==="failed"?t.linkFailed:i==="waiting"?t.linkWaiting:t.loading,e.linkRetry.hidden=i!=="expired"&&i!=="failed",e.linkRetry.textContent=t.retry}paintFiles(){let{e,s:t}=this,n=this.sending||Boolean(this.job?.id);e.attach.setAttribute("aria-label",t.attach),e.attach.disabled=n,e.attach.hidden=this.caps().maxCount===0,e.fileInput.setAttribute("accept",this.caps().types.join(",")),e.tray.hidden=this.view!=="describe"||this.files.length===0&&!this.fileRefusal,e.files.hidden=this.files.length===0,e.files.setAttribute("aria-label",t.incFiles),e.fileNote.hidden=!this.fileRefusal,e.fileNote.textContent=this.refusalText(this.fileRefusal);for(let[r,o]of this.chips)o.size.textContent=je(r.size,this.locale),o.rm.setAttribute("aria-label",t.removeFile(r.name)),o.rm.disabled=n}paintSettings(){let{e,s:t}=this;e.sizeLabel.textContent=t.size;for(let[n,r]of e.sizeButtons)r.textContent=t.sizes[n],r.setAttribute("aria-checked",String(this.size===n));if(e.techText.textContent=t.techDetails,e.techBtn.setAttribute("aria-expanded",String(this.techOpen)),e.tech.hidden=!this.techOpen,this.techOpen&&this.view==="settings"){let n=us({version:os,base:this.opts.base,config:this.config,engine:this.engine!==null,locale:this.locale},t);e.tech.replaceChildren(...n.flatMap(([r,o])=>[c("dt",{},r),c("dd",{},o)]))}if(this.view==="settings")rl(e.sizeSeg,e.sizeInd,e.sizeButtons.get(this.size))}paint(){let{e,s:t}=this,n=this.who();if(e.root.setAttribute("lang",this.locale),e.root.classList.toggle("nobutton",!this.button),e.root.dataset.dock=this.dock,e.root.style.setProperty("--vr-scale",String(mt[this.size])),e.fab.hidden=!this.button||this.marking,e.fabLabel.textContent=t.button,e.fab.setAttribute("aria-expanded",String(this.isOpen)),e.fab.setAttribute("aria-description",t.moveHint),e.fab.setAttribute("aria-keyshortcuts","Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight"),e.fabKbd.hidden=!this.keybind,e.fabKbd.textContent=this.keybind?Wt(this.keybind):"",e.card.hidden=!this.isOpen,e.card.classList.toggle("busy",this.sending),e.title.textContent=t.title,e.closeBtn.setAttribute("aria-label",t.close),this.paintAccount(),e.describe.hidden=this.view!=="describe",e.settings.hidden=this.view!=="settings",e.sent.hidden=this.view!=="sent",e.reports.hidden=this.view!=="reports",e.recents.hidden=this.view!=="recents",e.linking.hidden=this.view!=="link",this.view==="reports")this.paintReports();if(this.view==="recents")this.paintRecents();if(this.view==="link")this.paintLink();e.foot.hidden=this.view!=="describe",this.paintFiles(),e.kindsLabel.textContent=t.kindsLabel;for(let[o,i]of e.kindButtons)i.textContent=t.kinds[o],i.setAttribute("aria-checked",String(this.kind===o)),i.disabled=this.sending||Boolean(this.job?.id);e.prompt.textContent=t.prompt,e.desc.placeholder=t.placeholder,e.attachedText.textContent=t.attached(this.config?.profile.windowSec??60),e.attached.hidden=this.engine===null||this.config?.capturing===!1,e.discloseText.textContent=t.included,e.disclose.setAttribute("aria-expanded",String(this.includedOpen)),e.included.hidden=!this.includedOpen,e.included.replaceChildren(...this.includedItems().map((o)=>c("li",{},o))),e.desc.disabled=this.sending,e.lines.hidden=this.markers.length===0,e.linesEmpty.hidden=!this.marking||this.markers.length>0,e.linesEmpty.textContent=t.linesEmpty;for(let o of this.lines.values())o.note.disabled=this.sending,o.rm.disabled=this.sending;e.notify.hidden=n===null,e.notifyText.textContent=t.notify,e.error.hidden=this.error==="",e.error.textContent={"":"",create:t.errorCreate,files:t.errorFiles,capture:t.errorCapture}[this.error],e.whereText.textContent=t.showWhere,e.where.setAttribute("aria-pressed",String(this.marking)),e.where.disabled=this.sending||Boolean(this.job?.id),e.send.textContent=this.sending?t.sending:this.error?t.retry:t.send,e.send.disabled=this.sending||this.words()==="",e.bindLabel.textContent=t.shortcut,e.bindBtn.setAttribute("aria-pressed",String(this.recordingBind)),e.bindBtn.setAttribute("aria-label",`${t.shortcut}: ${this.keybind?Wt(this.keybind):t.notSet} — ${t.recordShortcut}`),e.bindBtn.textContent=this.recordingBind?t.pressKeys:this.keybind?Wt(this.keybind):t.notSet,e.unbind.textContent=t.removeShortcut,e.unbind.hidden=!this.keybind||this.recordingBind,e.bindHint.textContent=t.shortcutHint,e.bindReason.hidden=!this.bindRefused,e.bindReason.textContent=this.bindRefused?t.needModifier:"",e.back.textContent=t.back,this.paintSettings(),e.sentTitle.textContent=t.sentTitle,e.sentBody.textContent=this.result?.status==="quarantined"?t.sentQueued:this.sentNotify?t.sentNotify:t.sentBody,e.seeText.textContent=t.seeReport;let r=this.result?.reportUrl;if(e.see.hidden=!r,r)e.see.setAttribute("href",r);else e.see.removeAttribute("href");e.sentClose.textContent=t.close,e.mark.hidden=!this.marking,e.toolbar.setAttribute("aria-label",t.toolbar),e.seg.setAttribute("aria-label",t.toolbar),e.barLead.textContent=t.barLead;for(let[o,i]of e.toolButtons){let s=e.toolLabels.get(o);if(s)s.textContent=t.tools[o];i.setAttribute("aria-checked",String(this.tool===o))}if(e.cancel.textContent=t.cancelMarking,e.cancel.hidden=this.confirming,e.ask.hidden=!this.confirming,e.askText.textContent=t.discardMarks(this.markers.filter((o)=>!this.passKeys.has(o.key)).length),e.discard.textContent=t.discard,e.keep.textContent=t.keep,e.coach.hidden=!this.marking||this.markers.length>0,e.coachText.textContent=t.coach,e.coachMore.textContent=t.coachMore,e.coachKeys.textContent=t.keyboardHint,e.mark.setAttribute("aria-label",t.marking),this.marking){for(let o of e.shapes.querySelectorAll(".veil-label"))if(o.textContent)o.textContent=t.hidden}this.renderPins()}}function Ut(e){return va(e).map((t,n)=>({...t,key:e[n].key}))}var Vt="vitrinka-report",Vd=["key","base","open-selector","locale","button"];function il(e){return e.trim().replace(/\/+$/,"")}function hr(e){if(typeof customElements>"u"||customElements.get(Vt))return;class t extends HTMLElement{static get observedAttributes(){return Vd}options={};at=null;shown=null;widget=null;pill=null;gen=0;recordOffered=!1;offLink=null;pendingIdentity=void 0;get face(){return this.shown??"report"}connectedCallback(){this.hidden=!0,this.mount()}disconnectedCallback(){this.unmount()}attributeChangedCallback(n,r,o){if(r===o)return;if(!this.at){if(this.isConnected&&(n==="key"||n==="base"))this.mount();return}if(n==="key"||n==="base"){this.unmount(),this.mount();return}if(!this.widget)return;if(n==="locale")this.widget.setLocale(o);else if(n==="button")this.widget.setButton(o!=="false");else if(n==="open-selector")this.widget.setOpenSelector(o)}open(){this.widget?.open()}close(){this.widget?.close()}identify(n){this.pendingIdentity=n,this.widget?.identify(n)}setLocale(n){this.setAttribute("locale",String(n))}mount(){if(this.at)return;let n=(this.getAttribute("key")??"").trim(),r=il(this.getAttribute("base")??e.defaultBase());if(!n||!r){console.warn(`vitrinka: <${Vt}> needs a key${r?"":" and a base"} — nothing mounted`);return}if(this.at={key:n,base:r},e.recorderFace)this.offLink=vi(()=>this.offerRecord());this.show(e.recorderFace?ki(r):"report")}unmount(){this.offLink?.(),this.offLink=null,this.takeDown(),this.at=null,this.shown=null}takeDown(){this.gen++,this.widget?.unmount(),this.widget=null,this.recordOffered=!1,this.pill?.(),this.pill=null}show(n){let r=this.at;if(!r)return;this.takeDown();let o=e.recorderFace;if(n==="recorder"&&o){this.shown="recorder";let i=this.gen;o().then((s)=>{if(i!==this.gen)return;this.pill=s({base:r.base,appVersion:this.options.appVersion,sanitizeUrl:this.options.sanitizeUrl,onReportFace:()=>this.switchTo("report")})}).catch((s)=>{if(console.warn("vitrinka: the recorder face did not load — showing Report a problem",s),i===this.gen)this.show("report")});return}this.shown="report",this.widget=new fr({base:r.base,key:r.key,locale:Ke(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,appVersion:this.options.appVersion,capture:this.options.capture,sanitizeUrl:this.options.sanitizeUrl,loadRecord:e.loadRecord}),this.offerRecord()}offerRecord(){if(!this.widget||!this.at)return;let n=e.recorderFace!==null&&$e(this.at.base);if(n===this.recordOffered)return;this.recordOffered=n,this.widget.setRecordSwitch(n?()=>this.switchTo("recorder"):null)}switchTo(n){mi(n);let r=this.gen;setTimeout(()=>{if(r===this.gen&&this.shown!==n)this.show(n)},0)}}customElements.define(Vt,t)}function sl(e,t){if(e.face==="recorder")return Yd(e,t);hr(t);let n=document.createElement(Vt);if(n.setAttribute("key",e.key),e.base)n.setAttribute("base",e.base);if(e.locale)n.setAttribute("locale",String(e.locale));if(e.button===!1)n.setAttribute("button","false");if(e.openSelector)n.setAttribute("open-selector",e.openSelector);if(n.options={appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl},e.identity!==void 0)n.identify(e.identity);return(e.parent??document.body).append(n),{get face(){return n.face},open:()=>n.open(),close:()=>n.close(),identify:(r)=>n.identify(r),setLocale:(r)=>n.setLocale(r),unmount:()=>n.remove()}}function Yd(e,t){let n=il(e.base??t.defaultBase()),r=null,o=!1;if(!t.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else t.recorderFace().then((s)=>{if(!o)r=s({base:n,key:e.key,appVersion:e.appVersion,sanitizeUrl:e.sanitizeUrl})}).catch((s)=>console.warn("vitrinka: the recorder face did not load",s));let i=()=>{return};return{face:"recorder",open:i,close:i,identify:i,setLocale:i,unmount:()=>{o=!0,r?.()}}}var Xd=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function Gd(e){let n=await import(`${e}/vendor/rrweb-record-1.min.js`)??{},r=typeof n.default==="object"&&n.default!==null?n.default.record:void 0,o=typeof n.default==="function"?n.default:r??n.record;return typeof o==="function"?o:null}var al={loadRecord:Gd,recorderFace:null,defaultBase:()=>Xd};hr(al);function hf(e){return sl(e,al)}export{Dd as identify,hf as mountReport};