@vitrinka/web 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +15 -6
- package/build/hud.iife.js +15 -15
- package/build/one.iife.js +1 -1
- package/build/recorder/api.d.ts +5 -3
- package/build/recorder/api.js +5 -3
- package/build/recorder/storage/index.d.ts +1 -1
- package/build/recorder/storage/index.js +3 -2
- package/build/recorder/storage/lock.js +85 -3
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/engine.d.ts +8 -0
- package/build/report/engine.js +24 -3
- package/build/report/i18n.d.ts +2 -0
- package/build/report/i18n.js +2 -0
- package/build/report/styles.d.ts +1 -1
- package/build/report/styles.js +9 -3
- package/build/report/widget.d.ts +15 -2
- package/build/report/widget.js +81 -27
- package/build/report/wire.d.ts +40 -1
- package/build/report/wire.js +74 -9
- package/build/report-widget.mjs +18 -12
- package/package.json +1 -1
package/build/report-widget.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
|
-
`)||!
|
|
3
|
-
`))return null;let
|
|
1
|
+
class w0 extends Error{constructor(x="link code expired"){super(x);this.name="LinkExpired"}}class sx extends Error{constructor(x,$){super(`linked into ${x} — this app records into ${$}; link again and pick ${$}`);this.linked=x,this.expected=$,this.name="LinkWorkspaceMismatch"}}class W0 extends Error{constructor(x,$){super(x);this.status=$,this.name="LinkError"}}class L extends Error{constructor(x,$){super(x);this.status=$,this.name="VitrinkaApiError"}}function m(x){return x>=400&&x<500&&x!==408&&x!==429}function ex(x){return new URL(x).origin}function X1(x){let $=/^\/w\/([^/]+)/.exec(new URL(x).pathname);if(!$?.[1])return;try{return decodeURIComponent($[1])}catch{return $[1]}}function rx(x,$){if(!$)return x;let z=new URL(x);return z.searchParams.set("workspace",$),z.href}function x4(x){return x===401}function $4(x){let $=x.fetch??globalThis.fetch;if(typeof $!=="function")throw Error("vitrinka link: no fetch available");return $}function tx(x,$,z,Q){let Z=(V)=>{if(!V)return;try{let J=new URL(V,x);if(J.protocol!=="http:"&&J.protocol!=="https:")return;if(J.origin===x)return J.href;return x+J.pathname+J.search}catch{return}};return Z($)??Z(z)??x+Q}function V1(x,$,z){let Q=x[$];if(typeof Q!=="string"||Q==="")throw new W0(`link start → malformed payload (${$})`,z);return Q}async function z4(x,$){let z=ex(x),Q=await $4($)(`${z}/api/v1/cli/auth`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"recorder",label:$.label})});if(Q.status!==201&&Q.status!==200)throw new W0(`link start → ${Q.status}`,Q.status);let Z;try{Z=await Q.json()}catch{throw new W0("link start → malformed payload (not JSON)",Q.status)}if(typeof Z!=="object"||Z===null)throw new W0("link start → malformed payload",Q.status);let V=Z,J=V1(V,"device_code",Q.status),X=V1(V,"user_code",Q.status),G=V1(V,"verify_path",Q.status),Y=V1(V,"qr_path",Q.status);return{base:x,device_code:J,user_code:X,verify_path:G,verifyUrl:rx(tx(z,typeof V.verify_url==="string"?V.verify_url:void 0,G,`/cli-auth?code=${encodeURIComponent(X)}`),$.workspace),qrUrl:rx(tx(z,Y,Y,`/cli-auth/qr?code=${encodeURIComponent(X)}`),$.workspace),interval:Math.max(2,Number(V.interval)||2),expires_in:Number(V.expires_in)||0}}var W8=600,F8=30000;function q8(x){return x>=500||x===408||x===429}function D8(x,$){let z=x.headers.get("retry-after");if(!z)return;let Q=Number(z);if(Number.isFinite(Q)&&Q>=0)return Q*1000;let Z=Date.parse(z);return Number.isNaN(Z)?void 0:Math.max(0,Z-$)}function M8(x,$){return new Promise((z,Q)=>{if($?.aborted)return Q(z2());let Z=setTimeout(()=>{$?.removeEventListener("abort",V),z()},x),V=()=>{clearTimeout(Z),Q(z2())};$?.addEventListener("abort",V,{once:!0})})}function z2(){let x=Error("link polling aborted");return x.name="AbortError",x}async function Q4(x,$,z={}){let Q=ex(x),Z=$4(z),V=z.sleep??M8,J=z.now??Date.now,X=Math.max(2,z.interval??2),G=J()+(z.expiresIn&&z.expiresIn>0?z.expiresIn:W8)*1000,Y=0,F=async(q,U)=>{Y++;let W=G-J();if(W<=0)throw new w0(`link code expired (last claim: ${q})`);let D=Math.max(Math.min(F8,X*1000*2**Y),U??0);await V(Math.min(D,W),z.signal)};for(;;){if(z.signal?.aborted)throw z2();let q;try{q=await Z(`${Q}/api/v1/cli/auth/claim`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({device_code:$}),signal:z.signal})}catch(U){if(z.signal?.aborted||!(U instanceof TypeError))throw U;await F(U.message);continue}if(q8(q.status)){await F(String(q.status),D8(q,J()));continue}if(Y=0,q.status===200){let U=await q.json();if(z.workspace&&U.workspace!==z.workspace){let W=typeof U.workspace==="string"&&U.workspace?U.workspace:"(no workspace)";throw new sx(W,z.workspace)}return U}if(q.status===404||q.status===410)throw new w0;if(q.status!==202)throw new W0(`link claim → ${q.status}`,q.status);await V(X*1000,z.signal)}}var B={tabId:"root",tabHost:"/",pathname:"/"};function Z4(){try{let x=globalThis.sessionStorage,$=x.getItem("vitrinka.tab");if($)return $;let z=Math.random().toString(36).slice(2,10);return x.setItem("vitrinka.tab",z),z}catch{return"root"}}function J4(x,$){B.tabId=x,B.tabHost=$}var k0={following:null},y0="__vitrinkaCaptureOwner";function V4(x,$){let z=globalThis,Q=z[y0];if(Q){if(x==="report")return null;if(Q.face==="report")z[y0]=null,Q.yieldTo?.()}let Z=`${x}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return z[y0]={face:x,token:Z,...$?{yieldTo:$}:{}},Z}function X4(x){let $=globalThis;if(x&&$[y0]?.token===x)$[y0]=null}var Q2=new Set;function G4(x){return Q2.add(x),()=>Q2.delete(x)}function o(){for(let x of Q2)x()}async function Y4(x,$){let z=`vitrinka.recorder.${x}`;if(globalThis.navigator?.locks){await navigator.locks.request(z,{signal:AbortSignal.timeout(5000)},$);return}let Q={area:P8(),key:`vitrinka.recorder.lock.${x}`},Z=await C8(),V={fence:void 0,since:0};while(!await L8(Z,z,Q,$,V))await H8()}var U4=1000,K8=5,H8=()=>new Promise((x)=>setTimeout(x,K8));function P8(){try{return globalThis.localStorage??null}catch{return null}}function N8(x,$){return typeof $!=="string"||!x.area||x.area.getItem(x.key)===$}function O8(x){if(!x.area)return null;let $=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;try{return x.area.setItem(x.key,$),$}catch(z){return console.warn("vitrinka: recorder lock fence not stored — the next tab may not see this allocation",z),null}}function B8(x,$){let z=Date.now();if(x.fence!==$)return x.fence=$,x.since=z,!1;if(z-x.since<U4)return!1;return g8(),!0}var j4=!1;function g8(){if(j4)return;j4=!0,console.warn(`vitrinka: this tab did not hear the last recorder lock holder within ${U4} ms — numbering anyway`)}function L8(x,$,z,Q,Z){return new Promise((V,J)=>{let X=x.transaction("locks","readwrite"),G=X.objectStore("locks"),Y=!1;X.oncomplete=()=>V(Y),X.onabort=()=>J(X.error??Error("vitrinka: recorder lock transaction aborted"));let F=G.get($);F.onsuccess=()=>{if(!N8(z,F.result)&&!B8(Z,F.result))return;try{Q()}catch(U){J(U),X.abort();return}Y=!0;let q=O8(z);if(q)G.put(q,$)}})}var p0;function C8(){if(!p0)p0=new Promise((x,$)=>{let z=indexedDB.open("vitrinka.recorder.locks",1);z.onupgradeneeded=()=>z.result.createObjectStore("locks"),z.onerror=()=>$(z.error),z.onsuccess=()=>{let Q=z.result;Q.onversionchange=()=>{Q.close(),p0=void 0},x(Q)}}).catch((x)=>{throw p0=void 0,x});return p0}var Z0="vitrinka.recorder.",Z2=null,A8=!1;function R(){if(!Z2)Z2=_8()??I8();return A8=!0,Z2}function _8(){try{let x=globalThis.localStorage;if(!x)return null;let $=`${Z0}probe`;return x.setItem($,"1"),x.removeItem($),{getString:(z)=>x.getItem(Z0+z),set:(z,Q)=>x.setItem(Z0+z,Q),remove:(z)=>x.removeItem(Z0+z),withLock:Y4,keys:()=>Array.from({length:x.length},(z,Q)=>x.key(Q)).filter((z)=>z!==null&&z.startsWith(Z0)).map((z)=>z.slice(Z0.length)),watch:(z,Q)=>{let Z=(V)=>{if(V.storageArea===x&&V.key===Z0+z)Q(V.newValue)};return globalThis.addEventListener("storage",Z),()=>globalThis.removeEventListener("storage",Z)}}}catch{return console.warn("vitrinka: localStorage unavailable — the recorder queue will not survive a reload"),null}}function I8(){let x=new Map;return{getString:($)=>x.get($)??null,set:($,z)=>void x.set($,z),remove:($)=>void x.delete($),keys:()=>[...x.keys()]}}var F0={url:"",key:""};function G1(){return F0}var J2=new Set;function W4(x){let $=x.replace(/\/+$/,"");return J2.add($),()=>J2.delete($)}function V2(x){if(F0.url!==""&&x.startsWith(F0.url))return!0;for(let $ of J2)if($!==""&&x.startsWith($))return!0;return!1}var v0="link";function h0(){let x=R().getString(v0);if(!x)return null;try{let $=JSON.parse(x);return typeof $.token==="string"&&$.token?$:null}catch{return null}}function F4(x){R().set(v0,JSON.stringify(x)),o()}function q4(){R().remove(v0),o()}function D4(){return F0.key||h0()?.token||""}function M4(){if(F0.label)return F0.label;let x=globalThis.navigator?.userAgent??"",$=/Edg\//.test(x)?"Edge":/OPR\//.test(x)?"Opera":/Chrome\//.test(x)?"Chrome":/Firefox\//.test(x)?"Firefox":/Safari\//.test(x)?"Safari":"Browser",z=/iPhone|iPad/.test(x)?"iOS":/Android/.test(x)?"Android":/Mac OS X/.test(x)?"macOS":/Windows/.test(x)?"Windows":/Linux/.test(x)?"Linux":"unknown OS",Q=globalThis.location?.host??"";return`${$} on ${z}${Q?` · ${Q}`:""}`}var H4="vitrinka.report.face",K4=(x)=>x.trim().replace(/\/+$/,"");function j1(){try{return globalThis.localStorage??null}catch{return null}}function m0(x){let $=h0();if(!$)return!1;if($.base)return K4($.base)===K4(x);try{let z=X1(x);return z===void 0||z===$.workspace}catch{return!1}}function R8(){let x=j1()?.getItem(H4);return x==="recorder"||x==="report"?x:null}function P4(x){try{j1()?.setItem(H4,x)}catch($){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",$)}}var N4="vitrinka.report.mode";function O4(x){try{if(x==="dev"||x==="regular")j1()?.setItem(N4,x)}catch($){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",$)}}function B4(x){if(!m0(x))return"report";let $=R8();if($)return $;return j1()?.getItem(N4)==="dev"?"recorder":"report"}function g4(x){let $=R().watch?.(v0,()=>x()),z=G4(x);return()=>{$?.(),z()}}var L4=["bug","suggestion","question","other"];function q0(x,$,z,Q){if(x===1)return $;if(x>=2&&x<=4)return z;return Q}var S8={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:(x)=>{if(x<60)return`The last ${x} seconds are attached`;let $=Math.round(x/60);return $===1?"The last minute is attached":`The last ${$} 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:(x)=>x===1?"Discard 1 mark?":`Discard ${x} 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:(x)=>`Mark ${x}`,removeMark:(x)=>`Remove mark ${x}`,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:(x)=>`Linked to vitrinka as ${x}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(x)=>`Remove ${x}`,fileTooBig:(x,$)=>`${x} is over the ${$} limit`,tooManyFiles:(x)=>x===1?"Up to 1 file per report":`Up to ${x} files per report`,fileType:(x,$)=>`${x} can’t be attached — ${$} 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:(x)=>{if(x<60)return x===1?"1 second":`${x} seconds`;let $=Math.round(x/60);return $===1?"1 minute":`${$} minutes`}},T8={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:(x)=>{if(x<60)return q0(x,"Poslední sekunda je přiložena",`Poslední ${x} sekundy jsou přiloženy`,`Posledních ${x} sekund je přiloženo`);let $=Math.round(x/60);return q0($,"Poslední minuta je přiložena",`Poslední ${$} minuty jsou přiloženy`,`Posledních ${$} 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:(x)=>q0(x,"Zahodit 1 značku?",`Zahodit ${x} značky?`,`Zahodit ${x} 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:(x)=>`Značka ${x}`,removeMark:(x)=>`Odebrat značku ${x}`,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:(x)=>`Propojeno s vitrinkou jako ${x}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(x)=>`Odebrat ${x}`,fileTooBig:(x,$)=>`${x} přesahuje limit ${$}`,tooManyFiles:(x)=>q0(x,"Nejvýš 1 soubor na hlášení",`Nejvýš ${x} soubory na hlášení`,`Nejvýš ${x} souborů na hlášení`),fileType:(x,$)=>`${x} nelze přiložit — jen ${$}`,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:(x)=>{if(x<60)return q0(x,"1 sekunda",`${x} sekundy`,`${x} sekund`);let $=Math.round(x/60);return q0($,"1 minuta",`${$} minuty`,`${$} minut`)}},f8={cs:T8,en:S8};function X2(x){return f8[x]}function u0(x){if(typeof x!=="string")return null;let $=x.trim().toLowerCase().split(/[-_]/)[0];return $==="cs"||$==="en"?$:null}function G2(){let x=globalThis.navigator,$=x?x.languages?.length?x.languages:[x.language]:[];for(let z of $){let Q=u0(z);if(Q)return Q}return"en"}var b8=null;function C4(x){if(x4(x))b8?.()}function A4(x){return x??{url:G1().url,key:D4()}}async function n(x,$,z,Q={}){let{url:Z,key:V}=A4(Q.target),J=await fetch(Z+$,{method:x,mode:"cors",credentials:"omit",keepalive:Q.keepalive??!1,...Q.signal?{signal:Q.signal}:{},headers:{authorization:`Bearer ${V}`,...z!==void 0?{"content-type":"application/json"}:{}},body:z===void 0?void 0:JSON.stringify(z)}),X=await J.text();if(!J.ok){if(!Q.target)C4(J.status);throw new L(`${x} ${$} → ${J.status}: ${X}`,J.status)}return X?JSON.parse(X):{}}function _4(x,$,z){return R4(x,"chunk",$,"application/json",z)}function I4(x,$,z){return R4(x,"shot",$,z.type,z)}function R4(x,$,z,Q,Z){return j2(`/api/v1/sessions/${x}/${$}?seq=${z}`,Q,Z)}async function j2(x,$,z,Q,Z){let{url:V,key:J}=A4(Q),X=await fetch(V+x,{method:"POST",mode:"cors",credentials:"omit",...Z?{signal:Z}:{},headers:{authorization:`Bearer ${J}`,"content-type":$},body:z}),G=await X.text();if(!X.ok){if(!Q)C4(X.status);throw new L(`POST ${x} → ${X.status}: ${G}`,X.status)}try{return JSON.parse(G)}catch{return{}}}var f4="[redacted]",E8=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],w8=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function D0(x){return String(x).toLowerCase().replace(/[-_]/g,"")}var Y2=null;function U2(x){let $=JSON.stringify(x??null);if(Y2?.src===$)return Y2.rules;let z=new Set(E8),Q=new Set(w8),Z=[];for(let J of x?.extraHeaders??[]){let X=D0(J);if(X)z.add(X)}for(let J of x?.extraBodyKeys??[]){let X=D0(J);if(X)Q.add(X)}for(let J of x?.patterns??[])try{Z.push(new RegExp(J,"g"))}catch(X){console.warn("vitrinka redact: unsupported pattern skipped",J,X)}let V={full:x?.fullFidelity===!0,maskAllText:x?.maskAllText===!0,headers:z,bodyKeys:Q,patterns:Z};return Y2={src:$,rules:V},V}var y8=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),k8=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function p8(x){return x.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(($)=>$.toLowerCase())}function b4(x){let $=p8(x);if($.some((z)=>y8.has(z)))return!0;for(let z=0;z<$.length;z++){let Q="";for(let Z=z;Z<$.length;Z++){if(Q+=$[Z],k8.includes(Q))return!0;if(Q.length>24)break}}return!1}function E4(x,$){let z=D0($);return x.headers.has(z)||z.endsWith("apikey")||z.endsWith("token")||b4($)}function a(x,$){return x.bodyKeys.has(D0($))||b4($)}function w4(x,$){if(a(x,$))return!0;let z=D0($);return z.endsWith("apikey")||z.endsWith("token")}var v8=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,h8=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function y4(x){return x.includes("PRIVATE KEY-----")?x.replace(v8,"[redacted]"):x}function M0(x,$){let z=y4($);for(let Q of x.patterns)Q.lastIndex=0,z=z.replace(Q,"[redacted]");return z}function k4(x,$){if(h8.test($))return!0;for(let z of $.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(a(x,z[1]))return!0;return!1}function Y1(x){let $=x;for(let z=0;z<3;z++){let Q=m8($);if(Q===$)break;$=Q}return $}function m8(x){if(!x.includes("%"))return x;try{return decodeURIComponent(x)}catch{return x.replace(/(%[0-9A-Fa-f]{2})+/g,($)=>{try{return decodeURIComponent($)}catch{return $.replace(/%([0-9A-Fa-f]{2})/g,(z,Q)=>{let Z=Number.parseInt(Q,16);return Z<128?String.fromCharCode(Z):z})}})}}function p4(x,$,z){let Q=!1,Z=z.split(/[&;]/).map((V)=>{if(V==="")return V;let J=V.indexOf("="),X=J>=0?V.slice(0,J):V,G=Y1(X.replace(/\+/g," ")),Y=G.lastIndexOf("?"),F=Y>=0?G.slice(Y+1):null;if($(x,G)||F!==null&&$(x,F))return Q=!0,`${X}=[redacted]`;if(J>=0&&k4(x,Y1(V.slice(J+1))))return Q=!0,`${X}=[redacted]`;return V});return Q?Z.join("&"):z}function W2(x,$){if(x.full||!$)return $;let z=$.search(/[?#]/);if(z<0)return M0(x,$);let Q=$.slice(z+1).split("#").map((Z)=>p4(x,w4,Z)).join("#");return M0(x,$.slice(0,z+1)+Q)}var u8=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,c8=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,d8=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,l8=131072;function U1(x,$){if($.length>l8)return`[body omitted: ${$.length} bytes, unmaskable]`;let z=y4($).replace(d8,(Q,Z)=>E4(x,Z)?`${Z}: [redacted]`:Q).replace(/\b((?:proxy-)?authorization|www-authenticate)(\s*[:=]\s*)[^\r\n]+/gi,(Q,Z,V)=>`${Z}${V}[redacted]`).replace(/\b(Digest|Negotiate|NTLM)\s+(?=[A-Za-z][A-Za-z-]{0,30}\s*=)[^\r\n]+/gi,(Q,Z)=>`${Z} [redacted]`).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9._-]{10,}/g,"[redacted]").replace(c8,(Q,Z,V,J)=>{if(w4(x,Y1(V)))return`${Z}${V}=[redacted]`;if(k4(x,Y1(J)))return`${Z}${V}=[redacted]`;return Q}).replace(u8,(Q,Z,V,J,X)=>{if(X==="[redacted]")return Q;return a(x,Z)?`${Z}${V}${J}[redacted]${J}`:Q});return M0(x,z)}function i8(x){switch(D0(x)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var o8=64;function W1(x,$,z){if(z>o8)return"[redacted]";if(Array.isArray($))return $.map((Q)=>W1(x,Q,z+1));if($!==null&&typeof $==="object"){let Q={};for(let[Z,V]of Object.entries($))if(a(x,Z))Q[Z]="[redacted]";else if(typeof V==="string"&&i8(Z))Q[Z]=W2(x,V);else Q[Z]=W1(x,V,z+1);return Q}return typeof $==="string"?M0(x,$):$}function S4(x){if(!x.includes("\\"))return x;return x.replace(/\\u([0-9A-Fa-f]{4})|\\(.)/g,($,z,Q)=>z!==void 0?String.fromCharCode(Number.parseInt(z,16)):Q)}function n8(x,$){for(let z of $.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(a(x,S4(z[1])))return"";return $.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(z,Q,Z)=>a(x,S4(Z))?`${Q}"[redacted]"`:z)}function F2(x){let $=x.trimStart();return $.startsWith("{")||$.startsWith("[")}function a8(x,$,z){let Q=/boundary="?([^";]+)"?/i.exec(z);if(!Q)return null;let Z=`--${Q[1]}`,V=$.split(Z);if(V.length<3||V[0]!=="")return null;if(!V[V.length-1].startsWith("--"))return null;let J=[V[0]];for(let X=1;X<V.length-1;X++){let G=V[X];if(!G.startsWith(`\r
|
|
2
|
+
`)||!G.endsWith(`\r
|
|
3
|
+
`))return null;let Y=G.indexOf(`\r
|
|
4
4
|
\r
|
|
5
|
-
`);if(
|
|
6
|
-
${
|
|
5
|
+
`);if(Y<0)return null;let F=G.slice(2,Y),q=G.slice(Y+4,-2),W=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(F)?.[1]??"",D=W!==""&&a(x,W)?"[redacted]":U1(x,q);J.push(`\r
|
|
6
|
+
${F}\r
|
|
7
7
|
\r
|
|
8
|
-
${
|
|
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=`
|
|
8
|
+
${D}\r
|
|
9
|
+
`)}return J.push(V[V.length-1]),J.join(Z)}var v4=262144;function T4(x,$,z){if(x.full||!$)return $;try{if(F2($)){if($.length<=v4)try{return JSON.stringify(W1(x,JSON.parse($),0))}catch{}return M0(x,n8(x,$))}let Q=(z??"").toLowerCase();if(Q.includes("x-www-form-urlencoded"))return U1(x,p4(x,a,$));if(Q.includes("multipart/form-data")){let Z=a8(x,$,z??"");if(Z!==null)return Z;return`[multipart body omitted: unparseable (${$.length} chars)]`}return U1(x,$)}catch{return"[redacted]"}}function h4(x,$){if($===void 0)return;if(x.full)return $;if(F2($))try{return JSON.stringify(W1(x,JSON.parse($),0))}catch{}try{return U1(x,$)}catch{return"[redacted]"}}function m4(x,$,z,Q){if(x.full)return $.length>z?`${$.slice(0,z)}…[truncated]`:$;if($.length>z&&Q?.toLowerCase().includes("multipart/form-data"))return`[multipart body omitted: oversized (${$.length} chars)]`;if(F2($)&&$.length<=v4){let V=T4(x,$,Q);return V.length>z?`${V.slice(0,z)}…[truncated]`:V}let Z=$.length>z?`${$.slice(0,z)}…[truncated]`:$;return T4(x,Z,Q)}function u4(x,$,z){if(!$)return;let Q=z?.maxValueLen??1024,Z=z?.budget??8192,V={};for(let[J,X]of Object.entries($)){let Y=(x.full?String(X):E4(x,J)?"[redacted]":M0(x,String(X))).slice(0,Q);if(Z-=J.length+Y.length,Z<0){V["…"]="(truncated)";break}V[J]=Y}return V}function c4(x){if(x.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:x.maskAllText,...x.maskAllText?{maskTextSelector:"*"}:{}}}var K0=U2(null);function l4(x){K0=U2(x??null)}function i4(x){return h4(K0,x)}function q2(x,$,z){return m4(K0,x,$,z)}var d4=null,o4=null;function D2(x){o4=x??null}function r8(x){let $=o4??G1().sanitizeUrl;if(!$)return x;let z;try{let Q=$(x);if(typeof Q==="string")return Q;z=`returned ${typeof Q}`}catch{z="threw"}if(d4!==$)d4=$,console.warn(`vitrinka: sanitizeUrl ${z} — such URLs are recorded as their origin only`);return t8(x)??f4}function t8(x){try{let{origin:$}=new URL(x);return $==="null"?null:$}catch{return null}}function J0(x){return W2(K0,r8(x))}var s8=4;function M2(x){return x.type===s8}function K2(x){if(!M2(x))return x;return{...x,data:{...x.data,href:J0(x.data.href)}}}function c0(x){return u4(K0,x)}function n4(){return c4(K0)}var e8="recents",x9=5,$9=["recording","saved","unsaved","deleted"];function z9(x){if(!x||typeof x!=="object")return!1;let $=x;return typeof $.sessionId==="string"&&typeof $.title==="string"&&typeof $.startedAt==="number"&&$9.includes($.status)}var F1;function a4(){if(F1===void 0)try{let x=JSON.parse(R().getString(e8)??"[]");F1=Array.isArray(x)?x.filter(z9).slice(0,x9):[]}catch{F1=[]}return F1}var d0="data-vitrinka-recorder";var H2="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;",r4=H2;function f(x,$,z,Q={}){let Z=x,V=Z.__zone_symbol__addEventListener??x.addEventListener,J=Z.__zone_symbol__removeEventListener??x.removeEventListener,X=Q.capture??!1;return V.call(x,$,z,{capture:X,passive:!1}),()=>J.call(x,$,z,X)}var Q9=["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 x3(x){for(let $ of Q9)x.addEventListener($,(z)=>z.stopPropagation())}var Z9=["keydown","keyup","keypress"],J9=["vitrinkaHud","vitrinkaSheet"],t4=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),V9=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),X9=new Set(["text","search","email","url","tel","password","number"]);function G9(x){let $=x.key.length===1;if($&&x.getModifierState?.("AltGraph"))return!0;if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return $||t4.has(x.key);if(t4.has(x.key))return!0;return(x.ctrlKey||x.metaKey)&&!x.altKey&&V9.has(x.code)}function j9(x){if(typeof x!=="object"||x===null)return!1;if("isContentEditable"in x&&x.isContentEditable===!0)return!0;let $="tagName"in x&&typeof x.tagName==="string"?x.tagName:"";if($==="TEXTAREA")return!0;return $==="INPUT"&&"type"in x&&typeof x.type==="string"&&X9.has(x.type)}function Y9(x){if(typeof x!=="object"||x===null||!("dataset"in x))return!1;let $=x.dataset;return typeof $==="object"&&$!==null&&J9.some((z)=>(z in $))}function U9(x){if(!G9(x))return!1;let $=x.composedPath();return j9($[0])&&$.some(Y9)}var s4=0,q1=null;function $3(){if(s4++,!q1&&typeof window<"u"){let $=(Q)=>{if(U9(Q))Q.stopImmediatePropagation()},z=Z9.map((Q)=>f(window,Q,$,{capture:!0}));q1=()=>{for(let Q of z)Q()}}let x=!0;return()=>{if(!x)return;if(x=!1,--s4>0)return;q1?.(),q1=null}}function z3(){let x=document.createElement("div");x.setAttribute(d0,""),x.setAttribute("data-vitrinka-hud",""),x.style.cssText=H2;let $=x.attachShadow({mode:"open"}),z=document.createElement("div");$.append(z),x3(x);let Q=$3();document.documentElement.append(x);let Z=typeof x.showPopover==="function",V=()=>{if(!Z||!x.isConnected)return;try{x.hidePopover?.()}catch{}try{x.showPopover?.()}catch{}};if(Z)x.popover="manual";V();let J=!1,X=()=>{if(J)return;J=!0,queueMicrotask(()=>{J=!1,V()})},G=(W)=>{if(W.type==="attributes")return W.target instanceof Element&&e4(W.target);for(let D of[W.addedNodes,W.removedNodes])for(let H of D){if(!(H instanceof Element))continue;if(e4(H))return!0;if(H.childElementCount>0&&H.querySelector(Q3))return!0}return!1},Y=[],F=0,q=()=>{F=0;let W=Y;if(Y=[],W.some(G))X()},U=new MutationObserver((W)=>{for(let D of W)Y.push(D);if(F===0)F=typeof requestAnimationFrame==="function"?requestAnimationFrame(q):setTimeout(q,16)});return U.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:x,mount:z,destroy:()=>{if(Q(),U.disconnect(),F!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(F);Y=[];try{x.hidePopover?.()}catch{}x.remove()}}}var Q3='dialog,[role="dialog"]';function e4(x){return x.matches(Q3)}function Z3(){let x=document.querySelectorAll("dialog[open]"),$=x[x.length-1];if($)return $;let z=document.querySelectorAll('[role="dialog"][data-state="open"]');return z[z.length-1]??null}function J3(x){let $=document.createElement("div");$.setAttribute(d0,""),$.setAttribute("data-vitrinka-sheet",""),$.style.cssText=r4;let z=$.attachShadow({mode:"open"}),Q=document.createElement("div");z.append(Q),x3($);let Z=$3();return x.append($),{mount:Q,destroy:()=>{Z(),$.remove()}}}function V3(x){if(!(x instanceof Node))return!1;let $=x instanceof Element?x:x.parentElement;return Boolean($?.closest("[data-vitrinka-hud],[data-vitrinka-sheet]"))}var X3="0.8.1";var r={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function W9(x,$){return typeof x==="number"&&Number.isInteger(x)&&x>0?x:$}function G3(x){if(typeof x!=="object"||x===null)return r;let $={...x},z=Array.isArray($.types)?$.types.filter((Q)=>typeof Q==="string"&&Q.trim()!=="").map((Q)=>Q.trim().toLowerCase()):[];return{maxBytes:W9($.maxBytes,r.maxBytes),maxCount:typeof $.maxCount==="number"&&Number.isInteger($.maxCount)&&$.maxCount>=0?$.maxCount:r.maxCount,types:z.length?z:r.types}}function F9(x,$){let z=x.type.toLowerCase(),Q=x.name.toLowerCase();return $.some((Z)=>{if(Z==="*"||Z==="*/*")return!0;if(Z.startsWith("."))return Q.endsWith(Z);if(Z.endsWith("/*"))return z.startsWith(Z.slice(0,-1));return z===Z})}function q9(x,$){return x.name===$.name&&x.size===$.size&&x.lastModified===$.lastModified}function j3(x,$,z){let Q=[],Z=null;for(let V of $){if([...x,...Q].some((J)=>q9(J,V)))continue;if(!F9(V,z.types))Z??={kind:"type",name:V.name};else if(V.size>z.maxBytes)Z??={kind:"size",name:V.name,cap:z.maxBytes};else if(x.length+Q.length>=z.maxCount)Z??={kind:"count",cap:z.maxCount};else Q.push(V)}return{files:Q,refusal:Z}}function l0(x,$){let z=(Q,Z,V)=>`${new Intl.NumberFormat($,{maximumFractionDigits:V}).format(Q)} ${Z}`;if(x<1024)return z(x,"B",0);if(x<1048576)return z(x/1024,"kB",0);return z(x/1048576,"MB",x<10485760?1:0)}function Y3(x,$,z){let Q=(V)=>{if(V.startsWith("image/"))return $.image;if(V==="application/pdf"||V===".pdf")return $.pdf;if(V.startsWith("text/"))return $.text;if(/officedocument|msword|ms-excel|ms-powerpoint|opendocument/.test(V))return $.office;return V.startsWith(".")?V:V.split("/")[1]??V},Z=x.map(Q);return new Intl.ListFormat(z,{type:"conjunction"}).format([...new Set(Z)])}function U3(x,$){let z=/^image\.(\w+)$/i.exec(x);return z?`pasted-${$}.${z[1]}`:x}var P2=["sm","md","lg"],D1={sm:0.88,md:1,lg:1.18},N2="vitrinka.report.size";function W3(){try{return globalThis.localStorage??null}catch{return null}}function O2(x){return W3()?.getItem(x)??null}function M1(x,$){try{W3()?.setItem(x,$)}catch(z){console.warn(`vitrinka: could not remember ${x} on this browser`,z)}}function F3(){let x=O2(N2);return P2.find(($)=>$===x)??"md"}function q3(x,$){let z=x.config,Q=!x.engine||z?.capturing===!1?$.captureOff:z?$.captureOn:$.captureStarting,Z=x.base;try{Z=new URL(x.base).host}catch{}return[[$.techVersion,`@vitrinka/web ${x.version}`],[$.techWindow,z?$.windowLength(z.profile.windowSec):"—"],[$.techCapture,Q],[$.techBuffer,z?`${z.profile.storage==="browser"?$.bufferBrowser:$.bufferMemory} · ${l0(z.profile.maxBytes,x.locale)}`:"—"],[$.techServer,Z]]}var D3="vitrinka.report.dock",M3=6,B2={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},D9=["br","bl","tr","tl"];function M9(x){return x==="tl"||x==="tr"?"t":"b"}function K9(x){return x==="tl"||x==="bl"?"l":"r"}function K3(){let x=O2(D3);return D9.find(($)=>$===x)??"br"}function H3(x){M1(D3,x)}function P3(x,$,z){return B2[x.y<z/2?"t":"b"][x.x<$/2?"l":"r"]}function N3(x,$){if($==="ArrowLeft"||$==="ArrowRight")return B2[M9(x)][$==="ArrowLeft"?"l":"r"];if($==="ArrowUp"||$==="ArrowDown")return B2[$==="ArrowUp"?"t":"b"][K9(x)];return null}var O3=30000,H9=4194304,P9=20000,C2=500,N9=2000,O9=2,B3={windowMs:O3,checkoutMs:O3,maxBytes:H9,maxEvents:P9,maxLaneEvents:C2},s=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function A2(x,$){return $&&$.load===x.load?$.startMs:x.lastMs}var B9=new TextEncoder,x0=!1,g3=0,S=B3,N=[],b=[],u=[],t=[],g9=0,P0=[],N0=new Map,O0=null,H0=null,i0=!1,L9=0,e=null,K1=null,L2=Promise.resolve();function L3(x=B3){if(I2(),x0=!0,g3++,S=x,e=x.store??null,N=(x.prior??[]).filter(($)=>$.kind!=="lanes").map(($)=>({id:$.id,load:$.load,startMs:$.startMs,lastMs:$.lastMs,events:[],count:$.count,bytes:$.bytes,href:$.href,route:$.route,stored:!0})),b=(x.priorLanes??[]).slice(-x.maxLaneEvents),u=[],t=[],P0=(x.prior??[]).filter(($)=>$.kind==="lanes").map(($)=>({id:$.id,lastMs:$.lastMs})),N0.clear(),O0=null,P1(Date.now()),e)K1=setInterval(H1,N9)}function C3(){H1(),I2(),x0=!1,e=null,N=[],b=[],u=[],t=[],P0=[],N0.clear(),O0=null}function A3(){return S}function _2(x){H0=x}function _3(){if(!x0)return;N=[],b=[],u=[],t=[],P0=[],N0.clear(),O0=null;let x=B.tabId;V0(($)=>$.clear(x)),H0?.()}function I3(){return L2}function H1(){if(!x0||!e)return;let x=Date.now();P1(x),R2(x);for(let $ of N){if($.stored)continue;let z=N0.get($.id)??{events:0,parts:0};if(z.events===$.events.length)continue;let Q=JSON.stringify($.events.slice(z.events)),Z=z.parts;N0.set($.id,{events:$.events.length,parts:Z+1});let V=R3($);V0((J)=>J.putWindowChunk(V,Z,Q,[]))}C9(x)}function C9(x){let $=x-S.windowMs;while(t.length>0&&t[0].lastMs<=$){let[X]=t.splice(0,1);if(X)V0((G)=>G.dropWindow(X.id))}for(let X of P0.filter((G)=>G.lastMs<=$))V0((G)=>G.dropWindow(X.id));P0=P0.filter((X)=>X.lastMs>$);let z=u;if(!z.length)return;u=[];let Q=t.at(-1);if(!Q||Q.startMs<=$)Q={id:`${s}.lanes.${++g9}`,startMs:Date.parse(z[0].ts),lastMs:0,parts:0},t.push(Q);Q.lastMs=Date.parse(z.at(-1).ts);let Z=Q.parts++,V=Q,J={id:V.id,tab:B.tabId,scope:S.scope??"",kind:"lanes",load:s,startMs:V.startMs,lastMs:V.lastMs,count:0,bytes:0,href:"",route:""};V0((X)=>X.putWindowChunk(J,Z,"[]",z))}function I2(){if(K1)clearInterval(K1);K1=null}function R3(x){return{id:x.id,tab:B.tabId,scope:S.scope??"",load:x.load,startMs:x.startMs,lastMs:x.lastMs,count:x.count,bytes:x.bytes,href:x.href,route:x.route}}function V0(x){let $=e;if(!$)return;L2=L2.then(()=>x($)).catch((z)=>{if(e!==$)return;e=null,I2(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",z)})}function g2(x){let[$]=N.splice(x,1);if(!$)return;N0.delete($.id),V0((z)=>z.dropWindow($.id))}function P1(x){while(N.length>0){let Q=N[0],Z=N[1];if(!Z&&Q.load===s)break;if(A2(Q,Z)>x-S.windowMs)break;g2(0)}if(i0)return;let $=N.at(-1);if($&&$.load===s&&H0&&$.lastMs<=x-S.windowMs){i0=!0;try{H0()}finally{i0=!1}let Q=N.indexOf($);if(Q>=0&&Q<N.length-1)for(let Z=Q;Z>=0;Z--)g2(Z)}let z=!1;while(N.length>0&&A9()){if(N.length===1&&N[0].load===s&&!z&&H0){z=!0,i0=!0;try{H0()}finally{i0=!1}if(N.length>1)continue}g2(0),O0=N[0]?.startMs??x}}function S3(){return x0?`flight:${g3}`:null}function R2(x){let $=Math.min(N[0]?.startMs??Number.POSITIVE_INFINITY,x-S.windowMs),z=b.findIndex((Q)=>Date.parse(Q.ts)>=$);if(z===-1)b=[];else if(z>0)b=b.slice(z)}function A9(){let x=0,$=0;for(let z of N)x+=z.bytes,$+=z.count;return x>S.maxBytes||$>S.maxEvents}function T3(x){if(!x0)return;let $=N[0];if(M2(x)){let Q=globalThis.location?.pathname??B.pathname,Z={id:`${s}.${++L9}`,load:s,startMs:x.timestamp,lastMs:x.timestamp,events:[],count:0,bytes:0,href:x.data.href,route:J0(Q)};N.push(Z);let V=R3(Z);V0((J)=>J.putWindow(V))}let z=N.at(-1);if(!z||z.load!==s)return;if(z.events.push(x),z.count++,z.lastMs=Math.max(z.lastMs,x.timestamp),z.bytes+=B9.encode(JSON.stringify(x)).length,P1(x.timestamp),N[0]!==$)R2(x.timestamp)}function f3(x,$,z){if(!x0)return null;let Q=S.keepLane?S.keepLane(x,$):$;if(Q===null)return null;let Z=new Date().toISOString(),V={ts:Z,tabId:z.tabId,tabHost:z.tabHost,kind:x,payload:Q},J=S.maxLaneEvents;if(b.push(V),b.length>J)b.splice(0,b.length-J);if(e){if(u.push(V),u.length>J)u.splice(0,u.length-J)}return Z}function N1(){if(!x0)return null;let x=Date.now();return P1(x),R2(x),{windows:N.map(($)=>({...$,events:$.events.slice()})),lanes:b.slice(),truncated:O0!==null&&O0>x-S.windowMs}}function S2(x){return x.windows.some(($)=>$.events[1]?.type===O9)}var T2=null;function O1(){if(!T2)T2=typeof indexedDB>"u"?_9():I9();return T2}function _9(){let x=new Map;return{durable:!1,put:async($,z)=>void x.set($,z),get:async($)=>x.get($)??null,delete:async($)=>void x.delete($),keys:async()=>[...x.keys()]}}function I9(){let x,$=()=>{return x??=new Promise((Q,Z)=>{let V=indexedDB.open("vitrinka.recorder.blobs",1);V.onupgradeneeded=()=>V.result.createObjectStore("blobs"),V.onerror=()=>Z(V.error??Error("vitrinka: blob journal did not open")),V.onsuccess=()=>{let J=V.result;J.onversionchange=()=>{J.close(),x=void 0},J.onclose=()=>{x=void 0},Q(J)}}).catch((Q)=>{throw x=void 0,Q}),x},z=async(Q,Z)=>{let V=$(),J;try{J=(await V).transaction("blobs",Q)}catch(G){if(x===V)x=void 0;throw G}let X=Z(J.objectStore("blobs"));return new Promise((G,Y)=>{J.oncomplete=()=>G(X.result),J.onabort=J.onerror=()=>Y(J.error??X.error??Error("vitrinka: blob journal transaction failed"))})};return{durable:!0,put:async(Q,Z)=>void await z("readwrite",(V)=>V.put(Z,Q)),get:async(Q)=>{let Z=await z("readonly",(V)=>V.get(Q));return Z instanceof Blob?Z:null},delete:async(Q)=>void await z("readwrite",(Z)=>Z.delete(Q)),keys:async()=>(await z("readonly",(Q)=>Q.getAllKeys())).filter((Q)=>typeof Q==="string")}}var R9=2000,w2=20000,u3=200,S9=4194304,T9=3145728,S1=500,f9=S9-1024,b9=12582912,E9=10485760,w9=b9-64,y9=1048576,k9=new TextEncoder;function T0(x){return k9.encode(x).length}var A=()=>R();function d(x,$){let z=A().getString(x);if(!z)return $;try{return JSON.parse(z)}catch{return $}}var b3=!1;function l(x,$){try{return A().set(x,$),!0}catch(z){if(!b3)b3=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",z);return!1}}var L1="rec",j0;function _(){if(j0===void 0)j0=d(L1,null);return j0}function c3(x){if(j0=x,x===null)A().remove(L1),A().remove(p9);else l(L1,JSON.stringify(v9(x)))}var p9="notes";var n0=null;function v9(x){if(n0?.sessionId!==x.sessionId)return x;return{...x,paused:!0,activeMs:n0.activeMs,resumeAt:null,stopping:n0.at}}var h9=new Set;function m9(){for(let x of h9)try{x()}catch($){console.warn("vitrinka: before-stop hook failed",$)}}function u9(x){let $=null;if(x)try{$=JSON.parse(x)}catch{return"unchanged"}let z=_();if($?.stopping&&$.sessionId===z?.sessionId&&!z.paused&&n0?.sessionId!==$.sessionId)m9();if(!$){if(!z)return"unchanged";return j0=null,m3(),x7(),"ended"}if(z?.sessionId===$.sessionId){if($.seq=Math.max($.seq,z.seq),$.policy===void 0&&z.policy!==void 0)$.policy=z.policy;if($.attachments===void 0&&z.attachments!==void 0)$.attachments=z.attachments;if(n0?.sessionId===$.sessionId)$.paused=z.paused,$.activeMs=z.activeMs,$.resumeAt=z.resumeAt,delete $.stopping;return j0=$,"updated"}return j0=$,m3(),"joined"}var c9=700,Y0,c=null,Q0=!1;function g0(){if(Y0===void 0)Y0=d("buffer",[]);return Y0}function T1(){if(c)clearTimeout(c),c=null;if(Y0!==void 0&&!Q0)l("buffer",JSON.stringify(Y0))}function d3(){if(Q0=!1,c)return;c=setTimeout(()=>{c=null,T1(),l3()},c9)}function E3(x){Y0=x,Q0=!1,T1()}var B0,C0=0;function X0(){if(B0===void 0)B0=d("chunks",[]),C0=B0.reduce((x,$)=>x+$.body.length,0);return B0}function l3(){if(Q0)return;let x=X0();if(x.length===0){A().remove("chunks");return}if(C0>y9){A().remove("chunks");return}l("chunks",JSON.stringify(x))}function d9(x){B0=x,C0=x.reduce(($,z)=>$+z.body.length,0),Q0=!1,l3()}var C1,A0=new Map,L0=new Set,_0=new Map,B1=new Map,w3=5,l9=200,i9=67108864,o9=0,y3=!1,n9="blobs";function E(){return C1??=d("images",[]),C1}function i3(){if(Q0)return;let x=E().filter(($)=>!L0.has($.blob));if(x.length===0)A().remove("images");else l("images",JSON.stringify(x))}function o3(x){C1=x,Q0=!1,i3()}function a9(x,$){let z=O1();if(!z.durable&&!y3)y3=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");l(n9,"1");let Q=[];return{drafts:$.map(({blob:V,payload:J})=>{let X=`${x}/${t3}.${++o9}`;return A0.set(X,V),L0.add(X),Q.push(z.put(X,V).then(()=>{if(!(A0.has(X)||E().some((Y)=>Y.blob===X)||[..._0.values()].includes(X)))return L0.delete(X),y2(X),!1;if(!z.durable)return!1;if(L0.delete(X),E().some((Y)=>Y.blob===X))i3();return!0},(G)=>{return console.warn("vitrinka: an attached image could not be journaled — it will not survive a reload",G),!1})),{blob:X,payload:J}}),journaled:Promise.all(Q).then((V)=>V.every(Boolean))}}function y2(x){O1().delete(x).catch(($)=>console.warn("vitrinka: blob journal delete failed",$))}function I0(x,$){for(let z of x)if(A0.delete(z),L0.delete(z),B1.delete(z),$)y2(z)}var A1=(x)=>x.kind==="event"?(x.images??[]).map(($)=>$.blob):[];var r9=0,n3="",a3=0,k3=-1;function k2(){r9=Date.now(),a3=0,n3=""}function R0(x){a3++,n3=String(x instanceof Error?x.message:x).slice(0,200)}var p3={actions:0,pages:0,frames:0,notes:0},t9=new Set;function s9(x){let $={...p3};for(let z of x)if(z.kind==="click")$.actions++;else if(z.kind==="nav")$.pages++;else if(z.kind==="rrweb")$.frames+=typeof z.payload?.count==="number"?z.payload.count:1;else if(z.kind==="note"){if($.notes++,typeof z.payload?.cid==="string")t9.add(z.payload.cid)}p3=$}function e9(x){let $=_();if(!$||$.dead)return;if($.dead=!0,$.deadReason=x,!$.paused&&$.resumeAt)$.activeMs=($.activeMs||0)+(Date.now()-Date.parse($.resumeAt)),$.resumeAt=null;c3($),console.warn("vitrinka: session marked dead —",x),o()}var f2=null;function x7(){if(f2)clearInterval(f2);f2=null}function r3(x){let $=_();if(!$||$.dead||x<1)return null;let z=d("seq",null),Q=Math.max($.seq,z?.sessionId===$.sessionId?z.seq:0)+1;return A().set("seq",JSON.stringify({sessionId:$.sessionId,seq:Q+x-1})),$.seq=Q+x-1,c3($),{seq:Q,sessionId:$.sessionId}}var t3=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,_1="allocation.",$7=0,w=new Set,z7=16777216,I1=0,R1=0,S0=new Map;function f1(x){return x.kind==="event"?1+(x.images?.length??0):1}function Q7(x,$){return new Set(Array.from({length:f1($)},(z,Q)=>x+Q))}function p2(x,$,z){return JSON.stringify(z&&z.size<f1(x)?{draft:x,seq:$,left:[...z]}:{draft:x,seq:$})}var v3=!1,o0=null;function g1(x){if(!w.delete(x))return;if(I1-=x.bytes,x.draft.kind==="chunk")R1--}function s3(x){if(w.add(x),I1+=x.bytes,x.draft.kind==="chunk")R1++;while(w.size>w2||I1>z7||R1>u3){let $=w.values().next().value;g1($),A().remove($.key),I0(A1($.draft),!0);let z=Error("vitrinka: pending allocation budget full — oldest capture dropped");R0(z),console.warn(z.message)}}function e3(x=!1){if(v3&&!x)return;v3=!0;let $=A();if(!$.withLock)return;let z=new Set([...w].map((Q)=>Q.key));for(let Q of $.keys?.()??[]){if(!Q.startsWith(_1)||z.has(Q)||S0.has(Q))continue;let Z=d(Q,null);if(Z&&Z.draft&&Z.draft.sessionId===_()?.sessionId)s3({...Z,key:Q,persisted:!0,bytes:T0(JSON.stringify(Z))})}}function x6(x,$,z){let{ts:Q,tabId:Z,tabHost:V,sessionId:J}=x,X=(G)=>!z||z.has(G);if(x.kind==="event"){let G=x.images??[],Y=$+G.length,F=G.length?{...x.event,payload:{...x.event.payload,attachments:G.map((U,W)=>$+W)}}:x.event,q=g0();if(X(Y)&&!q.some((U)=>U.seq===Y))q.push({seq:Y,ts:Q,tabId:Z,tabHost:V,...F});if(G.length){let U=E();G.forEach((D,H)=>{let K=$+H;if(!X(K)||U.some((P)=>P.seq===K))return;if(q.some((P)=>P.seq===K)){_0.set(K,D.blob);return}U.push({seq:K,ts:Q,tabId:Z,tabHost:V,sessionId:J,blob:D.blob,payload:D.payload})});let W=U.reduce((D,H)=>D+H.payload.bytes,0);while(U.length>l9||W>i9){let D=U.shift();W-=D.payload.bytes,z0(D.sessionId,new Set([D.seq])),I0([D.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${D.payload.name} (seq ${D.seq}); its note lands without it`)}o3(U)}if(q.length>w2){let U=q.splice(0,q.length-w2);z0(J,new Set(U.map((W)=>W.seq))),console.warn(`vitrinka: retry buffer full — dropped ${U.length} oldest events`)}}else{let G=X0();if(!G.some((Y)=>Y.seq===$)&&!g0().some((Y)=>Y.seq===$))G.push({seq:$,ts:Q,tabId:Z,tabHost:V,sessionId:J,...x.part}),C0+=x.part.body.length;while(G.length>u3){let Y=G.shift();C0-=Y.body.length,z0(J,new Set([Y.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${Y.seq}`)}}d3(),G0()}function z0(x,$){for(let[z,Q]of S0){if(Q.sessionId!==x)continue;let Z=Q.seqs.size;for(let J of Q.seqs)if($.has(J))Q.seqs.delete(J);let V=Q.seqs.size&&Q.seqs.size<Z&&Q.persisted?d(z,null):null;if(V){let J=new Set([...Q.seqs].filter((X)=>!V.left||V.left.includes(X)));if(J.size)l(z,p2(V.draft,V.seq,J));else Q.seqs.clear()}if(Q.seqs.size===0){A().remove(z),S0.delete(z);let J=z.slice(_1.length,z.lastIndexOf(".")),X=`tab.${J}`,G=d(X,null);if(G?.departed&&G.recoverable&&!A().keys?.().some((Y)=>Y.startsWith(`${_1}${J}.`)))A().remove(X)}}}function $6(){if(o0)return o0;let x=A();return o0=v2(Promise.resolve().then(async()=>{for(let $ of w)await x.withLock("seq",()=>{if(!w.has($))return;if($.persisted){let Z=d($.key,null);if(!Z){g1($),I0(A1($.draft),!1);return}$.seq=Z.seq,$.left=Z.left}if(u9(x.getString(L1)??null),_()?.sessionId!==$.draft.sessionId){g1($),I0(A1($.draft),!0);return}let z=$.seq??r3(f1($.draft))?.seq;if(z===void 0)return;$.seq=z;let Q=$.left?new Set($.left):Q7(z,$.draft);if($.persisted)x.set($.key,p2($.draft,z,Q));S0.set($.key,{sessionId:$.draft.sessionId,seqs:Q,persisted:$.persisted}),x6($.draft,z,Q),g1($)})}).catch(($)=>{throw R0($),console.warn("vitrinka: seq allocation failed — capture kept for retry",$),G0(),o(),$})).finally(()=>{o0=null}),o0}function z6(x,$){let z=_(),Q=x.kind==="event"&&x.event.kind==="note";if(!z||z.dead||z.paused&&!Q)return!1;if(e3(),A().withLock){let Z=`${_1}${t3}.${++$7}`,V=JSON.stringify({draft:x}),J={key:Z,draft:x,persisted:!$&&l(Z,V),bytes:T0(V)};s3(J),$6(),$?.then((X)=>{if(X)Z7(J)})}else{let Z=r3(f1(x));if(Z)x6(x,Z.seq);else I0(A1(x),!0)}return!0}function Z7(x){let $=S0.get(x.key);if($)$.persisted=l(x.key,p2(x.draft,x.seq,$.seqs));else if(w.has(x))x.persisted=l(x.key,JSON.stringify({draft:x.draft}))}var h3=new Set;function v2(x){return h3.add(x),x.catch(()=>{return}).finally(()=>{h3.delete(x)})}function $0(x){return _()?.sessionId!==x.sessionId}function a0(x,$,z,Q=[]){if(k0.following)return null;let Z=_();if(!Z)return f3(x,$,z);if(Z.dead||Z.paused&&x!=="note")return null;let V=new Date().toISOString(),{tabId:J,tabHost:X}=z,G=Q.length?a9(Z.sessionId,Q):null;return z6({sessionId:Z.sessionId,ts:V,tabId:J,tabHost:X,kind:"event",event:{kind:x,payload:$},...G?{images:G.drafts}:{}},G?.journaled),h2(),V}function Q6(x){g0().push(x),h2(),d3(),G0()}var J7=Date.now();function h2(){J7=Date.now()}function m2(x,$=E9,z=w9){let Q=[],Z=[],V=[],J=2,X=()=>{if(!V.length)return;Q.push({count:V.length,body:`[${V.join(",")}]`}),V=[],J=2};for(let G of x){let Y=JSON.stringify(G),F=T0(Y)+1;if(F>z){Z.push(F);continue}if(F>$){X(),Q.push({count:1,body:`[${Y}]`});continue}if(V.length&&J+F>$)X();V.push(Y),J+=F}return X(),{parts:Q,dropped:Z}}function Z6(x,$){if(!x.length)return 0;let z=_();if(!z||z.paused||z.dead||k0.following)return 0;let{parts:Q,dropped:Z}=m2(x);for(let G of Z)console.warn(`vitrinka: rrweb event (${G} bytes) exceeds the chunk cap — dropped`),a0("note",{text:`⚠ rrweb event dropped (${(G/1048576).toFixed(1)} MiB > chunk cap) — replay may be incomplete from here`},$);let V=new Date().toISOString(),{tabId:J,tabHost:X}=$;for(let G of Q)if(!z6({sessionId:z.sessionId,ts:V,tabId:J,tabHost:X,kind:"chunk",part:G}))return 0;return h2(),Q.length}async function V7(x=5){let $=X0();if($.length===0)return!0;let z=_(),Q=0,Z=new Set;for(let V of $){if(Q>=x)break;if(Q++,!z||V.sessionId!==z.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${V.seq} from ended session ${V.sessionId}`),Z.add(V.seq);continue}try{let J=await _4(z.sessionId,V.seq,V.body);if($0(z))return X0().length===0;Q6({seq:V.seq,ts:V.ts,tabId:V.tabId,tabHost:V.tabHost,kind:"rrweb",payload:{count:V.count},blobKey:J.blobKey}),k2(),Z.add(V.seq)}catch(J){if($0(z))return X0().length===0;if(J instanceof L&&m(J.status)){console.warn(`vitrinka: rrweb chunk seq ${V.seq} rejected permanently (${J.status}) — dropped`),z0(V.sessionId,new Set([V.seq])),Z.add(V.seq);continue}R0(J),console.warn("vitrinka: chunk upload failed",J);break}}if(Z.size)d9(X0().filter((V)=>!Z.has(V.seq)));return X0().length===0}async function X7(x=4){let $=E();if($.length===0)return!0;let z=_(),Q=0,Z=new Set,V=[];for(let J of $){if(Q>=x)break;if(Q++,!z||J.sessionId!==z.sessionId){console.warn(`vitrinka: dropping attachment seq ${J.seq} from ended session ${J.sessionId}`),Z.add(J.seq),V.push(J.blob);continue}let X=A0.get(J.blob)??null;if(!X){try{X=await O1().get(J.blob),B1.delete(J.blob)}catch(G){if($0(z))return E().length===0;let Y=(B1.get(J.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${Y}/${w3})`,G),Y<w3){B1.set(J.blob,Y),R0(G);break}}if($0(z))return E().length===0}if(!X){console.warn(`vitrinka: attachment seq ${J.seq} (${J.payload.name}) lost its bytes — its note lands without it`),z0(J.sessionId,new Set([J.seq])),Z.add(J.seq),V.push(J.blob);continue}try{let G=await I4(z.sessionId,J.seq,X);if($0(z))return E().length===0;Q6({seq:J.seq,ts:J.ts,tabId:J.tabId,tabHost:J.tabHost,kind:"attachment",payload:{...J.payload},blobKey:G.blobKey}),A0.delete(J.blob),_0.set(J.seq,J.blob),k2(),Z.add(J.seq)}catch(G){if($0(z))return E().length===0;if(G instanceof L&&m(G.status)){console.warn(`vitrinka: attachment seq ${J.seq} rejected permanently (${G.status}) — dropped`),z0(J.sessionId,new Set([J.seq])),Z.add(J.seq),V.push(J.blob);continue}R0(G),console.warn("vitrinka: attachment upload failed",G);break}}if(Z.size)T1(),o3(E().filter((J)=>!Z.has(J.seq)));return I0(V,!0),E().length===0}var b2=null;function G0(){if(b2)return;b2=setTimeout(()=>{b2=null,G7()},R9)}var E2=!1;async function G7(x={}){if(E2)return!1;E2=!0;try{return await j7(x)}finally{E2=!1}}async function j7(x){if(_()?.dead)return!1;if(e3(!0),w.size)await $6();if(w.size)return!1;let $=await V7(),z=x.keepalive?E().length===0:await X7(),Q=$&&z;if(!Q)G0();let Z=_(),V=g0();if(!Z||V.length===0)return Q;let J=[],X=new Set,G=0,Y=x.keepalive?61440:T9;for(let U of V){if(J.length>=S1)break;let W=T0(JSON.stringify(U))+1;if(W>f9){console.warn(`vitrinka: event seq ${U.seq} (${W} bytes) exceeds the wire cap — dropped`),X.add(U.seq);continue}if(W>Y){if(x.keepalive)break;if(J.length===0)J.push(U),G=W;break}if(J.length>0&&G+W>Y)break;J.push(U),G+=W}if(X.size){if(z0(Z.sessionId,X),E3(g0().filter((U)=>!X.has(U.seq))),!J.length)return G0(),!1}if(!J.length)return!1;T1();try{await n("POST",`/api/v1/sessions/${Z.sessionId}/events`,{events:J},x)}catch(U){if($0(Z))return!1;if(U instanceof L&&m(U.status))return e9(`server rejected this session (${U.status})`),!1;return R0(U),o(),console.warn("vitrinka: flush failed, retrying",U),G0(),!1}if($0(Z))return!0;k2(),k3=Math.max(k3,...J.map((U)=>U.seq)),s9(J);let F=new Set(J.map((U)=>U.seq));z0(Z.sessionId,F);let q=g0().filter((U)=>!F.has(U.seq));E3(q),o();for(let U of F){let W=_0.get(U);if(W===void 0)continue;_0.delete(U),y2(W)}if(q.length)G0();return!0}function m3(){if(c)clearTimeout(c),c=null;Y0=[],B0=[],C0=0,C1=[],A0.clear(),L0.clear(),_0.clear(),w.clear(),I1=R1=0,S0.clear(),Q0=!0}var Y7=8192,r0="__vitrinkaRecorderConsolePatched";function b1(x){return x.map(($)=>{if(typeof $==="string")return $;if($ instanceof Error)return $.stack??$.message;try{return JSON.stringify($)}catch{return String($)}}).join(" ").slice(0,Y7)}function E1(x,$="error"){if(!x||x.startsWith("vitrinka:"))return;a0("console",{level:$,text:i4(x)},{tabId:B.tabId,tabHost:B.tabHost})}var u2="__vitrinkaRecorderConsoleUnpatch",J6={};function V6(){let x=globalThis;if(x[r0]!==void 0&&x[r0]!==J6)return;x[u2]?.()}function X6(x={}){let $=globalThis;if($[r0])return;$[r0]=J6;let z=console.error,Q=z.bind(console),Z=(...Y)=>{Q(...Y);try{E1(b1(Y))}catch{}};console.error=Z;let V=(x.levels??[]).map((Y)=>{let F=console[Y],q=F.bind(console),U=(...W)=>{q(...W);try{E1(b1(W),Y)}catch{}};return console[Y]=U,()=>{if(console[Y]===U)console[Y]=F}}),J=(Y)=>{try{E1(b1([Y.error??Y.message]))}catch{}},X=(Y)=>{try{E1(`unhandled rejection: ${b1([Y.reason])}`)}catch{}},G=typeof addEventListener==="function";if(G)addEventListener("error",J),addEventListener("unhandledrejection",X);$[u2]=()=>{if(console.error===Z)console.error=z;for(let Y of V)Y();if(G)removeEventListener("error",J),removeEventListener("unhandledrejection",X);delete $[r0],delete $[u2]}}var G6=65536,t0=524288,j6=3000;var c2="full";function l2(){if(k0.following)return null;let x=_();if(x)return!x.paused&&!x.dead?x.sessionId:null;return S3()}function s0(x){return x!==null&&l2()===x}function w1(x,$){if(typeof x==="string")return q2(x,G6,$);if(typeof URLSearchParams<"u"&&x instanceof URLSearchParams)return q2(x.toString(),G6,"application/x-www-form-urlencoded");return U7(x)}function U7(x){if(x==null)return;if(typeof FormData<"u"&&x instanceof FormData){let $=0;try{x.forEach(()=>$++)}catch{}return`[formdata body omitted: ${$} field(s)]`}if(typeof Blob<"u"&&x instanceof Blob)return`[blob body omitted: ${x.size} bytes${x.type?`, ${x.type}`:""}]`;if(x instanceof ArrayBuffer)return`[buffer body omitted: ${x.byteLength} bytes]`;if(ArrayBuffer.isView(x))return`[buffer body omitted: ${x.byteLength} bytes]`;if(typeof ReadableStream<"u"&&x instanceof ReadableStream)return"[stream body omitted]";return`[${typeof x} body omitted]`}function d2(x){for(let[$,z]of Object.entries(x??{}))if($.toLowerCase().replace(/[-_]/g,"")==="contenttype")return z;return""}function i2(x){return typeof x==="string"||x instanceof URL?{}:x}function e0(x){let $=typeof x.url==="string"?J0(x.url):x.url;a0("net",{...x,url:$},{tabId:B.tabId,tabHost:B.tabHost})}function o2(x){if(!x)return;try{let $={},z=x;if(typeof z.forEach==="function")if(Array.isArray(x)){for(let Q of x)if(Array.isArray(Q)&&Q.length>=2)$[String(Q[0])]=String(Q[1])}else z.forEach((Q,Z)=>{$[Z]=String(Q)});else if(typeof x==="object")for(let[Q,Z]of Object.entries(x))$[Q]=String(Z);return Object.keys($).length>0?$:void 0}catch{return}}function W7(x,$){let z=o2($?.headers);if(z)return z;let Q=i2(x);return o2(Q.headers)}function F7(x){if(!x)return;let $={};for(let z of x.split(/\r?\n/)){let Q=z.indexOf(":");if(Q>0)$[z.slice(0,Q).trim()]=z.slice(Q+1).trim()}return Object.keys($).length>0?$:void 0}function n2(x){try{x.body?.cancel?.().catch(()=>{return})}catch{}}function q7(x){let $=x.get("content-length");if(!$)return null;let z=Number($);return Number.isFinite(z)?z:null}async function D7(x,$){let z=await M7(x,$);if(z===void 0)return;let Q="";try{Q=$.get("content-type")??""}catch{}return w1(z,Q)}async function M7(x,$){let z=q7($);if(z!==null&&z>t0)return n2(x),`[body omitted: ${z} bytes]`;let Q=x.body;if(Q?.getReader){let Z=Q.getReader(),V=[],J=0,X=!1,G=!1,Y=Date.now()+j6;try{while(J<t0){let W=Y-Date.now();if(W<=0){G=!0;break}let D,H=await Promise.race([Z.read(),new Promise((O)=>{D=setTimeout(()=>O("timeout"),W)})]).finally(()=>{if(D!==void 0)clearTimeout(D)});if(H==="timeout"){G=!0;break}let{done:K,value:P}=H;if(K)break;if(P){let O=t0-J,M=P.byteLength>O?P.subarray(0,O):P;V.push(M),J+=M.byteLength}}X=J>=t0,Z.cancel().catch(()=>{return})}catch{return}let F=new Uint8Array(J),q=0;for(let W of V)F.set(W,q),q+=W.byteLength;let U;try{U=new TextDecoder().decode(F)}catch{return`[body omitted: ${J} bytes, undecodable]`}if(G)return`${U}…[body read timed out after ${j6}ms]`;return X?`${U}…[truncated at ${t0} bytes]`:U}if(z===null)return n2(x),"[body omitted: length-less response, no stream API]";try{return await x.text()}catch{return}}var x1="__vitrinkaRecorderNetPatched",a2="__vitrinkaRecorderNetUnpatch",Y6={};function U6(){let x=globalThis;if(x[x1]!==void 0&&x[x1]!==Y6)return;x[a2]?.()}function W6(x={}){let $=globalThis;if($[x1])return;$[x1]=Y6,c2=x.detail??"full";let z=[];$[a2]=()=>{for(let U of z.splice(0))U();delete $[x1],delete $[a2]};let Q=globalThis.fetch,Z=async(U,W)=>{let D=typeof U==="string"?U:U instanceof URL?U.href:U.url,H=l2();if(V2(D)||H===null)return Q(U,W);let K=W?.method??("method"in i2(U)?i2(U).method:"GET"),P=Date.now();try{let O=await Q(U,W),M=Date.now()-P;if(c2==="meta"){if(s0(H))e0({method:K,url:D,status:O.status,ms:M,via:"fetch"});return O}let I;try{I=O.clone()}catch{I=void 0}let{headers:f0,status:b0}=O;return v2((async()=>{if(!s0(H)){if(I)n2(I);return}let J1=I?await D7(I,f0):void 0;if(!s0(H))return;let E0=W7(U,W);e0({method:K,url:D,status:b0,ms:M,reqHeaders:c0(E0),resHeaders:c0(o2(f0)),reqBody:w1(W?.body,d2(E0)),resBody:J1,via:"fetch"})})()),O}catch(O){if(s0(H))e0({method:K,url:D,error:String(O),ms:Date.now()-P,via:"fetch"});throw O}};globalThis.fetch=Z,z.push(()=>{if(globalThis.fetch===Z)globalThis.fetch=Q});let V=globalThis.XMLHttpRequest;if(!V?.prototype)return;let J=V.prototype.open,X=V.prototype.send,G=V.prototype.setRequestHeader;z.push(()=>{let U=V.prototype;if(U.open===Y)U.open=J;if(U.send===q)U.send=X;if(U.setRequestHeader===F)U.setRequestHeader=G});let Y=V.prototype.open=function(...U){return this.__vt={method:U[0],url:String(U[1])},J.apply(this,U)},F=V.prototype.setRequestHeader=function(U,W){let D=this.__vt;if(D)(D.reqHeaders??={})[U]=W;return G?.call(this,U,W)},q=V.prototype.send=function(U){let W=this.__vt,D=l2();if(W&&!V2(W.url)&&D!==null){let H=Date.now();this.addEventListener("loadend",()=>{if(!s0(D))return;if(c2==="meta"){e0({method:W.method,url:W.url,status:this.status,ms:Date.now()-H,via:"xhr"});return}let K;try{K=F7(this.getAllResponseHeaders())}catch{K=void 0}let P;try{P=this.responseType===""||this.responseType==="text"?w1(this.responseText,d2(K)):void 0}catch{P=void 0}e0({method:W.method,url:W.url,status:this.status,ms:Date.now()-H,reqHeaders:c0(W.reqHeaders),resHeaders:c0(K),reqBody:w1(U,d2(W.reqHeaders)),resBody:P,via:"xhr"})})}return X.call(this,U)}}var K7=2000,H7=300000,z1=null,Q1=null,$1=[],y1=null;function F6(){if(!$1.length)return;let x=$1;$1=[],Z6(x,{tabId:B.tabId,tabHost:B.tabHost})}function Z1(){return Q1}function q6(x,$,z={}){if(z1)return;let Q=n4(),Z=z.unmaskSelector;try{z1=x({emit:$==="flight"?(J)=>T3(K2(J)):(J)=>{$1.push(K2(J))},checkoutEveryNms:$==="flight"?A3().checkoutMs:H7,inlineImages:!1,collectFonts:!0,maskAllInputs:Q.maskAllInputs,...Q.maskTextSelector?{maskTextSelector:Q.maskTextSelector}:{},...Q.maskTextSelector&&Z?{maskTextFn:(J,X)=>{try{if(X?.closest(Z))return J}catch{}return J.replace(/\S/g,"*")}}:{},blockSelector:`[${d0}]`})??null}catch(V){console.warn("vitrinka: rrweb failed to start",V);return}if(Q1=x,$==="flight")_2(k1);if($==="session")y1=setInterval(F6,K7)}function D6(){if(y1)clearInterval(y1);y1=null,F6();try{z1?.()}catch{}z1=null,Q1=null,_2(null),$1=[]}function k1(){if(!z1||!Q1)return;try{Q1.takeFullSnapshot?.(!0)}catch{}}var H6="vitrinka.capture",y="windows",k="chunks";function U0(x){return new Promise(($,z)=>{x.oncomplete=()=>$(),x.onabort=x.onerror=()=>z(x.error??Error("vitrinka: capture store transaction failed"))})}function r2(x){return new Promise(($,z)=>{x.onsuccess=()=>$(x.result),x.onerror=()=>z(x.error??Error("vitrinka: capture store request failed"))})}function M6(x){return IDBKeyRange.bound([x,0],[x,Number.MAX_SAFE_INTEGER])}function K6(x){if(typeof x!=="object"||x===null)return!1;let $=x;return typeof $.id==="string"&&typeof $.tab==="string"&&typeof $.startMs==="number"&&typeof $.lastMs==="number"}function P6(x=globalThis.indexedDB){if(!x)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise(($,z)=>{let Q=x.open(H6,1);Q.onupgradeneeded=()=>{Q.result.createObjectStore(y,{keyPath:"id"}),Q.result.createObjectStore(k)},Q.onerror=()=>z(Q.error??Error("vitrinka: capture store did not open")),Q.onblocked=()=>z(Error("vitrinka: capture store is blocked by another tab")),Q.onsuccess=()=>$(Q.result)}).then(($)=>{$.onversionchange=()=>$.close();let z=(Z,V)=>{Z.objectStore(y).delete(V),Z.objectStore(k).delete(M6(V))};return{async putWindow(Z){let V=$.transaction(y,"readwrite");V.objectStore(y).put(Z),await U0(V)},async putChunk(Z,V,J,X){let G=$.transaction(k,"readwrite"),Y={events:J,lanes:[...X]};G.objectStore(k).put(Y,[Z,V]),await U0(G)},async putWindowChunk(Z,V,J,X){let G=$.transaction([y,k],"readwrite"),Y={events:J,lanes:[...X]};try{G.objectStore(k).put(Y,[Z.id,V]),G.objectStore(y).put(Z)}catch(F){throw G.abort(),F}await U0(G)},async dropWindow(Z){let V=$.transaction([y,k],"readwrite");z(V,Z),await U0(V)},async clear(Z){let V=$.transaction([y,k],"readwrite"),J=await r2(V.objectStore(y).getAll());for(let X of J)if(K6(X)&&X.tab===Z)z(V,X.id);await U0(V)},async sweep(Z,V,J,X){let G=$.transaction([y,k],"readwrite"),Y=(await r2(G.objectStore(y).getAll())).filter(K6),F=[],q=new Map;for(let U of Y)q.set(U.tab,[...q.get(U.tab)??[],U]);for(let[U,W]of q){let D=W.filter((K)=>K.kind!=="lanes").sort((K,P)=>K.startMs-P.startMs),H=(K)=>K.kind==="lanes"?K.lastMs:A2(K,D[D.indexOf(K)+1]);for(let K of W.sort((P,O)=>P.startMs-O.startMs))if(H(K)<=Z-V||U===J&&K.scope!==X)z(G,K.id);else if(U===J)F.push(K)}return await U0(G),F},async read(Z){let V=$.transaction(k,"readonly"),J=await r2(V.objectStore(k).getAll(M6(Z)));await U0(V);let X=[],G=[];for(let Y of J)X.push(...JSON.parse(Y.events)),G.push(...Y.lanes);return{events:X,lanes:G}},close:()=>$.close()}})}function N6(x=globalThis.indexedDB){try{x?.deleteDatabase(H6)}catch($){console.warn("vitrinka: could not delete the capture store",$)}}function t2(x,$){return{x:Math.min(x.x,$.x),y:Math.min(x.y,$.y),w:Math.abs($.x-x.x),h:Math.abs($.y-x.y)}}function s2(x,$){return`${$.y<x.y?"n":"s"}${$.x<x.x?"w":"e"}`}function e2(x,$){let z=x.x,Q=x.x+x.w,Z=x.y,V=x.y+x.h,J={x:$.endsWith("w")?z:Q,y:$.startsWith("n")?Z:V};return{tail:{x:$.endsWith("w")?Q:z,y:$.startsWith("n")?V:Z},tip:J}}function O6(x,$,z){if(x==="arrow")return Math.hypot(z.x-$.x,z.y-$.y)>=16;return Math.abs(z.x-$.x)>=8&&Math.abs(z.y-$.y)>=8}function B6(x){return x.map(($,z)=>({...$,n:z+1}))}function g6(x){return x.map(($)=>({n:$.n,shape:$.shape,rect:{x:Math.round($.rect.x),y:Math.round($.rect.y),w:Math.round($.rect.w),h:Math.round($.rect.h)},...$.note.trim()?{note:$.note.trim()}:{},...$.shape==="arrow"&&$.head?{head:$.head}:{}}))}var P7=2,N7=3,O7=0,B7=5,x5=2,g7=3,L7=2000000000,C7="data-vitrinka-hidden",A7="#1b1b1f";function _7(x,$){let z=`position:fixed;left:${Math.round(x.x)}px;top:${Math.round(x.y)}px;width:${Math.round(x.w)}px;height:${Math.round(x.h)}px;background:${A7};z-index:2147483647;pointer-events:none;`;return{type:x5,id:L7+$,tagName:"div",attributes:{[C7]:"",style:z},childNodes:[]}}function $5(x,$,z,Q){let Z={...x};if(x.type===g7&&$.has(x.id))Z.textContent="";if(x.attributes&&$.has(x.id)&&"value"in x.attributes)Z.attributes={...x.attributes,value:""};if(x.childNodes){if(Z.childNodes=x.childNodes.map((V)=>$5(V,$,z,Q)),!Q.done&&x.type===x5&&x.tagName==="body")Z.childNodes.push(...z),Q.done=!0}return Z}function I7(x,$){(x.childNodes?.find((Q)=>Q.type===x5)??x).childNodes?.push(...$)}function R7(x,$){return $5(x,$,[],{done:!0})}function L6(x,$,z){if(!$.length&&!z.size)return x.slice();let Q=$.map(_7);return x.map((Z)=>{let V=Z.data;if(Z.type===P7&&V.node){let J={done:!1},X=$5(V.node,z,Q,J);if(!J.done)I7(X,Q);return{...Z,data:{...Z.data,node:X}}}if(Z.type!==N7||!z.size)return Z;if(V.source===O7){let J=Z.data,X={...J,...J.texts?{texts:J.texts.map((G)=>z.has(G.id)?{...G,value:""}:G)}:{},...J.adds?{adds:J.adds.map((G)=>({...G,node:R7(G.node,z)}))}:{},...J.attributes?{attributes:J.attributes.map((G)=>z.has(G.id)&&("value"in G.attributes)?{...G,attributes:{...G.attributes,value:""}}:G)}:{}};return{...Z,data:X}}if(V.source===B7){let J=Z.data;if(z.has(J.id))return{...Z,data:{...J,text:""}}}return Z})}function S7(x,$){return x.x>=$.x&&x.x<=$.x+$.w&&x.y>=$.y&&x.y<=$.y+$.h}function T7(x){return{x:x.left+x.width/2,y:x.top+x.height/2}}function z5(x,$,z=document){let Q=new Set;if(!x.length||!$||!z.body)return Q;let Z=(G)=>G.width>0&&G.height>0&&x.some((Y)=>S7(T7(G),Y)),V=(G)=>{let Y=$.getId(G);if(Y>0)Q.add(Y)},J=z.createTreeWalker(z.body,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),X=z.createRange();for(let G=J.nextNode();G;G=J.nextNode())if(G.nodeType===Node.TEXT_NODE){if(!G.textContent?.trim())continue;if(X.selectNodeContents(G),Z(X.getBoundingClientRect()))V(G)}else if(G instanceof HTMLInputElement||G instanceof HTMLTextAreaElement||G instanceof HTMLSelectElement){if(Z(G.getBoundingClientRect()))V(G)}return X.detach(),Q}var f7=["errors","interactions","full","console","network"];var p1={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function m1(x){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:x===!1?["errors"]:["errors","interactions"]}}function v1(x,$,z){return Math.min(z,Math.max($,x))}function b7(x){if(!Array.isArray(x))return null;return f7.filter(($)=>x.includes($))}function C6(x,$){if(typeof x!=="object"||x===null)return m1($);let z=x;return{storage:z.storage==="browser"?"browser":z.storage==="memory"?"memory":p1.storage,windowSec:typeof z.windowSec==="number"&&Number.isFinite(z.windowSec)?v1(Math.round(z.windowSec),10,3600):p1.windowSec,maxBytes:typeof z.maxBytes==="number"&&Number.isFinite(z.maxBytes)?v1(Math.round(z.maxBytes),262144,67108864):p1.maxBytes,classes:b7(z.classes)??p1.classes}}function h1(x){let $=x.includes("full");return{replay:$||x.includes("interactions"),errors:$||x.includes("errors"),console:$||x.includes("console"),network:$||x.includes("network")}}function E7(x){let $=[];if(x.errors)$.push("errors");if(x.replay)$.push("interactions");if(x.console)$.push("console");if(x.network)$.push("network");return $}function A6(x,$){if(!$)return x;let z=typeof $.windowSec==="number"&&$.windowSec>0?Math.min(x.windowSec,$.windowSec):x.windowSec,Q=typeof $.maxBytes==="number"&&$.maxBytes>0?Math.min(x.maxBytes,$.maxBytes):x.maxBytes,Z=x.classes;if($.classes){let V=h1(x.classes),J=h1($.classes);Z=E7({replay:V.replay&&J.replay,errors:V.errors&&J.errors,console:V.console&&J.console,network:V.network&&J.network})}return{storage:$.storage==="memory"?"memory":x.storage,windowSec:v1(z,10,3600),maxBytes:v1(Q,262144,67108864),classes:Z}}function _6(x){return x==="balanced"||x==="full"?x:"strict"}function I6(x){if(x==="full")return{fullFidelity:!0};if(x==="balanced")return{};return{maskAllText:!0}}var R6="[data-vitrinka-unmask]";var w7=3670016,S6=4194240,y7=2000,T6=500,k7=60000,p7=/[A-Za-z0-9_-]{20,}/g;function i(x,$=""){return typeof x==="string"?x:$}function v7(x){let $=i(x),z;try{z=new URL($,globalThis.location?.href??"http://localhost").pathname}catch{z=$.split(/[?#]/)[0]??""}return z.replace(p7,"•••").slice(0,300)}var h7=4;function m7(x,$){let z=[],Q=!1,Z=[],V=!1,J=()=>{if(V)Q=!0;else z.push(...Z);Z=[],V=!1};for(let X of x){if(X.type===h7&&Z.length)J();if(!V&&T0(JSON.stringify(X))+1>$)V=!0;Z.push(X)}return J(),{events:z,dropped:Q}}function u7(x){return($,z)=>{if($==="console"){let Q=i(z?.level,"error");if(Q==="error"?!(x.errors||x.console):!x.console)return null;return{level:Q,text:i(z?.text).slice(0,y7)}}if($==="net"){let Q=typeof z?.status==="number"?z.status:0,Z=Q===0||Q>=400||z?.error!==void 0;if(!(x.network||x.errors&&Z))return null;return{method:i(z?.method,"GET").toUpperCase(),path:v7(z?.url),status:Q,ms:typeof z?.ms==="number"?Math.max(0,Math.round(z.ms)):0}}return null}}async function c7(x){try{let $=await n("GET","/api/v1/report-config",void 0,{target:x}),z=typeof $.flightRecorder==="boolean"?$.flightRecorder:void 0;return{project:i($.project),profile:$.captureProfile==null?m1(z):C6($.captureProfile,z),masking:_6($.profile),reachable:!0,attachments:G3(typeof $.captureProfile==="object"&&$.captureProfile!==null&&"attachments"in $.captureProfile?$.captureProfile.attachments:$.attachments)}}catch($){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",$),{project:"",profile:m1(),masking:"strict",reachable:!1,attachments:r}}}function f6(x){let $=x?.mirror;if(typeof $!=="object"||$===null)return null;let z=$.getId;return typeof z==="function"?{getId:(Q)=>Number(z.call($,Q))}:null}class b6{opts;ready;store=null;stopped=!1;claim=null;config=null;listeners=new Set;capturing=!1;offs=[];capture=[];constructor(x){this.opts=x;this.ready=this.start()}async start(){let{opts:x}=this;this.offs.push(W4(x.base));let $=await c7({url:x.base,key:x.key}),z=A6($.profile,x.capture),Q=h1(z.classes),Z={project:$.project,profile:z,lanes:Q,masking:$.masking,reachable:$.reachable,capturing:!1,attachments:$.attachments};if(this.stopped)return Z;if(this.config=Z,this.claim=V4("report",()=>this.standDown()),!this.claim)return console.warn("vitrinka: the recorder runs this page’s capture — Report a problem sends without one"),Z;this.capturing=!0,Z.capturing=!0,J4(Z4(),globalThis.location?.host??""),B.pathname=globalThis.location?.pathname??"/",l4(I6(Z.masking)),D2(x.sanitizeUrl),this.capture.push(()=>D2(null));let V=z.windowSec*1000,J=[x.base,$.project,Z.masking,z.classes.join(",")].join("|"),X=[],G=[];if(z.storage==="browser")try{this.store=await P6();let Y=await this.store.sweep(Date.now(),V,B.tabId,J);X=Y;let F=this.store;G=(await Promise.all(Y.filter((U)=>U.kind==="lanes").map((U)=>F.read(U.id)))).flatMap((U)=>U.lanes).sort((U,W)=>Date.parse(U.ts)-Date.parse(W.ts))}catch(Y){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",Y),this.store=null,X=[],G=[]}else N6();if(!this.capturing)return this.store?.close(),this.store=null,Z;if(L3({windowMs:V,checkoutMs:Math.min(k7,V),maxBytes:z.maxBytes,maxEvents:Math.max(20000,Math.round(z.maxBytes/200)),maxLaneEvents:C2,keepLane:u7(Q),store:this.store,scope:J,prior:X,priorLanes:G}),this.capture.push(C3),this.store&&typeof window<"u"){let Y=()=>H1();this.capture.push(f(window,"pagehide",Y),f(document,"visibilitychange",Y))}if(Q.errors||Q.console)X6({levels:Q.console?["warn","info","log"]:[]}),this.capture.push(V6);if(Q.errors||Q.network)W6({detail:"meta"}),this.capture.push(U6);if(Q.replay){let Y=await x.loadRecord(x.base).catch((F)=>{return console.warn("vitrinka: the page recorder did not load — reports go without a replay",F),null});if(Y&&this.capturing)q6(Y,"flight",{unmaskSelector:R6}),this.capture.push(D6)}return Z}onChange(x){return this.listeners.add(x),()=>this.listeners.delete(x)}standDown(){if(!this.capturing)return;if(this.capturing=!1,this.config)this.config.capturing=!1;for(let $ of this.capture.splice(0).reverse())$();let x=this.store;if(this.store=null,x)I3().then(()=>x.close());for(let $ of this.listeners)$()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};B.pathname=globalThis.location?.pathname??B.pathname;let x=N1();if(x&&Z1()&&!S2(x))k1(),x=N1();let $=this.store,z=x?.windows.filter((Z)=>Z.stored).map((Z)=>Z.id)??[],Q=$&&z.length?Promise.all(z.map(async(Z)=>[Z,await $.read(Z)])).then((Z)=>new Map(Z)):Promise.resolve(new Map);return Q.catch(()=>{return}),{clip:x,stored:Q}}withScreen(x){if(!this.capturing||!Z1()||x&&S2(x))return x;k1();let $=N1();if(!$)return x;return{windows:[...x?.windows.filter((z)=>z.stored)??[],...$.windows.filter((z)=>!z.stored)],lanes:x?.lanes??$.lanes,truncated:x?.truncated??$.truncated}}hiddenIdsAt(x){if(!this.capturing)return null;let $=f6(Z1());return $?z5([x],$):null}async build(x,$,z=new Set){let Q=$.filter((M)=>M.shape==="hide").map((M)=>M.rect),Z=f6(Z1()),V=Q.length>0&&!Z;if(V)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let J=new Set(z);if(Q.length&&Z)for(let M of z5(Q,Z))J.add(M);let X=[],G=this.withScreen(x.clip),Y=G?.truncated??!1,F=await x.stored.catch((M)=>{return console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",M),null});for(let M of G?.windows??[]){if(!M.stored){X.push(...M.events);continue}let I=F?.get(M.id);if(!I?.events.length)Y=!0;else X.push(...I.events)}let q=G?.lanes??[],U=V?{events:[],dropped:!1}:m7(L6(X,Q,J),S6);if(U.dropped)Y=!0;let{parts:W,dropped:D}=m2(U.events,w7,S6),H=[],K=0;for(let M of W){K+=M.count;let I=U.events[K-1]?.timestamp??Date.now();H.push({seq:H.length+1,ts:new Date(I).toISOString(),count:M.count,body:M.body})}let P=q.filter((M)=>M.kind==="console").slice(-T6).map((M)=>({level:i(M.payload?.level,"error"),ts:M.ts,text:i(M.payload?.text)})),O=q.filter((M)=>M.kind==="net").slice(-T6).map((M)=>({method:i(M.payload?.method,"GET"),path:i(M.payload?.path),status:typeof M.payload?.status==="number"?M.payload.status:0,ms:typeof M.payload?.ms==="number"?M.payload.ms:0}));return{chunks:H,truncated:Y||D.length>0,console:P,network:O}}clear(){if(this.capturing)_3()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),X4(this.claim),this.claim=null;for(let x of this.offs.splice(0).reverse())x()}}var v=null;function E6(x){if(v){let $=v.engine.opts;if(!($.base===x.base&&$.key===x.key&&$.sanitizeUrl===x.sanitizeUrl&&JSON.stringify($.capture??{})===JSON.stringify(x.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 v.refs++,v.engine}return v={engine:new b6(x),refs:1},v.engine}function w6(x){if(!x||!v||v.engine!==x)return;if(--v.refs>0)return;v=null,x.stop()}var d7=/^[\w-]+\.[\w-]+\.[\w-]+$/;function u1(x){if(!x)return null;if("token"in x){let Q=typeof x.token==="string"?x.token.trim():"";if(Q.length>4096||!d7.test(Q))return console.warn("vitrinka: identify({token}) needs the compact JWS your server signed — reporting anonymously"),null;return{token:Q}}let $=typeof x.email==="string"?x.email.trim().slice(0,254):"";if(!$.includes("@"))return console.warn("vitrinka: identify({email}) needs an email address — reporting anonymously"),null;let z=typeof x.name==="string"?x.name.trim().slice(0,200):"";return z?{email:$,name:z}:{email:$}}var y6=null,Q5=new Set;function l7(x){y6=u1(x);for(let $ of Q5)$()}function k6(){return y6}function p6(x){return Q5.add(x),()=>Q5.delete(x)}var i7=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),c1="report.keybind";function v6(x){if(i7.has(x.key))return{kind:"wait"};if(x.key==="Escape"&&!x.altKey&&!x.ctrlKey&&!x.metaKey&&!x.shiftKey)return{kind:"cancel"};if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return{kind:"bare"};return{kind:"bind",bind:{code:x.code,alt:x.altKey,ctrl:x.ctrlKey,meta:x.metaKey,shift:x.shiftKey}}}function h6(x,$){return x.code===$.code&&x.altKey===$.alt&&x.ctrlKey===$.ctrl&&x.metaKey===$.meta&&x.shiftKey===$.shift}var o7={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function n7(x){let $=/^Key([A-Z])$/.exec(x);if($)return $[1];let z=/^(?:Digit|Numpad)(\d)$/.exec(x);if(z)return z[1];return o7[x]??x}function a7(){let x=globalThis.navigator,$=x?.userAgentData?.platform??x?.platform??"";return/mac|iphone|ipad/i.test($)}function d1(x,$=a7()){let z=n7(x.code);if($)return`${x.ctrl?"⌃":""}${x.alt?"⌥":""}${x.shift?"⇧":""}${x.meta?"⌘":""}${z}`;return[x.ctrl&&"Ctrl",x.alt&&"Alt",x.shift&&"Shift",x.meta&&"Meta",z].filter(Boolean).join("+")}function m6(x){if(!x)return null;try{let $=JSON.parse(x);if(typeof $!=="object"||$===null)return null;let z=$;if(typeof z.code!=="string"||!z.code)return null;let Q={code:z.code,alt:z.alt===!0,ctrl:z.ctrl===!0,meta:z.meta===!0,shift:z.shift===!0};return Q.alt||Q.ctrl||Q.meta?Q:null}catch{return null}}function u6(){return m6(R().getString(c1))}function Z5(x){let $=R();if(x)$.set(c1,JSON.stringify(x));else $.remove(c1)}function c6(x){let $=R();return $.watch?$.watch(c1,(z)=>x(m6(z))):()=>{return}}var r7=["br","bl","tr","tl"];function J5(x,$){let z=x==="br"||x==="tr"?$.vw-$.w-$.edge:$.edge,Q=x==="br"||x==="bl"?$.vh-$.h-$.bottom:$.top;return{x:Math.max($.edge,z),y:Math.max($.top,Q),w:$.w,h:$.h}}function t7(x,$){let z=Math.min(x.x+x.w,$.x+$.w+12)-Math.max(x.x,$.x-12),Q=Math.min(x.y+x.h,$.y+$.h+12)-Math.max(x.y,$.y-12);return z>0&&Q>0?z*Q:0}function d6(x,$,z){let Q=J5(x,z);return $.reduce((Z,V)=>Z+t7(Q,V),0)}function l6(x,$,z){let Q=d6(x,$,z);if(Q===0)return x;let Z=x,V=Q;for(let J of r7){let X=d6(J,$,z);if(X<V)Z=J,V=X}return Z}async function i6(x,$,z,Q,Z){let V=await fetch(z.url+$,{method:x,mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${z.key}`,...Z?{"x-vitrinka-reporter":Z}:{},...Q!==void 0?{"content-type":"application/json"}:{}},body:Q===void 0?void 0:JSON.stringify(Q)}),J=await V.text();if(!V.ok)throw new L(`${x} ${$} → ${V.status}: ${J}`,V.status);return J?JSON.parse(J):{}}function o6(x,$){return i6("POST","/api/v1/report/session",x,{token:$})}function n6(x,$=Date.now()){return x!==null&&Date.parse(x.expiresAt)-$>60000}function V5(x,$,z){let Q=z?`?cursor=${encodeURIComponent(z)}`:"";return i6("GET",`/api/v1/report/mine${Q}`,x,void 0,$)}function a6(x,$){return`vitrinka.report.sent:${x}|${$}`}function r6(){try{return globalThis.localStorage??null}catch{return null}}function X5(x,$){let z=r6()?.getItem(a6(x,$));if(!z)return[];try{let Q=JSON.parse(z);if(!Array.isArray(Q))return[];return Q.filter((Z)=>typeof Z?.title==="string"&&typeof Z?.at==="number"&&(Z.status==="filed"||Z.status==="quarantined"))}catch{return[]}}function t6(x,$,z){let Q=r6();if(!Q)return;let Z=[z,...X5(x,$)].slice(0,20);try{Q.setItem(a6(x,$),JSON.stringify(Z))}catch(V){console.warn("vitrinka: could not remember the sent report on this browser",V)}}var s6=`
|
|
10
10
|
:host { all: initial; }
|
|
11
11
|
.vr {
|
|
12
12
|
--ink: #f2f1ef;
|
|
@@ -137,8 +137,13 @@ kbd {
|
|
|
137
137
|
display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 8px;
|
|
138
138
|
background: transparent; color: var(--ink); font-size: 13.5px; font-weight: 550; text-decoration: none; text-align: left;
|
|
139
139
|
}
|
|
140
|
-
.pop-item:hover, .pop-item:focus-visible { background: var(--faint); }
|
|
140
|
+
.pop-item:hover:not([aria-disabled="true"]), .pop-item:focus-visible { background: var(--faint); }
|
|
141
|
+
/* A waiting item stays focusable (aria-disabled) so the arrows reach its reason; it only looks unavailable. */
|
|
142
|
+
.pop-item[aria-disabled="true"] { color: var(--dim); cursor: default; }
|
|
141
143
|
.pop-item svg { width: 15px; height: 15px; flex: none; color: var(--dim); }
|
|
144
|
+
/* Why an item waits (Record over an unsent report): a second line under the label, aligned past the icon. */
|
|
145
|
+
.pop-item:has(.pop-why:not([hidden])) { flex-wrap: wrap; row-gap: 2px; height: auto; min-height: 36px; padding: 8px 10px; }
|
|
146
|
+
.pop-why { flex-basis: 100%; padding-left: 25px; font-size: 12px; font-weight: 450; line-height: 1.35; }
|
|
142
147
|
.acc-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; }
|
|
143
148
|
.acc-who strong { font-size: 14px; }
|
|
144
149
|
.acc-mail, .acc-via { color: var(--dim); font-size: 12.5px; margin: 0; }
|
|
@@ -381,13 +386,14 @@ a.row:hover { background: var(--faint); }
|
|
|
381
386
|
.seg button { padding: 0 9px; }
|
|
382
387
|
.coach { width: 260px; }
|
|
383
388
|
}
|
|
389
|
+
/* Every motion of the face stops here: the menu rises with the card's vr-in, the coach dims as you press, the chevron turns. */
|
|
384
390
|
@media (prefers-reduced-motion: reduce) {
|
|
385
|
-
.card { animation: none; }
|
|
386
|
-
.card.parked, .seg-ind, .seg button, .kinds button, .pin .rm { transition: none; }
|
|
391
|
+
.card, .pop { animation: none; }
|
|
392
|
+
.card.parked, .seg-ind, .seg button, .kinds button, .pin .rm, .link svg, .coach { transition: none; }
|
|
387
393
|
.card.busy .head::after { animation: none; }
|
|
388
394
|
.fab, .fab.gliding { transition: none; }
|
|
389
395
|
.coach .loop { animation: none; stroke-dashoffset: 0; }
|
|
390
396
|
.coach .hold { animation: none; opacity: .9; }
|
|
391
397
|
}
|
|
392
|
-
`;class
|
|
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};
|
|
398
|
+
`;var e6={ms:30000,bytesPerMs:32};class x8 extends Error{constructor(x,$){super(`vitrinka: ${x} got no answer in ${Math.round($/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function G5(x,$,z){let Q=new AbortController,Z,V=new Promise((J,X)=>{Z=setTimeout(()=>{let G=new x8(x,$);Q.abort(G),X(G)},$)});try{return await Promise.race([z(Q.signal),V])}finally{clearTimeout(Z)}}var j5={chunks:[],truncated:!1,console:[],network:[]};function $8(x,$=e6.ms){return G5("preparing the capture",$,x).catch((z)=>{return console.warn("vitrinka: the capture could not be prepared — the report goes without it",z),j5})}class Y5{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(x,$,z,Q=[],Z=e6){this.capture=x;this.tabHost=$;this.target=z;this.files=Q;this.limits=Z}call(x,$,z){return G5(`${x} ${$}`,this.limits.ms,(Q)=>n(x,$,z,{target:this.target,signal:Q}))}upload(x,$,z){let Q=typeof z==="string"?new TextEncoder().encode(z).byteLength:z.size,Z=this.limits.ms+Math.ceil(Q/this.limits.bytesPerMs);return G5(`POST ${x}`,Z,(V)=>j2(x,$,z,this.target,V))}get filesPending(){return this.filesDone.size<this.files.length}async run(x){let $={title:x.title,description:x.description,markers:x.markers,notify:x.notify??!1},z=JSON.stringify($);if(!this.id){let Z=await this.call("POST","/api/v1/reports",x).catch((V)=>{if(x.type===void 0||!(V instanceof L)||V.status!==400||!/\btype\b/.test(V.message))throw V;console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:J,...X}=x;return this.call("POST","/api/v1/reports",X)});if(typeof Z.id!=="string"||!Z.id)throw Error("vitrinka: the server filed the report without an id");this.id=Z.id,this.custody=Z.custody==="direct"?"direct":"quarantined",this.sent=z}else if(this.sent!==z)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,$),this.sent=z;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(Z){if(!(Z instanceof L)||!m(Z.status))throw Z;console.warn("vitrinka: the server refused the recording — the report goes without it",Z),this.skipCapture=!0}let Q=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:Q.status==="filed"?"filed":"quarantined",...typeof Q.reportUrl==="string"&&Q.reportUrl?{reportUrl:Q.reportUrl}:{}}}async sendFiles(){let x=encodeURIComponent(this.id);for(let[$,z]of this.files.entries()){if(this.filesDone.has($))continue;try{await this.upload(`/api/v1/reports/${x}/attachment?name=${encodeURIComponent(z.name)}`,z.type||"application/octet-stream",z)}catch(Q){if(!(Q instanceof L)||!m(Q.status))throw Q;console.warn(`vitrinka: the server refused ${z.name} — the report goes without it`,Q)}this.filesDone.add($)}}async sendCapture(){let x=encodeURIComponent(this.id),{chunks:$,truncated:z}=this.capture;for(let Z of $){if(this.blobKeys.has(Z.seq))continue;let V=await this.upload(`/api/v1/reports/${x}/chunk?seq=${Z.seq}`,"application/json",Z.body);if(!V.blobKey)throw Error(`vitrinka: chunk ${Z.seq} came back without a blob key`);this.blobKeys.set(Z.seq,V.blobKey)}let Q=$.map((Z)=>({seq:Z.seq,ts:Z.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:Z.count,source:"replay",truncated:z},blobKey:this.blobKeys.get(Z.seq)??""}));while(this.rowsPosted<Q.length){let Z=Q.slice(this.rowsPosted,this.rowsPosted+S1);await this.call("POST",`/api/v1/reports/${x}/events`,{events:Z}),this.rowsPosted+=Z.length}}}var s7="http://www.w3.org/2000/svg",z8=100,e7=["circle","box","arrow","hide"],U5={w:160,h:80},Q8=16,Z8={w:380,h:460},l1=72,W5=16,x$={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},g={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>'},J8="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14";function $$(x){let $=x?"":`<animateMotion dur="2.8s" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="0;0.18;0.72;1" calcMode="linear" path="${J8}"/>`;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="${J8}" pathLength="200"/><g class="pointer"${x?' 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"/>${$}</g></svg>`}function j(x,$={},...z){let Q=document.createElement(x);for(let[Z,V]of Object.entries($))Q.setAttribute(Z,V);return Q.append(...z),Q}function C(x){let $=document.createElement("template");$.innerHTML=x;let z=$.content.firstElementChild;if(!z)throw Error("vitrinka: icon markup is empty");return z}function p(x,$){let z=document.createElementNS(s7,x);for(let[Q,Z]of Object.entries($))z.setAttribute(Q,String(Z));return z}function V8(x){let $=x.split(`
|
|
399
|
+
`)[0]?.trim()??"";return $.length>z8?`${$.slice(0,z8-1)}…`:$}function G8(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function F5(){let x=document.activeElement;while(x?.shadowRoot?.activeElement)x=x.shadowRoot.activeElement;if(x===document.body)return null;return x instanceof HTMLElement||x instanceof SVGElement?x:null}function z$(x){return(x.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((z)=>z[0]?.toUpperCase()??"").join("")||"?"}function h(x,$){let z=x.querySelector("span");if(z)z.textContent=$}function X8(x,$,z,Q=!1){if(!z||!z.offsetWidth)return;let Z=Q||!x.classList.contains("measured");if(Z)$.style.transition="none";if($.style.width=`${z.offsetWidth}px`,$.style.transform=`translateX(${z.offsetLeft}px)`,x.classList.add("measured"),!Z)return;$.offsetWidth,$.style.removeProperty("transition")}function Q$(){let x=F5();return x instanceof HTMLInputElement||x instanceof HTMLTextAreaElement||x instanceof HTMLElement&&x.isContentEditable}function Z$(x){let $=j("span"),z=j("kbd"),Q=j("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},$,z),Z=j("h2",{id:"vr-title"}),V=j("span",{class:"av","aria-hidden":"true"}),J=j("span",{class:"who-name"}),X=j("button",{class:"who",type:"button","aria-haspopup":"dialog","aria-expanded":"false"},V,J),G=j("button",{class:"icon",type:"button","aria-haspopup":"menu","aria-expanded":"false"},C(g.dots)),Y=j("button",{class:"icon",type:"button"},C(g.close)),F=j("header",{class:"head"},Z,X,G,Y),q=j("strong"),U=j("span",{class:"acc-mail"}),W=j("p",{class:"acc-via"}),D=j("p",{class:"acc-linked"}),H=j("button",{class:"link",type:"button"}),K=j("button",{class:"pop-item",type:"button"},C(g.link),j("span")),P=j("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},C(g.ext),j("span")),O=j("div",{class:"pop acc",role:"dialog"},j("div",{class:"acc-who"},q,U,W),j("div",{class:"acc-member"},D,H),K,P),M=(T)=>j("button",{class:"pop-item",type:"button",role:"menuitem"},C(T),j("span")),I=M(g.list),f0=M(g.clock),b0=M(g.rec),J1=j("small",{class:"pop-why",id:"vr-record-why","aria-hidden":"true"});b0.append(J1);let E0=M(g.gear),M5=j("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},C(g.ext),j("span")),K5=j("div",{class:"pop more",role:"menu"},I,f0,b0,E0,M5),H5=j("span",{class:"sr",id:"vr-kinds"}),n1=new Map;for(let T of L4)n1.set(T,j("button",{type:"button",role:"radio","aria-checked":"false","data-kind":T}));let P5=j("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},H5,...n1.values()),N5=j("label",{class:"prompt",for:"vr-desc"}),O5=j("textarea",{class:"desc",id:"vr-desc",rows:"3"}),B5=j("ol",{class:"lines"}),g5=j("p",{class:"ln-empty"}),L5=j("span"),C5=j("span"),A5=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},C5,C(g.chevron)),_5=j("div",{class:"attached"},C(g.clip),L5,j("span",{"aria-hidden":"true"},"·"),A5),I5=j("ul",{class:"included",id:"vr-included"}),R5=j("input",{type:"checkbox"}),S5=j("span"),T5=j("label",{class:"notify"},R5,S5),f5=j("p",{class:"error",role:"alert"}),b5=j("span"),E5=j("button",{class:"where",type:"button","aria-pressed":"false"},C(g.pen),b5),w5=j("button",{class:"send",type:"button"}),y5=j("div",{class:"pane describe"},P5,N5,O5,j("div",{class:"lines-wrap"},B5,g5),_5,I5,T5,f5),k5=j("button",{class:"icon",type:"button"},C(g.clip)),p5=j("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),v5=j("p",{class:"file-note",role:"status"}),h5=j("ul",{class:"files"}),m5=j("div",{class:"tray"},v5,h5),u5=j("div",{class:"foot"},k5,p5,E5,w5),c5=j("span",{class:"label",id:"vr-bind-label"}),d5=j("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),l5=j("button",{class:"link",type:"button"}),i5=j("p",{class:"hint"}),o5=j("p",{class:"reason",role:"status"}),n5=j("button",{class:"link",type:"button"}),a5=j("span",{class:"label",id:"vr-size-label"}),a1=new Map;for(let T of P2)a1.set(T,j("button",{type:"button",role:"radio","aria-checked":"false","data-size":T}));let r5=j("span",{class:"seg-ind","aria-hidden":"true"}),t5=j("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},r5,...a1.values()),s5=j("span"),e5=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},s5,C(g.chevron)),xx=j("dl",{class:"tech",id:"vr-tech"}),$x=j("div",{class:"pane settings"},j("div",{class:"row"},c5,d5),o5,i5,j("div",{class:"row size-row"},a5,t5),j("div",{class:"tech-wrap"},e5,xx),j("div",{class:"settings-foot"},n5,l5)),zx=j("h3"),Qx=j("p",{class:"sent-body"}),Zx=j("span"),Jx=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Zx),Vx=j("button",{class:"link",type:"button"}),Xx=j("div",{class:"pane sent",role:"status"},j("div",{class:"sent-head"},C(g.check),zx),Qx,j("div",{class:"sent-actions"},Jx,Vx)),r1=()=>j("button",{class:"back",type:"button"},C(g.left),j("span")),Gx=r1(),jx=j("p",{class:"list-status"}),Yx=j("ul",{class:"rows"}),Ux=j("p",{class:"list-note"}),Wx=j("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),Fx=j("div",{class:"pane list"},Gx,jx,Yx,Ux,Wx),qx=r1(),Dx=j("p",{class:"list-status"}),Mx=j("ul",{class:"rows"}),Kx=j("div",{class:"pane list"},qx,Dx,Mx),Hx=r1(),Px=j("p",{class:"list-note"}),Nx=j("div",{class:"code"}),Ox=j("span"),Bx=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Ox),gx=j("img",{class:"qr",alt:""}),Lx=j("p",{class:"hint"}),Cx=j("p",{class:"list-status",role:"status"}),Ax=j("button",{class:"link",type:"button"}),_x=j("div",{class:"pane linking"},Hx,Px,Nx,j("div",{class:"link-go"},Bx,gx),Lx,Cx,Ax),Ix=j("div",{class:"body"},y5,$x,Xx,Fx,Kx,_x),Rx=j("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},F,O,K5,Ix,m5,u5),t1=p("svg",{class:"ink","aria-hidden":"true"}),Sx=p("defs",{}),Tx=p("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});Tx.append(p("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),Sx.append(Tx);let fx=p("g",{}),bx=p("g",{class:"draft"});t1.append(Sx,fx,bx);let Ex=j("div",{class:"pins"}),wx=j("p"),yx=j("p"),kx=j("p",{class:"keys",id:"vr-keys"}),s1=j("div",{class:"coach",role:"status"});s1.append(C($$(G8())),wx,yx,kx);let e1=new Map,px=new Map;for(let T of e7){let ax=j("span");px.set(T,ax),e1.set(T,j("button",{type:"button",role:"radio","aria-checked":"false","data-tool":T},C(g[T]),ax))}let vx=j("span",{class:"seg-ind","aria-hidden":"true"}),hx=j("div",{class:"seg",role:"radiogroup"},vx,...e1.values()),mx=j("span",{class:"tb-lead"}),ux=j("button",{type:"button",class:"tb-quiet"}),cx=j("span",{class:"tb-ask"}),dx=j("button",{type:"button",class:"tb-discard"}),lx=j("button",{type:"button",class:"tb-quiet"}),ix=j("span",{class:"tb-confirm",role:"group"},cx,dx,lx),ox=j("div",{class:"tb",role:"toolbar"},mx,hx,j("span",{class:"tb-sep","aria-hidden":"true"}),ux,ix),x2=j("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},Ex,s1,ox);x2.prepend(t1);let $2=j("div",{class:"vr"},Q,x2,Rx),nx=j("style");return nx.textContent=s6,$2.prepend(nx),x.append($2),{root:$2,fab:Q,fabLabel:$,fabKbd:z,card:Rx,head:F,title:Z,whoBtn:X,whoAv:V,whoName:J,more:G,closeBtn:Y,body:Ix,foot:u5,accountPop:O,accName:q,accMail:U,accVia:W,accLinked:D,accUnlink:H,accLink:K,accPortal:P,morePop:K5,mReports:I,mRecents:f0,mRecord:b0,mRecordWhy:J1,mSettings:E0,mOpen:M5,reports:Fx,repBack:Gx,repStatus:jx,repRows:Yx,repLocal:Ux,repPortal:Wx,recents:Kx,recBack:qx,recStatus:Dx,recRows:Mx,linking:_x,linkBack:Hx,linkLabel:Px,linkCode:Nx,linkOpen:Bx,linkOpenText:Ox,linkQr:gx,linkHint:Lx,linkWait:Cx,linkRetry:Ax,describe:y5,kinds:P5,kindsLabel:H5,kindButtons:n1,prompt:N5,desc:O5,lines:B5,linesEmpty:g5,attached:_5,attachedText:L5,disclose:A5,discloseText:C5,included:I5,notify:T5,notifyBox:R5,notifyText:S5,error:f5,where:E5,whereText:b5,send:w5,attach:k5,fileInput:p5,fileNote:v5,files:h5,tray:m5,settings:$x,bindLabel:c5,bindBtn:d5,unbind:l5,bindHint:i5,bindReason:o5,back:n5,sizeLabel:a5,sizeButtons:a1,sizeInd:r5,sizeSeg:t5,techText:s5,techBtn:e5,tech:xx,sent:Xx,sentTitle:zx,sentBody:Qx,see:Jx,seeText:Zx,sentClose:Vx,mark:x2,ink:t1,shapes:fx,draft:bx,pins:Ex,coach:s1,coachText:wx,coachMore:yx,coachKeys:kx,toolbar:ox,barLead:mx,seg:hx,segInd:vx,toolButtons:e1,toolLabels:px,cancel:ux,ask:ix,askText:cx,discard:dx,keep:lx}}class q5{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=K3();size=F3();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((x)=>x instanceof HTMLDialogElement);activeDialog(){this.dialogOrder=this.dialogOrder.filter((z)=>z.isConnected&&z.open);let x=(z)=>{try{return z.matches(":modal")}catch{return!1}};return[...this.dialogOrder].reverse().find(x)??this.dialogOrder.at(-1)??Z3()}sheet=null;e;constructor(x){this.opts=x;this.locale=x.locale??G2(),this.s=X2(this.locale),this.button=x.button,this.openSelector=x.openSelector??null,this.identity=x.identity===void 0?void 0:u1(x.identity),this.keybind=u6(),this.hud=z3(),this.e=Z$(this.hud.mount),this.engine=E6({base:x.base,key:x.key,appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl,loadRecord:x.loadRecord}),this.engine?.ready.then(($)=>{this.config=$,this.paint()}),this.bind(),this.paint(),this.followDialog()}followDialog(){let x=this.activeDialog();if((this.sheet?.target??null)===x)return;let $=this.e.root.getRootNode(),z=$ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement?$.activeElement:null,Q=this.sheet;if(x){let Z=J3(x);Z.mount.append(this.e.root),this.sheet={target:x,host:Z}}else this.hud.mount.append(this.e.root),this.sheet=null;Q?.host.destroy(),z?.focus()}open(){if(this.isOpen)return;if(this.isOpen=!0,this.opener=V3(document.activeElement)?null:F5(),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 x=this.opener;if(this.opener=null,x?.focus(),x&&F5()===x)return;if(this.button)this.e.fab.focus()}setLocale(x){let $=u0(x)??G2();if($===this.locale)return;this.locale=$,this.s=X2($),this.paint()}setButton(x){this.button=x,this.paint()}setOpenSelector(x){this.openSelector=x||null}setRecordSwitch(x){this.recordSwitch=x,this.paint()}identify(x){this.identity=x===void 0?void 0:u1(x),this.whoChanged()}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let x of this.offs.splice(0).reverse())x();w6(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let x=this.e,$=(J,X,G)=>{J.addEventListener(X,G)};$(x.fab,"click",()=>{if(this.swallowClick){this.swallowClick=!1;return}if(this.isOpen)this.close();else this.open()}),$(x.fab,"pointerdown",(J)=>this.fabDown(J)),$(x.fab,"pointermove",(J)=>this.fabMove(J)),$(x.fab,"pointerup",(J)=>this.fabUp(J,!0)),$(x.fab,"pointercancel",(J)=>this.fabUp(J,!1)),$(x.fab,"keydown",(J)=>{if(!J.altKey||J.ctrlKey||J.metaKey||J.shiftKey)return;let X=N3(this.dock,J.key);if(!X)return;if(J.preventDefault(),X!==this.dock)this.moveDock(X)}),$(x.attach,"click",()=>x.fileInput.click()),$(x.fileInput,"change",()=>{this.addFiles([...x.fileInput.files??[]]),x.fileInput.value=""}),$(x.card,"paste",(J)=>{let X=[...J.clipboardData?.files??[]];if(!X.length||!this.canAttach())return;let G=J.clipboardData?.getData("text/plain").trim()??"";if(G&&!X.some((Y)=>Y.name&&G.includes(Y.name)))return;J.preventDefault(),this.addFiles(X.map((Y)=>{let F=U3(Y.name,++this.pastes);return F===Y.name?Y:new File([Y],F,{type:Y.type,lastModified:Y.lastModified})}))}),$(x.card,"dragover",(J)=>{if(!J.dataTransfer?.types.includes("Files")||!this.canAttach())return;J.preventDefault(),J.dataTransfer.dropEffect="copy",x.card.classList.add("dropping")}),$(x.card,"dragleave",(J)=>{if(J.relatedTarget instanceof Node&&x.card.contains(J.relatedTarget))return;x.card.classList.remove("dropping")}),$(x.card,"drop",(J)=>{x.card.classList.remove("dropping");let X=[...J.dataTransfer?.files??[]];if(!X.length||!this.canAttach())return;J.preventDefault(),this.addFiles(X)});for(let[J,X]of x.sizeButtons)$(X,"click",()=>{if(this.size=J,M1(N2,J),this.paint(),this.parked)this.placeCard(!0)});$(x.techBtn,"click",()=>{this.techOpen=!this.techOpen,this.paint()}),$(x.closeBtn,"click",()=>this.close()),$(x.whoBtn,"click",()=>this.toggleMenu("account")),$(x.more,"click",()=>this.toggleMenu("more"));let z=(J)=>()=>{this.menu=null,J(),this.paint()};$(x.morePop,"keydown",(J)=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(J.key))return;let X=[...x.morePop.querySelectorAll('[role="menuitem"]')].filter((W)=>!W.hidden&&!(W instanceof HTMLButtonElement&&W.disabled));if(!X.length)return;J.preventDefault();let G=x.morePop.getRootNode(),Y=X.indexOf(G.activeElement),F=X.length-1,q=J.key==="ArrowDown",U=J.key==="Home"?0:J.key==="End"?F:Y<0?q?0:F:(Y+(q?1:-1)+X.length)%X.length;X[U]?.focus()}),$(x.mReports,"click",z(()=>void this.openReports())),$(x.mRecents,"click",z(()=>this.show("recents")));let Q=z(()=>this.recordSwitch?.());$(x.mRecord,"click",()=>{if(!this.recordWaits())Q()}),$(x.mSettings,"click",z(()=>this.show("settings"))),$(x.mOpen,"click",z(()=>{return})),$(x.accPortal,"click",z(()=>{return})),$(x.accLink,"click",z(()=>this.startLinkFlow())),$(x.accUnlink,"click",()=>{q4(),this.member=null,this.paint()});for(let J of[x.repBack,x.recBack,x.linkBack])$(J,"click",()=>this.show("describe"));$(x.linkRetry,"click",()=>this.startLinkFlow()),$(x.card,"pointerdown",(J)=>{let X=J.target;if(!this.menu||!(X instanceof Node))return;if([x.accountPop,x.morePop,x.whoBtn,x.more].some((G)=>G.contains(X)))return;this.menu=null,this.paint()}),$(x.back,"click",()=>this.show("describe")),$(x.sentClose,"click",()=>this.close()),$(x.desc,"input",()=>this.paint()),$(x.disclose,"click",()=>{this.includedOpen=!this.includedOpen,this.paint()}),$(x.notifyBox,"change",()=>{this.notify=x.notifyBox.checked}),$(x.where,"click",()=>this.marking?this.endMarking(!0):this.startMarking()),$(x.send,"click",()=>void this.send()),$(x.bindBtn,"click",()=>this.recordingBind?this.stopRecordingBind():this.startRecordingBind()),$(x.unbind,"click",()=>{this.keybind=null,Z5(null),this.paint()});for(let[J,X]of x.kindButtons)$(X,"click",()=>{this.kind=this.kind===J?null:J,this.paint()});$(x.card,"keydown",(J)=>{if(J.key!=="Escape"||this.recordingBind||J.defaultPrevented)return;if(J.preventDefault(),this.menu){let X=this.menu==="account"?x.whoBtn:x.more;this.menu=null,this.paint(),X.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close()});for(let[J,X]of x.toolButtons)$(X,"click",(G)=>{if(this.tool=J,this.renderKbDraft(),this.paint(),this.placeSeg(),G.detail===0)x.mark.focus()});if($(x.mark,"keydown",(J)=>this.markKey(J)),$(x.cancel,"click",()=>this.cancelMarking()),$(x.discard,"click",()=>{this.markers=i1(this.markers.filter((J)=>this.passKeys.has(J.key))),this.renderMarks(),this.endMarking(!0)}),$(x.keep,"click",()=>{this.confirming=!1,this.paint(),x.cancel.focus()}),$(x.mark,"pointerdown",(J)=>this.pointerDown(J)),$(x.mark,"pointermove",(J)=>this.pointerMove(J)),$(x.mark,"pointerup",(J)=>this.pointerUp(J)),$(x.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(f(x.mark,"wheel",(J)=>J.preventDefault())),this.offs.push(f(x.mark,"touchmove",(J)=>J.preventDefault())),this.offs.push(f(window,"keydown",(J)=>{if(this.recordingBind)return;if(this.marking&&J.key==="Escape"){if(J.preventDefault(),this.confirming)x.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);return}if(this.marking&&(J.metaKey||J.ctrlKey)&&!J.shiftKey&&!J.altKey&&J.key.toLowerCase()==="z"&&!Q$()){J.preventDefault(),this.markers=i1(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&h6(J,this.keybind))if(J.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(f(document,"click",(J)=>{let X=this.openSelector,G=J.target;if(!X||!(G instanceof Element))return;let Y=null;try{Y=G.closest(X)}catch{return}if(!Y)return;J.preventDefault(),this.open()})),this.offs.push(f(window,"resize",()=>{if(this.parked)this.placeCard(!0);if(this.marking)this.placeSeg()})),this.offs.push(c6((J)=>{this.keybind=J,this.paint()})),this.offs.push(p6(()=>this.whoChanged())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let Z=0,V=new MutationObserver((J)=>{for(let X of J){if(X.type!=="attributes"||X.attributeName!=="open"||!(X.target instanceof HTMLDialogElement))continue;let G=X.target;if(!G.open)this.dialogOrder=this.dialogOrder.filter((Y)=>Y!==G);else if(X.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((Y)=>Y!==G),G]}if(Z)return;Z=requestAnimationFrame(()=>{Z=0,this.followDialog()})});V.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(V.disconnect(),Z)cancelAnimationFrame(Z)})}show(x){if(this.stopRecordingBind(),x!=="link"&&this.linkFlow)this.linkFlow.abort.abort(),this.linkFlow=null;this.view=x,this.paint();let $={describe:this.e.desc,settings:this.e.bindBtn,sent:null,reports:this.e.repBack,recents:this.e.recBack,link:this.e.linkBack}[x];if($)requestAnimationFrame(()=>$.focus())}target(){return{url:this.opts.base,key:this.opts.key}}toggleMenu(x){if(this.menu=this.menu===x?null:x,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 x=this.who();if(!x||!("token"in x))return this.session=null,this.sessionToken="",null;if(this.sessionToken===x.token&&n6(this.session))return this.session;this.sessionToken=x.token;let $=null;try{$=await o6(this.target(),x.token)}catch(z){console.warn("vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only",z)}if(this.sessionToken!==x.token)return null;return this.session=$,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 x=m0(this.opts.base)?h0():null;if(!x){if(this.member)this.member=null,this.paint();return}try{let $=await n("GET","/api/v1/recorder/me",void 0,{target:{url:this.opts.base,key:x.token}});this.member={email:$.user?.email??"",name:$.user?.name??"",workspace:$.workspace?.slug??x.workspace},O4($.displayMode)}catch($){console.warn("vitrinka: the linked vitrinka account could not be read",$),this.member={email:"",name:"",workspace:x.workspace}}this.paint()}async openReports(){this.show("reports"),await this.loadReports()}async loadReports(){let x=this.whoToken(),$=await this.refreshWho();if(this.whoToken()!==x)return;if(!$){this.mine={rows:[],state:"ok"},this.paint();return}this.mine={rows:[],state:"loading"},this.paint();let z;try{z={rows:await this.listMineRenewing($),state:"ok"}}catch(Q){console.warn("vitrinka: My reports could not be loaded",Q),z={rows:[],state:"failed"}}if(this.whoToken()!==x)return;this.mine=z,this.paint()}async listMineRenewing(x){try{return(await V5(this.target(),x.session)).reports}catch($){if(!($ instanceof L)||$.status!==401)throw $;this.session=null,this.sessionToken="";let z=await this.refreshWho();if(!z)throw $;return(await V5(this.target(),z.session)).reports}}startLinkFlow(){this.linkFlow?.abort.abort();let x={start:null,state:"starting",abort:new AbortController};this.linkFlow=x,this.show("link");let $=this.opts.base,z=X1($);(async()=>{try{x.start=await z4($,{label:M4(),workspace:z}),x.state="waiting",this.paint();let Q=await Q4($,x.start.device_code,{interval:x.start.interval,expiresIn:x.start.expires_in,workspace:z,signal:x.abort.signal});F4({...Q,base:$}),this.linkFlow=null,this.show("describe"),await this.refreshMember()}catch(Q){if(x.abort.signal.aborted)return;if(x.state=Q instanceof w0?"expired":"failed",x.state==="failed")console.warn("vitrinka: linking the vitrinka account failed",Q);this.paint()}})()}ago(x){let $=new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}),z=Math.round((x-Date.now())/1000),Q=[[60,"second"],[60,"minute"],[24,"hour"],[30,"day"],[12,"month"],[1/0,"year"]],Z=z;for(let[V,J]of Q){if(Math.abs(Z)<V)return $.format(Z,J);Z=Math.round(Z/V)}return $.format(Z,"year")}row(x,$,z,Q){let Z=[j("span",{class:"row-t"},x),j("span",{class:"step"},$),j("span",{class:"age"},this.ago(z))],V=Q?j("a",{class:"row",href:Q,target:"_blank",rel:"noopener noreferrer"},...Z):j("div",{class:"row"},...Z);return j("li",{},V)}who(){return this.identity!==void 0?this.identity:k6()}whoToken(){let x=this.who();return x&&"token"in x?x.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=f(window,"keydown",(x)=>{x.preventDefault(),x.stopPropagation();let $=v6(x);if($.kind==="wait")return;if($.kind==="bare"){this.bindRefused=!0,this.paint();return}if($.kind==="bind")this.keybind=$.bind,Z5($.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??r}addFiles(x){if(!x.length)return;let{files:$,refusal:z}=j3(this.files,x,this.caps());this.files=[...this.files,...$],this.fileRefusal=z,this.renderFiles(),this.paint()}removeFile(x){this.files=this.files.filter(($)=>$!==x),this.fileRefusal=null,this.renderFiles(),this.paint(),this.e.attach.focus()}renderFiles(){let x=new Set(this.files);for(let[$,z]of this.chips){if(x.has($))continue;z.el.remove(),this.chips.delete($)}for(let $ of this.files){if(this.chips.has($))continue;let z=j("span",{class:"file-size"}),Q=j("button",{class:"ln-x",type:"button"},C(g.close)),Z=j("li",{class:"file"},j("span",{class:"file-name"},$.name),z,Q);Q.addEventListener("click",()=>this.removeFile($)),this.e.files.append(Z),this.chips.set($,{el:Z,size:z,rm:Q})}}refusalText(x){let $=this.s;if(!x)return"";if(x.kind==="size")return $.fileTooBig(x.name,l0(x.cap,this.locale));if(x.kind==="count")return $.tooManyFiles(x.cap);return $.fileType(x.name,Y3(this.caps().types,$.typeNames,this.locale))}fabDown(x){if(this.swallowClick=!1,x.button!==0||!x.isPrimary)return;let $=this.e.fab.getBoundingClientRect();this.fabDrag={pointer:x.pointerId,start:{x:x.clientX,y:x.clientY},grab:{x:x.clientX-$.left,y:x.clientY-$.top},moved:!1};try{this.e.fab.setPointerCapture(x.pointerId)}catch{}}fabMove(x){let $=this.fabDrag;if(!$||x.pointerId!==$.pointer)return;if(!$.moved&&Math.hypot(x.clientX-$.start.x,x.clientY-$.start.y)<M3)return;$.moved=!0;let z=this.e.fab;z.classList.add("dragging");let Q=z.getBoundingClientRect(),Z=globalThis.innerWidth||800,V=globalThis.innerHeight||600,J=z.style;J.left=`${Math.min(Math.max(0,x.clientX-$.grab.x),Z-Q.width)}px`,J.top=`${Math.min(Math.max(0,x.clientY-$.grab.y),V-Q.height)}px`,J.right="auto",J.bottom="auto"}fabUp(x,$){let z=this.fabDrag;if(!z||x.pointerId!==z.pointer)return;if(this.fabDrag=null,!z.moved)return;let Q=this.e.fab,Z=Q.getBoundingClientRect();Q.classList.remove("dragging");for(let X of["left","top","right","bottom"])Q.style.removeProperty(X);this.swallowClick=!0,setTimeout(()=>{this.swallowClick=!1},0);let V=globalThis.innerWidth||800,J=globalThis.innerHeight||600;this.moveDock($?P3({x:Z.left+Z.width/2,y:Z.top+Z.height/2},V,J):this.dock,Z)}moveDock(x,$){let z=this.e.fab,Q=$??z.getBoundingClientRect();if(this.dock=x,H3(x),this.paint(),z.hidden||G8())return;let Z=z.getBoundingClientRect(),V=Q.left-Z.left,J=Q.top-Z.top;if(!V&&!J)return;this.glide?.abort();let X=new AbortController;this.glide=X,z.classList.remove("gliding"),z.style.setProperty("translate",`${V}px ${J}px`),z.offsetWidth,z.classList.add("gliding"),z.style.setProperty("translate","0px 0px");let G=(Y)=>{if(Y.propertyName!=="translate")return;X.abort(),z.classList.remove("gliding"),z.style.removeProperty("translate")};z.addEventListener("transitionend",G,{signal:X.signal}),z.addEventListener("transitioncancel",G,{signal:X.signal})}startMarking(){if(this.job?.id)return;this.marking=!0,this.confirming=!1,this.passKeys=new Set(this.markers.map((z)=>z.key));let x=this.parked??this.dock;this.parkInsets=this.insetsAt(x,this.e.card.getBoundingClientRect()),this.parked=x,this.renderMarks(),this.paint(),this.placeCard(),this.placeSeg(!0);let $=globalThis.innerWidth||800;this.placeCoach({x:$/2-150,y:l1+12},!1),this.e.mark.focus()}endMarking(x){if(this.cancelDraft(),this.marking=!1,this.confirming=!1,this.paint(),x&&this.isOpen)requestAnimationFrame(()=>this.e.desc.focus())}cancelMarking(){if(this.markers.filter(($)=>!this.passKeys.has($.key)).length===0){this.endMarking(!0);return}this.confirming=!0,this.paint(),this.e.discard.focus()}insetsAt(x,$){let z=globalThis.innerWidth||800,Q=globalThis.innerHeight||600,Z=l1*D1[this.size],V=x==="br"||x==="bl";return{edge:Math.max(0,Math.min($.left,z-$.right)),top:V?Z:Math.max(Z,$.top),bottom:V?Math.max(0,Q-$.bottom):W5}}frame(){let x=globalThis.innerWidth||800,$=globalThis.innerHeight||600,z=D1[this.size],Q=this.parkInsets??{top:l1*z,bottom:W5,edge:W5},Z=this.e.card.getBoundingClientRect();return{vw:x,vh:$,w:Z.width||Math.min(Z8.w*z,x-32),h:Z.height||Math.min(Z8.h*z,$-Q.top-Q.bottom),...Q}}placeCard(x=!1){if(!this.parked)return;let $=this.frame(),z=this.parked;this.parked=l6(this.parked,this.markers.map((J)=>J.rect),$);let Q=J5(this.parked,$),Z=this.e.card,V=x&&this.parked===z;if(V)Z.style.transition="none";if(Z.classList.add("parked"),Z.style.left=`${Q.x}px`,Z.style.top=`${Q.y}px`,!V)return;Z.offsetWidth,Z.style.removeProperty("transition")}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(x=!1){X8(this.e.seg,this.e.segInd,this.e.toolButtons.get(this.tool),x)}onChrome(x){return x instanceof Node&&(this.e.toolbar.contains(x)||this.e.pins.contains(x))}pointerDown(x){if(this.onChrome(x.target)||x.button!==0||!x.isPrimary)return;x.preventDefault();let $=this.e.root.getRootNode();if($ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement)$.activeElement.blur();this.drawing={start:{x:x.clientX,y:x.clientY},shape:this.tool,pointer:x.pointerId};try{this.e.mark.setPointerCapture(x.pointerId)}catch{}this.e.coach.classList.add("pressing")}pointerMove(x){if(!this.markers.length)this.placeCoach({x:x.clientX,y:x.clientY},!0);let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:$.shape,rect:t2($.start,{x:x.clientX,y:x.clientY}),head:s2($.start,{x:x.clientX,y:x.clientY})}))}pointerUp(x){let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;let z={x:x.clientX,y:x.clientY};if(this.cancelDraft(),!O6($.shape,$.start,z))return;this.addMarker($.shape,t2($.start,z),$.shape==="arrow"?s2($.start,z):void 0)}addMarker(x,$,z){let Q=this.nextKey++;if(x==="hide"){let Z=this.engine?.hiddenIdsAt($);if(Z)this.hideIds.set(Q,Z)}this.markers=i1([...this.markers,{key:Q,n:this.markers.length+1,shape:x,rect:$,note:"",...z?{head:z}:{}}]),this.renderMarks(),this.paint(),this.lines.get(Q)?.note.focus()}cancelDraft(){this.drawing=null,this.kbDraft=null,this.e.draft.replaceChildren(),this.e.coach.classList.remove("pressing")}kbDraft=null;markKey(x){if(x.target!==this.e.mark)return;let $=globalThis.innerWidth||800,z=globalThis.innerHeight||600;if(x.key==="Enter"||x.key===" "){if(x.preventDefault(),!this.kbDraft){this.kbDraft={x:Math.round($/2-U5.w/2),y:Math.round(z/2-U5.h/2),...U5},this.renderKbDraft();return}let X=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,X,this.tool==="arrow"?"se":void 0);return}let Q=x$[x.key];if(!Q||!this.kbDraft)return;x.preventDefault();let Z=this.kbDraft,[V,J]=Q;this.kbDraft=x.shiftKey?{...Z,w:Math.min($-Z.x,Math.max(Q8,Z.w+V)),h:Math.min(z-Z.y,Math.max(Q8,Z.h+J))}:{...Z,x:Math.min($-Z.w,Math.max(0,Z.x+V)),y:Math.min(z-Z.h,Math.max(0,Z.y+J))},this.renderKbDraft()}renderKbDraft(){let x=this.kbDraft;if(!x)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:this.tool,rect:x,head:"se"}))}placeCoach(x,$){let z=globalThis.innerWidth||800,Q=globalThis.innerHeight||600,Z=this.e.coach.offsetWidth||300,V=this.e.coach.offsetHeight||140,J=$?x.x+20:x.x,X=$?x.y+20:x.y;if(J+Z>z-8)J=$?x.x-Z-20:z-Z-8;if(X+V>Q-90)X=$?x.y-V-20:Q-V-90;this.e.coach.style.left=`${Math.max(8,J)}px`,this.e.coach.style.top=`${Math.max(8,X)}px`}shapeNodes(x){let{x:$,y:z,w:Q,h:Z}=x.rect;if(x.shape==="circle")return[p("ellipse",{class:"stroke",cx:$+Q/2,cy:z+Z/2,rx:Math.max(1,Q/2),ry:Math.max(1,Z/2)})];if(x.shape==="box")return[p("rect",{class:"stroke",x:$,y:z,width:Q,height:Z,rx:6})];if(x.shape==="arrow"){let{tail:X,tip:G}=e2(x.rect,x.head??"se");return[p("line",{class:"stroke",x1:X.x,y1:X.y,x2:G.x,y2:G.y,"marker-end":"url(#vr-head)"})]}let V=p("rect",{class:"veil",x:$,y:z,width:Q,height:Z,rx:4}),J=p("text",{class:"veil-label",x:$+Q/2,y:z+Z/2+4,"text-anchor":"middle"});return J.textContent=Q>60&&Z>20?this.s.hidden:"",[V,J]}renderMarks(){this.e.shapes.replaceChildren(...this.markers.flatMap((z)=>this.shapeNodes(z)));let x=new Set(this.markers.map((z)=>z.key));for(let[z,Q]of this.pins){if(x.has(z))continue;Q.el.remove(),this.pins.delete(z)}for(let[z,Q]of this.lines){if(x.has(z))continue;Q.el.remove(),this.lines.delete(z)}let $=(z)=>{this.markers=i1(this.markers.filter((Q)=>Q.key!==z)),this.renderMarks(),this.paint()};for(let z of this.markers){if(this.pins.has(z.key))continue;let Q=j("button",{class:"num",type:"button"}),Z=j("button",{class:"rm",type:"button"},C(g.close)),V=j("div",{class:"pin"},Q,Z);Q.addEventListener("click",()=>this.lines.get(z.key)?.note.focus()),Z.addEventListener("click",()=>$(z.key)),this.e.pins.append(V),this.pins.set(z.key,{el:V,num:Q,rm:Z});let J=j("span",{class:"ln-n","aria-hidden":"true"}),X=j("input",{class:"ln-t",type:"text",maxlength:"500"}),G=j("button",{class:"ln-x",type:"button"},C(g.close)),Y=j("li",{class:"ln"},J,X,G);X.addEventListener("input",()=>{this.markers=this.markers.map((F)=>F.key===z.key?{...F,note:X.value}:F),this.paint()}),X.addEventListener("keydown",(F)=>{if(F.key!=="Enter"||!this.marking)return;F.preventDefault(),this.e.mark.focus()}),G.addEventListener("click",()=>$(z.key)),this.e.lines.append(Y),this.lines.set(z.key,{el:Y,num:J,note:X,rm:G})}for(let z of this.markers){let Q=this.lines.get(z.key);if(Q)this.e.lines.append(Q.el)}if(this.renderPins(),this.parked)this.placeCard()}renderPins(){let x=globalThis.innerWidth||800;for(let $ of this.markers){let z=this.pins.get($.key),Q=this.lines.get($.key);if(!z||!Q)continue;let Z=$.shape==="arrow"?e2($.rect,$.head??"se").tail:{x:$.rect.x,y:$.rect.y};z.el.style.left=`${Math.min(Math.max(4,Z.x-12),x-60)}px`,z.el.style.top=`${Math.max(l1-12,Z.y-12)}px`,z.num.textContent=String($.n),z.num.setAttribute("aria-label",this.s.mark($.n)),z.rm.setAttribute("aria-label",this.s.removeMark($.n)),Q.num.textContent=String($.n),Q.el.classList.toggle("hide",$.shape==="hide"),Q.note.placeholder=this.s.notePlaceholder,Q.note.setAttribute("aria-label",`${this.s.mark($.n)} — ${this.s.notePlaceholder}`),Q.rm.setAttribute("aria-label",this.s.removeMark($.n))}}envelope(x,$){let z=this.who(),Q=globalThis.location;return{title:V8(x),description:x,env:{url:J0(Q?`${Q.origin}${Q.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:$.console,network:$.network,...z?{identity:z,notify:this.notify}:{},markers:g6(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{}}}words(){return this.e.desc.value.trim()||(this.markers.find((x)=>x.note.trim())?.note.trim()??"")}hasDraft(){return this.e.desc.value.trim()!==""||this.markers.length>0||this.kind!==null||this.files.length>0}recordWaits(){return this.sending||this.job!==null||this.hasDraft()}async send(){let x=this.words();if(this.sending||!x)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 $=new Set;for(let V of this.markers)for(let J of this.hideIds.get(V.key)??[])$.add(J);let z=this.engine,Q=this.frozen??{clip:null,stored:Promise.resolve(new Map)},Z=z?await $8(()=>z.build(Q,this.markers,$)):j5;this.job=new Y5(Z,globalThis.location?.host??"",{url:this.opts.base,key:this.opts.key},this.files)}this.result=await this.job.run(this.envelope(x,this.job.capture)),t6(this.opts.base,globalThis.location?.host??"",{title:V8(x),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($){console.warn("vitrinka: the report did not go through — Retry resumes it",$),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 x=this.s,$=[],z=this.config?.lanes;if(z?.replay)$.push(`${x.incReplay} — ${x.incReplayMasked[this.config?.masking??"strict"].toLowerCase()}`);if(z?.errors)$.push(x.incErrors);if(z?.console)$.push(x.incConsole);if(z?.network)$.push(x.incNetwork);else if(z?.errors)$.push(x.incFailedRequests);if($.push(x.incEnv),this.who())$.push(x.incIdentity);if(this.markers.length)$.push(x.incMarks);if(this.files.length)$.push(x.incFiles);return $}paintAccount(){let{e:x,s:$}=this,z=this.who(),Q=!z?null:("email"in z)?{name:z.name??"",email:z.email}:this.session?{name:this.session.reporter.name??"",email:this.session.reporter.email}:null,Z=Q?.name||Q?.email||"";x.whoAv.textContent=z?z$(Z):"?",x.whoName.textContent=Z.split(/[\s@]/)[0]??"",x.whoName.hidden=!Z,x.whoBtn.setAttribute("aria-label",`${$.account}: ${Z||(z?"":$.anonymous)}`.replace(/: $/,"")),x.whoBtn.setAttribute("aria-expanded",String(this.menu==="account")),x.more.setAttribute("aria-label",$.menu),x.more.setAttribute("aria-expanded",String(this.menu==="more")),x.accountPop.hidden=this.menu!=="account",x.morePop.hidden=this.menu!=="more",x.accountPop.setAttribute("aria-label",$.account),x.morePop.setAttribute("aria-label",$.menu),x.accName.textContent=z?Q?.name||Q?.email||"":$.anonymous,x.accMail.textContent=Q?.name?Q.email:"",x.accMail.hidden=!x.accMail.textContent,x.accVia.textContent=z&&"token"in z?$.signedInByApp:$.anonymousHint;let V=this.member;x.accLinked.hidden=!V,x.accUnlink.hidden=!V,x.accLinked.textContent=V?$.linkedAs(V.email||V.name||V.workspace):"",x.accUnlink.textContent=$.unlink,x.accLink.hidden=Boolean(V),h(x.accLink,$.linkVitrinka);let J=this.session?.portalUrl;if(x.accPortal.hidden=!J,J)x.accPortal.setAttribute("href",J);h(x.accPortal,$.openPortal),h(x.mReports,$.myReports),h(x.mRecents,$.recentRecordings),h(x.mRecord,$.record),h(x.mSettings,$.settings),x.mRecents.hidden=!this.recordSwitch,x.mRecord.hidden=!this.recordSwitch;let X=this.recordWaits();if(X)x.mRecord.setAttribute("aria-disabled","true");else x.mRecord.removeAttribute("aria-disabled");if(x.mRecordWhy.hidden=!X,x.mRecordWhy.textContent=$.recordHasDraft,X)x.mRecord.setAttribute("aria-describedby",x.mRecordWhy.id);else x.mRecord.removeAttribute("aria-describedby");let G=V?this.opts.base:J;if(x.mOpen.hidden=!G,G)x.mOpen.setAttribute("href",G);h(x.mOpen,V?$.openVitrinka:$.openPortal)}paintReports(){let{e:x,s:$}=this;h(x.repBack,$.myReports);let z=!this.session,Q=z?X5(this.opts.base,globalThis.location?.host??"").map((J)=>this.row(J.title,J.status==="quarantined"?$.waiting:$.steps.received??"",J.at,J.url)):this.mine.rows.map((J)=>this.row(J.title,$.steps[J.step]??J.step,Date.parse(J.updatedAt),J.url));x.repRows.replaceChildren(...Q);let Z=z?"ok":this.mine.state;x.repStatus.hidden=Z==="ok"&&Q.length>0,x.repStatus.textContent=Z==="loading"?$.loading:Z==="failed"?$.listFailed:$.noReports,x.repLocal.hidden=!z||Q.length===0,x.repLocal.textContent=$.fromThisBrowser;let V=this.session?.portalUrl;if(x.repPortal.hidden=!V,V)x.repPortal.setAttribute("href",V);x.repPortal.textContent=$.openPortal}paintRecents(){let{e:x,s:$}=this;h(x.recBack,$.recentRecordings);let z=a4().map((Q)=>this.row(Q.title,"",Q.startedAt,Q.boardUrl));x.recRows.replaceChildren(...z),x.recStatus.hidden=z.length>0,x.recStatus.textContent=$.noRecordings}paintLink(){let{e:x,s:$}=this,z=this.linkFlow;h(x.linkBack,$.linkVitrinka),x.linkLabel.textContent=$.linkCode,x.linkCode.textContent=z?.start?.user_code??"…",x.linkOpenText.textContent=$.openVitrinka;let Q=z?.start;if(x.linkOpen.hidden=!Q,Q)x.linkOpen.setAttribute("href",Q.verifyUrl);let Z=globalThis.matchMedia?.("(pointer: fine)").matches??!0;if(x.linkQr.hidden=!Q||!Z,Q&&Z&&x.linkQr.getAttribute("src")!==Q.qrUrl)x.linkQr.setAttribute("src",Q.qrUrl);x.linkHint.textContent=$.linkHint;let V=z?.state??"failed";x.linkWait.textContent=V==="expired"?$.linkExpired:V==="failed"?$.linkFailed:V==="waiting"?$.linkWaiting:$.loading,x.linkRetry.hidden=V!=="expired"&&V!=="failed",x.linkRetry.textContent=$.retry}paintFiles(){let{e:x,s:$}=this,z=this.sending||Boolean(this.job?.id);x.attach.setAttribute("aria-label",$.attach),x.attach.disabled=z,x.attach.hidden=this.caps().maxCount===0,x.fileInput.setAttribute("accept",this.caps().types.join(",")),x.tray.hidden=this.view!=="describe"||this.files.length===0&&!this.fileRefusal,x.files.hidden=this.files.length===0,x.files.setAttribute("aria-label",$.incFiles),x.fileNote.hidden=!this.fileRefusal,x.fileNote.textContent=this.refusalText(this.fileRefusal);for(let[Q,Z]of this.chips)Z.size.textContent=l0(Q.size,this.locale),Z.rm.setAttribute("aria-label",$.removeFile(Q.name)),Z.rm.disabled=z}paintSettings(){let{e:x,s:$}=this;x.sizeLabel.textContent=$.size;for(let[z,Q]of x.sizeButtons)Q.textContent=$.sizes[z],Q.setAttribute("aria-checked",String(this.size===z));if(x.techText.textContent=$.techDetails,x.techBtn.setAttribute("aria-expanded",String(this.techOpen)),x.tech.hidden=!this.techOpen,this.techOpen&&this.view==="settings"){let z=q3({version:X3,base:this.opts.base,config:this.config,engine:this.engine!==null,locale:this.locale},$);x.tech.replaceChildren(...z.flatMap(([Q,Z])=>[j("dt",{},Q),j("dd",{},Z)]))}if(this.view==="settings")X8(x.sizeSeg,x.sizeInd,x.sizeButtons.get(this.size))}paint(){let{e:x,s:$}=this,z=this.who();if(x.root.setAttribute("lang",this.locale),x.root.classList.toggle("nobutton",!this.button),x.root.dataset.dock=this.dock,x.root.style.setProperty("--vr-scale",String(D1[this.size])),x.fab.hidden=!this.button||this.marking,x.fabLabel.textContent=$.button,x.fab.setAttribute("aria-expanded",String(this.isOpen)),x.fab.setAttribute("aria-description",$.moveHint),x.fab.setAttribute("aria-keyshortcuts","Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight"),x.fabKbd.hidden=!this.keybind,x.fabKbd.textContent=this.keybind?d1(this.keybind):"",x.card.hidden=!this.isOpen,x.card.classList.toggle("busy",this.sending),x.title.textContent=$.title,x.closeBtn.setAttribute("aria-label",$.close),this.paintAccount(),x.describe.hidden=this.view!=="describe",x.settings.hidden=this.view!=="settings",x.sent.hidden=this.view!=="sent",x.reports.hidden=this.view!=="reports",x.recents.hidden=this.view!=="recents",x.linking.hidden=this.view!=="link",this.view==="reports")this.paintReports();if(this.view==="recents")this.paintRecents();if(this.view==="link")this.paintLink();x.foot.hidden=this.view!=="describe",this.paintFiles(),x.kindsLabel.textContent=$.kindsLabel;for(let[Z,V]of x.kindButtons)V.textContent=$.kinds[Z],V.setAttribute("aria-checked",String(this.kind===Z)),V.disabled=this.sending||Boolean(this.job?.id);x.prompt.textContent=$.prompt,x.desc.placeholder=$.placeholder,x.attachedText.textContent=$.attached(this.config?.profile.windowSec??60),x.attached.hidden=this.engine===null||this.config?.capturing===!1,x.discloseText.textContent=$.included,x.disclose.setAttribute("aria-expanded",String(this.includedOpen)),x.included.hidden=!this.includedOpen,x.included.replaceChildren(...this.includedItems().map((Z)=>j("li",{},Z))),x.desc.disabled=this.sending,x.lines.hidden=this.markers.length===0,x.linesEmpty.hidden=!this.marking||this.markers.length>0,x.linesEmpty.textContent=$.linesEmpty;for(let Z of this.lines.values())Z.note.disabled=this.sending,Z.rm.disabled=this.sending;x.notify.hidden=z===null,x.notifyText.textContent=$.notify,x.error.hidden=this.error==="",x.error.textContent={"":"",create:$.errorCreate,files:$.errorFiles,capture:$.errorCapture}[this.error],x.whereText.textContent=$.showWhere,x.where.setAttribute("aria-pressed",String(this.marking)),x.where.disabled=this.sending||Boolean(this.job?.id),x.send.textContent=this.sending?$.sending:this.error?$.retry:$.send,x.send.disabled=this.sending||this.words()==="",x.bindLabel.textContent=$.shortcut,x.bindBtn.setAttribute("aria-pressed",String(this.recordingBind)),x.bindBtn.setAttribute("aria-label",`${$.shortcut}: ${this.keybind?d1(this.keybind):$.notSet} — ${$.recordShortcut}`),x.bindBtn.textContent=this.recordingBind?$.pressKeys:this.keybind?d1(this.keybind):$.notSet,x.unbind.textContent=$.removeShortcut,x.unbind.hidden=!this.keybind||this.recordingBind,x.bindHint.textContent=$.shortcutHint,x.bindReason.hidden=!this.bindRefused,x.bindReason.textContent=this.bindRefused?$.needModifier:"",x.back.textContent=$.back,this.paintSettings(),x.sentTitle.textContent=$.sentTitle,x.sentBody.textContent=this.result?.status==="quarantined"?$.sentQueued:this.sentNotify?$.sentNotify:$.sentBody,x.seeText.textContent=$.seeReport;let Q=this.result?.reportUrl;if(x.see.hidden=!Q,Q)x.see.setAttribute("href",Q);else x.see.removeAttribute("href");x.sentClose.textContent=$.close,x.mark.hidden=!this.marking,x.toolbar.setAttribute("aria-label",$.toolbar),x.seg.setAttribute("aria-label",$.toolbar),x.barLead.textContent=$.barLead;for(let[Z,V]of x.toolButtons){let J=x.toolLabels.get(Z);if(J)J.textContent=$.tools[Z];V.setAttribute("aria-checked",String(this.tool===Z))}if(x.cancel.textContent=$.cancelMarking,x.cancel.hidden=this.confirming,x.ask.hidden=!this.confirming,x.askText.textContent=$.discardMarks(this.markers.filter((Z)=>!this.passKeys.has(Z.key)).length),x.discard.textContent=$.discard,x.keep.textContent=$.keep,x.coach.hidden=!this.marking||this.markers.length>0,x.coachText.textContent=$.coach,x.coachMore.textContent=$.coachMore,x.coachKeys.textContent=$.keyboardHint,x.mark.setAttribute("aria-label",$.marking),this.marking){for(let Z of x.shapes.querySelectorAll(".veil-label"))if(Z.textContent)Z.textContent=$.hidden}this.renderPins()}}function i1(x){return B6(x).map(($,z)=>({...$,key:x[z].key}))}var o1="vitrinka-report",J$=["key","base","open-selector","locale","button"];function j8(x){return x.trim().replace(/\/+$/,"")}function D5(x){if(typeof customElements>"u"||customElements.get(o1))return;class $ extends HTMLElement{static get observedAttributes(){return J$}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(z,Q,Z){if(Q===Z)return;if(!this.at){if(this.isConnected&&(z==="key"||z==="base"))this.mount();return}if(z==="key"||z==="base"){this.unmount(),this.mount();return}if(!this.widget)return;if(z==="locale")this.widget.setLocale(Z);else if(z==="button")this.widget.setButton(Z!=="false");else if(z==="open-selector")this.widget.setOpenSelector(Z)}open(){this.widget?.open()}close(){this.widget?.close()}identify(z){this.pendingIdentity=z,this.widget?.identify(z)}setLocale(z){this.setAttribute("locale",String(z))}mount(){if(this.at)return;let z=(this.getAttribute("key")??"").trim(),Q=j8(this.getAttribute("base")??x.defaultBase());if(!z||!Q){console.warn(`vitrinka: <${o1}> needs a key${Q?"":" and a base"} — nothing mounted`);return}if(this.at={key:z,base:Q},x.recorderFace)this.offLink=g4(()=>this.offerRecord());this.show(x.recorderFace?B4(Q):"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(z){let Q=this.at;if(!Q)return;this.takeDown();let Z=x.recorderFace;if(z==="recorder"&&Z){this.shown="recorder";let V=this.gen;Z().then((J)=>{if(V!==this.gen)return;this.pill=J({base:Q.base,appVersion:this.options.appVersion,sanitizeUrl:this.options.sanitizeUrl,onReportFace:()=>this.switchTo("report")})}).catch((J)=>{if(console.warn("vitrinka: the recorder face did not load — showing Report a problem",J),V===this.gen)this.show("report")});return}this.shown="report",this.widget=new q5({base:Q.base,key:Q.key,locale:u0(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:x.loadRecord}),this.offerRecord()}offerRecord(){if(!this.widget||!this.at)return;let z=x.recorderFace!==null&&m0(this.at.base);if(z===this.recordOffered)return;this.recordOffered=z,this.widget.setRecordSwitch(z?()=>this.switchTo("recorder"):null)}switchTo(z){P4(z);let Q=this.gen;setTimeout(()=>{if(Q===this.gen&&this.shown!==z)this.show(z)},0)}}customElements.define(o1,$)}function Y8(x,$){if(x.face==="recorder")return V$(x,$);D5($);let z=document.createElement(o1);if(z.setAttribute("key",x.key),x.base)z.setAttribute("base",x.base);if(x.locale)z.setAttribute("locale",String(x.locale));if(x.button===!1)z.setAttribute("button","false");if(x.openSelector)z.setAttribute("open-selector",x.openSelector);if(z.options={appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl},x.identity!==void 0)z.identify(x.identity);return(x.parent??document.body).append(z),{get face(){return z.face},open:()=>z.open(),close:()=>z.close(),identify:(Q)=>z.identify(Q),setLocale:(Q)=>z.setLocale(Q),unmount:()=>z.remove()}}function V$(x,$){let z=j8(x.base??$.defaultBase()),Q=null,Z=!1;if(!$.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else $.recorderFace().then((J)=>{if(!Z)Q=J({base:z,key:x.key,appVersion:x.appVersion,sanitizeUrl:x.sanitizeUrl})}).catch((J)=>console.warn("vitrinka: the recorder face did not load",J));let V=()=>{return};return{face:"recorder",open:V,close:V,identify:V,setLocale:V,unmount:()=>{Z=!0,Q?.()}}}var X$=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function G$(x){let z=await import(`${x}/vendor/rrweb-record-1.min.js`)??{},Q=typeof z.default==="object"&&z.default!==null?z.default.record:void 0,Z=typeof z.default==="function"?z.default:Q??z.record;return typeof Z==="function"?Z:null}var U8={loadRecord:G$,recorderFace:null,defaultBase:()=>X$};D5(U8);function CQ(x){return Y8(x,U8)}export{CQ as mountReport,l7 as identify};
|