@vitrinka/web 0.9.3 → 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.
- package/CHANGELOG.md +8 -0
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/widget.js +27 -26
- package/build/report-widget.mjs +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @vitrinka/web
|
|
2
2
|
|
|
3
|
+
## 0.9.4
|
|
4
|
+
|
|
5
|
+
- **Escape belongs to reporting while reporting has the focus.** A host
|
|
6
|
+
modal's document-capture Escape listener could close the app's editor
|
|
7
|
+
before the report card handled it, leaving the card open. Reporting now
|
|
8
|
+
handles its Escape at window capture, preserving its menu/settings/marking
|
|
9
|
+
steps and shortcut recording while leaving the app dialog and draft alone.
|
|
10
|
+
|
|
3
11
|
## 0.9.3
|
|
4
12
|
|
|
5
13
|
- **Reporting stays in the window, not the app's modal.** The floating
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Sent as `meta.recorder` and written as `data-vitrinka-page`; bumped with the package version. */
|
|
2
|
-
export declare const RECORDER_VERSION = "0.9.
|
|
3
|
-
export declare const RECORDER_ID = "web/0.9.
|
|
2
|
+
export declare const RECORDER_VERSION = "0.9.4";
|
|
3
|
+
export declare const RECORDER_ID = "web/0.9.4";
|
package/build/report/widget.js
CHANGED
|
@@ -821,23 +821,6 @@ export class ReportWidget {
|
|
|
821
821
|
this.paint();
|
|
822
822
|
});
|
|
823
823
|
}
|
|
824
|
-
on(e.card, 'keydown', (ev) => {
|
|
825
|
-
// Marking's own Escape (the window listener) already acted on it.
|
|
826
|
-
if (ev.key !== 'Escape' || this.recordingBind || ev.defaultPrevented)
|
|
827
|
-
return;
|
|
828
|
-
ev.preventDefault();
|
|
829
|
-
// Esc steps back one layer: an open popover, then a list or settings, then the card itself.
|
|
830
|
-
if (this.menu) {
|
|
831
|
-
const opener = this.menu === 'account' ? e.whoBtn : e.more;
|
|
832
|
-
this.menu = null;
|
|
833
|
-
this.paint();
|
|
834
|
-
opener.focus();
|
|
835
|
-
}
|
|
836
|
-
else if (this.view !== 'describe' && this.view !== 'sent')
|
|
837
|
-
this.show('describe');
|
|
838
|
-
else
|
|
839
|
-
this.close();
|
|
840
|
-
});
|
|
841
824
|
for (const [tool, btn] of e.toolButtons) {
|
|
842
825
|
on(btn, 'click', (ev) => {
|
|
843
826
|
this.tool = tool;
|
|
@@ -869,19 +852,37 @@ export class ReportWidget {
|
|
|
869
852
|
this.offs.push(listen(e.mark, 'wheel', (ev) => ev.preventDefault()));
|
|
870
853
|
this.offs.push(listen(e.mark, 'touchmove', (ev) => ev.preventDefault()));
|
|
871
854
|
this.offs.push(listen(window, 'keydown', (ev) => {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
855
|
+
const inCard = ev.composedPath().includes(e.card);
|
|
856
|
+
// A modal's document-capture listener runs before a card listener.
|
|
857
|
+
// Own this Escape at window capture so it never dismisses the app's dialog.
|
|
858
|
+
if (ev.key === 'Escape' && this.isOpen && (this.marking || inCard)) {
|
|
875
859
|
ev.preventDefault();
|
|
876
|
-
|
|
877
|
-
if (this.
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
860
|
+
ev.stopImmediatePropagation();
|
|
861
|
+
if (this.recordingBind) {
|
|
862
|
+
this.stopRecordingBind();
|
|
863
|
+
}
|
|
864
|
+
else if (this.marking) {
|
|
865
|
+
if (this.confirming)
|
|
866
|
+
e.keep.click();
|
|
867
|
+
else if (this.kbDraft)
|
|
868
|
+
this.cancelDraft();
|
|
869
|
+
else
|
|
870
|
+
this.endMarking(true);
|
|
871
|
+
}
|
|
872
|
+
else if (this.menu) {
|
|
873
|
+
const opener = this.menu === 'account' ? e.whoBtn : e.more;
|
|
874
|
+
this.menu = null;
|
|
875
|
+
this.paint();
|
|
876
|
+
opener.focus();
|
|
877
|
+
}
|
|
878
|
+
else if (this.view !== 'describe' && this.view !== 'sent')
|
|
879
|
+
this.show('describe');
|
|
881
880
|
else
|
|
882
|
-
this.
|
|
881
|
+
this.close();
|
|
883
882
|
return;
|
|
884
883
|
}
|
|
884
|
+
if (this.recordingBind)
|
|
885
|
+
return;
|
|
885
886
|
// ⌘Z / Ctrl+Z takes the newest mark back — unless a field is being typed in, whose own undo wins.
|
|
886
887
|
if (this.marking && (ev.metaKey || ev.ctrlKey) && !ev.shiftKey && !ev.altKey && ev.key.toLowerCase() === 'z' && !typing()) {
|
|
887
888
|
ev.preventDefault();
|
package/build/report-widget.mjs
CHANGED
|
@@ -6,7 +6,7 @@ function P(e,t,n,r={}){let o=e,i=o.__zone_symbol__addEventListener??e.addEventLi
|
|
|
6
6
|
${p}\r
|
|
7
7
|
\r
|
|
8
8
|
${g}\r
|
|
9
|
-
`)}return s.push(i[i.length-1]),s.join(o)}var 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.3";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=`
|
|
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;
|
|
@@ -414,4 +414,4 @@ a.row:hover { background: var(--faint); }
|
|
|
414
414
|
.fab, .fab.gliding { transition: none; }
|
|
415
415
|
}
|
|
416
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()});t(e.card,"keydown",(a)=>{if(a.key!=="Escape"||this.recordingBind||a.defaultPrevented)return;if(a.preventDefault(),this.menu){let l=this.menu==="account"?e.whoBtn:e.more;this.menu=null,this.paint(),l.focus()}else if(this.view!=="describe"&&this.view!=="sent")this.show("describe");else this.close()});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)=>{if(this.recordingBind)return;if(this.marking&&a.key==="Escape"){if(a.preventDefault(),this.confirming)e.keep.click();else if(this.kbDraft)this.cancelDraft();else this.endMarking(!0);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};
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitrinka/web",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "vitrinka toolkit for React DOM apps — the journey recorder (capture manual-testing sessions: rrweb DOM stream, clicks, navigation, network, console, notes) and Report a problem (a reporter's button, marks and the last minutes, cs/en), straight into vitrinka.",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"repository": {
|