@vitrinka/web 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- function L(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 bc=/^[a-z0-9_]{1,32}$/;function vt(e){let t=0;for(let n of e)t++;return t}function Bi(e){if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function yc(e){if(typeof e==="string"){let r=e.trim(),o=vt(r);return o>=1&&o<=100?r:{broken:"a value is a string of 1 to 100 characters after trimming, or {id, label?}"}}if(!Bi(e))return{broken:"a value is a string of 1 to 100 characters after trimming, or {id, label?}"};if(typeof e.id!=="string")return{broken:"an id is 1 to 100 characters after trimming"};let t=e.id.trim();if(vt(t)<1||vt(t)>100)return{broken:"an id is 1 to 100 characters after trimming"};if(e.label===void 0)return{id:t};if(typeof e.label!=="string")return{broken:"a label is at most 100 characters after trimming"};let n=e.label.trim();if(vt(n)>100)return{broken:"a label is at most 100 characters after trimming"};return{id:t,label:n}}function kc(e){if(e===null||e===void 0)return{context:{},dropped:[]};let t;try{if(!Bi(e))return{context:{},dropped:["the whole context (a context is a plain object of keys to values)"]};t=Object.keys(e)}catch{return{context:{},dropped:["the whole context (reading it threw in the host app)"]}}let n=[],r=[];for(let o of t){if(!bc.test(o)){r.push(`${JSON.stringify(o)} (a key is 1 to 32 characters of [a-z0-9_])`);continue}let i;try{i=yc(e[o])}catch{i={broken:"reading it threw in the host app"}}if(typeof i==="object"&&"broken"in i){r.push(`${JSON.stringify(o)} (${i.broken})`);continue}if(n.length>=8){r.push(`${JSON.stringify(o)} (a context holds at most 8 keys)`);continue}n.push([o,i])}return{context:Object.fromEntries(n),dropped:r}}var Hi=new Set;function Fi(e){let{context:t,dropped:n}=kc(e),r=n.filter((o)=>!Hi.has(o));for(let o of r)Hi.add(o);if(r.length)console.warn(`vitrinka: setContext dropped ${r.join("; ")}. The report goes without ${r.length===1?"it":"them"}.`);return t}function $i(e){return Object.keys(e).length?{context:e}:{}}class We extends Error{constructor(e="link code expired"){super(e);this.name="LinkExpired"}}class qi 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 we extends Error{constructor(e,t){super(e);this.status=t,this.name="LinkError"}}class T extends Error{constructor(e,t){super(e);this.status=t,this.name="VitrinkaApiError"}}function U(e){return e>=400&&e<500&&e!==408&&e!==429}function Wi(e){return new URL(e).origin}function xt(e){let t=/^\/w\/([^/]+)/.exec(new URL(e).pathname);if(!t?.[1])return;try{return decodeURIComponent(t[1])}catch{return t[1]}}function zi(e,t){if(!t)return e;let n=new URL(e);return n.searchParams.set("workspace",t),n.href}function Ui(e){return e===401}function ji(e){let t=e.fetch??globalThis.fetch;if(typeof t!=="function")throw Error("vitrinka link: no fetch available");return t}function Ki(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 wt(e,t,n){let r=e[t];if(typeof r!=="string"||r==="")throw new we(`link start → malformed payload (${t})`,n);return r}async function Vi(e,t){let n=Wi(e),r=await ji(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 we(`link start → ${r.status}`,r.status);let o;try{o=await r.json()}catch{throw new we("link start → malformed payload (not JSON)",r.status)}if(typeof o!=="object"||o===null)throw new we("link start → malformed payload",r.status);let i=o,s=wt(i,"device_code",r.status),a=wt(i,"user_code",r.status),l=wt(i,"verify_path",r.status),d=wt(i,"qr_path",r.status);return{base:e,device_code:s,user_code:a,verify_path:l,verifyUrl:zi(Ki(n,typeof i.verify_url==="string"?i.verify_url:void 0,l,`/cli-auth?code=${encodeURIComponent(a)}`),t.workspace),qrUrl:zi(Ki(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 vc=600,wc=30000;function xc(e){return e>=500||e===408||e===429}function Sc(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 Rc(e,t){return new Promise((n,r)=>{if(t?.aborted)return r(yn());let o=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e),i=()=>{clearTimeout(o),r(yn())};t?.addEventListener("abort",i,{once:!0})})}function yn(){let e=Error("link polling aborted");return e.name="AbortError",e}async function Yi(e,t,n={}){let r=Wi(e),o=ji(n),i=n.sleep??Rc,s=n.now??Date.now,a=Math.max(2,n.interval??2),l=s()+(n.expiresIn&&n.expiresIn>0?n.expiresIn:vc)*1000,d=0,p=async(h,u)=>{d++;let f=l-s();if(f<=0)throw new We(`link code expired (last claim: ${h})`);let g=Math.max(Math.min(wc,a*1000*2**d),u??0);await i(Math.min(g,f),n.signal)};for(;;){if(n.signal?.aborted)throw yn();let h;try{h=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 p(u.message);continue}if(xc(h.status)){await p(String(h.status),Sc(h,s()));continue}if(d=0,h.status===200){let u=await h.json();if(n.workspace&&u.workspace!==n.workspace){let f=typeof u.workspace==="string"&&u.workspace?u.workspace:"(no workspace)";throw new qi(f,n.workspace)}return u}if(h.status===404||h.status===410)throw new We;if(h.status!==202)throw new we(`link claim → ${h.status}`,h.status);await i(a*1000,n.signal)}}var y={tabId:"root",tabHost:"/",pathname:"/"};function Xi(){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 Gi(e,t){y.tabId=e,y.tabHost=t}function Ji(e){if(y.pathname===e)return!1;return y.pathname=e,I(),!0}var Ue={following:null},xe="__vitrinkaCaptureOwner";function Zi(e,t){let n=globalThis,r=n[xe];if(r){if(e==="report")return null;if(r.face==="report")n[xe]=null,r.yieldTo?.()}let o=`${e}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return n[xe]={face:e,token:o,...t?{yieldTo:t}:{}},o}function St(){return globalThis[xe]?.face??null}function Qi(e){let t=globalThis;if(e&&t[xe]?.token===e)t[xe]=null}var kn=new Set;function es(e){return kn.add(e),()=>kn.delete(e)}function I(){for(let e of kn)e()}async function ns(e,t){let n=`vitrinka.recorder.${e}`;if(globalThis.navigator?.locks){await navigator.locks.request(n,{signal:AbortSignal.timeout(5000)},t);return}let r={area:Tc(),key:`vitrinka.recorder.lock.${e}`},o=await Oc(),i={fence:void 0,since:0};while(!await Ic(o,n,r,t,i))await Cc()}var rs=1000,Ec=5,Cc=()=>new Promise((e)=>setTimeout(e,Ec));function Tc(){try{return globalThis.localStorage??null}catch{return null}}function Ac(e,t){return typeof t!=="string"||!e.area||e.area.getItem(e.key)===t}function Mc(e){if(!e.area)return null;let t=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;try{return e.area.setItem(e.key,t),t}catch(n){return console.warn("vitrinka: recorder lock fence not stored — the next tab may not see this allocation",n),null}}function Lc(e,t){let n=Date.now();if(e.fence!==t)return e.fence=t,e.since=n,!1;if(n-e.since<rs)return!1;return Pc(),!0}var ts=!1;function Pc(){if(ts)return;ts=!0,console.warn(`vitrinka: this tab did not hear the last recorder lock holder within ${rs} ms — numbering anyway`)}function Ic(e,t,n,r,o){return new Promise((i,s)=>{let a=e.transaction("locks","readwrite"),l=a.objectStore("locks"),d=!1;a.oncomplete=()=>i(d),a.onabort=()=>s(a.error??Error("vitrinka: recorder lock transaction aborted"));let p=l.get(t);p.onsuccess=()=>{if(!Ac(n,p.result)&&!Lc(o,p.result))return;try{r()}catch(u){s(u),a.abort();return}d=!0;let h=Mc(n);if(h)l.put(h,t)}})}var je;function Oc(){if(!je)je=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(),je=void 0},e(r)}}).catch((e)=>{throw je=void 0,e});return je}var le="vitrinka.recorder.",vn=null,_c=!1;function R(){if(!vn)vn=Dc()??Nc();return _c=!0,vn}function Dc(){try{let e=globalThis.localStorage;if(!e)return null;let t=`${le}probe`;return e.setItem(t,"1"),e.removeItem(t),{getString:(n)=>e.getItem(le+n),set:(n,r)=>e.setItem(le+n,r),remove:(n)=>e.removeItem(le+n),withLock:ns,keys:()=>Array.from({length:e.length},(n,r)=>e.key(r)).filter((n)=>n!==null&&n.startsWith(le)).map((n)=>n.slice(le.length)),watch:(n,r)=>{let o=(i)=>{if(i.storageArea===e&&i.key===le+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 Nc(){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 Se={url:"",key:""};function Ve(){return Se}var wn=new Set;function os(e){let t=e.replace(/\/+$/,"");return wn.add(t),()=>wn.delete(t)}function xn(e){if(Se.url!==""&&e.startsWith(Se.url))return!0;for(let t of wn)if(t!==""&&e.startsWith(t))return!0;return!1}var Ye="link";function ce(){let e=R().getString(Ye);if(!e)return null;try{let t=JSON.parse(e);return typeof t.token==="string"&&t.token?t:null}catch{return null}}function Sn(e){R().set(Ye,JSON.stringify(e)),I()}function Rt(){R().remove(Ye),I()}function is(){return Se.key||ce()?.token||""}function Rn(){if(Se.label)return Se.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}`:""}`}function ss(e){return`${e}.${Math.random().toString(36).slice(2,10)}`}var Hc=null;function as(e){if(Ui(e))Hc?.()}function ls(e){return e??{url:Ve().url,key:is()}}async function J(e,t,n,r={}){let{url:o,key:i}=ls(r.target),s=await fetch(o+t,{method:e,mode:"cors",credentials:"omit",keepalive:r.keepalive??!1,...r.signal?{signal:r.signal}:{},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)as(s.status);throw new T(`${e} ${t} → ${s.status}: ${a}`,s.status)}return a?JSON.parse(a):{}}function cs(e,t,n){return us(e,"chunk",t,"application/json",n)}function ds(e,t,n){return us(e,"shot",t,n.type,n)}function us(e,t,n,r,o){return En(`/api/v1/sessions/${e}/${t}?seq=${n}`,r,o)}async function En(e,t,n,r,o){let{url:i,key:s}=ls(r),a=await fetch(i+e,{method:"POST",mode:"cors",credentials:"omit",...o?{signal:o}:{},headers:{authorization:`Bearer ${s}`,"content-type":t},body:n}),l=await a.text();if(!a.ok){if(!r)as(a.status);throw new T(`POST ${e} → ${a.status}: ${l}`,a.status)}try{return JSON.parse(l)}catch{return{}}}var hs="[redacted]",Bc=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],Fc=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function Re(e){return String(e).toLowerCase().replace(/[-_]/g,"")}var Cn=null;function Tn(e){let t=JSON.stringify(e??null);if(Cn?.src===t)return Cn.rules;let n=new Set(Bc),r=new Set(Fc),o=[];for(let s of e?.extraHeaders??[]){let a=Re(s);if(a)n.add(a)}for(let s of e?.extraBodyKeys??[]){let a=Re(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 Cn={src:t,rules:i},i}var $c=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),zc=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function Kc(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t)=>t.toLowerCase())}function gs(e){let t=Kc(e);if(t.some((n)=>$c.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],zc.includes(r))return!0;if(r.length>24)break}}return!1}function ms(e,t){let n=Re(t);return e.headers.has(n)||n.endsWith("apikey")||n.endsWith("token")||gs(t)}function Z(e,t){return e.bodyKeys.has(Re(t))||gs(t)}function bs(e,t){if(Z(e,t))return!0;let n=Re(t);return n.endsWith("apikey")||n.endsWith("token")}var qc=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,Wc=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function ys(e){return e.includes("PRIVATE KEY-----")?e.replace(qc,"[redacted]"):e}function Ee(e,t){let n=ys(t);for(let r of e.patterns)r.lastIndex=0,n=n.replace(r,"[redacted]");return n}function ks(e,t){if(Wc.test(t))return!0;for(let n of t.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(Z(e,n[1]))return!0;return!1}function Et(e){let t=e;for(let n=0;n<3;n++){let r=Uc(t);if(r===t)break;t=r}return t}function Uc(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 vs(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=Et(a.replace(/\+/g," ")),d=l.lastIndexOf("?"),p=d>=0?l.slice(d+1):null;if(t(e,l)||p!==null&&t(e,p))return r=!0,`${a}=[redacted]`;if(s>=0&&ks(e,Et(i.slice(s+1))))return r=!0,`${a}=[redacted]`;return i});return r?o.join("&"):n}function An(e,t){if(e.full||!t)return t;let n=t.search(/[?#]/);if(n<0)return Ee(e,t);let r=t.slice(n+1).split("#").map((o)=>vs(e,bs,o)).join("#");return Ee(e,t.slice(0,n+1)+r)}var jc=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,Vc=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,Yc=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,Xc=131072;function Ct(e,t){if(t.length>Xc)return`[body omitted: ${t.length} bytes, unmaskable]`;let n=ys(t).replace(Yc,(r,o)=>ms(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(Vc,(r,o,i,s)=>{if(bs(e,Et(i)))return`${o}${i}=[redacted]`;if(ks(e,Et(s)))return`${o}${i}=[redacted]`;return r}).replace(jc,(r,o,i,s,a)=>{if(a==="[redacted]")return r;return Z(e,o)?`${o}${i}${s}[redacted]${s}`:r});return Ee(e,n)}function Gc(e){switch(Re(e)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var Jc=64;function Tt(e,t,n){if(n>Jc)return"[redacted]";if(Array.isArray(t))return t.map((r)=>Tt(e,r,n+1));if(t!==null&&typeof t==="object"){let r={};for(let[o,i]of Object.entries(t))if(Z(e,o))r[o]="[redacted]";else if(typeof i==="string"&&Gc(o))r[o]=An(e,i);else r[o]=Tt(e,i,n+1);return r}return typeof t==="string"?Ee(e,t):t}function ps(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 Zc(e,t){for(let n of t.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(Z(e,ps(n[1])))return"";return t.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(n,r,o)=>Z(e,ps(o))?`${r}"[redacted]"`:n)}function Mn(e){let t=e.trimStart();return t.startsWith("{")||t.startsWith("[")}function Qc(e,t,n){let r=/boundary="?([^";]+)"?/i.exec(n);if(!r)return null;let o=`--${r[1]}`,i=t.split(o);if(i.length<3||i[0]!=="")return null;if(!i[i.length-1].startsWith("--"))return null;let s=[i[0]];for(let a=1;a<i.length-1;a++){let l=i[a];if(!l.startsWith(`\r
1
+ function L(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 Oc=/^[a-z0-9_]{1,32}$/;function xt(e){let t=0;for(let n of e)t++;return t}function Vi(e){if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function _c(e){if(typeof e==="string"){let r=e.trim(),o=xt(r);return o>=1&&o<=100?r:{broken:"a value is a string of 1 to 100 characters after trimming, or {id, label?}"}}if(!Vi(e))return{broken:"a value is a string of 1 to 100 characters after trimming, or {id, label?}"};if(typeof e.id!=="string")return{broken:"an id is 1 to 100 characters after trimming"};let t=e.id.trim();if(xt(t)<1||xt(t)>100)return{broken:"an id is 1 to 100 characters after trimming"};if(e.label===void 0)return{id:t};if(typeof e.label!=="string")return{broken:"a label is at most 100 characters after trimming"};let n=e.label.trim();if(xt(n)>100)return{broken:"a label is at most 100 characters after trimming"};return{id:t,label:n}}function Dc(e){if(e===null||e===void 0)return{context:{},dropped:[]};let t;try{if(!Vi(e))return{context:{},dropped:["the whole context (a context is a plain object of keys to values)"]};t=Object.keys(e)}catch{return{context:{},dropped:["the whole context (reading it threw in the host app)"]}}let n=[],r=[];for(let o of t){if(!Oc.test(o)){r.push(`${JSON.stringify(o)} (a key is 1 to 32 characters of [a-z0-9_])`);continue}let i;try{i=_c(e[o])}catch{i={broken:"reading it threw in the host app"}}if(typeof i==="object"&&"broken"in i){r.push(`${JSON.stringify(o)} (${i.broken})`);continue}if(n.length>=8){r.push(`${JSON.stringify(o)} (a context holds at most 8 keys)`);continue}n.push([o,i])}return{context:Object.fromEntries(n),dropped:r}}var Ui=new Set;function Yi(e){let{context:t,dropped:n}=Dc(e),r=n.filter((o)=>!Ui.has(o));for(let o of r)Ui.add(o);if(r.length)console.warn(`vitrinka: setContext dropped ${r.join("; ")}. The report goes without ${r.length===1?"it":"them"}.`);return t}function Xi(e){return Object.keys(e).length?{context:e}:{}}var Z={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function Nc(e,t){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:t}function Gi(e){if(typeof e!=="object"||e===null)return Z;let t={...e},n=Array.isArray(t.types)?t.types.filter((r)=>typeof r==="string"&&r.trim()!=="").map((r)=>r.trim().toLowerCase()):[];return{maxBytes:Nc(t.maxBytes,Z.maxBytes),maxCount:typeof t.maxCount==="number"&&Number.isInteger(t.maxCount)&&t.maxCount>=0?t.maxCount:Z.maxCount,types:n.length?n:Z.types}}function Hc(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 Bc(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}function Ji(e,t,n){let r=[],o=null;for(let i of t){if([...e,...r].some((s)=>Bc(s,i)))continue;if(!Hc(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 Ve(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 Zi(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 Qi(e,t){let n=/^image\.(\w+)$/i.exec(e);return n?`pasted-${t}.${n[1]}`:e}var vn=["sm","md","lg"],Q={sm:0.88,md:1,lg:1.18},yn="vitrinka.report.size";function es(){try{return globalThis.localStorage??null}catch{return null}}function Re(e){return es()?.getItem(e)??null}function de(e,t){try{es()?.setItem(e,t)}catch(n){console.warn(`vitrinka: could not remember ${e} on this browser`,n)}}function ts(){let e=Re(yn);return vn.find((t)=>t===e)??"md"}var wn="vitrinka.report.coach";function ns(){return Re(wn)!=="off"}function rs(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} · ${Ve(n.profile.maxBytes,e.locale)}`:"—"],[t.techServer,o]]}var ss="vitrinka.report.edge",xn=0.62,os=0.1,is={top:80,bottom:136};function Sn(e){return e==="corner"?"corner":"edge"}function as(e){let t=(n,r)=>typeof n==="number"&&Number.isFinite(n)&&n>=0?n:r;return{top:t(e?.top,is.top),bottom:t(e?.bottom,is.bottom)}}function Ye(e){return Math.min(1,Math.max(0,e))}function ls(){let e=Re(ss);if(e===null||e.trim()==="")return xn;let t=Number(e);return Number.isFinite(t)&&t>=0&&t<=1?t:xn}function cs(e){de(ss,String(Math.round(Ye(e)*1000)/1000))}function Rn(e,t,n,r){let o=t-r.top-r.bottom-n;if(o<=0)return Math.max(0,Math.round((t-n)/2));return Math.round(r.top+Ye(e)*o)}function En(e,t,n,r){let o=t-r.top-r.bottom-n;if(o<=0)return xn;return Ye((e-r.top)/o)}function ds(e,t){if(t==="ArrowUp")return Ye(Math.round((e-os)*1000)/1000);if(t==="ArrowDown")return Ye(Math.round((e+os)*1000)/1000);return null}function us(e){return e<0.5?"tr":"br"}function ps(e,t,n,r,o=16){let i=e+t/2-n/2,s=r-n-o;if(s<o)return Math.max(0,Math.round((r-n)/2));return Math.round(Math.min(s,Math.max(o,i)))}class Xe extends Error{constructor(e="link code expired"){super(e);this.name="LinkExpired"}}class gs 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 Ee extends Error{constructor(e,t){super(e);this.status=t,this.name="LinkError"}}class A extends Error{constructor(e,t){super(e);this.status=t,this.name="VitrinkaApiError"}}function U(e){return e>=400&&e<500&&e!==408&&e!==429}function ms(e){return new URL(e).origin}function Rt(e){let t=/^\/w\/([^/]+)/.exec(new URL(e).pathname);if(!t?.[1])return;try{return decodeURIComponent(t[1])}catch{return t[1]}}function fs(e,t){if(!t)return e;let n=new URL(e);return n.searchParams.set("workspace",t),n.href}function bs(e){return e===401}function ks(e){let t=e.fetch??globalThis.fetch;if(typeof t!=="function")throw Error("vitrinka link: no fetch available");return t}function hs(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 Ee(`link start → malformed payload (${t})`,n);return r}async function vs(e,t){let n=ms(e),r=await ks(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 Ee(`link start → ${r.status}`,r.status);let o;try{o=await r.json()}catch{throw new Ee("link start → malformed payload (not JSON)",r.status)}if(typeof o!=="object"||o===null)throw new Ee("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:fs(hs(n,typeof i.verify_url==="string"?i.verify_url:void 0,l,`/cli-auth?code=${encodeURIComponent(a)}`),t.workspace),qrUrl:fs(hs(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 zc=600,Fc=30000;function $c(e){return e>=500||e===408||e===429}function Kc(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 jc(e,t){return new Promise((n,r)=>{if(t?.aborted)return r(Cn());let o=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e),i=()=>{clearTimeout(o),r(Cn())};t?.addEventListener("abort",i,{once:!0})})}function Cn(){let e=Error("link polling aborted");return e.name="AbortError",e}async function ys(e,t,n={}){let r=ms(e),o=ks(n),i=n.sleep??jc,s=n.now??Date.now,a=Math.max(2,n.interval??2),l=s()+(n.expiresIn&&n.expiresIn>0?n.expiresIn:zc)*1000,d=0,p=async(h,u)=>{d++;let f=l-s();if(f<=0)throw new Xe(`link code expired (last claim: ${h})`);let g=Math.max(Math.min(Fc,a*1000*2**d),u??0);await i(Math.min(g,f),n.signal)};for(;;){if(n.signal?.aborted)throw Cn();let h;try{h=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 p(u.message);continue}if($c(h.status)){await p(String(h.status),Kc(h,s()));continue}if(d=0,h.status===200){let u=await h.json();if(n.workspace&&u.workspace!==n.workspace){let f=typeof u.workspace==="string"&&u.workspace?u.workspace:"(no workspace)";throw new gs(f,n.workspace)}return u}if(h.status===404||h.status===410)throw new Xe;if(h.status!==202)throw new Ee(`link claim → ${h.status}`,h.status);await i(a*1000,n.signal)}}var k={tabId:"root",tabHost:"/",pathname:"/"};function ws(){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 xs(e,t){k.tabId=e,k.tabHost=t}function Ss(e){if(k.pathname===e)return!1;return k.pathname=e,I(),!0}var Ge={following:null},Ce="__vitrinkaCaptureOwner";function Rs(e,t){let n=globalThis,r=n[Ce];if(r){if(e==="report")return null;if(r.face==="report")n[Ce]=null,r.yieldTo?.()}let o=`${e}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return n[Ce]={face:e,token:o,...t?{yieldTo:t}:{}},o}function Et(){return globalThis[Ce]?.face??null}function Es(e){let t=globalThis;if(e&&t[Ce]?.token===e)t[Ce]=null}var Tn=new Set;function Cs(e){return Tn.add(e),()=>Tn.delete(e)}function I(){for(let e of Tn)e()}async function As(e,t){let n=`vitrinka.recorder.${e}`;if(globalThis.navigator?.locks){await navigator.locks.request(n,{signal:AbortSignal.timeout(5000)},t);return}let r={area:Uc(),key:`vitrinka.recorder.lock.${e}`},o=await Zc(),i={fence:void 0,since:0};while(!await Jc(o,n,r,t,i))await Wc()}var Ms=1000,qc=5,Wc=()=>new Promise((e)=>setTimeout(e,qc));function Uc(){try{return globalThis.localStorage??null}catch{return null}}function Vc(e,t){return typeof t!=="string"||!e.area||e.area.getItem(e.key)===t}function Yc(e){if(!e.area)return null;let t=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;try{return e.area.setItem(e.key,t),t}catch(n){return console.warn("vitrinka: recorder lock fence not stored — the next tab may not see this allocation",n),null}}function Xc(e,t){let n=Date.now();if(e.fence!==t)return e.fence=t,e.since=n,!1;if(n-e.since<Ms)return!1;return Gc(),!0}var Ts=!1;function Gc(){if(Ts)return;Ts=!0,console.warn(`vitrinka: this tab did not hear the last recorder lock holder within ${Ms} ms — numbering anyway`)}function Jc(e,t,n,r,o){return new Promise((i,s)=>{let a=e.transaction("locks","readwrite"),l=a.objectStore("locks"),d=!1;a.oncomplete=()=>i(d),a.onabort=()=>s(a.error??Error("vitrinka: recorder lock transaction aborted"));let p=l.get(t);p.onsuccess=()=>{if(!Vc(n,p.result)&&!Xc(o,p.result))return;try{r()}catch(u){s(u),a.abort();return}d=!0;let h=Yc(n);if(h)l.put(h,t)}})}var Je;function Zc(){if(!Je)Je=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(),Je=void 0},e(r)}}).catch((e)=>{throw Je=void 0,e});return Je}var ue="vitrinka.recorder.",An=null,Qc=!1;function E(){if(!An)An=ed()??td();return Qc=!0,An}function ed(){try{let e=globalThis.localStorage;if(!e)return null;let t=`${ue}probe`;return e.setItem(t,"1"),e.removeItem(t),{getString:(n)=>e.getItem(ue+n),set:(n,r)=>e.setItem(ue+n,r),remove:(n)=>e.removeItem(ue+n),withLock:As,keys:()=>Array.from({length:e.length},(n,r)=>e.key(r)).filter((n)=>n!==null&&n.startsWith(ue)).map((n)=>n.slice(ue.length)),watch:(n,r)=>{let o=(i)=>{if(i.storageArea===e&&i.key===ue+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 td(){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 Te={url:"",key:""};function Ze(){return Te}var Mn=new Set;function Ls(e){let t=e.replace(/\/+$/,"");return Mn.add(t),()=>Mn.delete(t)}function Ln(e){if(Te.url!==""&&e.startsWith(Te.url))return!0;for(let t of Mn)if(t!==""&&e.startsWith(t))return!0;return!1}var Qe="link";function pe(){let e=E().getString(Qe);if(!e)return null;try{let t=JSON.parse(e);return typeof t.token==="string"&&t.token?t:null}catch{return null}}function Pn(e){E().set(Qe,JSON.stringify(e)),I()}function Ct(){E().remove(Qe),I()}function Ps(){return Te.key||pe()?.token||""}function In(){if(Te.label)return Te.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}`:""}`}function Is(e){return`${e}.${Math.random().toString(36).slice(2,10)}`}var nd=null;function Os(e){if(bs(e))nd?.()}function _s(e){return e??{url:Ze().url,key:Ps()}}async function ee(e,t,n,r={}){let{url:o,key:i}=_s(r.target),s=await fetch(o+t,{method:e,mode:"cors",credentials:"omit",keepalive:r.keepalive??!1,...r.signal?{signal:r.signal}:{},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)Os(s.status);throw new A(`${e} ${t} → ${s.status}: ${a}`,s.status)}return a?JSON.parse(a):{}}function Ds(e,t,n){return Hs(e,"chunk",t,"application/json",n)}function Ns(e,t,n){return Hs(e,"shot",t,n.type,n)}function Hs(e,t,n,r,o){return On(`/api/v1/sessions/${e}/${t}?seq=${n}`,r,o)}async function On(e,t,n,r,o){let{url:i,key:s}=_s(r),a=await fetch(i+e,{method:"POST",mode:"cors",credentials:"omit",...o?{signal:o}:{},headers:{authorization:`Bearer ${s}`,"content-type":t},body:n}),l=await a.text();if(!a.ok){if(!r)Os(a.status);throw new A(`POST ${e} → ${a.status}: ${l}`,a.status)}try{return JSON.parse(l)}catch{return{}}}var Fs="[redacted]",rd=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],od=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function Ae(e){return String(e).toLowerCase().replace(/[-_]/g,"")}var _n=null;function Dn(e){let t=JSON.stringify(e??null);if(_n?.src===t)return _n.rules;let n=new Set(rd),r=new Set(od),o=[];for(let s of e?.extraHeaders??[]){let a=Ae(s);if(a)n.add(a)}for(let s of e?.extraBodyKeys??[]){let a=Ae(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 _n={src:t,rules:i},i}var id=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),sd=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function ad(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t)=>t.toLowerCase())}function $s(e){let t=ad(e);if(t.some((n)=>id.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],sd.includes(r))return!0;if(r.length>24)break}}return!1}function Ks(e,t){let n=Ae(t);return e.headers.has(n)||n.endsWith("apikey")||n.endsWith("token")||$s(t)}function te(e,t){return e.bodyKeys.has(Ae(t))||$s(t)}function js(e,t){if(te(e,t))return!0;let n=Ae(t);return n.endsWith("apikey")||n.endsWith("token")}var ld=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,cd=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function qs(e){return e.includes("PRIVATE KEY-----")?e.replace(ld,"[redacted]"):e}function Me(e,t){let n=qs(t);for(let r of e.patterns)r.lastIndex=0,n=n.replace(r,"[redacted]");return n}function Ws(e,t){if(cd.test(t))return!0;for(let n of t.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(te(e,n[1]))return!0;return!1}function Tt(e){let t=e;for(let n=0;n<3;n++){let r=dd(t);if(r===t)break;t=r}return t}function dd(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 Us(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=Tt(a.replace(/\+/g," ")),d=l.lastIndexOf("?"),p=d>=0?l.slice(d+1):null;if(t(e,l)||p!==null&&t(e,p))return r=!0,`${a}=[redacted]`;if(s>=0&&Ws(e,Tt(i.slice(s+1))))return r=!0,`${a}=[redacted]`;return i});return r?o.join("&"):n}function Nn(e,t){if(e.full||!t)return t;let n=t.search(/[?#]/);if(n<0)return Me(e,t);let r=t.slice(n+1).split("#").map((o)=>Us(e,js,o)).join("#");return Me(e,t.slice(0,n+1)+r)}var ud=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,pd=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,fd=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,hd=131072;function At(e,t){if(t.length>hd)return`[body omitted: ${t.length} bytes, unmaskable]`;let n=qs(t).replace(fd,(r,o)=>Ks(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(pd,(r,o,i,s)=>{if(js(e,Tt(i)))return`${o}${i}=[redacted]`;if(Ws(e,Tt(s)))return`${o}${i}=[redacted]`;return r}).replace(ud,(r,o,i,s,a)=>{if(a==="[redacted]")return r;return te(e,o)?`${o}${i}${s}[redacted]${s}`:r});return Me(e,n)}function gd(e){switch(Ae(e)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var md=64;function Mt(e,t,n){if(n>md)return"[redacted]";if(Array.isArray(t))return t.map((r)=>Mt(e,r,n+1));if(t!==null&&typeof t==="object"){let r={};for(let[o,i]of Object.entries(t))if(te(e,o))r[o]="[redacted]";else if(typeof i==="string"&&gd(o))r[o]=Nn(e,i);else r[o]=Mt(e,i,n+1);return r}return typeof t==="string"?Me(e,t):t}function Bs(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 bd(e,t){for(let n of t.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(te(e,Bs(n[1])))return"";return t.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(n,r,o)=>te(e,Bs(o))?`${r}"[redacted]"`:n)}function Hn(e){let t=e.trimStart();return t.startsWith("{")||t.startsWith("[")}function kd(e,t,n){let r=/boundary="?([^";]+)"?/i.exec(n);if(!r)return null;let o=`--${r[1]}`,i=t.split(o);if(i.length<3||i[0]!=="")return null;if(!i[i.length-1].startsWith("--"))return null;let s=[i[0]];for(let a=1;a<i.length-1;a++){let l=i[a];if(!l.startsWith(`\r
2
2
  `)||!l.endsWith(`\r
3
3
  `))return null;let d=l.indexOf(`\r
4
4
  \r
5
- `);if(d<0)return null;let p=l.slice(2,d),h=l.slice(d+4,-2),f=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(p)?.[1]??"",g=f!==""&&Z(e,f)?"[redacted]":Ct(e,h);s.push(`\r
5
+ `);if(d<0)return null;let p=l.slice(2,d),h=l.slice(d+4,-2),f=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(p)?.[1]??"",g=f!==""&&te(e,f)?"[redacted]":At(e,h);s.push(`\r
6
6
  ${p}\r
7
7
  \r
8
8
  ${g}\r
9
- `)}return s.push(i[i.length-1]),s.join(o)}var ws=262144;function fs(e,t,n){if(e.full||!t)return t;try{if(Mn(t)){if(t.length<=ws)try{return JSON.stringify(Tt(e,JSON.parse(t),0))}catch{}return Ee(e,Zc(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return Ct(e,vs(e,Z,t));if(r.includes("multipart/form-data")){let o=Qc(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return Ct(e,t)}catch{return"[redacted]"}}function xs(e,t){if(t===void 0)return;if(e.full)return t;if(Mn(t))try{return JSON.stringify(Tt(e,JSON.parse(t),0))}catch{}try{return Ct(e,t)}catch{return"[redacted]"}}function Ss(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(Mn(t)&&t.length<=ws){let i=fs(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 fs(e,o,r)}function Rs(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):ms(e,s)?"[redacted]":Ee(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function Es(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var Ce=Tn(null);function Ts(e){Ce=Tn(e??null)}function At(e){return xs(Ce,e)}function Ln(e,t,n){return Ss(Ce,e,t,n)}var Cs=null,As=null;function Pn(e){As=e??null}function ed(e){let t=As??Ve().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(Cs!==t)Cs=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return td(e)??hs}function td(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function B(e){return An(Ce,ed(e))}function Ms(){return B(y.pathname)}var nd=4;function In(e){return e.type===nd}function On(e){if(!In(e))return e;return{...e,data:{...e.data,href:B(e.data.href)}}}function Xe(e){return Rs(Ce,e)}function Mt(){return Es(Ce)}var Ls=30000,rd=4194304,od=20000,Nn=500,id=2000,sd=2,Ps={windowMs:Ls,checkoutMs:Ls,maxBytes:rd,maxEvents:od,maxLaneEvents:Nn},ee=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function Hn(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var ad=new TextEncoder,ne=!1,Is=0,P=Ps,w=[],D=[],j=[],Q=[],ld=0,Ae=[],Me=new Map,Le=null,Te=null,Ge=!1,cd=0,te=null,Lt=null,Dn=Promise.resolve();function Os(e=Ps){if(Fn(),ne=!0,Is++,P=e,te=e.store??null,w=(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),j=[],Q=[],Ae=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),Me.clear(),Le=null,It(Date.now()),te)Lt=setInterval(Pt,id)}function _s(){Pt(),Fn(),ne=!1,te=null,w=[],D=[],j=[],Q=[],Ae=[],Me.clear(),Le=null}function Ds(){return P}function Bn(e){Te=e}function Ns(){if(!ne)return;w=[],D=[],j=[],Q=[],Ae=[],Me.clear(),Le=null;let e=y.tabId;de((t)=>t.clear(e)),Te?.()}function Hs(){return Dn}function Pt(){if(!ne||!te)return;let e=Date.now();It(e),zn(e);for(let t of w){if(t.stored)continue;let n=Me.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;Me.set(t.id,{events:t.events.length,parts:o+1});let i=Bs(t);de((s)=>s.putWindowChunk(i,o,r,[]))}dd(e)}function dd(e){let t=e-P.windowMs;while(Q.length>0&&Q[0].lastMs<=t){let[a]=Q.splice(0,1);if(a)de((l)=>l.dropWindow(a.id))}for(let a of Ae.filter((l)=>l.lastMs<=t))de((l)=>l.dropWindow(a.id));Ae=Ae.filter((a)=>a.lastMs>t);let n=j;if(!n.length)return;j=[];let r=Q.at(-1);if(!r||r.startMs<=t)r={id:`${ee}.lanes.${++ld}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},Q.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:y.tabId,scope:P.scope??"",kind:"lanes",load:ee,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};de((a)=>a.putWindowChunk(s,o,"[]",n))}function Fn(){if(Lt)clearInterval(Lt);Lt=null}function Bs(e){return{id:e.id,tab:y.tabId,scope:P.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function de(e){let t=te;if(!t)return;Dn=Dn.then(()=>e(t)).catch((n)=>{if(te!==t)return;te=null,Fn(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function _n(e){let[t]=w.splice(e,1);if(!t)return;Me.delete(t.id),de((n)=>n.dropWindow(t.id))}function It(e){while(w.length>0){let r=w[0],o=w[1];if(!o&&r.load===ee)break;if(Hn(r,o)>e-P.windowMs)break;_n(0)}if(Ge)return;let t=w.at(-1);if(t&&t.load===ee&&Te&&t.lastMs<=e-P.windowMs){Ge=!0;try{Te()}finally{Ge=!1}let r=w.indexOf(t);if(r>=0&&r<w.length-1)for(let o=r;o>=0;o--)_n(o)}let n=!1;while(w.length>0&&ud()){if(w.length===1&&w[0].load===ee&&!n&&Te){n=!0,Ge=!0;try{Te()}finally{Ge=!1}if(w.length>1)continue}_n(0),Le=w[0]?.startMs??e}}function $n(){return ne?`flight:${Is}`:null}function zn(e){let t=Math.min(w[0]?.startMs??Number.POSITIVE_INFINITY,e-P.windowMs),n=D.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)D=[];else if(n>0)D=D.slice(n)}function ud(){let e=0,t=0;for(let n of w)e+=n.bytes,t+=n.count;return e>P.maxBytes||t>P.maxEvents}function Fs(e){if(!ne)return;let t=w[0];if(In(e)){let r=globalThis.location?.pathname??y.pathname,o={id:`${ee}.${++cd}`,load:ee,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:B(r)};w.push(o);let i=Bs(o);de((s)=>s.putWindow(i))}let n=w.at(-1);if(!n||n.load!==ee)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=ad.encode(JSON.stringify(e)).length,It(e.timestamp),w[0]!==t)zn(e.timestamp)}function Kn(e,t,n){if(!ne)return null;let r=P.keepLane?P.keepLane(e,t):t;if(r===null)return null;let o=new Date().toISOString(),i={ts:o,tabId:n.tabId,tabHost:n.tabHost,kind:e,payload:r},s=P.maxLaneEvents;if(D.push(i),D.length>s)D.splice(0,D.length-s);if(te){if(j.push(i),j.length>s)j.splice(0,j.length-s)}return o}function Ot(){if(!ne)return null;let e=Date.now();return It(e),zn(e),{windows:w.map((t)=>({...t,events:t.events.slice()})),lanes:D.slice(),truncated:Le!==null&&Le>e-P.windowMs}}function qn(e){return e.windows.some((t)=>t.events[1]?.type===sd)}var Wn=null;function Je(){if(!Wn)Wn=typeof indexedDB>"u"?pd():fd();return Wn}function pd(){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 fd(){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 hd=2000,Yn=20000,Ys=200,gd=4194304,md=3145728,Ft=500,bd=gd-1024,yd=12582912,kd=10485760,vd=yd-64,wd=1048576,xd=new TextEncoder;function Ne(e){return xd.encode(e).length}var C=()=>R();function Y(e,t){let n=C().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var $s=!1;function X(e,t){try{return C().set(e,t),!0}catch(n){if(!$s)$s=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var Dt="rec",fe;function S(){if(fe===void 0)fe=Y(Dt,null);return fe}function $t(e){if(fe=e,e===null)C().remove(Dt),C().remove(Sd);else X(Dt,JSON.stringify(Rd(e)))}var Sd="notes";var Qe=null;function Rd(e){if(Qe?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:Qe.activeMs,resumeAt:null,stopping:Qe.at}}var Ed=new Set;function Cd(){for(let e of Ed)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function Td(e){let t=null;if(e)try{t=JSON.parse(e)}catch{return"unchanged"}let n=S();if(t?.stopping&&t.sessionId===n?.sessionId&&!n.paused&&Qe?.sessionId!==t.sessionId)Cd();if(!t){if(!n)return"unchanged";return fe=null,Vs(),Hd(),"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(Qe?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return fe=t,"updated"}return fe=t,Vs(),"joined"}var Ad=700,he,V=null,se=!1;function Ie(){if(he===void 0)he=Y("buffer",[]);return he}function zt(){if(V)clearTimeout(V),V=null;if(he!==void 0&&!se)X("buffer",JSON.stringify(he))}function Xs(){if(se=!1,V)return;V=setTimeout(()=>{V=null,zt(),Gs()},Ad)}function Xn(e){he=e,se=!1,zt()}var Pe,Oe=0;function ue(){if(Pe===void 0)Pe=Y("chunks",[]),Oe=Pe.reduce((e,t)=>e+t.body.length,0);return Pe}function Gs(){if(se)return;let e=ue();if(e.length===0){C().remove("chunks");return}if(Oe>wd){C().remove("chunks");return}X("chunks",JSON.stringify(e))}function Js(e){Pe=e,Oe=e.reduce((t,n)=>t+n.body.length,0),se=!1,Gs()}var Nt,me=new Map,ge=new Set,be=new Map,et=new Map,zs=5,Md=200,Ld=67108864,Pd=0,Ks=!1,Gn="blobs";function N(){return Nt??=Y("images",[]),Nt}function Zs(){if(se)return;let e=N().filter((t)=>!ge.has(t.blob));if(e.length===0)C().remove("images");else X("images",JSON.stringify(e))}function Jn(e){Nt=e,se=!1,Zs()}function Id(e,t){let n=Je();if(!n.durable&&!Ks)Ks=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");X(Gn,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${ra}.${++Pd}`;return me.set(a,i),ge.add(a),r.push(n.put(a,i).then(()=>{if(!(me.has(a)||N().some((d)=>d.blob===a)||[...be.values()].includes(a)))return ge.delete(a),Zn(a),!1;if(!n.durable)return!1;if(ge.delete(a),N().some((d)=>d.blob===a))Zs();return!0},(l)=>(console.warn("vitrinka: an attached image could not be journaled — it will not survive a reload",l),!1))),{blob:a,payload:s}}),journaled:Promise.all(r).then((i)=>i.every(Boolean))}}function Zn(e){Je().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function _e(e,t){for(let n of e)if(me.delete(n),ge.delete(n),et.delete(n),t)Zn(n)}var Ht=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];async function Qs(e){if(!C().getString(Gn))return;let t=Je(),n=S()?.sessionId;try{let r=await t.keys(),o=0;for(let i of r)if(e?i.startsWith(`${e}/`):!n||!i.startsWith(`${n}/`))await t.delete(i);else o++;if(o===0&&!S())C().remove(Gn)}catch(r){console.warn("vitrinka: blob journal cleanup failed",r)}}var Od=0,ea="",ta=0,qs=-1;function Qn(){Od=Date.now(),ta=0,ea=""}function De(e){ta++,ea=String(e instanceof Error?e.message:e).slice(0,200)}var Ws={actions:0,pages:0,frames:0,notes:0},_d=new Set;function Dd(e){let t={...Ws};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")_d.add(n.payload.cid)}Ws=t}function Nd(e){let t=S();if(!t||t.dead)return;if(t.dead=!0,t.deadReason=e,!t.paused&&t.resumeAt)t.activeMs=(t.activeMs||0)+(Date.now()-Date.parse(t.resumeAt)),t.resumeAt=null;$t(t),console.warn("vitrinka: session marked dead —",e),I()}var Un=null;function Hd(){if(Un)clearInterval(Un);Un=null}function na(e){let t=S();if(!t||t.dead||e<1)return null;let n=Y("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return C().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,$t(t),{seq:r,sessionId:t.sessionId}}var ra=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,Bt="allocation.",Bd=0,O=new Set,Fd=16777216,tt=0,nt=0,ie=new Map;function Kt(e){return e.kind==="event"?1+(e.images?.length??0):1}function $d(e,t){return new Set(Array.from({length:Kt(t)},(n,r)=>e+r))}function er(e,t,n){return JSON.stringify(n&&n.size<Kt(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var Us=!1,Ze=null;function _t(e){if(!O.delete(e))return;if(tt-=e.bytes,e.draft.kind==="chunk")nt--}function oa(e){if(O.add(e),tt+=e.bytes,e.draft.kind==="chunk")nt++;while(O.size>Yn||tt>Fd||nt>Ys){let t=O.values().next().value;_t(t),C().remove(t.key),_e(Ht(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");De(n),console.warn(n.message)}}function ia(e=!1){if(Us&&!e)return;Us=!0;let t=C();if(!t.withLock)return;let n=new Set([...O].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(Bt)||n.has(r)||ie.has(r))continue;let o=Y(r,null);if(o&&o.draft&&o.draft.sessionId===S()?.sessionId)oa({...o,key:r,persisted:!0,bytes:Ne(JSON.stringify(o))})}}function sa(e,t,n){let{ts:r,tabId:o,tabHost:i,sessionId:s}=e,a=(l)=>!n||n.has(l);if(e.kind==="event"){let l=e.images??[],d=t+l.length,p=l.length?{...e.event,payload:{...e.event.payload,attachments:l.map((u,f)=>t+f)}}:e.event,h=Ie();if(a(d)&&!h.some((u)=>u.seq===d))h.push({seq:d,ts:r,tabId:o,tabHost:i,...p});if(l.length){let u=N();l.forEach((g,k)=>{let b=t+k;if(!a(b)||u.some((v)=>v.seq===b))return;if(h.some((v)=>v.seq===b)){be.set(b,g.blob);return}u.push({seq:b,ts:r,tabId:o,tabHost:i,sessionId:s,blob:g.blob,payload:g.payload})});let f=u.reduce((g,k)=>g+k.payload.bytes,0);while(u.length>Md||f>Ld){let g=u.shift();f-=g.payload.bytes,oe(g.sessionId,new Set([g.seq])),_e([g.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${g.payload.name} (seq ${g.seq}); its note lands without it`)}Jn(u)}if(h.length>Yn){let u=h.splice(0,h.length-Yn);oe(s,new Set(u.map((f)=>f.seq))),console.warn(`vitrinka: retry buffer full — dropped ${u.length} oldest events`)}}else{let l=ue();if(!l.some((d)=>d.seq===t)&&!Ie().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),Oe+=e.part.body.length;while(l.length>Ys){let d=l.shift();Oe-=d.body.length,oe(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}Xs(),pe()}function oe(e,t){for(let[n,r]of ie){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?Y(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)X(n,er(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){C().remove(n),ie.delete(n);let s=n.slice(Bt.length,n.lastIndexOf(".")),a=`tab.${s}`,l=Y(a,null);if(l?.departed&&l.recoverable&&!C().keys?.().some((d)=>d.startsWith(`${Bt}${s}.`)))C().remove(a)}}}function aa(){if(Ze)return Ze;let e=C();return Ze=tr(Promise.resolve().then(async()=>{for(let t of O)await e.withLock("seq",()=>{if(!O.has(t))return;if(t.persisted){let o=Y(t.key,null);if(!o){_t(t),_e(Ht(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(Td(e.getString(Dt)??null),S()?.sessionId!==t.draft.sessionId){_t(t),_e(Ht(t.draft),!0);return}let n=t.seq??na(Kt(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):$d(n,t.draft);if(t.persisted)e.set(t.key,er(t.draft,n,r));ie.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),sa(t.draft,n,r),_t(t)})}).catch((t)=>{throw De(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),pe(),I(),t})).finally(()=>{Ze=null}),Ze}function la(e,t){let n=S(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(ia(),C().withLock){let o=`${Bt}${ra}.${++Bd}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&X(o,i),bytes:Ne(i)};oa(s),aa(),t?.then((a)=>{if(a)zd(s)})}else{let o=na(Kt(e));if(o)sa(e,o.seq);else _e(Ht(e),!0)}return!0}function zd(e){let t=ie.get(e.key);if(t)t.persisted=X(e.key,er(e.draft,e.seq,t.seqs));else if(O.has(e))e.persisted=X(e.key,JSON.stringify({draft:e.draft}))}var js=new Set;function tr(e){return js.add(e),e.catch(()=>{return}).finally(()=>{js.delete(e)})}function re(e){return S()?.sessionId!==e.sessionId}function G(e,t,n,r=[]){if(Ue.following)return null;if(St()==="report")return Kn(e,t,n);let o=S();if(!o)return Kn(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?Id(o.sessionId,r):null;return la({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),nr(),i}function ca(e){Ie().push(e),nr(),Xs(),pe()}var Kd=Date.now();function nr(){Kd=Date.now()}function rr(e,t=kd,n=vd){let r=[],o=[],i=[],s=2,a=()=>{if(!i.length)return;r.push({count:i.length,body:`[${i.join(",")}]`}),i=[],s=2};for(let l of e){let d=JSON.stringify(l),p=Ne(d)+1;if(p>n){o.push(p);continue}if(p>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+p>t)a();i.push(d),s+=p}return a(),{parts:r,dropped:o}}function da(e,t){if(!e.length)return 0;let n=S();if(!n||n.paused||n.dead||Ue.following)return 0;let{parts:r,dropped:o}=rr(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),G("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(!la({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return nr(),r.length}async function qd(e=5){let t=ue();if(t.length===0)return!0;let n=S(),r=0,o=new Set;for(let i of t){if(r>=e)break;if(r++,!n||i.sessionId!==n.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${i.seq} from ended session ${i.sessionId}`),o.add(i.seq);continue}try{let s=await cs(n.sessionId,i.seq,i.body);if(re(n))return ue().length===0;ca({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),Qn(),o.add(i.seq)}catch(s){if(re(n))return ue().length===0;if(s instanceof T&&U(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),oe(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}De(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Js(ue().filter((i)=>!o.has(i.seq)));return ue().length===0}async function Wd(e=4){let t=N();if(t.length===0)return!0;let n=S(),r=0,o=new Set,i=[];for(let s of t){if(r>=e)break;if(r++,!n||s.sessionId!==n.sessionId){console.warn(`vitrinka: dropping attachment seq ${s.seq} from ended session ${s.sessionId}`),o.add(s.seq),i.push(s.blob);continue}let a=me.get(s.blob)??null;if(!a){try{a=await Je().get(s.blob),et.delete(s.blob)}catch(l){if(re(n))return N().length===0;let d=(et.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${zs})`,l),d<zs){et.set(s.blob,d),De(l);break}}if(re(n))return N().length===0}if(!a){console.warn(`vitrinka: attachment seq ${s.seq} (${s.payload.name}) lost its bytes — its note lands without it`),oe(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await ds(n.sessionId,s.seq,a);if(re(n))return N().length===0;ca({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),me.delete(s.blob),be.set(s.seq,s.blob),Qn(),o.add(s.seq)}catch(l){if(re(n))return N().length===0;if(l instanceof T&&U(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),oe(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}De(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)zt(),Jn(N().filter((s)=>!o.has(s.seq)));return _e(i,!0),N().length===0}var jn=null;function pe(){if(jn)return;jn=setTimeout(()=>{jn=null,Ud()},hd)}var Vn=!1;async function Ud(e={}){if(Vn)return!1;Vn=!0;try{return await jd(e)}finally{Vn=!1}}async function jd(e){if(S()?.dead)return!1;if(ia(!0),O.size)await aa();if(O.size)return!1;let t=await qd(),n=e.keepalive?N().length===0:await Wd(),r=t&&n;if(!r)pe();let o=S(),i=Ie();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:md;for(let u of i){if(s.length>=Ft)break;let f=Ne(JSON.stringify(u))+1;if(f>bd){console.warn(`vitrinka: event seq ${u.seq} (${f} bytes) exceeds the wire cap — dropped`),a.add(u.seq);continue}if(f>d){if(e.keepalive)break;if(s.length===0)s.push(u),l=f;break}if(s.length>0&&l+f>d)break;s.push(u),l+=f}if(a.size){if(oe(o.sessionId,a),Xn(Ie().filter((u)=>!a.has(u.seq))),!s.length)return pe(),!1}if(!s.length)return!1;zt();try{await J("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(u){if(re(o))return!1;if(u instanceof T&&U(u.status))return Nd(`server rejected this session (${u.status})`),!1;return De(u),I(),console.warn("vitrinka: flush failed, retrying",u),pe(),!1}if(re(o))return!0;Qn(),qs=Math.max(qs,...s.map((u)=>u.seq)),Dd(s);let p=new Set(s.map((u)=>u.seq));oe(o.sessionId,p);let h=Ie().filter((u)=>!p.has(u.seq));Xn(h),I();for(let u of p){let f=be.get(u);if(f===void 0)continue;be.delete(u),Zn(f)}if(h.length)pe();return!0}function ua(){for(let e of ie.keys())C().remove(e);for(let e of O)C().remove(e.key);ie.clear(),O.clear(),tt=nt=0,Xn([]),Js([]),me.clear(),ge.clear(),be.clear(),et.clear(),Jn([])}function Vs(){if(V)clearTimeout(V),V=null;he=[],Pe=[],Oe=0,Nt=[],me.clear(),ge.clear(),be.clear(),O.clear(),tt=nt=0,ie.clear(),se=!0}var pa="0.11.0";var Pf={from:"page",inst:ss("p")};var Vd=!1;function fa(){return Vd}var ga="vitrinka.report.face",ha=(e)=>e.trim().replace(/\/+$/,"");function qt(){try{return globalThis.localStorage??null}catch{return null}}function He(e){let t=ce();if(!t)return!1;if(t.base)return ha(t.base)===ha(e);try{let n=xt(e);return n===void 0||n===t.workspace}catch{return!1}}function ye(e){return He(e)?ce()?.token??"":""}function ma(e){return/revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(e)}function Yd(){let e=qt()?.getItem(ga);return e==="recorder"||e==="report"?e:null}function or(e){try{qt()?.setItem(ga,e)}catch(t){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",t)}}var ba="vitrinka.report.mode";function ya(e){try{if(e==="dev"||e==="regular")qt()?.setItem(ba,e)}catch(t){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",t)}}function ka(e){if(!He(e))return"report";let t=Yd();if(t)return t;return qt()?.getItem(ba)==="dev"?"recorder":"report"}function va(){return S()!==null||fa()}function Wt(e){let t=R().watch?.(Ye,()=>e()),n=es(e);return()=>{t?.(),n()}}var wa=["bug","suggestion","question","other"];function Be(e,t,n,r){if(e===1)return t;if(e>=2&&e<=4)return n;return r}var Xd={button:"Report a problem",title:"Report a problem",close:"Close",settings:"Settings",prompt:"What went wrong?",placeholder:"Tell us what happened and what you expected",attached:(e)=>{if(e<60)return`The last ${e} seconds are attached`;let t=Math.round(e/60);return t===1?"The last minute is attached":`The last ${t} minutes are attached`},included:"What’s included",incReplay:"A replay of what happened on this page",incReplayMasked:{strict:"Text on the page and anything you typed are hidden in it",balanced:"Anything you typed is hidden in it",full:"It shows the page as you saw it"},incErrors:"Errors the page ran into",incConsole:"Messages from the browser console",incNetwork:"Which addresses the page loaded, with their status",incFailedRequests:"Requests that failed — address and status only",incEnv:"Your browser, screen size, language and this page’s address",incIdentity:"Your name and email from this app",incMarks:"The places you marked, with your notes",showWhere:"Show us where",kinds:{bug:"Bug",suggestion:"Suggestion",question:"Question",other:"Other"},kindsLabel:"What is it?",linesEmpty:"Each place you mark gets a line here for its note.",notify:"Email me when it’s fixed",send:"Send",sending:"Sending…",retry:"Try again",errorCreate:"Couldn’t send — your text is safe, try again",errorCapture:"Your report arrived, the recording not yet — try again to attach it",sentTitle:"Thanks — we’ve got it",sentBody:"The team will take a look.",sentNotify:"We’ll email you when it’s fixed.",seeReport:"See your report",tools:{circle:"Circle",box:"Box",arrow:"Arrow",hide:"Cover"},toolbar:"Marking tools",barLead:"Mark where the problem is",barLeadHide:"Cover what the team shouldn’t see",cancelMarking:"Cancel",discardMarks:(e)=>e===1?"Discard 1 mark?":`Discard ${e} marks?`,discard:"Discard",keep:"Keep",coach:{box:"Click, hold and move across the problem.",circle:"Click, hold and move around the problem.",arrow:"Click, hold and move from a clear spot to the problem.",hide:"Click, hold and move across anything private — it stays blank in what you send."},coachMore:"You can mark more than one place.",coachDismiss:"Got it, don’t show again",coachSetting:"Marking tips",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Covered — not sent",notePlaceholder:"Add a note (optional)",mark:(e)=>`Mark ${e}`,removeMark:(e)=>`Remove mark ${e}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back",account:"Your account",menu:"Menu",anonymous:"Not signed in",anonymousHint:"The team checks your report before it’s filed.",signedInByApp:"Signed in by this app",linkVitrinka:"Link your vitrinka account",linkedAs:(e)=>`Linked to vitrinka as ${e}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(e)=>`Remove ${e}`,fileTooBig:(e,t)=>`${e} is over the ${t} limit`,tooManyFiles:(e)=>e===1?"Up to 1 file per report":`Up to ${e} files per report`,fileType:(e,t)=>`${e} can’t be attached — ${t} only`,typeNames:{image:"images",pdf:"PDF",text:"text files",office:"office documents"},incFiles:"The files you attached",errorFiles:"Your report arrived, a file not yet — try again to attach it",moveHint:"Click, hold and move it to another corner, or press Alt and an arrow key.",size:"Size",sizes:{sm:"Small",md:"Medium",lg:"Large"},techDetails:"Technical details",techVersion:"Version",techWindow:"Capture window",techCapture:"Capture",techBuffer:"Buffer",techServer:"Server",captureOn:"Running",captureOff:"Off",captureStarting:"Starting…",bufferMemory:"In memory",bufferBrowser:"In this browser",windowLength:(e)=>{if(e<60)return e===1?"1 second":`${e} seconds`;let t=Math.round(e/60);return t===1?"1 minute":`${t} minutes`}},Gd={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 Be(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 Be(t,"Poslední minuta je přiložena",`Poslední ${t} minuty jsou přiloženy`,`Posledních ${t} minut je přiloženo`)},included:"Co je přiloženo",incReplay:"Záznam toho, co se na stránce dělo",incReplayMasked:{strict:"Texty stránky i vše, co jste napsali, jsou v něm skryté",balanced:"Vše, co jste napsali, je v něm skryté",full:"Ukazuje stránku tak, jak jste ji viděli"},incErrors:"Chyby, na které stránka narazila",incConsole:"Zprávy z konzole prohlížeče",incNetwork:"Které adresy stránka načítala a s jakým výsledkem",incFailedRequests:"Požadavky, které selhaly — jen adresa a výsledek",incEnv:"Váš prohlížeč, velikost obrazovky, jazyk a adresa stránky",incIdentity:"Vaše jméno a e-mail z této aplikace",incMarks:"Místa, která jste označili, i s poznámkami",showWhere:"Ukažte nám kde",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Dotaz",other:"Jiné"},kindsLabel:"Co to je?",linesEmpty:"Každé označené místo tu dostane řádek pro poznámku.",notify:"Pošlete mi e-mail, až to bude opravené",send:"Odeslat",sending:"Odesílám…",retry:"Zkusit znovu",errorCreate:"Nepodařilo se odeslat — váš text zůstal, zkuste to znovu",errorCapture:"Hlášení dorazilo, záznam zatím ne — zkuste to znovu a přiložíme ho",sentTitle:"Díky — máme to",sentBody:"Tým se na to podívá.",sentNotify:"Až to bude opravené, pošleme vám e-mail.",seeReport:"Zobrazit hlášení",tools:{circle:"Kruh",box:"Obdélník",arrow:"Šipka",hide:"Zakrýt"},toolbar:"Nástroje pro označení",barLead:"Označte, kde je problém",barLeadHide:"Zakryjte, co tým nemá vidět",cancelMarking:"Zrušit",discardMarks:(e)=>Be(e,"Zahodit 1 značku?",`Zahodit ${e} značky?`,`Zahodit ${e} značek?`),discard:"Zahodit",keep:"Ponechat",coach:{box:"Klikněte, podržte a veďte přes problém.",circle:"Klikněte, podržte a veďte kolem problému.",arrow:"Klikněte, podržte a veďte z volného místa k problému.",hide:"Klikněte, podržte a veďte přes vše soukromé — v hlášení zůstane prázdné."},coachMore:"Označit můžete i více míst.",coachDismiss:"Chápu, už nezobrazovat",coachSetting:"Nápověda při označování",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Zakryto — neodešle se",notePlaceholder:"Přidejte poznámku (nepovinné)",mark:(e)=>`Značka ${e}`,removeMark:(e)=>`Odebrat značku ${e}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět",account:"Váš účet",menu:"Nabídka",anonymous:"Nepřihlášeno",anonymousHint:"Hlášení nejdřív zkontroluje tým.",signedInByApp:"Přihlášen touto aplikací",linkVitrinka:"Propojit s vitrinkou",linkedAs:(e)=>`Propojeno s vitrinkou jako ${e}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(e)=>`Odebrat ${e}`,fileTooBig:(e,t)=>`${e} přesahuje limit ${t}`,tooManyFiles:(e)=>Be(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 Be(e,"1 sekunda",`${e} sekundy`,`${e} sekund`);let t=Math.round(e/60);return Be(t,"1 minuta",`${t} minuty`,`${t} minut`)}},Jd={cs:Gd,en:Xd};function ir(e){return Jd[e]}function rt(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"?t:null}function sr(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=rt(n);if(r)return r}return"en"}var xa="recents",Sa=5,Zd=["recording","saved","unsaved","deleted"];function Qd(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.sessionId==="string"&&typeof t.title==="string"&&typeof t.startedAt==="number"&&Zd.includes(t.status)}var Fe;function ar(){if(Fe===void 0)try{let e=JSON.parse(R().getString(xa)??"[]");Fe=Array.isArray(e)?e.filter(Qd).slice(0,Sa):[]}catch{Fe=[]}return Fe}function eu(e){Fe=e.slice(0,Sa);try{R().set(xa,JSON.stringify(Fe))}catch(t){console.warn("vitrinka: could not store recent recordings",t)}I()}function Ra(e,t){let n=ar();if(!n.some((r)=>r.sessionId===e))return;eu(n.map((r)=>r.sessionId===e?{...r,...t}:r))}var ke="data-vitrinka-recorder";var lr="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;",Ea=lr;var tu=["pointerdown","pointerup","pointermove","pointerover","pointerout","pointercancel","mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchmove","touchcancel","wheel","focusin","focusout","keydown","keyup","keypress","paste","dragenter","dragover","dragleave","drop"];function Ma(e){for(let t of tu)e.addEventListener(t,(n)=>n.stopPropagation())}var nu=["keydown","keyup","keypress"],ru=["vitrinkaHud","vitrinkaSheet"],Ca=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),ou=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),iu=new Set(["text","search","email","url","tel","password","number"]);function su(e){let t=e.key.length===1;if(t&&e.getModifierState?.("AltGraph"))return!0;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return t||Ca.has(e.key);if(Ca.has(e.key))return!0;return(e.ctrlKey||e.metaKey)&&!e.altKey&&ou.has(e.code)}function au(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"&&iu.has(e.type)}function lu(e){if(typeof e!=="object"||e===null||!("dataset"in e))return!1;let t=e.dataset;return typeof t==="object"&&t!==null&&ru.some((n)=>(n in t))}function cu(e){if(!su(e))return!1;let t=e.composedPath();return au(t[0])&&t.some(lu)}var Ta=0,Ut=null;function La(){if(Ta++,!Ut&&typeof window<"u"){let t=(r)=>{if(cu(r))r.stopImmediatePropagation()},n=nu.map((r)=>L(window,r,t,{capture:!0}));Ut=()=>{for(let r of n)r()}}let e=!0;return()=>{if(!e)return;if(e=!1,--Ta>0)return;Ut?.(),Ut=null}}function Pa(){let e=document.createElement("div");e.setAttribute(ke,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=lr;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),Ma(e);let r=La();document.documentElement.append(e);let o=typeof e.showPopover==="function",i=()=>{if(!o||!e.isConnected)return;try{e.hidePopover?.()}catch{}try{e.showPopover?.()}catch{}};if(o)e.popover="manual";i();let s=!1,a=()=>{if(s)return;s=!0,queueMicrotask(()=>{s=!1,i()})},l=(f)=>{if(f.type==="attributes")return f.target instanceof Element&&Aa(f.target);for(let g of[f.addedNodes,f.removedNodes])for(let k of g){if(!(k instanceof Element))continue;if(Aa(k))return!0;if(k.childElementCount>0&&k.querySelector(Ia))return!0}return!1},d=[],p=0,h=()=>{p=0;let f=d;if(d=[],f.some(l))a()},u=new MutationObserver((f)=>{for(let g of f)d.push(g);if(p===0)p=typeof requestAnimationFrame==="function"?requestAnimationFrame(h):setTimeout(h,16)});return u.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:e,mount:n,destroy:()=>{if(r(),u.disconnect(),p!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(p);d=[];try{e.hidePopover?.()}catch{}e.remove()}}}var Ia='dialog,[role="dialog"]';function Aa(e){return e.matches(Ia)}function Oa(){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 _a(e){let t=document.createElement("div");t.setAttribute(ke,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=Ea;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");n.append(r),Ma(t);let o=La();if(typeof t.showPopover==="function")t.popover="manual";return e.append(t),t.showPopover?.(),{mount:r,destroy:()=>{o(),t.remove()}}}function jt(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 du="me";var uu;function Da(){uu=null,R().remove(du)}var Na="";function ot(e=!1){let t=globalThis.location;if(!t)return!1;let n=t.href;if(Ji(t.pathname),n===Na&&!e)return!1;return Na=n,G("nav",{url:B(n),route:B(t.pathname),spa:!0},{tabId:y.tabId,tabHost:y.tabHost})!==null}var $e="__vitrinkaRecorderNavPatched",Vt="__vitrinkaRecorderNavUnpatch",cr={};function pu(){let e=globalThis;if(e[$e]||typeof history>"u")return;e[$e]=cr;let t=[],n=(o)=>{let i=history[o],s=history[o]=function(...a){let l=i.apply(this,a);return queueMicrotask(ot),l};t.push(()=>{if(history[o]===s)history[o]=i})};n("pushState"),n("replaceState");let r=()=>queueMicrotask(ot);addEventListener("popstate",r),addEventListener("hashchange",r),e[Vt]=()=>{for(let o of t.splice(0))o();removeEventListener("popstate",r),removeEventListener("hashchange",r),delete e[$e],delete e[Vt]}}function Ha(){let e=globalThis;if(e[$e]!==cr)return;e[Vt]?.()}function Ba(){let e=globalThis;if(e[$e]===cr)return!1;return e[Vt]?.(),delete e[$e],pu(),ot()}function Fa(e){if(!e)return 0;let t=e.activeMs||0;if(!e.paused&&e.resumeAt)t+=Date.now()-Date.parse(e.resumeAt);return t}function $a(){Rt(),Da();let e=S();if(e)Ra(e.sessionId,{status:"unsaved",durationMs:Fa(e)}),$t(null),ua(),Qs(e.sessionId);I()}var ae={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function fu(e,t){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:t}function za(e){if(typeof e!=="object"||e===null)return ae;let t={...e},n=Array.isArray(t.types)?t.types.filter((r)=>typeof r==="string"&&r.trim()!=="").map((r)=>r.trim().toLowerCase()):[];return{maxBytes:fu(t.maxBytes,ae.maxBytes),maxCount:typeof t.maxCount==="number"&&Number.isInteger(t.maxCount)&&t.maxCount>=0?t.maxCount:ae.maxCount,types:n.length?n:ae.types}}function hu(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 gu(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}function Ka(e,t,n){let r=[],o=null;for(let i of t){if([...e,...r].some((s)=>gu(s,i)))continue;if(!hu(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 it(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 qa(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 Wa(e,t){let n=/^image\.(\w+)$/i.exec(e);return n?`pasted-${t}.${n[1]}`:e}var dr=["sm","md","lg"],st={sm:0.88,md:1,lg:1.18},ur="vitrinka.report.size";function Ua(){try{return globalThis.localStorage??null}catch{return null}}function Yt(e){return Ua()?.getItem(e)??null}function at(e,t){try{Ua()?.setItem(e,t)}catch(n){console.warn(`vitrinka: could not remember ${e} on this browser`,n)}}function ja(){let e=Yt(ur);return dr.find((t)=>t===e)??"md"}var pr="vitrinka.report.coach";function Va(){return Yt(pr)!=="off"}function Ya(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} · ${it(n.profile.maxBytes,e.locale)}`:"—"],[t.techServer,o]]}var Xa="vitrinka.report.dock",Ga=6,fr={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},mu=["br","bl","tr","tl"];function bu(e){return e==="tl"||e==="tr"?"t":"b"}function yu(e){return e==="tl"||e==="bl"?"l":"r"}function Ja(){let e=Yt(Xa);return mu.find((t)=>t===e)??"br"}function Za(e){at(Xa,e)}function Qa(e,t,n){return fr[e.y<n/2?"t":"b"][e.x<t/2?"l":"r"]}function el(e,t){if(t==="ArrowLeft"||t==="ArrowRight")return fr[bu(e)][t==="ArrowLeft"?"l":"r"];if(t==="ArrowUp"||t==="ArrowDown")return fr[t==="ArrowUp"?"t":"b"][yu(e)];return null}function nl(e){if(!e)return"";if(e.id)return`#${e.id}`;let t=e.getAttribute("data-testid")||e.getAttribute("data-test");if(t)return`[data-testid="${t}"]`;let n=[],r=e;while(r&&n.length<4){let o=r.tagName.toLowerCase();if(r.classList.length)o+="."+[...r.classList].slice(0,2).join(".");if(n.unshift(o),r.id){n[0]=`#${r.id}`;break}r=r.parentElement}return n.join(" > ")}var ku="input,textarea,select",tl=".rr-mask,.rr-block";function rl(e){if(e.matches(ku)||e.closest(tl)||e.querySelector(tl))return"";return(e.innerText||"").trim().slice(0,80)}var vu="a,button,[role=button],input,select,textarea,label";function wu(e){let t=e.getBoundingClientRect(),n=globalThis.devicePixelRatio||1;return{x:Math.round(t.x*n),y:Math.round(t.y*n),w:Math.round(t.width*n),h:Math.round(t.height*n)}}function xu(e){if(Mt().maskAllText)return"";return At(rl(e))??""}function ol(e){let t=(n)=>{try{if(e.ignore(n.target))return;let r=n.target instanceof Element?n.target:null,o=r?r.closest(vu)||r:null;if(!o)return;G("click",{selector:nl(o),text:xu(o),rect:wu(o),route:Ms()},{tabId:y.tabId,tabHost:y.tabHost})}catch{}};return document.addEventListener("click",t,!0),()=>document.removeEventListener("click",t,!0)}var Su=8192,lt="__vitrinkaRecorderConsolePatched";function Xt(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,Su)}function Gt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;G("console",{level:t,text:At(e)},{tabId:y.tabId,tabHost:y.tabHost})}var hr="__vitrinkaRecorderConsoleUnpatch",il={};function sl(){let e=globalThis;if(e[lt]!==void 0&&e[lt]!==il)return;e[hr]?.()}function al(e={}){let t=globalThis;if(t[lt])return;t[lt]=il;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{Gt(Xt(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let p=console[d],h=p.bind(console),u=(...f)=>{h(...f);try{Gt(Xt(f),d)}catch{}};return console[d]=u,()=>{if(console[d]===u)console[d]=p}}),s=(d)=>{try{Gt(Xt([d.error??d.message]))}catch{}},a=(d)=>{try{Gt(`unhandled rejection: ${Xt([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[hr]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[lt],delete t[hr]}}var ll=65536,ct=524288,cl=3000;var gr="full";function br(){if(Ue.following)return null;if(St()==="report")return $n();let e=S();if(e)return!e.paused&&!e.dead?e.sessionId:null;return $n()}function dt(e){return e!==null&&br()===e}function Jt(e,t){if(typeof e==="string")return Ln(e,ll,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return Ln(e.toString(),ll,"application/x-www-form-urlencoded");return Ru(e)}function Ru(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 mr(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function yr(e){return typeof e==="string"||e instanceof URL?{}:e}function ut(e){let t=typeof e.url==="string"?B(e.url):e.url;G("net",{...e,url:t},{tabId:y.tabId,tabHost:y.tabHost})}function kr(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 Eu(e,t){let n=kr(t?.headers);if(n)return n;let r=yr(e);return kr(r.headers)}function Cu(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 vr(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function Tu(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function Au(e,t){let n=await Mu(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return Jt(n,r)}async function Mu(e,t){let n=Tu(t);if(n!==null&&n>ct)return vr(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()+cl;try{while(s<ct){let f=d-Date.now();if(f<=0){l=!0;break}let g,k=await Promise.race([o.read(),new Promise((x)=>{g=setTimeout(()=>x("timeout"),f)})]).finally(()=>{if(g!==void 0)clearTimeout(g)});if(k==="timeout"){l=!0;break}let{done:b,value:v}=k;if(b)break;if(v){let x=ct-s,m=v.byteLength>x?v.subarray(0,x):v;i.push(m),s+=m.byteLength}}a=s>=ct,o.cancel().catch(()=>{return})}catch{return}let p=new Uint8Array(s),h=0;for(let f of i)p.set(f,h),h+=f.byteLength;let u;try{u=new TextDecoder().decode(p)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${u}…[body read timed out after ${cl}ms]`;return a?`${u}…[truncated at ${ct} bytes]`:u}if(n===null)return vr(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var pt="__vitrinkaRecorderNetPatched",wr="__vitrinkaRecorderNetUnpatch",dl={};function ul(){let e=globalThis;if(e[pt]!==void 0&&e[pt]!==dl)return;e[wr]?.()}function pl(e={}){let t=globalThis;if(t[pt])return;t[pt]=dl,gr=e.detail??"full";let n=[];t[wr]=()=>{for(let u of n.splice(0))u();delete t[pt],delete t[wr]};let r=globalThis.fetch,o=async(u,f)=>{let g=typeof u==="string"?u:u instanceof URL?u.href:u.url,k=br();if(xn(g)||k===null)return r(u,f);let b=f?.method??("method"in yr(u)?yr(u).method:"GET"),v=Date.now();try{let x=await r(u,f),m=Date.now()-v;if(gr==="meta"){if(dt(k))ut({method:b,url:g,status:x.status,ms:m,via:"fetch"});return x}let M;try{M=x.clone()}catch{M=void 0}let{headers:ze,status:Ke}=x;return tr((async()=>{if(!dt(k)){if(M)vr(M);return}let kt=M?await Au(M,ze):void 0;if(!dt(k))return;let qe=Eu(u,f);ut({method:b,url:g,status:Ke,ms:m,reqHeaders:Xe(qe),resHeaders:Xe(kr(ze)),reqBody:Jt(f?.body,mr(qe)),resBody:kt,via:"fetch"})})()),x}catch(x){if(dt(k))ut({method:b,url:g,error:String(x),ms:Date.now()-v,via:"fetch"});throw x}};globalThis.fetch=o,n.push(()=>{if(globalThis.fetch===o)globalThis.fetch=r});let i=globalThis.XMLHttpRequest;if(!i?.prototype)return;let s=i.prototype.open,a=i.prototype.send,l=i.prototype.setRequestHeader;n.push(()=>{let u=i.prototype;if(u.open===d)u.open=s;if(u.send===h)u.send=a;if(u.setRequestHeader===p)u.setRequestHeader=l});let d=i.prototype.open=function(...u){return this.__vt={method:u[0],url:String(u[1])},s.apply(this,u)},p=i.prototype.setRequestHeader=function(u,f){let g=this.__vt;if(g)(g.reqHeaders??={})[u]=f;return l?.call(this,u,f)},h=i.prototype.send=function(u){let f=this.__vt,g=br();if(f&&!xn(f.url)&&g!==null){let k=Date.now();this.addEventListener("loadend",()=>{if(!dt(g))return;if(gr==="meta"){ut({method:f.method,url:f.url,status:this.status,ms:Date.now()-k,via:"xhr"});return}let b;try{b=Cu(this.getAllResponseHeaders())}catch{b=void 0}let v;try{v=this.responseType===""||this.responseType==="text"?Jt(this.responseText,mr(b)):void 0}catch{v=void 0}ut({method:f.method,url:f.url,status:this.status,ms:Date.now()-k,reqHeaders:Xe(f.reqHeaders),resHeaders:Xe(b),reqBody:Jt(u,mr(f.reqHeaders)),resBody:v,via:"xhr"})})}return a.call(this,u)}}var Lu=2000,Pu=300000,ht=null,gt=null,ft=[],Zt=null;function fl(){if(!ft.length)return;let e=ft;ft=[],da(e,{tabId:y.tabId,tabHost:y.tabHost})}function mt(){return gt}function hl(e,t,n={}){if(ht)return;let r=Mt(),o=n.unmaskSelector;try{ht=e({emit:t==="flight"?(s)=>Fs(On(s)):(s)=>{ft.push(On(s))},checkoutEveryNms:t==="flight"?Ds().checkoutMs:Pu,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:`[${ke}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(gt=e,t==="flight")Bn(Qt);if(t==="session")Zt=setInterval(fl,Lu)}function gl(){if(Zt)clearInterval(Zt);Zt=null,fl();try{ht?.()}catch{}ht=null,gt=null,Bn(null),ft=[]}function Qt(){if(!ht||!gt)return;try{gt.takeFullSnapshot?.(!0)}catch{}}var yl="vitrinka.capture",F="windows",z="chunks";function ve(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function xr(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function ml(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function bl(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 kl(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(yl,1);r.onupgradeneeded=()=>{r.result.createObjectStore(F,{keyPath:"id"}),r.result.createObjectStore(z)},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(F).delete(i),o.objectStore(z).delete(ml(i))};return{async putWindow(o){let i=t.transaction(F,"readwrite");i.objectStore(F).put(o),await ve(i)},async putChunk(o,i,s,a){let l=t.transaction(z,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(z).put(d,[o,i]),await ve(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([F,z],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(z).put(d,[o.id,i]),l.objectStore(F).put(o)}catch(p){throw l.abort(),p}await ve(l)},async dropWindow(o){let i=t.transaction([F,z],"readwrite");n(i,o),await ve(i)},async clear(o){let i=t.transaction([F,z],"readwrite"),s=await xr(i.objectStore(F).getAll());for(let a of s)if(bl(a)&&a.tab===o)n(i,a.id);await ve(i)},async sweep(o,i,s,a){let l=t.transaction([F,z],"readwrite"),d=(await xr(l.objectStore(F).getAll())).filter(bl),p=[],h=new Map;for(let u of d)h.set(u.tab,[...h.get(u.tab)??[],u]);for(let[u,f]of h){let g=f.filter((b)=>b.kind!=="lanes").sort((b,v)=>b.startMs-v.startMs),k=(b)=>b.kind==="lanes"?b.lastMs:Hn(b,g[g.indexOf(b)+1]);for(let b of f.sort((v,x)=>v.startMs-x.startMs))if(k(b)<=o-i||u===s&&b.scope!==a)n(l,b.id);else if(u===s)p.push(b)}return await ve(l),p},async read(o){let i=t.transaction(z,"readonly"),s=await xr(i.objectStore(z).getAll(ml(o)));await ve(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 vl(e=globalThis.indexedDB){try{e?.deleteDatabase(yl)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function Sr(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 Rr(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 wl(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 xl(e){return e.map((t,n)=>({...t,n:n+1}))}function Sl(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 Iu=2,Ou=3,_u=0,Du=5,Cr=2,Nu=3,Hu=2000000000,Bu="data-vitrinka-hidden",Fu="#1b1b1f";function $u(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:${Fu};z-index:2147483647;pointer-events:none;`;return{type:Cr,id:Hu+t,tagName:"div",attributes:{[Bu]:"",style:n},childNodes:[]}}function Tr(e,t,n,r){let o={...e};if(e.type===Nu&&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)=>Tr(i,t,n,r)),!r.done&&e.type===Cr&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function zu(e,t){(e.childNodes?.find((r)=>r.type===Cr)??e).childNodes?.push(...t)}function Ku(e,t){return Tr(e,t,[],{done:!0})}function Rl(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map($u);return e.map((o)=>{let i=o.data;if(o.type===Iu&&i.node){let s={done:!1},a=Tr(i.node,n,r,s);if(!s.done)zu(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==Ou||!n.size)return o;if(i.source===_u){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:Ku(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===Du){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function qu(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function Wu(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function Ar(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)=>qu(Wu(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 Uu=["errors","interactions","full","console","network"];var en={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function rn(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function tn(e,t,n){return Math.min(n,Math.max(t,e))}function ju(e){if(!Array.isArray(e))return null;return Uu.filter((t)=>e.includes(t))}function El(e,t){if(typeof e!=="object"||e===null)return rn(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":en.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?tn(Math.round(n.windowSec),10,3600):en.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?tn(Math.round(n.maxBytes),262144,67108864):en.maxBytes,classes:ju(n.classes)??en.classes}}function nn(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 Vu(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 Cl(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=nn(e.classes),s=nn(t.classes);o=Vu({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:tn(n,10,3600),maxBytes:tn(r,262144,67108864),classes:o}}function Tl(e){return e==="balanced"||e==="full"?e:"strict"}function Al(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var Ml="[data-vitrinka-unmask]";var Yu=3670016,Ll=4194240,Xu=2000,Mr=500,Gu=60000,on=/[A-Za-z0-9_-]{20,}/g;function H(e,t=""){return typeof e==="string"?e:t}function Ju(e){let t=e;if(e.includes("%"))try{t=decodeURIComponent(e)}catch{t=e}if(on.lastIndex=0,t===e||!on.test(t))return e.replace(on,"•••");return t.replace(on,"•••").replace(/[/?#%]/g,(n)=>encodeURIComponent(n))}function bt(e){let t=H(e),n;try{n=new URL(t,globalThis.location?.href??"http://localhost").pathname}catch{n=t.split(/[?#]/)[0]??""}return n.split("/").map(Ju).join("/").slice(0,300)}var Zu=`.rr-block,[${ke}]`;function Qu(e){return typeof Element<"u"&&e instanceof Element&&e.closest(Zu)!==null}function ep(e){try{let t=new URL(H(e),globalThis.location?.href??"http://localhost");return t.origin+bt(t.pathname)}catch{return bt(e)}}var tp=4;function np(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===tp&&o.length)s();if(!i&&Ne(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}var rp=300,op=80;function ip(e){if(typeof e!=="object"||e===null)return null;let t=e,n=(a)=>typeof t[a]==="number"&&Number.isFinite(t[a])?t[a]:null,[r,o,i,s]=[n("x"),n("y"),n("w"),n("h")];return r===null||o===null||i===null||s===null?null:{x:r,y:o,w:i,h:s}}function sp(e){return(t,n)=>{if(t==="click"){if(!e.replay)return null;let r=ip(n?.rect);return{selector:H(n?.selector).slice(0,rp),text:H(n?.text).slice(0,op),...r?{rect:r}:{},route:bt(n?.route)}}if(t==="nav"){if(!e.replay)return null;return{url:ep(n?.url),route:bt(n?.route),spa:!0}}if(t==="console"){let r=H(n?.level,"error");if(r==="error"?!(e.errors||e.console):!e.console)return null;return{level:r,text:H(n?.text).slice(0,Xu)}}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:H(n?.method,"GET").toUpperCase(),path:bt(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}function ap(e,t=!0){return e.filter((n)=>t&&n.kind==="click"||n.kind==="nav").slice(-Mr).map((n)=>({kind:n.kind,ts:n.ts,payload:n.payload??{}}))}async function lp(e){try{let t=await J("GET","/api/v1/report-config",void 0,{target:e}),n=typeof t.flightRecorder==="boolean"?t.flightRecorder:void 0;return{project:H(t.project),profile:t.captureProfile==null?rn(n):El(t.captureProfile,n),masking:Tl(t.profile),reachable:!0,attachments:za(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:rn(),masking:"strict",reachable:!1,attachments:ae}}}function Pl(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 Il{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(os(e.base));let t=await lp({url:e.base,key:e.key}),n=Cl(t.profile,e.capture),r=nn(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=Zi("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,Gi(Xi(),globalThis.location?.host??""),y.pathname=globalThis.location?.pathname??"/",Ts(Al(o.masking)),Pn(e.sanitizeUrl),this.capture.push(()=>Pn(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 kl();let d=await this.store.sweep(Date.now(),i,y.tabId,s);a=d;let p=this.store;l=(await Promise.all(d.filter((u)=>u.kind==="lanes").map((u)=>p.read(u.id)))).flatMap((u)=>u.lanes).sort((u,f)=>Date.parse(u.ts)-Date.parse(f.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else vl();if(!this.capturing)return this.store?.close(),this.store=null,o;if(Os({windowMs:i,checkoutMs:Math.min(Gu,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:Nn,keepLane:sp(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(_s),this.store&&typeof window<"u"){let d=()=>Pt();this.capture.push(L(window,"pagehide",d),L(document,"visibilitychange",d))}if(r.errors||r.console)al({levels:r.console?["warn","info","log"]:[]}),this.capture.push(sl);if(r.errors||r.network)pl({detail:"meta"}),this.capture.push(ul);if(r.replay){if(typeof document<"u")this.capture.push(ol({ignore:(p)=>jt(p)||Qu(p)}));if(!Ba())ot(!0);let d=await e.loadRecord(e.base).catch((p)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",p),null));if(d&&this.capturing)hl(d,"flight",{unmaskSelector:Ml}),this.capture.push(gl)}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)Hs().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};y.pathname=globalThis.location?.pathname??y.pathname;let e=Ot();if(e&&mt()&&!qn(e))Qt(),e=Ot();let t=this.store,n=e?.windows.filter((o)=>o.stored).map((o)=>o.id)??[],r=t&&n.length?Promise.all(n.map(async(o)=>[o,await t.read(o)])).then((o)=>new Map(o)):Promise.resolve(new Map);return r.catch(()=>{return}),{clip:e,stored:r}}withScreen(e){if(!this.capturing||!mt()||e&&qn(e))return e;Qt();let t=Ot();if(!t)return e;return{windows:[...e?.windows.filter((n)=>n.stored)??[],...t.windows.filter((n)=>!n.stored)],lanes:e?.lanes??t.lanes,truncated:e?.truncated??t.truncated}}hiddenIdsAt(e){if(!this.capturing)return null;let t=Pl(mt());return t?Ar([e],t):null}async build(e,t,n=new Set){let r=t.filter((m)=>m.shape==="hide").map((m)=>m.rect),o=Pl(mt()),i=r.length>0&&!o;if(i)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let s=new Set(n);if(r.length&&o)for(let m of Ar(r,o))s.add(m);let a=[],l=this.withScreen(e.clip),d=l?.truncated??!1,p=await e.stored.catch((m)=>(console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",m),null));for(let m of l?.windows??[]){if(!m.stored){a.push(...m.events);continue}let M=p?.get(m.id);if(!M?.events.length)d=!0;else a.push(...M.events)}let h=l?.lanes??[],u=i?{events:[],dropped:!1}:np(Rl(a,r,s),Ll);if(u.dropped)d=!0;let{parts:f,dropped:g}=rr(u.events,Yu,Ll),k=[],b=0;for(let m of f){b+=m.count;let M=u.events[b-1]?.timestamp??Date.now();k.push({seq:k.length+1,ts:new Date(M).toISOString(),count:m.count,body:m.body})}let v=h.filter((m)=>m.kind==="console").slice(-Mr).map((m)=>({level:H(m.payload?.level,"error"),ts:m.ts,text:H(m.payload?.text)})),x=h.filter((m)=>m.kind==="net").slice(-Mr).map((m)=>({method:H(m.payload?.method,"GET"),path:H(m.payload?.path),status:typeof m.payload?.status==="number"?m.payload.status:0,ms:typeof m.payload?.ms==="number"?m.payload.ms:0,ts:m.ts}));return{chunks:k,truncated:d||g.length>0,console:v,network:x,journey:ap(h,r.length===0)}}clear(){if(this.capturing)Ns()}stop(){if(this.stopped=!0,this.listeners.clear(),this.capturing&&this.config?.lanes.replay)Ha();this.standDown(),Qi(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var q=null;function Ol(e){if(q){let t=q.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 q.refs++,q.engine}return q={engine:new Il(e),refs:1},q.engine}function _l(e){if(!e||!q||q.engine!==e)return;if(--q.refs>0)return;q=null,e.stop()}var cp=/^[\w-]+\.[\w-]+\.[\w-]+$/;function sn(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!cp.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 Dl=null,Lr=new Set;function dp(e){Dl=sn(e);for(let t of Lr)t()}function Nl(){return Dl}function Hl(e){return Lr.add(e),()=>Lr.delete(e)}var up=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),Pr="report.keybind";function Bl(e){if(up.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 Fl(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var pp={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function $l(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 pp[e]??e}function fp(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function an(e,t=fp()){let n=$l(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 zl(e){return[e.ctrl&&"Control",e.alt&&"Alt",e.shift&&"Shift",e.meta&&"Meta",$l(e.code)].filter(Boolean).join("+")}function hp(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;let n=t;if(typeof n.code!=="string"||!n.code)return null;let r={code:n.code,alt:n.alt===!0,ctrl:n.ctrl===!0,meta:n.meta===!0,shift:n.shift===!0};return r.alt||r.ctrl||r.meta?r:null}catch{return null}}var gp={code:"KeyA",alt:!0,ctrl:!1,meta:!1,shift:!0},Kl="off";function ql(e){if(e===Kl)return null;return hp(e)??gp}function Wl(){return ql(R().getString(Pr))}function Ir(e){R().set(Pr,e?JSON.stringify(e):Kl)}function Ul(e){let t=R();return t.watch?t.watch(Pr,(n)=>e(ql(n))):()=>{return}}var mp=["br","bl","tr","tl"];function Or(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 bp(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 jl(e,t,n){let r=Or(e,n);return t.reduce((o,i)=>o+bp(r,i),0)}function Vl(e,t,n){let r=jl(e,t,n);if(r===0)return e;let o=e,i=r;for(let s of mp){let a=jl(s,t,n);if(a<i)o=s,i=a}return o}function Yl(e,t,n,r){let o=e==="br"||e==="bl";if(t.vh-t.top-t.h-t.bottom>=n.h+r)return o?"above":"below";if(t.vw-2*t.edge-t.w>=n.w+r)return e==="br"||e==="tr"?"left":"right";return"over"}var yp="report.round";function _r(e){return`${yp}:${e.url}|${e.key}`}function kp(e){try{return JSON.parse(R().getString(_r(e))??"null")}catch{return null}}function vp(e,t){try{let n=R();if(t)n.set(_r(e),JSON.stringify(t));else n.remove(_r(e))}catch(n){console.warn("vitrinka: the test round could not be kept in this browser — the next report opens a new one",n)}}function wp(e){if(typeof e!=="object"||e===null)return null;let t=e;if(typeof t.token!=="string"||!t.token)return null;return{token:t.token,reports:typeof t.reports==="number"&&Number.isFinite(t.reports)&&t.reports>0?Math.floor(t.reports):0,openedAt:typeof t.openedAt==="string"?t.openedAt:""}}function Dr(e){return wp(kp(e))}function Xl(e,t,n=""){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.token!=="string"||!r.token)return null;let o={token:r.token,reports:typeof r.reports==="number"&&Number.isFinite(r.reports)&&r.reports>0?Math.floor(r.reports):1,openedAt:typeof r.openedAt==="string"?r.openedAt:""},i=Dr(e);if((i?.token??"")!==n){if(i?.token!==o.token)return null}if(i?.token===o.token)o.reports=Math.max(o.reports,i.reports);return vp(e,o),{round:o,rotated:r.rotated===!0}}function Hr(e){if(!(e instanceof T)||e.status!==400)return"";return/unknown field \\?"(\w+)\\?"/.exec(e.message)?.[1]??""}var Gl={ms:30000,bytesPerMs:32};class Jl extends Error{constructor(e,t){super(`vitrinka: ${e} got no answer in ${Math.round(t/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function Nr(e,t,n){let r=new AbortController,o,i=new Promise((s,a)=>{o=setTimeout(()=>{let l=new Jl(e,t);r.abort(l),a(l)},t)});try{return await Promise.race([n(r.signal),i])}finally{clearTimeout(o)}}var Br={chunks:[],truncated:!1,console:[],network:[],journey:[]};function Zl(e,t=Gl.ms){return Nr("preparing the capture",t,e).catch((n)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",n),Br))}class Fr{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(e,t,n,r=[],o=Gl){this.capture=e;this.tabHost=t;this.target=n;this.files=r;this.limits=o}call(e,t,n){return Nr(`${e} ${t}`,this.limits.ms,(r)=>J(e,t,n,{target:this.target,signal:r}))}upload(e,t,n){let r=typeof n==="string"?new TextEncoder().encode(n).byteLength:n.size,o=this.limits.ms+Math.ceil(r/this.limits.bytesPerMs);return Nr(`POST ${e}`,o,(i)=>En(e,t,n,this.target,i))}get filesPending(){return this.filesDone.size<this.files.length}async run(e,t){let n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let{res:i,memberSent:s,roundSent:a}=await this.create(e);if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");if(this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r,Xl(this.target,i.round,a),typeof i.memberError==="string"&&i.memberError)t?.(i.memberError,s)}else if(this.sent!==r)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n),this.sent=r;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof T)||!U(i.status))throw i;console.warn("vitrinka: the server refused the recording — the report goes without it",i),this.skipCapture=!0}let o=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async create(e){let t=e;for(;;)try{return{res:await this.call("POST","/api/v1/reports",t),memberSent:t.memberToken??"",roundSent:t.round??""}}catch(n){let r=Hr(n);if(r==="type"&&t.type!==void 0){console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:o,...i}=t;t=i}else if(r==="memberToken"&&t.memberToken!==void 0){console.warn("vitrinka: this server takes no member link yet — sending the report without it");let{memberToken:o,...i}=t;t=i}else if(r==="round"&&t.round!==void 0){console.warn("vitrinka: this server keeps no test rounds yet — sending the report without one");let{round:o,...i}=t;t=i}else if(r==="context"&&t.context!==void 0){console.warn("vitrinka: this server takes no report context yet; sending the report without it");let{context:o,...i}=t;t=i}else throw n}}async sendFiles(){let e=encodeURIComponent(this.id);for(let[t,n]of this.files.entries()){if(this.filesDone.has(t))continue;try{await this.upload(`/api/v1/reports/${e}/attachment?name=${encodeURIComponent(n.name)}`,n.type||"application/octet-stream",n)}catch(r){if(!(r instanceof T)||!U(r.status))throw r;console.warn(`vitrinka: the server refused ${n.name} — the report goes without it`,r)}this.filesDone.add(t)}}async sendCapture(){let e=encodeURIComponent(this.id),{chunks:t,truncated:n,journey:r}=this.capture;for(let i of t){if(this.blobKeys.has(i.seq))continue;let s=await this.upload(`/api/v1/reports/${e}/chunk?seq=${i.seq}`,"application/json",i.body);if(!s.blobKey)throw Error(`vitrinka: chunk ${i.seq} came back without a blob key`);this.blobKeys.set(i.seq,s.blobKey)}let o=t.map((i)=>({seq:i.seq,ts:i.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:i.count,source:"replay",truncated:n},blobKey:this.blobKeys.get(i.seq)??""}));if(t.length)for(let i of r)o.push({seq:o.length+1,ts:i.ts,tabHost:this.tabHost,kind:i.kind,payload:i.payload,blobKey:""});while(this.rowsPosted<o.length){let i=o.slice(this.rowsPosted,this.rowsPosted+Ft);await this.call("POST",`/api/v1/reports/${e}/events`,{events:i}),this.rowsPosted+=i.length}}}async function ln(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 T(`${e} ${t} → ${i.status}: ${s}`,i.status);return s?JSON.parse(s):{}}async function Ql(e,t,n=""){if(!n)return ln("POST","/api/v1/report/session",e,{token:t});try{return await ln("POST","/api/v1/report/session",e,{token:t,memberToken:n})}catch(o){if(Hr(o)!=="memberToken")throw o;return console.warn("vitrinka: this server takes no member link yet — the reporter session opens without it"),ln("POST","/api/v1/report/session",e,{token:t})}}function $r(e,t){return e?JSON.stringify([e,t]):""}function ec(e,t=Date.now()){return e!==null&&Date.parse(e.expiresAt)-t>60000}function zr(e,t,n){let r=n?`?cursor=${encodeURIComponent(n)}`:"";return ln("GET",`/api/v1/report/mine${r}`,e,void 0,t)}function tc(e,t){return`vitrinka.report.sent:${e}|${t}`}function nc(){try{return globalThis.localStorage??null}catch{return null}}function Kr(e,t){let n=nc()?.getItem(tc(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 rc(e,t,n){let r=nc();if(!r)return;let o=[n,...Kr(e,t)].slice(0,20);try{r.setItem(tc(e,t),JSON.stringify(o))}catch(i){console.warn("vitrinka: could not remember the sent report on this browser",i)}}var oc=`
9
+ `)}return s.push(i[i.length-1]),s.join(o)}var Vs=262144;function zs(e,t,n){if(e.full||!t)return t;try{if(Hn(t)){if(t.length<=Vs)try{return JSON.stringify(Mt(e,JSON.parse(t),0))}catch{}return Me(e,bd(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return At(e,Us(e,te,t));if(r.includes("multipart/form-data")){let o=kd(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return At(e,t)}catch{return"[redacted]"}}function Ys(e,t){if(t===void 0)return;if(e.full)return t;if(Hn(t))try{return JSON.stringify(Mt(e,JSON.parse(t),0))}catch{}try{return At(e,t)}catch{return"[redacted]"}}function Xs(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(Hn(t)&&t.length<=Vs){let i=zs(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 zs(e,o,r)}function Gs(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):Ks(e,s)?"[redacted]":Me(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function Js(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var Le=Dn(null);function Qs(e){Le=Dn(e??null)}function Lt(e){return Ys(Le,e)}function Bn(e,t,n){return Xs(Le,e,t,n)}var Zs=null,ea=null;function zn(e){ea=e??null}function vd(e){let t=ea??Ze().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(Zs!==t)Zs=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return yd(e)??Fs}function yd(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function z(e){return Nn(Le,vd(e))}function ta(){return z(k.pathname)}var wd=4;function Fn(e){return e.type===wd}function $n(e){if(!Fn(e))return e;return{...e,data:{...e.data,href:z(e.data.href)}}}function et(e){return Gs(Le,e)}function Pt(){return Js(Le)}var na=30000,xd=4194304,Sd=20000,qn=500,Rd=2000,Ed=2,ra={windowMs:na,checkoutMs:na,maxBytes:xd,maxEvents:Sd,maxLaneEvents:qn},re=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function Wn(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var Cd=new TextEncoder,ie=!1,oa=0,P=ra,w=[],D=[],V=[],ne=[],Td=0,Ie=[],Oe=new Map,_e=null,Pe=null,tt=!1,Ad=0,oe=null,It=null,jn=Promise.resolve();function ia(e=ra){if(Vn(),ie=!0,oa++,P=e,oe=e.store??null,w=(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),V=[],ne=[],Ie=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),Oe.clear(),_e=null,_t(Date.now()),oe)It=setInterval(Ot,Rd)}function sa(){Ot(),Vn(),ie=!1,oe=null,w=[],D=[],V=[],ne=[],Ie=[],Oe.clear(),_e=null}function aa(){return P}function Un(e){Pe=e}function la(){if(!ie)return;w=[],D=[],V=[],ne=[],Ie=[],Oe.clear(),_e=null;let e=k.tabId;fe((t)=>t.clear(e)),Pe?.()}function ca(){return jn}function Ot(){if(!ie||!oe)return;let e=Date.now();_t(e),Xn(e);for(let t of w){if(t.stored)continue;let n=Oe.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;Oe.set(t.id,{events:t.events.length,parts:o+1});let i=da(t);fe((s)=>s.putWindowChunk(i,o,r,[]))}Md(e)}function Md(e){let t=e-P.windowMs;while(ne.length>0&&ne[0].lastMs<=t){let[a]=ne.splice(0,1);if(a)fe((l)=>l.dropWindow(a.id))}for(let a of Ie.filter((l)=>l.lastMs<=t))fe((l)=>l.dropWindow(a.id));Ie=Ie.filter((a)=>a.lastMs>t);let n=V;if(!n.length)return;V=[];let r=ne.at(-1);if(!r||r.startMs<=t)r={id:`${re}.lanes.${++Td}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},ne.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:k.tabId,scope:P.scope??"",kind:"lanes",load:re,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};fe((a)=>a.putWindowChunk(s,o,"[]",n))}function Vn(){if(It)clearInterval(It);It=null}function da(e){return{id:e.id,tab:k.tabId,scope:P.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function fe(e){let t=oe;if(!t)return;jn=jn.then(()=>e(t)).catch((n)=>{if(oe!==t)return;oe=null,Vn(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function Kn(e){let[t]=w.splice(e,1);if(!t)return;Oe.delete(t.id),fe((n)=>n.dropWindow(t.id))}function _t(e){while(w.length>0){let r=w[0],o=w[1];if(!o&&r.load===re)break;if(Wn(r,o)>e-P.windowMs)break;Kn(0)}if(tt)return;let t=w.at(-1);if(t&&t.load===re&&Pe&&t.lastMs<=e-P.windowMs){tt=!0;try{Pe()}finally{tt=!1}let r=w.indexOf(t);if(r>=0&&r<w.length-1)for(let o=r;o>=0;o--)Kn(o)}let n=!1;while(w.length>0&&Ld()){if(w.length===1&&w[0].load===re&&!n&&Pe){n=!0,tt=!0;try{Pe()}finally{tt=!1}if(w.length>1)continue}Kn(0),_e=w[0]?.startMs??e}}function Yn(){return ie?`flight:${oa}`:null}function Xn(e){let t=Math.min(w[0]?.startMs??Number.POSITIVE_INFINITY,e-P.windowMs),n=D.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)D=[];else if(n>0)D=D.slice(n)}function Ld(){let e=0,t=0;for(let n of w)e+=n.bytes,t+=n.count;return e>P.maxBytes||t>P.maxEvents}function ua(e){if(!ie)return;let t=w[0];if(Fn(e)){let r=globalThis.location?.pathname??k.pathname,o={id:`${re}.${++Ad}`,load:re,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:z(r)};w.push(o);let i=da(o);fe((s)=>s.putWindow(i))}let n=w.at(-1);if(!n||n.load!==re)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=Cd.encode(JSON.stringify(e)).length,_t(e.timestamp),w[0]!==t)Xn(e.timestamp)}function Gn(e,t,n){if(!ie)return null;let r=P.keepLane?P.keepLane(e,t):t;if(r===null)return null;let o=new Date().toISOString(),i={ts:o,tabId:n.tabId,tabHost:n.tabHost,kind:e,payload:r},s=P.maxLaneEvents;if(D.push(i),D.length>s)D.splice(0,D.length-s);if(oe){if(V.push(i),V.length>s)V.splice(0,V.length-s)}return o}function Dt(){if(!ie)return null;let e=Date.now();return _t(e),Xn(e),{windows:w.map((t)=>({...t,events:t.events.slice()})),lanes:D.slice(),truncated:_e!==null&&_e>e-P.windowMs}}function Jn(e){return e.windows.some((t)=>t.events[1]?.type===Ed)}var Zn=null;function nt(){if(!Zn)Zn=typeof indexedDB>"u"?Pd():Id();return Zn}function Pd(){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 Id(){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 Od=2000,nr=20000,ya=200,_d=4194304,Dd=3145728,$t=500,Nd=_d-1024,Hd=12582912,Bd=10485760,zd=Hd-64,Fd=1048576,$d=new TextEncoder;function Fe(e){return $d.encode(e).length}var C=()=>E();function X(e,t){let n=C().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var pa=!1;function G(e,t){try{return C().set(e,t),!0}catch(n){if(!pa)pa=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var Ht="rec",me;function S(){if(me===void 0)me=X(Ht,null);return me}function Kt(e){if(me=e,e===null)C().remove(Ht),C().remove(Kd);else G(Ht,JSON.stringify(jd(e)))}var Kd="notes";var ot=null;function jd(e){if(ot?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:ot.activeMs,resumeAt:null,stopping:ot.at}}var qd=new Set;function Wd(){for(let e of qd)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function Ud(e){let t=null;if(e)try{t=JSON.parse(e)}catch{return"unchanged"}let n=S();if(t?.stopping&&t.sessionId===n?.sessionId&&!n.paused&&ot?.sessionId!==t.sessionId)Wd();if(!t){if(!n)return"unchanged";return me=null,va(),nu(),"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(ot?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return me=t,"updated"}return me=t,va(),"joined"}var Vd=700,be,Y=null,ce=!1;function Ne(){if(be===void 0)be=X("buffer",[]);return be}function jt(){if(Y)clearTimeout(Y),Y=null;if(be!==void 0&&!ce)G("buffer",JSON.stringify(be))}function wa(){if(ce=!1,Y)return;Y=setTimeout(()=>{Y=null,jt(),xa()},Vd)}function rr(e){be=e,ce=!1,jt()}var De,He=0;function he(){if(De===void 0)De=X("chunks",[]),He=De.reduce((e,t)=>e+t.body.length,0);return De}function xa(){if(ce)return;let e=he();if(e.length===0){C().remove("chunks");return}if(He>Fd){C().remove("chunks");return}G("chunks",JSON.stringify(e))}function Sa(e){De=e,He=e.reduce((t,n)=>t+n.body.length,0),ce=!1,xa()}var Bt,ve=new Map,ke=new Set,ye=new Map,it=new Map,fa=5,Yd=200,Xd=67108864,Gd=0,ha=!1,or="blobs";function N(){return Bt??=X("images",[]),Bt}function Ra(){if(ce)return;let e=N().filter((t)=>!ke.has(t.blob));if(e.length===0)C().remove("images");else G("images",JSON.stringify(e))}function ir(e){Bt=e,ce=!1,Ra()}function Jd(e,t){let n=nt();if(!n.durable&&!ha)ha=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");G(or,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${Ma}.${++Gd}`;return ve.set(a,i),ke.add(a),r.push(n.put(a,i).then(()=>{if(!(ve.has(a)||N().some((d)=>d.blob===a)||[...ye.values()].includes(a)))return ke.delete(a),sr(a),!1;if(!n.durable)return!1;if(ke.delete(a),N().some((d)=>d.blob===a))Ra();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 sr(e){nt().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function Be(e,t){for(let n of e)if(ve.delete(n),ke.delete(n),it.delete(n),t)sr(n)}var zt=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];async function Ea(e){if(!C().getString(or))return;let t=nt(),n=S()?.sessionId;try{let r=await t.keys(),o=0;for(let i of r)if(e?i.startsWith(`${e}/`):!n||!i.startsWith(`${n}/`))await t.delete(i);else o++;if(o===0&&!S())C().remove(or)}catch(r){console.warn("vitrinka: blob journal cleanup failed",r)}}var Zd=0,Ca="",Ta=0,ga=-1;function ar(){Zd=Date.now(),Ta=0,Ca=""}function ze(e){Ta++,Ca=String(e instanceof Error?e.message:e).slice(0,200)}var ma={actions:0,pages:0,frames:0,notes:0},Qd=new Set;function eu(e){let t={...ma};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")Qd.add(n.payload.cid)}ma=t}function tu(e){let t=S();if(!t||t.dead)return;if(t.dead=!0,t.deadReason=e,!t.paused&&t.resumeAt)t.activeMs=(t.activeMs||0)+(Date.now()-Date.parse(t.resumeAt)),t.resumeAt=null;Kt(t),console.warn("vitrinka: session marked dead —",e),I()}var Qn=null;function nu(){if(Qn)clearInterval(Qn);Qn=null}function Aa(e){let t=S();if(!t||t.dead||e<1)return null;let n=X("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return C().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,Kt(t),{seq:r,sessionId:t.sessionId}}var Ma=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,Ft="allocation.",ru=0,O=new Set,ou=16777216,st=0,at=0,le=new Map;function qt(e){return e.kind==="event"?1+(e.images?.length??0):1}function iu(e,t){return new Set(Array.from({length:qt(t)},(n,r)=>e+r))}function lr(e,t,n){return JSON.stringify(n&&n.size<qt(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var ba=!1,rt=null;function Nt(e){if(!O.delete(e))return;if(st-=e.bytes,e.draft.kind==="chunk")at--}function La(e){if(O.add(e),st+=e.bytes,e.draft.kind==="chunk")at++;while(O.size>nr||st>ou||at>ya){let t=O.values().next().value;Nt(t),C().remove(t.key),Be(zt(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");ze(n),console.warn(n.message)}}function Pa(e=!1){if(ba&&!e)return;ba=!0;let t=C();if(!t.withLock)return;let n=new Set([...O].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(Ft)||n.has(r)||le.has(r))continue;let o=X(r,null);if(o&&o.draft&&o.draft.sessionId===S()?.sessionId)La({...o,key:r,persisted:!0,bytes:Fe(JSON.stringify(o))})}}function Ia(e,t,n){let{ts:r,tabId:o,tabHost:i,sessionId:s}=e,a=(l)=>!n||n.has(l);if(e.kind==="event"){let l=e.images??[],d=t+l.length,p=l.length?{...e.event,payload:{...e.event.payload,attachments:l.map((u,f)=>t+f)}}:e.event,h=Ne();if(a(d)&&!h.some((u)=>u.seq===d))h.push({seq:d,ts:r,tabId:o,tabHost:i,...p});if(l.length){let u=N();l.forEach((g,v)=>{let b=t+v;if(!a(b)||u.some((y)=>y.seq===b))return;if(h.some((y)=>y.seq===b)){ye.set(b,g.blob);return}u.push({seq:b,ts:r,tabId:o,tabHost:i,sessionId:s,blob:g.blob,payload:g.payload})});let f=u.reduce((g,v)=>g+v.payload.bytes,0);while(u.length>Yd||f>Xd){let g=u.shift();f-=g.payload.bytes,ae(g.sessionId,new Set([g.seq])),Be([g.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${g.payload.name} (seq ${g.seq}); its note lands without it`)}ir(u)}if(h.length>nr){let u=h.splice(0,h.length-nr);ae(s,new Set(u.map((f)=>f.seq))),console.warn(`vitrinka: retry buffer full — dropped ${u.length} oldest events`)}}else{let l=he();if(!l.some((d)=>d.seq===t)&&!Ne().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),He+=e.part.body.length;while(l.length>ya){let d=l.shift();He-=d.body.length,ae(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}wa(),ge()}function ae(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?X(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)G(n,lr(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){C().remove(n),le.delete(n);let s=n.slice(Ft.length,n.lastIndexOf(".")),a=`tab.${s}`,l=X(a,null);if(l?.departed&&l.recoverable&&!C().keys?.().some((d)=>d.startsWith(`${Ft}${s}.`)))C().remove(a)}}}function Oa(){if(rt)return rt;let e=C();return rt=cr(Promise.resolve().then(async()=>{for(let t of O)await e.withLock("seq",()=>{if(!O.has(t))return;if(t.persisted){let o=X(t.key,null);if(!o){Nt(t),Be(zt(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(Ud(e.getString(Ht)??null),S()?.sessionId!==t.draft.sessionId){Nt(t),Be(zt(t.draft),!0);return}let n=t.seq??Aa(qt(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):iu(n,t.draft);if(t.persisted)e.set(t.key,lr(t.draft,n,r));le.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),Ia(t.draft,n,r),Nt(t)})}).catch((t)=>{throw ze(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),ge(),I(),t})).finally(()=>{rt=null}),rt}function _a(e,t){let n=S(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(Pa(),C().withLock){let o=`${Ft}${Ma}.${++ru}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&G(o,i),bytes:Fe(i)};La(s),Oa(),t?.then((a)=>{if(a)su(s)})}else{let o=Aa(qt(e));if(o)Ia(e,o.seq);else Be(zt(e),!0)}return!0}function su(e){let t=le.get(e.key);if(t)t.persisted=G(e.key,lr(e.draft,e.seq,t.seqs));else if(O.has(e))e.persisted=G(e.key,JSON.stringify({draft:e.draft}))}var ka=new Set;function cr(e){return ka.add(e),e.catch(()=>{return}).finally(()=>{ka.delete(e)})}function se(e){return S()?.sessionId!==e.sessionId}function J(e,t,n,r=[]){if(Ge.following)return null;if(Et()==="report")return Gn(e,t,n);let o=S();if(!o)return Gn(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?Jd(o.sessionId,r):null;return _a({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),dr(),i}function Da(e){Ne().push(e),dr(),wa(),ge()}var au=Date.now();function dr(){au=Date.now()}function ur(e,t=Bd,n=zd){let r=[],o=[],i=[],s=2,a=()=>{if(!i.length)return;r.push({count:i.length,body:`[${i.join(",")}]`}),i=[],s=2};for(let l of e){let d=JSON.stringify(l),p=Fe(d)+1;if(p>n){o.push(p);continue}if(p>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+p>t)a();i.push(d),s+=p}return a(),{parts:r,dropped:o}}function Na(e,t){if(!e.length)return 0;let n=S();if(!n||n.paused||n.dead||Ge.following)return 0;let{parts:r,dropped:o}=ur(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),J("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(!_a({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return dr(),r.length}async function lu(e=5){let t=he();if(t.length===0)return!0;let n=S(),r=0,o=new Set;for(let i of t){if(r>=e)break;if(r++,!n||i.sessionId!==n.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${i.seq} from ended session ${i.sessionId}`),o.add(i.seq);continue}try{let s=await Ds(n.sessionId,i.seq,i.body);if(se(n))return he().length===0;Da({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),ar(),o.add(i.seq)}catch(s){if(se(n))return he().length===0;if(s instanceof A&&U(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),ae(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}ze(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Sa(he().filter((i)=>!o.has(i.seq)));return he().length===0}async function cu(e=4){let t=N();if(t.length===0)return!0;let n=S(),r=0,o=new Set,i=[];for(let s of t){if(r>=e)break;if(r++,!n||s.sessionId!==n.sessionId){console.warn(`vitrinka: dropping attachment seq ${s.seq} from ended session ${s.sessionId}`),o.add(s.seq),i.push(s.blob);continue}let a=ve.get(s.blob)??null;if(!a){try{a=await nt().get(s.blob),it.delete(s.blob)}catch(l){if(se(n))return N().length===0;let d=(it.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${fa})`,l),d<fa){it.set(s.blob,d),ze(l);break}}if(se(n))return N().length===0}if(!a){console.warn(`vitrinka: attachment seq ${s.seq} (${s.payload.name}) lost its bytes — its note lands without it`),ae(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await Ns(n.sessionId,s.seq,a);if(se(n))return N().length===0;Da({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),ve.delete(s.blob),ye.set(s.seq,s.blob),ar(),o.add(s.seq)}catch(l){if(se(n))return N().length===0;if(l instanceof A&&U(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),ae(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}ze(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)jt(),ir(N().filter((s)=>!o.has(s.seq)));return Be(i,!0),N().length===0}var er=null;function ge(){if(er)return;er=setTimeout(()=>{er=null,du()},Od)}var tr=!1;async function du(e={}){if(tr)return!1;tr=!0;try{return await uu(e)}finally{tr=!1}}async function uu(e){if(S()?.dead)return!1;if(Pa(!0),O.size)await Oa();if(O.size)return!1;let t=await lu(),n=e.keepalive?N().length===0:await cu(),r=t&&n;if(!r)ge();let o=S(),i=Ne();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:Dd;for(let u of i){if(s.length>=$t)break;let f=Fe(JSON.stringify(u))+1;if(f>Nd){console.warn(`vitrinka: event seq ${u.seq} (${f} bytes) exceeds the wire cap — dropped`),a.add(u.seq);continue}if(f>d){if(e.keepalive)break;if(s.length===0)s.push(u),l=f;break}if(s.length>0&&l+f>d)break;s.push(u),l+=f}if(a.size){if(ae(o.sessionId,a),rr(Ne().filter((u)=>!a.has(u.seq))),!s.length)return ge(),!1}if(!s.length)return!1;jt();try{await ee("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(u){if(se(o))return!1;if(u instanceof A&&U(u.status))return tu(`server rejected this session (${u.status})`),!1;return ze(u),I(),console.warn("vitrinka: flush failed, retrying",u),ge(),!1}if(se(o))return!0;ar(),ga=Math.max(ga,...s.map((u)=>u.seq)),eu(s);let p=new Set(s.map((u)=>u.seq));ae(o.sessionId,p);let h=Ne().filter((u)=>!p.has(u.seq));rr(h),I();for(let u of p){let f=ye.get(u);if(f===void 0)continue;ye.delete(u),sr(f)}if(h.length)ge();return!0}function Ha(){for(let e of le.keys())C().remove(e);for(let e of O)C().remove(e.key);le.clear(),O.clear(),st=at=0,rr([]),Sa([]),ve.clear(),ke.clear(),ye.clear(),it.clear(),ir([])}function va(){if(Y)clearTimeout(Y),Y=null;be=[],De=[],He=0,Bt=[],ve.clear(),ke.clear(),ye.clear(),O.clear(),st=at=0,le.clear(),ce=!0}var Ba="0.12.0";var Qf={from:"page",inst:Is("p")};var pu=!1;function za(){return pu}var $a="vitrinka.report.face",Fa=(e)=>e.trim().replace(/\/+$/,"");function Wt(){try{return globalThis.localStorage??null}catch{return null}}function $e(e){let t=pe();if(!t)return!1;if(t.base)return Fa(t.base)===Fa(e);try{let n=Rt(e);return n===void 0||n===t.workspace}catch{return!1}}function we(e){return $e(e)?pe()?.token??"":""}function Ka(e){return/revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(e)}function fu(){let e=Wt()?.getItem($a);return e==="recorder"||e==="report"?e:null}function pr(e){try{Wt()?.setItem($a,e)}catch(t){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",t)}}var ja="vitrinka.report.mode";function qa(e){try{if(e==="dev"||e==="regular")Wt()?.setItem(ja,e)}catch(t){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",t)}}function Wa(e){if(!$e(e))return"report";let t=fu();if(t)return t;return Wt()?.getItem(ja)==="dev"?"recorder":"report"}function Ua(){return S()!==null||za()}function Ut(e){let t=E().watch?.(Qe,()=>e()),n=Cs(e);return()=>{t?.(),n()}}var Va=["bug","suggestion","question","other"];function H(e,t,n,r){if(e===1)return t;if(e>=2&&e<=4)return n;return r}var hu={button:"Report a problem",title:"Report a problem",close:"Close",settings:"Settings",prompt:"What went wrong?",placeholder:"Tell us what happened and what you expected",attached:(e)=>{if(e<60)return`The last ${e} seconds are attached`;let t=Math.round(e/60);return t===1?"The last minute is attached":`The last ${t} minutes are attached`},included:"What’s included",incReplay:"A replay of what happened on this page",incReplayMasked:{strict:"Text on the page and anything you typed are hidden in it",balanced:"Anything you typed is hidden in it",full:"It shows the page as you saw it"},incErrors:"Errors the page ran into",incConsole:"Messages from the browser console",incNetwork:"Which addresses the page loaded, with their status",incFailedRequests:"Requests that failed — address and status only",incEnv:"Your browser, screen size, language and this page’s address",incIdentity:"Your name and email from this app",incMarks:"The places you marked, with your notes",showWhere:"Show us where",kinds:{bug:"Bug",suggestion:"Suggestion",question:"Question",other:"Other"},kindsLabel:"What is it?",linesEmpty:"Each place you mark gets a line here for its note.",notify:"Email me when it’s fixed",send:"Send",sending:"Sending…",retry:"Try again",errorCreate:"Couldn’t send — your text is safe, try again",errorCapture:"Your report arrived, the recording not yet — try again to attach it",sentTitle:"Thanks — we’ve got it",sentBody:"The team will take a look.",sentNotify:"We’ll email you when it’s fixed.",seeReport:"See your report",tools:{circle:"Circle",box:"Box",arrow:"Arrow",hide:"Cover"},toolbar:"Marking tools",barLead:"Mark where the problem is",barLeadHide:"Cover what the team shouldn’t see",cancelMarking:"Cancel",discardMarks:(e)=>e===1?"Discard 1 mark?":`Discard ${e} marks?`,discard:"Discard",keep:"Keep",coach:{box:"Click, hold and move across the problem.",circle:"Click, hold and move around the problem.",arrow:"Click, hold and move from a clear spot to the problem.",hide:"Click, hold and move across anything private — it stays blank in what you send."},coachMore:"You can mark more than one place.",coachDismiss:"Got it, don’t show again",coachSetting:"Marking tips",marking:"Marking",keyboardHint:"Keyboard: Enter to start, arrows to move, Shift+arrows to resize, Enter to place.",hidden:"Covered — not sent",notePlaceholder:"Add a note (optional)",mark:(e)=>`Mark ${e}`,removeMark:(e)=>`Remove mark ${e}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back",account:"Your account",menu:"Menu",anonymous:"Not signed in",anonymousHint:"The team checks your report before it’s filed.",signedInByApp:"Signed in by this app",linkVitrinka:"Link your vitrinka account",linkedAs:(e)=>`Linked to vitrinka as ${e}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(e)=>`Remove ${e}`,fileTooBig:(e,t)=>`${e} is over the ${t} limit`,tooManyFiles:(e)=>e===1?"Up to 1 file per report":`Up to ${e} files per report`,fileType:(e,t)=>`${e} can’t be attached — ${t} only`,typeNames:{image:"images",pdf:"PDF",text:"text files",office:"office documents"},incFiles:"The files you attached",errorFiles:"Your report arrived, a file not yet — try again to attach it",moveHint:"Click, hold and move it to another corner, or press Alt and an arrow key.",edgeHint:"Click, hold and move it up or down along the edge, or press Alt and the up or down arrow.",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`}},gu={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 H(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 H(t,"Poslední minuta je přiložena",`Poslední ${t} minuty jsou přiloženy`,`Posledních ${t} minut je přiloženo`)},included:"Co je přiloženo",incReplay:"Záznam toho, co se na stránce dělo",incReplayMasked:{strict:"Texty stránky i vše, co jste napsali, jsou v něm skryté",balanced:"Vše, co jste napsali, je v něm skryté",full:"Ukazuje stránku tak, jak jste ji viděli"},incErrors:"Chyby, na které stránka narazila",incConsole:"Zprávy z konzole prohlížeče",incNetwork:"Které adresy stránka načítala a s jakým výsledkem",incFailedRequests:"Požadavky, které selhaly — jen adresa a výsledek",incEnv:"Váš prohlížeč, velikost obrazovky, jazyk a adresa stránky",incIdentity:"Vaše jméno a e-mail z této aplikace",incMarks:"Místa, která jste označili, i s poznámkami",showWhere:"Ukažte nám kde",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Dotaz",other:"Jiné"},kindsLabel:"Co to je?",linesEmpty:"Každé označené místo tu dostane řádek pro poznámku.",notify:"Pošlete mi e-mail, až to bude opravené",send:"Odeslat",sending:"Odesílám…",retry:"Zkusit znovu",errorCreate:"Nepodařilo se odeslat — váš text zůstal, zkuste to znovu",errorCapture:"Hlášení dorazilo, záznam zatím ne — zkuste to znovu a přiložíme ho",sentTitle:"Díky — máme to",sentBody:"Tým se na to podívá.",sentNotify:"Až to bude opravené, pošleme vám e-mail.",seeReport:"Zobrazit hlášení",tools:{circle:"Kruh",box:"Obdélník",arrow:"Šipka",hide:"Zakrýt"},toolbar:"Nástroje pro označení",barLead:"Označte, kde je problém",barLeadHide:"Zakryjte, co tým nemá vidět",cancelMarking:"Zrušit",discardMarks:(e)=>H(e,"Zahodit 1 značku?",`Zahodit ${e} značky?`,`Zahodit ${e} značek?`),discard:"Zahodit",keep:"Ponechat",coach:{box:"Klikněte, podržte a veďte přes problém.",circle:"Klikněte, podržte a veďte kolem problému.",arrow:"Klikněte, podržte a veďte z volného místa k problému.",hide:"Klikněte, podržte a veďte přes vše soukromé — v hlášení zůstane prázdné."},coachMore:"Označit můžete i více míst.",coachDismiss:"Chápu, už nezobrazovat",coachSetting:"Nápověda při označování",marking:"Označování",keyboardHint:"Klávesnice: Enter začne, šipky posouvají, Shift+šipky mění velikost, Enter umístí.",hidden:"Zakryto — neodešle se",notePlaceholder:"Přidejte poznámku (nepovinné)",mark:(e)=>`Značka ${e}`,removeMark:(e)=>`Odebrat značku ${e}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět",account:"Váš účet",menu:"Nabídka",anonymous:"Nepřihlášeno",anonymousHint:"Hlášení nejdřív zkontroluje tým.",signedInByApp:"Přihlášen touto aplikací",linkVitrinka:"Propojit s vitrinkou",linkedAs:(e)=>`Propojeno s vitrinkou jako ${e}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(e)=>`Odebrat ${e}`,fileTooBig:(e,t)=>`${e} přesahuje limit ${t}`,tooManyFiles:(e)=>H(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.",edgeHint:"Klikněte, podržte a posuňte ho nahoru nebo dolů podél okraje, nebo stiskněte Alt a šipku nahoru či dolů.",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 H(e,"1 sekunda",`${e} sekundy`,`${e} sekund`);let t=Math.round(e/60);return H(t,"1 minuta",`${t} minuty`,`${t} minut`)}},mu={button:"Nahlásiť problém",title:"Nahlásiť problém",close:"Zavrieť",settings:"Nastavenia",prompt:"Čo sa pokazilo?",placeholder:"Napíšte, čo sa stalo a čo ste čakali",attached:(e)=>{if(e<60)return H(e,"Posledná sekunda je priložená",`Posledné ${e} sekundy sú priložené`,`Posledných ${e} sekúnd je priložených`);let t=Math.round(e/60);return H(t,"Posledná minúta je priložená",`Posledné ${t} minúty sú priložené`,`Posledných ${t} minút je priložených`)},included:"Čo je priložené",incReplay:"Záznam toho, čo sa na stránke dialo",incReplayMasked:{strict:"Texty stránky aj všetko, čo ste napísali, sú v ňom skryté",balanced:"Všetko, čo ste napísali, je v ňom skryté",full:"Ukazuje stránku tak, ako ste ju videli"},incErrors:"Chyby, na ktoré stránka narazila",incConsole:"Správy z konzoly prehliadača",incNetwork:"Ktoré adresy stránka načítavala a s akým výsledkom",incFailedRequests:"Požiadavky, ktoré zlyhali — len adresa a výsledok",incEnv:"Váš prehliadač, veľkosť obrazovky, jazyk a adresa stránky",incIdentity:"Vaše meno a e-mail z tejto aplikácie",incMarks:"Miesta, ktoré ste označili, aj s poznámkami",showWhere:"Ukážte nám kde",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Otázka",other:"Iné"},kindsLabel:"Čo to je?",linesEmpty:"Každé označené miesto tu dostane riadok na poznámku.",notify:"Pošlite mi e-mail, keď to bude opravené",send:"Odoslať",sending:"Odosielam…",retry:"Skúsiť znova",errorCreate:"Nepodarilo sa odoslať — váš text zostal, skúste to znova",errorCapture:"Hlásenie dorazilo, záznam zatiaľ nie — skúste to znova a priložíme ho",sentTitle:"Vďaka — máme to",sentBody:"Tím sa na to pozrie.",sentNotify:"Keď to bude opravené, pošleme vám e-mail.",seeReport:"Zobraziť hlásenie",tools:{circle:"Kruh",box:"Obdĺžnik",arrow:"Šípka",hide:"Zakryť"},toolbar:"Nástroje na označenie",barLead:"Označte, kde je problém",barLeadHide:"Zakryte, čo tím nemá vidieť",cancelMarking:"Zrušiť",discardMarks:(e)=>H(e,"Zahodiť 1 značku?",`Zahodiť ${e} značky?`,`Zahodiť ${e} značiek?`),discard:"Zahodiť",keep:"Ponechať",coach:{box:"Kliknite, podržte a veďte cez problém.",circle:"Kliknite, podržte a veďte okolo problému.",arrow:"Kliknite, podržte a veďte z voľného miesta k problému.",hide:"Kliknite, podržte a veďte cez všetko súkromné — v hlásení zostane prázdne."},coachMore:"Označiť môžete aj viac miest.",coachDismiss:"Rozumiem, už nezobrazovať",coachSetting:"Nápoveda pri označovaní",marking:"Označovanie",keyboardHint:"Klávesnica: Enter začne, šípky posúvajú, Shift+šípky menia veľkosť, Enter umiestni.",hidden:"Zakryté — neodošle sa",notePlaceholder:"Pridajte poznámku (nepovinné)",mark:(e)=>`Značka ${e}`,removeMark:(e)=>`Odobrať značku ${e}`,shortcut:"Klávesová skratka",shortcutHint:"Otvorí Nahlásiť problém kdekoľvek v tejto aplikácii.",notSet:"Nenastavená",recordShortcut:"Nahrať novú skratku",pressKeys:"Stlačte klávesy · Esc zruší",needModifier:"Pridajte Ctrl, Alt alebo ⌘ — samotná klávesa by prekážala pri písaní",removeShortcut:"Odobrať",back:"Späť",account:"Váš účet",menu:"Ponuka",anonymous:"Neprihlásené",anonymousHint:"Hlásenie najprv skontroluje tím.",signedInByApp:"Prihlásený touto aplikáciou",linkVitrinka:"Prepojiť s vitrinkou",linkedAs:(e)=>`Prepojené s vitrinkou ako ${e}`,unlink:"Odpojiť",myReports:"Moje hlásenia",recentRecordings:"Nedávne nahrávky",record:"Nahrávať",recordHasDraft:"Odošlite alebo zmažte rozpísané hlásenie",openVitrinka:"Otvoriť vitrinku",openPortal:"Otvoriť portál hlásení",loading:"Načítavam…",listFailed:"Nepodarilo sa načítať — skúste to znova",noReports:"Zatiaľ žiadne hlásenia.",noRecordings:"Zatiaľ žiadne nahrávky.",fromThisBrowser:"Odoslané z tohto prehliadača",steps:{received:"Prijaté",planned:"Naplánované",in_progress:"Riešime",fixed:"Opravené",done:"Hotovo"},waiting:"Čaká na schválenie",sentQueued:"Kým ho zaradíme, tím ho skontroluje.",linkCode:"Váš kód",linkHint:"Schváľte kód vo vitrinke — na tomto alebo inom zariadení, kde ste prihlásení.",linkWaiting:"Čakám na schválenie…",linkExpired:"Kód vypršal.",linkFailed:"Prepojenie sa nepodarilo.",attach:"Priložiť súbor",removeFile:(e)=>`Odobrať ${e}`,fileTooBig:(e,t)=>`${e} prekračuje limit ${t}`,tooManyFiles:(e)=>H(e,"Najviac 1 súbor na hlásenie",`Najviac ${e} súbory na hlásenie`,`Najviac ${e} súborov na hlásenie`),fileType:(e,t)=>`${e} nemožno priložiť — len ${t}`,typeNames:{image:"obrázky",pdf:"PDF",text:"textové súbory",office:"kancelárske dokumenty"},incFiles:"Súbory, ktoré ste priložili",errorFiles:"Hlásenie dorazilo, súbor zatiaľ nie — skúste to znova a priložíme ho",moveHint:"Kliknite, podržte a veďte ho do iného rohu, alebo stlačte Alt a šípku.",edgeHint:"Kliknite, podržte a posuňte ho hore alebo dole pozdĺž okraja, alebo stlačte Alt a šípku hore či dole.",size:"Veľkosť",sizes:{sm:"Malá",md:"Stredná",lg:"Veľká"},techDetails:"Technické údaje",techVersion:"Verzia",techWindow:"Okno záznamu",techCapture:"Záznam",techBuffer:"Vyrovnávacia pamäť",techServer:"Server",captureOn:"Beží",captureOff:"Vypnutý",captureStarting:"Spúšťa sa…",bufferMemory:"V pamäti",bufferBrowser:"V tomto prehliadači",windowLength:(e)=>{if(e<60)return H(e,"1 sekunda",`${e} sekundy`,`${e} sekúnd`);let t=Math.round(e/60);return H(t,"1 minúta",`${t} minúty`,`${t} minút`)}},bu={cs:gu,en:hu,sk:mu};function fr(e){return bu[e]}function lt(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"||t==="sk"?t:null}function hr(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=lt(n);if(r)return r}return"en"}var Ya="recents",Xa=5,ku=["recording","saved","unsaved","deleted"];function vu(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.sessionId==="string"&&typeof t.title==="string"&&typeof t.startedAt==="number"&&ku.includes(t.status)}var Ke;function gr(){if(Ke===void 0)try{let e=JSON.parse(E().getString(Ya)??"[]");Ke=Array.isArray(e)?e.filter(vu).slice(0,Xa):[]}catch{Ke=[]}return Ke}function yu(e){Ke=e.slice(0,Xa);try{E().set(Ya,JSON.stringify(Ke))}catch(t){console.warn("vitrinka: could not store recent recordings",t)}I()}function Ga(e,t){let n=gr();if(!n.some((r)=>r.sessionId===e))return;yu(n.map((r)=>r.sessionId===e?{...r,...t}:r))}var xe="data-vitrinka-recorder";var mr="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;",Ja=mr;var wu=["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 tl(e){for(let t of wu)e.addEventListener(t,(n)=>n.stopPropagation())}var xu=["keydown","keyup","keypress"],Su=["vitrinkaHud","vitrinkaSheet"],Za=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Ru=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),Eu=new Set(["text","search","email","url","tel","password","number"]);function Cu(e){let t=e.key.length===1;if(t&&e.getModifierState?.("AltGraph"))return!0;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return t||Za.has(e.key);if(Za.has(e.key))return!0;return(e.ctrlKey||e.metaKey)&&!e.altKey&&Ru.has(e.code)}function Tu(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"&&Eu.has(e.type)}function Au(e){if(typeof e!=="object"||e===null||!("dataset"in e))return!1;let t=e.dataset;return typeof t==="object"&&t!==null&&Su.some((n)=>(n in t))}function Mu(e){if(!Cu(e))return!1;let t=e.composedPath();return Tu(t[0])&&t.some(Au)}var Qa=0,Vt=null;function nl(){if(Qa++,!Vt&&typeof window<"u"){let t=(r)=>{if(Mu(r))r.stopImmediatePropagation()},n=xu.map((r)=>L(window,r,t,{capture:!0}));Vt=()=>{for(let r of n)r()}}let e=!0;return()=>{if(!e)return;if(e=!1,--Qa>0)return;Vt?.(),Vt=null}}function rl(){let e=document.createElement("div");e.setAttribute(xe,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=mr;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),tl(e);let r=nl();document.documentElement.append(e);let o=typeof e.showPopover==="function",i=()=>{if(!o||!e.isConnected)return;try{e.hidePopover?.()}catch{}try{e.showPopover?.()}catch{}};if(o)e.popover="manual";i();let s=!1,a=()=>{if(s)return;s=!0,queueMicrotask(()=>{s=!1,i()})},l=(f)=>{if(f.type==="attributes")return f.target instanceof Element&&el(f.target);for(let g of[f.addedNodes,f.removedNodes])for(let v of g){if(!(v instanceof Element))continue;if(el(v))return!0;if(v.childElementCount>0&&v.querySelector(ol))return!0}return!1},d=[],p=0,h=()=>{p=0;let f=d;if(d=[],f.some(l))a()},u=new MutationObserver((f)=>{for(let g of f)d.push(g);if(p===0)p=typeof requestAnimationFrame==="function"?requestAnimationFrame(h):setTimeout(h,16)});return u.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:e,mount:n,destroy:()=>{if(r(),u.disconnect(),p!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(p);d=[];try{e.hidePopover?.()}catch{}e.remove()}}}var ol='dialog,[role="dialog"]';function el(e){return e.matches(ol)}function il(){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 sl(e){let t=document.createElement("div");t.setAttribute(xe,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=Ja;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");n.append(r),tl(t);let o=nl();if(typeof t.showPopover==="function")t.popover="manual";return e.append(t),t.showPopover?.(),{mount:r,destroy:()=>{o(),t.remove()}}}function Yt(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 Lu="me";var Pu;function al(){Pu=null,E().remove(Lu)}var ll="";function ct(e=!1){let t=globalThis.location;if(!t)return!1;let n=t.href;if(Ss(t.pathname),n===ll&&!e)return!1;return ll=n,J("nav",{url:z(n),route:z(t.pathname),spa:!0},{tabId:k.tabId,tabHost:k.tabHost})!==null}var je="__vitrinkaRecorderNavPatched",Xt="__vitrinkaRecorderNavUnpatch",br={};function Iu(){let e=globalThis;if(e[je]||typeof history>"u")return;e[je]=br;let t=[],n=(o)=>{let i=history[o],s=history[o]=function(...a){let l=i.apply(this,a);return queueMicrotask(ct),l};t.push(()=>{if(history[o]===s)history[o]=i})};n("pushState"),n("replaceState");let r=()=>queueMicrotask(ct);addEventListener("popstate",r),addEventListener("hashchange",r),e[Xt]=()=>{for(let o of t.splice(0))o();removeEventListener("popstate",r),removeEventListener("hashchange",r),delete e[je],delete e[Xt]}}function cl(){let e=globalThis;if(e[je]!==br)return;e[Xt]?.()}function dl(){let e=globalThis;if(e[je]===br)return!1;return e[Xt]?.(),delete e[je],Iu(),ct()}function ul(e){if(!e)return 0;let t=e.activeMs||0;if(!e.paused&&e.resumeAt)t+=Date.now()-Date.parse(e.resumeAt);return t}function pl(){Ct(),al();let e=S();if(e)Ga(e.sessionId,{status:"unsaved",durationMs:ul(e)}),Kt(null),Ha(),Ea(e.sessionId);I()}var fl="vitrinka.report.dock",hl=6,kr={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},Ou=["br","bl","tr","tl"];function _u(e){return e==="tl"||e==="tr"?"t":"b"}function Du(e){return e==="tl"||e==="bl"?"l":"r"}function gl(){let e=Re(fl);return Ou.find((t)=>t===e)??"br"}function ml(e){de(fl,e)}function bl(e,t,n){return kr[e.y<n/2?"t":"b"][e.x<t/2?"l":"r"]}function kl(e,t){if(t==="ArrowLeft"||t==="ArrowRight")return kr[_u(e)][t==="ArrowLeft"?"l":"r"];if(t==="ArrowUp"||t==="ArrowDown")return kr[t==="ArrowUp"?"t":"b"][Du(e)];return null}function yl(e){if(!e)return"";if(e.id)return`#${e.id}`;let t=e.getAttribute("data-testid")||e.getAttribute("data-test");if(t)return`[data-testid="${t}"]`;let n=[],r=e;while(r&&n.length<4){let o=r.tagName.toLowerCase();if(r.classList.length)o+="."+[...r.classList].slice(0,2).join(".");if(n.unshift(o),r.id){n[0]=`#${r.id}`;break}r=r.parentElement}return n.join(" > ")}var Nu="input,textarea,select",vl=".rr-mask,.rr-block";function wl(e){if(e.matches(Nu)||e.closest(vl)||e.querySelector(vl))return"";return(e.innerText||"").trim().slice(0,80)}var Hu="a,button,[role=button],input,select,textarea,label";function Bu(e){let t=e.getBoundingClientRect(),n=globalThis.devicePixelRatio||1;return{x:Math.round(t.x*n),y:Math.round(t.y*n),w:Math.round(t.width*n),h:Math.round(t.height*n)}}function zu(e){if(Pt().maskAllText)return"";return Lt(wl(e))??""}function xl(e){let t=(n)=>{try{if(e.ignore(n.target))return;let r=n.target instanceof Element?n.target:null,o=r?r.closest(Hu)||r:null;if(!o)return;J("click",{selector:yl(o),text:zu(o),rect:Bu(o),route:ta()},{tabId:k.tabId,tabHost:k.tabHost})}catch{}};return document.addEventListener("click",t,!0),()=>document.removeEventListener("click",t,!0)}var Fu=8192,dt="__vitrinkaRecorderConsolePatched";function Gt(e){return e.map((t)=>{if(typeof t==="string")return t;if(t instanceof Error)return t.stack??t.message;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ").slice(0,Fu)}function Jt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;J("console",{level:t,text:Lt(e)},{tabId:k.tabId,tabHost:k.tabHost})}var vr="__vitrinkaRecorderConsoleUnpatch",Sl={};function Rl(){let e=globalThis;if(e[dt]!==void 0&&e[dt]!==Sl)return;e[vr]?.()}function El(e={}){let t=globalThis;if(t[dt])return;t[dt]=Sl;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{Jt(Gt(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let p=console[d],h=p.bind(console),u=(...f)=>{h(...f);try{Jt(Gt(f),d)}catch{}};return console[d]=u,()=>{if(console[d]===u)console[d]=p}}),s=(d)=>{try{Jt(Gt([d.error??d.message]))}catch{}},a=(d)=>{try{Jt(`unhandled rejection: ${Gt([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[vr]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[dt],delete t[vr]}}var Cl=65536,ut=524288,Tl=3000;var yr="full";function xr(){if(Ge.following)return null;if(Et()==="report")return Yn();let e=S();if(e)return!e.paused&&!e.dead?e.sessionId:null;return Yn()}function pt(e){return e!==null&&xr()===e}function Zt(e,t){if(typeof e==="string")return Bn(e,Cl,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return Bn(e.toString(),Cl,"application/x-www-form-urlencoded");return $u(e)}function $u(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 wr(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function Sr(e){return typeof e==="string"||e instanceof URL?{}:e}function ft(e){let t=typeof e.url==="string"?z(e.url):e.url;J("net",{...e,url:t},{tabId:k.tabId,tabHost:k.tabHost})}function Rr(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 Ku(e,t){let n=Rr(t?.headers);if(n)return n;let r=Sr(e);return Rr(r.headers)}function ju(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 Er(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function qu(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function Wu(e,t){let n=await Uu(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return Zt(n,r)}async function Uu(e,t){let n=qu(t);if(n!==null&&n>ut)return Er(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()+Tl;try{while(s<ut){let f=d-Date.now();if(f<=0){l=!0;break}let g,v=await Promise.race([o.read(),new Promise((x)=>{g=setTimeout(()=>x("timeout"),f)})]).finally(()=>{if(g!==void 0)clearTimeout(g)});if(v==="timeout"){l=!0;break}let{done:b,value:y}=v;if(b)break;if(y){let x=ut-s,m=y.byteLength>x?y.subarray(0,x):y;i.push(m),s+=m.byteLength}}a=s>=ut,o.cancel().catch(()=>{return})}catch{return}let p=new Uint8Array(s),h=0;for(let f of i)p.set(f,h),h+=f.byteLength;let u;try{u=new TextDecoder().decode(p)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${u}…[body read timed out after ${Tl}ms]`;return a?`${u}…[truncated at ${ut} bytes]`:u}if(n===null)return Er(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var ht="__vitrinkaRecorderNetPatched",Cr="__vitrinkaRecorderNetUnpatch",Al={};function Ml(){let e=globalThis;if(e[ht]!==void 0&&e[ht]!==Al)return;e[Cr]?.()}function Ll(e={}){let t=globalThis;if(t[ht])return;t[ht]=Al,yr=e.detail??"full";let n=[];t[Cr]=()=>{for(let u of n.splice(0))u();delete t[ht],delete t[Cr]};let r=globalThis.fetch,o=async(u,f)=>{let g=typeof u==="string"?u:u instanceof URL?u.href:u.url,v=xr();if(Ln(g)||v===null)return r(u,f);let b=f?.method??("method"in Sr(u)?Sr(u).method:"GET"),y=Date.now();try{let x=await r(u,f),m=Date.now()-y;if(yr==="meta"){if(pt(v))ft({method:b,url:g,status:x.status,ms:m,via:"fetch"});return x}let M;try{M=x.clone()}catch{M=void 0}let{headers:qe,status:wt}=x;return cr((async()=>{if(!pt(v)){if(M)Er(M);return}let We=M?await Wu(M,qe):void 0;if(!pt(v))return;let Ue=Ku(u,f);ft({method:b,url:g,status:wt,ms:m,reqHeaders:et(Ue),resHeaders:et(Rr(qe)),reqBody:Zt(f?.body,wr(Ue)),resBody:We,via:"fetch"})})()),x}catch(x){if(pt(v))ft({method:b,url:g,error:String(x),ms:Date.now()-y,via:"fetch"});throw x}};globalThis.fetch=o,n.push(()=>{if(globalThis.fetch===o)globalThis.fetch=r});let i=globalThis.XMLHttpRequest;if(!i?.prototype)return;let s=i.prototype.open,a=i.prototype.send,l=i.prototype.setRequestHeader;n.push(()=>{let u=i.prototype;if(u.open===d)u.open=s;if(u.send===h)u.send=a;if(u.setRequestHeader===p)u.setRequestHeader=l});let d=i.prototype.open=function(...u){return this.__vt={method:u[0],url:String(u[1])},s.apply(this,u)},p=i.prototype.setRequestHeader=function(u,f){let g=this.__vt;if(g)(g.reqHeaders??={})[u]=f;return l?.call(this,u,f)},h=i.prototype.send=function(u){let f=this.__vt,g=xr();if(f&&!Ln(f.url)&&g!==null){let v=Date.now();this.addEventListener("loadend",()=>{if(!pt(g))return;if(yr==="meta"){ft({method:f.method,url:f.url,status:this.status,ms:Date.now()-v,via:"xhr"});return}let b;try{b=ju(this.getAllResponseHeaders())}catch{b=void 0}let y;try{y=this.responseType===""||this.responseType==="text"?Zt(this.responseText,wr(b)):void 0}catch{y=void 0}ft({method:f.method,url:f.url,status:this.status,ms:Date.now()-v,reqHeaders:et(f.reqHeaders),resHeaders:et(b),reqBody:Zt(u,wr(f.reqHeaders)),resBody:y,via:"xhr"})})}return a.call(this,u)}}var Vu=2000,Yu=300000,mt=null,bt=null,gt=[],Qt=null;function Pl(){if(!gt.length)return;let e=gt;gt=[],Na(e,{tabId:k.tabId,tabHost:k.tabHost})}function kt(){return bt}function Il(e,t,n={}){if(mt)return;let r=Pt(),o=n.unmaskSelector;try{mt=e({emit:t==="flight"?(s)=>ua($n(s)):(s)=>{gt.push($n(s))},checkoutEveryNms:t==="flight"?aa().checkoutMs:Yu,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:`[${xe}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(bt=e,t==="flight")Un(en);if(t==="session")Qt=setInterval(Pl,Vu)}function Ol(){if(Qt)clearInterval(Qt);Qt=null,Pl();try{mt?.()}catch{}mt=null,bt=null,Un(null),gt=[]}function en(){if(!mt||!bt)return;try{bt.takeFullSnapshot?.(!0)}catch{}}var Nl="vitrinka.capture",F="windows",K="chunks";function Se(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function Tr(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function _l(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function Dl(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 Hl(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(Nl,1);r.onupgradeneeded=()=>{r.result.createObjectStore(F,{keyPath:"id"}),r.result.createObjectStore(K)},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(F).delete(i),o.objectStore(K).delete(_l(i))};return{async putWindow(o){let i=t.transaction(F,"readwrite");i.objectStore(F).put(o),await Se(i)},async putChunk(o,i,s,a){let l=t.transaction(K,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(K).put(d,[o,i]),await Se(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([F,K],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(K).put(d,[o.id,i]),l.objectStore(F).put(o)}catch(p){throw l.abort(),p}await Se(l)},async dropWindow(o){let i=t.transaction([F,K],"readwrite");n(i,o),await Se(i)},async clear(o){let i=t.transaction([F,K],"readwrite"),s=await Tr(i.objectStore(F).getAll());for(let a of s)if(Dl(a)&&a.tab===o)n(i,a.id);await Se(i)},async sweep(o,i,s,a){let l=t.transaction([F,K],"readwrite"),d=(await Tr(l.objectStore(F).getAll())).filter(Dl),p=[],h=new Map;for(let u of d)h.set(u.tab,[...h.get(u.tab)??[],u]);for(let[u,f]of h){let g=f.filter((b)=>b.kind!=="lanes").sort((b,y)=>b.startMs-y.startMs),v=(b)=>b.kind==="lanes"?b.lastMs:Wn(b,g[g.indexOf(b)+1]);for(let b of f.sort((y,x)=>y.startMs-x.startMs))if(v(b)<=o-i||u===s&&b.scope!==a)n(l,b.id);else if(u===s)p.push(b)}return await Se(l),p},async read(o){let i=t.transaction(K,"readonly"),s=await Tr(i.objectStore(K).getAll(_l(o)));await Se(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 Bl(e=globalThis.indexedDB){try{e?.deleteDatabase(Nl)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function Ar(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 Mr(e,t){return`${t.y<e.y?"n":"s"}${t.x<e.x?"w":"e"}`}function Lr(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 zl(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 Fl(e){return e.map((t,n)=>({...t,n:n+1}))}function $l(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 Xu=2,Gu=3,Ju=0,Zu=5,Pr=2,Qu=3,ep=2000000000,tp="data-vitrinka-hidden",np="#1b1b1f";function rp(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:${np};z-index:2147483647;pointer-events:none;`;return{type:Pr,id:ep+t,tagName:"div",attributes:{[tp]:"",style:n},childNodes:[]}}function Ir(e,t,n,r){let o={...e};if(e.type===Qu&&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)=>Ir(i,t,n,r)),!r.done&&e.type===Pr&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function op(e,t){(e.childNodes?.find((r)=>r.type===Pr)??e).childNodes?.push(...t)}function ip(e,t){return Ir(e,t,[],{done:!0})}function Kl(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map(rp);return e.map((o)=>{let i=o.data;if(o.type===Xu&&i.node){let s={done:!1},a=Ir(i.node,n,r,s);if(!s.done)op(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==Gu||!n.size)return o;if(i.source===Ju){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:ip(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===Zu){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function sp(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function ap(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function Or(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)=>sp(ap(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 lp=["errors","interactions","full","console","network"];var tn={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function on(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function nn(e,t,n){return Math.min(n,Math.max(t,e))}function cp(e){if(!Array.isArray(e))return null;return lp.filter((t)=>e.includes(t))}function jl(e,t){if(typeof e!=="object"||e===null)return on(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":tn.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?nn(Math.round(n.windowSec),10,3600):tn.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?nn(Math.round(n.maxBytes),262144,67108864):tn.maxBytes,classes:cp(n.classes)??tn.classes}}function rn(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 dp(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 ql(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=rn(e.classes),s=rn(t.classes);o=dp({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:nn(n,10,3600),maxBytes:nn(r,262144,67108864),classes:o}}function Wl(e){return e==="balanced"||e==="full"?e:"strict"}function Ul(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var Vl="[data-vitrinka-unmask]";var up=3670016,Yl=4194240,pp=2000,_r=500,fp=60000,sn=/[A-Za-z0-9_-]{20,}/g;function B(e,t=""){return typeof e==="string"?e:t}function hp(e){let t=e;if(e.includes("%"))try{t=decodeURIComponent(e)}catch{t=e}if(sn.lastIndex=0,t===e||!sn.test(t))return e.replace(sn,"•••");return t.replace(sn,"•••").replace(/[/?#%]/g,(n)=>encodeURIComponent(n))}function vt(e){let t=B(e),n;try{n=new URL(t,globalThis.location?.href??"http://localhost").pathname}catch{n=t.split(/[?#]/)[0]??""}return n.split("/").map(hp).join("/").slice(0,300)}var gp=`.rr-block,[${xe}]`;function mp(e){return typeof Element<"u"&&e instanceof Element&&e.closest(gp)!==null}function bp(e){try{let t=new URL(B(e),globalThis.location?.href??"http://localhost");return t.origin+vt(t.pathname)}catch{return vt(e)}}var kp=4;function vp(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===kp&&o.length)s();if(!i&&Fe(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}var yp=300,wp=80;function xp(e){if(typeof e!=="object"||e===null)return null;let t=e,n=(a)=>typeof t[a]==="number"&&Number.isFinite(t[a])?t[a]:null,[r,o,i,s]=[n("x"),n("y"),n("w"),n("h")];return r===null||o===null||i===null||s===null?null:{x:r,y:o,w:i,h:s}}function Sp(e){return(t,n)=>{if(t==="click"){if(!e.replay)return null;let r=xp(n?.rect);return{selector:B(n?.selector).slice(0,yp),text:B(n?.text).slice(0,wp),...r?{rect:r}:{},route:vt(n?.route)}}if(t==="nav"){if(!e.replay)return null;return{url:bp(n?.url),route:vt(n?.route),spa:!0}}if(t==="console"){let r=B(n?.level,"error");if(r==="error"?!(e.errors||e.console):!e.console)return null;return{level:r,text:B(n?.text).slice(0,pp)}}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:B(n?.method,"GET").toUpperCase(),path:vt(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}function Rp(e,t=!0){return e.filter((n)=>t&&n.kind==="click"||n.kind==="nav").slice(-_r).map((n)=>({kind:n.kind,ts:n.ts,payload:n.payload??{}}))}async function Ep(e){try{let t=await ee("GET","/api/v1/report-config",void 0,{target:e}),n=typeof t.flightRecorder==="boolean"?t.flightRecorder:void 0;return{project:B(t.project),profile:t.captureProfile==null?on(n):jl(t.captureProfile,n),masking:Wl(t.profile),reachable:!0,attachments:Gi(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:on(),masking:"strict",reachable:!1,attachments:Z}}}function Xl(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 Gl{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(Ls(e.base));let t=await Ep({url:e.base,key:e.key}),n=ql(t.profile,e.capture),r=rn(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=Rs("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,xs(ws(),globalThis.location?.host??""),k.pathname=globalThis.location?.pathname??"/",Qs(Ul(o.masking)),zn(e.sanitizeUrl),this.capture.push(()=>zn(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 Hl();let d=await this.store.sweep(Date.now(),i,k.tabId,s);a=d;let p=this.store;l=(await Promise.all(d.filter((u)=>u.kind==="lanes").map((u)=>p.read(u.id)))).flatMap((u)=>u.lanes).sort((u,f)=>Date.parse(u.ts)-Date.parse(f.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else Bl();if(!this.capturing)return this.store?.close(),this.store=null,o;if(ia({windowMs:i,checkoutMs:Math.min(fp,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:qn,keepLane:Sp(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(sa),this.store&&typeof window<"u"){let d=()=>Ot();this.capture.push(L(window,"pagehide",d),L(document,"visibilitychange",d))}if(r.errors||r.console)El({levels:r.console?["warn","info","log"]:[]}),this.capture.push(Rl);if(r.errors||r.network)Ll({detail:"meta"}),this.capture.push(Ml);if(r.replay){if(typeof document<"u")this.capture.push(xl({ignore:(p)=>Yt(p)||mp(p)}));if(!dl())ct(!0);let d=await e.loadRecord(e.base).catch((p)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",p),null));if(d&&this.capturing)Il(d,"flight",{unmaskSelector:Vl}),this.capture.push(Ol)}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)ca().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};k.pathname=globalThis.location?.pathname??k.pathname;let e=Dt();if(e&&kt()&&!Jn(e))en(),e=Dt();let t=this.store,n=e?.windows.filter((o)=>o.stored).map((o)=>o.id)??[],r=t&&n.length?Promise.all(n.map(async(o)=>[o,await t.read(o)])).then((o)=>new Map(o)):Promise.resolve(new Map);return r.catch(()=>{return}),{clip:e,stored:r}}withScreen(e){if(!this.capturing||!kt()||e&&Jn(e))return e;en();let t=Dt();if(!t)return e;return{windows:[...e?.windows.filter((n)=>n.stored)??[],...t.windows.filter((n)=>!n.stored)],lanes:e?.lanes??t.lanes,truncated:e?.truncated??t.truncated}}hiddenIdsAt(e){if(!this.capturing)return null;let t=Xl(kt());return t?Or([e],t):null}async build(e,t,n=new Set){let r=t.filter((m)=>m.shape==="hide").map((m)=>m.rect),o=Xl(kt()),i=r.length>0&&!o;if(i)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let s=new Set(n);if(r.length&&o)for(let m of Or(r,o))s.add(m);let a=[],l=this.withScreen(e.clip),d=l?.truncated??!1,p=await e.stored.catch((m)=>(console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",m),null));for(let m of l?.windows??[]){if(!m.stored){a.push(...m.events);continue}let M=p?.get(m.id);if(!M?.events.length)d=!0;else a.push(...M.events)}let h=l?.lanes??[],u=i?{events:[],dropped:!1}:vp(Kl(a,r,s),Yl);if(u.dropped)d=!0;let{parts:f,dropped:g}=ur(u.events,up,Yl),v=[],b=0;for(let m of f){b+=m.count;let M=u.events[b-1]?.timestamp??Date.now();v.push({seq:v.length+1,ts:new Date(M).toISOString(),count:m.count,body:m.body})}let y=h.filter((m)=>m.kind==="console").slice(-_r).map((m)=>({level:B(m.payload?.level,"error"),ts:m.ts,text:B(m.payload?.text)})),x=h.filter((m)=>m.kind==="net").slice(-_r).map((m)=>({method:B(m.payload?.method,"GET"),path:B(m.payload?.path),status:typeof m.payload?.status==="number"?m.payload.status:0,ms:typeof m.payload?.ms==="number"?m.payload.ms:0,ts:m.ts}));return{chunks:v,truncated:d||g.length>0,console:y,network:x,journey:Rp(h,r.length===0)}}clear(){if(this.capturing)la()}stop(){if(this.stopped=!0,this.listeners.clear(),this.capturing&&this.config?.lanes.replay)cl();this.standDown(),Es(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var q=null;function Jl(e){if(q){let t=q.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 q.refs++,q.engine}return q={engine:new Gl(e),refs:1},q.engine}function Zl(e){if(!e||!q||q.engine!==e)return;if(--q.refs>0)return;q=null,e.stop()}var Cp=/^[\w-]+\.[\w-]+\.[\w-]+$/;function an(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!Cp.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 Ql=null,Dr=new Set;function Tp(e){Ql=an(e);for(let t of Dr)t()}function ec(){return Ql}function tc(e){return Dr.add(e),()=>Dr.delete(e)}var Ap=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),Nr="report.keybind";function nc(e){if(Ap.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 rc(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var Mp={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function oc(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 Mp[e]??e}function Lp(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function ln(e,t=Lp()){let n=oc(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 ic(e){return[e.ctrl&&"Control",e.alt&&"Alt",e.shift&&"Shift",e.meta&&"Meta",oc(e.code)].filter(Boolean).join("+")}function Pp(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;let n=t;if(typeof n.code!=="string"||!n.code)return null;let r={code:n.code,alt:n.alt===!0,ctrl:n.ctrl===!0,meta:n.meta===!0,shift:n.shift===!0};return r.alt||r.ctrl||r.meta?r:null}catch{return null}}var Ip={code:"KeyA",alt:!0,ctrl:!1,meta:!1,shift:!0},sc="off";function ac(e){if(e===sc)return null;return Pp(e)??Ip}function lc(){return ac(E().getString(Nr))}function Hr(e){E().set(Nr,e?JSON.stringify(e):sc)}function cc(e){let t=E();return t.watch?t.watch(Nr,(n)=>e(ac(n))):()=>{return}}var Op=["br","bl","tr","tl"];function Br(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 _p(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 dc(e,t,n){let r=Br(e,n);return t.reduce((o,i)=>o+_p(r,i),0)}function uc(e,t,n){let r=dc(e,t,n);if(r===0)return e;let o=e,i=r;for(let s of Op){let a=dc(s,t,n);if(a<i)o=s,i=a}return o}function pc(e,t,n,r){let o=e==="br"||e==="bl";if(t.vh-t.top-t.h-t.bottom>=n.h+r)return o?"above":"below";if(t.vw-2*t.edge-t.w>=n.w+r)return e==="br"||e==="tr"?"left":"right";return"over"}var Dp="report.round";function zr(e){return`${Dp}:${e.url}|${e.key}`}function Np(e){try{return JSON.parse(E().getString(zr(e))??"null")}catch{return null}}function Hp(e,t){try{let n=E();if(t)n.set(zr(e),JSON.stringify(t));else n.remove(zr(e))}catch(n){console.warn("vitrinka: the test round could not be kept in this browser — the next report opens a new one",n)}}function Bp(e){if(typeof e!=="object"||e===null)return null;let t=e;if(typeof t.token!=="string"||!t.token)return null;return{token:t.token,reports:typeof t.reports==="number"&&Number.isFinite(t.reports)&&t.reports>0?Math.floor(t.reports):0,openedAt:typeof t.openedAt==="string"?t.openedAt:""}}function Fr(e){return Bp(Np(e))}function fc(e,t,n=""){if(typeof t!=="object"||t===null)return null;let r=t;if(typeof r.token!=="string"||!r.token)return null;let o={token:r.token,reports:typeof r.reports==="number"&&Number.isFinite(r.reports)&&r.reports>0?Math.floor(r.reports):1,openedAt:typeof r.openedAt==="string"?r.openedAt:""},i=Fr(e);if((i?.token??"")!==n){if(i?.token!==o.token)return null}if(i?.token===o.token)o.reports=Math.max(o.reports,i.reports);return Hp(e,o),{round:o,rotated:r.rotated===!0}}function Kr(e){if(!(e instanceof A)||e.status!==400)return"";return/unknown field \\?"(\w+)\\?"/.exec(e.message)?.[1]??""}var hc={ms:30000,bytesPerMs:32};class gc extends Error{constructor(e,t){super(`vitrinka: ${e} got no answer in ${Math.round(t/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function $r(e,t,n){let r=new AbortController,o,i=new Promise((s,a)=>{o=setTimeout(()=>{let l=new gc(e,t);r.abort(l),a(l)},t)});try{return await Promise.race([n(r.signal),i])}finally{clearTimeout(o)}}var jr={chunks:[],truncated:!1,console:[],network:[],journey:[]};function mc(e,t=hc.ms){return $r("preparing the capture",t,e).catch((n)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",n),jr))}class qr{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(e,t,n,r=[],o=hc){this.capture=e;this.tabHost=t;this.target=n;this.files=r;this.limits=o}call(e,t,n){return $r(`${e} ${t}`,this.limits.ms,(r)=>ee(e,t,n,{target:this.target,signal:r}))}upload(e,t,n){let r=typeof n==="string"?new TextEncoder().encode(n).byteLength:n.size,o=this.limits.ms+Math.ceil(r/this.limits.bytesPerMs);return $r(`POST ${e}`,o,(i)=>On(e,t,n,this.target,i))}get filesPending(){return this.filesDone.size<this.files.length}async run(e,t){let n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let{res:i,memberSent:s,roundSent:a}=await this.create(e);if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");if(this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r,fc(this.target,i.round,a),typeof i.memberError==="string"&&i.memberError)t?.(i.memberError,s)}else if(this.sent!==r)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n),this.sent=r;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof A)||!U(i.status))throw i;console.warn("vitrinka: the server refused the recording — the report goes without it",i),this.skipCapture=!0}let o=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async create(e){let t=e;for(;;)try{return{res:await this.call("POST","/api/v1/reports",t),memberSent:t.memberToken??"",roundSent:t.round??""}}catch(n){let r=Kr(n);if(r==="type"&&t.type!==void 0){console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:o,...i}=t;t=i}else if(r==="memberToken"&&t.memberToken!==void 0){console.warn("vitrinka: this server takes no member link yet — sending the report without it");let{memberToken:o,...i}=t;t=i}else if(r==="round"&&t.round!==void 0){console.warn("vitrinka: this server keeps no test rounds yet — sending the report without one");let{round:o,...i}=t;t=i}else if(r==="context"&&t.context!==void 0){console.warn("vitrinka: this server takes no report context yet; sending the report without it");let{context:o,...i}=t;t=i}else throw n}}async sendFiles(){let e=encodeURIComponent(this.id);for(let[t,n]of this.files.entries()){if(this.filesDone.has(t))continue;try{await this.upload(`/api/v1/reports/${e}/attachment?name=${encodeURIComponent(n.name)}`,n.type||"application/octet-stream",n)}catch(r){if(!(r instanceof A)||!U(r.status))throw r;console.warn(`vitrinka: the server refused ${n.name} — the report goes without it`,r)}this.filesDone.add(t)}}async sendCapture(){let e=encodeURIComponent(this.id),{chunks:t,truncated:n,journey:r}=this.capture;for(let i of t){if(this.blobKeys.has(i.seq))continue;let s=await this.upload(`/api/v1/reports/${e}/chunk?seq=${i.seq}`,"application/json",i.body);if(!s.blobKey)throw Error(`vitrinka: chunk ${i.seq} came back without a blob key`);this.blobKeys.set(i.seq,s.blobKey)}let o=t.map((i)=>({seq:i.seq,ts:i.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:i.count,source:"replay",truncated:n},blobKey:this.blobKeys.get(i.seq)??""}));if(t.length)for(let i of r)o.push({seq:o.length+1,ts:i.ts,tabHost:this.tabHost,kind:i.kind,payload:i.payload,blobKey:""});while(this.rowsPosted<o.length){let i=o.slice(this.rowsPosted,this.rowsPosted+$t);await this.call("POST",`/api/v1/reports/${e}/events`,{events:i}),this.rowsPosted+=i.length}}}async function cn(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 A(`${e} ${t} → ${i.status}: ${s}`,i.status);return s?JSON.parse(s):{}}async function bc(e,t,n=""){if(!n)return cn("POST","/api/v1/report/session",e,{token:t});try{return await cn("POST","/api/v1/report/session",e,{token:t,memberToken:n})}catch(o){if(Kr(o)!=="memberToken")throw o;return console.warn("vitrinka: this server takes no member link yet — the reporter session opens without it"),cn("POST","/api/v1/report/session",e,{token:t})}}function Wr(e,t){return e?JSON.stringify([e,t]):""}function kc(e,t=Date.now()){return e!==null&&Date.parse(e.expiresAt)-t>60000}function Ur(e,t,n){let r=n?`?cursor=${encodeURIComponent(n)}`:"";return cn("GET",`/api/v1/report/mine${r}`,e,void 0,t)}function vc(e,t){return`vitrinka.report.sent:${e}|${t}`}function yc(){try{return globalThis.localStorage??null}catch{return null}}function Vr(e,t){let n=yc()?.getItem(vc(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 wc(e,t,n){let r=yc();if(!r)return;let o=[n,...Vr(e,t)].slice(0,20);try{r.setItem(vc(e,t),JSON.stringify(o))}catch(i){console.warn("vitrinka: could not remember the sent report on this browser",i)}}var xc=`
10
10
  :host { all: initial; }
11
11
  .vr {
12
12
  --ink: #f2f1ef;
@@ -87,6 +87,72 @@ kbd {
87
87
  .vr[data-dock="bl"] .fab, .vr[data-dock="bl"] .card { transform-origin: 0 100%; }
88
88
  .vr[data-dock="tr"] .fab, .vr[data-dock="tr"] .card { transform-origin: 100% 0; }
89
89
  .vr[data-dock="tl"] .fab, .vr[data-dock="tl"] .card { transform-origin: 0 0; }
90
+ /* -- the edge drop (vt-3811, the default launcher; edge.ts) ---------------------
91
+ A half-bead resting on the right edge, with two meniscus feet where it meets it: the edge is the flat
92
+ surface the liquid sits on. It grows its name on hover or focus, swells with a soft spring, stretches
93
+ while it is moved along the edge and settles with one damped wobble. It never moves at rest. Ink in
94
+ both colour schemes; a hairline light rim keeps it visible on a dark page. A host themes it with
95
+ --vr-drop-fill and --vr-drop-ink on the HUD host. The card opens beside it, centred on it. */
96
+ .fab-glyph { display: none; }
97
+ .fab-glyph svg { display: block; width: 18px; height: 18px; }
98
+ .vr[data-launcher="edge"] {
99
+ --drop-fill: var(--vr-drop-fill, #131216);
100
+ --drop-ink: var(--vr-drop-ink, #fff);
101
+ --spring: cubic-bezier(.34, 1.56, .64, 1);
102
+ }
103
+ .vr[data-launcher="edge"] .fab {
104
+ right: 0; bottom: auto; top: var(--vr-drop-top, 62vh);
105
+ transform-origin: 100% 50%;
106
+ height: 48px; gap: 0; padding: 0 11px 0 13px;
107
+ border-radius: 24px 0 0 24px;
108
+ background: radial-gradient(7px 3.5px at 15px 10px, rgba(255, 255, 255, .24), transparent) no-repeat, var(--drop-fill);
109
+ color: var(--drop-ink);
110
+ font-size: 14px; font-weight: 500; letter-spacing: normal;
111
+ box-shadow: none;
112
+ filter: drop-shadow(0 0 .6px rgba(255, 255, 255, .55)) drop-shadow(-3px 5px 9px rgba(0, 0, 0, .22));
113
+ transition: top var(--dur-slow) var(--ease-smooth-out), transform 420ms var(--spring);
114
+ }
115
+ .vr[data-launcher="edge"] .fab::before, .vr[data-launcher="edge"] .fab::after {
116
+ content: ""; position: absolute; right: 0; width: 11px; height: 11px; pointer-events: none;
117
+ transition: transform 420ms var(--spring);
118
+ }
119
+ .vr[data-launcher="edge"] .fab::before {
120
+ bottom: 100%; transform-origin: 100% 100%;
121
+ background: radial-gradient(circle at 0 0, transparent 10.5px, var(--drop-fill) 11px);
122
+ }
123
+ .vr[data-launcher="edge"] .fab::after {
124
+ top: 100%; transform-origin: 100% 0;
125
+ background: radial-gradient(circle at 0 100%, transparent 10.5px, var(--drop-fill) 11px);
126
+ }
127
+ .vr[data-launcher="edge"] .fab-glyph { display: block; flex: none; }
128
+ .vr[data-launcher="edge"] .fab-label {
129
+ max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0;
130
+ transition: max-width 460ms cubic-bezier(.34, 1.4, .64, 1), opacity .2s ease .06s, padding .3s ease;
131
+ }
132
+ .vr[data-launcher="edge"] .fab:hover, .vr[data-launcher="edge"] .fab:focus-visible { transform: scale(1.07); box-shadow: none; }
133
+ .vr[data-launcher="edge"] .fab:hover::before, .vr[data-launcher="edge"] .fab:hover::after,
134
+ .vr[data-launcher="edge"] .fab:focus-visible::before, .vr[data-launcher="edge"] .fab:focus-visible::after { transform: scaleY(1.45); }
135
+ /* Never while the card is open: the name would grow under the card beside it. */
136
+ .vr[data-launcher="edge"] .fab[aria-expanded="false"]:hover .fab-label,
137
+ .vr[data-launcher="edge"] .fab[aria-expanded="false"]:focus-visible .fab-label { max-width: 240px; opacity: 1; padding: 0 7px 0 9px; }
138
+ .vr[data-launcher="edge"] .fab:focus-visible { outline-offset: -4px; }
139
+ /* Moved along the edge it follows the pointer and stretches; released, it settles. */
140
+ .vr[data-launcher="edge"] .fab.dragging { transform: scale(.9, 1.16); transition: transform 200ms var(--spring); cursor: grabbing; }
141
+ .vr[data-launcher="edge"] .fab.settle { animation: vr-settle 520ms ease-out; }
142
+ @keyframes vr-settle {
143
+ 0% { transform: scale(.9, 1.16); }
144
+ 35% { transform: scale(1.08, .9); }
145
+ 60% { transform: scale(.97, 1.04); }
146
+ 80% { transform: scale(1.01, .99); }
147
+ 100% { transform: none; }
148
+ }
149
+ .vr[data-launcher="edge"] .card {
150
+ right: calc((44px + 12px) * var(--vr-scale)); bottom: auto; top: var(--vr-card-top, 16px);
151
+ transform-origin: 100% 0;
152
+ height: min(460px, calc((100vh - 32px) / var(--vr-scale)));
153
+ }
154
+ .vr.nobutton[data-launcher="edge"] .card { right: var(--edge); }
155
+ .vr[data-launcher="edge"] .card.parked { right: auto; transform-origin: 0 0; }
90
156
  /* Dragged, the button rides the pointer by its left/top; dropped, it glides into its corner (FLIP on translate). */
91
157
  .vr .fab.dragging { transform-origin: 0 0; transition: none; cursor: grabbing; }
92
158
  .fab.gliding { transition: translate var(--dur-slow) var(--ease-smooth-out), transform .14s ease, box-shadow .14s ease; }
@@ -402,6 +468,8 @@ a.row:hover { background: var(--faint); }
402
468
  @media (max-width: 520px) {
403
469
  .vr { --edge: 16px; --lift: calc(var(--edge) + 68px * var(--vr-scale)); }
404
470
  .fab { padding: 13px 18px; font-size: 16px; }
471
+ /* A phone has no room beside the drop: the card takes the width and covers it. */
472
+ .vr[data-launcher="edge"] .card { right: var(--edge); }
405
473
  .tb { max-width: calc((100vw - 16px) / var(--vr-scale)); overflow-x: auto; }
406
474
  .tb-lead { display: none; }
407
475
  .seg button { padding: 0 9px; }
@@ -412,6 +480,13 @@ a.row:hover { background: var(--faint); }
412
480
  .card.parked, .seg-ind, .seg button, .kinds button, .pin .rm, .link svg, .coach, .switch, .switch .knob { transition: none; }
413
481
  .card.busy .head::after { animation: none; }
414
482
  .fab, .fab.gliding { transition: none; }
415
- }
416
- `;var xp="http://www.w3.org/2000/svg",ic=100,pc=["box","circle","arrow","hide"],qr={w:160,h:80},sc=16,ac={w:380,h:460},Wr=72,Ur={w:300,h:160,gap:10},jr=16,Sp={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},E={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>'},fc="0;0.18;0.72;1",yt="2.8s",lc="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14",Rp='<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"/>';function Ep(e,t,n){return`<animate attributeName="${e}" values="${t};${t};${n};${n}" keyTimes="${fc}" calcMode="linear" dur="${yt}" repeatCount="indefinite"/>`}function Cp(e,t){let n=(p,h)=>t?h:p,r=(p,h,u)=>t?"":Ep(p,h,u),o=t?"":`<animate attributeName="opacity" values="1;1;0" keyTimes="0;0.9;1" dur="${yt}" repeatCount="indefinite"/>`,i=t?"":`<animate attributeName="opacity" values="0;0;.9;.9;0;0" keyTimes="0;0.08;0.14;0.72;0.8;1" dur="${yt}" repeatCount="indefinite"/>`,s,a,l;if(e==="circle")a=lc,l={x:134,y:14},s=`<rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${lc}" pathLength="200" stroke-dasharray="200" stroke-dashoffset="${n(200,0)}">${r("stroke-dashoffset",200,0)}${o}</path>`;else if(e==="arrow"){a="M 74 54 L 128 33",l={x:128,y:33};let p=t?"":`<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.18;0.19;0.9;1" dur="${yt}" repeatCount="indefinite"/>`;s=`<defs><marker id="vr-coach-head" viewBox="0 0 10 10" refX="7" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="#e6455f"/></marker></defs><rect class="bar" x="136" y="27" width="70" height="10" rx="5"/><line class="loop" x1="74" y1="54" x2="${n(74,128)}" y2="${n(54,33)}" marker-end="url(#vr-coach-head)"${t?"":' opacity="0"'}>${r("x2",74,128)}${r("y2",54,33)}${p}</line>`}else{let p=e==="hide";a=p?"M 90 10 L 178 54":"M 96 12 L 172 52",l=p?{x:178,y:54}:{x:172,y:52};let h=p?90:96,u=p?10:12,f=l.x-h,g=l.y-u;s=(p?'<rect class="bar" x="102" y="20" width="64" height="8" rx="4"/><rect class="bar" x="102" y="35" width="44" height="8" rx="4"/>':'<rect class="bar" x="110" y="27" width="48" height="10" rx="5"/>')+`<rect class="${p?"veil":"loop"}" x="${h}" y="${u}" width="${n(0,f)}" height="${n(0,g)}" rx="${p?4:6}">${r("width",0,f)}${r("height",0,g)}${o}</rect>`}let d=t?"":`<animateMotion dur="${yt}" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="${fc}" calcMode="linear" path="${a}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true" data-shape="${e}">${s}<g class="pointer"${t?` transform="translate(${l.x} ${l.y})"`:""}><circle class="hold" r="9"${t?' opacity=".9"':' opacity="0"'}>${i}</circle>${Rp}${d}</g></svg>`}function c(e,t={},...n){let r=document.createElement(e);for(let[o,i]of Object.entries(t))r.setAttribute(o,i);return r.append(...n),r}function A(e){let t=document.createElement("template");t.innerHTML=e;let n=t.content.firstElementChild;if(!n)throw Error("vitrinka: icon markup is empty");return n}function K(e,t){let n=document.createElementNS(xp,e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function cc(e){let t=e.split(`
417
- `)[0]?.trim()??"";return t.length>ic?`${t.slice(0,ic-1)}…`:t}function dc(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function Vr(){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 Tp(e){return(e.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((n)=>n[0]?.toUpperCase()??"").join("")||"?"}function W(e,t){let n=e.querySelector("span");if(n)n.textContent=t}function uc(e,t,n,r=!1){if(!n||!n.offsetWidth)return;let o=r||!e.classList.contains("measured");if(o)t.style.transition="none";if(t.style.width=`${n.offsetWidth}px`,t.style.transform=`translateX(${n.offsetLeft}px)`,e.classList.add("measured"),!o)return;t.offsetWidth,t.style.removeProperty("transition")}function Ap(){let e=Vr();return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Yr(e,t){let n=e.target;if(!t||!(n instanceof Element))return!1;try{return n.closest(t)!==null}catch{return!1}}function Mp(e){let t=c("span"),n=c("kbd",{"aria-hidden":"true"}),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"},A(E.dots)),d=c("button",{class:"icon",type:"button"},A(E.close)),p=c("header",{class:"head"},o,a,l,d),h=c("strong"),u=c("span",{class:"acc-mail"}),f=c("p",{class:"acc-via"}),g=c("p",{class:"acc-linked"}),k=c("button",{class:"link",type:"button"}),b=c("button",{class:"pop-item",type:"button"},A(E.link),c("span")),v=c("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},A(E.ext),c("span")),x=c("div",{class:"pop acc",role:"dialog"},c("div",{class:"acc-who"},h,u,f),c("div",{class:"acc-member"},g,k),b,v),m=(_)=>c("button",{class:"pop-item",type:"button",role:"menuitem"},A(_),c("span")),M=m(E.list),ze=m(E.clock),Ke=m(E.rec),kt=c("small",{class:"pop-why",id:"vr-record-why","aria-hidden":"true"});Ke.append(kt);let qe=m(E.gear),Jr=c("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},A(E.ext),c("span")),Zr=c("div",{class:"pop more",role:"menu"},M,ze,Ke,qe,Jr),Qr=c("span",{class:"sr",id:"vr-kinds"}),un=new Map;for(let _ of wa)un.set(_,c("button",{type:"button",role:"radio","aria-checked":"false","data-kind":_}));let eo=c("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},Qr,...un.values()),to=c("label",{class:"prompt",for:"vr-desc"}),no=c("textarea",{class:"desc",id:"vr-desc",rows:"3"}),ro=c("ol",{class:"lines"}),oo=c("p",{class:"ln-empty"}),io=c("span"),so=c("span"),ao=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},so,A(E.chevron)),lo=c("div",{class:"attached"},A(E.clip),io,c("span",{"aria-hidden":"true"},"·"),ao),co=c("ul",{class:"included",id:"vr-included"}),uo=c("input",{type:"checkbox"}),po=c("span"),fo=c("label",{class:"notify"},uo,po),ho=c("p",{class:"error",role:"alert"}),go=c("span"),mo=c("button",{class:"where",type:"button","aria-pressed":"false"},A(E.pen),go),bo=c("button",{class:"send",type:"button"}),yo=c("div",{class:"pane describe"},eo,to,no,c("div",{class:"lines-wrap"},ro,oo),lo,co,fo,ho),ko=c("button",{class:"icon",type:"button"},A(E.clip)),vo=c("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),wo=c("p",{class:"file-note",role:"status"}),xo=c("ul",{class:"files"}),So=c("div",{class:"tray"},wo,xo),Ro=c("div",{class:"foot"},ko,vo,mo,bo),Eo=c("span",{class:"label",id:"vr-bind-label"}),Co=c("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),To=c("button",{class:"link",type:"button"}),Ao=c("p",{class:"hint"}),Mo=c("p",{class:"reason",role:"status"}),Lo=c("button",{class:"link",type:"button"}),Po=c("span",{class:"label",id:"vr-size-label"}),pn=new Map;for(let _ of dr)pn.set(_,c("button",{type:"button",role:"radio","aria-checked":"false","data-size":_}));let Io=c("span",{class:"seg-ind","aria-hidden":"true"}),Oo=c("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},Io,...pn.values()),_o=c("span",{class:"label",id:"vr-coach-label"}),Do=c("button",{class:"switch",type:"button",role:"switch","aria-checked":"true","aria-labelledby":"vr-coach-label"},c("span",{class:"knob","aria-hidden":"true"})),No=c("span"),Ho=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},No,A(E.chevron)),Bo=c("dl",{class:"tech",id:"vr-tech"}),Fo=c("div",{class:"pane settings"},c("div",{class:"row"},Eo,Co),Mo,Ao,c("div",{class:"row size-row"},Po,Oo),c("div",{class:"row tips-row"},_o,Do),c("div",{class:"tech-wrap"},Ho,Bo),c("div",{class:"settings-foot"},Lo,To)),$o=c("h3"),zo=c("p",{class:"sent-body"}),Ko=c("span"),qo=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Ko),Wo=c("button",{class:"link",type:"button"}),Uo=c("div",{class:"pane sent",role:"status"},c("div",{class:"sent-head"},A(E.check),$o),zo,c("div",{class:"sent-actions"},qo,Wo)),fn=()=>c("button",{class:"back",type:"button"},A(E.left),c("span")),jo=fn(),Vo=c("p",{class:"list-status"}),Yo=c("ul",{class:"rows"}),Xo=c("p",{class:"list-note"}),Go=c("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),Jo=c("div",{class:"pane list"},jo,Vo,Yo,Xo,Go),Zo=fn(),Qo=c("p",{class:"list-status"}),ei=c("ul",{class:"rows"}),ti=c("div",{class:"pane list"},Zo,Qo,ei),ni=fn(),ri=c("p",{class:"list-note"}),oi=c("div",{class:"code"}),ii=c("span"),si=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},ii),ai=c("img",{class:"qr",alt:""}),li=c("p",{class:"hint"}),ci=c("p",{class:"list-status",role:"status"}),di=c("button",{class:"link",type:"button"}),ui=c("div",{class:"pane linking"},ni,ri,oi,c("div",{class:"link-go"},si,ai),li,ci,di),pi=c("div",{class:"coach-art"}),fi=c("p"),hi=c("p"),gi=c("button",{class:"coach-ok",type:"button"}),mi=c("div",{class:"coach",role:"status"},pi,fi,hi,gi),bi=c("p",{class:"sr-only",id:"vr-keys"}),yi=c("div",{class:"body"},yo,Fo,Uo,Jo,ti,ui),ki=c("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},p,x,Zr,yi,So,Ro,mi),hn=K("svg",{class:"ink","aria-hidden":"true"}),vi=K("defs",{}),wi=K("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});wi.append(K("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),vi.append(wi);let xi=K("g",{}),Si=K("g",{class:"draft"});hn.append(vi,xi,Si);let Ri=c("div",{class:"pins"}),gn=new Map,Ei=new Map;for(let _ of pc){let Ni=c("span");Ei.set(_,Ni),gn.set(_,c("button",{type:"button",role:"radio","aria-checked":"false","data-tool":_},A(E[_]),Ni))}let Ci=c("span",{class:"seg-ind","aria-hidden":"true"}),Ti=c("div",{class:"seg",role:"radiogroup"},Ci,...gn.values()),Ai=c("span",{class:"tb-lead"}),Mi=c("button",{type:"button",class:"tb-quiet"}),Li=c("span",{class:"tb-ask"}),Pi=c("button",{type:"button",class:"tb-discard"}),Ii=c("button",{type:"button",class:"tb-quiet"}),Oi=c("span",{class:"tb-confirm",role:"group"},Li,Pi,Ii),_i=c("div",{class:"tb",role:"toolbar"},Ai,Ti,c("span",{class:"tb-sep","aria-hidden":"true"}),Mi,Oi),mn=c("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},Ri,bi,_i);mn.prepend(hn);let bn=c("div",{class:"vr"},r,mn,ki),Di=c("style");return Di.textContent=oc,bn.prepend(Di),e.append(bn),{root:bn,fab:r,fabLabel:t,fabKbd:n,card:ki,head:p,title:o,whoBtn:a,whoAv:i,whoName:s,more:l,closeBtn:d,body:yi,foot:Ro,accountPop:x,accName:h,accMail:u,accVia:f,accLinked:g,accUnlink:k,accLink:b,accPortal:v,morePop:Zr,mReports:M,mRecents:ze,mRecord:Ke,mRecordWhy:kt,mSettings:qe,mOpen:Jr,reports:Jo,repBack:jo,repStatus:Vo,repRows:Yo,repLocal:Xo,repPortal:Go,recents:ti,recBack:Zo,recStatus:Qo,recRows:ei,linking:ui,linkBack:ni,linkLabel:ri,linkCode:oi,linkOpen:si,linkOpenText:ii,linkQr:ai,linkHint:li,linkWait:ci,linkRetry:di,describe:yo,kinds:eo,kindsLabel:Qr,kindButtons:un,prompt:to,desc:no,lines:ro,linesEmpty:oo,attached:lo,attachedText:io,disclose:ao,discloseText:so,included:co,notify:fo,notifyBox:uo,notifyText:po,error:ho,where:mo,whereText:go,send:bo,attach:ko,fileInput:vo,fileNote:wo,files:xo,tray:So,settings:Fo,bindLabel:Eo,bindBtn:Co,unbind:To,bindHint:Ao,bindReason:Mo,back:Lo,sizeLabel:Po,sizeButtons:pn,sizeInd:Io,sizeSeg:Oo,coachLabel:_o,coachSwitch:Do,techText:No,techBtn:Ho,tech:Bo,sent:Uo,sentTitle:$o,sentBody:zo,see:qo,seeText:Ko,sentClose:Wo,mark:mn,ink:hn,shapes:xi,draft:Si,pins:Ri,coach:mi,coachArtSlot:pi,coachText:fi,coachMore:hi,coachDismiss:gi,coachKeys:bi,toolbar:_i,barLead:Ai,seg:Ti,segInd:Ci,toolButtons:gn,toolLabels:Ei,cancel:Mi,ask:Oi,askText:Li,discard:Pi,keep:Ii}}class Xr{opts;hud;engine;config=null;locale;s;button;openSelector;identity;context;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool=pc[0];coachOn=Va();coachShape=null;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=Ja();size=ja();techOpen=!1;fabDrag=null;swallowClick=!1;glide=null;files=[];fileRefusal=null;pastes=0;chips=new Map;recordSwitch=null;menu=null;session=null;sessionKey="";linkSeen="";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)??Oa()}sheet=null;e;constructor(e){this.opts=e;this.locale=e.locale??sr(),this.s=ir(this.locale),this.button=e.button,this.openSelector=e.openSelector??null,this.identity=e.identity===void 0?void 0:sn(e.identity),this.context=e.context??{},this.keybind=Wl(),this.hud=Pa(),this.e=Mp(this.hud.mount),this.engine=Ol({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=_a(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=jt(document.activeElement)?null:Vr(),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&&Vr()===e)return;if(this.button)this.e.fab.focus()}setLocale(e){let t=rt(e)??sr();if(t===this.locale)return;this.locale=t,this.s=ir(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:sn(e),this.whoChanged()}setContext(e){this.context=e}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let e of this.offs.splice(0).reverse())e();_l(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let e=this.e,t=(a,l,d)=>{a.addEventListener(l,d)};t(e.fab,"click",()=>{if(this.swallowClick){this.swallowClick=!1;return}if(this.isOpen)this.close();else this.open()}),t(e.fab,"pointerdown",(a)=>this.fabDown(a)),t(e.fab,"pointermove",(a)=>this.fabMove(a)),t(e.fab,"pointerup",(a)=>this.fabUp(a,!0)),t(e.fab,"pointercancel",(a)=>this.fabUp(a,!1)),t(e.fab,"keydown",(a)=>{if(!a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;let l=el(this.dock,a.key);if(!l)return;if(a.preventDefault(),l!==this.dock)this.moveDock(l)}),t(e.attach,"click",()=>e.fileInput.click()),t(e.fileInput,"change",()=>{this.addFiles([...e.fileInput.files??[]]),e.fileInput.value=""}),t(e.card,"paste",(a)=>{let l=[...a.clipboardData?.files??[]];if(!l.length||!this.canAttach())return;let d=a.clipboardData?.getData("text/plain").trim()??"";if(d&&!l.some((p)=>p.name&&d.includes(p.name)))return;a.preventDefault(),this.addFiles(l.map((p)=>{let h=Wa(p.name,++this.pastes);return h===p.name?p:new File([p],h,{type:p.type,lastModified:p.lastModified})}))}),t(e.card,"dragover",(a)=>{if(!a.dataTransfer?.types.includes("Files")||!this.canAttach())return;a.preventDefault(),a.dataTransfer.dropEffect="copy",e.card.classList.add("dropping")}),t(e.card,"dragleave",(a)=>{if(a.relatedTarget instanceof Node&&e.card.contains(a.relatedTarget))return;e.card.classList.remove("dropping")}),t(e.card,"drop",(a)=>{e.card.classList.remove("dropping");let l=[...a.dataTransfer?.files??[]];if(!l.length||!this.canAttach())return;a.preventDefault(),this.addFiles(l)});for(let[a,l]of e.sizeButtons)t(l,"click",()=>{if(this.size=a,at(ur,a),this.paint(),this.parked)this.placeCard(!0)});let n=(a)=>{this.coachOn=a,at(pr,a?"on":"off"),this.paint()};t(e.coachDismiss,"click",()=>{if(n(!1),this.marking)e.mark.focus()}),t(e.coachSwitch,"click",()=>n(!this.coachOn)),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 r=(a)=>()=>{this.menu=null,a(),this.paint()};t(e.morePop,"keydown",(a)=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(a.key))return;let l=[...e.morePop.querySelectorAll('[role="menuitem"]')].filter((g)=>!g.hidden&&!(g instanceof HTMLButtonElement&&g.disabled));if(!l.length)return;a.preventDefault();let d=e.morePop.getRootNode(),p=l.indexOf(d.activeElement),h=l.length-1,u=a.key==="ArrowDown",f=a.key==="Home"?0:a.key==="End"?h:p<0?u?0:h:(p+(u?1:-1)+l.length)%l.length;l[f]?.focus()}),t(e.mReports,"click",r(()=>void this.openReports())),t(e.mRecents,"click",r(()=>this.show("recents")));let o=r(()=>this.recordSwitch?.());t(e.mRecord,"click",()=>{if(!this.recordWaits())o()}),t(e.mSettings,"click",r(()=>this.show("settings"))),t(e.mOpen,"click",r(()=>{return})),t(e.accPortal,"click",r(()=>{return})),t(e.accLink,"click",r(()=>this.startLinkFlow())),t(e.accUnlink,"click",()=>{Rt(),this.member=null,this.paint()});for(let a of[e.repBack,e.recBack,e.linkBack])t(a,"click",()=>this.show("describe"));t(e.linkRetry,"click",()=>this.startLinkFlow()),t(e.card,"pointerdown",(a)=>{let l=a.target;if(!this.menu||!(l instanceof Node))return;if([e.accountPop,e.morePop,e.whoBtn,e.more].some((d)=>d.contains(l)))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[a,l]of e.kindButtons)t(l,"click",()=>{this.kind=this.kind===a?null:a,this.paint()});for(let[a,l]of e.toolButtons)t(l,"click",(d)=>{if(this.tool=a,this.renderKbDraft(),this.paint(),this.placeSeg(),d.detail===0)e.mark.focus()});if(t(e.mark,"keydown",(a)=>this.markKey(a)),t(e.cancel,"click",()=>this.cancelMarking()),t(e.discard,"click",()=>{this.markers=cn(this.markers.filter((a)=>this.passKeys.has(a.key))),this.renderMarks(),this.endMarking(!0)}),t(e.keep,"click",()=>{this.confirming=!1,this.paint(),e.cancel.focus()}),t(e.mark,"pointerdown",(a)=>this.pointerDown(a)),t(e.mark,"pointermove",(a)=>this.pointerMove(a)),t(e.mark,"pointerup",(a)=>this.pointerUp(a)),t(e.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(L(e.mark,"wheel",(a)=>a.preventDefault())),this.offs.push(L(e.mark,"touchmove",(a)=>a.preventDefault())),this.offs.push(L(window,"keydown",(a)=>{let l=a.composedPath().includes(e.card);if(a.key==="Escape"&&this.isOpen&&(this.marking||l)){if(a.preventDefault(),a.stopImmediatePropagation(),this.recordingBind)this.stopRecordingBind();else if(this.marking)if(this.confirming)e.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);else if(this.menu){let d=this.menu==="account"?e.whoBtn:e.more;this.menu=null,this.paint(),d.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close();return}if(this.recordingBind)return;if(this.marking&&(a.metaKey||a.ctrlKey)&&!a.shiftKey&&!a.altKey&&a.key.toLowerCase()==="z"&&!Ap()){a.preventDefault(),this.markers=cn(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&Fl(a,this.keybind))if(a.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(L(document,"click",(a)=>{if(!Yr(a,this.openSelector))return;a.preventDefault(),this.open()})),this.offs.push(L(window,"resize",()=>{if(this.parked)this.placeCard(!0);if(this.marking)this.placeSeg()})),this.offs.push(Ul((a)=>{this.keybind=a,this.paint()})),this.offs.push(Hl(()=>this.whoChanged())),this.linkSeen=ye(this.opts.base),this.offs.push(Wt(()=>this.linkChanged())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let i=0,s=new MutationObserver((a)=>{for(let l of a){if(l.type!=="attributes"||l.attributeName!=="open"||!(l.target instanceof HTMLDialogElement))continue;let d=l.target;if(!d.open)this.dialogOrder=this.dialogOrder.filter((p)=>p!==d);else if(l.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((p)=>p!==d),d]}if(i)return;i=requestAnimationFrame(()=>{i=0,this.followDialog()})});s.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(s.disconnect(),i)cancelAnimationFrame(i)})}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.whoToken();if(!e)return this.session=null,this.sessionKey="",null;let t=ye(this.opts.base),n=$r(e,t);if(this.sessionKey===n&&ec(this.session))return this.session;this.sessionKey=n;let r=null;try{r=await Ql(this.target(),e,t)}catch(o){console.warn("vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only",o)}if(this.sessionKey!==n)return null;if(this.session=r,this.paint(),r?.memberError)this.memberRefused(r.memberError,t);return this.sessionKey===n?this.session:null}whoKey(){return $r(this.whoToken(),ye(this.opts.base))}whoChanged(){if(this.whoKey()!==this.sessionKey){if(this.session=null,this.sessionKey="",this.mine={rows:[],state:"ok"},this.isOpen)this.view==="reports"?this.loadReports():this.refreshWho()}this.paint()}linkChanged(){let e=ye(this.opts.base);if(e===this.linkSeen)return;if(this.linkSeen=e,this.member=null,e&&this.isOpen)this.refreshMember();this.whoChanged()}memberRefused(e,t){let n=ma(e);if(console.warn(`vitrinka: vitrinka did not take this browser’s member link (${e}) — ${n?"it is forgotten; link the account again":"it stays linked, and the reporter alone owns what goes with it"}`),n&&t&&ce()?.token===t)$a()}async refreshMember(){let e=He(this.opts.base)?ce():null;if(!e){if(this.member)this.member=null,this.paint();return}let t,n;try{let r=await J("GET","/api/v1/recorder/me",void 0,{target:{url:this.opts.base,key:e.token}});t={email:r.user?.email??"",name:r.user?.name??"",workspace:r.workspace?.slug??e.workspace},n=r.displayMode}catch(r){console.warn("vitrinka: the linked vitrinka account could not be read",r),t={email:"",name:"",workspace:e.workspace}}if(ye(this.opts.base)!==e.token)return;this.member=t,ya(n),this.paint()}async openReports(){this.show("reports"),await this.loadReports()}async loadReports(){let e=this.whoKey(),t=await this.refreshWho();if(this.whoKey()!==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.whoKey()!==e)return;this.mine=n,this.paint()}async listMineRenewing(e){try{return(await zr(this.target(),e.session)).reports}catch(t){if(!(t instanceof T)||t.status!==401)throw t;this.session=null,this.sessionKey="";let n=await this.refreshWho();if(!n)throw t;return(await zr(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=xt(t);(async()=>{try{e.start=await Vi(t,{label:Rn(),workspace:n}),e.state="waiting",this.paint();let r=await Yi(t,e.start.device_code,{interval:e.start.interval,expiresIn:e.start.expires_in,workspace:n,signal:e.abort.signal});Sn({...r,base:t}),this.linkFlow=null,this.show("describe")}catch(r){if(e.abort.signal.aborted)return;if(e.state=r instanceof We?"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:Nl()}whoToken(){let e=this.who();return e&&"token"in e?e.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=L(window,"keydown",(e)=>{e.preventDefault(),e.stopPropagation();let t=Bl(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??ae}addFiles(e){if(!e.length)return;let{files:t,refusal:n}=Ka(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"},A(E.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,it(e.cap,this.locale));if(e.kind==="count")return t.tooManyFiles(e.cap);return t.fileType(e.name,qa(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)<Ga)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?Qa({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,Za(e),this.paint(),n.hidden||dc())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((t)=>t.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(!0),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=Wr*st[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):jr}}frame(){let e=globalThis.innerWidth||800,t=globalThis.innerHeight||600,n=st[this.size],r=this.parkInsets??{top:Wr*n,bottom:jr,edge:jr},o=this.e.card.getBoundingClientRect();return{vw:e,vh:t,w:o.width||Math.min(ac.w*n,e-32),h:o.height||Math.min(ac.h*n,t-r.top-r.bottom),...r}}placeCard(e=!1){if(!this.parked)return;let t=this.frame(),n=this.parked;this.parked=Vl(this.parked,this.markers.map((s)=>s.rect),t);let r=Or(this.parked,t),o=this.e.card,i=e&&this.parked===n;if(i)o.style.transition="none";if(o.classList.add("parked"),o.style.left=`${r.x}px`,o.style.top=`${r.y}px`,this.placeCoachSide(),!i)return;o.offsetWidth,o.style.removeProperty("transition")}placeCoachSide(){let e=st[this.size],t=this.e.coach;t.dataset.side="above";let n=t.offsetHeight||Ur.h;t.dataset.side=Yl(this.parked??this.dock,this.frame(),{w:Ur.w*e,h:n*e},Ur.gap*e)}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(e=!1){uc(this.e.seg,this.e.segInd,this.e.toolButtons.get(this.tool),e)}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){let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:t.shape,rect:Sr(t.start,{x:e.clientX,y:e.clientY}),head:Rr(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(),!wl(t.shape,t.start,n))return;this.addMarker(t.shape,Sr(t.start,n),t.shape==="arrow"?Rr(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=cn([...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-qr.w/2),y:Math.round(n/2-qr.h/2),...qr},this.renderKbDraft();return}let a=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,a,this.tool==="arrow"?"se":void 0);return}let r=Sp[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(sc,o.w+i)),h:Math.min(n-o.y,Math.max(sc,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"}))}shapeNodes(e){let{x:t,y:n,w:r,h:o}=e.rect;if(e.shape==="circle")return[K("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[K("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[K("line",{class:"stroke",x1:a.x,y1:a.y,x2:l.x,y2:l.y,"marker-end":"url(#vr-head)"})]}let i=K("rect",{class:"veil",x:t,y:n,width:r,height:o,rx:4}),s=K("text",{class:"veil-label",x:t+r/2,y:n+o/2+4,"text-anchor":"middle"});return s.textContent=r>150&&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=cn(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"},A(E.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"},A(E.close)),d=c("li",{class:"ln"},s,a,l);a.addEventListener("input",()=>{this.markers=this.markers.map((p)=>p.key===n.key?{...p,note:a.value}:p),this.paint()}),a.addEventListener("keydown",(p)=>{if(p.key!=="Enter"||!this.marking)return;p.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(Wr-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=ye(this.opts.base),o=Dr({url:this.opts.base,key:this.opts.key}),i=globalThis.location;return{title:cc(e),description:e,env:{url:B(i?`${i.origin}${i.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:Sl(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{},...o?{round:o.token}:{},...r?{memberToken:r}:{},...$i(this.context)}}words(){return this.e.desc.value.trim()||(this.markers.find((e)=>e.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 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 i of this.markers)for(let s of this.hideIds.get(i.key)??[])t.add(s);let n=this.engine,r=this.frozen??{clip:null,stored:Promise.resolve(new Map)},o=n?await Zl(()=>n.build(r,this.markers,t)):Br;this.job=new Fr(o,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),(t,n)=>this.memberRefused(t,n)),rc(this.opts.base,globalThis.location?.host??"",{title:cc(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?Tp(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),W(e.accLink,t.linkVitrinka);let s=this.session?.portalUrl;if(e.accPortal.hidden=!s,s)e.accPortal.setAttribute("href",s);W(e.accPortal,t.openPortal),W(e.mReports,t.myReports),W(e.mRecents,t.recentRecordings),W(e.mRecord,t.record),W(e.mSettings,t.settings),e.mRecents.hidden=!this.recordSwitch,e.mRecord.hidden=!this.recordSwitch;let a=this.recordWaits();if(a)e.mRecord.setAttribute("aria-disabled","true");else e.mRecord.removeAttribute("aria-disabled");if(e.mRecordWhy.hidden=!a,e.mRecordWhy.textContent=t.recordHasDraft,a)e.mRecord.setAttribute("aria-describedby",e.mRecordWhy.id);else e.mRecord.removeAttribute("aria-describedby");let l=i?this.opts.base:s;if(e.mOpen.hidden=!l,l)e.mOpen.setAttribute("href",l);W(e.mOpen,i?t.openVitrinka:t.openPortal)}paintReports(){let{e,s:t}=this;W(e.repBack,t.myReports);let n=!this.session,r=n?Kr(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;W(e.recBack,t.recentRecordings);let n=ar().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;W(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=it(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,e.coachLabel.textContent=t.coachSetting,e.coachSwitch.setAttribute("aria-checked",String(this.coachOn));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=Ya({version:pa,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")uc(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(st[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",`${this.keybind?`${zl(this.keybind)} `:""}Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight`),e.fabKbd.hidden=!this.keybind,e.fabKbd.textContent=this.keybind?an(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?an(this.keybind):t.notSet} — ${t.recordShortcut}`),e.bindBtn.textContent=this.recordingBind?t.pressKeys:this.keybind?an(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=this.tool==="hide"?t.barLeadHide: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.coachOn,e.coach.hidden)this.coachShape=null;else if(this.coachShape!==this.tool)this.coachShape=this.tool,e.coachArtSlot.replaceChildren(A(Cp(this.tool,dc()))),this.placeCoachSide();if(e.coachText.textContent=t.coach[this.tool],e.coachMore.textContent=t.coachMore,e.coachDismiss.textContent=t.coachDismiss,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 cn(e){return xl(e).map((t,n)=>({...t,key:e[n].key}))}var dn="vitrinka-report",Lp=["key","base","open-selector","locale","button"];function hc(e){return e.trim().replace(/\/+$/,"")}function Gr(e){if(typeof customElements>"u"||customElements.get(dn))return;class t extends HTMLElement{static get observedAttributes(){return Lp}options={};at=null;shown=null;widget=null;pill=null;gen=0;recordOffered=!1;offPillOpener=null;warnedRecording=!1;offLink=null;pendingIdentity=void 0;context={};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(){if(this.shown==="recorder")this.openFromPill();else this.widget?.open()}close(){this.widget?.close()}identify(n){this.pendingIdentity=n,this.widget?.identify(n)}setContext(n){this.context=Fi(n),this.widget?.setContext(this.context)}setLocale(n){this.setAttribute("locale",String(n))}mount(){if(this.at)return;let n=(this.getAttribute("key")??"").trim(),r=hc(this.getAttribute("base")??e.defaultBase());if(!n||!r){console.warn(`vitrinka: <${dn}> needs a key${r?"":" and a base"} — nothing mounted`);return}if(this.at={key:n,base:r},e.recorderFace)this.offLink=Wt(()=>this.offerRecord());this.show(e.recorderFace?ka(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.offPillOpener?.(),this.offPillOpener=null,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",this.offPillOpener=L(document,"click",(s)=>{if(!Yr(s,this.getAttribute("open-selector")))return;s.preventDefault(),this.open()});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 Xr({base:r.base,key:r.key,locale:rt(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,context:this.context,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&&He(this.at.base);if(n===this.recordOffered)return;this.recordOffered=n,this.widget.setRecordSwitch(n?()=>this.switchTo("recorder"):null)}openFromPill(){if(this.keepsPill())return;let n=this.at;setTimeout(()=>{if(!n||this.at!==n)return;if(this.shown==="recorder"){if(this.keepsPill())return;or("report"),this.show("report")}this.widget?.open()},0)}keepsPill(){if(!va())return!1;if(!this.warnedRecording)console.warn("vitrinka: Report a problem stays closed while the recorder pill records — leaving would strand the session; stop the recording first");return this.warnedRecording=!0,!0}switchTo(n){or(n);let r=this.gen;setTimeout(()=>{if(r===this.gen&&this.shown!==n)this.show(n)},0)}}customElements.define(dn,t)}function gc(e,t){if(e.face==="recorder")return Pp(e,t);Gr(t);let n=document.createElement(dn);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);if(e.context!==void 0)n.setContext(e.context);return(e.parent??document.body).append(n),{get face(){return n.face},open:()=>n.open(),close:()=>n.close(),identify:(r)=>n.identify(r),setContext:(r)=>n.setContext(r),setLocale:(r)=>n.setLocale(r),unmount:()=>n.remove()}}function Pp(e,t){let n=hc(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,setContext:i,setLocale:i,unmount:()=>{o=!0,r?.()}}}var Ip=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function Op(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 mc={loadRecord:Op,recorderFace:null,defaultBase:()=>Ip};Gr(mc);function Qg(e){return gc(e,mc)}export{dp as identify,Qg as mountReport};
483
+ /* The edge drop stays the still bead: no swell, stretch or wobble, and it moves without gliding. */
484
+ .vr[data-launcher="edge"] .fab, .vr[data-launcher="edge"] .fab::before, .vr[data-launcher="edge"] .fab::after,
485
+ .vr[data-launcher="edge"] .fab-label { transition: none; }
486
+ .vr[data-launcher="edge"] .fab:hover, .vr[data-launcher="edge"] .fab:focus-visible, .vr[data-launcher="edge"] .fab.dragging { transform: none; }
487
+ .vr[data-launcher="edge"] .fab:hover::before, .vr[data-launcher="edge"] .fab:hover::after,
488
+ .vr[data-launcher="edge"] .fab:focus-visible::before, .vr[data-launcher="edge"] .fab:focus-visible::after { transform: none; }
489
+ .vr[data-launcher="edge"] .fab.settle { animation: none; }
490
+ }
491
+ `;var zp="http://www.w3.org/2000/svg",Sc=100,Ac=["box","circle","arrow","hide"],Yr={w:160,h:80},Rc=16,Xr={w:380,h:460},Gr=72,Jr={h:48,w:44,gap:12},Zr={w:300,h:160,gap:10},Qr=16,Fp={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},R={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>',report:'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12a8.5 8.5 0 0 1-12.6 7.4L3 21l1.6-5.4A8.5 8.5 0 1 1 21 12Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M12 8v4.2M12 15.6h.01" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="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>'},Mc="0;0.18;0.72;1",yt="2.8s",Ec="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14",$p='<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"/>';function Kp(e,t,n){return`<animate attributeName="${e}" values="${t};${t};${n};${n}" keyTimes="${Mc}" calcMode="linear" dur="${yt}" repeatCount="indefinite"/>`}function jp(e,t){let n=(p,h)=>t?h:p,r=(p,h,u)=>t?"":Kp(p,h,u),o=t?"":`<animate attributeName="opacity" values="1;1;0" keyTimes="0;0.9;1" dur="${yt}" repeatCount="indefinite"/>`,i=t?"":`<animate attributeName="opacity" values="0;0;.9;.9;0;0" keyTimes="0;0.08;0.14;0.72;0.8;1" dur="${yt}" repeatCount="indefinite"/>`,s,a,l;if(e==="circle")a=Ec,l={x:134,y:14},s=`<rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${Ec}" pathLength="200" stroke-dasharray="200" stroke-dashoffset="${n(200,0)}">${r("stroke-dashoffset",200,0)}${o}</path>`;else if(e==="arrow"){a="M 74 54 L 128 33",l={x:128,y:33};let p=t?"":`<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.18;0.19;0.9;1" dur="${yt}" repeatCount="indefinite"/>`;s=`<defs><marker id="vr-coach-head" viewBox="0 0 10 10" refX="7" refY="5" markerWidth="5" markerHeight="5" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="#e6455f"/></marker></defs><rect class="bar" x="136" y="27" width="70" height="10" rx="5"/><line class="loop" x1="74" y1="54" x2="${n(74,128)}" y2="${n(54,33)}" marker-end="url(#vr-coach-head)"${t?"":' opacity="0"'}>${r("x2",74,128)}${r("y2",54,33)}${p}</line>`}else{let p=e==="hide";a=p?"M 90 10 L 178 54":"M 96 12 L 172 52",l=p?{x:178,y:54}:{x:172,y:52};let h=p?90:96,u=p?10:12,f=l.x-h,g=l.y-u;s=(p?'<rect class="bar" x="102" y="20" width="64" height="8" rx="4"/><rect class="bar" x="102" y="35" width="44" height="8" rx="4"/>':'<rect class="bar" x="110" y="27" width="48" height="10" rx="5"/>')+`<rect class="${p?"veil":"loop"}" x="${h}" y="${u}" width="${n(0,f)}" height="${n(0,g)}" rx="${p?4:6}">${r("width",0,f)}${r("height",0,g)}${o}</rect>`}let d=t?"":`<animateMotion dur="${yt}" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="${Mc}" calcMode="linear" path="${a}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true" data-shape="${e}">${s}<g class="pointer"${t?` transform="translate(${l.x} ${l.y})"`:""}><circle class="hold" r="9"${t?' opacity=".9"':' opacity="0"'}>${i}</circle>${$p}${d}</g></svg>`}function c(e,t={},...n){let r=document.createElement(e);for(let[o,i]of Object.entries(t))r.setAttribute(o,i);return r.append(...n),r}function T(e){let t=document.createElement("template");t.innerHTML=e;let n=t.content.firstElementChild;if(!n)throw Error("vitrinka: icon markup is empty");return n}function j(e,t){let n=document.createElementNS(zp,e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Cc(e){let t=e.split(`
492
+ `)[0]?.trim()??"";return t.length>Sc?`${t.slice(0,Sc-1)}…`:t}function eo(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function to(){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 qp(e){return(e.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((n)=>n[0]?.toUpperCase()??"").join("")||"?"}function W(e,t){let n=e.querySelector("span");if(n)n.textContent=t}function Tc(e,t,n,r=!1){if(!n||!n.offsetWidth)return;let o=r||!e.classList.contains("measured");if(o)t.style.transition="none";if(t.style.width=`${n.offsetWidth}px`,t.style.transform=`translateX(${n.offsetLeft}px)`,e.classList.add("measured"),!o)return;t.offsetWidth,t.style.removeProperty("transition")}function Wp(){let e=to();return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function no(e,t){let n=e.target;if(!t||!(n instanceof Element))return!1;try{return n.closest(t)!==null}catch{return!1}}function Up(e){let t=c("span",{class:"fab-label"}),n=c("kbd",{"aria-hidden":"true"}),r=c("span",{class:"fab-glyph","aria-hidden":"true"},T(R.report)),o=c("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},r,t,n),i=c("h2",{id:"vr-title"}),s=c("span",{class:"av","aria-hidden":"true"}),a=c("span",{class:"who-name"}),l=c("button",{class:"who",type:"button","aria-haspopup":"dialog","aria-expanded":"false"},s,a),d=c("button",{class:"icon",type:"button","aria-haspopup":"menu","aria-expanded":"false"},T(R.dots)),p=c("button",{class:"icon",type:"button"},T(R.close)),h=c("header",{class:"head"},i,l,d,p),u=c("strong"),f=c("span",{class:"acc-mail"}),g=c("p",{class:"acc-via"}),v=c("p",{class:"acc-linked"}),b=c("button",{class:"link",type:"button"}),y=c("button",{class:"pop-item",type:"button"},T(R.link),c("span")),x=c("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},T(R.ext),c("span")),m=c("div",{class:"pop acc",role:"dialog"},c("div",{class:"acc-who"},u,f,g),c("div",{class:"acc-member"},v,b),y,x),M=(_)=>c("button",{class:"pop-item",type:"button",role:"menuitem"},T(_),c("span")),qe=M(R.list),wt=M(R.clock),We=M(R.rec),Ue=c("small",{class:"pop-why",id:"vr-record-why","aria-hidden":"true"});We.append(Ue);let io=M(R.gear),so=c("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},T(R.ext),c("span")),ao=c("div",{class:"pop more",role:"menu"},qe,wt,We,io,so),lo=c("span",{class:"sr",id:"vr-kinds"}),pn=new Map;for(let _ of Va)pn.set(_,c("button",{type:"button",role:"radio","aria-checked":"false","data-kind":_}));let co=c("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},lo,...pn.values()),uo=c("label",{class:"prompt",for:"vr-desc"}),po=c("textarea",{class:"desc",id:"vr-desc",rows:"3"}),fo=c("ol",{class:"lines"}),ho=c("p",{class:"ln-empty"}),go=c("span"),mo=c("span"),bo=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},mo,T(R.chevron)),ko=c("div",{class:"attached"},T(R.clip),go,c("span",{"aria-hidden":"true"},"·"),bo),vo=c("ul",{class:"included",id:"vr-included"}),yo=c("input",{type:"checkbox"}),wo=c("span"),xo=c("label",{class:"notify"},yo,wo),So=c("p",{class:"error",role:"alert"}),Ro=c("span"),Eo=c("button",{class:"where",type:"button","aria-pressed":"false"},T(R.pen),Ro),Co=c("button",{class:"send",type:"button"}),To=c("div",{class:"pane describe"},co,uo,po,c("div",{class:"lines-wrap"},fo,ho),ko,vo,xo,So),Ao=c("button",{class:"icon",type:"button"},T(R.clip)),Mo=c("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),Lo=c("p",{class:"file-note",role:"status"}),Po=c("ul",{class:"files"}),Io=c("div",{class:"tray"},Lo,Po),Oo=c("div",{class:"foot"},Ao,Mo,Eo,Co),_o=c("span",{class:"label",id:"vr-bind-label"}),Do=c("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),No=c("button",{class:"link",type:"button"}),Ho=c("p",{class:"hint"}),Bo=c("p",{class:"reason",role:"status"}),zo=c("button",{class:"link",type:"button"}),Fo=c("span",{class:"label",id:"vr-size-label"}),fn=new Map;for(let _ of vn)fn.set(_,c("button",{type:"button",role:"radio","aria-checked":"false","data-size":_}));let $o=c("span",{class:"seg-ind","aria-hidden":"true"}),Ko=c("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},$o,...fn.values()),jo=c("span",{class:"label",id:"vr-coach-label"}),qo=c("button",{class:"switch",type:"button",role:"switch","aria-checked":"true","aria-labelledby":"vr-coach-label"},c("span",{class:"knob","aria-hidden":"true"})),Wo=c("span"),Uo=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},Wo,T(R.chevron)),Vo=c("dl",{class:"tech",id:"vr-tech"}),Yo=c("div",{class:"pane settings"},c("div",{class:"row"},_o,Do),Bo,Ho,c("div",{class:"row size-row"},Fo,Ko),c("div",{class:"row tips-row"},jo,qo),c("div",{class:"tech-wrap"},Uo,Vo),c("div",{class:"settings-foot"},zo,No)),Xo=c("h3"),Go=c("p",{class:"sent-body"}),Jo=c("span"),Zo=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Jo),Qo=c("button",{class:"link",type:"button"}),ei=c("div",{class:"pane sent",role:"status"},c("div",{class:"sent-head"},T(R.check),Xo),Go,c("div",{class:"sent-actions"},Zo,Qo)),hn=()=>c("button",{class:"back",type:"button"},T(R.left),c("span")),ti=hn(),ni=c("p",{class:"list-status"}),ri=c("ul",{class:"rows"}),oi=c("p",{class:"list-note"}),ii=c("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),si=c("div",{class:"pane list"},ti,ni,ri,oi,ii),ai=hn(),li=c("p",{class:"list-status"}),ci=c("ul",{class:"rows"}),di=c("div",{class:"pane list"},ai,li,ci),ui=hn(),pi=c("p",{class:"list-note"}),fi=c("div",{class:"code"}),hi=c("span"),gi=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},hi),mi=c("img",{class:"qr",alt:""}),bi=c("p",{class:"hint"}),ki=c("p",{class:"list-status",role:"status"}),vi=c("button",{class:"link",type:"button"}),yi=c("div",{class:"pane linking"},ui,pi,fi,c("div",{class:"link-go"},gi,mi),bi,ki,vi),wi=c("div",{class:"coach-art"}),xi=c("p"),Si=c("p"),Ri=c("button",{class:"coach-ok",type:"button"}),Ei=c("div",{class:"coach",role:"status"},wi,xi,Si,Ri),Ci=c("p",{class:"sr-only",id:"vr-keys"}),Ti=c("div",{class:"body"},To,Yo,ei,si,di,yi),Ai=c("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},h,m,ao,Ti,Io,Oo,Ei),gn=j("svg",{class:"ink","aria-hidden":"true"}),Mi=j("defs",{}),Li=j("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});Li.append(j("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),Mi.append(Li);let Pi=j("g",{}),Ii=j("g",{class:"draft"});gn.append(Mi,Pi,Ii);let Oi=c("div",{class:"pins"}),mn=new Map,_i=new Map;for(let _ of Ac){let Wi=c("span");_i.set(_,Wi),mn.set(_,c("button",{type:"button",role:"radio","aria-checked":"false","data-tool":_},T(R[_]),Wi))}let Di=c("span",{class:"seg-ind","aria-hidden":"true"}),Ni=c("div",{class:"seg",role:"radiogroup"},Di,...mn.values()),Hi=c("span",{class:"tb-lead"}),Bi=c("button",{type:"button",class:"tb-quiet"}),zi=c("span",{class:"tb-ask"}),Fi=c("button",{type:"button",class:"tb-discard"}),$i=c("button",{type:"button",class:"tb-quiet"}),Ki=c("span",{class:"tb-confirm",role:"group"},zi,Fi,$i),ji=c("div",{class:"tb",role:"toolbar"},Hi,Ni,c("span",{class:"tb-sep","aria-hidden":"true"}),Bi,Ki),bn=c("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},Oi,Ci,ji);bn.prepend(gn);let kn=c("div",{class:"vr"},o,bn,Ai),qi=c("style");return qi.textContent=xc,kn.prepend(qi),e.append(kn),{root:kn,fab:o,fabGlyph:r,fabLabel:t,fabKbd:n,card:Ai,head:h,title:i,whoBtn:l,whoAv:s,whoName:a,more:d,closeBtn:p,body:Ti,foot:Oo,accountPop:m,accName:u,accMail:f,accVia:g,accLinked:v,accUnlink:b,accLink:y,accPortal:x,morePop:ao,mReports:qe,mRecents:wt,mRecord:We,mRecordWhy:Ue,mSettings:io,mOpen:so,reports:si,repBack:ti,repStatus:ni,repRows:ri,repLocal:oi,repPortal:ii,recents:di,recBack:ai,recStatus:li,recRows:ci,linking:yi,linkBack:ui,linkLabel:pi,linkCode:fi,linkOpen:gi,linkOpenText:hi,linkQr:mi,linkHint:bi,linkWait:ki,linkRetry:vi,describe:To,kinds:co,kindsLabel:lo,kindButtons:pn,prompt:uo,desc:po,lines:fo,linesEmpty:ho,attached:ko,attachedText:go,disclose:bo,discloseText:mo,included:vo,notify:xo,notifyBox:yo,notifyText:wo,error:So,where:Eo,whereText:Ro,send:Co,attach:Ao,fileInput:Mo,fileNote:Lo,files:Po,tray:Io,settings:Yo,bindLabel:_o,bindBtn:Do,unbind:No,bindHint:Ho,bindReason:Bo,back:zo,sizeLabel:Fo,sizeButtons:fn,sizeInd:$o,sizeSeg:Ko,coachLabel:jo,coachSwitch:qo,techText:Wo,techBtn:Uo,tech:Vo,sent:ei,sentTitle:Xo,sentBody:Go,see:Zo,seeText:Jo,sentClose:Qo,mark:bn,ink:gn,shapes:Pi,draft:Ii,pins:Oi,coach:Ei,coachArtSlot:wi,coachText:xi,coachMore:Si,coachDismiss:Ri,coachKeys:Ci,toolbar:ji,barLead:Hi,seg:Ni,segInd:Di,toolButtons:mn,toolLabels:_i,cancel:Bi,ask:Ki,askText:zi,discard:Fi,keep:$i}}class ro{opts;hud;engine;config=null;locale;s;button;openSelector;identity;context;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool=Ac[0];coachOn=ns();coachShape=null;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=gl();launcher;edge=ls();insets;size=ts();techOpen=!1;fabDrag=null;swallowClick=!1;glide=null;files=[];fileRefusal=null;pastes=0;chips=new Map;recordSwitch=null;menu=null;session=null;sessionKey="";linkSeen="";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)??il()}sheet=null;e;constructor(e){this.opts=e;this.locale=e.locale??hr(),this.s=fr(this.locale),this.button=e.button,this.launcher=e.launcher??"edge",this.insets=as(e.edgeInsets),this.openSelector=e.openSelector??null,this.identity=e.identity===void 0?void 0:an(e.identity),this.context=e.context??{},this.keybind=lc(),this.hud=rl(),this.e=Up(this.hud.mount),this.engine=Jl({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=sl(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=Yt(document.activeElement)?null:to(),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&&to()===e)return;if(this.button)this.e.fab.focus()}setLocale(e){let t=lt(e)??hr();if(t===this.locale)return;this.locale=t,this.s=fr(t),this.paint()}setButton(e){this.button=e,this.paint()}setLauncher(e){if(e===this.launcher)return;this.launcher=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:an(e),this.whoChanged()}setContext(e){this.context=e}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let e of this.offs.splice(0).reverse())e();Zl(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let e=this.e,t=(a,l,d)=>{a.addEventListener(l,d)};t(e.fab,"click",()=>{if(this.swallowClick){this.swallowClick=!1;return}if(this.isOpen)this.close();else this.open()}),t(e.fab,"pointerdown",(a)=>this.fabDown(a)),t(e.fab,"pointermove",(a)=>this.fabMove(a)),t(e.fab,"pointerup",(a)=>this.fabUp(a,!0)),t(e.fab,"pointercancel",(a)=>this.fabUp(a,!1)),t(e.fab,"keydown",(a)=>{if(!a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;if(this.launcher==="edge"){let d=ds(this.edge,a.key);if(d===null)return;if(a.preventDefault(),d!==this.edge)this.moveEdge(d);return}let l=kl(this.dock,a.key);if(!l)return;if(a.preventDefault(),l!==this.dock)this.moveDock(l)}),t(e.attach,"click",()=>e.fileInput.click()),t(e.fileInput,"change",()=>{this.addFiles([...e.fileInput.files??[]]),e.fileInput.value=""}),t(e.card,"paste",(a)=>{let l=[...a.clipboardData?.files??[]];if(!l.length||!this.canAttach())return;let d=a.clipboardData?.getData("text/plain").trim()??"";if(d&&!l.some((p)=>p.name&&d.includes(p.name)))return;a.preventDefault(),this.addFiles(l.map((p)=>{let h=Qi(p.name,++this.pastes);return h===p.name?p:new File([p],h,{type:p.type,lastModified:p.lastModified})}))}),t(e.card,"dragover",(a)=>{if(!a.dataTransfer?.types.includes("Files")||!this.canAttach())return;a.preventDefault(),a.dataTransfer.dropEffect="copy",e.card.classList.add("dropping")}),t(e.card,"dragleave",(a)=>{if(a.relatedTarget instanceof Node&&e.card.contains(a.relatedTarget))return;e.card.classList.remove("dropping")}),t(e.card,"drop",(a)=>{e.card.classList.remove("dropping");let l=[...a.dataTransfer?.files??[]];if(!l.length||!this.canAttach())return;a.preventDefault(),this.addFiles(l)});for(let[a,l]of e.sizeButtons)t(l,"click",()=>{if(this.size=a,de(yn,a),this.paint(),this.parked)this.placeCard(!0)});let n=(a)=>{this.coachOn=a,de(wn,a?"on":"off"),this.paint()};t(e.coachDismiss,"click",()=>{if(n(!1),this.marking)e.mark.focus()}),t(e.coachSwitch,"click",()=>n(!this.coachOn)),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 r=(a)=>()=>{this.menu=null,a(),this.paint()};t(e.morePop,"keydown",(a)=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(a.key))return;let l=[...e.morePop.querySelectorAll('[role="menuitem"]')].filter((g)=>!g.hidden&&!(g instanceof HTMLButtonElement&&g.disabled));if(!l.length)return;a.preventDefault();let d=e.morePop.getRootNode(),p=l.indexOf(d.activeElement),h=l.length-1,u=a.key==="ArrowDown",f=a.key==="Home"?0:a.key==="End"?h:p<0?u?0:h:(p+(u?1:-1)+l.length)%l.length;l[f]?.focus()}),t(e.mReports,"click",r(()=>void this.openReports())),t(e.mRecents,"click",r(()=>this.show("recents")));let o=r(()=>this.recordSwitch?.());t(e.mRecord,"click",()=>{if(!this.recordWaits())o()}),t(e.mSettings,"click",r(()=>this.show("settings"))),t(e.mOpen,"click",r(()=>{return})),t(e.accPortal,"click",r(()=>{return})),t(e.accLink,"click",r(()=>this.startLinkFlow())),t(e.accUnlink,"click",()=>{Ct(),this.member=null,this.paint()});for(let a of[e.repBack,e.recBack,e.linkBack])t(a,"click",()=>this.show("describe"));t(e.linkRetry,"click",()=>this.startLinkFlow()),t(e.card,"pointerdown",(a)=>{let l=a.target;if(!this.menu||!(l instanceof Node))return;if([e.accountPop,e.morePop,e.whoBtn,e.more].some((d)=>d.contains(l)))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,Hr(null),this.paint()});for(let[a,l]of e.kindButtons)t(l,"click",()=>{this.kind=this.kind===a?null:a,this.paint()});for(let[a,l]of e.toolButtons)t(l,"click",(d)=>{if(this.tool=a,this.renderKbDraft(),this.paint(),this.placeSeg(),d.detail===0)e.mark.focus()});if(t(e.mark,"keydown",(a)=>this.markKey(a)),t(e.cancel,"click",()=>this.cancelMarking()),t(e.discard,"click",()=>{this.markers=dn(this.markers.filter((a)=>this.passKeys.has(a.key))),this.renderMarks(),this.endMarking(!0)}),t(e.keep,"click",()=>{this.confirming=!1,this.paint(),e.cancel.focus()}),t(e.mark,"pointerdown",(a)=>this.pointerDown(a)),t(e.mark,"pointermove",(a)=>this.pointerMove(a)),t(e.mark,"pointerup",(a)=>this.pointerUp(a)),t(e.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(L(e.mark,"wheel",(a)=>a.preventDefault())),this.offs.push(L(e.mark,"touchmove",(a)=>a.preventDefault())),this.offs.push(L(window,"keydown",(a)=>{let l=a.composedPath().includes(e.card);if(a.key==="Escape"&&this.isOpen&&(this.marking||l)){if(a.preventDefault(),a.stopImmediatePropagation(),this.recordingBind)this.stopRecordingBind();else if(this.marking)if(this.confirming)e.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);else if(this.menu){let d=this.menu==="account"?e.whoBtn:e.more;this.menu=null,this.paint(),d.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close();return}if(this.recordingBind)return;if(this.marking&&(a.metaKey||a.ctrlKey)&&!a.shiftKey&&!a.altKey&&a.key.toLowerCase()==="z"&&!Wp()){a.preventDefault(),this.markers=dn(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&rc(a,this.keybind))if(a.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(L(document,"click",(a)=>{if(!no(a,this.openSelector))return;a.preventDefault(),this.open()})),this.offs.push(L(window,"resize",()=>{if(this.launcher==="edge")this.placeEdge();if(this.parked)this.placeCard(!0);if(this.marking)this.placeSeg()})),this.offs.push(cc((a)=>{this.keybind=a,this.paint()})),this.offs.push(tc(()=>this.whoChanged())),this.linkSeen=we(this.opts.base),this.offs.push(Ut(()=>this.linkChanged())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let i=0,s=new MutationObserver((a)=>{for(let l of a){if(l.type!=="attributes"||l.attributeName!=="open"||!(l.target instanceof HTMLDialogElement))continue;let d=l.target;if(!d.open)this.dialogOrder=this.dialogOrder.filter((p)=>p!==d);else if(l.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((p)=>p!==d),d]}if(i)return;i=requestAnimationFrame(()=>{i=0,this.followDialog()})});s.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(s.disconnect(),i)cancelAnimationFrame(i)})}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.whoToken();if(!e)return this.session=null,this.sessionKey="",null;let t=we(this.opts.base),n=Wr(e,t);if(this.sessionKey===n&&kc(this.session))return this.session;this.sessionKey=n;let r=null;try{r=await bc(this.target(),e,t)}catch(o){console.warn("vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only",o)}if(this.sessionKey!==n)return null;if(this.session=r,this.paint(),r?.memberError)this.memberRefused(r.memberError,t);return this.sessionKey===n?this.session:null}whoKey(){return Wr(this.whoToken(),we(this.opts.base))}whoChanged(){if(this.whoKey()!==this.sessionKey){if(this.session=null,this.sessionKey="",this.mine={rows:[],state:"ok"},this.isOpen)this.view==="reports"?this.loadReports():this.refreshWho()}this.paint()}linkChanged(){let e=we(this.opts.base);if(e===this.linkSeen)return;if(this.linkSeen=e,this.member=null,e&&this.isOpen)this.refreshMember();this.whoChanged()}memberRefused(e,t){let n=Ka(e);if(console.warn(`vitrinka: vitrinka did not take this browser’s member link (${e}) — ${n?"it is forgotten; link the account again":"it stays linked, and the reporter alone owns what goes with it"}`),n&&t&&pe()?.token===t)pl()}async refreshMember(){let e=$e(this.opts.base)?pe():null;if(!e){if(this.member)this.member=null,this.paint();return}let t,n;try{let r=await ee("GET","/api/v1/recorder/me",void 0,{target:{url:this.opts.base,key:e.token}});t={email:r.user?.email??"",name:r.user?.name??"",workspace:r.workspace?.slug??e.workspace},n=r.displayMode}catch(r){console.warn("vitrinka: the linked vitrinka account could not be read",r),t={email:"",name:"",workspace:e.workspace}}if(we(this.opts.base)!==e.token)return;this.member=t,qa(n),this.paint()}async openReports(){this.show("reports"),await this.loadReports()}async loadReports(){let e=this.whoKey(),t=await this.refreshWho();if(this.whoKey()!==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.whoKey()!==e)return;this.mine=n,this.paint()}async listMineRenewing(e){try{return(await Ur(this.target(),e.session)).reports}catch(t){if(!(t instanceof A)||t.status!==401)throw t;this.session=null,this.sessionKey="";let n=await this.refreshWho();if(!n)throw t;return(await Ur(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=Rt(t);(async()=>{try{e.start=await vs(t,{label:In(),workspace:n}),e.state="waiting",this.paint();let r=await ys(t,e.start.device_code,{interval:e.start.interval,expiresIn:e.start.expires_in,workspace:n,signal:e.abort.signal});Pn({...r,base:t}),this.linkFlow=null,this.show("describe")}catch(r){if(e.abort.signal.aborted)return;if(e.state=r instanceof Xe?"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:ec()}whoToken(){let e=this.who();return e&&"token"in e?e.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=L(window,"keydown",(e)=>{e.preventDefault(),e.stopPropagation();let t=nc(e);if(t.kind==="wait")return;if(t.kind==="bare"){this.bindRefused=!0,this.paint();return}if(t.kind==="bind")this.keybind=t.bind,Hr(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??Z}addFiles(e){if(!e.length)return;let{files:t,refusal:n}=Ji(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"},T(R.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,Ve(e.cap,this.locale));if(e.kind==="count")return t.tooManyFiles(e.cap);return t.fileType(e.name,Zi(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)<hl)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;if(this.launcher==="edge"){n.classList.remove("settle");let a=Jr.h*Q[this.size],l=Rn(En(e.clientY-t.grab.y,i,a,this.insets),i,a,this.insets);t.edgeTop=l,this.e.root.style.setProperty("--vr-drop-top",`${l}px`);return}let 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;if(this.launcher==="edge"){let a=Jr.h*Q[this.size];this.moveEdge(t&&n.edgeTop!==void 0?En(n.edgeTop,s,a,this.insets):this.edge),this.settle();return}this.moveDock(t?bl({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,ml(e),this.paint(),n.hidden||eo())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})}rest(){return this.launcher==="edge"?us(this.edge):this.dock}moveEdge(e){this.edge=e,cs(e),this.paint()}settle(){let e=this.e.fab;if(eo())return;e.classList.remove("settle"),e.offsetWidth,e.classList.add("settle"),e.addEventListener("animationend",()=>e.classList.remove("settle"),{once:!0})}placeEdge(){let e=this.e.root,t=globalThis.innerHeight||600,n=Q[this.size],r=Jr.h*n,o=this.fabDrag?.edgeTop??Rn(this.edge,t,r,this.insets);e.style.setProperty("--vr-drop-top",`${o}px`);let i=Math.min(Xr.h*n,t-32);e.style.setProperty("--vr-card-top",`${ps(o,r,i,t)}px`)}startMarking(){if(this.job?.id)return;this.marking=!0,this.confirming=!1,this.passKeys=new Set(this.markers.map((t)=>t.key));let e=this.parked??this.rest();this.parkInsets=this.insetsAt(e,this.e.card.getBoundingClientRect()),this.parked=e,this.renderMarks(),this.paint(),this.placeCard(),this.placeSeg(!0),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=Gr*Q[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):Qr}}frame(){let e=globalThis.innerWidth||800,t=globalThis.innerHeight||600,n=Q[this.size],r=this.parkInsets??{top:Gr*n,bottom:Qr,edge:Qr},o=this.e.card.getBoundingClientRect();return{vw:e,vh:t,w:o.width||Math.min(Xr.w*n,e-32),h:o.height||Math.min(Xr.h*n,t-r.top-r.bottom),...r}}placeCard(e=!1){if(!this.parked)return;let t=this.frame(),n=this.parked;this.parked=uc(this.parked,this.markers.map((s)=>s.rect),t);let r=Br(this.parked,t),o=this.e.card,i=e&&this.parked===n;if(i)o.style.transition="none";if(o.classList.add("parked"),o.style.left=`${r.x}px`,o.style.top=`${r.y}px`,this.placeCoachSide(),!i)return;o.offsetWidth,o.style.removeProperty("transition")}placeCoachSide(){let e=Q[this.size],t=this.e.coach;t.dataset.side="above";let n=t.offsetHeight||Zr.h;t.dataset.side=pc(this.parked??this.rest(),this.frame(),{w:Zr.w*e,h:n*e},Zr.gap*e)}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(e=!1){Tc(this.e.seg,this.e.segInd,this.e.toolButtons.get(this.tool),e)}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){let t=this.drawing;if(!t||e.pointerId!==t.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:t.shape,rect:Ar(t.start,{x:e.clientX,y:e.clientY}),head:Mr(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(),!zl(t.shape,t.start,n))return;this.addMarker(t.shape,Ar(t.start,n),t.shape==="arrow"?Mr(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=dn([...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-Yr.w/2),y:Math.round(n/2-Yr.h/2),...Yr},this.renderKbDraft();return}let a=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,a,this.tool==="arrow"?"se":void 0);return}let r=Fp[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(Rc,o.w+i)),h:Math.min(n-o.y,Math.max(Rc,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"}))}shapeNodes(e){let{x:t,y:n,w:r,h:o}=e.rect;if(e.shape==="circle")return[j("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[j("rect",{class:"stroke",x:t,y:n,width:r,height:o,rx:6})];if(e.shape==="arrow"){let{tail:a,tip:l}=Lr(e.rect,e.head??"se");return[j("line",{class:"stroke",x1:a.x,y1:a.y,x2:l.x,y2:l.y,"marker-end":"url(#vr-head)"})]}let i=j("rect",{class:"veil",x:t,y:n,width:r,height:o,rx:4}),s=j("text",{class:"veil-label",x:t+r/2,y:n+o/2+4,"text-anchor":"middle"});return s.textContent=r>150&&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=dn(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"},T(R.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"},T(R.close)),d=c("li",{class:"ln"},s,a,l);a.addEventListener("input",()=>{this.markers=this.markers.map((p)=>p.key===n.key?{...p,note:a.value}:p),this.paint()}),a.addEventListener("keydown",(p)=>{if(p.key!=="Enter"||!this.marking)return;p.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"?Lr(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(Gr-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=we(this.opts.base),o=Fr({url:this.opts.base,key:this.opts.key}),i=globalThis.location;return{title:Cc(e),description:e,env:{url:z(i?`${i.origin}${i.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:$l(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{},...o?{round:o.token}:{},...r?{memberToken:r}:{},...Xi(this.context)}}words(){return this.e.desc.value.trim()||(this.markers.find((e)=>e.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 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 i of this.markers)for(let s of this.hideIds.get(i.key)??[])t.add(s);let n=this.engine,r=this.frozen??{clip:null,stored:Promise.resolve(new Map)},o=n?await mc(()=>n.build(r,this.markers,t)):jr;this.job=new qr(o,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),(t,n)=>this.memberRefused(t,n)),wc(this.opts.base,globalThis.location?.host??"",{title:Cc(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?qp(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),W(e.accLink,t.linkVitrinka);let s=this.session?.portalUrl;if(e.accPortal.hidden=!s,s)e.accPortal.setAttribute("href",s);W(e.accPortal,t.openPortal),W(e.mReports,t.myReports),W(e.mRecents,t.recentRecordings),W(e.mRecord,t.record),W(e.mSettings,t.settings),e.mRecents.hidden=!this.recordSwitch,e.mRecord.hidden=!this.recordSwitch;let a=this.recordWaits();if(a)e.mRecord.setAttribute("aria-disabled","true");else e.mRecord.removeAttribute("aria-disabled");if(e.mRecordWhy.hidden=!a,e.mRecordWhy.textContent=t.recordHasDraft,a)e.mRecord.setAttribute("aria-describedby",e.mRecordWhy.id);else e.mRecord.removeAttribute("aria-describedby");let l=i?this.opts.base:s;if(e.mOpen.hidden=!l,l)e.mOpen.setAttribute("href",l);W(e.mOpen,i?t.openVitrinka:t.openPortal)}paintReports(){let{e,s:t}=this;W(e.repBack,t.myReports);let n=!this.session,r=n?Vr(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;W(e.recBack,t.recentRecordings);let n=gr().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;W(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=Ve(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,e.coachLabel.textContent=t.coachSetting,e.coachSwitch.setAttribute("aria-checked",String(this.coachOn));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=rs({version:Ba,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")Tc(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.dataset.launcher=this.launcher,this.launcher==="edge")this.placeEdge();e.root.style.setProperty("--vr-scale",String(Q[this.size])),e.fab.hidden=!this.button||this.marking,e.fabLabel.textContent=t.button,e.fab.setAttribute("aria-expanded",String(this.isOpen));let r=this.launcher==="edge";if(e.fab.setAttribute("aria-description",r?t.edgeHint:t.moveHint),e.fab.setAttribute("aria-keyshortcuts",`${this.keybind?`${ic(this.keybind)} `:""}Alt+ArrowUp Alt+ArrowDown${r?"":" Alt+ArrowLeft Alt+ArrowRight"}`),e.fabKbd.hidden=!this.keybind||r,e.fabKbd.textContent=this.keybind?ln(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[i,s]of e.kindButtons)s.textContent=t.kinds[i],s.setAttribute("aria-checked",String(this.kind===i)),s.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((i)=>c("li",{},i))),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 i of this.lines.values())i.note.disabled=this.sending,i.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?ln(this.keybind):t.notSet} — ${t.recordShortcut}`),e.bindBtn.textContent=this.recordingBind?t.pressKeys:this.keybind?ln(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 o=this.result?.reportUrl;if(e.see.hidden=!o,o)e.see.setAttribute("href",o);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=this.tool==="hide"?t.barLeadHide:t.barLead;for(let[i,s]of e.toolButtons){let a=e.toolLabels.get(i);if(a)a.textContent=t.tools[i];s.setAttribute("aria-checked",String(this.tool===i))}if(e.cancel.textContent=t.cancelMarking,e.cancel.hidden=this.confirming,e.ask.hidden=!this.confirming,e.askText.textContent=t.discardMarks(this.markers.filter((i)=>!this.passKeys.has(i.key)).length),e.discard.textContent=t.discard,e.keep.textContent=t.keep,e.coach.hidden=!this.marking||!this.coachOn,e.coach.hidden)this.coachShape=null;else if(this.coachShape!==this.tool)this.coachShape=this.tool,e.coachArtSlot.replaceChildren(T(jp(this.tool,eo()))),this.placeCoachSide();if(e.coachText.textContent=t.coach[this.tool],e.coachMore.textContent=t.coachMore,e.coachDismiss.textContent=t.coachDismiss,e.coachKeys.textContent=t.keyboardHint,e.mark.setAttribute("aria-label",t.marking),this.marking){for(let i of e.shapes.querySelectorAll(".veil-label"))if(i.textContent)i.textContent=t.hidden}this.renderPins()}}function dn(e){return Fl(e).map((t,n)=>({...t,key:e[n].key}))}var un="vitrinka-report",Vp=["key","base","open-selector","locale","button","launcher"];function Lc(e){return e.trim().replace(/\/+$/,"")}function oo(e){if(typeof customElements>"u"||customElements.get(un))return;class t extends HTMLElement{static get observedAttributes(){return Vp}options={};at=null;shown=null;widget=null;pill=null;gen=0;recordOffered=!1;offPillOpener=null;warnedRecording=!1;offLink=null;pendingIdentity=void 0;context={};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==="launcher")this.widget.setLauncher(Sn(o));else if(n==="open-selector")this.widget.setOpenSelector(o)}open(){if(this.shown==="recorder")this.openFromPill();else this.widget?.open()}close(){this.widget?.close()}identify(n){this.pendingIdentity=n,this.widget?.identify(n)}setContext(n){this.context=Yi(n),this.widget?.setContext(this.context)}setLocale(n){this.setAttribute("locale",String(n))}mount(){if(this.at)return;let n=(this.getAttribute("key")??"").trim(),r=Lc(this.getAttribute("base")??e.defaultBase());if(!n||!r){console.warn(`vitrinka: <${un}> needs a key${r?"":" and a base"} — nothing mounted`);return}if(this.at={key:n,base:r},e.recorderFace)this.offLink=Ut(()=>this.offerRecord());this.show(e.recorderFace?Wa(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.offPillOpener?.(),this.offPillOpener=null,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",this.offPillOpener=L(document,"click",(s)=>{if(!no(s,this.getAttribute("open-selector")))return;s.preventDefault(),this.open()});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 ro({base:r.base,key:r.key,locale:lt(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",launcher:Sn(this.getAttribute("launcher")),edgeInsets:this.options.edgeInsets,openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,context:this.context,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)}openFromPill(){if(this.keepsPill())return;let n=this.at;setTimeout(()=>{if(!n||this.at!==n)return;if(this.shown==="recorder"){if(this.keepsPill())return;pr("report"),this.show("report")}this.widget?.open()},0)}keepsPill(){if(!Ua())return!1;if(!this.warnedRecording)console.warn("vitrinka: Report a problem stays closed while the recorder pill records — leaving would strand the session; stop the recording first");return this.warnedRecording=!0,!0}switchTo(n){pr(n);let r=this.gen;setTimeout(()=>{if(r===this.gen&&this.shown!==n)this.show(n)},0)}}customElements.define(un,t)}function Pc(e,t){if(e.face==="recorder")return Yp(e,t);oo(t);let n=document.createElement(un);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.launcher)n.setAttribute("launcher",e.launcher);if(e.openSelector)n.setAttribute("open-selector",e.openSelector);if(n.options={appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl,edgeInsets:e.edgeInsets},e.identity!==void 0)n.identify(e.identity);if(e.context!==void 0)n.setContext(e.context);return(e.parent??document.body).append(n),{get face(){return n.face},open:()=>n.open(),close:()=>n.close(),identify:(r)=>n.identify(r),setContext:(r)=>n.setContext(r),setLocale:(r)=>n.setLocale(r),setButton:(r)=>n.setAttribute("button",r?"true":"false"),unmount:()=>n.remove()}}function Yp(e,t){let n=Lc(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,setContext:i,setLocale:i,setButton:i,unmount:()=>{o=!0,r?.()}}}var Xp=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function Gp(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 Ic={loadRecord:Gp,recorderFace:null,defaultBase:()=>Xp};oo(Ic);function ym(e){return Pc(e,Ic)}export{Tp as identify,ym as mountReport};