@vitrinka/web 0.9.2 → 0.9.4

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 R(x,$,z,Q={}){let Z=x,J=Z.__zone_symbol__addEventListener??x.addEventListener,X=Z.__zone_symbol__removeEventListener??x.removeEventListener,V=Q.capture??!1;return J.call(x,$,z,{capture:V,passive:!1}),()=>X.call(x,$,z,V)}class v0 extends Error{constructor(x="link code expired"){super(x);this.name="LinkExpired"}}class P4 extends Error{constructor(x,$){super(`linked into ${x} — this app records into ${$}; link again and pick ${$}`);this.linked=x,this.expected=$,this.name="LinkWorkspaceMismatch"}}class H0 extends Error{constructor(x,$){super(x);this.status=$,this.name="LinkError"}}class _ extends Error{constructor(x,$){super(x);this.status=$,this.name="VitrinkaApiError"}}function u(x){return x>=400&&x<500&&x!==408&&x!==429}function B4(x){return new URL(x).origin}function D1(x){let $=/^\/w\/([^/]+)/.exec(new URL(x).pathname);if(!$?.[1])return;try{return decodeURIComponent($[1])}catch{return $[1]}}function H4(x,$){if(!$)return x;let z=new URL(x);return z.searchParams.set("workspace",$),z.href}function O4(x){return x===401}function L4(x){let $=x.fetch??globalThis.fetch;if(typeof $!=="function")throw Error("vitrinka link: no fetch available");return $}function N4(x,$,z,Q){let Z=(J)=>{if(!J)return;try{let X=new URL(J,x);if(X.protocol!=="http:"&&X.protocol!=="https:")return;if(X.origin===x)return X.href;return x+X.pathname+X.search}catch{return}};return Z($)??Z(z)??x+Q}function K1(x,$,z){let Q=x[$];if(typeof Q!=="string"||Q==="")throw new H0(`link start → malformed payload (${$})`,z);return Q}async function I4(x,$){let z=B4(x),Q=await L4($)(`${z}/api/v1/cli/auth`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"recorder",label:$.label})});if(Q.status!==201&&Q.status!==200)throw new H0(`link start → ${Q.status}`,Q.status);let Z;try{Z=await Q.json()}catch{throw new H0("link start → malformed payload (not JSON)",Q.status)}if(typeof Z!=="object"||Z===null)throw new H0("link start → malformed payload",Q.status);let J=Z,X=K1(J,"device_code",Q.status),V=K1(J,"user_code",Q.status),G=K1(J,"verify_path",Q.status),Y=K1(J,"qr_path",Q.status);return{base:x,device_code:X,user_code:V,verify_path:G,verifyUrl:H4(N4(z,typeof J.verify_url==="string"?J.verify_url:void 0,G,`/cli-auth?code=${encodeURIComponent(V)}`),$.workspace),qrUrl:H4(N4(z,Y,Y,`/cli-auth/qr?code=${encodeURIComponent(V)}`),$.workspace),interval:Math.max(2,Number(J.interval)||2),expires_in:Number(J.expires_in)||0}}var l8=600,c8=30000;function i8(x){return x>=500||x===408||x===429}function o8(x,$){let z=x.headers.get("retry-after");if(!z)return;let Q=Number(z);if(Number.isFinite(Q)&&Q>=0)return Q*1000;let Z=Date.parse(z);return Number.isNaN(Z)?void 0:Math.max(0,Z-$)}function n8(x,$){return new Promise((z,Q)=>{if($?.aborted)return Q(X2());let Z=setTimeout(()=>{$?.removeEventListener("abort",J),z()},x),J=()=>{clearTimeout(Z),Q(X2())};$?.addEventListener("abort",J,{once:!0})})}function X2(){let x=Error("link polling aborted");return x.name="AbortError",x}async function g4(x,$,z={}){let Q=B4(x),Z=L4(z),J=z.sleep??n8,X=z.now??Date.now,V=Math.max(2,z.interval??2),G=X()+(z.expiresIn&&z.expiresIn>0?z.expiresIn:l8)*1000,Y=0,U=async(F,W)=>{Y++;let q=G-X();if(q<=0)throw new v0(`link code expired (last claim: ${F})`);let M=Math.max(Math.min(c8,V*1000*2**Y),W??0);await J(Math.min(M,q),z.signal)};for(;;){if(z.signal?.aborted)throw X2();let F;try{F=await Z(`${Q}/api/v1/cli/auth/claim`,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify({device_code:$}),signal:z.signal})}catch(W){if(z.signal?.aborted||!(W instanceof TypeError))throw W;await U(W.message);continue}if(i8(F.status)){await U(String(F.status),o8(F,X()));continue}if(Y=0,F.status===200){let W=await F.json();if(z.workspace&&W.workspace!==z.workspace){let q=typeof W.workspace==="string"&&W.workspace?W.workspace:"(no workspace)";throw new P4(q,z.workspace)}return W}if(F.status===404||F.status===410)throw new v0;if(F.status!==202)throw new H0(`link claim → ${F.status}`,F.status);await J(V*1000,z.signal)}}var O={tabId:"root",tabHost:"/",pathname:"/"};function _4(){try{let x=globalThis.sessionStorage,$=x.getItem("vitrinka.tab");if($)return $;let z=Math.random().toString(36).slice(2,10);return x.setItem("vitrinka.tab",z),z}catch{return"root"}}function A4(x,$){O.tabId=x,O.tabHost=$}var m0={following:null},h0="__vitrinkaCaptureOwner";function C4(x,$){let z=globalThis,Q=z[h0];if(Q){if(x==="report")return null;if(Q.face==="report")z[h0]=null,Q.yieldTo?.()}let Z=`${x}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return z[h0]={face:x,token:Z,...$?{yieldTo:$}:{}},Z}function T4(x){let $=globalThis;if(x&&$[h0]?.token===x)$[h0]=null}var V2=new Set;function R4(x){return V2.add(x),()=>V2.delete(x)}function w(){for(let x of V2)x()}async function E4(x,$){let z=`vitrinka.recorder.${x}`;if(globalThis.navigator?.locks){await navigator.locks.request(z,{signal:AbortSignal.timeout(5000)},$);return}let Q={area:s8(),key:`vitrinka.recorder.lock.${x}`},Z=await Q9(),J={fence:void 0,since:0};while(!await z9(Z,z,Q,$,J))await r8()}var b4=1000,a8=5,r8=()=>new Promise((x)=>setTimeout(x,a8));function s8(){try{return globalThis.localStorage??null}catch{return null}}function t8(x,$){return typeof $!=="string"||!x.area||x.area.getItem(x.key)===$}function e8(x){if(!x.area)return null;let $=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;try{return x.area.setItem(x.key,$),$}catch(z){return console.warn("vitrinka: recorder lock fence not stored — the next tab may not see this allocation",z),null}}function x9(x,$){let z=Date.now();if(x.fence!==$)return x.fence=$,x.since=z,!1;if(z-x.since<b4)return!1;return $9(),!0}var S4=!1;function $9(){if(S4)return;S4=!0,console.warn(`vitrinka: this tab did not hear the last recorder lock holder within ${b4} ms — numbering anyway`)}function z9(x,$,z,Q,Z){return new Promise((J,X)=>{let V=x.transaction("locks","readwrite"),G=V.objectStore("locks"),Y=!1;V.oncomplete=()=>J(Y),V.onabort=()=>X(V.error??Error("vitrinka: recorder lock transaction aborted"));let U=G.get($);U.onsuccess=()=>{if(!t8(z,U.result)&&!x9(Z,U.result))return;try{Q()}catch(W){X(W),V.abort();return}Y=!0;let F=e8(z);if(F)G.put(F,$)}})}var u0;function Q9(){if(!u0)u0=new Promise((x,$)=>{let z=indexedDB.open("vitrinka.recorder.locks",1);z.onupgradeneeded=()=>z.result.createObjectStore("locks"),z.onerror=()=>$(z.error),z.onsuccess=()=>{let Q=z.result;Q.onversionchange=()=>{Q.close(),u0=void 0},x(Q)}}).catch((x)=>{throw u0=void 0,x});return u0}var J0="vitrinka.recorder.",G2=null,Z9=!1;function C(){if(!G2)G2=J9()??X9();return Z9=!0,G2}function J9(){try{let x=globalThis.localStorage;if(!x)return null;let $=`${J0}probe`;return x.setItem($,"1"),x.removeItem($),{getString:(z)=>x.getItem(J0+z),set:(z,Q)=>x.setItem(J0+z,Q),remove:(z)=>x.removeItem(J0+z),withLock:E4,keys:()=>Array.from({length:x.length},(z,Q)=>x.key(Q)).filter((z)=>z!==null&&z.startsWith(J0)).map((z)=>z.slice(J0.length)),watch:(z,Q)=>{let Z=(J)=>{if(J.storageArea===x&&J.key===J0+z)Q(J.newValue)};return globalThis.addEventListener("storage",Z),()=>globalThis.removeEventListener("storage",Z)}}}catch{return console.warn("vitrinka: localStorage unavailable — the recorder queue will not survive a reload"),null}}function X9(){let x=new Map;return{getString:($)=>x.get($)??null,set:($,z)=>void x.set($,z),remove:($)=>void x.delete($),keys:()=>[...x.keys()]}}var N0={url:"",key:""};function d0(){return N0}var j2=new Set;function w4(x){let $=x.replace(/\/+$/,"");return j2.add($),()=>j2.delete($)}function Y2(x){if(N0.url!==""&&x.startsWith(N0.url))return!0;for(let $ of j2)if($!==""&&x.startsWith($))return!0;return!1}var l0="link";function X0(){let x=C().getString(l0);if(!x)return null;try{let $=JSON.parse(x);return typeof $.token==="string"&&$.token?$:null}catch{return null}}function W2(x){C().set(l0,JSON.stringify(x)),w()}function H1(){C().remove(l0),w()}function f4(){return N0.key||X0()?.token||""}function U2(){if(N0.label)return N0.label;let x=globalThis.navigator?.userAgent??"",$=/Edg\//.test(x)?"Edge":/OPR\//.test(x)?"Opera":/Chrome\//.test(x)?"Chrome":/Firefox\//.test(x)?"Firefox":/Safari\//.test(x)?"Safari":"Browser",z=/iPhone|iPad/.test(x)?"iOS":/Android/.test(x)?"Android":/Mac OS X/.test(x)?"macOS":/Windows/.test(x)?"Windows":/Linux/.test(x)?"Linux":"unknown OS",Q=globalThis.location?.host??"";return`${$} on ${z}${Q?` · ${Q}`:""}`}function y4(x){return`${x}.${Math.random().toString(36).slice(2,10)}`}var V9=null;function k4(x){if(O4(x))V9?.()}function p4(x){return x??{url:d0().url,key:f4()}}async function n(x,$,z,Q={}){let{url:Z,key:J}=p4(Q.target),X=await fetch(Z+$,{method:x,mode:"cors",credentials:"omit",keepalive:Q.keepalive??!1,...Q.signal?{signal:Q.signal}:{},headers:{authorization:`Bearer ${J}`,...z!==void 0?{"content-type":"application/json"}:{}},body:z===void 0?void 0:JSON.stringify(z)}),V=await X.text();if(!X.ok){if(!Q.target)k4(X.status);throw new _(`${x} ${$} → ${X.status}: ${V}`,X.status)}return V?JSON.parse(V):{}}function v4(x,$,z){return m4(x,"chunk",$,"application/json",z)}function h4(x,$,z){return m4(x,"shot",$,z.type,z)}function m4(x,$,z,Q,Z){return q2(`/api/v1/sessions/${x}/${$}?seq=${z}`,Q,Z)}async function q2(x,$,z,Q,Z){let{url:J,key:X}=p4(Q),V=await fetch(J+x,{method:"POST",mode:"cors",credentials:"omit",...Z?{signal:Z}:{},headers:{authorization:`Bearer ${X}`,"content-type":$},body:z}),G=await V.text();if(!V.ok){if(!Q)k4(V.status);throw new _(`POST ${x} → ${V.status}: ${G}`,V.status)}try{return JSON.parse(G)}catch{return{}}}var l4="[redacted]",G9=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],j9=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function P0(x){return String(x).toLowerCase().replace(/[-_]/g,"")}var F2=null;function M2(x){let $=JSON.stringify(x??null);if(F2?.src===$)return F2.rules;let z=new Set(G9),Q=new Set(j9),Z=[];for(let X of x?.extraHeaders??[]){let V=P0(X);if(V)z.add(V)}for(let X of x?.extraBodyKeys??[]){let V=P0(X);if(V)Q.add(V)}for(let X of x?.patterns??[])try{Z.push(new RegExp(X,"g"))}catch(V){console.warn("vitrinka redact: unsupported pattern skipped",X,V)}let J={full:x?.fullFidelity===!0,maskAllText:x?.maskAllText===!0,headers:z,bodyKeys:Q,patterns:Z};return F2={src:$,rules:J},J}var Y9=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),W9=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function U9(x){return x.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(($)=>$.toLowerCase())}function c4(x){let $=U9(x);if($.some((z)=>Y9.has(z)))return!0;for(let z=0;z<$.length;z++){let Q="";for(let Z=z;Z<$.length;Z++){if(Q+=$[Z],W9.includes(Q))return!0;if(Q.length>24)break}}return!1}function i4(x,$){let z=P0($);return x.headers.has(z)||z.endsWith("apikey")||z.endsWith("token")||c4($)}function a(x,$){return x.bodyKeys.has(P0($))||c4($)}function o4(x,$){if(a(x,$))return!0;let z=P0($);return z.endsWith("apikey")||z.endsWith("token")}var q9=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,F9=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function n4(x){return x.includes("PRIVATE KEY-----")?x.replace(q9,"[redacted]"):x}function B0(x,$){let z=n4($);for(let Q of x.patterns)Q.lastIndex=0,z=z.replace(Q,"[redacted]");return z}function a4(x,$){if(F9.test($))return!0;for(let z of $.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(a(x,z[1]))return!0;return!1}function N1(x){let $=x;for(let z=0;z<3;z++){let Q=M9($);if(Q===$)break;$=Q}return $}function M9(x){if(!x.includes("%"))return x;try{return decodeURIComponent(x)}catch{return x.replace(/(%[0-9A-Fa-f]{2})+/g,($)=>{try{return decodeURIComponent($)}catch{return $.replace(/%([0-9A-Fa-f]{2})/g,(z,Q)=>{let Z=Number.parseInt(Q,16);return Z<128?String.fromCharCode(Z):z})}})}}function r4(x,$,z){let Q=!1,Z=z.split(/[&;]/).map((J)=>{if(J==="")return J;let X=J.indexOf("="),V=X>=0?J.slice(0,X):J,G=N1(V.replace(/\+/g," ")),Y=G.lastIndexOf("?"),U=Y>=0?G.slice(Y+1):null;if($(x,G)||U!==null&&$(x,U))return Q=!0,`${V}=[redacted]`;if(X>=0&&a4(x,N1(J.slice(X+1))))return Q=!0,`${V}=[redacted]`;return J});return Q?Z.join("&"):z}function K2(x,$){if(x.full||!$)return $;let z=$.search(/[?#]/);if(z<0)return B0(x,$);let Q=$.slice(z+1).split("#").map((Z)=>r4(x,o4,Z)).join("#");return B0(x,$.slice(0,z+1)+Q)}var K9=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,D9=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,H9=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,N9=131072;function P1(x,$){if($.length>N9)return`[body omitted: ${$.length} bytes, unmaskable]`;let z=n4($).replace(H9,(Q,Z)=>i4(x,Z)?`${Z}: [redacted]`:Q).replace(/\b((?:proxy-)?authorization|www-authenticate)(\s*[:=]\s*)[^\r\n]+/gi,(Q,Z,J)=>`${Z}${J}[redacted]`).replace(/\b(Digest|Negotiate|NTLM)\s+(?=[A-Za-z][A-Za-z-]{0,30}\s*=)[^\r\n]+/gi,(Q,Z)=>`${Z} [redacted]`).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [redacted]").replace(/\beyJ[A-Za-z0-9._-]{10,}/g,"[redacted]").replace(D9,(Q,Z,J,X)=>{if(o4(x,N1(J)))return`${Z}${J}=[redacted]`;if(a4(x,N1(X)))return`${Z}${J}=[redacted]`;return Q}).replace(K9,(Q,Z,J,X,V)=>{if(V==="[redacted]")return Q;return a(x,Z)?`${Z}${J}${X}[redacted]${X}`:Q});return B0(x,z)}function P9(x){switch(P0(x)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var B9=64;function B1(x,$,z){if(z>B9)return"[redacted]";if(Array.isArray($))return $.map((Q)=>B1(x,Q,z+1));if($!==null&&typeof $==="object"){let Q={};for(let[Z,J]of Object.entries($))if(a(x,Z))Q[Z]="[redacted]";else if(typeof J==="string"&&P9(Z))Q[Z]=K2(x,J);else Q[Z]=B1(x,J,z+1);return Q}return typeof $==="string"?B0(x,$):$}function u4(x){if(!x.includes("\\"))return x;return x.replace(/\\u([0-9A-Fa-f]{4})|\\(.)/g,($,z,Q)=>z!==void 0?String.fromCharCode(Number.parseInt(z,16)):Q)}function O9(x,$){for(let z of $.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(a(x,u4(z[1])))return"";return $.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(z,Q,Z)=>a(x,u4(Z))?`${Q}"[redacted]"`:z)}function D2(x){let $=x.trimStart();return $.startsWith("{")||$.startsWith("[")}function L9(x,$,z){let Q=/boundary="?([^";]+)"?/i.exec(z);if(!Q)return null;let Z=`--${Q[1]}`,J=$.split(Z);if(J.length<3||J[0]!=="")return null;if(!J[J.length-1].startsWith("--"))return null;let X=[J[0]];for(let V=1;V<J.length-1;V++){let G=J[V];if(!G.startsWith(`\r
2
- `)||!G.endsWith(`\r
3
- `))return null;let Y=G.indexOf(`\r
1
+ function P(e,t,n,r={}){let o=e,i=o.__zone_symbol__addEventListener??e.addEventListener,s=o.__zone_symbol__removeEventListener??e.removeEventListener,a=r.capture??!1;return i.call(e,t,n,{capture:a,passive:!1}),()=>s.call(e,t,n,a)}class $e extends Error{constructor(e="link code expired"){super(e);this.name="LinkExpired"}}class Si 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 ke extends Error{constructor(e,t){super(e);this.status=t,this.name="LinkError"}}class C extends Error{constructor(e,t){super(e);this.status=t,this.name="VitrinkaApiError"}}function q(e){return e>=400&&e<500&&e!==408&&e!==429}function Ri(e){return new URL(e).origin}function yt(e){let t=/^\/w\/([^/]+)/.exec(new URL(e).pathname);if(!t?.[1])return;try{return decodeURIComponent(t[1])}catch{return t[1]}}function wi(e,t){if(!t)return e;let n=new URL(e);return n.searchParams.set("workspace",t),n.href}function Ei(e){return e===401}function Ci(e){let t=e.fetch??globalThis.fetch;if(typeof t!=="function")throw Error("vitrinka link: no fetch available");return t}function xi(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 bt(e,t,n){let r=e[t];if(typeof r!=="string"||r==="")throw new ke(`link start → malformed payload (${t})`,n);return r}async function Ti(e,t){let n=Ri(e),r=await Ci(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 ke(`link start → ${r.status}`,r.status);let o;try{o=await r.json()}catch{throw new ke("link start → malformed payload (not JSON)",r.status)}if(typeof o!=="object"||o===null)throw new ke("link start → malformed payload",r.status);let i=o,s=bt(i,"device_code",r.status),a=bt(i,"user_code",r.status),l=bt(i,"verify_path",r.status),d=bt(i,"qr_path",r.status);return{base:e,device_code:s,user_code:a,verify_path:l,verifyUrl:wi(xi(n,typeof i.verify_url==="string"?i.verify_url:void 0,l,`/cli-auth?code=${encodeURIComponent(a)}`),t.workspace),qrUrl:wi(xi(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 Vl=600,Yl=30000;function Gl(e){return e>=500||e===408||e===429}function Xl(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 Jl(e,t){return new Promise((n,r)=>{if(t?.aborted)return r(ln());let o=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e),i=()=>{clearTimeout(o),r(ln())};t?.addEventListener("abort",i,{once:!0})})}function ln(){let e=Error("link polling aborted");return e.name="AbortError",e}async function Mi(e,t,n={}){let r=Ri(e),o=Ci(n),i=n.sleep??Jl,s=n.now??Date.now,a=Math.max(2,n.interval??2),l=s()+(n.expiresIn&&n.expiresIn>0?n.expiresIn:Vl)*1000,d=0,p=async(h,u)=>{d++;let f=l-s();if(f<=0)throw new $e(`link code expired (last claim: ${h})`);let g=Math.max(Math.min(Yl,a*1000*2**d),u??0);await i(Math.min(g,f),n.signal)};for(;;){if(n.signal?.aborted)throw ln();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(Gl(h.status)){await p(String(h.status),Xl(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 Si(f,n.workspace)}return u}if(h.status===404||h.status===410)throw new $e;if(h.status!==202)throw new ke(`link claim → ${h.status}`,h.status);await i(a*1000,n.signal)}}var x={tabId:"root",tabHost:"/",pathname:"/"};function Ai(){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 Pi(e,t){x.tabId=e,x.tabHost=t}var Ke={following:null},ze="__vitrinkaCaptureOwner";function Li(e,t){let n=globalThis,r=n[ze];if(r){if(e==="report")return null;if(r.face==="report")n[ze]=null,r.yieldTo?.()}let o=`${e}:${Date.now().toString(36)}.${Math.random().toString(36).slice(2,10)}`;return n[ze]={face:e,token:o,...t?{yieldTo:t}:{}},o}function Ii(e){let t=globalThis;if(e&&t[ze]?.token===e)t[ze]=null}var cn=new Set;function Oi(e){return cn.add(e),()=>cn.delete(e)}function D(){for(let e of cn)e()}async function _i(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:ec(),key:`vitrinka.recorder.lock.${e}`},o=await sc(),i={fence:void 0,since:0};while(!await ic(o,n,r,t,i))await Ql()}var Hi=1000,Zl=5,Ql=()=>new Promise((e)=>setTimeout(e,Zl));function ec(){try{return globalThis.localStorage??null}catch{return null}}function tc(e,t){return typeof t!=="string"||!e.area||e.area.getItem(e.key)===t}function nc(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 rc(e,t){let n=Date.now();if(e.fence!==t)return e.fence=t,e.since=n,!1;if(n-e.since<Hi)return!1;return oc(),!0}var Di=!1;function oc(){if(Di)return;Di=!0,console.warn(`vitrinka: this tab did not hear the last recorder lock holder within ${Hi} 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(!tc(n,p.result)&&!rc(o,p.result))return;try{r()}catch(u){s(u),a.abort();return}d=!0;let h=nc(n);if(h)l.put(h,t)}})}var qe;function sc(){if(!qe)qe=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(),qe=void 0},e(r)}}).catch((e)=>{throw qe=void 0,e});return qe}var se="vitrinka.recorder.",dn=null,ac=!1;function M(){if(!dn)dn=lc()??cc();return ac=!0,dn}function lc(){try{let e=globalThis.localStorage;if(!e)return null;let t=`${se}probe`;return e.setItem(t,"1"),e.removeItem(t),{getString:(n)=>e.getItem(se+n),set:(n,r)=>e.setItem(se+n,r),remove:(n)=>e.removeItem(se+n),withLock:_i,keys:()=>Array.from({length:e.length},(n,r)=>e.key(r)).filter((n)=>n!==null&&n.startsWith(se)).map((n)=>n.slice(se.length)),watch:(n,r)=>{let o=(i)=>{if(i.storageArea===e&&i.key===se+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 cc(){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 ve={url:"",key:""};function We(){return ve}var un=new Set;function Bi(e){let t=e.replace(/\/+$/,"");return un.add(t),()=>un.delete(t)}function pn(e){if(ve.url!==""&&e.startsWith(ve.url))return!0;for(let t of un)if(t!==""&&e.startsWith(t))return!0;return!1}var je="link";function ae(){let e=M().getString(je);if(!e)return null;try{let t=JSON.parse(e);return typeof t.token==="string"&&t.token?t:null}catch{return null}}function fn(e){M().set(je,JSON.stringify(e)),D()}function kt(){M().remove(je),D()}function Ni(){return ve.key||ae()?.token||""}function hn(){if(ve.label)return ve.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 Fi(e){return`${e}.${Math.random().toString(36).slice(2,10)}`}var dc=null;function $i(e){if(Ei(e))dc?.()}function zi(e){return e??{url:We().url,key:Ni()}}async function G(e,t,n,r={}){let{url:o,key:i}=zi(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)$i(s.status);throw new C(`${e} ${t} → ${s.status}: ${a}`,s.status)}return a?JSON.parse(a):{}}function Ki(e,t,n){return Wi(e,"chunk",t,"application/json",n)}function qi(e,t,n){return Wi(e,"shot",t,n.type,n)}function Wi(e,t,n,r,o){return gn(`/api/v1/sessions/${e}/${t}?seq=${n}`,r,o)}async function gn(e,t,n,r,o){let{url:i,key:s}=zi(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)$i(a.status);throw new C(`POST ${e} → ${a.status}: ${l}`,a.status)}try{return JSON.parse(l)}catch{return{}}}var Vi="[redacted]",uc=["authorization","proxyauthorization","cookie","setcookie","xapikey","xauthtoken","xcsrftoken","xamzsecuritytoken"],pc=["password","passwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","apikey","clientsecret","card","cardnumber","cvv","cvc","pin","ssn"];function we(e){return String(e).toLowerCase().replace(/[-_]/g,"")}var mn=null;function bn(e){let t=JSON.stringify(e??null);if(mn?.src===t)return mn.rules;let n=new Set(uc),r=new Set(pc),o=[];for(let s of e?.extraHeaders??[]){let a=we(s);if(a)n.add(a)}for(let s of e?.extraBodyKeys??[]){let a=we(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 mn={src:t,rules:i},i}var fc=new Set(["password","passwd","pwd","secret","token","auth","authorization","otp","pin","apikey","credential","credentials","cookie","cvv","cvc","iban","ssn"]),hc=["apikey","privatekey","secretkey","sessionid","cardnumber","birthnumber","rodnecislo","accesstoken","refreshtoken","idtoken"];function gc(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t)=>t.toLowerCase())}function Yi(e){let t=gc(e);if(t.some((n)=>fc.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],hc.includes(r))return!0;if(r.length>24)break}}return!1}function Gi(e,t){let n=we(t);return e.headers.has(n)||n.endsWith("apikey")||n.endsWith("token")||Yi(t)}function X(e,t){return e.bodyKeys.has(we(t))||Yi(t)}function Xi(e,t){if(X(e,t))return!0;let n=we(t);return n.endsWith("apikey")||n.endsWith("token")}var mc=/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,bc=/-----BEGIN[A-Z +]*PRIVATE[ +]KEY-----/;function Ji(e){return e.includes("PRIVATE KEY-----")?e.replace(mc,"[redacted]"):e}function xe(e,t){let n=Ji(t);for(let r of e.patterns)r.lastIndex=0,n=n.replace(r,"[redacted]");return n}function Zi(e,t){if(bc.test(t))return!0;for(let n of t.matchAll(/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})\s*[:=]/g))if(X(e,n[1]))return!0;return!1}function vt(e){let t=e;for(let n=0;n<3;n++){let r=yc(t);if(r===t)break;t=r}return t}function yc(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 Qi(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=vt(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&&Zi(e,vt(i.slice(s+1))))return r=!0,`${a}=[redacted]`;return i});return r?o.join("&"):n}function yn(e,t){if(e.full||!t)return t;let n=t.search(/[?#]/);if(n<0)return xe(e,t);let r=t.slice(n+1).split("#").map((o)=>Qi(e,Xi,o)).join("#");return xe(e,t.slice(0,n+1)+r)}var kc=/([A-Za-z][A-Za-z0-9_.\-[\]]{0,60})("?\s*[:=]\s*(?!\/\/))("?)([^&?"'\s,}]*)\3/g,vc=/([?&])([^=&#\s]{1,120})=([^&#\s]*)/g,wc=/^([A-Za-z][A-Za-z0-9_.-]{0,60})[ \t]*:[ \t]*(.+)$/gm,xc=131072;function wt(e,t){if(t.length>xc)return`[body omitted: ${t.length} bytes, unmaskable]`;let n=Ji(t).replace(wc,(r,o)=>Gi(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(Xi(e,vt(i)))return`${o}${i}=[redacted]`;if(Zi(e,vt(s)))return`${o}${i}=[redacted]`;return r}).replace(kc,(r,o,i,s,a)=>{if(a==="[redacted]")return r;return X(e,o)?`${o}${i}${s}[redacted]${s}`:r});return xe(e,n)}function Sc(e){switch(we(e)){case"url":case"href":case"uri":case"location":return!0;default:return!1}}var Rc=64;function xt(e,t,n){if(n>Rc)return"[redacted]";if(Array.isArray(t))return t.map((r)=>xt(e,r,n+1));if(t!==null&&typeof t==="object"){let r={};for(let[o,i]of Object.entries(t))if(X(e,o))r[o]="[redacted]";else if(typeof i==="string"&&Sc(o))r[o]=yn(e,i);else r[o]=xt(e,i,n+1);return r}return typeof t==="string"?xe(e,t):t}function ji(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 Ec(e,t){for(let n of t.matchAll(/"((?:[^"\\\r\n]|\\.)*)"\s*:\s*[{\[]/g))if(X(e,ji(n[1])))return"";return t.replace(/("((?:[A-Za-z0-9_-]|\\u[0-9A-Fa-f]{4}|\\.)+)"\s*:\s*)("(?:[^"\\]|\\.)*"?|[^,{}[\]"\r\n]*)/g,(n,r,o)=>X(e,ji(o))?`${r}"[redacted]"`:n)}function kn(e){let t=e.trimStart();return t.startsWith("{")||t.startsWith("[")}function Cc(e,t,n){let r=/boundary="?([^";]+)"?/i.exec(n);if(!r)return null;let o=`--${r[1]}`,i=t.split(o);if(i.length<3||i[0]!=="")return null;if(!i[i.length-1].startsWith("--"))return null;let s=[i[0]];for(let a=1;a<i.length-1;a++){let l=i[a];if(!l.startsWith(`\r
2
+ `)||!l.endsWith(`\r
3
+ `))return null;let d=l.indexOf(`\r
4
4
  \r
5
- `);if(Y<0)return null;let U=G.slice(2,Y),F=G.slice(Y+4,-2),q=/content-disposition:[^\r\n]*;\s*name="([^"]*)"/i.exec(U)?.[1]??"",M=q!==""&&a(x,q)?"[redacted]":P1(x,F);X.push(`\r
6
- ${U}\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!==""&&X(e,f)?"[redacted]":wt(e,h);s.push(`\r
6
+ ${p}\r
7
7
  \r
8
- ${M}\r
9
- `)}return X.push(J[J.length-1]),X.join(Z)}var s4=262144;function d4(x,$,z){if(x.full||!$)return $;try{if(D2($)){if($.length<=s4)try{return JSON.stringify(B1(x,JSON.parse($),0))}catch{}return B0(x,O9(x,$))}let Q=(z??"").toLowerCase();if(Q.includes("x-www-form-urlencoded"))return P1(x,r4(x,a,$));if(Q.includes("multipart/form-data")){let Z=L9(x,$,z??"");if(Z!==null)return Z;return`[multipart body omitted: unparseable (${$.length} chars)]`}return P1(x,$)}catch{return"[redacted]"}}function t4(x,$){if($===void 0)return;if(x.full)return $;if(D2($))try{return JSON.stringify(B1(x,JSON.parse($),0))}catch{}try{return P1(x,$)}catch{return"[redacted]"}}function e4(x,$,z,Q){if(x.full)return $.length>z?`${$.slice(0,z)}…[truncated]`:$;if($.length>z&&Q?.toLowerCase().includes("multipart/form-data"))return`[multipart body omitted: oversized (${$.length} chars)]`;if(D2($)&&$.length<=s4){let J=d4(x,$,Q);return J.length>z?`${J.slice(0,z)}…[truncated]`:J}let Z=$.length>z?`${$.slice(0,z)}…[truncated]`:$;return d4(x,Z,Q)}function x3(x,$,z){if(!$)return;let Q=z?.maxValueLen??1024,Z=z?.budget??8192,J={};for(let[X,V]of Object.entries($)){let Y=(x.full?String(V):i4(x,X)?"[redacted]":B0(x,String(V))).slice(0,Q);if(Z-=X.length+Y.length,Z<0){J["…"]="(truncated)";break}J[X]=Y}return J}function $3(x){if(x.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:x.maskAllText,...x.maskAllText?{maskTextSelector:"*"}:{}}}var O0=M2(null);function Q3(x){O0=M2(x??null)}function Z3(x){return t4(O0,x)}function H2(x,$,z){return e4(O0,x,$,z)}var z3=null,J3=null;function N2(x){J3=x??null}function I9(x){let $=J3??d0().sanitizeUrl;if(!$)return x;let z;try{let Q=$(x);if(typeof Q==="string")return Q;z=`returned ${typeof Q}`}catch{z="threw"}if(z3!==$)z3=$,console.warn(`vitrinka: sanitizeUrl ${z} — such URLs are recorded as their origin only`);return g9(x)??l4}function g9(x){try{let{origin:$}=new URL(x);return $==="null"?null:$}catch{return null}}function V0(x){return K2(O0,I9(x))}var _9=4;function P2(x){return x.type===_9}function B2(x){if(!P2(x))return x;return{...x,data:{...x.data,href:V0(x.data.href)}}}function c0(x){return x3(O0,x)}function X3(){return $3(O0)}var V3=30000,A9=4194304,C9=20000,I2=500,T9=2000,R9=2,G3={windowMs:V3,checkoutMs:V3,maxBytes:A9,maxEvents:C9,maxLaneEvents:I2},s=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function g2(x,$){return $&&$.load===x.load?$.startMs:x.lastMs}var S9=new TextEncoder,e=!1,j3=0,S=G3,P=[],f=[],d=[],r=[],E9=0,I0=[],g0=new Map,_0=null,L0=null,i0=!1,b9=0,t=null,O1=null,L2=Promise.resolve();function Y3(x=G3){if(A2(),e=!0,j3++,S=x,t=x.store??null,P=(x.prior??[]).filter(($)=>$.kind!=="lanes").map(($)=>({id:$.id,load:$.load,startMs:$.startMs,lastMs:$.lastMs,events:[],count:$.count,bytes:$.bytes,href:$.href,route:$.route,stored:!0})),f=(x.priorLanes??[]).slice(-x.maxLaneEvents),d=[],r=[],I0=(x.prior??[]).filter(($)=>$.kind==="lanes").map(($)=>({id:$.id,lastMs:$.lastMs})),g0.clear(),_0=null,I1(Date.now()),t)O1=setInterval(L1,T9)}function W3(){L1(),A2(),e=!1,t=null,P=[],f=[],d=[],r=[],I0=[],g0.clear(),_0=null}function U3(){return S}function _2(x){L0=x}function q3(){if(!e)return;P=[],f=[],d=[],r=[],I0=[],g0.clear(),_0=null;let x=O.tabId;G0(($)=>$.clear(x)),L0?.()}function F3(){return L2}function L1(){if(!e||!t)return;let x=Date.now();I1(x),C2(x);for(let $ of P){if($.stored)continue;let z=g0.get($.id)??{events:0,parts:0};if(z.events===$.events.length)continue;let Q=JSON.stringify($.events.slice(z.events)),Z=z.parts;g0.set($.id,{events:$.events.length,parts:Z+1});let J=M3($);G0((X)=>X.putWindowChunk(J,Z,Q,[]))}w9(x)}function w9(x){let $=x-S.windowMs;while(r.length>0&&r[0].lastMs<=$){let[V]=r.splice(0,1);if(V)G0((G)=>G.dropWindow(V.id))}for(let V of I0.filter((G)=>G.lastMs<=$))G0((G)=>G.dropWindow(V.id));I0=I0.filter((V)=>V.lastMs>$);let z=d;if(!z.length)return;d=[];let Q=r.at(-1);if(!Q||Q.startMs<=$)Q={id:`${s}.lanes.${++E9}`,startMs:Date.parse(z[0].ts),lastMs:0,parts:0},r.push(Q);Q.lastMs=Date.parse(z.at(-1).ts);let Z=Q.parts++,J=Q,X={id:J.id,tab:O.tabId,scope:S.scope??"",kind:"lanes",load:s,startMs:J.startMs,lastMs:J.lastMs,count:0,bytes:0,href:"",route:""};G0((V)=>V.putWindowChunk(X,Z,"[]",z))}function A2(){if(O1)clearInterval(O1);O1=null}function M3(x){return{id:x.id,tab:O.tabId,scope:S.scope??"",load:x.load,startMs:x.startMs,lastMs:x.lastMs,count:x.count,bytes:x.bytes,href:x.href,route:x.route}}function G0(x){let $=t;if(!$)return;L2=L2.then(()=>x($)).catch((z)=>{if(t!==$)return;t=null,A2(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",z)})}function O2(x){let[$]=P.splice(x,1);if(!$)return;g0.delete($.id),G0((z)=>z.dropWindow($.id))}function I1(x){while(P.length>0){let Q=P[0],Z=P[1];if(!Z&&Q.load===s)break;if(g2(Q,Z)>x-S.windowMs)break;O2(0)}if(i0)return;let $=P.at(-1);if($&&$.load===s&&L0&&$.lastMs<=x-S.windowMs){i0=!0;try{L0()}finally{i0=!1}let Q=P.indexOf($);if(Q>=0&&Q<P.length-1)for(let Z=Q;Z>=0;Z--)O2(Z)}let z=!1;while(P.length>0&&f9()){if(P.length===1&&P[0].load===s&&!z&&L0){z=!0,i0=!0;try{L0()}finally{i0=!1}if(P.length>1)continue}O2(0),_0=P[0]?.startMs??x}}function K3(){return e?`flight:${j3}`:null}function C2(x){let $=Math.min(P[0]?.startMs??Number.POSITIVE_INFINITY,x-S.windowMs),z=f.findIndex((Q)=>Date.parse(Q.ts)>=$);if(z===-1)f=[];else if(z>0)f=f.slice(z)}function f9(){let x=0,$=0;for(let z of P)x+=z.bytes,$+=z.count;return x>S.maxBytes||$>S.maxEvents}function D3(x){if(!e)return;let $=P[0];if(P2(x)){let Q=globalThis.location?.pathname??O.pathname,Z={id:`${s}.${++b9}`,load:s,startMs:x.timestamp,lastMs:x.timestamp,events:[],count:0,bytes:0,href:x.data.href,route:V0(Q)};P.push(Z);let J=M3(Z);G0((X)=>X.putWindow(J))}let z=P.at(-1);if(!z||z.load!==s)return;if(z.events.push(x),z.count++,z.lastMs=Math.max(z.lastMs,x.timestamp),z.bytes+=S9.encode(JSON.stringify(x)).length,I1(x.timestamp),P[0]!==$)C2(x.timestamp)}function H3(x,$,z){if(!e)return null;let Q=S.keepLane?S.keepLane(x,$):$;if(Q===null)return null;let Z=new Date().toISOString(),J={ts:Z,tabId:z.tabId,tabHost:z.tabHost,kind:x,payload:Q},X=S.maxLaneEvents;if(f.push(J),f.length>X)f.splice(0,f.length-X);if(t){if(d.push(J),d.length>X)d.splice(0,d.length-X)}return Z}function g1(){if(!e)return null;let x=Date.now();return I1(x),C2(x),{windows:P.map(($)=>({...$,events:$.events.slice()})),lanes:f.slice(),truncated:_0!==null&&_0>x-S.windowMs}}function T2(x){return x.windows.some(($)=>$.events[1]?.type===R9)}var R2=null;function o0(){if(!R2)R2=typeof indexedDB>"u"?y9():k9();return R2}function y9(){let x=new Map;return{durable:!1,put:async($,z)=>void x.set($,z),get:async($)=>x.get($)??null,delete:async($)=>void x.delete($),keys:async()=>[...x.keys()]}}function k9(){let x,$=()=>{return x??=new Promise((Q,Z)=>{let J=indexedDB.open("vitrinka.recorder.blobs",1);J.onupgradeneeded=()=>J.result.createObjectStore("blobs"),J.onerror=()=>Z(J.error??Error("vitrinka: blob journal did not open")),J.onsuccess=()=>{let X=J.result;X.onversionchange=()=>{X.close(),x=void 0},X.onclose=()=>{x=void 0},Q(X)}}).catch((Q)=>{throw x=void 0,Q}),x},z=async(Q,Z)=>{let J=$(),X;try{X=(await J).transaction("blobs",Q)}catch(G){if(x===J)x=void 0;throw G}let V=Z(X.objectStore("blobs"));return new Promise((G,Y)=>{X.oncomplete=()=>G(V.result),X.onabort=X.onerror=()=>Y(X.error??V.error??Error("vitrinka: blob journal transaction failed"))})};return{durable:!0,put:async(Q,Z)=>void await z("readwrite",(J)=>J.put(Z,Q)),get:async(Q)=>{let Z=await z("readonly",(J)=>J.get(Q));return Z instanceof Blob?Z:null},delete:async(Q)=>void await z("readwrite",(Z)=>Z.delete(Q)),keys:async()=>(await z("readonly",(Q)=>Q.getAllKeys())).filter((Q)=>typeof Q==="string")}}var p9=2000,w2=20000,A3=200,v9=4194304,h9=3145728,S1=500,m9=v9-1024,u9=12582912,d9=10485760,l9=u9-64,c9=1048576,i9=new TextEncoder;function E0(x){return i9.encode(x).length}var g=()=>C();function c(x,$){let z=g().getString(x);if(!z)return $;try{return JSON.parse(z)}catch{return $}}var N3=!1;function i(x,$){try{return g().set(x,$),!0}catch(z){if(!N3)N3=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",z);return!1}}var A1="rec",W0;function L(){if(W0===void 0)W0=c(A1,null);return W0}function E1(x){if(W0=x,x===null)g().remove(A1),g().remove(o9);else i(A1,JSON.stringify(n9(x)))}var o9="notes";var a0=null;function n9(x){if(a0?.sessionId!==x.sessionId)return x;return{...x,paused:!0,activeMs:a0.activeMs,resumeAt:null,stopping:a0.at}}var a9=new Set;function r9(){for(let x of a9)try{x()}catch($){console.warn("vitrinka: before-stop hook failed",$)}}function s9(x){let $=null;if(x)try{$=JSON.parse(x)}catch{return"unchanged"}let z=L();if($?.stopping&&$.sessionId===z?.sessionId&&!z.paused&&a0?.sessionId!==$.sessionId)r9();if(!$){if(!z)return"unchanged";return W0=null,_3(),V7(),"ended"}if(z?.sessionId===$.sessionId){if($.seq=Math.max($.seq,z.seq),$.policy===void 0&&z.policy!==void 0)$.policy=z.policy;if($.attachments===void 0&&z.attachments!==void 0)$.attachments=z.attachments;if(a0?.sessionId===$.sessionId)$.paused=z.paused,$.activeMs=z.activeMs,$.resumeAt=z.resumeAt,delete $.stopping;return W0=$,"updated"}return W0=$,_3(),"joined"}var t9=700,U0,l=null,Q0=!1;function C0(){if(U0===void 0)U0=c("buffer",[]);return U0}function b1(){if(l)clearTimeout(l),l=null;if(U0!==void 0&&!Q0)i("buffer",JSON.stringify(U0))}function C3(){if(Q0=!1,l)return;l=setTimeout(()=>{l=null,b1(),T3()},t9)}function f2(x){U0=x,Q0=!1,b1()}var A0,T0=0;function j0(){if(A0===void 0)A0=c("chunks",[]),T0=A0.reduce((x,$)=>x+$.body.length,0);return A0}function T3(){if(Q0)return;let x=j0();if(x.length===0){g().remove("chunks");return}if(T0>c9){g().remove("chunks");return}i("chunks",JSON.stringify(x))}function R3(x){A0=x,T0=x.reduce(($,z)=>$+z.body.length,0),Q0=!1,T3()}var C1,F0=new Map,q0=new Set,M0=new Map,r0=new Map,P3=5,e9=200,x7=67108864,$7=0,B3=!1,y2="blobs";function y(){return C1??=c("images",[]),C1}function S3(){if(Q0)return;let x=y().filter(($)=>!q0.has($.blob));if(x.length===0)g().remove("images");else i("images",JSON.stringify(x))}function k2(x){C1=x,Q0=!1,S3()}function z7(x,$){let z=o0();if(!z.durable&&!B3)B3=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");i(y2,"1");let Q=[];return{drafts:$.map(({blob:J,payload:X})=>{let V=`${x}/${y3}.${++$7}`;return F0.set(V,J),q0.add(V),Q.push(z.put(V,J).then(()=>{if(!(F0.has(V)||y().some((Y)=>Y.blob===V)||[...M0.values()].includes(V)))return q0.delete(V),p2(V),!1;if(!z.durable)return!1;if(q0.delete(V),y().some((Y)=>Y.blob===V))S3();return!0},(G)=>{return console.warn("vitrinka: an attached image could not be journaled — it will not survive a reload",G),!1})),{blob:V,payload:X}}),journaled:Promise.all(Q).then((J)=>J.every(Boolean))}}function p2(x){o0().delete(x).catch(($)=>console.warn("vitrinka: blob journal delete failed",$))}function R0(x,$){for(let z of x)if(F0.delete(z),q0.delete(z),r0.delete(z),$)p2(z)}var T1=(x)=>x.kind==="event"?(x.images??[]).map(($)=>$.blob):[];async function E3(x){if(!g().getString(y2))return;let $=o0(),z=L()?.sessionId;try{let Q=await $.keys(),Z=0;for(let J of Q)if(x?J.startsWith(`${x}/`):!z||!J.startsWith(`${z}/`))await $.delete(J);else Z++;if(Z===0&&!L())g().remove(y2)}catch(Q){console.warn("vitrinka: blob journal cleanup failed",Q)}}var Q7=0,b3="",w3=0,O3=-1;function v2(){Q7=Date.now(),w3=0,b3=""}function S0(x){w3++,b3=String(x instanceof Error?x.message:x).slice(0,200)}var L3={actions:0,pages:0,frames:0,notes:0},Z7=new Set;function J7(x){let $={...L3};for(let z of x)if(z.kind==="click")$.actions++;else if(z.kind==="nav")$.pages++;else if(z.kind==="rrweb")$.frames+=typeof z.payload?.count==="number"?z.payload.count:1;else if(z.kind==="note"){if($.notes++,typeof z.payload?.cid==="string")Z7.add(z.payload.cid)}L3=$}function X7(x){let $=L();if(!$||$.dead)return;if($.dead=!0,$.deadReason=x,!$.paused&&$.resumeAt)$.activeMs=($.activeMs||0)+(Date.now()-Date.parse($.resumeAt)),$.resumeAt=null;E1($),console.warn("vitrinka: session marked dead —",x),w()}var S2=null;function V7(){if(S2)clearInterval(S2);S2=null}function f3(x){let $=L();if(!$||$.dead||x<1)return null;let z=c("seq",null),Q=Math.max($.seq,z?.sessionId===$.sessionId?z.seq:0)+1;return g().set("seq",JSON.stringify({sessionId:$.sessionId,seq:Q+x-1})),$.seq=Q+x-1,E1($),{seq:Q,sessionId:$.sessionId}}var y3=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,R1="allocation.",G7=0,E=new Set,j7=16777216,s0=0,t0=0,z0=new Map;function w1(x){return x.kind==="event"?1+(x.images?.length??0):1}function Y7(x,$){return new Set(Array.from({length:w1($)},(z,Q)=>x+Q))}function h2(x,$,z){return JSON.stringify(z&&z.size<w1(x)?{draft:x,seq:$,left:[...z]}:{draft:x,seq:$})}var I3=!1,n0=null;function _1(x){if(!E.delete(x))return;if(s0-=x.bytes,x.draft.kind==="chunk")t0--}function k3(x){if(E.add(x),s0+=x.bytes,x.draft.kind==="chunk")t0++;while(E.size>w2||s0>j7||t0>A3){let $=E.values().next().value;_1($),g().remove($.key),R0(T1($.draft),!0);let z=Error("vitrinka: pending allocation budget full — oldest capture dropped");S0(z),console.warn(z.message)}}function p3(x=!1){if(I3&&!x)return;I3=!0;let $=g();if(!$.withLock)return;let z=new Set([...E].map((Q)=>Q.key));for(let Q of $.keys?.()??[]){if(!Q.startsWith(R1)||z.has(Q)||z0.has(Q))continue;let Z=c(Q,null);if(Z&&Z.draft&&Z.draft.sessionId===L()?.sessionId)k3({...Z,key:Q,persisted:!0,bytes:E0(JSON.stringify(Z))})}}function v3(x,$,z){let{ts:Q,tabId:Z,tabHost:J,sessionId:X}=x,V=(G)=>!z||z.has(G);if(x.kind==="event"){let G=x.images??[],Y=$+G.length,U=G.length?{...x.event,payload:{...x.event.payload,attachments:G.map((W,q)=>$+q)}}:x.event,F=C0();if(V(Y)&&!F.some((W)=>W.seq===Y))F.push({seq:Y,ts:Q,tabId:Z,tabHost:J,...U});if(G.length){let W=y();G.forEach((M,H)=>{let D=$+H;if(!V(D)||W.some((N)=>N.seq===D))return;if(F.some((N)=>N.seq===D)){M0.set(D,M.blob);return}W.push({seq:D,ts:Q,tabId:Z,tabHost:J,sessionId:X,blob:M.blob,payload:M.payload})});let q=W.reduce((M,H)=>M+H.payload.bytes,0);while(W.length>e9||q>x7){let M=W.shift();q-=M.payload.bytes,$0(M.sessionId,new Set([M.seq])),R0([M.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${M.payload.name} (seq ${M.seq}); its note lands without it`)}k2(W)}if(F.length>w2){let W=F.splice(0,F.length-w2);$0(X,new Set(W.map((q)=>q.seq))),console.warn(`vitrinka: retry buffer full — dropped ${W.length} oldest events`)}}else{let G=j0();if(!G.some((Y)=>Y.seq===$)&&!C0().some((Y)=>Y.seq===$))G.push({seq:$,ts:Q,tabId:Z,tabHost:J,sessionId:X,...x.part}),T0+=x.part.body.length;while(G.length>A3){let Y=G.shift();T0-=Y.body.length,$0(X,new Set([Y.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${Y.seq}`)}}C3(),Y0()}function $0(x,$){for(let[z,Q]of z0){if(Q.sessionId!==x)continue;let Z=Q.seqs.size;for(let X of Q.seqs)if($.has(X))Q.seqs.delete(X);let J=Q.seqs.size&&Q.seqs.size<Z&&Q.persisted?c(z,null):null;if(J){let X=new Set([...Q.seqs].filter((V)=>!J.left||J.left.includes(V)));if(X.size)i(z,h2(J.draft,J.seq,X));else Q.seqs.clear()}if(Q.seqs.size===0){g().remove(z),z0.delete(z);let X=z.slice(R1.length,z.lastIndexOf(".")),V=`tab.${X}`,G=c(V,null);if(G?.departed&&G.recoverable&&!g().keys?.().some((Y)=>Y.startsWith(`${R1}${X}.`)))g().remove(V)}}}function h3(){if(n0)return n0;let x=g();return n0=m2(Promise.resolve().then(async()=>{for(let $ of E)await x.withLock("seq",()=>{if(!E.has($))return;if($.persisted){let Z=c($.key,null);if(!Z){_1($),R0(T1($.draft),!1);return}$.seq=Z.seq,$.left=Z.left}if(s9(x.getString(A1)??null),L()?.sessionId!==$.draft.sessionId){_1($),R0(T1($.draft),!0);return}let z=$.seq??f3(w1($.draft))?.seq;if(z===void 0)return;$.seq=z;let Q=$.left?new Set($.left):Y7(z,$.draft);if($.persisted)x.set($.key,h2($.draft,z,Q));z0.set($.key,{sessionId:$.draft.sessionId,seqs:Q,persisted:$.persisted}),v3($.draft,z,Q),_1($)})}).catch(($)=>{throw S0($),console.warn("vitrinka: seq allocation failed — capture kept for retry",$),Y0(),w(),$})).finally(()=>{n0=null}),n0}function m3(x,$){let z=L(),Q=x.kind==="event"&&x.event.kind==="note";if(!z||z.dead||z.paused&&!Q)return!1;if(p3(),g().withLock){let Z=`${R1}${y3}.${++G7}`,J=JSON.stringify({draft:x}),X={key:Z,draft:x,persisted:!$&&i(Z,J),bytes:E0(J)};k3(X),h3(),$?.then((V)=>{if(V)W7(X)})}else{let Z=f3(w1(x));if(Z)v3(x,Z.seq);else R0(T1(x),!0)}return!0}function W7(x){let $=z0.get(x.key);if($)$.persisted=i(x.key,h2(x.draft,x.seq,$.seqs));else if(E.has(x))x.persisted=i(x.key,JSON.stringify({draft:x.draft}))}var g3=new Set;function m2(x){return g3.add(x),x.catch(()=>{return}).finally(()=>{g3.delete(x)})}function x0(x){return L()?.sessionId!==x.sessionId}function e0(x,$,z,Q=[]){if(m0.following)return null;let Z=L();if(!Z)return H3(x,$,z);if(Z.dead||Z.paused&&x!=="note")return null;let J=new Date().toISOString(),{tabId:X,tabHost:V}=z,G=Q.length?z7(Z.sessionId,Q):null;return m3({sessionId:Z.sessionId,ts:J,tabId:X,tabHost:V,kind:"event",event:{kind:x,payload:$},...G?{images:G.drafts}:{}},G?.journaled),u2(),J}function u3(x){C0().push(x),u2(),C3(),Y0()}var U7=Date.now();function u2(){U7=Date.now()}function d2(x,$=d9,z=l9){let Q=[],Z=[],J=[],X=2,V=()=>{if(!J.length)return;Q.push({count:J.length,body:`[${J.join(",")}]`}),J=[],X=2};for(let G of x){let Y=JSON.stringify(G),U=E0(Y)+1;if(U>z){Z.push(U);continue}if(U>$){V(),Q.push({count:1,body:`[${Y}]`});continue}if(J.length&&X+U>$)V();J.push(Y),X+=U}return V(),{parts:Q,dropped:Z}}function d3(x,$){if(!x.length)return 0;let z=L();if(!z||z.paused||z.dead||m0.following)return 0;let{parts:Q,dropped:Z}=d2(x);for(let G of Z)console.warn(`vitrinka: rrweb event (${G} bytes) exceeds the chunk cap — dropped`),e0("note",{text:`⚠ rrweb event dropped (${(G/1048576).toFixed(1)} MiB > chunk cap) — replay may be incomplete from here`},$);let J=new Date().toISOString(),{tabId:X,tabHost:V}=$;for(let G of Q)if(!m3({sessionId:z.sessionId,ts:J,tabId:X,tabHost:V,kind:"chunk",part:G}))return 0;return u2(),Q.length}async function q7(x=5){let $=j0();if($.length===0)return!0;let z=L(),Q=0,Z=new Set;for(let J of $){if(Q>=x)break;if(Q++,!z||J.sessionId!==z.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${J.seq} from ended session ${J.sessionId}`),Z.add(J.seq);continue}try{let X=await v4(z.sessionId,J.seq,J.body);if(x0(z))return j0().length===0;u3({seq:J.seq,ts:J.ts,tabId:J.tabId,tabHost:J.tabHost,kind:"rrweb",payload:{count:J.count},blobKey:X.blobKey}),v2(),Z.add(J.seq)}catch(X){if(x0(z))return j0().length===0;if(X instanceof _&&u(X.status)){console.warn(`vitrinka: rrweb chunk seq ${J.seq} rejected permanently (${X.status}) — dropped`),$0(J.sessionId,new Set([J.seq])),Z.add(J.seq);continue}S0(X),console.warn("vitrinka: chunk upload failed",X);break}}if(Z.size)R3(j0().filter((J)=>!Z.has(J.seq)));return j0().length===0}async function F7(x=4){let $=y();if($.length===0)return!0;let z=L(),Q=0,Z=new Set,J=[];for(let X of $){if(Q>=x)break;if(Q++,!z||X.sessionId!==z.sessionId){console.warn(`vitrinka: dropping attachment seq ${X.seq} from ended session ${X.sessionId}`),Z.add(X.seq),J.push(X.blob);continue}let V=F0.get(X.blob)??null;if(!V){try{V=await o0().get(X.blob),r0.delete(X.blob)}catch(G){if(x0(z))return y().length===0;let Y=(r0.get(X.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${Y}/${P3})`,G),Y<P3){r0.set(X.blob,Y),S0(G);break}}if(x0(z))return y().length===0}if(!V){console.warn(`vitrinka: attachment seq ${X.seq} (${X.payload.name}) lost its bytes — its note lands without it`),$0(X.sessionId,new Set([X.seq])),Z.add(X.seq),J.push(X.blob);continue}try{let G=await h4(z.sessionId,X.seq,V);if(x0(z))return y().length===0;u3({seq:X.seq,ts:X.ts,tabId:X.tabId,tabHost:X.tabHost,kind:"attachment",payload:{...X.payload},blobKey:G.blobKey}),F0.delete(X.blob),M0.set(X.seq,X.blob),v2(),Z.add(X.seq)}catch(G){if(x0(z))return y().length===0;if(G instanceof _&&u(G.status)){console.warn(`vitrinka: attachment seq ${X.seq} rejected permanently (${G.status}) — dropped`),$0(X.sessionId,new Set([X.seq])),Z.add(X.seq),J.push(X.blob);continue}S0(G),console.warn("vitrinka: attachment upload failed",G);break}}if(Z.size)b1(),k2(y().filter((X)=>!Z.has(X.seq)));return R0(J,!0),y().length===0}var E2=null;function Y0(){if(E2)return;E2=setTimeout(()=>{E2=null,M7()},p9)}var b2=!1;async function M7(x={}){if(b2)return!1;b2=!0;try{return await K7(x)}finally{b2=!1}}async function K7(x){if(L()?.dead)return!1;if(p3(!0),E.size)await h3();if(E.size)return!1;let $=await q7(),z=x.keepalive?y().length===0:await F7(),Q=$&&z;if(!Q)Y0();let Z=L(),J=C0();if(!Z||J.length===0)return Q;let X=[],V=new Set,G=0,Y=x.keepalive?61440:h9;for(let W of J){if(X.length>=S1)break;let q=E0(JSON.stringify(W))+1;if(q>m9){console.warn(`vitrinka: event seq ${W.seq} (${q} bytes) exceeds the wire cap — dropped`),V.add(W.seq);continue}if(q>Y){if(x.keepalive)break;if(X.length===0)X.push(W),G=q;break}if(X.length>0&&G+q>Y)break;X.push(W),G+=q}if(V.size){if($0(Z.sessionId,V),f2(C0().filter((W)=>!V.has(W.seq))),!X.length)return Y0(),!1}if(!X.length)return!1;b1();try{await n("POST",`/api/v1/sessions/${Z.sessionId}/events`,{events:X},x)}catch(W){if(x0(Z))return!1;if(W instanceof _&&u(W.status))return X7(`server rejected this session (${W.status})`),!1;return S0(W),w(),console.warn("vitrinka: flush failed, retrying",W),Y0(),!1}if(x0(Z))return!0;v2(),O3=Math.max(O3,...X.map((W)=>W.seq)),J7(X);let U=new Set(X.map((W)=>W.seq));$0(Z.sessionId,U);let F=C0().filter((W)=>!U.has(W.seq));f2(F),w();for(let W of U){let q=M0.get(W);if(q===void 0)continue;M0.delete(W),p2(q)}if(F.length)Y0();return!0}function l3(){for(let x of z0.keys())g().remove(x);for(let x of E)g().remove(x.key);z0.clear(),E.clear(),s0=t0=0,f2([]),R3([]),F0.clear(),q0.clear(),M0.clear(),r0.clear(),k2([])}function _3(){if(l)clearTimeout(l),l=null;U0=[],A0=[],T0=0,C1=[],F0.clear(),q0.clear(),M0.clear(),E.clear(),s0=t0=0,z0.clear(),Q0=!0}var c3="0.9.2";var kz={from:"page",inst:y4("p")};var D7=!1;function i3(){return D7}var n3="vitrinka.report.face",o3=(x)=>x.trim().replace(/\/+$/,"");function f1(){try{return globalThis.localStorage??null}catch{return null}}function b0(x){let $=X0();if(!$)return!1;if($.base)return o3($.base)===o3(x);try{let z=D1(x);return z===void 0||z===$.workspace}catch{return!1}}function K0(x){return b0(x)?X0()?.token??"":""}function a3(x){return/revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(x)}function H7(){let x=f1()?.getItem(n3);return x==="recorder"||x==="report"?x:null}function l2(x){try{f1()?.setItem(n3,x)}catch($){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",$)}}var r3="vitrinka.report.mode";function s3(x){try{if(x==="dev"||x==="regular")f1()?.setItem(r3,x)}catch($){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",$)}}function t3(x){if(!b0(x))return"report";let $=H7();if($)return $;return f1()?.getItem(r3)==="dev"?"recorder":"report"}function e3(){return L()!==null||i3()}function y1(x){let $=C().watch?.(l0,()=>x()),z=R4(x);return()=>{$?.(),z()}}var x6=["bug","suggestion","question","other"];function w0(x,$,z,Q){if(x===1)return $;if(x>=2&&x<=4)return z;return Q}var N7={button:"Report a problem",title:"Report a problem",close:"Close",settings:"Settings",prompt:"What went wrong?",placeholder:"Tell us what happened and what you expected",attached:(x)=>{if(x<60)return`The last ${x} seconds are attached`;let $=Math.round(x/60);return $===1?"The last minute is attached":`The last ${$} minutes are attached`},included:"What’s included",incReplay:"A replay of what happened on this page",incReplayMasked:{strict:"Text on the page and anything you typed are hidden in it",balanced:"Anything you typed is hidden in it",full:"It shows the page as you saw it"},incErrors:"Errors the page ran into",incConsole:"Messages from the browser console",incNetwork:"Which addresses the page loaded, with their status",incFailedRequests:"Requests that failed — address and status only",incEnv:"Your browser, screen size, language and this page’s address",incIdentity:"Your name and email from this app",incMarks:"The places you marked, with your notes",showWhere:"Show us where",kinds:{bug:"Bug",suggestion:"Suggestion",question:"Question",other:"Other"},kindsLabel:"What is it?",linesEmpty:"Each place you mark gets a line here for its note.",notify:"Email me when it’s fixed",send:"Send",sending:"Sending…",retry:"Try again",errorCreate:"Couldn’t send — your text is safe, try again",errorCapture:"Your report arrived, the recording not yet — try again to attach it",sentTitle:"Thanks — we’ve got it",sentBody:"The team will take a look.",sentNotify:"We’ll email you when it’s fixed.",seeReport:"See your report",tools:{circle:"Circle",box:"Box",arrow:"Arrow",hide:"Cover"},toolbar:"Marking tools",barLead:"Mark where the problem is",barLeadHide:"Cover what the team shouldn’t see",cancelMarking:"Cancel",discardMarks:(x)=>x===1?"Discard 1 mark?":`Discard ${x} 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:(x)=>`Mark ${x}`,removeMark:(x)=>`Remove mark ${x}`,shortcut:"Keyboard shortcut",shortcutHint:"Opens Report a problem anywhere in this app.",notSet:"Not set",recordShortcut:"Record a new shortcut",pressKeys:"Press keys · Esc cancels",needModifier:"Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing",removeShortcut:"Remove",back:"Back",account:"Your account",menu:"Menu",anonymous:"Not signed in",anonymousHint:"The team checks your report before it’s filed.",signedInByApp:"Signed in by this app",linkVitrinka:"Link your vitrinka account",linkedAs:(x)=>`Linked to vitrinka as ${x}`,unlink:"Unlink",myReports:"My reports",recentRecordings:"Recent recordings",record:"Record",recordHasDraft:"Send or clear the report you started first",openVitrinka:"Open vitrinka",openPortal:"Open the report portal",loading:"Loading…",listFailed:"Couldn’t load — try again",noReports:"No reports yet.",noRecordings:"No recordings yet.",fromThisBrowser:"Sent from this browser",steps:{received:"Received",planned:"Planned",in_progress:"In progress",fixed:"Fixed",done:"Done"},waiting:"Waiting for approval",sentQueued:"The team checks it before it’s filed.",linkCode:"Your code",linkHint:"Approve this code in vitrinka — on this device or another one where you’re signed in.",linkWaiting:"Waiting for approval…",linkExpired:"The code expired.",linkFailed:"Linking didn’t work.",attach:"Attach a file",removeFile:(x)=>`Remove ${x}`,fileTooBig:(x,$)=>`${x} is over the ${$} limit`,tooManyFiles:(x)=>x===1?"Up to 1 file per report":`Up to ${x} files per report`,fileType:(x,$)=>`${x} can’t be attached — ${$} only`,typeNames:{image:"images",pdf:"PDF",text:"text files",office:"office documents"},incFiles:"The files you attached",errorFiles:"Your report arrived, a file not yet — try again to attach it",moveHint:"Click, hold and move it to another corner, or press Alt and an arrow key.",size:"Size",sizes:{sm:"Small",md:"Medium",lg:"Large"},techDetails:"Technical details",techVersion:"Version",techWindow:"Capture window",techCapture:"Capture",techBuffer:"Buffer",techServer:"Server",captureOn:"Running",captureOff:"Off",captureStarting:"Starting…",bufferMemory:"In memory",bufferBrowser:"In this browser",windowLength:(x)=>{if(x<60)return x===1?"1 second":`${x} seconds`;let $=Math.round(x/60);return $===1?"1 minute":`${$} minutes`}},P7={button:"Nahlásit problém",title:"Nahlásit problém",close:"Zavřít",settings:"Nastavení",prompt:"Co se pokazilo?",placeholder:"Napište, co se stalo a co jste čekali",attached:(x)=>{if(x<60)return w0(x,"Poslední sekunda je přiložena",`Poslední ${x} sekundy jsou přiloženy`,`Posledních ${x} sekund je přiloženo`);let $=Math.round(x/60);return w0($,"Poslední minuta je přiložena",`Poslední ${$} minuty jsou přiloženy`,`Posledních ${$} minut je přiloženo`)},included:"Co je přiloženo",incReplay:"Záznam toho, co se na stránce dělo",incReplayMasked:{strict:"Texty stránky i vše, co jste napsali, jsou v něm skryté",balanced:"Vše, co jste napsali, je v něm skryté",full:"Ukazuje stránku tak, jak jste ji viděli"},incErrors:"Chyby, na které stránka narazila",incConsole:"Zprávy z konzole prohlížeče",incNetwork:"Které adresy stránka načítala a s jakým výsledkem",incFailedRequests:"Požadavky, které selhaly — jen adresa a výsledek",incEnv:"Váš prohlížeč, velikost obrazovky, jazyk a adresa stránky",incIdentity:"Vaše jméno a e-mail z této aplikace",incMarks:"Místa, která jste označili, i s poznámkami",showWhere:"Ukažte nám kde",kinds:{bug:"Chyba",suggestion:"Návrh",question:"Dotaz",other:"Jiné"},kindsLabel:"Co to je?",linesEmpty:"Každé označené místo tu dostane řádek pro poznámku.",notify:"Pošlete mi e-mail, až to bude opravené",send:"Odeslat",sending:"Odesílám…",retry:"Zkusit znovu",errorCreate:"Nepodařilo se odeslat — váš text zůstal, zkuste to znovu",errorCapture:"Hlášení dorazilo, záznam zatím ne — zkuste to znovu a přiložíme ho",sentTitle:"Díky — máme to",sentBody:"Tým se na to podívá.",sentNotify:"Až to bude opravené, pošleme vám e-mail.",seeReport:"Zobrazit hlášení",tools:{circle:"Kruh",box:"Obdélník",arrow:"Šipka",hide:"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:(x)=>w0(x,"Zahodit 1 značku?",`Zahodit ${x} značky?`,`Zahodit ${x} 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:(x)=>`Značka ${x}`,removeMark:(x)=>`Odebrat značku ${x}`,shortcut:"Klávesová zkratka",shortcutHint:"Otevře Nahlásit problém kdekoli v této aplikaci.",notSet:"Nenastavena",recordShortcut:"Nahrát novou zkratku",pressKeys:"Stiskněte klávesy · Esc zruší",needModifier:"Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní",removeShortcut:"Odebrat",back:"Zpět",account:"Váš účet",menu:"Nabídka",anonymous:"Nepřihlášeno",anonymousHint:"Hlášení nejdřív zkontroluje tým.",signedInByApp:"Přihlášen touto aplikací",linkVitrinka:"Propojit s vitrinkou",linkedAs:(x)=>`Propojeno s vitrinkou jako ${x}`,unlink:"Odpojit",myReports:"Moje hlášení",recentRecordings:"Nedávné nahrávky",record:"Nahrávat",recordHasDraft:"Odešlete nebo smažte rozepsané hlášení",openVitrinka:"Otevřít vitrinku",openPortal:"Otevřít portál hlášení",loading:"Načítám…",listFailed:"Nepodařilo se načíst — zkuste to znovu",noReports:"Zatím žádná hlášení.",noRecordings:"Zatím žádné nahrávky.",fromThisBrowser:"Odesláno z tohoto prohlížeče",steps:{received:"Přijato",planned:"Naplánováno",in_progress:"Řešíme",fixed:"Opraveno",done:"Hotovo"},waiting:"Čeká na schválení",sentQueued:"Než ho zařadíme, tým ho zkontroluje.",linkCode:"Váš kód",linkHint:"Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.",linkWaiting:"Čekám na schválení…",linkExpired:"Kód vypršel.",linkFailed:"Propojení se nepodařilo.",attach:"Přiložit soubor",removeFile:(x)=>`Odebrat ${x}`,fileTooBig:(x,$)=>`${x} přesahuje limit ${$}`,tooManyFiles:(x)=>w0(x,"Nejvýš 1 soubor na hlášení",`Nejvýš ${x} soubory na hlášení`,`Nejvýš ${x} souborů na hlášení`),fileType:(x,$)=>`${x} nelze přiložit — jen ${$}`,typeNames:{image:"obrázky",pdf:"PDF",text:"textové soubory",office:"kancelářské dokumenty"},incFiles:"Soubory, které jste přiložili",errorFiles:"Hlášení dorazilo, soubor zatím ne — zkuste to znovu a přiložíme ho",moveHint:"Klikněte, podržte a veďte ho do jiného rohu, nebo stiskněte Alt a šipku.",size:"Velikost",sizes:{sm:"Malá",md:"Střední",lg:"Velká"},techDetails:"Technické údaje",techVersion:"Verze",techWindow:"Okno záznamu",techCapture:"Záznam",techBuffer:"Vyrovnávací paměť",techServer:"Server",captureOn:"Běží",captureOff:"Vypnutý",captureStarting:"Spouští se…",bufferMemory:"V paměti",bufferBrowser:"V tomto prohlížeči",windowLength:(x)=>{if(x<60)return w0(x,"1 sekunda",`${x} sekundy`,`${x} sekund`);let $=Math.round(x/60);return w0($,"1 minuta",`${$} minuty`,`${$} minut`)}},B7={cs:P7,en:N7};function c2(x){return B7[x]}function x1(x){if(typeof x!=="string")return null;let $=x.trim().toLowerCase().split(/[-_]/)[0];return $==="cs"||$==="en"?$:null}function i2(){let x=globalThis.navigator,$=x?x.languages?.length?x.languages:[x.language]:[];for(let z of $){let Q=x1(z);if(Q)return Q}return"en"}var $6="recents",z6=5,O7=["recording","saved","unsaved","deleted"];function L7(x){if(!x||typeof x!=="object")return!1;let $=x;return typeof $.sessionId==="string"&&typeof $.title==="string"&&typeof $.startedAt==="number"&&O7.includes($.status)}var f0;function o2(){if(f0===void 0)try{let x=JSON.parse(C().getString($6)??"[]");f0=Array.isArray(x)?x.filter(L7).slice(0,z6):[]}catch{f0=[]}return f0}function I7(x){f0=x.slice(0,z6);try{C().set($6,JSON.stringify(f0))}catch($){console.warn("vitrinka: could not store recent recordings",$)}w()}function Q6(x,$){let z=o2();if(!z.some((Q)=>Q.sessionId===x))return;I7(z.map((Q)=>Q.sessionId===x?{...Q,...$}:Q))}var $1="data-vitrinka-recorder";var n2="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;",Z6=n2;var g7=["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 G6(x){for(let $ of g7)x.addEventListener($,(z)=>z.stopPropagation())}var _7=["keydown","keyup","keypress"],A7=["vitrinkaHud","vitrinkaSheet"],J6=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),C7=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),T7=new Set(["text","search","email","url","tel","password","number"]);function R7(x){let $=x.key.length===1;if($&&x.getModifierState?.("AltGraph"))return!0;if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return $||J6.has(x.key);if(J6.has(x.key))return!0;return(x.ctrlKey||x.metaKey)&&!x.altKey&&C7.has(x.code)}function S7(x){if(typeof x!=="object"||x===null)return!1;if("isContentEditable"in x&&x.isContentEditable===!0)return!0;let $="tagName"in x&&typeof x.tagName==="string"?x.tagName:"";if($==="TEXTAREA")return!0;return $==="INPUT"&&"type"in x&&typeof x.type==="string"&&T7.has(x.type)}function E7(x){if(typeof x!=="object"||x===null||!("dataset"in x))return!1;let $=x.dataset;return typeof $==="object"&&$!==null&&A7.some((z)=>(z in $))}function b7(x){if(!R7(x))return!1;let $=x.composedPath();return S7($[0])&&$.some(E7)}var X6=0,k1=null;function j6(){if(X6++,!k1&&typeof window<"u"){let $=(Q)=>{if(b7(Q))Q.stopImmediatePropagation()},z=_7.map((Q)=>R(window,Q,$,{capture:!0}));k1=()=>{for(let Q of z)Q()}}let x=!0;return()=>{if(!x)return;if(x=!1,--X6>0)return;k1?.(),k1=null}}function Y6(){let x=document.createElement("div");x.setAttribute($1,""),x.setAttribute("data-vitrinka-hud",""),x.style.cssText=n2;let $=x.attachShadow({mode:"open"}),z=document.createElement("div");$.append(z),G6(x);let Q=j6();document.documentElement.append(x);let Z=typeof x.showPopover==="function",J=()=>{if(!Z||!x.isConnected)return;try{x.hidePopover?.()}catch{}try{x.showPopover?.()}catch{}};if(Z)x.popover="manual";J();let X=!1,V=()=>{if(X)return;X=!0,queueMicrotask(()=>{X=!1,J()})},G=(q)=>{if(q.type==="attributes")return q.target instanceof Element&&V6(q.target);for(let M of[q.addedNodes,q.removedNodes])for(let H of M){if(!(H instanceof Element))continue;if(V6(H))return!0;if(H.childElementCount>0&&H.querySelector(W6))return!0}return!1},Y=[],U=0,F=()=>{U=0;let q=Y;if(Y=[],q.some(G))V()},W=new MutationObserver((q)=>{for(let M of q)Y.push(M);if(U===0)U=typeof requestAnimationFrame==="function"?requestAnimationFrame(F):setTimeout(F,16)});return W.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["open","data-state"]}),{host:x,mount:z,destroy:()=>{if(Q(),W.disconnect(),U!==0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(U);Y=[];try{x.hidePopover?.()}catch{}x.remove()}}}var W6='dialog,[role="dialog"]';function V6(x){return x.matches(W6)}function U6(){let x=document.querySelectorAll("dialog[open]"),$=x[x.length-1];if($)return $;let z=document.querySelectorAll('[role="dialog"][data-state="open"]');return z[z.length-1]??null}function q6(x){let $=document.createElement("div");$.setAttribute($1,""),$.setAttribute("data-vitrinka-sheet",""),$.style.cssText=Z6;let z=$.attachShadow({mode:"open"}),Q=document.createElement("div");z.append(Q),G6($);let Z=j6();return x.append($),{mount:Q,destroy:()=>{Z(),$.remove()}}}function F6(x){if(!(x instanceof Node))return!1;let $=x instanceof Element?x:x.parentElement;return Boolean($?.closest("[data-vitrinka-hud],[data-vitrinka-sheet]"))}var w7="me";var f7;function M6(){f7=null,C().remove(w7)}function K6(x){if(!x)return 0;let $=x.activeMs||0;if(!x.paused&&x.resumeAt)$+=Date.now()-Date.parse(x.resumeAt);return $}function D6(){H1(),M6();let x=L();if(x)Q6(x.sessionId,{status:"unsaved",durationMs:K6(x)}),E1(null),l3(),E3(x.sessionId);w()}var Z0={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function y7(x,$){return typeof x==="number"&&Number.isInteger(x)&&x>0?x:$}function H6(x){if(typeof x!=="object"||x===null)return Z0;let $={...x},z=Array.isArray($.types)?$.types.filter((Q)=>typeof Q==="string"&&Q.trim()!=="").map((Q)=>Q.trim().toLowerCase()):[];return{maxBytes:y7($.maxBytes,Z0.maxBytes),maxCount:typeof $.maxCount==="number"&&Number.isInteger($.maxCount)&&$.maxCount>=0?$.maxCount:Z0.maxCount,types:z.length?z:Z0.types}}function k7(x,$){let z=x.type.toLowerCase(),Q=x.name.toLowerCase();return $.some((Z)=>{if(Z==="*"||Z==="*/*")return!0;if(Z.startsWith("."))return Q.endsWith(Z);if(Z.endsWith("/*"))return z.startsWith(Z.slice(0,-1));return z===Z})}function p7(x,$){return x.name===$.name&&x.size===$.size&&x.lastModified===$.lastModified}function N6(x,$,z){let Q=[],Z=null;for(let J of $){if([...x,...Q].some((X)=>p7(X,J)))continue;if(!k7(J,z.types))Z??={kind:"type",name:J.name};else if(J.size>z.maxBytes)Z??={kind:"size",name:J.name,cap:z.maxBytes};else if(x.length+Q.length>=z.maxCount)Z??={kind:"count",cap:z.maxCount};else Q.push(J)}return{files:Q,refusal:Z}}function z1(x,$){let z=(Q,Z,J)=>`${new Intl.NumberFormat($,{maximumFractionDigits:J}).format(Q)} ${Z}`;if(x<1024)return z(x,"B",0);if(x<1048576)return z(x/1024,"kB",0);return z(x/1048576,"MB",x<10485760?1:0)}function P6(x,$,z){let Q=(J)=>{if(J.startsWith("image/"))return $.image;if(J==="application/pdf"||J===".pdf")return $.pdf;if(J.startsWith("text/"))return $.text;if(/officedocument|msword|ms-excel|ms-powerpoint|opendocument/.test(J))return $.office;return J.startsWith(".")?J:J.split("/")[1]??J},Z=x.map(Q);return new Intl.ListFormat(z,{type:"conjunction"}).format([...new Set(Z)])}function B6(x,$){let z=/^image\.(\w+)$/i.exec(x);return z?`pasted-${$}.${z[1]}`:x}var a2=["sm","md","lg"],Q1={sm:0.88,md:1,lg:1.18},r2="vitrinka.report.size";function O6(){try{return globalThis.localStorage??null}catch{return null}}function p1(x){return O6()?.getItem(x)??null}function Z1(x,$){try{O6()?.setItem(x,$)}catch(z){console.warn(`vitrinka: could not remember ${x} on this browser`,z)}}function L6(){let x=p1(r2);return a2.find(($)=>$===x)??"md"}var s2="vitrinka.report.coach";function I6(){return p1(s2)!=="off"}function g6(x,$){let z=x.config,Q=!x.engine||z?.capturing===!1?$.captureOff:z?$.captureOn:$.captureStarting,Z=x.base;try{Z=new URL(x.base).host}catch{}return[[$.techVersion,`@vitrinka/web ${x.version}`],[$.techWindow,z?$.windowLength(z.profile.windowSec):"—"],[$.techCapture,Q],[$.techBuffer,z?`${z.profile.storage==="browser"?$.bufferBrowser:$.bufferMemory} · ${z1(z.profile.maxBytes,x.locale)}`:"—"],[$.techServer,Z]]}var _6="vitrinka.report.dock",A6=6,t2={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},v7=["br","bl","tr","tl"];function h7(x){return x==="tl"||x==="tr"?"t":"b"}function m7(x){return x==="tl"||x==="bl"?"l":"r"}function C6(){let x=p1(_6);return v7.find(($)=>$===x)??"br"}function T6(x){Z1(_6,x)}function R6(x,$,z){return t2[x.y<z/2?"t":"b"][x.x<$/2?"l":"r"]}function S6(x,$){if($==="ArrowLeft"||$==="ArrowRight")return t2[h7(x)][$==="ArrowLeft"?"l":"r"];if($==="ArrowUp"||$==="ArrowDown")return t2[$==="ArrowUp"?"t":"b"][m7(x)];return null}var u7=8192,J1="__vitrinkaRecorderConsolePatched";function v1(x){return x.map(($)=>{if(typeof $==="string")return $;if($ instanceof Error)return $.stack??$.message;try{return JSON.stringify($)}catch{return String($)}}).join(" ").slice(0,u7)}function h1(x,$="error"){if(!x||x.startsWith("vitrinka:"))return;e0("console",{level:$,text:Z3(x)},{tabId:O.tabId,tabHost:O.tabHost})}var e2="__vitrinkaRecorderConsoleUnpatch",E6={};function b6(){let x=globalThis;if(x[J1]!==void 0&&x[J1]!==E6)return;x[e2]?.()}function w6(x={}){let $=globalThis;if($[J1])return;$[J1]=E6;let z=console.error,Q=z.bind(console),Z=(...Y)=>{Q(...Y);try{h1(v1(Y))}catch{}};console.error=Z;let J=(x.levels??[]).map((Y)=>{let U=console[Y],F=U.bind(console),W=(...q)=>{F(...q);try{h1(v1(q),Y)}catch{}};return console[Y]=W,()=>{if(console[Y]===W)console[Y]=U}}),X=(Y)=>{try{h1(v1([Y.error??Y.message]))}catch{}},V=(Y)=>{try{h1(`unhandled rejection: ${v1([Y.reason])}`)}catch{}},G=typeof addEventListener==="function";if(G)addEventListener("error",X),addEventListener("unhandledrejection",V);$[e2]=()=>{if(console.error===Z)console.error=z;for(let Y of J)Y();if(G)removeEventListener("error",X),removeEventListener("unhandledrejection",V);delete $[J1],delete $[e2]}}var f6=65536,X1=524288,y6=3000;var x5="full";function z5(){if(m0.following)return null;let x=L();if(x)return!x.paused&&!x.dead?x.sessionId:null;return K3()}function V1(x){return x!==null&&z5()===x}function m1(x,$){if(typeof x==="string")return H2(x,f6,$);if(typeof URLSearchParams<"u"&&x instanceof URLSearchParams)return H2(x.toString(),f6,"application/x-www-form-urlencoded");return d7(x)}function d7(x){if(x==null)return;if(typeof FormData<"u"&&x instanceof FormData){let $=0;try{x.forEach(()=>$++)}catch{}return`[formdata body omitted: ${$} field(s)]`}if(typeof Blob<"u"&&x instanceof Blob)return`[blob body omitted: ${x.size} bytes${x.type?`, ${x.type}`:""}]`;if(x instanceof ArrayBuffer)return`[buffer body omitted: ${x.byteLength} bytes]`;if(ArrayBuffer.isView(x))return`[buffer body omitted: ${x.byteLength} bytes]`;if(typeof ReadableStream<"u"&&x instanceof ReadableStream)return"[stream body omitted]";return`[${typeof x} body omitted]`}function $5(x){for(let[$,z]of Object.entries(x??{}))if($.toLowerCase().replace(/[-_]/g,"")==="contenttype")return z;return""}function Q5(x){return typeof x==="string"||x instanceof URL?{}:x}function G1(x){let $=typeof x.url==="string"?V0(x.url):x.url;e0("net",{...x,url:$},{tabId:O.tabId,tabHost:O.tabHost})}function Z5(x){if(!x)return;try{let $={},z=x;if(typeof z.forEach==="function")if(Array.isArray(x)){for(let Q of x)if(Array.isArray(Q)&&Q.length>=2)$[String(Q[0])]=String(Q[1])}else z.forEach((Q,Z)=>{$[Z]=String(Q)});else if(typeof x==="object")for(let[Q,Z]of Object.entries(x))$[Q]=String(Z);return Object.keys($).length>0?$:void 0}catch{return}}function l7(x,$){let z=Z5($?.headers);if(z)return z;let Q=Q5(x);return Z5(Q.headers)}function c7(x){if(!x)return;let $={};for(let z of x.split(/\r?\n/)){let Q=z.indexOf(":");if(Q>0)$[z.slice(0,Q).trim()]=z.slice(Q+1).trim()}return Object.keys($).length>0?$:void 0}function J5(x){try{x.body?.cancel?.().catch(()=>{return})}catch{}}function i7(x){let $=x.get("content-length");if(!$)return null;let z=Number($);return Number.isFinite(z)?z:null}async function o7(x,$){let z=await n7(x,$);if(z===void 0)return;let Q="";try{Q=$.get("content-type")??""}catch{}return m1(z,Q)}async function n7(x,$){let z=i7($);if(z!==null&&z>X1)return J5(x),`[body omitted: ${z} bytes]`;let Q=x.body;if(Q?.getReader){let Z=Q.getReader(),J=[],X=0,V=!1,G=!1,Y=Date.now()+y6;try{while(X<X1){let q=Y-Date.now();if(q<=0){G=!0;break}let M,H=await Promise.race([Z.read(),new Promise((B)=>{M=setTimeout(()=>B("timeout"),q)})]).finally(()=>{if(M!==void 0)clearTimeout(M)});if(H==="timeout"){G=!0;break}let{done:D,value:N}=H;if(D)break;if(N){let B=X1-X,K=N.byteLength>B?N.subarray(0,B):N;J.push(K),X+=K.byteLength}}V=X>=X1,Z.cancel().catch(()=>{return})}catch{return}let U=new Uint8Array(X),F=0;for(let q of J)U.set(q,F),F+=q.byteLength;let W;try{W=new TextDecoder().decode(U)}catch{return`[body omitted: ${X} bytes, undecodable]`}if(G)return`${W}…[body read timed out after ${y6}ms]`;return V?`${W}…[truncated at ${X1} bytes]`:W}if(z===null)return J5(x),"[body omitted: length-less response, no stream API]";try{return await x.text()}catch{return}}var j1="__vitrinkaRecorderNetPatched",X5="__vitrinkaRecorderNetUnpatch",k6={};function p6(){let x=globalThis;if(x[j1]!==void 0&&x[j1]!==k6)return;x[X5]?.()}function v6(x={}){let $=globalThis;if($[j1])return;$[j1]=k6,x5=x.detail??"full";let z=[];$[X5]=()=>{for(let W of z.splice(0))W();delete $[j1],delete $[X5]};let Q=globalThis.fetch,Z=async(W,q)=>{let M=typeof W==="string"?W:W instanceof URL?W.href:W.url,H=z5();if(Y2(M)||H===null)return Q(W,q);let D=q?.method??("method"in Q5(W)?Q5(W).method:"GET"),N=Date.now();try{let B=await Q(W,q),K=Date.now()-N;if(x5==="meta"){if(V1(H))G1({method:D,url:M,status:B.status,ms:K,via:"fetch"});return B}let T;try{T=B.clone()}catch{T=void 0}let{headers:y0,status:k0}=B;return m2((async()=>{if(!V1(H)){if(T)J5(T);return}let M1=T?await o7(T,y0):void 0;if(!V1(H))return;let p0=l7(W,q);G1({method:D,url:M,status:k0,ms:K,reqHeaders:c0(p0),resHeaders:c0(Z5(y0)),reqBody:m1(q?.body,$5(p0)),resBody:M1,via:"fetch"})})()),B}catch(B){if(V1(H))G1({method:D,url:M,error:String(B),ms:Date.now()-N,via:"fetch"});throw B}};globalThis.fetch=Z,z.push(()=>{if(globalThis.fetch===Z)globalThis.fetch=Q});let J=globalThis.XMLHttpRequest;if(!J?.prototype)return;let X=J.prototype.open,V=J.prototype.send,G=J.prototype.setRequestHeader;z.push(()=>{let W=J.prototype;if(W.open===Y)W.open=X;if(W.send===F)W.send=V;if(W.setRequestHeader===U)W.setRequestHeader=G});let Y=J.prototype.open=function(...W){return this.__vt={method:W[0],url:String(W[1])},X.apply(this,W)},U=J.prototype.setRequestHeader=function(W,q){let M=this.__vt;if(M)(M.reqHeaders??={})[W]=q;return G?.call(this,W,q)},F=J.prototype.send=function(W){let q=this.__vt,M=z5();if(q&&!Y2(q.url)&&M!==null){let H=Date.now();this.addEventListener("loadend",()=>{if(!V1(M))return;if(x5==="meta"){G1({method:q.method,url:q.url,status:this.status,ms:Date.now()-H,via:"xhr"});return}let D;try{D=c7(this.getAllResponseHeaders())}catch{D=void 0}let N;try{N=this.responseType===""||this.responseType==="text"?m1(this.responseText,$5(D)):void 0}catch{N=void 0}G1({method:q.method,url:q.url,status:this.status,ms:Date.now()-H,reqHeaders:c0(q.reqHeaders),resHeaders:c0(D),reqBody:m1(W,$5(q.reqHeaders)),resBody:N,via:"xhr"})})}return V.call(this,W)}}var a7=2000,r7=300000,W1=null,U1=null,Y1=[],u1=null;function h6(){if(!Y1.length)return;let x=Y1;Y1=[],d3(x,{tabId:O.tabId,tabHost:O.tabHost})}function q1(){return U1}function m6(x,$,z={}){if(W1)return;let Q=X3(),Z=z.unmaskSelector;try{W1=x({emit:$==="flight"?(X)=>D3(B2(X)):(X)=>{Y1.push(B2(X))},checkoutEveryNms:$==="flight"?U3().checkoutMs:r7,inlineImages:!1,collectFonts:!0,maskAllInputs:Q.maskAllInputs,...Q.maskTextSelector?{maskTextSelector:Q.maskTextSelector}:{},...Q.maskTextSelector&&Z?{maskTextFn:(X,V)=>{try{if(V?.closest(Z))return X}catch{}return X.replace(/\S/g,"*")}}:{},blockSelector:`[${$1}]`})??null}catch(J){console.warn("vitrinka: rrweb failed to start",J);return}if(U1=x,$==="flight")_2(d1);if($==="session")u1=setInterval(h6,a7)}function u6(){if(u1)clearInterval(u1);u1=null,h6();try{W1?.()}catch{}W1=null,U1=null,_2(null),Y1=[]}function d1(){if(!W1||!U1)return;try{U1.takeFullSnapshot?.(!0)}catch{}}var c6="vitrinka.capture",k="windows",p="chunks";function D0(x){return new Promise(($,z)=>{x.oncomplete=()=>$(),x.onabort=x.onerror=()=>z(x.error??Error("vitrinka: capture store transaction failed"))})}function V5(x){return new Promise(($,z)=>{x.onsuccess=()=>$(x.result),x.onerror=()=>z(x.error??Error("vitrinka: capture store request failed"))})}function d6(x){return IDBKeyRange.bound([x,0],[x,Number.MAX_SAFE_INTEGER])}function l6(x){if(typeof x!=="object"||x===null)return!1;let $=x;return typeof $.id==="string"&&typeof $.tab==="string"&&typeof $.startMs==="number"&&typeof $.lastMs==="number"}function i6(x=globalThis.indexedDB){if(!x)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise(($,z)=>{let Q=x.open(c6,1);Q.onupgradeneeded=()=>{Q.result.createObjectStore(k,{keyPath:"id"}),Q.result.createObjectStore(p)},Q.onerror=()=>z(Q.error??Error("vitrinka: capture store did not open")),Q.onblocked=()=>z(Error("vitrinka: capture store is blocked by another tab")),Q.onsuccess=()=>$(Q.result)}).then(($)=>{$.onversionchange=()=>$.close();let z=(Z,J)=>{Z.objectStore(k).delete(J),Z.objectStore(p).delete(d6(J))};return{async putWindow(Z){let J=$.transaction(k,"readwrite");J.objectStore(k).put(Z),await D0(J)},async putChunk(Z,J,X,V){let G=$.transaction(p,"readwrite"),Y={events:X,lanes:[...V]};G.objectStore(p).put(Y,[Z,J]),await D0(G)},async putWindowChunk(Z,J,X,V){let G=$.transaction([k,p],"readwrite"),Y={events:X,lanes:[...V]};try{G.objectStore(p).put(Y,[Z.id,J]),G.objectStore(k).put(Z)}catch(U){throw G.abort(),U}await D0(G)},async dropWindow(Z){let J=$.transaction([k,p],"readwrite");z(J,Z),await D0(J)},async clear(Z){let J=$.transaction([k,p],"readwrite"),X=await V5(J.objectStore(k).getAll());for(let V of X)if(l6(V)&&V.tab===Z)z(J,V.id);await D0(J)},async sweep(Z,J,X,V){let G=$.transaction([k,p],"readwrite"),Y=(await V5(G.objectStore(k).getAll())).filter(l6),U=[],F=new Map;for(let W of Y)F.set(W.tab,[...F.get(W.tab)??[],W]);for(let[W,q]of F){let M=q.filter((D)=>D.kind!=="lanes").sort((D,N)=>D.startMs-N.startMs),H=(D)=>D.kind==="lanes"?D.lastMs:g2(D,M[M.indexOf(D)+1]);for(let D of q.sort((N,B)=>N.startMs-B.startMs))if(H(D)<=Z-J||W===X&&D.scope!==V)z(G,D.id);else if(W===X)U.push(D)}return await D0(G),U},async read(Z){let J=$.transaction(p,"readonly"),X=await V5(J.objectStore(p).getAll(d6(Z)));await D0(J);let V=[],G=[];for(let Y of X)V.push(...JSON.parse(Y.events)),G.push(...Y.lanes);return{events:V,lanes:G}},close:()=>$.close()}})}function o6(x=globalThis.indexedDB){try{x?.deleteDatabase(c6)}catch($){console.warn("vitrinka: could not delete the capture store",$)}}function G5(x,$){return{x:Math.min(x.x,$.x),y:Math.min(x.y,$.y),w:Math.abs($.x-x.x),h:Math.abs($.y-x.y)}}function j5(x,$){return`${$.y<x.y?"n":"s"}${$.x<x.x?"w":"e"}`}function Y5(x,$){let z=x.x,Q=x.x+x.w,Z=x.y,J=x.y+x.h,X={x:$.endsWith("w")?z:Q,y:$.startsWith("n")?Z:J};return{tail:{x:$.endsWith("w")?Q:z,y:$.startsWith("n")?J:Z},tip:X}}function n6(x,$,z){if(x==="arrow")return Math.hypot(z.x-$.x,z.y-$.y)>=16;return Math.abs(z.x-$.x)>=8&&Math.abs(z.y-$.y)>=8}function a6(x){return x.map(($,z)=>({...$,n:z+1}))}function r6(x){return x.map(($)=>({n:$.n,shape:$.shape,rect:{x:Math.round($.rect.x),y:Math.round($.rect.y),w:Math.round($.rect.w),h:Math.round($.rect.h)},...$.note.trim()?{note:$.note.trim()}:{},...$.shape==="arrow"&&$.head?{head:$.head}:{}}))}var s7=2,t7=3,e7=0,x$=5,W5=2,$$=3,z$=2000000000,Q$="data-vitrinka-hidden",Z$="#1b1b1f";function J$(x,$){let z=`position:fixed;left:${Math.round(x.x)}px;top:${Math.round(x.y)}px;width:${Math.round(x.w)}px;height:${Math.round(x.h)}px;background:${Z$};z-index:2147483647;pointer-events:none;`;return{type:W5,id:z$+$,tagName:"div",attributes:{[Q$]:"",style:z},childNodes:[]}}function U5(x,$,z,Q){let Z={...x};if(x.type===$$&&$.has(x.id))Z.textContent="";if(x.attributes&&$.has(x.id)&&"value"in x.attributes)Z.attributes={...x.attributes,value:""};if(x.childNodes){if(Z.childNodes=x.childNodes.map((J)=>U5(J,$,z,Q)),!Q.done&&x.type===W5&&x.tagName==="body")Z.childNodes.push(...z),Q.done=!0}return Z}function X$(x,$){(x.childNodes?.find((Q)=>Q.type===W5)??x).childNodes?.push(...$)}function V$(x,$){return U5(x,$,[],{done:!0})}function s6(x,$,z){if(!$.length&&!z.size)return x.slice();let Q=$.map(J$);return x.map((Z)=>{let J=Z.data;if(Z.type===s7&&J.node){let X={done:!1},V=U5(J.node,z,Q,X);if(!X.done)X$(V,Q);return{...Z,data:{...Z.data,node:V}}}if(Z.type!==t7||!z.size)return Z;if(J.source===e7){let X=Z.data,V={...X,...X.texts?{texts:X.texts.map((G)=>z.has(G.id)?{...G,value:""}:G)}:{},...X.adds?{adds:X.adds.map((G)=>({...G,node:V$(G.node,z)}))}:{},...X.attributes?{attributes:X.attributes.map((G)=>z.has(G.id)&&("value"in G.attributes)?{...G,attributes:{...G.attributes,value:""}}:G)}:{}};return{...Z,data:V}}if(J.source===x$){let X=Z.data;if(z.has(X.id))return{...Z,data:{...X,text:""}}}return Z})}function G$(x,$){return x.x>=$.x&&x.x<=$.x+$.w&&x.y>=$.y&&x.y<=$.y+$.h}function j$(x){return{x:x.left+x.width/2,y:x.top+x.height/2}}function q5(x,$,z=document){let Q=new Set;if(!x.length||!$||!z.body)return Q;let Z=(G)=>G.width>0&&G.height>0&&x.some((Y)=>G$(j$(G),Y)),J=(G)=>{let Y=$.getId(G);if(Y>0)Q.add(Y)},X=z.createTreeWalker(z.body,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),V=z.createRange();for(let G=X.nextNode();G;G=X.nextNode())if(G.nodeType===Node.TEXT_NODE){if(!G.textContent?.trim())continue;if(V.selectNodeContents(G),Z(V.getBoundingClientRect()))J(G)}else if(G instanceof HTMLInputElement||G instanceof HTMLTextAreaElement||G instanceof HTMLSelectElement){if(Z(G.getBoundingClientRect()))J(G)}return V.detach(),Q}var Y$=["errors","interactions","full","console","network"];var l1={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function o1(x){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:x===!1?["errors"]:["errors","interactions"]}}function c1(x,$,z){return Math.min(z,Math.max($,x))}function W$(x){if(!Array.isArray(x))return null;return Y$.filter(($)=>x.includes($))}function t6(x,$){if(typeof x!=="object"||x===null)return o1($);let z=x;return{storage:z.storage==="browser"?"browser":z.storage==="memory"?"memory":l1.storage,windowSec:typeof z.windowSec==="number"&&Number.isFinite(z.windowSec)?c1(Math.round(z.windowSec),10,3600):l1.windowSec,maxBytes:typeof z.maxBytes==="number"&&Number.isFinite(z.maxBytes)?c1(Math.round(z.maxBytes),262144,67108864):l1.maxBytes,classes:W$(z.classes)??l1.classes}}function i1(x){let $=x.includes("full");return{replay:$||x.includes("interactions"),errors:$||x.includes("errors"),console:$||x.includes("console"),network:$||x.includes("network")}}function U$(x){let $=[];if(x.errors)$.push("errors");if(x.replay)$.push("interactions");if(x.console)$.push("console");if(x.network)$.push("network");return $}function e6(x,$){if(!$)return x;let z=typeof $.windowSec==="number"&&$.windowSec>0?Math.min(x.windowSec,$.windowSec):x.windowSec,Q=typeof $.maxBytes==="number"&&$.maxBytes>0?Math.min(x.maxBytes,$.maxBytes):x.maxBytes,Z=x.classes;if($.classes){let J=i1(x.classes),X=i1($.classes);Z=U$({replay:J.replay&&X.replay,errors:J.errors&&X.errors,console:J.console&&X.console,network:J.network&&X.network})}return{storage:$.storage==="memory"?"memory":x.storage,windowSec:c1(z,10,3600),maxBytes:c1(Q,262144,67108864),classes:Z}}function x8(x){return x==="balanced"||x==="full"?x:"strict"}function $8(x){if(x==="full")return{fullFidelity:!0};if(x==="balanced")return{};return{maskAllText:!0}}var z8="[data-vitrinka-unmask]";var q$=3670016,Q8=4194240,F$=2000,Z8=500,M$=60000,K$=/[A-Za-z0-9_-]{20,}/g;function o(x,$=""){return typeof x==="string"?x:$}function D$(x){let $=o(x),z;try{z=new URL($,globalThis.location?.href??"http://localhost").pathname}catch{z=$.split(/[?#]/)[0]??""}return z.replace(K$,"•••").slice(0,300)}var H$=4;function N$(x,$){let z=[],Q=!1,Z=[],J=!1,X=()=>{if(J)Q=!0;else z.push(...Z);Z=[],J=!1};for(let V of x){if(V.type===H$&&Z.length)X();if(!J&&E0(JSON.stringify(V))+1>$)J=!0;Z.push(V)}return X(),{events:z,dropped:Q}}function P$(x){return($,z)=>{if($==="console"){let Q=o(z?.level,"error");if(Q==="error"?!(x.errors||x.console):!x.console)return null;return{level:Q,text:o(z?.text).slice(0,F$)}}if($==="net"){let Q=typeof z?.status==="number"?z.status:0,Z=Q===0||Q>=400||z?.error!==void 0;if(!(x.network||x.errors&&Z))return null;return{method:o(z?.method,"GET").toUpperCase(),path:D$(z?.url),status:Q,ms:typeof z?.ms==="number"?Math.max(0,Math.round(z.ms)):0}}return null}}async function B$(x){try{let $=await n("GET","/api/v1/report-config",void 0,{target:x}),z=typeof $.flightRecorder==="boolean"?$.flightRecorder:void 0;return{project:o($.project),profile:$.captureProfile==null?o1(z):t6($.captureProfile,z),masking:x8($.profile),reachable:!0,attachments:H6(typeof $.captureProfile==="object"&&$.captureProfile!==null&&"attachments"in $.captureProfile?$.captureProfile.attachments:$.attachments)}}catch($){return console.warn("vitrinka: report config unavailable — capturing the last minute, strictly masked",$),{project:"",profile:o1(),masking:"strict",reachable:!1,attachments:Z0}}}function J8(x){let $=x?.mirror;if(typeof $!=="object"||$===null)return null;let z=$.getId;return typeof z==="function"?{getId:(Q)=>Number(z.call($,Q))}:null}class X8{opts;ready;store=null;stopped=!1;claim=null;config=null;listeners=new Set;capturing=!1;offs=[];capture=[];constructor(x){this.opts=x;this.ready=this.start()}async start(){let{opts:x}=this;this.offs.push(w4(x.base));let $=await B$({url:x.base,key:x.key}),z=e6($.profile,x.capture),Q=i1(z.classes),Z={project:$.project,profile:z,lanes:Q,masking:$.masking,reachable:$.reachable,capturing:!1,attachments:$.attachments};if(this.stopped)return Z;if(this.config=Z,this.claim=C4("report",()=>this.standDown()),!this.claim)return console.warn("vitrinka: the recorder runs this page’s capture — Report a problem sends without one"),Z;this.capturing=!0,Z.capturing=!0,A4(_4(),globalThis.location?.host??""),O.pathname=globalThis.location?.pathname??"/",Q3($8(Z.masking)),N2(x.sanitizeUrl),this.capture.push(()=>N2(null));let J=z.windowSec*1000,X=[x.base,$.project,Z.masking,z.classes.join(",")].join("|"),V=[],G=[];if(z.storage==="browser")try{this.store=await i6();let Y=await this.store.sweep(Date.now(),J,O.tabId,X);V=Y;let U=this.store;G=(await Promise.all(Y.filter((W)=>W.kind==="lanes").map((W)=>U.read(W.id)))).flatMap((W)=>W.lanes).sort((W,q)=>Date.parse(W.ts)-Date.parse(q.ts))}catch(Y){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",Y),this.store=null,V=[],G=[]}else o6();if(!this.capturing)return this.store?.close(),this.store=null,Z;if(Y3({windowMs:J,checkoutMs:Math.min(M$,J),maxBytes:z.maxBytes,maxEvents:Math.max(20000,Math.round(z.maxBytes/200)),maxLaneEvents:I2,keepLane:P$(Q),store:this.store,scope:X,prior:V,priorLanes:G}),this.capture.push(W3),this.store&&typeof window<"u"){let Y=()=>L1();this.capture.push(R(window,"pagehide",Y),R(document,"visibilitychange",Y))}if(Q.errors||Q.console)w6({levels:Q.console?["warn","info","log"]:[]}),this.capture.push(b6);if(Q.errors||Q.network)v6({detail:"meta"}),this.capture.push(p6);if(Q.replay){let Y=await x.loadRecord(x.base).catch((U)=>{return console.warn("vitrinka: the page recorder did not load — reports go without a replay",U),null});if(Y&&this.capturing)m6(Y,"flight",{unmaskSelector:z8}),this.capture.push(u6)}return Z}onChange(x){return this.listeners.add(x),()=>this.listeners.delete(x)}standDown(){if(!this.capturing)return;if(this.capturing=!1,this.config)this.config.capturing=!1;for(let $ of this.capture.splice(0).reverse())$();let x=this.store;if(this.store=null,x)F3().then(()=>x.close());for(let $ of this.listeners)$()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};O.pathname=globalThis.location?.pathname??O.pathname;let x=g1();if(x&&q1()&&!T2(x))d1(),x=g1();let $=this.store,z=x?.windows.filter((Z)=>Z.stored).map((Z)=>Z.id)??[],Q=$&&z.length?Promise.all(z.map(async(Z)=>[Z,await $.read(Z)])).then((Z)=>new Map(Z)):Promise.resolve(new Map);return Q.catch(()=>{return}),{clip:x,stored:Q}}withScreen(x){if(!this.capturing||!q1()||x&&T2(x))return x;d1();let $=g1();if(!$)return x;return{windows:[...x?.windows.filter((z)=>z.stored)??[],...$.windows.filter((z)=>!z.stored)],lanes:x?.lanes??$.lanes,truncated:x?.truncated??$.truncated}}hiddenIdsAt(x){if(!this.capturing)return null;let $=J8(q1());return $?q5([x],$):null}async build(x,$,z=new Set){let Q=$.filter((K)=>K.shape==="hide").map((K)=>K.rect),Z=J8(q1()),J=Q.length>0&&!Z;if(J)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let X=new Set(z);if(Q.length&&Z)for(let K of q5(Q,Z))X.add(K);let V=[],G=this.withScreen(x.clip),Y=G?.truncated??!1,U=await x.stored.catch((K)=>{return console.warn("vitrinka: the stored part of the capture could not be read — the replay starts later",K),null});for(let K of G?.windows??[]){if(!K.stored){V.push(...K.events);continue}let T=U?.get(K.id);if(!T?.events.length)Y=!0;else V.push(...T.events)}let F=G?.lanes??[],W=J?{events:[],dropped:!1}:N$(s6(V,Q,X),Q8);if(W.dropped)Y=!0;let{parts:q,dropped:M}=d2(W.events,q$,Q8),H=[],D=0;for(let K of q){D+=K.count;let T=W.events[D-1]?.timestamp??Date.now();H.push({seq:H.length+1,ts:new Date(T).toISOString(),count:K.count,body:K.body})}let N=F.filter((K)=>K.kind==="console").slice(-Z8).map((K)=>({level:o(K.payload?.level,"error"),ts:K.ts,text:o(K.payload?.text)})),B=F.filter((K)=>K.kind==="net").slice(-Z8).map((K)=>({method:o(K.payload?.method,"GET"),path:o(K.payload?.path),status:typeof K.payload?.status==="number"?K.payload.status:0,ms:typeof K.payload?.ms==="number"?K.payload.ms:0}));return{chunks:H,truncated:Y||M.length>0,console:N,network:B}}clear(){if(this.capturing)q3()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),T4(this.claim),this.claim=null;for(let x of this.offs.splice(0).reverse())x()}}var h=null;function V8(x){if(h){let $=h.engine.opts;if(!($.base===x.base&&$.key===x.key&&$.sanitizeUrl===x.sanitizeUrl&&JSON.stringify($.capture??{})===JSON.stringify(x.capture??{})))return console.warn("vitrinka: one capture engine per page — this widget reports without a capture (another widget’s key, base, capture or sanitizeUrl owns it)"),null;return h.refs++,h.engine}return h={engine:new X8(x),refs:1},h.engine}function G8(x){if(!x||!h||h.engine!==x)return;if(--h.refs>0)return;h=null,x.stop()}var O$=/^[\w-]+\.[\w-]+\.[\w-]+$/;function n1(x){if(!x)return null;if("token"in x){let Q=typeof x.token==="string"?x.token.trim():"";if(Q.length>4096||!O$.test(Q))return console.warn("vitrinka: identify({token}) needs the compact JWS your server signed — reporting anonymously"),null;return{token:Q}}let $=typeof x.email==="string"?x.email.trim().slice(0,254):"";if(!$.includes("@"))return console.warn("vitrinka: identify({email}) needs an email address — reporting anonymously"),null;let z=typeof x.name==="string"?x.name.trim().slice(0,200):"";return z?{email:$,name:z}:{email:$}}var j8=null,F5=new Set;function L$(x){j8=n1(x);for(let $ of F5)$()}function Y8(){return j8}function W8(x){return F5.add(x),()=>F5.delete(x)}var I$=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),M5="report.keybind";function U8(x){if(I$.has(x.key))return{kind:"wait"};if(x.key==="Escape"&&!x.altKey&&!x.ctrlKey&&!x.metaKey&&!x.shiftKey)return{kind:"cancel"};if(!x.altKey&&!x.ctrlKey&&!x.metaKey)return{kind:"bare"};return{kind:"bind",bind:{code:x.code,alt:x.altKey,ctrl:x.ctrlKey,meta:x.metaKey,shift:x.shiftKey}}}function q8(x,$){return x.code===$.code&&x.altKey===$.alt&&x.ctrlKey===$.ctrl&&x.metaKey===$.meta&&x.shiftKey===$.shift}var g$={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function F8(x){let $=/^Key([A-Z])$/.exec(x);if($)return $[1];let z=/^(?:Digit|Numpad)(\d)$/.exec(x);if(z)return z[1];return g$[x]??x}function _$(){let x=globalThis.navigator,$=x?.userAgentData?.platform??x?.platform??"";return/mac|iphone|ipad/i.test($)}function a1(x,$=_$()){let z=F8(x.code);if($)return`${x.ctrl?"⌃":""}${x.alt?"⌥":""}${x.shift?"⇧":""}${x.meta?"⌘":""}${z}`;return[x.ctrl&&"Ctrl",x.alt&&"Alt",x.shift&&"Shift",x.meta&&"Meta",z].filter(Boolean).join("+")}function M8(x){return[x.ctrl&&"Control",x.alt&&"Alt",x.shift&&"Shift",x.meta&&"Meta",F8(x.code)].filter(Boolean).join("+")}function A$(x){if(!x)return null;try{let $=JSON.parse(x);if(typeof $!=="object"||$===null)return null;let z=$;if(typeof z.code!=="string"||!z.code)return null;let Q={code:z.code,alt:z.alt===!0,ctrl:z.ctrl===!0,meta:z.meta===!0,shift:z.shift===!0};return Q.alt||Q.ctrl||Q.meta?Q:null}catch{return null}}var C$={code:"KeyA",alt:!0,ctrl:!1,meta:!1,shift:!0},K8="off";function D8(x){if(x===K8)return null;return A$(x)??C$}function H8(){return D8(C().getString(M5))}function K5(x){C().set(M5,x?JSON.stringify(x):K8)}function N8(x){let $=C();return $.watch?$.watch(M5,(z)=>x(D8(z))):()=>{return}}var T$=["br","bl","tr","tl"];function D5(x,$){let z=x==="br"||x==="tr"?$.vw-$.w-$.edge:$.edge,Q=x==="br"||x==="bl"?$.vh-$.h-$.bottom:$.top;return{x:Math.max($.edge,z),y:Math.max($.top,Q),w:$.w,h:$.h}}function R$(x,$){let z=Math.min(x.x+x.w,$.x+$.w+12)-Math.max(x.x,$.x-12),Q=Math.min(x.y+x.h,$.y+$.h+12)-Math.max(x.y,$.y-12);return z>0&&Q>0?z*Q:0}function P8(x,$,z){let Q=D5(x,z);return $.reduce((Z,J)=>Z+R$(Q,J),0)}function B8(x,$,z){let Q=P8(x,$,z);if(Q===0)return x;let Z=x,J=Q;for(let X of T$){let V=P8(X,$,z);if(V<J)Z=X,J=V}return Z}function O8(x,$,z,Q){let Z=x==="br"||x==="bl";if($.vh-$.top-$.h-$.bottom>=z.h+Q)return Z?"above":"below";if($.vw-2*$.edge-$.w>=z.w+Q)return x==="br"||x==="tr"?"left":"right";return"over"}function N5(x){if(!(x instanceof _)||x.status!==400)return"";return/unknown field \\?"(\w+)\\?"/.exec(x.message)?.[1]??""}var L8={ms:30000,bytesPerMs:32};class I8 extends Error{constructor(x,$){super(`vitrinka: ${x} got no answer in ${Math.round($/1000)} s — Try again resumes it`);this.name="LegTimeout"}}async function H5(x,$,z){let Q=new AbortController,Z,J=new Promise((X,V)=>{Z=setTimeout(()=>{let G=new I8(x,$);Q.abort(G),V(G)},$)});try{return await Promise.race([z(Q.signal),J])}finally{clearTimeout(Z)}}var P5={chunks:[],truncated:!1,console:[],network:[]};function g8(x,$=L8.ms){return H5("preparing the capture",$,x).catch((z)=>{return console.warn("vitrinka: the capture could not be prepared — the report goes without it",z),P5})}class B5{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(x,$,z,Q=[],Z=L8){this.capture=x;this.tabHost=$;this.target=z;this.files=Q;this.limits=Z}call(x,$,z){return H5(`${x} ${$}`,this.limits.ms,(Q)=>n(x,$,z,{target:this.target,signal:Q}))}upload(x,$,z){let Q=typeof z==="string"?new TextEncoder().encode(z).byteLength:z.size,Z=this.limits.ms+Math.ceil(Q/this.limits.bytesPerMs);return H5(`POST ${x}`,Z,(J)=>q2(x,$,z,this.target,J))}get filesPending(){return this.filesDone.size<this.files.length}async run(x,$){let z={title:x.title,description:x.description,markers:x.markers,notify:x.notify??!1},Q=JSON.stringify(z);if(!this.id){let{res:J,memberSent:X}=await this.create(x);if(typeof J.id!=="string"||!J.id)throw Error("vitrinka: the server filed the report without an id");if(this.id=J.id,this.custody=J.custody==="direct"?"direct":"quarantined",this.sent=Q,typeof J.memberError==="string"&&J.memberError)$?.(J.memberError,X)}else if(this.sent!==Q)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,z),this.sent=Q;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(J){if(!(J instanceof _)||!u(J.status))throw J;console.warn("vitrinka: the server refused the recording — the report goes without it",J),this.skipCapture=!0}let Z=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:Z.status==="filed"?"filed":"quarantined",...typeof Z.reportUrl==="string"&&Z.reportUrl?{reportUrl:Z.reportUrl}:{}}}async create(x){let $=x;for(;;)try{return{res:await this.call("POST","/api/v1/reports",$),memberSent:$.memberToken??""}}catch(z){let Q=N5(z);if(Q==="type"&&$.type!==void 0){console.warn("vitrinka: this server takes no report type yet — sending the report without it");let{type:Z,...J}=$;$=J}else if(Q==="memberToken"&&$.memberToken!==void 0){console.warn("vitrinka: this server takes no member link yet — sending the report without it");let{memberToken:Z,...J}=$;$=J}else throw z}}async sendFiles(){let x=encodeURIComponent(this.id);for(let[$,z]of this.files.entries()){if(this.filesDone.has($))continue;try{await this.upload(`/api/v1/reports/${x}/attachment?name=${encodeURIComponent(z.name)}`,z.type||"application/octet-stream",z)}catch(Q){if(!(Q instanceof _)||!u(Q.status))throw Q;console.warn(`vitrinka: the server refused ${z.name} — the report goes without it`,Q)}this.filesDone.add($)}}async sendCapture(){let x=encodeURIComponent(this.id),{chunks:$,truncated:z}=this.capture;for(let Z of $){if(this.blobKeys.has(Z.seq))continue;let J=await this.upload(`/api/v1/reports/${x}/chunk?seq=${Z.seq}`,"application/json",Z.body);if(!J.blobKey)throw Error(`vitrinka: chunk ${Z.seq} came back without a blob key`);this.blobKeys.set(Z.seq,J.blobKey)}let Q=$.map((Z)=>({seq:Z.seq,ts:Z.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:Z.count,source:"replay",truncated:z},blobKey:this.blobKeys.get(Z.seq)??""}));while(this.rowsPosted<Q.length){let Z=Q.slice(this.rowsPosted,this.rowsPosted+S1);await this.call("POST",`/api/v1/reports/${x}/events`,{events:Z}),this.rowsPosted+=Z.length}}}async function r1(x,$,z,Q,Z){let J=await fetch(z.url+$,{method:x,mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${z.key}`,...Z?{"x-vitrinka-reporter":Z}:{},...Q!==void 0?{"content-type":"application/json"}:{}},body:Q===void 0?void 0:JSON.stringify(Q)}),X=await J.text();if(!J.ok)throw new _(`${x} ${$} → ${J.status}: ${X}`,J.status);return X?JSON.parse(X):{}}async function _8(x,$,z=""){if(!z)return r1("POST","/api/v1/report/session",x,{token:$});try{return await r1("POST","/api/v1/report/session",x,{token:$,memberToken:z})}catch(Z){if(N5(Z)!=="memberToken")throw Z;return console.warn("vitrinka: this server takes no member link yet — the reporter session opens without it"),r1("POST","/api/v1/report/session",x,{token:$})}}function O5(x,$){return x?JSON.stringify([x,$]):""}function A8(x,$=Date.now()){return x!==null&&Date.parse(x.expiresAt)-$>60000}function L5(x,$,z){let Q=z?`?cursor=${encodeURIComponent(z)}`:"";return r1("GET",`/api/v1/report/mine${Q}`,x,void 0,$)}function C8(x,$){return`vitrinka.report.sent:${x}|${$}`}function T8(){try{return globalThis.localStorage??null}catch{return null}}function I5(x,$){let z=T8()?.getItem(C8(x,$));if(!z)return[];try{let Q=JSON.parse(z);if(!Array.isArray(Q))return[];return Q.filter((Z)=>typeof Z?.title==="string"&&typeof Z?.at==="number"&&(Z.status==="filed"||Z.status==="quarantined"))}catch{return[]}}function R8(x,$,z){let Q=T8();if(!Q)return;let Z=[z,...I5(x,$)].slice(0,20);try{Q.setItem(C8(x,$),JSON.stringify(Z))}catch(J){console.warn("vitrinka: could not remember the sent report on this browser",J)}}var S8=`
8
+ ${g}\r
9
+ `)}return s.push(i[i.length-1]),s.join(o)}var es=262144;function Ui(e,t,n){if(e.full||!t)return t;try{if(kn(t)){if(t.length<=es)try{return JSON.stringify(xt(e,JSON.parse(t),0))}catch{}return xe(e,Ec(e,t))}let r=(n??"").toLowerCase();if(r.includes("x-www-form-urlencoded"))return wt(e,Qi(e,X,t));if(r.includes("multipart/form-data")){let o=Cc(e,t,n??"");if(o!==null)return o;return`[multipart body omitted: unparseable (${t.length} chars)]`}return wt(e,t)}catch{return"[redacted]"}}function ts(e,t){if(t===void 0)return;if(e.full)return t;if(kn(t))try{return JSON.stringify(xt(e,JSON.parse(t),0))}catch{}try{return wt(e,t)}catch{return"[redacted]"}}function ns(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(kn(t)&&t.length<=es){let i=Ui(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 Ui(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):Gi(e,s)?"[redacted]":xe(e,String(a))).slice(0,r);if(o-=s.length+d.length,o<0){i["…"]="(truncated)";break}i[s]=d}return i}function os(e){if(e.full)return{maskAllInputs:!1,maskAllText:!1};return{maskAllInputs:!0,maskAllText:e.maskAllText,...e.maskAllText?{maskTextSelector:"*"}:{}}}var Se=bn(null);function ss(e){Se=bn(e??null)}function as(e){return ts(Se,e)}function vn(e,t,n){return ns(Se,e,t,n)}var is=null,ls=null;function wn(e){ls=e??null}function Tc(e){let t=ls??We().sanitizeUrl;if(!t)return e;let n;try{let r=t(e);if(typeof r==="string")return r;n=`returned ${typeof r}`}catch{n="threw"}if(is!==t)is=t,console.warn(`vitrinka: sanitizeUrl ${n} — such URLs are recorded as their origin only`);return Mc(e)??Vi}function Mc(e){try{let{origin:t}=new URL(e);return t==="null"?null:t}catch{return null}}function le(e){return yn(Se,Tc(e))}var Ac=4;function xn(e){return e.type===Ac}function Sn(e){if(!xn(e))return e;return{...e,data:{...e.data,href:le(e.data.href)}}}function Ue(e){return rs(Se,e)}function cs(){return os(Se)}var ds=30000,Pc=4194304,Lc=20000,Cn=500,Ic=2000,Oc=2,us={windowMs:ds,checkoutMs:ds,maxBytes:Pc,maxEvents:Lc,maxLaneEvents:Cn},Z=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2,8)}`;function Tn(e,t){return t&&t.load===e.load?t.startMs:e.lastMs}var Dc=new TextEncoder,ee=!1,ps=0,L=us,v=[],_=[],W=[],J=[],_c=0,Ee=[],Ce=new Map,Te=null,Re=null,Ve=!1,Hc=0,Q=null,St=null,En=Promise.resolve();function fs(e=us){if(An(),ee=!0,ps++,L=e,Q=e.store??null,v=(e.prior??[]).filter((t)=>t.kind!=="lanes").map((t)=>({id:t.id,load:t.load,startMs:t.startMs,lastMs:t.lastMs,events:[],count:t.count,bytes:t.bytes,href:t.href,route:t.route,stored:!0})),_=(e.priorLanes??[]).slice(-e.maxLaneEvents),W=[],J=[],Ee=(e.prior??[]).filter((t)=>t.kind==="lanes").map((t)=>({id:t.id,lastMs:t.lastMs})),Ce.clear(),Te=null,Et(Date.now()),Q)St=setInterval(Rt,Ic)}function hs(){Rt(),An(),ee=!1,Q=null,v=[],_=[],W=[],J=[],Ee=[],Ce.clear(),Te=null}function gs(){return L}function Mn(e){Re=e}function ms(){if(!ee)return;v=[],_=[],W=[],J=[],Ee=[],Ce.clear(),Te=null;let e=x.tabId;ce((t)=>t.clear(e)),Re?.()}function bs(){return En}function Rt(){if(!ee||!Q)return;let e=Date.now();Et(e),Pn(e);for(let t of v){if(t.stored)continue;let n=Ce.get(t.id)??{events:0,parts:0};if(n.events===t.events.length)continue;let r=JSON.stringify(t.events.slice(n.events)),o=n.parts;Ce.set(t.id,{events:t.events.length,parts:o+1});let i=ys(t);ce((s)=>s.putWindowChunk(i,o,r,[]))}Bc(e)}function Bc(e){let t=e-L.windowMs;while(J.length>0&&J[0].lastMs<=t){let[a]=J.splice(0,1);if(a)ce((l)=>l.dropWindow(a.id))}for(let a of Ee.filter((l)=>l.lastMs<=t))ce((l)=>l.dropWindow(a.id));Ee=Ee.filter((a)=>a.lastMs>t);let n=W;if(!n.length)return;W=[];let r=J.at(-1);if(!r||r.startMs<=t)r={id:`${Z}.lanes.${++_c}`,startMs:Date.parse(n[0].ts),lastMs:0,parts:0},J.push(r);r.lastMs=Date.parse(n.at(-1).ts);let o=r.parts++,i=r,s={id:i.id,tab:x.tabId,scope:L.scope??"",kind:"lanes",load:Z,startMs:i.startMs,lastMs:i.lastMs,count:0,bytes:0,href:"",route:""};ce((a)=>a.putWindowChunk(s,o,"[]",n))}function An(){if(St)clearInterval(St);St=null}function ys(e){return{id:e.id,tab:x.tabId,scope:L.scope??"",load:e.load,startMs:e.startMs,lastMs:e.lastMs,count:e.count,bytes:e.bytes,href:e.href,route:e.route}}function ce(e){let t=Q;if(!t)return;En=En.then(()=>e(t)).catch((n)=>{if(Q!==t)return;Q=null,An(),console.warn("vitrinka: browser capture storage failed — the capture stays in memory for this page",n)})}function Rn(e){let[t]=v.splice(e,1);if(!t)return;Ce.delete(t.id),ce((n)=>n.dropWindow(t.id))}function Et(e){while(v.length>0){let r=v[0],o=v[1];if(!o&&r.load===Z)break;if(Tn(r,o)>e-L.windowMs)break;Rn(0)}if(Ve)return;let t=v.at(-1);if(t&&t.load===Z&&Re&&t.lastMs<=e-L.windowMs){Ve=!0;try{Re()}finally{Ve=!1}let r=v.indexOf(t);if(r>=0&&r<v.length-1)for(let o=r;o>=0;o--)Rn(o)}let n=!1;while(v.length>0&&Nc()){if(v.length===1&&v[0].load===Z&&!n&&Re){n=!0,Ve=!0;try{Re()}finally{Ve=!1}if(v.length>1)continue}Rn(0),Te=v[0]?.startMs??e}}function ks(){return ee?`flight:${ps}`:null}function Pn(e){let t=Math.min(v[0]?.startMs??Number.POSITIVE_INFINITY,e-L.windowMs),n=_.findIndex((r)=>Date.parse(r.ts)>=t);if(n===-1)_=[];else if(n>0)_=_.slice(n)}function Nc(){let e=0,t=0;for(let n of v)e+=n.bytes,t+=n.count;return e>L.maxBytes||t>L.maxEvents}function vs(e){if(!ee)return;let t=v[0];if(xn(e)){let r=globalThis.location?.pathname??x.pathname,o={id:`${Z}.${++Hc}`,load:Z,startMs:e.timestamp,lastMs:e.timestamp,events:[],count:0,bytes:0,href:e.data.href,route:le(r)};v.push(o);let i=ys(o);ce((s)=>s.putWindow(i))}let n=v.at(-1);if(!n||n.load!==Z)return;if(n.events.push(e),n.count++,n.lastMs=Math.max(n.lastMs,e.timestamp),n.bytes+=Dc.encode(JSON.stringify(e)).length,Et(e.timestamp),v[0]!==t)Pn(e.timestamp)}function ws(e,t,n){if(!ee)return null;let r=L.keepLane?L.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=L.maxLaneEvents;if(_.push(i),_.length>s)_.splice(0,_.length-s);if(Q){if(W.push(i),W.length>s)W.splice(0,W.length-s)}return o}function Ct(){if(!ee)return null;let e=Date.now();return Et(e),Pn(e),{windows:v.map((t)=>({...t,events:t.events.slice()})),lanes:_.slice(),truncated:Te!==null&&Te>e-L.windowMs}}function Ln(e){return e.windows.some((t)=>t.events[1]?.type===Oc)}var In=null;function Ye(){if(!In)In=typeof indexedDB>"u"?Fc():$c();return In}function Fc(){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 $c(){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 zc=2000,Hn=20000,Ps=200,Kc=4194304,qc=3145728,It=500,Wc=Kc-1024,jc=12582912,Uc=10485760,Vc=jc-64,Yc=1048576,Gc=new TextEncoder;function Oe(e){return Gc.encode(e).length}var E=()=>M();function U(e,t){let n=E().getString(e);if(!n)return t;try{return JSON.parse(n)}catch{return t}}var xs=!1;function V(e,t){try{return E().set(e,t),!0}catch(n){if(!xs)xs=!0,console.warn("vitrinka: storage write failed — the queue tail is memory-only until it clears",n);return!1}}var Mt="rec",pe;function S(){if(pe===void 0)pe=U(Mt,null);return pe}function Ot(e){if(pe=e,e===null)E().remove(Mt),E().remove(Xc);else V(Mt,JSON.stringify(Jc(e)))}var Xc="notes";var Xe=null;function Jc(e){if(Xe?.sessionId!==e.sessionId)return e;return{...e,paused:!0,activeMs:Xe.activeMs,resumeAt:null,stopping:Xe.at}}var Zc=new Set;function Qc(){for(let e of Zc)try{e()}catch(t){console.warn("vitrinka: before-stop hook failed",t)}}function ed(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&&Xe?.sessionId!==t.sessionId)Qc();if(!t){if(!n)return"unchanged";return pe=null,As(),dd(),"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(Xe?.sessionId===t.sessionId)t.paused=n.paused,t.activeMs=n.activeMs,t.resumeAt=n.resumeAt,delete t.stopping;return pe=t,"updated"}return pe=t,As(),"joined"}var td=700,fe,j=null,oe=!1;function Ae(){if(fe===void 0)fe=U("buffer",[]);return fe}function Dt(){if(j)clearTimeout(j),j=null;if(fe!==void 0&&!oe)V("buffer",JSON.stringify(fe))}function Ls(){if(oe=!1,j)return;j=setTimeout(()=>{j=null,Dt(),Is()},td)}function Bn(e){fe=e,oe=!1,Dt()}var Me,Pe=0;function de(){if(Me===void 0)Me=U("chunks",[]),Pe=Me.reduce((e,t)=>e+t.body.length,0);return Me}function Is(){if(oe)return;let e=de();if(e.length===0){E().remove("chunks");return}if(Pe>Yc){E().remove("chunks");return}V("chunks",JSON.stringify(e))}function Os(e){Me=e,Pe=e.reduce((t,n)=>t+n.body.length,0),oe=!1,Is()}var At,ge=new Map,he=new Set,me=new Map,Je=new Map,Ss=5,nd=200,rd=67108864,od=0,Rs=!1,Nn="blobs";function H(){return At??=U("images",[]),At}function Ds(){if(oe)return;let e=H().filter((t)=>!he.has(t.blob));if(e.length===0)E().remove("images");else V("images",JSON.stringify(e))}function Fn(e){At=e,oe=!1,Ds()}function id(e,t){let n=Ye();if(!n.durable&&!Rs)Rs=!0,console.warn("vitrinka: no IndexedDB — an attached image will not survive a reload");V(Nn,"1");let r=[];return{drafts:t.map(({blob:i,payload:s})=>{let a=`${e}/${Fs}.${++od}`;return ge.set(a,i),he.add(a),r.push(n.put(a,i).then(()=>{if(!(ge.has(a)||H().some((d)=>d.blob===a)||[...me.values()].includes(a)))return he.delete(a),$n(a),!1;if(!n.durable)return!1;if(he.delete(a),H().some((d)=>d.blob===a))Ds();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 $n(e){Ye().delete(e).catch((t)=>console.warn("vitrinka: blob journal delete failed",t))}function Le(e,t){for(let n of e)if(ge.delete(n),he.delete(n),Je.delete(n),t)$n(n)}var Pt=(e)=>e.kind==="event"?(e.images??[]).map((t)=>t.blob):[];async function _s(e){if(!E().getString(Nn))return;let t=Ye(),n=S()?.sessionId;try{let r=await t.keys(),o=0;for(let i of r)if(e?i.startsWith(`${e}/`):!n||!i.startsWith(`${n}/`))await t.delete(i);else o++;if(o===0&&!S())E().remove(Nn)}catch(r){console.warn("vitrinka: blob journal cleanup failed",r)}}var sd=0,Hs="",Bs=0,Es=-1;function zn(){sd=Date.now(),Bs=0,Hs=""}function Ie(e){Bs++,Hs=String(e instanceof Error?e.message:e).slice(0,200)}var Cs={actions:0,pages:0,frames:0,notes:0},ad=new Set;function ld(e){let t={...Cs};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")ad.add(n.payload.cid)}Cs=t}function cd(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;Ot(t),console.warn("vitrinka: session marked dead —",e),D()}var On=null;function dd(){if(On)clearInterval(On);On=null}function Ns(e){let t=S();if(!t||t.dead||e<1)return null;let n=U("seq",null),r=Math.max(t.seq,n?.sessionId===t.sessionId?n.seq:0)+1;return E().set("seq",JSON.stringify({sessionId:t.sessionId,seq:r+e-1})),t.seq=r+e-1,Ot(t),{seq:r,sessionId:t.sessionId}}var Fs=`${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`,Lt="allocation.",ud=0,I=new Set,pd=16777216,Ze=0,Qe=0,re=new Map;function _t(e){return e.kind==="event"?1+(e.images?.length??0):1}function fd(e,t){return new Set(Array.from({length:_t(t)},(n,r)=>e+r))}function Kn(e,t,n){return JSON.stringify(n&&n.size<_t(e)?{draft:e,seq:t,left:[...n]}:{draft:e,seq:t})}var Ts=!1,Ge=null;function Tt(e){if(!I.delete(e))return;if(Ze-=e.bytes,e.draft.kind==="chunk")Qe--}function $s(e){if(I.add(e),Ze+=e.bytes,e.draft.kind==="chunk")Qe++;while(I.size>Hn||Ze>pd||Qe>Ps){let t=I.values().next().value;Tt(t),E().remove(t.key),Le(Pt(t.draft),!0);let n=Error("vitrinka: pending allocation budget full — oldest capture dropped");Ie(n),console.warn(n.message)}}function zs(e=!1){if(Ts&&!e)return;Ts=!0;let t=E();if(!t.withLock)return;let n=new Set([...I].map((r)=>r.key));for(let r of t.keys?.()??[]){if(!r.startsWith(Lt)||n.has(r)||re.has(r))continue;let o=U(r,null);if(o&&o.draft&&o.draft.sessionId===S()?.sessionId)$s({...o,key:r,persisted:!0,bytes:Oe(JSON.stringify(o))})}}function Ks(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=Ae();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=H();l.forEach((g,y)=>{let b=t+y;if(!a(b)||u.some((k)=>k.seq===b))return;if(h.some((k)=>k.seq===b)){me.set(b,g.blob);return}u.push({seq:b,ts:r,tabId:o,tabHost:i,sessionId:s,blob:g.blob,payload:g.payload})});let f=u.reduce((g,y)=>g+y.payload.bytes,0);while(u.length>nd||f>rd){let g=u.shift();f-=g.payload.bytes,ne(g.sessionId,new Set([g.seq])),Le([g.blob],!0),console.warn(`vitrinka: attached image queue full — dropped ${g.payload.name} (seq ${g.seq}); its note lands without it`)}Fn(u)}if(h.length>Hn){let u=h.splice(0,h.length-Hn);ne(s,new Set(u.map((f)=>f.seq))),console.warn(`vitrinka: retry buffer full — dropped ${u.length} oldest events`)}}else{let l=de();if(!l.some((d)=>d.seq===t)&&!Ae().some((d)=>d.seq===t))l.push({seq:t,ts:r,tabId:o,tabHost:i,sessionId:s,...e.part}),Pe+=e.part.body.length;while(l.length>Ps){let d=l.shift();Pe-=d.body.length,ne(s,new Set([d.seq])),console.warn(`vitrinka: pending chunk queue full — dropped rrweb chunk seq ${d.seq}`)}}Ls(),ue()}function ne(e,t){for(let[n,r]of re){if(r.sessionId!==e)continue;let o=r.seqs.size;for(let s of r.seqs)if(t.has(s))r.seqs.delete(s);let i=r.seqs.size&&r.seqs.size<o&&r.persisted?U(n,null):null;if(i){let s=new Set([...r.seqs].filter((a)=>!i.left||i.left.includes(a)));if(s.size)V(n,Kn(i.draft,i.seq,s));else r.seqs.clear()}if(r.seqs.size===0){E().remove(n),re.delete(n);let s=n.slice(Lt.length,n.lastIndexOf(".")),a=`tab.${s}`,l=U(a,null);if(l?.departed&&l.recoverable&&!E().keys?.().some((d)=>d.startsWith(`${Lt}${s}.`)))E().remove(a)}}}function qs(){if(Ge)return Ge;let e=E();return Ge=qn(Promise.resolve().then(async()=>{for(let t of I)await e.withLock("seq",()=>{if(!I.has(t))return;if(t.persisted){let o=U(t.key,null);if(!o){Tt(t),Le(Pt(t.draft),!1);return}t.seq=o.seq,t.left=o.left}if(ed(e.getString(Mt)??null),S()?.sessionId!==t.draft.sessionId){Tt(t),Le(Pt(t.draft),!0);return}let n=t.seq??Ns(_t(t.draft))?.seq;if(n===void 0)return;t.seq=n;let r=t.left?new Set(t.left):fd(n,t.draft);if(t.persisted)e.set(t.key,Kn(t.draft,n,r));re.set(t.key,{sessionId:t.draft.sessionId,seqs:r,persisted:t.persisted}),Ks(t.draft,n,r),Tt(t)})}).catch((t)=>{throw Ie(t),console.warn("vitrinka: seq allocation failed — capture kept for retry",t),ue(),D(),t})).finally(()=>{Ge=null}),Ge}function Ws(e,t){let n=S(),r=e.kind==="event"&&e.event.kind==="note";if(!n||n.dead||n.paused&&!r)return!1;if(zs(),E().withLock){let o=`${Lt}${Fs}.${++ud}`,i=JSON.stringify({draft:e}),s={key:o,draft:e,persisted:!t&&V(o,i),bytes:Oe(i)};$s(s),qs(),t?.then((a)=>{if(a)hd(s)})}else{let o=Ns(_t(e));if(o)Ks(e,o.seq);else Le(Pt(e),!0)}return!0}function hd(e){let t=re.get(e.key);if(t)t.persisted=V(e.key,Kn(e.draft,e.seq,t.seqs));else if(I.has(e))e.persisted=V(e.key,JSON.stringify({draft:e.draft}))}var Ms=new Set;function qn(e){return Ms.add(e),e.catch(()=>{return}).finally(()=>{Ms.delete(e)})}function te(e){return S()?.sessionId!==e.sessionId}function et(e,t,n,r=[]){if(Ke.following)return null;let o=S();if(!o)return ws(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 Ws({sessionId:o.sessionId,ts:i,tabId:s,tabHost:a,kind:"event",event:{kind:e,payload:t},...l?{images:l.drafts}:{}},l?.journaled),Wn(),i}function js(e){Ae().push(e),Wn(),Ls(),ue()}var gd=Date.now();function Wn(){gd=Date.now()}function jn(e,t=Uc,n=Vc){let r=[],o=[],i=[],s=2,a=()=>{if(!i.length)return;r.push({count:i.length,body:`[${i.join(",")}]`}),i=[],s=2};for(let l of e){let d=JSON.stringify(l),p=Oe(d)+1;if(p>n){o.push(p);continue}if(p>t){a(),r.push({count:1,body:`[${d}]`});continue}if(i.length&&s+p>t)a();i.push(d),s+=p}return a(),{parts:r,dropped:o}}function Us(e,t){if(!e.length)return 0;let n=S();if(!n||n.paused||n.dead||Ke.following)return 0;let{parts:r,dropped:o}=jn(e);for(let l of o)console.warn(`vitrinka: rrweb event (${l} bytes) exceeds the chunk cap — dropped`),et("note",{text:`⚠ rrweb event dropped (${(l/1048576).toFixed(1)} MiB > chunk cap) — replay may be incomplete from here`},t);let i=new Date().toISOString(),{tabId:s,tabHost:a}=t;for(let l of r)if(!Ws({sessionId:n.sessionId,ts:i,tabId:s,tabHost:a,kind:"chunk",part:l}))return 0;return Wn(),r.length}async function md(e=5){let t=de();if(t.length===0)return!0;let n=S(),r=0,o=new Set;for(let i of t){if(r>=e)break;if(r++,!n||i.sessionId!==n.sessionId){console.warn(`vitrinka: dropping rrweb chunk seq ${i.seq} from ended session ${i.sessionId}`),o.add(i.seq);continue}try{let s=await Ki(n.sessionId,i.seq,i.body);if(te(n))return de().length===0;js({seq:i.seq,ts:i.ts,tabId:i.tabId,tabHost:i.tabHost,kind:"rrweb",payload:{count:i.count},blobKey:s.blobKey}),zn(),o.add(i.seq)}catch(s){if(te(n))return de().length===0;if(s instanceof C&&q(s.status)){console.warn(`vitrinka: rrweb chunk seq ${i.seq} rejected permanently (${s.status}) — dropped`),ne(i.sessionId,new Set([i.seq])),o.add(i.seq);continue}Ie(s),console.warn("vitrinka: chunk upload failed",s);break}}if(o.size)Os(de().filter((i)=>!o.has(i.seq)));return de().length===0}async function bd(e=4){let t=H();if(t.length===0)return!0;let n=S(),r=0,o=new Set,i=[];for(let s of t){if(r>=e)break;if(r++,!n||s.sessionId!==n.sessionId){console.warn(`vitrinka: dropping attachment seq ${s.seq} from ended session ${s.sessionId}`),o.add(s.seq),i.push(s.blob);continue}let a=ge.get(s.blob)??null;if(!a){try{a=await Ye().get(s.blob),Je.delete(s.blob)}catch(l){if(te(n))return H().length===0;let d=(Je.get(s.blob)??0)+1;if(console.warn(`vitrinka: blob journal read failed (${d}/${Ss})`,l),d<Ss){Je.set(s.blob,d),Ie(l);break}}if(te(n))return H().length===0}if(!a){console.warn(`vitrinka: attachment seq ${s.seq} (${s.payload.name}) lost its bytes — its note lands without it`),ne(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}try{let l=await qi(n.sessionId,s.seq,a);if(te(n))return H().length===0;js({seq:s.seq,ts:s.ts,tabId:s.tabId,tabHost:s.tabHost,kind:"attachment",payload:{...s.payload},blobKey:l.blobKey}),ge.delete(s.blob),me.set(s.seq,s.blob),zn(),o.add(s.seq)}catch(l){if(te(n))return H().length===0;if(l instanceof C&&q(l.status)){console.warn(`vitrinka: attachment seq ${s.seq} rejected permanently (${l.status}) — dropped`),ne(s.sessionId,new Set([s.seq])),o.add(s.seq),i.push(s.blob);continue}Ie(l),console.warn("vitrinka: attachment upload failed",l);break}}if(o.size)Dt(),Fn(H().filter((s)=>!o.has(s.seq)));return Le(i,!0),H().length===0}var Dn=null;function ue(){if(Dn)return;Dn=setTimeout(()=>{Dn=null,yd()},zc)}var _n=!1;async function yd(e={}){if(_n)return!1;_n=!0;try{return await kd(e)}finally{_n=!1}}async function kd(e){if(S()?.dead)return!1;if(zs(!0),I.size)await qs();if(I.size)return!1;let t=await md(),n=e.keepalive?H().length===0:await bd(),r=t&&n;if(!r)ue();let o=S(),i=Ae();if(!o||i.length===0)return r;let s=[],a=new Set,l=0,d=e.keepalive?61440:qc;for(let u of i){if(s.length>=It)break;let f=Oe(JSON.stringify(u))+1;if(f>Wc){console.warn(`vitrinka: event seq ${u.seq} (${f} bytes) exceeds the wire cap — dropped`),a.add(u.seq);continue}if(f>d){if(e.keepalive)break;if(s.length===0)s.push(u),l=f;break}if(s.length>0&&l+f>d)break;s.push(u),l+=f}if(a.size){if(ne(o.sessionId,a),Bn(Ae().filter((u)=>!a.has(u.seq))),!s.length)return ue(),!1}if(!s.length)return!1;Dt();try{await G("POST",`/api/v1/sessions/${o.sessionId}/events`,{events:s},e)}catch(u){if(te(o))return!1;if(u instanceof C&&q(u.status))return cd(`server rejected this session (${u.status})`),!1;return Ie(u),D(),console.warn("vitrinka: flush failed, retrying",u),ue(),!1}if(te(o))return!0;zn(),Es=Math.max(Es,...s.map((u)=>u.seq)),ld(s);let p=new Set(s.map((u)=>u.seq));ne(o.sessionId,p);let h=Ae().filter((u)=>!p.has(u.seq));Bn(h),D();for(let u of p){let f=me.get(u);if(f===void 0)continue;me.delete(u),$n(f)}if(h.length)ue();return!0}function Vs(){for(let e of re.keys())E().remove(e);for(let e of I)E().remove(e.key);re.clear(),I.clear(),Ze=Qe=0,Bn([]),Os([]),ge.clear(),he.clear(),me.clear(),Je.clear(),Fn([])}function As(){if(j)clearTimeout(j),j=null;fe=[],Me=[],Pe=0,At=[],ge.clear(),he.clear(),me.clear(),I.clear(),Ze=Qe=0,re.clear(),oe=!0}var Ys="0.9.4";var $p={from:"page",inst:Fi("p")};var vd=!1;function Gs(){return vd}var Js="vitrinka.report.face",Xs=(e)=>e.trim().replace(/\/+$/,"");function Ht(){try{return globalThis.localStorage??null}catch{return null}}function De(e){let t=ae();if(!t)return!1;if(t.base)return Xs(t.base)===Xs(e);try{let n=yt(e);return n===void 0||n===t.workspace}catch{return!1}}function be(e){return De(e)?ae()?.token??"":""}function Zs(e){return/revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(e)}function wd(){let e=Ht()?.getItem(Js);return e==="recorder"||e==="report"?e:null}function Un(e){try{Ht()?.setItem(Js,e)}catch(t){console.warn("vitrinka: the picked face could not be remembered — the next load starts on Report a problem",t)}}var Qs="vitrinka.report.mode";function ea(e){try{if(e==="dev"||e==="regular")Ht()?.setItem(Qs,e)}catch(t){console.warn("vitrinka: the display mode could not be remembered — the next load starts on Report a problem",t)}}function ta(e){if(!De(e))return"report";let t=wd();if(t)return t;return Ht()?.getItem(Qs)==="dev"?"recorder":"report"}function na(){return S()!==null||Gs()}function Bt(e){let t=M().watch?.(je,()=>e()),n=Oi(e);return()=>{t?.(),n()}}var ra=["bug","suggestion","question","other"];function _e(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`}},Sd={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 _e(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 _e(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)=>_e(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)=>_e(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 _e(e,"1 sekunda",`${e} sekundy`,`${e} sekund`);let t=Math.round(e/60);return _e(t,"1 minuta",`${t} minuty`,`${t} minut`)}},Rd={cs:Sd,en:xd};function Vn(e){return Rd[e]}function tt(e){if(typeof e!=="string")return null;let t=e.trim().toLowerCase().split(/[-_]/)[0];return t==="cs"||t==="en"?t:null}function Yn(){let e=globalThis.navigator,t=e?e.languages?.length?e.languages:[e.language]:[];for(let n of t){let r=tt(n);if(r)return r}return"en"}var oa="recents",ia=5,Ed=["recording","saved","unsaved","deleted"];function Cd(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.sessionId==="string"&&typeof t.title==="string"&&typeof t.startedAt==="number"&&Ed.includes(t.status)}var He;function Gn(){if(He===void 0)try{let e=JSON.parse(M().getString(oa)??"[]");He=Array.isArray(e)?e.filter(Cd).slice(0,ia):[]}catch{He=[]}return He}function Td(e){He=e.slice(0,ia);try{M().set(oa,JSON.stringify(He))}catch(t){console.warn("vitrinka: could not store recent recordings",t)}D()}function sa(e,t){let n=Gn();if(!n.some((r)=>r.sessionId===e))return;Td(n.map((r)=>r.sessionId===e?{...r,...t}:r))}var nt="data-vitrinka-recorder";var Xn="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;",aa=Xn;var Md=["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 ua(e){for(let t of Md)e.addEventListener(t,(n)=>n.stopPropagation())}var Ad=["keydown","keyup","keypress"],Pd=["vitrinkaHud","vitrinkaSheet"],la=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Ld=new Set(["KeyA","KeyC","KeyX","KeyV","KeyZ","KeyY"]),Id=new Set(["text","search","email","url","tel","password","number"]);function Od(e){let t=e.key.length===1;if(t&&e.getModifierState?.("AltGraph"))return!0;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return t||la.has(e.key);if(la.has(e.key))return!0;return(e.ctrlKey||e.metaKey)&&!e.altKey&&Ld.has(e.code)}function Dd(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"&&Id.has(e.type)}function _d(e){if(typeof e!=="object"||e===null||!("dataset"in e))return!1;let t=e.dataset;return typeof t==="object"&&t!==null&&Pd.some((n)=>(n in t))}function Hd(e){if(!Od(e))return!1;let t=e.composedPath();return Dd(t[0])&&t.some(_d)}var ca=0,Nt=null;function pa(){if(ca++,!Nt&&typeof window<"u"){let t=(r)=>{if(Hd(r))r.stopImmediatePropagation()},n=Ad.map((r)=>P(window,r,t,{capture:!0}));Nt=()=>{for(let r of n)r()}}let e=!0;return()=>{if(!e)return;if(e=!1,--ca>0)return;Nt?.(),Nt=null}}function fa(){let e=document.createElement("div");e.setAttribute(nt,""),e.setAttribute("data-vitrinka-hud",""),e.style.cssText=Xn;let t=e.attachShadow({mode:"open"}),n=document.createElement("div");t.append(n),ua(e);let r=pa();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&&da(f.target);for(let g of[f.addedNodes,f.removedNodes])for(let y of g){if(!(y instanceof Element))continue;if(da(y))return!0;if(y.childElementCount>0&&y.querySelector(ha))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 ha='dialog,[role="dialog"]';function da(e){return e.matches(ha)}function ga(){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 ma(e){let t=document.createElement("div");t.setAttribute(nt,""),t.setAttribute("data-vitrinka-sheet",""),t.style.cssText=aa;let n=t.attachShadow({mode:"open"}),r=document.createElement("div");n.append(r),ua(t);let o=pa();if(typeof t.showPopover==="function")t.popover="manual";return e.append(t),t.showPopover?.(),{mount:r,destroy:()=>{o(),t.remove()}}}function ba(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 Bd="me";var Nd;function ya(){Nd=null,M().remove(Bd)}function ka(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 va(){kt(),ya();let e=S();if(e)sa(e.sessionId,{status:"unsaved",durationMs:ka(e)}),Ot(null),Vs(),_s(e.sessionId);D()}var ie={maxBytes:10485760,maxCount:5,types:["image/*","application/pdf","text/*"]};function Fd(e,t){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:t}function wa(e){if(typeof e!=="object"||e===null)return ie;let t={...e},n=Array.isArray(t.types)?t.types.filter((r)=>typeof r==="string"&&r.trim()!=="").map((r)=>r.trim().toLowerCase()):[];return{maxBytes:Fd(t.maxBytes,ie.maxBytes),maxCount:typeof t.maxCount==="number"&&Number.isInteger(t.maxCount)&&t.maxCount>=0?t.maxCount:ie.maxCount,types:n.length?n:ie.types}}function $d(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 zd(e,t){return e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}function xa(e,t,n){let r=[],o=null;for(let i of t){if([...e,...r].some((s)=>zd(s,i)))continue;if(!$d(i,n.types))o??={kind:"type",name:i.name};else if(i.size>n.maxBytes)o??={kind:"size",name:i.name,cap:n.maxBytes};else if(e.length+r.length>=n.maxCount)o??={kind:"count",cap:n.maxCount};else r.push(i)}return{files:r,refusal:o}}function rt(e,t){let n=(r,o,i)=>`${new Intl.NumberFormat(t,{maximumFractionDigits:i}).format(r)} ${o}`;if(e<1024)return n(e,"B",0);if(e<1048576)return n(e/1024,"kB",0);return n(e/1048576,"MB",e<10485760?1:0)}function Sa(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 Ra(e,t){let n=/^image\.(\w+)$/i.exec(e);return n?`pasted-${t}.${n[1]}`:e}var Jn=["sm","md","lg"],ot={sm:0.88,md:1,lg:1.18},Zn="vitrinka.report.size";function Ea(){try{return globalThis.localStorage??null}catch{return null}}function Ft(e){return Ea()?.getItem(e)??null}function it(e,t){try{Ea()?.setItem(e,t)}catch(n){console.warn(`vitrinka: could not remember ${e} on this browser`,n)}}function Ca(){let e=Ft(Zn);return Jn.find((t)=>t===e)??"md"}var Qn="vitrinka.report.coach";function Ta(){return Ft(Qn)!=="off"}function Ma(e,t){let n=e.config,r=!e.engine||n?.capturing===!1?t.captureOff:n?t.captureOn:t.captureStarting,o=e.base;try{o=new URL(e.base).host}catch{}return[[t.techVersion,`@vitrinka/web ${e.version}`],[t.techWindow,n?t.windowLength(n.profile.windowSec):"—"],[t.techCapture,r],[t.techBuffer,n?`${n.profile.storage==="browser"?t.bufferBrowser:t.bufferMemory} · ${rt(n.profile.maxBytes,e.locale)}`:"—"],[t.techServer,o]]}var Aa="vitrinka.report.dock",Pa=6,er={t:{l:"tl",r:"tr"},b:{l:"bl",r:"br"}},Kd=["br","bl","tr","tl"];function qd(e){return e==="tl"||e==="tr"?"t":"b"}function Wd(e){return e==="tl"||e==="bl"?"l":"r"}function La(){let e=Ft(Aa);return Kd.find((t)=>t===e)??"br"}function Ia(e){it(Aa,e)}function Oa(e,t,n){return er[e.y<n/2?"t":"b"][e.x<t/2?"l":"r"]}function Da(e,t){if(t==="ArrowLeft"||t==="ArrowRight")return er[qd(e)][t==="ArrowLeft"?"l":"r"];if(t==="ArrowUp"||t==="ArrowDown")return er[t==="ArrowUp"?"t":"b"][Wd(e)];return null}var jd=8192,st="__vitrinkaRecorderConsolePatched";function $t(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,jd)}function zt(e,t="error"){if(!e||e.startsWith("vitrinka:"))return;et("console",{level:t,text:as(e)},{tabId:x.tabId,tabHost:x.tabHost})}var tr="__vitrinkaRecorderConsoleUnpatch",_a={};function Ha(){let e=globalThis;if(e[st]!==void 0&&e[st]!==_a)return;e[tr]?.()}function Ba(e={}){let t=globalThis;if(t[st])return;t[st]=_a;let n=console.error,r=n.bind(console),o=(...d)=>{r(...d);try{zt($t(d))}catch{}};console.error=o;let i=(e.levels??[]).map((d)=>{let p=console[d],h=p.bind(console),u=(...f)=>{h(...f);try{zt($t(f),d)}catch{}};return console[d]=u,()=>{if(console[d]===u)console[d]=p}}),s=(d)=>{try{zt($t([d.error??d.message]))}catch{}},a=(d)=>{try{zt(`unhandled rejection: ${$t([d.reason])}`)}catch{}},l=typeof addEventListener==="function";if(l)addEventListener("error",s),addEventListener("unhandledrejection",a);t[tr]=()=>{if(console.error===o)console.error=n;for(let d of i)d();if(l)removeEventListener("error",s),removeEventListener("unhandledrejection",a);delete t[st],delete t[tr]}}var Na=65536,at=524288,Fa=3000;var nr="full";function or(){if(Ke.following)return null;let e=S();if(e)return!e.paused&&!e.dead?e.sessionId:null;return ks()}function lt(e){return e!==null&&or()===e}function Kt(e,t){if(typeof e==="string")return vn(e,Na,t);if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return vn(e.toString(),Na,"application/x-www-form-urlencoded");return Ud(e)}function Ud(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 rr(e){for(let[t,n]of Object.entries(e??{}))if(t.toLowerCase().replace(/[-_]/g,"")==="contenttype")return n;return""}function ir(e){return typeof e==="string"||e instanceof URL?{}:e}function ct(e){let t=typeof e.url==="string"?le(e.url):e.url;et("net",{...e,url:t},{tabId:x.tabId,tabHost:x.tabHost})}function sr(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 Vd(e,t){let n=sr(t?.headers);if(n)return n;let r=ir(e);return sr(r.headers)}function Yd(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 ar(e){try{e.body?.cancel?.().catch(()=>{return})}catch{}}function Gd(e){let t=e.get("content-length");if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null}async function Xd(e,t){let n=await Jd(e,t);if(n===void 0)return;let r="";try{r=t.get("content-type")??""}catch{}return Kt(n,r)}async function Jd(e,t){let n=Gd(t);if(n!==null&&n>at)return ar(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()+Fa;try{while(s<at){let f=d-Date.now();if(f<=0){l=!0;break}let g,y=await Promise.race([o.read(),new Promise((w)=>{g=setTimeout(()=>w("timeout"),f)})]).finally(()=>{if(g!==void 0)clearTimeout(g)});if(y==="timeout"){l=!0;break}let{done:b,value:k}=y;if(b)break;if(k){let w=at-s,m=k.byteLength>w?k.subarray(0,w):k;i.push(m),s+=m.byteLength}}a=s>=at,o.cancel().catch(()=>{return})}catch{return}let p=new Uint8Array(s),h=0;for(let f of i)p.set(f,h),h+=f.byteLength;let u;try{u=new TextDecoder().decode(p)}catch{return`[body omitted: ${s} bytes, undecodable]`}if(l)return`${u}…[body read timed out after ${Fa}ms]`;return a?`${u}…[truncated at ${at} bytes]`:u}if(n===null)return ar(e),"[body omitted: length-less response, no stream API]";try{return await e.text()}catch{return}}var dt="__vitrinkaRecorderNetPatched",lr="__vitrinkaRecorderNetUnpatch",$a={};function za(){let e=globalThis;if(e[dt]!==void 0&&e[dt]!==$a)return;e[lr]?.()}function Ka(e={}){let t=globalThis;if(t[dt])return;t[dt]=$a,nr=e.detail??"full";let n=[];t[lr]=()=>{for(let u of n.splice(0))u();delete t[dt],delete t[lr]};let r=globalThis.fetch,o=async(u,f)=>{let g=typeof u==="string"?u:u instanceof URL?u.href:u.url,y=or();if(pn(g)||y===null)return r(u,f);let b=f?.method??("method"in ir(u)?ir(u).method:"GET"),k=Date.now();try{let w=await r(u,f),m=Date.now()-k;if(nr==="meta"){if(lt(y))ct({method:b,url:g,status:w.status,ms:m,via:"fetch"});return w}let A;try{A=w.clone()}catch{A=void 0}let{headers:Be,status:Ne}=w;return qn((async()=>{if(!lt(y)){if(A)ar(A);return}let mt=A?await Xd(A,Be):void 0;if(!lt(y))return;let Fe=Vd(u,f);ct({method:b,url:g,status:Ne,ms:m,reqHeaders:Ue(Fe),resHeaders:Ue(sr(Be)),reqBody:Kt(f?.body,rr(Fe)),resBody:mt,via:"fetch"})})()),w}catch(w){if(lt(y))ct({method:b,url:g,error:String(w),ms:Date.now()-k,via:"fetch"});throw w}};globalThis.fetch=o,n.push(()=>{if(globalThis.fetch===o)globalThis.fetch=r});let i=globalThis.XMLHttpRequest;if(!i?.prototype)return;let s=i.prototype.open,a=i.prototype.send,l=i.prototype.setRequestHeader;n.push(()=>{let u=i.prototype;if(u.open===d)u.open=s;if(u.send===h)u.send=a;if(u.setRequestHeader===p)u.setRequestHeader=l});let d=i.prototype.open=function(...u){return this.__vt={method:u[0],url:String(u[1])},s.apply(this,u)},p=i.prototype.setRequestHeader=function(u,f){let g=this.__vt;if(g)(g.reqHeaders??={})[u]=f;return l?.call(this,u,f)},h=i.prototype.send=function(u){let f=this.__vt,g=or();if(f&&!pn(f.url)&&g!==null){let y=Date.now();this.addEventListener("loadend",()=>{if(!lt(g))return;if(nr==="meta"){ct({method:f.method,url:f.url,status:this.status,ms:Date.now()-y,via:"xhr"});return}let b;try{b=Yd(this.getAllResponseHeaders())}catch{b=void 0}let k;try{k=this.responseType===""||this.responseType==="text"?Kt(this.responseText,rr(b)):void 0}catch{k=void 0}ct({method:f.method,url:f.url,status:this.status,ms:Date.now()-y,reqHeaders:Ue(f.reqHeaders),resHeaders:Ue(b),reqBody:Kt(u,rr(f.reqHeaders)),resBody:k,via:"xhr"})})}return a.call(this,u)}}var Zd=2000,Qd=300000,pt=null,ft=null,ut=[],qt=null;function qa(){if(!ut.length)return;let e=ut;ut=[],Us(e,{tabId:x.tabId,tabHost:x.tabHost})}function ht(){return ft}function Wa(e,t,n={}){if(pt)return;let r=cs(),o=n.unmaskSelector;try{pt=e({emit:t==="flight"?(s)=>vs(Sn(s)):(s)=>{ut.push(Sn(s))},checkoutEveryNms:t==="flight"?gs().checkoutMs:Qd,inlineImages:!1,collectFonts:!0,maskAllInputs:r.maskAllInputs,...r.maskTextSelector?{maskTextSelector:r.maskTextSelector}:{},...r.maskTextSelector&&o?{maskTextFn:(s,a)=>{try{if(a?.closest(o))return s}catch{}return s.replace(/\S/g,"*")}}:{},blockSelector:`[${nt}]`})??null}catch(i){console.warn("vitrinka: rrweb failed to start",i);return}if(ft=e,t==="flight")Mn(Wt);if(t==="session")qt=setInterval(qa,Zd)}function ja(){if(qt)clearInterval(qt);qt=null,qa();try{pt?.()}catch{}pt=null,ft=null,Mn(null),ut=[]}function Wt(){if(!pt||!ft)return;try{ft.takeFullSnapshot?.(!0)}catch{}}var Ya="vitrinka.capture",B="windows",N="chunks";function ye(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=e.onerror=()=>n(e.error??Error("vitrinka: capture store transaction failed"))})}function cr(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error("vitrinka: capture store request failed"))})}function Ua(e){return IDBKeyRange.bound([e,0],[e,Number.MAX_SAFE_INTEGER])}function Va(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 Ga(e=globalThis.indexedDB){if(!e)return Promise.reject(Error("vitrinka: IndexedDB is not available"));return new Promise((t,n)=>{let r=e.open(Ya,1);r.onupgradeneeded=()=>{r.result.createObjectStore(B,{keyPath:"id"}),r.result.createObjectStore(N)},r.onerror=()=>n(r.error??Error("vitrinka: capture store did not open")),r.onblocked=()=>n(Error("vitrinka: capture store is blocked by another tab")),r.onsuccess=()=>t(r.result)}).then((t)=>{t.onversionchange=()=>t.close();let n=(o,i)=>{o.objectStore(B).delete(i),o.objectStore(N).delete(Ua(i))};return{async putWindow(o){let i=t.transaction(B,"readwrite");i.objectStore(B).put(o),await ye(i)},async putChunk(o,i,s,a){let l=t.transaction(N,"readwrite"),d={events:s,lanes:[...a]};l.objectStore(N).put(d,[o,i]),await ye(l)},async putWindowChunk(o,i,s,a){let l=t.transaction([B,N],"readwrite"),d={events:s,lanes:[...a]};try{l.objectStore(N).put(d,[o.id,i]),l.objectStore(B).put(o)}catch(p){throw l.abort(),p}await ye(l)},async dropWindow(o){let i=t.transaction([B,N],"readwrite");n(i,o),await ye(i)},async clear(o){let i=t.transaction([B,N],"readwrite"),s=await cr(i.objectStore(B).getAll());for(let a of s)if(Va(a)&&a.tab===o)n(i,a.id);await ye(i)},async sweep(o,i,s,a){let l=t.transaction([B,N],"readwrite"),d=(await cr(l.objectStore(B).getAll())).filter(Va),p=[],h=new Map;for(let u of d)h.set(u.tab,[...h.get(u.tab)??[],u]);for(let[u,f]of h){let g=f.filter((b)=>b.kind!=="lanes").sort((b,k)=>b.startMs-k.startMs),y=(b)=>b.kind==="lanes"?b.lastMs:Tn(b,g[g.indexOf(b)+1]);for(let b of f.sort((k,w)=>k.startMs-w.startMs))if(y(b)<=o-i||u===s&&b.scope!==a)n(l,b.id);else if(u===s)p.push(b)}return await ye(l),p},async read(o){let i=t.transaction(N,"readonly"),s=await cr(i.objectStore(N).getAll(Ua(o)));await ye(i);let a=[],l=[];for(let d of s)a.push(...JSON.parse(d.events)),l.push(...d.lanes);return{events:a,lanes:l}},close:()=>t.close()}})}function Xa(e=globalThis.indexedDB){try{e?.deleteDatabase(Ya)}catch(t){console.warn("vitrinka: could not delete the capture store",t)}}function dr(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 ur(e,t){return`${t.y<e.y?"n":"s"}${t.x<e.x?"w":"e"}`}function pr(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 Ja(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 Za(e){return e.map((t,n)=>({...t,n:n+1}))}function Qa(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 eu=2,tu=3,nu=0,ru=5,fr=2,ou=3,iu=2000000000,su="data-vitrinka-hidden",au="#1b1b1f";function lu(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:${au};z-index:2147483647;pointer-events:none;`;return{type:fr,id:iu+t,tagName:"div",attributes:{[su]:"",style:n},childNodes:[]}}function hr(e,t,n,r){let o={...e};if(e.type===ou&&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)=>hr(i,t,n,r)),!r.done&&e.type===fr&&e.tagName==="body")o.childNodes.push(...n),r.done=!0}return o}function cu(e,t){(e.childNodes?.find((r)=>r.type===fr)??e).childNodes?.push(...t)}function du(e,t){return hr(e,t,[],{done:!0})}function el(e,t,n){if(!t.length&&!n.size)return e.slice();let r=t.map(lu);return e.map((o)=>{let i=o.data;if(o.type===eu&&i.node){let s={done:!1},a=hr(i.node,n,r,s);if(!s.done)cu(a,r);return{...o,data:{...o.data,node:a}}}if(o.type!==tu||!n.size)return o;if(i.source===nu){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:du(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===ru){let s=o.data;if(n.has(s.id))return{...o,data:{...s,text:""}}}return o})}function uu(e,t){return e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h}function pu(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function gr(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)=>uu(pu(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 fu=["errors","interactions","full","console","network"];var jt={storage:"memory",windowSec:300,maxBytes:12582912,classes:["errors","interactions"]};function Yt(e){return{storage:"memory",windowSec:60,maxBytes:4194304,classes:e===!1?["errors"]:["errors","interactions"]}}function Ut(e,t,n){return Math.min(n,Math.max(t,e))}function hu(e){if(!Array.isArray(e))return null;return fu.filter((t)=>e.includes(t))}function tl(e,t){if(typeof e!=="object"||e===null)return Yt(t);let n=e;return{storage:n.storage==="browser"?"browser":n.storage==="memory"?"memory":jt.storage,windowSec:typeof n.windowSec==="number"&&Number.isFinite(n.windowSec)?Ut(Math.round(n.windowSec),10,3600):jt.windowSec,maxBytes:typeof n.maxBytes==="number"&&Number.isFinite(n.maxBytes)?Ut(Math.round(n.maxBytes),262144,67108864):jt.maxBytes,classes:hu(n.classes)??jt.classes}}function Vt(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 gu(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 nl(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=Vt(e.classes),s=Vt(t.classes);o=gu({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:Ut(n,10,3600),maxBytes:Ut(r,262144,67108864),classes:o}}function rl(e){return e==="balanced"||e==="full"?e:"strict"}function ol(e){if(e==="full")return{fullFidelity:!0};if(e==="balanced")return{};return{maskAllText:!0}}var il="[data-vitrinka-unmask]";var mu=3670016,sl=4194240,bu=2000,al=500,yu=60000,ku=/[A-Za-z0-9_-]{20,}/g;function Y(e,t=""){return typeof e==="string"?e:t}function vu(e){let t=Y(e),n;try{n=new URL(t,globalThis.location?.href??"http://localhost").pathname}catch{n=t.split(/[?#]/)[0]??""}return n.replace(ku,"•••").slice(0,300)}var wu=4;function xu(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===wu&&o.length)s();if(!i&&Oe(JSON.stringify(a))+1>t)i=!0;o.push(a)}return s(),{events:n,dropped:r}}function Su(e){return(t,n)=>{if(t==="console"){let r=Y(n?.level,"error");if(r==="error"?!(e.errors||e.console):!e.console)return null;return{level:r,text:Y(n?.text).slice(0,bu)}}if(t==="net"){let r=typeof n?.status==="number"?n.status:0,o=r===0||r>=400||n?.error!==void 0;if(!(e.network||e.errors&&o))return null;return{method:Y(n?.method,"GET").toUpperCase(),path:vu(n?.url),status:r,ms:typeof n?.ms==="number"?Math.max(0,Math.round(n.ms)):0}}return null}}async function Ru(e){try{let t=await G("GET","/api/v1/report-config",void 0,{target:e}),n=typeof t.flightRecorder==="boolean"?t.flightRecorder:void 0;return{project:Y(t.project),profile:t.captureProfile==null?Yt(n):tl(t.captureProfile,n),masking:rl(t.profile),reachable:!0,attachments:wa(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:Yt(),masking:"strict",reachable:!1,attachments:ie}}}function ll(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 cl{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(Bi(e.base));let t=await Ru({url:e.base,key:e.key}),n=nl(t.profile,e.capture),r=Vt(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=Li("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,Pi(Ai(),globalThis.location?.host??""),x.pathname=globalThis.location?.pathname??"/",ss(ol(o.masking)),wn(e.sanitizeUrl),this.capture.push(()=>wn(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 Ga();let d=await this.store.sweep(Date.now(),i,x.tabId,s);a=d;let p=this.store;l=(await Promise.all(d.filter((u)=>u.kind==="lanes").map((u)=>p.read(u.id)))).flatMap((u)=>u.lanes).sort((u,f)=>Date.parse(u.ts)-Date.parse(f.ts))}catch(d){console.warn("vitrinka: browser capture storage unavailable — keeping the capture in memory",d),this.store=null,a=[],l=[]}else Xa();if(!this.capturing)return this.store?.close(),this.store=null,o;if(fs({windowMs:i,checkoutMs:Math.min(yu,i),maxBytes:n.maxBytes,maxEvents:Math.max(20000,Math.round(n.maxBytes/200)),maxLaneEvents:Cn,keepLane:Su(r),store:this.store,scope:s,prior:a,priorLanes:l}),this.capture.push(hs),this.store&&typeof window<"u"){let d=()=>Rt();this.capture.push(P(window,"pagehide",d),P(document,"visibilitychange",d))}if(r.errors||r.console)Ba({levels:r.console?["warn","info","log"]:[]}),this.capture.push(Ha);if(r.errors||r.network)Ka({detail:"meta"}),this.capture.push(za);if(r.replay){let d=await e.loadRecord(e.base).catch((p)=>(console.warn("vitrinka: the page recorder did not load — reports go without a replay",p),null));if(d&&this.capturing)Wa(d,"flight",{unmaskSelector:il}),this.capture.push(ja)}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)bs().then(()=>e.close());for(let t of this.listeners)t()}freeze(){if(!this.capturing)return{clip:null,stored:Promise.resolve(new Map)};x.pathname=globalThis.location?.pathname??x.pathname;let e=Ct();if(e&&ht()&&!Ln(e))Wt(),e=Ct();let t=this.store,n=e?.windows.filter((o)=>o.stored).map((o)=>o.id)??[],r=t&&n.length?Promise.all(n.map(async(o)=>[o,await t.read(o)])).then((o)=>new Map(o)):Promise.resolve(new Map);return r.catch(()=>{return}),{clip:e,stored:r}}withScreen(e){if(!this.capturing||!ht()||e&&Ln(e))return e;Wt();let t=Ct();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=ll(ht());return t?gr([e],t):null}async build(e,t,n=new Set){let r=t.filter((m)=>m.shape==="hide").map((m)=>m.rect),o=ll(ht()),i=r.length>0&&!o;if(i)console.warn("vitrinka: this page recorder cannot name what a hide covers — the report goes without its replay");let s=new Set(n);if(r.length&&o)for(let m of gr(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 A=p?.get(m.id);if(!A?.events.length)d=!0;else a.push(...A.events)}let h=l?.lanes??[],u=i?{events:[],dropped:!1}:xu(el(a,r,s),sl);if(u.dropped)d=!0;let{parts:f,dropped:g}=jn(u.events,mu,sl),y=[],b=0;for(let m of f){b+=m.count;let A=u.events[b-1]?.timestamp??Date.now();y.push({seq:y.length+1,ts:new Date(A).toISOString(),count:m.count,body:m.body})}let k=h.filter((m)=>m.kind==="console").slice(-al).map((m)=>({level:Y(m.payload?.level,"error"),ts:m.ts,text:Y(m.payload?.text)})),w=h.filter((m)=>m.kind==="net").slice(-al).map((m)=>({method:Y(m.payload?.method,"GET"),path:Y(m.payload?.path),status:typeof m.payload?.status==="number"?m.payload.status:0,ms:typeof m.payload?.ms==="number"?m.payload.ms:0}));return{chunks:y,truncated:d||g.length>0,console:k,network:w}}clear(){if(this.capturing)ms()}stop(){this.stopped=!0,this.listeners.clear(),this.standDown(),Ii(this.claim),this.claim=null;for(let e of this.offs.splice(0).reverse())e()}}var z=null;function dl(e){if(z){let t=z.engine.opts;if(!(t.base===e.base&&t.key===e.key&&t.sanitizeUrl===e.sanitizeUrl&&JSON.stringify(t.capture??{})===JSON.stringify(e.capture??{})))return console.warn("vitrinka: one capture engine per page — this widget reports without a capture (another widget’s key, base, capture or sanitizeUrl owns it)"),null;return z.refs++,z.engine}return z={engine:new cl(e),refs:1},z.engine}function ul(e){if(!e||!z||z.engine!==e)return;if(--z.refs>0)return;z=null,e.stop()}var Eu=/^[\w-]+\.[\w-]+\.[\w-]+$/;function Gt(e){if(!e)return null;if("token"in e){let r=typeof e.token==="string"?e.token.trim():"";if(r.length>4096||!Eu.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 pl=null,mr=new Set;function Cu(e){pl=Gt(e);for(let t of mr)t()}function fl(){return pl}function hl(e){return mr.add(e),()=>mr.delete(e)}var Tu=new Set(["Shift","Control","Alt","Meta","AltGraph","OS","CapsLock","Fn","Hyper","Super"]),br="report.keybind";function gl(e){if(Tu.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 ml(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.metaKey===t.meta&&e.shiftKey===t.shift}var Mu={Space:"Space",Enter:"↵",Backspace:"⌫",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Slash:"/",Backslash:"\\",Period:".",Comma:",",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Minus:"-",Equal:"=",Backquote:"`"};function bl(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 Mu[e]??e}function Au(){let e=globalThis.navigator,t=e?.userAgentData?.platform??e?.platform??"";return/mac|iphone|ipad/i.test(t)}function Xt(e,t=Au()){let n=bl(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 yl(e){return[e.ctrl&&"Control",e.alt&&"Alt",e.shift&&"Shift",e.meta&&"Meta",bl(e.code)].filter(Boolean).join("+")}function Pu(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 Lu={code:"KeyA",alt:!0,ctrl:!1,meta:!1,shift:!0},kl="off";function vl(e){if(e===kl)return null;return Pu(e)??Lu}function wl(){return vl(M().getString(br))}function yr(e){M().set(br,e?JSON.stringify(e):kl)}function xl(e){let t=M();return t.watch?t.watch(br,(n)=>e(vl(n))):()=>{return}}var Iu=["br","bl","tr","tl"];function kr(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 Ou(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 Sl(e,t,n){let r=kr(e,n);return t.reduce((o,i)=>o+Ou(r,i),0)}function Rl(e,t,n){let r=Sl(e,t,n);if(r===0)return e;let o=e,i=r;for(let s of Iu){let a=Sl(s,t,n);if(a<i)o=s,i=a}return o}function El(e,t,n,r){let o=e==="br"||e==="bl";if(t.vh-t.top-t.h-t.bottom>=n.h+r)return o?"above":"below";if(t.vw-2*t.edge-t.w>=n.w+r)return e==="br"||e==="tr"?"left":"right";return"over"}function wr(e){if(!(e instanceof C)||e.status!==400)return"";return/unknown field \\?"(\w+)\\?"/.exec(e.message)?.[1]??""}var Cl={ms:30000,bytesPerMs:32};class Tl 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 vr(e,t,n){let r=new AbortController,o,i=new Promise((s,a)=>{o=setTimeout(()=>{let l=new Tl(e,t);r.abort(l),a(l)},t)});try{return await Promise.race([n(r.signal),i])}finally{clearTimeout(o)}}var xr={chunks:[],truncated:!1,console:[],network:[]};function Ml(e,t=Cl.ms){return vr("preparing the capture",t,e).catch((n)=>(console.warn("vitrinka: the capture could not be prepared — the report goes without it",n),xr))}class Sr{capture;tabHost;target;files;limits;id="";custody="";sent="";blobKeys=new Map;rowsPosted=0;skipCapture=!1;filesDone=new Set;constructor(e,t,n,r=[],o=Cl){this.capture=e;this.tabHost=t;this.target=n;this.files=r;this.limits=o}call(e,t,n){return vr(`${e} ${t}`,this.limits.ms,(r)=>G(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 vr(`POST ${e}`,o,(i)=>gn(e,t,n,this.target,i))}get filesPending(){return this.filesDone.size<this.files.length}async run(e,t){let n={title:e.title,description:e.description,markers:e.markers,notify:e.notify??!1},r=JSON.stringify(n);if(!this.id){let{res:i,memberSent:s}=await this.create(e);if(typeof i.id!=="string"||!i.id)throw Error("vitrinka: the server filed the report without an id");if(this.id=i.id,this.custody=i.custody==="direct"?"direct":"quarantined",this.sent=r,typeof i.memberError==="string"&&i.memberError)t?.(i.memberError,s)}else if(this.sent!==r)await this.call("PATCH",`/api/v1/reports/${encodeURIComponent(this.id)}`,n),this.sent=r;if(await this.sendFiles(),!this.skipCapture)try{await this.sendCapture()}catch(i){if(!(i instanceof C)||!q(i.status))throw i;console.warn("vitrinka: the server refused the recording — the report goes without it",i),this.skipCapture=!0}let o=await this.call("POST",`/api/v1/reports/${encodeURIComponent(this.id)}/submit`,{});return{status:o.status==="filed"?"filed":"quarantined",...typeof o.reportUrl==="string"&&o.reportUrl?{reportUrl:o.reportUrl}:{}}}async create(e){let t=e;for(;;)try{return{res:await this.call("POST","/api/v1/reports",t),memberSent:t.memberToken??""}}catch(n){let r=wr(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 throw n}}async sendFiles(){let e=encodeURIComponent(this.id);for(let[t,n]of this.files.entries()){if(this.filesDone.has(t))continue;try{await this.upload(`/api/v1/reports/${e}/attachment?name=${encodeURIComponent(n.name)}`,n.type||"application/octet-stream",n)}catch(r){if(!(r instanceof C)||!q(r.status))throw r;console.warn(`vitrinka: the server refused ${n.name} — the report goes without it`,r)}this.filesDone.add(t)}}async sendCapture(){let e=encodeURIComponent(this.id),{chunks:t,truncated:n}=this.capture;for(let o of t){if(this.blobKeys.has(o.seq))continue;let i=await this.upload(`/api/v1/reports/${e}/chunk?seq=${o.seq}`,"application/json",o.body);if(!i.blobKey)throw Error(`vitrinka: chunk ${o.seq} came back without a blob key`);this.blobKeys.set(o.seq,i.blobKey)}let r=t.map((o)=>({seq:o.seq,ts:o.ts,tabHost:this.tabHost,kind:"rrweb",payload:{count:o.count,source:"replay",truncated:n},blobKey:this.blobKeys.get(o.seq)??""}));while(this.rowsPosted<r.length){let o=r.slice(this.rowsPosted,this.rowsPosted+It);await this.call("POST",`/api/v1/reports/${e}/events`,{events:o}),this.rowsPosted+=o.length}}}async function Jt(e,t,n,r,o){let i=await fetch(n.url+t,{method:e,mode:"cors",credentials:"omit",headers:{authorization:`Bearer ${n.key}`,...o?{"x-vitrinka-reporter":o}:{},...r!==void 0?{"content-type":"application/json"}:{}},body:r===void 0?void 0:JSON.stringify(r)}),s=await i.text();if(!i.ok)throw new C(`${e} ${t} → ${i.status}: ${s}`,i.status);return s?JSON.parse(s):{}}async function Al(e,t,n=""){if(!n)return Jt("POST","/api/v1/report/session",e,{token:t});try{return await Jt("POST","/api/v1/report/session",e,{token:t,memberToken:n})}catch(o){if(wr(o)!=="memberToken")throw o;return console.warn("vitrinka: this server takes no member link yet — the reporter session opens without it"),Jt("POST","/api/v1/report/session",e,{token:t})}}function Rr(e,t){return e?JSON.stringify([e,t]):""}function Pl(e,t=Date.now()){return e!==null&&Date.parse(e.expiresAt)-t>60000}function Er(e,t,n){let r=n?`?cursor=${encodeURIComponent(n)}`:"";return Jt("GET",`/api/v1/report/mine${r}`,e,void 0,t)}function Ll(e,t){return`vitrinka.report.sent:${e}|${t}`}function Il(){try{return globalThis.localStorage??null}catch{return null}}function Cr(e,t){let n=Il()?.getItem(Ll(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 Ol(e,t,n){let r=Il();if(!r)return;let o=[n,...Cr(e,t)].slice(0,20);try{r.setItem(Ll(e,t),JSON.stringify(o))}catch(i){console.warn("vitrinka: could not remember the sent report on this browser",i)}}var Dl=`
10
10
  :host { all: initial; }
11
11
  .vr {
12
12
  --ink: #f2f1ef;
@@ -413,5 +413,5 @@ a.row:hover { background: var(--faint); }
413
413
  .card.busy .head::after { animation: none; }
414
414
  .fab, .fab.gliding { transition: none; }
415
415
  }
416
- `;var S$="http://www.w3.org/2000/svg",E8=100,v8=["box","circle","arrow","hide"],g5={w:160,h:80},b8=16,w8={w:380,h:460},_5=72,A5={w:300,h:160,gap:10},C5=16,E$={ArrowLeft:[-10,0],ArrowRight:[10,0],ArrowUp:[0,-10],ArrowDown:[0,10]},I={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>'},h8="0;0.18;0.72;1",F1="2.8s",f8="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14",b$='<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 w$(x,$,z){return`<animate attributeName="${x}" values="${$};${$};${z};${z}" keyTimes="${h8}" calcMode="linear" dur="${F1}" repeatCount="indefinite"/>`}function f$(x,$){let z=(U,F)=>$?F:U,Q=(U,F,W)=>$?"":w$(U,F,W),Z=$?"":`<animate attributeName="opacity" values="1;1;0" keyTimes="0;0.9;1" dur="${F1}" repeatCount="indefinite"/>`,J=$?"":`<animate attributeName="opacity" values="0;0;.9;.9;0;0" keyTimes="0;0.08;0.14;0.72;0.8;1" dur="${F1}" repeatCount="indefinite"/>`,X,V,G;if(x==="circle")V=f8,G={x:134,y:14},X=`<rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${f8}" pathLength="200" stroke-dasharray="200" stroke-dashoffset="${z(200,0)}">${Q("stroke-dashoffset",200,0)}${Z}</path>`;else if(x==="arrow"){V="M 74 54 L 128 33",G={x:128,y:33};let U=$?"":`<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.18;0.19;0.9;1" dur="${F1}" repeatCount="indefinite"/>`;X=`<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="${z(74,128)}" y2="${z(54,33)}" marker-end="url(#vr-coach-head)"${$?"":' opacity="0"'}>${Q("x2",74,128)}${Q("y2",54,33)}${U}</line>`}else{let U=x==="hide";V=U?"M 90 10 L 178 54":"M 96 12 L 172 52",G=U?{x:178,y:54}:{x:172,y:52};let F=U?90:96,W=U?10:12,q=G.x-F,M=G.y-W;X=(U?'<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="${U?"veil":"loop"}" x="${F}" y="${W}" width="${z(0,q)}" height="${z(0,M)}" rx="${U?4:6}">${Q("width",0,q)}${Q("height",0,M)}${Z}</rect>`}let Y=$?"":`<animateMotion dur="${F1}" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="${h8}" calcMode="linear" path="${V}"/>`;return`<svg viewBox="0 0 268 64" aria-hidden="true" data-shape="${x}">${X}<g class="pointer"${$?` transform="translate(${G.x} ${G.y})"`:""}><circle class="hold" r="9"${$?' opacity=".9"':' opacity="0"'}>${J}</circle>${b$}${Y}</g></svg>`}function j(x,$={},...z){let Q=document.createElement(x);for(let[Z,J]of Object.entries($))Q.setAttribute(Z,J);return Q.append(...z),Q}function A(x){let $=document.createElement("template");$.innerHTML=x;let z=$.content.firstElementChild;if(!z)throw Error("vitrinka: icon markup is empty");return z}function v(x,$){let z=document.createElementNS(S$,x);for(let[Q,Z]of Object.entries($))z.setAttribute(Q,String(Z));return z}function y8(x){let $=x.split(`
417
- `)[0]?.trim()??"";return $.length>E8?`${$.slice(0,E8-1)}…`:$}function k8(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function T5(){let x=document.activeElement;while(x?.shadowRoot?.activeElement)x=x.shadowRoot.activeElement;if(x===document.body)return null;return x instanceof HTMLElement||x instanceof SVGElement?x:null}function y$(x){return(x.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((z)=>z[0]?.toUpperCase()??"").join("")||"?"}function m(x,$){let z=x.querySelector("span");if(z)z.textContent=$}function p8(x,$,z,Q=!1){if(!z||!z.offsetWidth)return;let Z=Q||!x.classList.contains("measured");if(Z)$.style.transition="none";if($.style.width=`${z.offsetWidth}px`,$.style.transform=`translateX(${z.offsetLeft}px)`,x.classList.add("measured"),!Z)return;$.offsetWidth,$.style.removeProperty("transition")}function k$(){let x=T5();return x instanceof HTMLInputElement||x instanceof HTMLTextAreaElement||x instanceof HTMLElement&&x.isContentEditable}function R5(x,$){let z=x.target;if(!$||!(z instanceof Element))return!1;try{return z.closest($)!==null}catch{return!1}}function p$(x){let $=j("span"),z=j("kbd",{"aria-hidden":"true"}),Q=j("button",{class:"fab",type:"button",part:"button","aria-haspopup":"dialog"},$,z),Z=j("h2",{id:"vr-title"}),J=j("span",{class:"av","aria-hidden":"true"}),X=j("span",{class:"who-name"}),V=j("button",{class:"who",type:"button","aria-haspopup":"dialog","aria-expanded":"false"},J,X),G=j("button",{class:"icon",type:"button","aria-haspopup":"menu","aria-expanded":"false"},A(I.dots)),Y=j("button",{class:"icon",type:"button"},A(I.close)),U=j("header",{class:"head"},Z,V,G,Y),F=j("strong"),W=j("span",{class:"acc-mail"}),q=j("p",{class:"acc-via"}),M=j("p",{class:"acc-linked"}),H=j("button",{class:"link",type:"button"}),D=j("button",{class:"pop-item",type:"button"},A(I.link),j("span")),N=j("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},A(I.ext),j("span")),B=j("div",{class:"pop acc",role:"dialog"},j("div",{class:"acc-who"},F,W,q),j("div",{class:"acc-member"},M,H),D,N),K=(b)=>j("button",{class:"pop-item",type:"button",role:"menuitem"},A(b),j("span")),T=K(I.list),y0=K(I.clock),k0=K(I.rec),M1=j("small",{class:"pop-why",id:"vr-record-why","aria-hidden":"true"});k0.append(M1);let p0=K(I.gear),b5=j("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},A(I.ext),j("span")),w5=j("div",{class:"pop more",role:"menu"},T,y0,k0,p0,b5),f5=j("span",{class:"sr",id:"vr-kinds"}),e1=new Map;for(let b of x6)e1.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-kind":b}));let y5=j("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},f5,...e1.values()),k5=j("label",{class:"prompt",for:"vr-desc"}),p5=j("textarea",{class:"desc",id:"vr-desc",rows:"3"}),v5=j("ol",{class:"lines"}),h5=j("p",{class:"ln-empty"}),m5=j("span"),u5=j("span"),d5=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},u5,A(I.chevron)),l5=j("div",{class:"attached"},A(I.clip),m5,j("span",{"aria-hidden":"true"},"·"),d5),c5=j("ul",{class:"included",id:"vr-included"}),i5=j("input",{type:"checkbox"}),o5=j("span"),n5=j("label",{class:"notify"},i5,o5),a5=j("p",{class:"error",role:"alert"}),r5=j("span"),s5=j("button",{class:"where",type:"button","aria-pressed":"false"},A(I.pen),r5),t5=j("button",{class:"send",type:"button"}),e5=j("div",{class:"pane describe"},y5,k5,p5,j("div",{class:"lines-wrap"},v5,h5),l5,c5,n5,a5),xx=j("button",{class:"icon",type:"button"},A(I.clip)),$x=j("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),zx=j("p",{class:"file-note",role:"status"}),Qx=j("ul",{class:"files"}),Zx=j("div",{class:"tray"},zx,Qx),Jx=j("div",{class:"foot"},xx,$x,s5,t5),Xx=j("span",{class:"label",id:"vr-bind-label"}),Vx=j("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),Gx=j("button",{class:"link",type:"button"}),jx=j("p",{class:"hint"}),Yx=j("p",{class:"reason",role:"status"}),Wx=j("button",{class:"link",type:"button"}),Ux=j("span",{class:"label",id:"vr-size-label"}),x2=new Map;for(let b of a2)x2.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-size":b}));let qx=j("span",{class:"seg-ind","aria-hidden":"true"}),Fx=j("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},qx,...x2.values()),Mx=j("span",{class:"label",id:"vr-coach-label"}),Kx=j("button",{class:"switch",type:"button",role:"switch","aria-checked":"true","aria-labelledby":"vr-coach-label"},j("span",{class:"knob","aria-hidden":"true"})),Dx=j("span"),Hx=j("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},Dx,A(I.chevron)),Nx=j("dl",{class:"tech",id:"vr-tech"}),Px=j("div",{class:"pane settings"},j("div",{class:"row"},Xx,Vx),Yx,jx,j("div",{class:"row size-row"},Ux,Fx),j("div",{class:"row tips-row"},Mx,Kx),j("div",{class:"tech-wrap"},Hx,Nx),j("div",{class:"settings-foot"},Wx,Gx)),Bx=j("h3"),Ox=j("p",{class:"sent-body"}),Lx=j("span"),Ix=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Lx),gx=j("button",{class:"link",type:"button"}),_x=j("div",{class:"pane sent",role:"status"},j("div",{class:"sent-head"},A(I.check),Bx),Ox,j("div",{class:"sent-actions"},Ix,gx)),$2=()=>j("button",{class:"back",type:"button"},A(I.left),j("span")),Ax=$2(),Cx=j("p",{class:"list-status"}),Tx=j("ul",{class:"rows"}),Rx=j("p",{class:"list-note"}),Sx=j("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),Ex=j("div",{class:"pane list"},Ax,Cx,Tx,Rx,Sx),bx=$2(),wx=j("p",{class:"list-status"}),fx=j("ul",{class:"rows"}),yx=j("div",{class:"pane list"},bx,wx,fx),kx=$2(),px=j("p",{class:"list-note"}),vx=j("div",{class:"code"}),hx=j("span"),mx=j("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},hx),ux=j("img",{class:"qr",alt:""}),dx=j("p",{class:"hint"}),lx=j("p",{class:"list-status",role:"status"}),cx=j("button",{class:"link",type:"button"}),ix=j("div",{class:"pane linking"},kx,px,vx,j("div",{class:"link-go"},mx,ux),dx,lx,cx),ox=j("div",{class:"coach-art"}),nx=j("p"),ax=j("p"),rx=j("button",{class:"coach-ok",type:"button"}),sx=j("div",{class:"coach",role:"status"},ox,nx,ax,rx),tx=j("p",{class:"sr-only",id:"vr-keys"}),ex=j("div",{class:"body"},e5,Px,_x,Ex,yx,ix),x4=j("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},U,B,w5,ex,Zx,Jx,sx),z2=v("svg",{class:"ink","aria-hidden":"true"}),$4=v("defs",{}),z4=v("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});z4.append(v("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),$4.append(z4);let Q4=v("g",{}),Z4=v("g",{class:"draft"});z2.append($4,Q4,Z4);let J4=j("div",{class:"pins"}),Q2=new Map,X4=new Map;for(let b of v8){let D4=j("span");X4.set(b,D4),Q2.set(b,j("button",{type:"button",role:"radio","aria-checked":"false","data-tool":b},A(I[b]),D4))}let V4=j("span",{class:"seg-ind","aria-hidden":"true"}),G4=j("div",{class:"seg",role:"radiogroup"},V4,...Q2.values()),j4=j("span",{class:"tb-lead"}),Y4=j("button",{type:"button",class:"tb-quiet"}),W4=j("span",{class:"tb-ask"}),U4=j("button",{type:"button",class:"tb-discard"}),q4=j("button",{type:"button",class:"tb-quiet"}),F4=j("span",{class:"tb-confirm",role:"group"},W4,U4,q4),M4=j("div",{class:"tb",role:"toolbar"},j4,G4,j("span",{class:"tb-sep","aria-hidden":"true"}),Y4,F4),Z2=j("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},J4,tx,M4);Z2.prepend(z2);let J2=j("div",{class:"vr"},Q,Z2,x4),K4=j("style");return K4.textContent=S8,J2.prepend(K4),x.append(J2),{root:J2,fab:Q,fabLabel:$,fabKbd:z,card:x4,head:U,title:Z,whoBtn:V,whoAv:J,whoName:X,more:G,closeBtn:Y,body:ex,foot:Jx,accountPop:B,accName:F,accMail:W,accVia:q,accLinked:M,accUnlink:H,accLink:D,accPortal:N,morePop:w5,mReports:T,mRecents:y0,mRecord:k0,mRecordWhy:M1,mSettings:p0,mOpen:b5,reports:Ex,repBack:Ax,repStatus:Cx,repRows:Tx,repLocal:Rx,repPortal:Sx,recents:yx,recBack:bx,recStatus:wx,recRows:fx,linking:ix,linkBack:kx,linkLabel:px,linkCode:vx,linkOpen:mx,linkOpenText:hx,linkQr:ux,linkHint:dx,linkWait:lx,linkRetry:cx,describe:e5,kinds:y5,kindsLabel:f5,kindButtons:e1,prompt:k5,desc:p5,lines:v5,linesEmpty:h5,attached:l5,attachedText:m5,disclose:d5,discloseText:u5,included:c5,notify:n5,notifyBox:i5,notifyText:o5,error:a5,where:s5,whereText:r5,send:t5,attach:xx,fileInput:$x,fileNote:zx,files:Qx,tray:Zx,settings:Px,bindLabel:Xx,bindBtn:Vx,unbind:Gx,bindHint:jx,bindReason:Yx,back:Wx,sizeLabel:Ux,sizeButtons:x2,sizeInd:qx,sizeSeg:Fx,coachLabel:Mx,coachSwitch:Kx,techText:Dx,techBtn:Hx,tech:Nx,sent:_x,sentTitle:Bx,sentBody:Ox,see:Ix,seeText:Lx,sentClose:gx,mark:Z2,ink:z2,shapes:Q4,draft:Z4,pins:J4,coach:sx,coachArtSlot:ox,coachText:nx,coachMore:ax,coachDismiss:rx,coachKeys:tx,toolbar:M4,barLead:j4,seg:G4,segInd:V4,toolButtons:Q2,toolLabels:X4,cancel:Y4,ask:F4,askText:W4,discard:U4,keep:q4}}class S5{opts;hud;engine;config=null;locale;s;button;openSelector;identity;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool=v8[0];coachOn=I6();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=C6();size=L6();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((x)=>x instanceof HTMLDialogElement);activeDialog(){this.dialogOrder=this.dialogOrder.filter((z)=>z.isConnected&&z.open);let x=(z)=>{try{return z.matches(":modal")}catch{return!1}};return[...this.dialogOrder].reverse().find(x)??this.dialogOrder.at(-1)??U6()}sheet=null;e;constructor(x){this.opts=x;this.locale=x.locale??i2(),this.s=c2(this.locale),this.button=x.button,this.openSelector=x.openSelector??null,this.identity=x.identity===void 0?void 0:n1(x.identity),this.keybind=H8(),this.hud=Y6(),this.e=p$(this.hud.mount),this.engine=V8({base:x.base,key:x.key,appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl,loadRecord:x.loadRecord}),this.engine?.ready.then(($)=>{this.config=$,this.paint()}),this.bind(),this.paint(),this.followDialog()}followDialog(){let x=this.activeDialog();if((this.sheet?.target??null)===x)return;let $=this.e.root.getRootNode(),z=$ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement?$.activeElement:null,Q=this.sheet;if(x){let Z=q6(x);Z.mount.append(this.e.root),this.sheet={target:x,host:Z}}else this.hud.mount.append(this.e.root),this.sheet=null;Q?.host.destroy(),z?.focus()}open(){if(this.isOpen)return;if(this.isOpen=!0,this.opener=F6(document.activeElement)?null:T5(),this.view!=="describe")this.view="describe";if(this.result=null,!this.job)this.frozen=this.engine?.freeze()??null;this.paint(),requestAnimationFrame(()=>this.e.desc.focus()),this.refreshWho(),this.refreshMember()}close(){if(!this.isOpen)return;if(this.marking)this.endMarking(!1);this.stopRecordingBind(),this.isOpen=!1,this.view="describe",this.unpark(),this.paint();let x=this.opener;if(this.opener=null,x?.focus(),x&&T5()===x)return;if(this.button)this.e.fab.focus()}setLocale(x){let $=x1(x)??i2();if($===this.locale)return;this.locale=$,this.s=c2($),this.paint()}setButton(x){this.button=x,this.paint()}setOpenSelector(x){this.openSelector=x||null}setRecordSwitch(x){this.recordSwitch=x,this.paint()}identify(x){this.identity=x===void 0?void 0:n1(x),this.whoChanged()}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let x of this.offs.splice(0).reverse())x();G8(this.engine),this.sheet?.host.destroy(),this.sheet=null,this.hud.destroy()}bind(){let x=this.e,$=(V,G,Y)=>{V.addEventListener(G,Y)};$(x.fab,"click",()=>{if(this.swallowClick){this.swallowClick=!1;return}if(this.isOpen)this.close();else this.open()}),$(x.fab,"pointerdown",(V)=>this.fabDown(V)),$(x.fab,"pointermove",(V)=>this.fabMove(V)),$(x.fab,"pointerup",(V)=>this.fabUp(V,!0)),$(x.fab,"pointercancel",(V)=>this.fabUp(V,!1)),$(x.fab,"keydown",(V)=>{if(!V.altKey||V.ctrlKey||V.metaKey||V.shiftKey)return;let G=S6(this.dock,V.key);if(!G)return;if(V.preventDefault(),G!==this.dock)this.moveDock(G)}),$(x.attach,"click",()=>x.fileInput.click()),$(x.fileInput,"change",()=>{this.addFiles([...x.fileInput.files??[]]),x.fileInput.value=""}),$(x.card,"paste",(V)=>{let G=[...V.clipboardData?.files??[]];if(!G.length||!this.canAttach())return;let Y=V.clipboardData?.getData("text/plain").trim()??"";if(Y&&!G.some((U)=>U.name&&Y.includes(U.name)))return;V.preventDefault(),this.addFiles(G.map((U)=>{let F=B6(U.name,++this.pastes);return F===U.name?U:new File([U],F,{type:U.type,lastModified:U.lastModified})}))}),$(x.card,"dragover",(V)=>{if(!V.dataTransfer?.types.includes("Files")||!this.canAttach())return;V.preventDefault(),V.dataTransfer.dropEffect="copy",x.card.classList.add("dropping")}),$(x.card,"dragleave",(V)=>{if(V.relatedTarget instanceof Node&&x.card.contains(V.relatedTarget))return;x.card.classList.remove("dropping")}),$(x.card,"drop",(V)=>{x.card.classList.remove("dropping");let G=[...V.dataTransfer?.files??[]];if(!G.length||!this.canAttach())return;V.preventDefault(),this.addFiles(G)});for(let[V,G]of x.sizeButtons)$(G,"click",()=>{if(this.size=V,Z1(r2,V),this.paint(),this.parked)this.placeCard(!0)});let z=(V)=>{this.coachOn=V,Z1(s2,V?"on":"off"),this.paint()};$(x.coachDismiss,"click",()=>{if(z(!1),this.marking)x.mark.focus()}),$(x.coachSwitch,"click",()=>z(!this.coachOn)),$(x.techBtn,"click",()=>{this.techOpen=!this.techOpen,this.paint()}),$(x.closeBtn,"click",()=>this.close()),$(x.whoBtn,"click",()=>this.toggleMenu("account")),$(x.more,"click",()=>this.toggleMenu("more"));let Q=(V)=>()=>{this.menu=null,V(),this.paint()};$(x.morePop,"keydown",(V)=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(V.key))return;let G=[...x.morePop.querySelectorAll('[role="menuitem"]')].filter((M)=>!M.hidden&&!(M instanceof HTMLButtonElement&&M.disabled));if(!G.length)return;V.preventDefault();let Y=x.morePop.getRootNode(),U=G.indexOf(Y.activeElement),F=G.length-1,W=V.key==="ArrowDown",q=V.key==="Home"?0:V.key==="End"?F:U<0?W?0:F:(U+(W?1:-1)+G.length)%G.length;G[q]?.focus()}),$(x.mReports,"click",Q(()=>void this.openReports())),$(x.mRecents,"click",Q(()=>this.show("recents")));let Z=Q(()=>this.recordSwitch?.());$(x.mRecord,"click",()=>{if(!this.recordWaits())Z()}),$(x.mSettings,"click",Q(()=>this.show("settings"))),$(x.mOpen,"click",Q(()=>{return})),$(x.accPortal,"click",Q(()=>{return})),$(x.accLink,"click",Q(()=>this.startLinkFlow())),$(x.accUnlink,"click",()=>{H1(),this.member=null,this.paint()});for(let V of[x.repBack,x.recBack,x.linkBack])$(V,"click",()=>this.show("describe"));$(x.linkRetry,"click",()=>this.startLinkFlow()),$(x.card,"pointerdown",(V)=>{let G=V.target;if(!this.menu||!(G instanceof Node))return;if([x.accountPop,x.morePop,x.whoBtn,x.more].some((Y)=>Y.contains(G)))return;this.menu=null,this.paint()}),$(x.back,"click",()=>this.show("describe")),$(x.sentClose,"click",()=>this.close()),$(x.desc,"input",()=>this.paint()),$(x.disclose,"click",()=>{this.includedOpen=!this.includedOpen,this.paint()}),$(x.notifyBox,"change",()=>{this.notify=x.notifyBox.checked}),$(x.where,"click",()=>this.marking?this.endMarking(!0):this.startMarking()),$(x.send,"click",()=>void this.send()),$(x.bindBtn,"click",()=>this.recordingBind?this.stopRecordingBind():this.startRecordingBind()),$(x.unbind,"click",()=>{this.keybind=null,K5(null),this.paint()});for(let[V,G]of x.kindButtons)$(G,"click",()=>{this.kind=this.kind===V?null:V,this.paint()});$(x.card,"keydown",(V)=>{if(V.key!=="Escape"||this.recordingBind||V.defaultPrevented)return;if(V.preventDefault(),this.menu){let G=this.menu==="account"?x.whoBtn:x.more;this.menu=null,this.paint(),G.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close()});for(let[V,G]of x.toolButtons)$(G,"click",(Y)=>{if(this.tool=V,this.renderKbDraft(),this.paint(),this.placeSeg(),Y.detail===0)x.mark.focus()});if($(x.mark,"keydown",(V)=>this.markKey(V)),$(x.cancel,"click",()=>this.cancelMarking()),$(x.discard,"click",()=>{this.markers=s1(this.markers.filter((V)=>this.passKeys.has(V.key))),this.renderMarks(),this.endMarking(!0)}),$(x.keep,"click",()=>{this.confirming=!1,this.paint(),x.cancel.focus()}),$(x.mark,"pointerdown",(V)=>this.pointerDown(V)),$(x.mark,"pointermove",(V)=>this.pointerMove(V)),$(x.mark,"pointerup",(V)=>this.pointerUp(V)),$(x.mark,"pointercancel",()=>this.cancelDraft()),this.offs.push(R(x.mark,"wheel",(V)=>V.preventDefault())),this.offs.push(R(x.mark,"touchmove",(V)=>V.preventDefault())),this.offs.push(R(window,"keydown",(V)=>{if(this.recordingBind)return;if(this.marking&&V.key==="Escape"){if(V.preventDefault(),this.confirming)x.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);return}if(this.marking&&(V.metaKey||V.ctrlKey)&&!V.shiftKey&&!V.altKey&&V.key.toLowerCase()==="z"&&!k$()){V.preventDefault(),this.markers=s1(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&q8(V,this.keybind))if(V.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(R(document,"click",(V)=>{if(!R5(V,this.openSelector))return;V.preventDefault(),this.open()})),this.offs.push(R(window,"resize",()=>{if(this.parked)this.placeCard(!0);if(this.marking)this.placeSeg()})),this.offs.push(N8((V)=>{this.keybind=V,this.paint()})),this.offs.push(W8(()=>this.whoChanged())),this.linkSeen=K0(this.opts.base),this.offs.push(y1(()=>this.linkChanged())),this.engine)this.offs.push(this.engine.onChange(()=>this.paint()));let J=0,X=new MutationObserver((V)=>{for(let G of V){if(G.type!=="attributes"||G.attributeName!=="open"||!(G.target instanceof HTMLDialogElement))continue;let Y=G.target;if(!Y.open)this.dialogOrder=this.dialogOrder.filter((U)=>U!==Y);else if(G.oldValue===null)this.dialogOrder=[...this.dialogOrder.filter((U)=>U!==Y),Y]}if(J)return;J=requestAnimationFrame(()=>{J=0,this.followDialog()})});X.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["open","data-state"]}),this.offs.push(()=>{if(X.disconnect(),J)cancelAnimationFrame(J)})}show(x){if(this.stopRecordingBind(),x!=="link"&&this.linkFlow)this.linkFlow.abort.abort(),this.linkFlow=null;this.view=x,this.paint();let $={describe:this.e.desc,settings:this.e.bindBtn,sent:null,reports:this.e.repBack,recents:this.e.recBack,link:this.e.linkBack}[x];if($)requestAnimationFrame(()=>$.focus())}target(){return{url:this.opts.base,key:this.opts.key}}toggleMenu(x){if(this.menu=this.menu===x?null:x,this.menu==="account")this.refreshWho(),this.refreshMember();this.paint(),(this.menu==="account"?this.e.accountPop:this.menu==="more"?this.e.morePop:null)?.querySelector("button:not([hidden]), a:not([hidden])")?.focus()}async refreshWho(){let x=this.whoToken();if(!x)return this.session=null,this.sessionKey="",null;let $=K0(this.opts.base),z=O5(x,$);if(this.sessionKey===z&&A8(this.session))return this.session;this.sessionKey=z;let Q=null;try{Q=await _8(this.target(),x,$)}catch(Z){console.warn("vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only",Z)}if(this.sessionKey!==z)return null;if(this.session=Q,this.paint(),Q?.memberError)this.memberRefused(Q.memberError,$);return this.sessionKey===z?this.session:null}whoKey(){return O5(this.whoToken(),K0(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 x=K0(this.opts.base);if(x===this.linkSeen)return;if(this.linkSeen=x,this.member=null,x&&this.isOpen)this.refreshMember();this.whoChanged()}memberRefused(x,$){let z=a3(x);if(console.warn(`vitrinka: vitrinka did not take this browser’s member link (${x}) — ${z?"it is forgotten; link the account again":"it stays linked, and the reporter alone owns what goes with it"}`),z&&$&&X0()?.token===$)D6()}async refreshMember(){let x=b0(this.opts.base)?X0():null;if(!x){if(this.member)this.member=null,this.paint();return}let $,z;try{let Q=await n("GET","/api/v1/recorder/me",void 0,{target:{url:this.opts.base,key:x.token}});$={email:Q.user?.email??"",name:Q.user?.name??"",workspace:Q.workspace?.slug??x.workspace},z=Q.displayMode}catch(Q){console.warn("vitrinka: the linked vitrinka account could not be read",Q),$={email:"",name:"",workspace:x.workspace}}if(K0(this.opts.base)!==x.token)return;this.member=$,s3(z),this.paint()}async openReports(){this.show("reports"),await this.loadReports()}async loadReports(){let x=this.whoKey(),$=await this.refreshWho();if(this.whoKey()!==x)return;if(!$){this.mine={rows:[],state:"ok"},this.paint();return}this.mine={rows:[],state:"loading"},this.paint();let z;try{z={rows:await this.listMineRenewing($),state:"ok"}}catch(Q){console.warn("vitrinka: My reports could not be loaded",Q),z={rows:[],state:"failed"}}if(this.whoKey()!==x)return;this.mine=z,this.paint()}async listMineRenewing(x){try{return(await L5(this.target(),x.session)).reports}catch($){if(!($ instanceof _)||$.status!==401)throw $;this.session=null,this.sessionKey="";let z=await this.refreshWho();if(!z)throw $;return(await L5(this.target(),z.session)).reports}}startLinkFlow(){this.linkFlow?.abort.abort();let x={start:null,state:"starting",abort:new AbortController};this.linkFlow=x,this.show("link");let $=this.opts.base,z=D1($);(async()=>{try{x.start=await I4($,{label:U2(),workspace:z}),x.state="waiting",this.paint();let Q=await g4($,x.start.device_code,{interval:x.start.interval,expiresIn:x.start.expires_in,workspace:z,signal:x.abort.signal});W2({...Q,base:$}),this.linkFlow=null,this.show("describe")}catch(Q){if(x.abort.signal.aborted)return;if(x.state=Q instanceof v0?"expired":"failed",x.state==="failed")console.warn("vitrinka: linking the vitrinka account failed",Q);this.paint()}})()}ago(x){let $=new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}),z=Math.round((x-Date.now())/1000),Q=[[60,"second"],[60,"minute"],[24,"hour"],[30,"day"],[12,"month"],[1/0,"year"]],Z=z;for(let[J,X]of Q){if(Math.abs(Z)<J)return $.format(Z,X);Z=Math.round(Z/J)}return $.format(Z,"year")}row(x,$,z,Q){let Z=[j("span",{class:"row-t"},x),j("span",{class:"step"},$),j("span",{class:"age"},this.ago(z))],J=Q?j("a",{class:"row",href:Q,target:"_blank",rel:"noopener noreferrer"},...Z):j("div",{class:"row"},...Z);return j("li",{},J)}who(){return this.identity!==void 0?this.identity:Y8()}whoToken(){let x=this.who();return x&&"token"in x?x.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=R(window,"keydown",(x)=>{x.preventDefault(),x.stopPropagation();let $=U8(x);if($.kind==="wait")return;if($.kind==="bare"){this.bindRefused=!0,this.paint();return}if($.kind==="bind")this.keybind=$.bind,K5($.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??Z0}addFiles(x){if(!x.length)return;let{files:$,refusal:z}=N6(this.files,x,this.caps());this.files=[...this.files,...$],this.fileRefusal=z,this.renderFiles(),this.paint()}removeFile(x){this.files=this.files.filter(($)=>$!==x),this.fileRefusal=null,this.renderFiles(),this.paint(),this.e.attach.focus()}renderFiles(){let x=new Set(this.files);for(let[$,z]of this.chips){if(x.has($))continue;z.el.remove(),this.chips.delete($)}for(let $ of this.files){if(this.chips.has($))continue;let z=j("span",{class:"file-size"}),Q=j("button",{class:"ln-x",type:"button"},A(I.close)),Z=j("li",{class:"file"},j("span",{class:"file-name"},$.name),z,Q);Q.addEventListener("click",()=>this.removeFile($)),this.e.files.append(Z),this.chips.set($,{el:Z,size:z,rm:Q})}}refusalText(x){let $=this.s;if(!x)return"";if(x.kind==="size")return $.fileTooBig(x.name,z1(x.cap,this.locale));if(x.kind==="count")return $.tooManyFiles(x.cap);return $.fileType(x.name,P6(this.caps().types,$.typeNames,this.locale))}fabDown(x){if(this.swallowClick=!1,x.button!==0||!x.isPrimary)return;let $=this.e.fab.getBoundingClientRect();this.fabDrag={pointer:x.pointerId,start:{x:x.clientX,y:x.clientY},grab:{x:x.clientX-$.left,y:x.clientY-$.top},moved:!1};try{this.e.fab.setPointerCapture(x.pointerId)}catch{}}fabMove(x){let $=this.fabDrag;if(!$||x.pointerId!==$.pointer)return;if(!$.moved&&Math.hypot(x.clientX-$.start.x,x.clientY-$.start.y)<A6)return;$.moved=!0;let z=this.e.fab;z.classList.add("dragging");let Q=z.getBoundingClientRect(),Z=globalThis.innerWidth||800,J=globalThis.innerHeight||600,X=z.style;X.left=`${Math.min(Math.max(0,x.clientX-$.grab.x),Z-Q.width)}px`,X.top=`${Math.min(Math.max(0,x.clientY-$.grab.y),J-Q.height)}px`,X.right="auto",X.bottom="auto"}fabUp(x,$){let z=this.fabDrag;if(!z||x.pointerId!==z.pointer)return;if(this.fabDrag=null,!z.moved)return;let Q=this.e.fab,Z=Q.getBoundingClientRect();Q.classList.remove("dragging");for(let V of["left","top","right","bottom"])Q.style.removeProperty(V);this.swallowClick=!0,setTimeout(()=>{this.swallowClick=!1},0);let J=globalThis.innerWidth||800,X=globalThis.innerHeight||600;this.moveDock($?R6({x:Z.left+Z.width/2,y:Z.top+Z.height/2},J,X):this.dock,Z)}moveDock(x,$){let z=this.e.fab,Q=$??z.getBoundingClientRect();if(this.dock=x,T6(x),this.paint(),z.hidden||k8())return;let Z=z.getBoundingClientRect(),J=Q.left-Z.left,X=Q.top-Z.top;if(!J&&!X)return;this.glide?.abort();let V=new AbortController;this.glide=V,z.classList.remove("gliding"),z.style.setProperty("translate",`${J}px ${X}px`),z.offsetWidth,z.classList.add("gliding"),z.style.setProperty("translate","0px 0px");let G=(Y)=>{if(Y.propertyName!=="translate")return;V.abort(),z.classList.remove("gliding"),z.style.removeProperty("translate")};z.addEventListener("transitionend",G,{signal:V.signal}),z.addEventListener("transitioncancel",G,{signal:V.signal})}startMarking(){if(this.job?.id)return;this.marking=!0,this.confirming=!1,this.passKeys=new Set(this.markers.map(($)=>$.key));let x=this.parked??this.dock;this.parkInsets=this.insetsAt(x,this.e.card.getBoundingClientRect()),this.parked=x,this.renderMarks(),this.paint(),this.placeCard(),this.placeSeg(!0),this.e.mark.focus()}endMarking(x){if(this.cancelDraft(),this.marking=!1,this.confirming=!1,this.paint(),x&&this.isOpen)requestAnimationFrame(()=>this.e.desc.focus())}cancelMarking(){if(this.markers.filter(($)=>!this.passKeys.has($.key)).length===0){this.endMarking(!0);return}this.confirming=!0,this.paint(),this.e.discard.focus()}insetsAt(x,$){let z=globalThis.innerWidth||800,Q=globalThis.innerHeight||600,Z=_5*Q1[this.size],J=x==="br"||x==="bl";return{edge:Math.max(0,Math.min($.left,z-$.right)),top:J?Z:Math.max(Z,$.top),bottom:J?Math.max(0,Q-$.bottom):C5}}frame(){let x=globalThis.innerWidth||800,$=globalThis.innerHeight||600,z=Q1[this.size],Q=this.parkInsets??{top:_5*z,bottom:C5,edge:C5},Z=this.e.card.getBoundingClientRect();return{vw:x,vh:$,w:Z.width||Math.min(w8.w*z,x-32),h:Z.height||Math.min(w8.h*z,$-Q.top-Q.bottom),...Q}}placeCard(x=!1){if(!this.parked)return;let $=this.frame(),z=this.parked;this.parked=B8(this.parked,this.markers.map((X)=>X.rect),$);let Q=D5(this.parked,$),Z=this.e.card,J=x&&this.parked===z;if(J)Z.style.transition="none";if(Z.classList.add("parked"),Z.style.left=`${Q.x}px`,Z.style.top=`${Q.y}px`,this.placeCoachSide(),!J)return;Z.offsetWidth,Z.style.removeProperty("transition")}placeCoachSide(){let x=Q1[this.size],$=this.e.coach;$.dataset.side="above";let z=$.offsetHeight||A5.h;$.dataset.side=O8(this.parked??this.dock,this.frame(),{w:A5.w*x,h:z*x},A5.gap*x)}unpark(){this.parked=null,this.parkInsets=null,this.e.card.classList.remove("parked"),this.e.card.style.removeProperty("left"),this.e.card.style.removeProperty("top")}placeSeg(x=!1){p8(this.e.seg,this.e.segInd,this.e.toolButtons.get(this.tool),x)}onChrome(x){return x instanceof Node&&(this.e.toolbar.contains(x)||this.e.pins.contains(x))}pointerDown(x){if(this.onChrome(x.target)||x.button!==0||!x.isPrimary)return;x.preventDefault();let $=this.e.root.getRootNode();if($ instanceof ShadowRoot&&$.activeElement instanceof HTMLElement)$.activeElement.blur();this.drawing={start:{x:x.clientX,y:x.clientY},shape:this.tool,pointer:x.pointerId};try{this.e.mark.setPointerCapture(x.pointerId)}catch{}this.e.coach.classList.add("pressing")}pointerMove(x){let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:$.shape,rect:G5($.start,{x:x.clientX,y:x.clientY}),head:j5($.start,{x:x.clientX,y:x.clientY})}))}pointerUp(x){let $=this.drawing;if(!$||x.pointerId!==$.pointer)return;let z={x:x.clientX,y:x.clientY};if(this.cancelDraft(),!n6($.shape,$.start,z))return;this.addMarker($.shape,G5($.start,z),$.shape==="arrow"?j5($.start,z):void 0)}addMarker(x,$,z){let Q=this.nextKey++;if(x==="hide"){let Z=this.engine?.hiddenIdsAt($);if(Z)this.hideIds.set(Q,Z)}this.markers=s1([...this.markers,{key:Q,n:this.markers.length+1,shape:x,rect:$,note:"",...z?{head:z}:{}}]),this.renderMarks(),this.paint(),this.lines.get(Q)?.note.focus()}cancelDraft(){this.drawing=null,this.kbDraft=null,this.e.draft.replaceChildren(),this.e.coach.classList.remove("pressing")}kbDraft=null;markKey(x){if(x.target!==this.e.mark)return;let $=globalThis.innerWidth||800,z=globalThis.innerHeight||600;if(x.key==="Enter"||x.key===" "){if(x.preventDefault(),!this.kbDraft){this.kbDraft={x:Math.round($/2-g5.w/2),y:Math.round(z/2-g5.h/2),...g5},this.renderKbDraft();return}let V=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,V,this.tool==="arrow"?"se":void 0);return}let Q=E$[x.key];if(!Q||!this.kbDraft)return;x.preventDefault();let Z=this.kbDraft,[J,X]=Q;this.kbDraft=x.shiftKey?{...Z,w:Math.min($-Z.x,Math.max(b8,Z.w+J)),h:Math.min(z-Z.y,Math.max(b8,Z.h+X))}:{...Z,x:Math.min($-Z.w,Math.max(0,Z.x+J)),y:Math.min(z-Z.h,Math.max(0,Z.y+X))},this.renderKbDraft()}renderKbDraft(){let x=this.kbDraft;if(!x)return;this.e.draft.replaceChildren(...this.shapeNodes({shape:this.tool,rect:x,head:"se"}))}shapeNodes(x){let{x:$,y:z,w:Q,h:Z}=x.rect;if(x.shape==="circle")return[v("ellipse",{class:"stroke",cx:$+Q/2,cy:z+Z/2,rx:Math.max(1,Q/2),ry:Math.max(1,Z/2)})];if(x.shape==="box")return[v("rect",{class:"stroke",x:$,y:z,width:Q,height:Z,rx:6})];if(x.shape==="arrow"){let{tail:V,tip:G}=Y5(x.rect,x.head??"se");return[v("line",{class:"stroke",x1:V.x,y1:V.y,x2:G.x,y2:G.y,"marker-end":"url(#vr-head)"})]}let J=v("rect",{class:"veil",x:$,y:z,width:Q,height:Z,rx:4}),X=v("text",{class:"veil-label",x:$+Q/2,y:z+Z/2+4,"text-anchor":"middle"});return X.textContent=Q>150&&Z>20?this.s.hidden:"",[J,X]}renderMarks(){this.e.shapes.replaceChildren(...this.markers.flatMap((z)=>this.shapeNodes(z)));let x=new Set(this.markers.map((z)=>z.key));for(let[z,Q]of this.pins){if(x.has(z))continue;Q.el.remove(),this.pins.delete(z)}for(let[z,Q]of this.lines){if(x.has(z))continue;Q.el.remove(),this.lines.delete(z)}let $=(z)=>{this.markers=s1(this.markers.filter((Q)=>Q.key!==z)),this.renderMarks(),this.paint()};for(let z of this.markers){if(this.pins.has(z.key))continue;let Q=j("button",{class:"num",type:"button"}),Z=j("button",{class:"rm",type:"button"},A(I.close)),J=j("div",{class:"pin"},Q,Z);Q.addEventListener("click",()=>this.lines.get(z.key)?.note.focus()),Z.addEventListener("click",()=>$(z.key)),this.e.pins.append(J),this.pins.set(z.key,{el:J,num:Q,rm:Z});let X=j("span",{class:"ln-n","aria-hidden":"true"}),V=j("input",{class:"ln-t",type:"text",maxlength:"500"}),G=j("button",{class:"ln-x",type:"button"},A(I.close)),Y=j("li",{class:"ln"},X,V,G);V.addEventListener("input",()=>{this.markers=this.markers.map((U)=>U.key===z.key?{...U,note:V.value}:U),this.paint()}),V.addEventListener("keydown",(U)=>{if(U.key!=="Enter"||!this.marking)return;U.preventDefault(),this.e.mark.focus()}),G.addEventListener("click",()=>$(z.key)),this.e.lines.append(Y),this.lines.set(z.key,{el:Y,num:X,note:V,rm:G})}for(let z of this.markers){let Q=this.lines.get(z.key);if(Q)this.e.lines.append(Q.el)}if(this.renderPins(),this.parked)this.placeCard()}renderPins(){let x=globalThis.innerWidth||800;for(let $ of this.markers){let z=this.pins.get($.key),Q=this.lines.get($.key);if(!z||!Q)continue;let Z=$.shape==="arrow"?Y5($.rect,$.head??"se").tail:{x:$.rect.x,y:$.rect.y};z.el.style.left=`${Math.min(Math.max(4,Z.x-12),x-60)}px`,z.el.style.top=`${Math.max(_5-12,Z.y-12)}px`,z.num.textContent=String($.n),z.num.setAttribute("aria-label",this.s.mark($.n)),z.rm.setAttribute("aria-label",this.s.removeMark($.n)),Q.num.textContent=String($.n),Q.el.classList.toggle("hide",$.shape==="hide"),Q.note.placeholder=this.s.notePlaceholder,Q.note.setAttribute("aria-label",`${this.s.mark($.n)} — ${this.s.notePlaceholder}`),Q.rm.setAttribute("aria-label",this.s.removeMark($.n))}}envelope(x,$){let z=this.who(),Q=K0(this.opts.base),Z=globalThis.location;return{title:y8(x),description:x,env:{url:V0(Z?`${Z.origin}${Z.pathname}`:""),ua:globalThis.navigator?.userAgent??"",viewport:{w:globalThis.innerWidth||0,h:globalThis.innerHeight||0,dpr:globalThis.devicePixelRatio||1},appVersion:this.opts.appVersion??"",locale:globalThis.navigator?.language??""},console:$.console,network:$.network,...z?{identity:z,notify:this.notify}:{},markers:r6(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{},...Q?{memberToken:Q}:{}}}words(){return this.e.desc.value.trim()||(this.markers.find((x)=>x.note.trim())?.note.trim()??"")}hasDraft(){return this.e.desc.value.trim()!==""||this.markers.length>0||this.kind!==null||this.files.length>0}recordWaits(){return this.sending||this.job!==null||this.hasDraft()}async send(){let x=this.words();if(this.sending||!x)return;if(this.marking)this.endMarking(!1);if(this.sending=!0,this.error="",this.paint(),this.job&&!this.job.id)this.job=null;try{if(!this.job){let $=new Set;for(let J of this.markers)for(let X of this.hideIds.get(J.key)??[])$.add(X);let z=this.engine,Q=this.frozen??{clip:null,stored:Promise.resolve(new Map)},Z=z?await g8(()=>z.build(Q,this.markers,$)):P5;this.job=new B5(Z,globalThis.location?.host??"",{url:this.opts.base,key:this.opts.key},this.files)}this.result=await this.job.run(this.envelope(x,this.job.capture),($,z)=>this.memberRefused($,z)),R8(this.opts.base,globalThis.location?.host??"",{title:y8(x),at:Date.now(),status:this.result.status,...this.result.reportUrl?{url:this.result.reportUrl}:{}}),this.sentNotify=this.notify&&this.who()!==null,this.view="sent",this.job=null,this.frozen=null,this.e.desc.value="",this.markers=[],this.hideIds.clear(),this.kind=null,this.notify=!1,this.e.notifyBox.checked=!1,this.includedOpen=!1,this.files=[],this.fileRefusal=null,this.renderMarks(),this.renderFiles(),this.engine?.clear()}catch($){console.warn("vitrinka: the report did not go through — Retry resumes it",$),this.error=!this.job?.id?"create":this.job.filesPending?"files":"capture"}finally{this.sending=!1,this.paint()}if(this.view==="sent")requestAnimationFrame(()=>((this.result?.reportUrl)?this.e.see:this.e.sentClose).focus())}includedItems(){let x=this.s,$=[],z=this.config?.lanes;if(z?.replay)$.push(`${x.incReplay} — ${x.incReplayMasked[this.config?.masking??"strict"].toLowerCase()}`);if(z?.errors)$.push(x.incErrors);if(z?.console)$.push(x.incConsole);if(z?.network)$.push(x.incNetwork);else if(z?.errors)$.push(x.incFailedRequests);if($.push(x.incEnv),this.who())$.push(x.incIdentity);if(this.markers.length)$.push(x.incMarks);if(this.files.length)$.push(x.incFiles);return $}paintAccount(){let{e:x,s:$}=this,z=this.who(),Q=!z?null:("email"in z)?{name:z.name??"",email:z.email}:this.session?{name:this.session.reporter.name??"",email:this.session.reporter.email}:null,Z=Q?.name||Q?.email||"";x.whoAv.textContent=z?y$(Z):"?",x.whoName.textContent=Z.split(/[\s@]/)[0]??"",x.whoName.hidden=!Z,x.whoBtn.setAttribute("aria-label",`${$.account}: ${Z||(z?"":$.anonymous)}`.replace(/: $/,"")),x.whoBtn.setAttribute("aria-expanded",String(this.menu==="account")),x.more.setAttribute("aria-label",$.menu),x.more.setAttribute("aria-expanded",String(this.menu==="more")),x.accountPop.hidden=this.menu!=="account",x.morePop.hidden=this.menu!=="more",x.accountPop.setAttribute("aria-label",$.account),x.morePop.setAttribute("aria-label",$.menu),x.accName.textContent=z?Q?.name||Q?.email||"":$.anonymous,x.accMail.textContent=Q?.name?Q.email:"",x.accMail.hidden=!x.accMail.textContent,x.accVia.textContent=z&&"token"in z?$.signedInByApp:$.anonymousHint;let J=this.member;x.accLinked.hidden=!J,x.accUnlink.hidden=!J,x.accLinked.textContent=J?$.linkedAs(J.email||J.name||J.workspace):"",x.accUnlink.textContent=$.unlink,x.accLink.hidden=Boolean(J),m(x.accLink,$.linkVitrinka);let X=this.session?.portalUrl;if(x.accPortal.hidden=!X,X)x.accPortal.setAttribute("href",X);m(x.accPortal,$.openPortal),m(x.mReports,$.myReports),m(x.mRecents,$.recentRecordings),m(x.mRecord,$.record),m(x.mSettings,$.settings),x.mRecents.hidden=!this.recordSwitch,x.mRecord.hidden=!this.recordSwitch;let V=this.recordWaits();if(V)x.mRecord.setAttribute("aria-disabled","true");else x.mRecord.removeAttribute("aria-disabled");if(x.mRecordWhy.hidden=!V,x.mRecordWhy.textContent=$.recordHasDraft,V)x.mRecord.setAttribute("aria-describedby",x.mRecordWhy.id);else x.mRecord.removeAttribute("aria-describedby");let G=J?this.opts.base:X;if(x.mOpen.hidden=!G,G)x.mOpen.setAttribute("href",G);m(x.mOpen,J?$.openVitrinka:$.openPortal)}paintReports(){let{e:x,s:$}=this;m(x.repBack,$.myReports);let z=!this.session,Q=z?I5(this.opts.base,globalThis.location?.host??"").map((X)=>this.row(X.title,X.status==="quarantined"?$.waiting:$.steps.received??"",X.at,X.url)):this.mine.rows.map((X)=>this.row(X.title,$.steps[X.step]??X.step,Date.parse(X.updatedAt),X.url));x.repRows.replaceChildren(...Q);let Z=z?"ok":this.mine.state;x.repStatus.hidden=Z==="ok"&&Q.length>0,x.repStatus.textContent=Z==="loading"?$.loading:Z==="failed"?$.listFailed:$.noReports,x.repLocal.hidden=!z||Q.length===0,x.repLocal.textContent=$.fromThisBrowser;let J=this.session?.portalUrl;if(x.repPortal.hidden=!J,J)x.repPortal.setAttribute("href",J);x.repPortal.textContent=$.openPortal}paintRecents(){let{e:x,s:$}=this;m(x.recBack,$.recentRecordings);let z=o2().map((Q)=>this.row(Q.title,"",Q.startedAt,Q.boardUrl));x.recRows.replaceChildren(...z),x.recStatus.hidden=z.length>0,x.recStatus.textContent=$.noRecordings}paintLink(){let{e:x,s:$}=this,z=this.linkFlow;m(x.linkBack,$.linkVitrinka),x.linkLabel.textContent=$.linkCode,x.linkCode.textContent=z?.start?.user_code??"…",x.linkOpenText.textContent=$.openVitrinka;let Q=z?.start;if(x.linkOpen.hidden=!Q,Q)x.linkOpen.setAttribute("href",Q.verifyUrl);let Z=globalThis.matchMedia?.("(pointer: fine)").matches??!0;if(x.linkQr.hidden=!Q||!Z,Q&&Z&&x.linkQr.getAttribute("src")!==Q.qrUrl)x.linkQr.setAttribute("src",Q.qrUrl);x.linkHint.textContent=$.linkHint;let J=z?.state??"failed";x.linkWait.textContent=J==="expired"?$.linkExpired:J==="failed"?$.linkFailed:J==="waiting"?$.linkWaiting:$.loading,x.linkRetry.hidden=J!=="expired"&&J!=="failed",x.linkRetry.textContent=$.retry}paintFiles(){let{e:x,s:$}=this,z=this.sending||Boolean(this.job?.id);x.attach.setAttribute("aria-label",$.attach),x.attach.disabled=z,x.attach.hidden=this.caps().maxCount===0,x.fileInput.setAttribute("accept",this.caps().types.join(",")),x.tray.hidden=this.view!=="describe"||this.files.length===0&&!this.fileRefusal,x.files.hidden=this.files.length===0,x.files.setAttribute("aria-label",$.incFiles),x.fileNote.hidden=!this.fileRefusal,x.fileNote.textContent=this.refusalText(this.fileRefusal);for(let[Q,Z]of this.chips)Z.size.textContent=z1(Q.size,this.locale),Z.rm.setAttribute("aria-label",$.removeFile(Q.name)),Z.rm.disabled=z}paintSettings(){let{e:x,s:$}=this;x.sizeLabel.textContent=$.size,x.coachLabel.textContent=$.coachSetting,x.coachSwitch.setAttribute("aria-checked",String(this.coachOn));for(let[z,Q]of x.sizeButtons)Q.textContent=$.sizes[z],Q.setAttribute("aria-checked",String(this.size===z));if(x.techText.textContent=$.techDetails,x.techBtn.setAttribute("aria-expanded",String(this.techOpen)),x.tech.hidden=!this.techOpen,this.techOpen&&this.view==="settings"){let z=g6({version:c3,base:this.opts.base,config:this.config,engine:this.engine!==null,locale:this.locale},$);x.tech.replaceChildren(...z.flatMap(([Q,Z])=>[j("dt",{},Q),j("dd",{},Z)]))}if(this.view==="settings")p8(x.sizeSeg,x.sizeInd,x.sizeButtons.get(this.size))}paint(){let{e:x,s:$}=this,z=this.who();if(x.root.setAttribute("lang",this.locale),x.root.classList.toggle("nobutton",!this.button),x.root.dataset.dock=this.dock,x.root.style.setProperty("--vr-scale",String(Q1[this.size])),x.fab.hidden=!this.button||this.marking,x.fabLabel.textContent=$.button,x.fab.setAttribute("aria-expanded",String(this.isOpen)),x.fab.setAttribute("aria-description",$.moveHint),x.fab.setAttribute("aria-keyshortcuts",`${this.keybind?`${M8(this.keybind)} `:""}Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight`),x.fabKbd.hidden=!this.keybind,x.fabKbd.textContent=this.keybind?a1(this.keybind):"",x.card.hidden=!this.isOpen,x.card.classList.toggle("busy",this.sending),x.title.textContent=$.title,x.closeBtn.setAttribute("aria-label",$.close),this.paintAccount(),x.describe.hidden=this.view!=="describe",x.settings.hidden=this.view!=="settings",x.sent.hidden=this.view!=="sent",x.reports.hidden=this.view!=="reports",x.recents.hidden=this.view!=="recents",x.linking.hidden=this.view!=="link",this.view==="reports")this.paintReports();if(this.view==="recents")this.paintRecents();if(this.view==="link")this.paintLink();x.foot.hidden=this.view!=="describe",this.paintFiles(),x.kindsLabel.textContent=$.kindsLabel;for(let[Z,J]of x.kindButtons)J.textContent=$.kinds[Z],J.setAttribute("aria-checked",String(this.kind===Z)),J.disabled=this.sending||Boolean(this.job?.id);x.prompt.textContent=$.prompt,x.desc.placeholder=$.placeholder,x.attachedText.textContent=$.attached(this.config?.profile.windowSec??60),x.attached.hidden=this.engine===null||this.config?.capturing===!1,x.discloseText.textContent=$.included,x.disclose.setAttribute("aria-expanded",String(this.includedOpen)),x.included.hidden=!this.includedOpen,x.included.replaceChildren(...this.includedItems().map((Z)=>j("li",{},Z))),x.desc.disabled=this.sending,x.lines.hidden=this.markers.length===0,x.linesEmpty.hidden=!this.marking||this.markers.length>0,x.linesEmpty.textContent=$.linesEmpty;for(let Z of this.lines.values())Z.note.disabled=this.sending,Z.rm.disabled=this.sending;x.notify.hidden=z===null,x.notifyText.textContent=$.notify,x.error.hidden=this.error==="",x.error.textContent={"":"",create:$.errorCreate,files:$.errorFiles,capture:$.errorCapture}[this.error],x.whereText.textContent=$.showWhere,x.where.setAttribute("aria-pressed",String(this.marking)),x.where.disabled=this.sending||Boolean(this.job?.id),x.send.textContent=this.sending?$.sending:this.error?$.retry:$.send,x.send.disabled=this.sending||this.words()==="",x.bindLabel.textContent=$.shortcut,x.bindBtn.setAttribute("aria-pressed",String(this.recordingBind)),x.bindBtn.setAttribute("aria-label",`${$.shortcut}: ${this.keybind?a1(this.keybind):$.notSet} — ${$.recordShortcut}`),x.bindBtn.textContent=this.recordingBind?$.pressKeys:this.keybind?a1(this.keybind):$.notSet,x.unbind.textContent=$.removeShortcut,x.unbind.hidden=!this.keybind||this.recordingBind,x.bindHint.textContent=$.shortcutHint,x.bindReason.hidden=!this.bindRefused,x.bindReason.textContent=this.bindRefused?$.needModifier:"",x.back.textContent=$.back,this.paintSettings(),x.sentTitle.textContent=$.sentTitle,x.sentBody.textContent=this.result?.status==="quarantined"?$.sentQueued:this.sentNotify?$.sentNotify:$.sentBody,x.seeText.textContent=$.seeReport;let Q=this.result?.reportUrl;if(x.see.hidden=!Q,Q)x.see.setAttribute("href",Q);else x.see.removeAttribute("href");x.sentClose.textContent=$.close,x.mark.hidden=!this.marking,x.toolbar.setAttribute("aria-label",$.toolbar),x.seg.setAttribute("aria-label",$.toolbar),x.barLead.textContent=this.tool==="hide"?$.barLeadHide:$.barLead;for(let[Z,J]of x.toolButtons){let X=x.toolLabels.get(Z);if(X)X.textContent=$.tools[Z];J.setAttribute("aria-checked",String(this.tool===Z))}if(x.cancel.textContent=$.cancelMarking,x.cancel.hidden=this.confirming,x.ask.hidden=!this.confirming,x.askText.textContent=$.discardMarks(this.markers.filter((Z)=>!this.passKeys.has(Z.key)).length),x.discard.textContent=$.discard,x.keep.textContent=$.keep,x.coach.hidden=!this.marking||!this.coachOn,x.coach.hidden)this.coachShape=null;else if(this.coachShape!==this.tool)this.coachShape=this.tool,x.coachArtSlot.replaceChildren(A(f$(this.tool,k8()))),this.placeCoachSide();if(x.coachText.textContent=$.coach[this.tool],x.coachMore.textContent=$.coachMore,x.coachDismiss.textContent=$.coachDismiss,x.coachKeys.textContent=$.keyboardHint,x.mark.setAttribute("aria-label",$.marking),this.marking){for(let Z of x.shapes.querySelectorAll(".veil-label"))if(Z.textContent)Z.textContent=$.hidden}this.renderPins()}}function s1(x){return a6(x).map(($,z)=>({...$,key:x[z].key}))}var t1="vitrinka-report",v$=["key","base","open-selector","locale","button"];function m8(x){return x.trim().replace(/\/+$/,"")}function E5(x){if(typeof customElements>"u"||customElements.get(t1))return;class $ extends HTMLElement{static get observedAttributes(){return v$}options={};at=null;shown=null;widget=null;pill=null;gen=0;recordOffered=!1;offPillOpener=null;warnedRecording=!1;offLink=null;pendingIdentity=void 0;get face(){return this.shown??"report"}connectedCallback(){this.hidden=!0,this.mount()}disconnectedCallback(){this.unmount()}attributeChangedCallback(z,Q,Z){if(Q===Z)return;if(!this.at){if(this.isConnected&&(z==="key"||z==="base"))this.mount();return}if(z==="key"||z==="base"){this.unmount(),this.mount();return}if(!this.widget)return;if(z==="locale")this.widget.setLocale(Z);else if(z==="button")this.widget.setButton(Z!=="false");else if(z==="open-selector")this.widget.setOpenSelector(Z)}open(){if(this.shown==="recorder")this.openFromPill();else this.widget?.open()}close(){this.widget?.close()}identify(z){this.pendingIdentity=z,this.widget?.identify(z)}setLocale(z){this.setAttribute("locale",String(z))}mount(){if(this.at)return;let z=(this.getAttribute("key")??"").trim(),Q=m8(this.getAttribute("base")??x.defaultBase());if(!z||!Q){console.warn(`vitrinka: <${t1}> needs a key${Q?"":" and a base"} — nothing mounted`);return}if(this.at={key:z,base:Q},x.recorderFace)this.offLink=y1(()=>this.offerRecord());this.show(x.recorderFace?t3(Q):"report")}unmount(){this.offLink?.(),this.offLink=null,this.takeDown(),this.at=null,this.shown=null}takeDown(){this.gen++,this.widget?.unmount(),this.widget=null,this.recordOffered=!1,this.offPillOpener?.(),this.offPillOpener=null,this.pill?.(),this.pill=null}show(z){let Q=this.at;if(!Q)return;this.takeDown();let Z=x.recorderFace;if(z==="recorder"&&Z){this.shown="recorder",this.offPillOpener=R(document,"click",(X)=>{if(!R5(X,this.getAttribute("open-selector")))return;X.preventDefault(),this.open()});let J=this.gen;Z().then((X)=>{if(J!==this.gen)return;this.pill=X({base:Q.base,appVersion:this.options.appVersion,sanitizeUrl:this.options.sanitizeUrl,onReportFace:()=>this.switchTo("report")})}).catch((X)=>{if(console.warn("vitrinka: the recorder face did not load — showing Report a problem",X),J===this.gen)this.show("report")});return}this.shown="report",this.widget=new S5({base:Q.base,key:Q.key,locale:x1(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,appVersion:this.options.appVersion,capture:this.options.capture,sanitizeUrl:this.options.sanitizeUrl,loadRecord:x.loadRecord}),this.offerRecord()}offerRecord(){if(!this.widget||!this.at)return;let z=x.recorderFace!==null&&b0(this.at.base);if(z===this.recordOffered)return;this.recordOffered=z,this.widget.setRecordSwitch(z?()=>this.switchTo("recorder"):null)}openFromPill(){if(this.keepsPill())return;let z=this.at;setTimeout(()=>{if(!z||this.at!==z)return;if(this.shown==="recorder"){if(this.keepsPill())return;l2("report"),this.show("report")}this.widget?.open()},0)}keepsPill(){if(!e3())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(z){l2(z);let Q=this.gen;setTimeout(()=>{if(Q===this.gen&&this.shown!==z)this.show(z)},0)}}customElements.define(t1,$)}function u8(x,$){if(x.face==="recorder")return h$(x,$);E5($);let z=document.createElement(t1);if(z.setAttribute("key",x.key),x.base)z.setAttribute("base",x.base);if(x.locale)z.setAttribute("locale",String(x.locale));if(x.button===!1)z.setAttribute("button","false");if(x.openSelector)z.setAttribute("open-selector",x.openSelector);if(z.options={appVersion:x.appVersion,capture:x.capture,sanitizeUrl:x.sanitizeUrl},x.identity!==void 0)z.identify(x.identity);return(x.parent??document.body).append(z),{get face(){return z.face},open:()=>z.open(),close:()=>z.close(),identify:(Q)=>z.identify(Q),setLocale:(Q)=>z.setLocale(Q),unmount:()=>z.remove()}}function h$(x,$){let z=m8(x.base??$.defaultBase()),Q=null,Z=!1;if(!$.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else $.recorderFace().then((X)=>{if(!Z)Q=X({base:z,key:x.key,appVersion:x.appVersion,sanitizeUrl:x.sanitizeUrl})}).catch((X)=>console.warn("vitrinka: the recorder face did not load",X));let J=()=>{return};return{face:"recorder",open:J,close:J,identify:J,setLocale:J,unmount:()=>{Z=!0,Q?.()}}}var m$=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function u$(x){let z=await import(`${x}/vendor/rrweb-record-1.min.js`)??{},Q=typeof z.default==="object"&&z.default!==null?z.default.record:void 0,Z=typeof z.default==="function"?z.default:Q??z.record;return typeof Z==="function"?Z:null}var d8={loadRecord:u$,recorderFace:null,defaultBase:()=>m$};E5(d8);function hZ(x){return u8(x,d8)}export{hZ as mountReport,L$ as identify};
416
+ `;var Du="http://www.w3.org/2000/svg",_l=100,Kl=["box","circle","arrow","hide"],Tr={w:160,h:80},Hl=16,Bl={w:380,h:460},Mr=72,Ar={w:300,h:160,gap:10},Pr=16,_u={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>',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>'},ql="0;0.18;0.72;1",gt="2.8s",Nl="M 134 14 C 200 14, 214 50, 134 50 C 54 50, 68 14, 134 14",Hu='<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 Bu(e,t,n){return`<animate attributeName="${e}" values="${t};${t};${n};${n}" keyTimes="${ql}" calcMode="linear" dur="${gt}" repeatCount="indefinite"/>`}function Nu(e,t){let n=(p,h)=>t?h:p,r=(p,h,u)=>t?"":Bu(p,h,u),o=t?"":`<animate attributeName="opacity" values="1;1;0" keyTimes="0;0.9;1" dur="${gt}" 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="${gt}" repeatCount="indefinite"/>`,s,a,l;if(e==="circle")a=Nl,l={x:134,y:14},s=`<rect class="bar" x="84" y="27" width="100" height="10" rx="5"/><path class="loop" d="${Nl}" 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="${gt}" 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="${gt}" repeatCount="indefinite" keyPoints="0;0;1;1" keyTimes="${ql}" 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>${Hu}${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 F(e,t){let n=document.createElementNS(Du,e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Fl(e){let t=e.split(`
417
+ `)[0]?.trim()??"";return t.length>_l?`${t.slice(0,_l-1)}…`:t}function $l(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1}function Lr(){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 Fu(e){return(e.split("@")[0]?.split(/[\s._-]+/).filter(Boolean)??[]).slice(0,2).map((n)=>n[0]?.toUpperCase()??"").join("")||"?"}function K(e,t){let n=e.querySelector("span");if(n)n.textContent=t}function zl(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 $u(){let e=Lr();return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Ir(e,t){let n=e.target;if(!t||!(n instanceof Element))return!1;try{return n.closest(t)!==null}catch{return!1}}function zu(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"},T(R.dots)),d=c("button",{class:"icon",type:"button"},T(R.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"}),y=c("button",{class:"link",type:"button"}),b=c("button",{class:"pop-item",type:"button"},T(R.link),c("span")),k=c("a",{class:"pop-item",target:"_blank",rel:"noopener noreferrer"},T(R.ext),c("span")),w=c("div",{class:"pop acc",role:"dialog"},c("div",{class:"acc-who"},h,u,f),c("div",{class:"acc-member"},g,y),b,k),m=(O)=>c("button",{class:"pop-item",type:"button",role:"menuitem"},T(O),c("span")),A=m(R.list),Be=m(R.clock),Ne=m(R.rec),mt=c("small",{class:"pop-why",id:"vr-record-why","aria-hidden":"true"});Ne.append(mt);let Fe=m(R.gear),_r=c("a",{class:"pop-item",role:"menuitem",target:"_blank",rel:"noopener noreferrer"},T(R.ext),c("span")),Hr=c("div",{class:"pop more",role:"menu"},A,Be,Ne,Fe,_r),Br=c("span",{class:"sr",id:"vr-kinds"}),en=new Map;for(let O of ra)en.set(O,c("button",{type:"button",role:"radio","aria-checked":"false","data-kind":O}));let Nr=c("div",{class:"kinds",role:"radiogroup","aria-labelledby":"vr-kinds"},Br,...en.values()),Fr=c("label",{class:"prompt",for:"vr-desc"}),$r=c("textarea",{class:"desc",id:"vr-desc",rows:"3"}),zr=c("ol",{class:"lines"}),Kr=c("p",{class:"ln-empty"}),qr=c("span"),Wr=c("span"),jr=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-included"},Wr,T(R.chevron)),Ur=c("div",{class:"attached"},T(R.clip),qr,c("span",{"aria-hidden":"true"},"·"),jr),Vr=c("ul",{class:"included",id:"vr-included"}),Yr=c("input",{type:"checkbox"}),Gr=c("span"),Xr=c("label",{class:"notify"},Yr,Gr),Jr=c("p",{class:"error",role:"alert"}),Zr=c("span"),Qr=c("button",{class:"where",type:"button","aria-pressed":"false"},T(R.pen),Zr),eo=c("button",{class:"send",type:"button"}),to=c("div",{class:"pane describe"},Nr,Fr,$r,c("div",{class:"lines-wrap"},zr,Kr),Ur,Vr,Xr,Jr),no=c("button",{class:"icon",type:"button"},T(R.clip)),ro=c("input",{type:"file",multiple:"",tabindex:"-1","aria-hidden":"true",hidden:""}),oo=c("p",{class:"file-note",role:"status"}),io=c("ul",{class:"files"}),so=c("div",{class:"tray"},oo,io),ao=c("div",{class:"foot"},no,ro,Qr,eo),lo=c("span",{class:"label",id:"vr-bind-label"}),co=c("button",{class:"bind",type:"button","aria-pressed":"false","aria-describedby":"vr-bind-label"}),uo=c("button",{class:"link",type:"button"}),po=c("p",{class:"hint"}),fo=c("p",{class:"reason",role:"status"}),ho=c("button",{class:"link",type:"button"}),go=c("span",{class:"label",id:"vr-size-label"}),tn=new Map;for(let O of Jn)tn.set(O,c("button",{type:"button",role:"radio","aria-checked":"false","data-size":O}));let mo=c("span",{class:"seg-ind","aria-hidden":"true"}),bo=c("div",{class:"seg",role:"radiogroup","aria-labelledby":"vr-size-label"},mo,...tn.values()),yo=c("span",{class:"label",id:"vr-coach-label"}),ko=c("button",{class:"switch",type:"button",role:"switch","aria-checked":"true","aria-labelledby":"vr-coach-label"},c("span",{class:"knob","aria-hidden":"true"})),vo=c("span"),wo=c("button",{class:"link",type:"button","aria-expanded":"false","aria-controls":"vr-tech"},vo,T(R.chevron)),xo=c("dl",{class:"tech",id:"vr-tech"}),So=c("div",{class:"pane settings"},c("div",{class:"row"},lo,co),fo,po,c("div",{class:"row size-row"},go,bo),c("div",{class:"row tips-row"},yo,ko),c("div",{class:"tech-wrap"},wo,xo),c("div",{class:"settings-foot"},ho,uo)),Ro=c("h3"),Eo=c("p",{class:"sent-body"}),Co=c("span"),To=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},Co),Mo=c("button",{class:"link",type:"button"}),Ao=c("div",{class:"pane sent",role:"status"},c("div",{class:"sent-head"},T(R.check),Ro),Eo,c("div",{class:"sent-actions"},To,Mo)),nn=()=>c("button",{class:"back",type:"button"},T(R.left),c("span")),Po=nn(),Lo=c("p",{class:"list-status"}),Io=c("ul",{class:"rows"}),Oo=c("p",{class:"list-note"}),Do=c("a",{class:"link",target:"_blank",rel:"noopener noreferrer"}),_o=c("div",{class:"pane list"},Po,Lo,Io,Oo,Do),Ho=nn(),Bo=c("p",{class:"list-status"}),No=c("ul",{class:"rows"}),Fo=c("div",{class:"pane list"},Ho,Bo,No),$o=nn(),zo=c("p",{class:"list-note"}),Ko=c("div",{class:"code"}),qo=c("span"),Wo=c("a",{class:"see",target:"_blank",rel:"noopener noreferrer"},qo),jo=c("img",{class:"qr",alt:""}),Uo=c("p",{class:"hint"}),Vo=c("p",{class:"list-status",role:"status"}),Yo=c("button",{class:"link",type:"button"}),Go=c("div",{class:"pane linking"},$o,zo,Ko,c("div",{class:"link-go"},Wo,jo),Uo,Vo,Yo),Xo=c("div",{class:"coach-art"}),Jo=c("p"),Zo=c("p"),Qo=c("button",{class:"coach-ok",type:"button"}),ei=c("div",{class:"coach",role:"status"},Xo,Jo,Zo,Qo),ti=c("p",{class:"sr-only",id:"vr-keys"}),ni=c("div",{class:"body"},to,So,Ao,_o,Fo,Go),ri=c("section",{class:"card",role:"dialog","aria-modal":"false","aria-labelledby":"vr-title"},p,w,Hr,ni,so,ao,ei),rn=F("svg",{class:"ink","aria-hidden":"true"}),oi=F("defs",{}),ii=F("marker",{id:"vr-head",viewBox:"0 0 10 10",refX:7,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});ii.append(F("path",{d:"M0 0L10 5L0 10z",fill:"#dc2f4c"})),oi.append(ii);let si=F("g",{}),ai=F("g",{class:"draft"});rn.append(oi,si,ai);let li=c("div",{class:"pins"}),on=new Map,ci=new Map;for(let O of Kl){let vi=c("span");ci.set(O,vi),on.set(O,c("button",{type:"button",role:"radio","aria-checked":"false","data-tool":O},T(R[O]),vi))}let di=c("span",{class:"seg-ind","aria-hidden":"true"}),ui=c("div",{class:"seg",role:"radiogroup"},di,...on.values()),pi=c("span",{class:"tb-lead"}),fi=c("button",{type:"button",class:"tb-quiet"}),hi=c("span",{class:"tb-ask"}),gi=c("button",{type:"button",class:"tb-discard"}),mi=c("button",{type:"button",class:"tb-quiet"}),bi=c("span",{class:"tb-confirm",role:"group"},hi,gi,mi),yi=c("div",{class:"tb",role:"toolbar"},pi,ui,c("span",{class:"tb-sep","aria-hidden":"true"}),fi,bi),sn=c("div",{class:"mark",tabindex:"0",role:"application","aria-describedby":"vr-keys"},li,ti,yi);sn.prepend(rn);let an=c("div",{class:"vr"},r,sn,ri),ki=c("style");return ki.textContent=Dl,an.prepend(ki),e.append(an),{root:an,fab:r,fabLabel:t,fabKbd:n,card:ri,head:p,title:o,whoBtn:a,whoAv:i,whoName:s,more:l,closeBtn:d,body:ni,foot:ao,accountPop:w,accName:h,accMail:u,accVia:f,accLinked:g,accUnlink:y,accLink:b,accPortal:k,morePop:Hr,mReports:A,mRecents:Be,mRecord:Ne,mRecordWhy:mt,mSettings:Fe,mOpen:_r,reports:_o,repBack:Po,repStatus:Lo,repRows:Io,repLocal:Oo,repPortal:Do,recents:Fo,recBack:Ho,recStatus:Bo,recRows:No,linking:Go,linkBack:$o,linkLabel:zo,linkCode:Ko,linkOpen:Wo,linkOpenText:qo,linkQr:jo,linkHint:Uo,linkWait:Vo,linkRetry:Yo,describe:to,kinds:Nr,kindsLabel:Br,kindButtons:en,prompt:Fr,desc:$r,lines:zr,linesEmpty:Kr,attached:Ur,attachedText:qr,disclose:jr,discloseText:Wr,included:Vr,notify:Xr,notifyBox:Yr,notifyText:Gr,error:Jr,where:Qr,whereText:Zr,send:eo,attach:no,fileInput:ro,fileNote:oo,files:io,tray:so,settings:So,bindLabel:lo,bindBtn:co,unbind:uo,bindHint:po,bindReason:fo,back:ho,sizeLabel:go,sizeButtons:tn,sizeInd:mo,sizeSeg:bo,coachLabel:yo,coachSwitch:ko,techText:vo,techBtn:wo,tech:xo,sent:Ao,sentTitle:Ro,sentBody:Eo,see:To,seeText:Co,sentClose:Mo,mark:sn,ink:rn,shapes:si,draft:ai,pins:li,coach:ei,coachArtSlot:Xo,coachText:Jo,coachMore:Zo,coachDismiss:Qo,coachKeys:ti,toolbar:yi,barLead:pi,seg:ui,segInd:di,toolButtons:on,toolLabels:ci,cancel:fi,ask:bi,askText:hi,discard:gi,keep:mi}}class Or{opts;hud;engine;config=null;locale;s;button;openSelector;identity;keybind;isOpen=!1;opener=null;view="describe";marking=!1;markers=[];nextKey=1;tool=Kl[0];coachOn=Ta();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=La();size=Ca();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)??ga()}sheet=null;e;constructor(e){this.opts=e;this.locale=e.locale??Yn(),this.s=Vn(this.locale),this.button=e.button,this.openSelector=e.openSelector??null,this.identity=e.identity===void 0?void 0:Gt(e.identity),this.keybind=wl(),this.hud=fa(),this.e=zu(this.hud.mount),this.engine=dl({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=ma(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=ba(document.activeElement)?null:Lr(),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&&Lr()===e)return;if(this.button)this.e.fab.focus()}setLocale(e){let t=tt(e)??Yn();if(t===this.locale)return;this.locale=t,this.s=Vn(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:Gt(e),this.whoChanged()}unmount(){this.stopRecordingBind(),this.linkFlow?.abort.abort();for(let e of this.offs.splice(0).reverse())e();ul(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=Da(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=Ra(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,it(Zn,a),this.paint(),this.parked)this.placeCard(!0)});let n=(a)=>{this.coachOn=a,it(Qn,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",()=>{kt(),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,yr(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=Zt(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(P(e.mark,"wheel",(a)=>a.preventDefault())),this.offs.push(P(e.mark,"touchmove",(a)=>a.preventDefault())),this.offs.push(P(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"&&!$u()){a.preventDefault(),this.markers=Zt(this.markers.slice(0,-1)),this.renderMarks(),this.paint();return}if(this.keybind&&ml(a,this.keybind))if(a.preventDefault(),this.isOpen)this.close();else this.open()},{capture:!0})),this.offs.push(P(document,"click",(a)=>{if(!Ir(a,this.openSelector))return;a.preventDefault(),this.open()})),this.offs.push(P(window,"resize",()=>{if(this.parked)this.placeCard(!0);if(this.marking)this.placeSeg()})),this.offs.push(xl((a)=>{this.keybind=a,this.paint()})),this.offs.push(hl(()=>this.whoChanged())),this.linkSeen=be(this.opts.base),this.offs.push(Bt(()=>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=be(this.opts.base),n=Rr(e,t);if(this.sessionKey===n&&Pl(this.session))return this.session;this.sessionKey=n;let r=null;try{r=await Al(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 Rr(this.whoToken(),be(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=be(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=Zs(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&&ae()?.token===t)va()}async refreshMember(){let e=De(this.opts.base)?ae():null;if(!e){if(this.member)this.member=null,this.paint();return}let t,n;try{let r=await G("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(be(this.opts.base)!==e.token)return;this.member=t,ea(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 Er(this.target(),e.session)).reports}catch(t){if(!(t instanceof C)||t.status!==401)throw t;this.session=null,this.sessionKey="";let n=await this.refreshWho();if(!n)throw t;return(await Er(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=yt(t);(async()=>{try{e.start=await Ti(t,{label:hn(),workspace:n}),e.state="waiting",this.paint();let r=await Mi(t,e.start.device_code,{interval:e.start.interval,expiresIn:e.start.expires_in,workspace:n,signal:e.abort.signal});fn({...r,base:t}),this.linkFlow=null,this.show("describe")}catch(r){if(e.abort.signal.aborted)return;if(e.state=r instanceof $e?"expired":"failed",e.state==="failed")console.warn("vitrinka: linking the vitrinka account failed",r);this.paint()}})()}ago(e){let t=new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}),n=Math.round((e-Date.now())/1000),r=[[60,"second"],[60,"minute"],[24,"hour"],[30,"day"],[12,"month"],[1/0,"year"]],o=n;for(let[i,s]of r){if(Math.abs(o)<i)return t.format(o,s);o=Math.round(o/i)}return t.format(o,"year")}row(e,t,n,r){let o=[c("span",{class:"row-t"},e),c("span",{class:"step"},t),c("span",{class:"age"},this.ago(n))],i=r?c("a",{class:"row",href:r,target:"_blank",rel:"noopener noreferrer"},...o):c("div",{class:"row"},...o);return c("li",{},i)}who(){return this.identity!==void 0?this.identity:fl()}whoToken(){let e=this.who();return e&&"token"in e?e.token:""}stopBindListener=null;startRecordingBind(){this.recordingBind=!0,this.bindRefused=!1,this.stopBindListener=P(window,"keydown",(e)=>{e.preventDefault(),e.stopPropagation();let t=gl(e);if(t.kind==="wait")return;if(t.kind==="bare"){this.bindRefused=!0,this.paint();return}if(t.kind==="bind")this.keybind=t.bind,yr(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??ie}addFiles(e){if(!e.length)return;let{files:t,refusal:n}=xa(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,rt(e.cap,this.locale));if(e.kind==="count")return t.tooManyFiles(e.cap);return t.fileType(e.name,Sa(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)<Pa)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?Oa({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,Ia(e),this.paint(),n.hidden||$l())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=Mr*ot[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):Pr}}frame(){let e=globalThis.innerWidth||800,t=globalThis.innerHeight||600,n=ot[this.size],r=this.parkInsets??{top:Mr*n,bottom:Pr,edge:Pr},o=this.e.card.getBoundingClientRect();return{vw:e,vh:t,w:o.width||Math.min(Bl.w*n,e-32),h:o.height||Math.min(Bl.h*n,t-r.top-r.bottom),...r}}placeCard(e=!1){if(!this.parked)return;let t=this.frame(),n=this.parked;this.parked=Rl(this.parked,this.markers.map((s)=>s.rect),t);let r=kr(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=ot[this.size],t=this.e.coach;t.dataset.side="above";let n=t.offsetHeight||Ar.h;t.dataset.side=El(this.parked??this.dock,this.frame(),{w:Ar.w*e,h:n*e},Ar.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){zl(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:dr(t.start,{x:e.clientX,y:e.clientY}),head:ur(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(),!Ja(t.shape,t.start,n))return;this.addMarker(t.shape,dr(t.start,n),t.shape==="arrow"?ur(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=Zt([...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-Tr.w/2),y:Math.round(n/2-Tr.h/2),...Tr},this.renderKbDraft();return}let a=this.kbDraft;this.cancelDraft(),this.addMarker(this.tool,a,this.tool==="arrow"?"se":void 0);return}let r=_u[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(Hl,o.w+i)),h:Math.min(n-o.y,Math.max(Hl,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[F("ellipse",{class:"stroke",cx:t+r/2,cy:n+o/2,rx:Math.max(1,r/2),ry:Math.max(1,o/2)})];if(e.shape==="box")return[F("rect",{class:"stroke",x:t,y:n,width:r,height:o,rx:6})];if(e.shape==="arrow"){let{tail:a,tip:l}=pr(e.rect,e.head??"se");return[F("line",{class:"stroke",x1:a.x,y1:a.y,x2:l.x,y2:l.y,"marker-end":"url(#vr-head)"})]}let i=F("rect",{class:"veil",x:t,y:n,width:r,height:o,rx:4}),s=F("text",{class:"veil-label",x:t+r/2,y:n+o/2+4,"text-anchor":"middle"});return s.textContent=r>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=Zt(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"?pr(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(Mr-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=be(this.opts.base),o=globalThis.location;return{title:Fl(e),description:e,env:{url:le(o?`${o.origin}${o.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:Qa(this.markers),locale:this.locale,...this.kind?{type:this.kind}:{},...r?{memberToken:r}:{}}}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 Ml(()=>n.build(r,this.markers,t)):xr;this.job=new Sr(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)),Ol(this.opts.base,globalThis.location?.host??"",{title:Fl(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?Fu(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),K(e.accLink,t.linkVitrinka);let s=this.session?.portalUrl;if(e.accPortal.hidden=!s,s)e.accPortal.setAttribute("href",s);K(e.accPortal,t.openPortal),K(e.mReports,t.myReports),K(e.mRecents,t.recentRecordings),K(e.mRecord,t.record),K(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);K(e.mOpen,i?t.openVitrinka:t.openPortal)}paintReports(){let{e,s:t}=this;K(e.repBack,t.myReports);let n=!this.session,r=n?Cr(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;K(e.recBack,t.recentRecordings);let n=Gn().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;K(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=rt(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=Ma({version:Ys,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")zl(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(ot[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?`${yl(this.keybind)} `:""}Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight`),e.fabKbd.hidden=!this.keybind,e.fabKbd.textContent=this.keybind?Xt(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?Xt(this.keybind):t.notSet} — ${t.recordShortcut}`),e.bindBtn.textContent=this.recordingBind?t.pressKeys:this.keybind?Xt(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(T(Nu(this.tool,$l()))),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 Zt(e){return Za(e).map((t,n)=>({...t,key:e[n].key}))}var Qt="vitrinka-report",Ku=["key","base","open-selector","locale","button"];function Wl(e){return e.trim().replace(/\/+$/,"")}function Dr(e){if(typeof customElements>"u"||customElements.get(Qt))return;class t extends HTMLElement{static get observedAttributes(){return Ku}options={};at=null;shown=null;widget=null;pill=null;gen=0;recordOffered=!1;offPillOpener=null;warnedRecording=!1;offLink=null;pendingIdentity=void 0;get face(){return this.shown??"report"}connectedCallback(){this.hidden=!0,this.mount()}disconnectedCallback(){this.unmount()}attributeChangedCallback(n,r,o){if(r===o)return;if(!this.at){if(this.isConnected&&(n==="key"||n==="base"))this.mount();return}if(n==="key"||n==="base"){this.unmount(),this.mount();return}if(!this.widget)return;if(n==="locale")this.widget.setLocale(o);else if(n==="button")this.widget.setButton(o!=="false");else if(n==="open-selector")this.widget.setOpenSelector(o)}open(){if(this.shown==="recorder")this.openFromPill();else this.widget?.open()}close(){this.widget?.close()}identify(n){this.pendingIdentity=n,this.widget?.identify(n)}setLocale(n){this.setAttribute("locale",String(n))}mount(){if(this.at)return;let n=(this.getAttribute("key")??"").trim(),r=Wl(this.getAttribute("base")??e.defaultBase());if(!n||!r){console.warn(`vitrinka: <${Qt}> needs a key${r?"":" and a base"} — nothing mounted`);return}if(this.at={key:n,base:r},e.recorderFace)this.offLink=Bt(()=>this.offerRecord());this.show(e.recorderFace?ta(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=P(document,"click",(s)=>{if(!Ir(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 Or({base:r.base,key:r.key,locale:tt(this.getAttribute("locale")),button:this.getAttribute("button")!=="false",openSelector:this.getAttribute("open-selector"),identity:this.pendingIdentity,appVersion:this.options.appVersion,capture:this.options.capture,sanitizeUrl:this.options.sanitizeUrl,loadRecord:e.loadRecord}),this.offerRecord()}offerRecord(){if(!this.widget||!this.at)return;let n=e.recorderFace!==null&&De(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;Un("report"),this.show("report")}this.widget?.open()},0)}keepsPill(){if(!na())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){Un(n);let r=this.gen;setTimeout(()=>{if(r===this.gen&&this.shown!==n)this.show(n)},0)}}customElements.define(Qt,t)}function jl(e,t){if(e.face==="recorder")return qu(e,t);Dr(t);let n=document.createElement(Qt);if(n.setAttribute("key",e.key),e.base)n.setAttribute("base",e.base);if(e.locale)n.setAttribute("locale",String(e.locale));if(e.button===!1)n.setAttribute("button","false");if(e.openSelector)n.setAttribute("open-selector",e.openSelector);if(n.options={appVersion:e.appVersion,capture:e.capture,sanitizeUrl:e.sanitizeUrl},e.identity!==void 0)n.identify(e.identity);return(e.parent??document.body).append(n),{get face(){return n.face},open:()=>n.open(),close:()=>n.close(),identify:(r)=>n.identify(r),setLocale:(r)=>n.setLocale(r),unmount:()=>n.remove()}}function qu(e,t){let n=Wl(e.base??t.defaultBase()),r=null,o=!1;if(!t.recorderFace)console.warn("vitrinka: the recorder face needs the npm package (@vitrinka/web/report) — nothing mounted");else t.recorderFace().then((s)=>{if(!o)r=s({base:n,key:e.key,appVersion:e.appVersion,sanitizeUrl:e.sanitizeUrl})}).catch((s)=>console.warn("vitrinka: the recorder face did not load",s));let i=()=>{return};return{face:"recorder",open:i,close:i,identify:i,setLocale:i,unmount:()=>{o=!0,r?.()}}}var Wu=(()=>{try{return new URL(import.meta.url).origin}catch{return""}})();async function ju(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 Ul={loadRecord:ju,recorderFace:null,defaultBase:()=>Wu};Dr(Ul);function Wh(e){return jl(e,Ul)}export{Cu as identify,Wh as mountReport};