@qaiddev/thumbs-embed 1.11.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -13
- package/dist/a11y-dialog.d.ts +77 -0
- package/dist/a11y.d.ts +6 -65
- package/dist/chunks/annotate-DGyRcgPt.js +2 -0
- package/dist/chunks/{annotate-5zJWs-aB.js.map → annotate-DGyRcgPt.js.map} +1 -1
- package/dist/chunks/core-BsR7oV99.js +26 -0
- package/dist/chunks/core-BsR7oV99.js.map +1 -0
- package/dist/chunks/dom-scpOS8nl.js +2 -0
- package/dist/chunks/{dom-DvdtcUS8.js.map → dom-scpOS8nl.js.map} +1 -1
- package/dist/chunks/modal-DYxcs1Gm.js +2 -0
- package/dist/chunks/modal-DYxcs1Gm.js.map +1 -0
- package/dist/chunks/recording-BUw5-5Rf.js +2 -0
- package/dist/chunks/{recording-CPzxRL7f.js.map → recording-BUw5-5Rf.js.map} +1 -1
- package/dist/chunks/screenshot-CNe1irEz.js +2 -0
- package/dist/chunks/{screenshot-DYOKg2bS.js.map → screenshot-CNe1irEz.js.map} +1 -1
- package/dist/chunks/screenshot-dom-ZYP2w2h0.js +2 -0
- package/dist/chunks/{screenshot-dom-CME7tYRE.js.map → screenshot-dom-ZYP2w2h0.js.map} +1 -1
- package/dist/chunks/send-C26DRoYc.js +2 -0
- package/dist/chunks/send-C26DRoYc.js.map +1 -0
- package/dist/chunks/targeting-CMUEe-7C.js +6 -0
- package/dist/chunks/{targeting-mahtuPpo.js.map → targeting-CMUEe-7C.js.map} +1 -1
- package/dist/chunks/video-BSP4s2te.js +2 -0
- package/dist/chunks/{video-Bd_29-rK.js.map → video-BSP4s2te.js.map} +1 -1
- package/dist/embed.d.ts +26 -31
- package/dist/index.js +1495 -1390
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +6 -4
- package/dist/loader.js +1 -6
- package/dist/loader.js.map +1 -1
- package/dist/modal-positioning.d.ts +0 -27
- package/dist/qaid.umd.cjs +14 -14
- package/dist/qaid.umd.cjs.map +1 -1
- package/dist/quest-config.d.ts +2 -0
- package/dist/quest-launcher.d.ts +1 -3
- package/dist/send.d.ts +60 -0
- package/dist/tooltip-positioning.d.ts +31 -0
- package/package.json +2 -2
- package/dist/chunks/annotate-5zJWs-aB.js +0 -357
- package/dist/chunks/core-CL1dwdaN.js +0 -1342
- package/dist/chunks/core-CL1dwdaN.js.map +0 -1
- package/dist/chunks/dom-DvdtcUS8.js +0 -17
- package/dist/chunks/modal-DccueVYZ.js +0 -222
- package/dist/chunks/modal-DccueVYZ.js.map +0 -1
- package/dist/chunks/recording-CPzxRL7f.js +0 -323
- package/dist/chunks/screenshot-DYOKg2bS.js +0 -33
- package/dist/chunks/screenshot-dom-CME7tYRE.js +0 -63
- package/dist/chunks/targeting-mahtuPpo.js +0 -298
- package/dist/chunks/video-Bd_29-rK.js +0 -214
package/dist/qaid.umd.cjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(v,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(v=typeof globalThis<"u"?globalThis:v||self,E(v.Qaid={}))})(this,(function(v){"use strict";const E=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
2
2
|
<path stroke-linecap="round" stroke-linejoin="round" d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5"/>
|
|
3
|
-
</svg
|
|
3
|
+
</svg>`,V=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
4
4
|
<path stroke-linecap="round" stroke-linejoin="round" d="M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.737 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.095c.5 0 .905-.405.905-.905 0-.714.211-1.412.608-2.006L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5"/>
|
|
5
|
-
</svg>`,
|
|
5
|
+
</svg>`,pe=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
6
6
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z"/>
|
|
7
|
-
</svg>`,
|
|
7
|
+
</svg>`,tt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
8
8
|
<path stroke-linecap="round" stroke-linejoin="round" d="M8 10h8M8 14h5m-9 6l3.5-3.5H18a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v14z"/>
|
|
9
|
-
</svg>`,
|
|
9
|
+
</svg>`,fe=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
10
10
|
<rect x="4" y="6" width="16" height="12" rx="1" stroke-linejoin="round"/>
|
|
11
|
-
</svg>`,
|
|
11
|
+
</svg>`,me=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
12
12
|
<path stroke-linecap="round" stroke-linejoin="round" d="M5 19L19 5m0 0h-8m8 0v8"/>
|
|
13
|
-
</svg>`,
|
|
13
|
+
</svg>`,be=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
14
14
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 20h9M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/>
|
|
15
|
-
</svg>`,
|
|
15
|
+
</svg>`,ge=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
16
16
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3s6 6.4 6 10a6 6 0 01-12 0c0-3.6 6-10 6-10z"/>
|
|
17
|
-
</svg>`,
|
|
17
|
+
</svg>`,ve=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
18
18
|
<path stroke-linecap="round" stroke-linejoin="round" d="M9 14L4 9l5-5M4 9h11a5 5 0 010 10h-4"/>
|
|
19
|
-
</svg>`,
|
|
19
|
+
</svg>`,et=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
20
20
|
<path stroke-linecap="round" stroke-linejoin="round" d="M20 6L9 17l-5-5"/>
|
|
21
|
-
</svg>`,
|
|
21
|
+
</svg>`,ye=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
22
22
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6v8m0 4h.01"/>
|
|
23
|
-
</svg>`,
|
|
23
|
+
</svg>`,we=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
24
24
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6L6 18"/>
|
|
25
|
-
</svg>`,de="button{cursor:pointer}.qaid-buttons{display:flex;gap:.5rem}.qaid-buttons.qaid-vertical{flex-direction:column}.qaid-buttons.qaid-auto-container{position:fixed;z-index:50}.qaid-buttons.qaid-auto-container.qaid-bottom-right{bottom:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-bottom-left{bottom:1rem;left:1rem}.qaid-buttons.qaid-auto-container.qaid-top-right{top:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-top-left{top:1rem;left:1rem}.qaid-buttons.qaid-incognito{opacity:0;transition:opacity .2s ease-in-out}.qaid-buttons.qaid-incognito:hover{opacity:1}.qaid-buttons.qaid-dismissed{display:none!important}.qaid-dismiss-btn{width:20px;height:20px;padding:0;border:none;border-radius:50%;background:#0006;color:#fff;display:flex;align-items:center;justify-content:center;align-self:center;opacity:0;transition:opacity .15s,background .15s;cursor:pointer;pointer-events:auto;-webkit-appearance:none;appearance:none}.qaid-dismiss-btn:hover{background:#0009}.qaid-buttons:hover .qaid-dismiss-btn{opacity:1}button.qaid-btn-structural{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;-webkit-appearance:none;appearance:none}.qaid-icon{width:24px;height:24px}:where(button.qaid-btn-structural)>svg:where(:not(.qaid-icon):not([width])){width:var(--qaid-icon-size, 24px);height:var(--qaid-icon-size, 24px)}.qaid-btn-structural:not(:has(svg)),.qaid-btn:not(:has(svg)){font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-emoji-icon{font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-buttons,.qaid-buttons *,.qaid-modal-container,.qaid-modal-container *{cursor:pointer!important}.qaid-tooltip-wrapper{position:relative}.qaid-tooltip-text{position:fixed;padding:.5rem .75rem;background:#1f2937;color:#fff;font-size:var(--qaid-font-size, 16px);font-weight:600;border-radius:.5rem;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s;z-index:99999}.qaid-tooltip-text.qaid-tooltip-visible{opacity:1}button.qaid-btn-record:hover{background:#dc2626;color:#fff}button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}.qaid-buttons.qaid-incognito:focus-within{opacity:1}.qaid-buttons:focus-within .qaid-dismiss-btn,.qaid-dismiss-btn:focus-visible{opacity:1}.qaid-dismiss-btn{min-width:24px;min-height:24px}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}@media(forced-colors:active){button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid CanvasText;outline-offset:2px}}",ce="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let I=0;const le="button.qaid-btn{width:var(--qaid-btn-size);height:var(--qaid-btn-size);border-radius:50%;border:none;background:#f3f4f6;color:#374151;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);transition:background-color .2s,color .2s,transform .2s;-webkit-appearance:none;appearance:none;--qaid-hover-up-bg:var(--qaid-positive);--qaid-hover-up-color:#fff;--qaid-hover-down-bg:var(--qaid-negative);--qaid-hover-down-color:#fff}button.qaid-btn:hover{transform:scale(1.05)}button.qaid-btn-up:hover{background:var(--qaid-hover-up-bg);color:var(--qaid-hover-up-color)}button.qaid-btn-down:hover{background:var(--qaid-hover-down-bg);color:var(--qaid-hover-down-color)}button.qaid-btn-feedback:hover{background:var(--qaid-marker,#6365f1);color:var(--qaid-marker-text,#fff)}button.qaid-btn svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",he={small:36,medium:48,large:64},ue={small:18,medium:24,large:32};function fe(i,t,e){const[o,n,s]=[i,t,e].map(a=>(a=a/255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)));return .2126*o+.7152*n+.0722*s}function pe(i){if(i.startsWith("#")){const e=i.slice(1),o=e.length===3?e.split("").map(s=>s+s).join(""):e,n=parseInt(o,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=i.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function me(i){const t=pe(i);return t&&fe(t.r,t.g,t.b)>.4?"black":"white"}function be(i={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:e="rgb(255, 0, 0)",markerColor:o="#6365f1",buttonSize:n="medium",modalWidth:s=400,backdropOpacity:a=.3,fontFamily:c="system-ui, -apple-system, sans-serif",fontSize:l=16}=i,d=he[n],r=ue[n],h=me(o);return{"--qaid-positive":t,"--qaid-negative":e,"--qaid-marker":o,"--qaid-marker-text":h,"--qaid-btn-size":`${d}px`,"--qaid-icon-size":`${r}px`,"--qaid-modal-width":`${s}px`,"--qaid-backdrop-opacity":String(a),"--qaid-font-family":c,"--qaid-font-size":`${l}px`}}function ge(i,t){for(const[e,o]of Object.entries(t))i.style.setProperty(e,o)}function tt(){return de+le}function ve(){if(I++,I>1)return;const i=document.createElement("style");i.id="qaid-styles",i.textContent=ce,document.head.appendChild(i)}function ye(){I<=0||(I--,I===0&&document.getElementById("qaid-styles")?.remove())}const et="data-qaid-a11y-live",we="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;",ke=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function qe(i){return i.ownerDocument||document}function xe(i,t){const e=t?"assertive":"polite",o=i.querySelector(`[${et}="${e}"]`);if(o)return o;const s=qe(i).createElement("div");return s.setAttribute(et,e),s.setAttribute("role",t?"alert":"status"),s.setAttribute("aria-live",t?"assertive":"polite"),s.setAttribute("aria-atomic","true"),s.style.cssText=we,i.appendChild(s),s}function Ce(i,t,e={}){const o=xe(i,!!e.assertive);o.textContent="",o.textContent=t}function Se(i){return i.hasAttribute("disabled")?!0:i.disabled===!0}function Te(i){let t=i;for(;t;){if(t.hasAttribute("hidden"))return!0;const e=t.style;if(e&&(e.display==="none"||e.visibility==="hidden"||e.visibility==="collapse"))return!0;t=t.parentElement}return!1}function it(i){return Array.from(i.querySelectorAll(ke)).filter(e=>!(e.getAttribute("tabindex")==="-1"||e instanceof HTMLInputElement&&e.type==="hidden"||e instanceof HTMLAnchorElement&&!e.getAttribute("href")||Se(e)||Te(e)))}function ot(i){let t=i.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function Ee(i){const t=i.ownerDocument||document;let e=!1;const o=s=>{if(s.key!=="Tab")return;const a=it(i);if(a.length===0){s.preventDefault(),i.focus();return}const c=a[0],l=a[a.length-1],d=ot(t),r=d?a.indexOf(d)!==-1:!1;s.shiftKey?(!r||d===c)&&(s.preventDefault(),l.focus()):(!r||d===l)&&(s.preventDefault(),c.focus())};i.addEventListener("keydown",o);const n=it(i);return n.length>0?n[0].focus():(i.hasAttribute("tabindex")||(i.setAttribute("tabindex","-1"),e=!0),i.focus()),{release(){i.removeEventListener("keydown",o),e&&(i.removeAttribute("tabindex"),e=!1)}}}function Ae(){return ot(document)}function Le(i){if(!(!i||typeof i.focus!="function"))try{i.focus()}catch{}}function Ie(i,t={}){i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),t.labelledbyId&&i.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&i.setAttribute("aria-describedby",t.describedbyId),t.label&&i.setAttribute("aria-label",t.label)}function De(i,t){let e=i;for(;e&&e!==t;){const o=e.parentNode;if(o===t)return e;if(o&&o.host){e=o.host;continue}if(!o)return null;e=o}return null}function Me(i){const e=(i.ownerDocument||document).body;if(!e)return()=>{};const o=De(i,e),n=[];return Array.from(e.children).forEach(s=>{if(!(s instanceof HTMLElement)||o&&s===o)return;const a=s.inert===!0,c=s.getAttribute("aria-hidden");a&&c==="true"||(s.inert=!0,s.setAttribute("aria-hidden","true"),n.push({el:s,prevInert:a,prevAriaHidden:c}))}),function(){for(;n.length;){const a=n.pop();a.el.inert=a.prevInert,a.prevAriaHidden===null?a.el.removeAttribute("aria-hidden"):a.el.setAttribute("aria-hidden",a.prevAriaHidden)}}}const nt={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function Re(i,t,e,o,n){const s=i.y,a=t-(i.y+i.height);if(a>=e+o)return{top:i.y+i.height+o,position:"below"};if(s>=e+o)return{top:i.y-e-o,position:"above"};const c=a>s?"below":"above";let l;return c==="below"?l=Math.min(i.y+i.height+o,t-e-n):l=Math.max(n,i.y-e-o),{top:l,position:c}}function Pe(i,t,e,o){let s=i.x+i.width/2-e/2;return s=Math.max(o,Math.min(s,t-e-o)),s}function Be(i,t,e,o=24,n=24){const a=i.clickX-t-n/2;return Math.max(o,Math.min(a,e-o-n/2))}function He(i,t,e,o=nt){const n=o.height+o.arrowHeight,s=Re(i,e,n,o.gap,o.viewportPadding),a=Pe(i,t,o.width,o.viewportPadding);return{top:s.top,left:a,position:s.position}}function Oe(i,t,e,o={}){const n=o.gap??8;let s=i.bottom+n;s+t.height>e.height-n&&(s=i.top-t.height-n);let a=i.left;return a<n?a=n:a+t.width>e.width-n&&(a=e.width-t.width-n),s<n?s=n:s+t.height>e.height-n&&(s=e.height-t.height-n),{top:s,left:a}}function ze(i,t,e,o=nt){const n=He(i,t,e,o),s=Be(i,n.left,o.width);return{modal:n,arrow:{left:s}}}const $e=20;function _e(i){const t=[],e=console.error,o=console.warn,n=console.log,s=(a,c)=>{const l={message:c.map(d=>String(d)).join(" "),timestamp:Date.now(),level:a};t.length>=$e&&t.shift(),t.push(l),i&&i(l)};return console.error=function(...a){s("error",a),e.apply(console,a)},console.warn=function(...a){s("warn",a),o.apply(console,a)},console.log=function(...a){s("log",a),n.apply(console,a)},{errors:t,restore:()=>{console.error=e,console.warn=o,console.log=n}}}function x(i,t,e){const o=document.createElement(i);if(t)for(const[n,s]of Object.entries(t))n==="className"?o.className=s:o.setAttribute(n,s);return o}function Fe(i=640){return typeof window<"u"&&window.innerWidth<i}function st(i,t,e){const o=e.map(s=>s.style.visibility);e.forEach(s=>s.style.visibility="hidden");const n=document.elementFromPoint(i,t);return e.forEach((s,a)=>s.style.visibility=o[a]),n}function H(i){return i?i.hasAttribute("data-qaid-embed")||i.hasAttribute("data-qaid-embed-overlay")?!0:!!i.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function at(i,t=0){const e=i.getBoundingClientRect();return{x:e.left-t,y:e.top-t,width:e.width+t*2,height:e.height+t*2}}const Ne="https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";let Ve=i=>import(i),D=null,_=null;const F=new Map,N=new Map;function rt(i,t){return`${i.replace(/\/+$/,"")}/${encodeURIComponent(t)}/definition`}function Ue(i){if(F.has(i))return Promise.resolve();const t=N.get(i);if(t)return t;const e=fetch(i,{headers:{Accept:"application/json"}}).then(o=>o.ok?o.json():null).then(o=>{o&&F.set(i,o)}).catch(()=>{}).finally(()=>{N.delete(i)});return N.set(i,e),e}function dt(i){return D&&_===i||(_=i,D=Promise.resolve(Ve(i)).then(t=>{const e=t;if(!e||typeof e.QaidQuests!="function")throw new Error("quests module has no QaidQuests export");return e}).catch(t=>{throw D=null,_=null,t})),D}async function je(i){const t=await dt(i.moduleUrl),e=i.base.replace(/\/+$/,""),o=rt(e,i.questId),n=c=>c!=null?{feedbackId:c}:void 0;let s;const a=i.feedbackId;return a instanceof Promise?s=t.QaidQuests.supports?.asyncMetadata?a.then(n,()=>{}):n(await a.catch(()=>null)):s=n(a??null),new t.QaidQuests({endpoint:`${e}/responses`,configUrl:o,questionnaire:F.get(o),apiKey:i.apiKey||void 0,metadata:s,onClose:i.onClose})}const ct="qaid_visitor_id",lt="qaid_hide_feedback",Ke=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"];function We(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function V(i){return i?`${lt}_${i}`:lt}function Xe(i){try{return localStorage.getItem(V(i))==="1"}catch{return!1}}function ht(i,t=!0){try{t?localStorage.setItem(V(i),"1"):localStorage.removeItem(V(i))}catch{}}function ut(){const i=typeof crypto<"u"?crypto:void 0;if(i&&typeof i.randomUUID=="function")return i.randomUUID();const t=new Uint8Array(16);if(i&&typeof i.getRandomValues=="function")i.getRandomValues(t);else for(let o=0;o<t.length;o++)t[o]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,o=>o.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function Qe(){try{let i=localStorage.getItem(ct);return i||(i=ut(),localStorage.setItem(ct,i)),i}catch{return ut()}}function ft(i,t){const e=document.createElement("style");e.setAttribute("data-qaid-feature",""),e.textContent=t;const o=i.querySelectorAll("style[data-qaid-base], style[data-qaid-feature]"),n=o[o.length-1];i.insertBefore(e,n?n.nextSibling:i.firstChild)}class pt{config;state="IDLE";feedbackData={feedbackType:null,elementSelector:null,elementText:null,consoleErrors:[]};selectedBounds={x:0,y:0,width:0,height:0,clickX:0,clickY:0,visible:!1};feedbackIdPromise=Promise.resolve(null);questsPrewarmed=!1;activeQuest=null;isMobile=!1;visitorId;consoleCapture=null;recording=null;targeting=null;targetingPrewarmed=!1;prewarmHandle=null;prewarmIsTimeout=!1;videoPrewarmed=!1;screenshotPrewarmed=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;modal=null;modalPrewarmed=!1;dismissBtn=null;cssVars={};activeThumbBtn=null;keyboardActivation=!1;dialogTrigger=null;dialogTrap=null;dialogRestoreInert=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundResize;_startDismissed=!1;destroyed=!1;domObserver=null;boundBeforeSwap=null;constructor(t){this.config={endpoint:t.endpoint,apiKey:t.apiKey??"",container:t.container??"",buttonClass:t.buttonClass??"",direction:t.direction??"horizontal",position:t.position??"bottom-right",offset:{x:t.offset?.x??16,y:t.offset?.y??16},zIndex:t.zIndex??50,skipTargeting:t.skipTargeting??!1,singleButton:t.singleButton??!1,feedbackMode:t.feedbackMode??"target",colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#6365f1"},buttonSize:t.buttonSize??"medium",text:{tooltip:t.text?.tooltip??"",modalTitle:t.text?.modalTitle??"Thank you for your feedback!",modalSubtitle:t.text?.modalSubtitle??"Would you like to add a message to help us understand your feedback better?",placeholder:t.text?.placeholder??"Optional: Tell us more about your experience...",submitButton:t.text?.submitButton??"Submit",skipButton:t.text?.skipButton??"Skip",positiveLabel:t.text?.positiveLabel??"Send positive feedback",negativeLabel:t.text?.negativeLabel??"Send negative feedback",recordLabel:t.text?.recordLabel??"Record a screen recording",dismissLabel:t.text?.dismissLabel??"Hide Feedback",feedbackLabel:t.text?.feedbackLabel??"Send feedback",confirmationTitle:t.text?.confirmationTitle??"Thank you!",confirmationMessage:t.text?.confirmationMessage??"Your feedback has been received.",confirmationClose:t.text?.confirmationClose??"Close",errorTitle:t.text?.errorTitle??"Message not sent",errorMessage:t.text?.errorMessage??"Something went wrong, so we did not get your message. Please try again later."},hideConfirmation:t.hideConfirmation??!1,modalWidth:t.modalWidth??400,backdropOpacity:t.backdropOpacity??.3,fontFamily:t.fontFamily??"system-ui, -apple-system, sans-serif",fontSize:t.fontSize??16,captureScreenshot:t.captureScreenshot??!1,annotate:t.annotate??!0,annotationColor:t.annotationColor??t.colors?.marker??"#6365f1",annotationPalette:t.annotationPalette??Ke,screenshotMethod:t.screenshotMethod??"permission",screenshotOptions:{quality:t.screenshotOptions?.quality??.8,maxWidth:t.screenshotOptions?.maxWidth??1280,maxHeight:t.screenshotOptions?.maxHeight??800},incognito:t.incognito??!1,hideDismiss:t.hideDismiss??!1,positiveIcon:t.positiveIcon??"",negativeIcon:t.negativeIcon??"",feedbackIcon:t.feedbackIcon??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15,redaction:t.videoOptions?.redaction??!1},recordIcon:t.recordIcon??"",quests:{base:t.quests?.base??"",up:t.quests?.up??"",down:t.quests?.down??"",video:t.quests?.video??"",apiKey:t.quests?.apiKey??t.apiKey??"",moduleUrl:t.quests?.moduleUrl??Ne}},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=Qe(),this.init()}applyVars(t){ge(t,this.cssVars)}announceMsg(t,e=!1){const o=this.overlayShadowRoot??this.shadowRoot;o&&Ce(o,t,{assertive:e})}openDialogA11y(t,e){this.dialogTrigger=Ae(),Ie(t,e),this.dialogTrap=Ee(t),this.dialogRestoreInert=Me(t)}closeDialogA11y(){this.dialogTrap?.release(),this.dialogTrap=null,this.dialogRestoreInert&&(this.dialogRestoreInert(),this.dialogRestoreInert=null),Le(this.dialogTrigger),this.dialogTrigger=null}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){ve(),this.cssVars=be({positiveColor:this.config.colors.positive,negativeColor:this.config.colors.negative,markerColor:this.config.colors.marker,buttonSize:this.config.buttonSize,modalWidth:this.config.modalWidth,backdropOpacity:this.config.backdropOpacity,fontFamily:this.config.fontFamily,fontSize:this.config.fontSize}),!this.config.hideDismiss&&Xe(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=_e(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom(),(this.config.captureVideo&&this.videoSupported()||this.config.captureScreenshot||this.linkedQuestIds().length>0)&&this.schedulePrewarm(()=>{this.config.captureVideo&&this.videoSupported()&&this.prewarmVideo(),this.config.captureScreenshot&&this.prewarmScreenshot(),this.prewarmQuests()})}prewarmVideo(){this.videoPrewarmed||(this.videoPrewarmed=!0,Promise.resolve().then(()=>Pt).catch(()=>{}),Promise.resolve().then(()=>St).catch(()=>{}))}prewarmScreenshot(){this.screenshotPrewarmed||(this.screenshotPrewarmed=!0,(this.shouldCaptureViaDom()?Promise.resolve().then(()=>Lt):Promise.resolve().then(()=>Bt)).catch(()=>{}),this.config.annotate&&Promise.resolve().then(()=>Rt).catch(()=>{}))}linkedQuestIds(){const t=this.config.quests;return t.base?[t.up,t.down,t.video].filter(e=>e):[]}prewarmQuests(){if(this.questsPrewarmed)return;const t=this.linkedQuestIds();if(t.length!==0){this.questsPrewarmed=!0,dt(this.config.quests.moduleUrl).catch(()=>{});for(const e of t)Ue(rt(this.config.quests.base,e))}}schedulePrewarm(t){const e=window,o=()=>{this.destroyed||t()};typeof e.requestIdleCallback=="function"?(this.prewarmIsTimeout=!1,this.prewarmHandle=e.requestIdleCallback(o,{timeout:2e3})):(this.prewarmIsTimeout=!0,this.prewarmHandle=window.setTimeout(o,1200))}observeDom(){this.boundBeforeSwap=t=>{const e=t.newDocument;!e||this.destroyed||(this.shadowHost&&e.body.appendChild(this.shadowHost),this.overlayShadowHost&&e.body.appendChild(this.overlayShadowHost))},document.addEventListener("astro:before-swap",this.boundBeforeSwap),this.domObserver=new MutationObserver(()=>{this.destroyed||(this.shadowHost&&!this.shadowHost.isConnected&&document.body.appendChild(this.shadowHost),this.overlayShadowHost&&!this.overlayShadowHost.isConnected&&document.body.appendChild(this.overlayShadowHost))}),this.domObserver.observe(document.body,{childList:!0})}checkMobile(){this.isMobile=Fe()}handleResize(){this.checkMobile()}createEmbed(){this.shadowHost=document.createElement("div"),this.shadowHost.setAttribute("data-qaid-embed",""),this.shadowHost.style.position="static",this.shadowHost.style.display="contents";let t=null;this.config.container&&(t=document.querySelector(this.config.container)),t?(t.appendChild(this.shadowHost),this.isUserProvidedContainer=!0,this.config.hideDismiss=!0):(this.shadowHost.style.position="fixed",this.shadowHost.style.display="block",this.shadowHost.style.inset="0",this.shadowHost.style.pointerEvents="none",this.shadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.shadowHost)),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"});const e=document.createElement("style");if(e.setAttribute("data-qaid-base",""),e.textContent=tt(),this.shadowRoot.appendChild(e),this.config.css){const d=document.createElement("style");d.textContent=this.config.css,this.shadowRoot.appendChild(d)}const o=this.config.direction==="vertical"?"qaid-vertical":"";if(this.isUserProvidedContainer)this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-${this.config.position} ${o}`.trim(),this.config.incognito&&this.buttonsContainer.classList.add("qaid-incognito");else{this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-auto-container qaid-${this.config.position} ${o}${this.config.incognito?" qaid-incognito":""}`.trim(),this.buttonsContainer.style.pointerEvents="auto";const{x:d,y:r}=this.config.offset;this.config.position.includes("right")?this.buttonsContainer.style.right=`${d}px`:this.buttonsContainer.style.left=`${d}px`,this.config.position.includes("bottom")?this.buttonsContainer.style.bottom=`${r}px`:this.buttonsContainer.style.top=`${r}px`}this.applyVars(this.buttonsContainer),this.shadowRoot.appendChild(this.buttonsContainer),this.buttonsContainer.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" "||d.key==="Spacebar")&&(this.keyboardActivation=!0)}),this.buttonsContainer.addEventListener("mousedown",()=>{this.keyboardActivation=!1}),this.buttonsContainer.addEventListener("pointerdown",()=>{this.keyboardActivation=!1});const n=!!this.config.buttonClass,s=n?`qaid-btn-structural ${this.config.buttonClass}`:"qaid-btn",c=this.config.text.tooltip||"Feedback for us?",l=document.createElement("div");if(l.className="qaid-tooltip-text",l.textContent=c,this.applyVars(l),this.shadowRoot.appendChild(l),this.tooltipElement=l,this.config.singleButton){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-feedback`:"qaid-btn qaid-btn-feedback",r.setAttribute("aria-label",this.config.text.feedbackLabel),r.innerHTML=this.config.feedbackIcon||G,r.addEventListener("click",h=>this.handleThumbClick("neutral",h.currentTarget,h)),r.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(r)}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r),this.buttonsContainer.appendChild(d)}else if(!this.config.hideThumbs){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",r.setAttribute("aria-label",this.config.text.positiveLabel),r.innerHTML=this.config.positiveIcon||T,r.addEventListener("click",b=>this.handleThumbClick("up",b.currentTarget,b)),r.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.prewarmQuests(),this.showTooltip(r)}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r);const h=document.createElement("div");h.className="qaid-tooltip-wrapper";const p=document.createElement("button");p.type="button",p.className=n?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",p.setAttribute("aria-label",this.config.text.negativeLabel),p.innerHTML=this.config.negativeIcon||$,p.addEventListener("click",b=>this.handleThumbClick("down",b.currentTarget,b)),p.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.prewarmQuests(),this.showTooltip(p)}),p.addEventListener("mouseleave",()=>this.hideTooltip()),h.appendChild(p),this.buttonsContainer.appendChild(d),this.buttonsContainer.appendChild(h)}if(this.config.captureVideo&&this.videoSupported()){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",r.setAttribute("aria-label",this.config.text.recordLabel),r.innerHTML=this.config.recordIcon||te,r.addEventListener("click",()=>{this.ensureRecording().then(p=>this.config.videoOptions.redaction?p.startPicking():p.startRecording())});const h=()=>this.prewarmVideo();r.addEventListener("mouseenter",()=>{h(),this.showTooltip(r)}),r.addEventListener("focus",h),r.addEventListener("touchstart",h,{passive:!0}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r),this.buttonsContainer.appendChild(d)}this.config.hideDismiss||(this.dismissBtn=document.createElement("button"),this.dismissBtn.type="button",this.dismissBtn.className="qaid-dismiss-btn",this.dismissBtn.setAttribute("aria-label",this.config.text.dismissLabel),this.dismissBtn.title=this.config.text.dismissLabel,this.dismissBtn.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 2l8 8M10 2l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',this.dismissBtn.addEventListener("click",d=>{d.stopPropagation(),this.handleDismiss()}),this.buttonsContainer.insertBefore(this.dismissBtn,this.buttonsContainer.firstChild),this._startDismissed&&this.buttonsContainer.classList.add("qaid-dismissed"))}ensureOverlayHost(){if(this.overlayShadowRoot)return this.overlayShadowRoot;this.overlayShadowHost=document.createElement("div"),this.overlayShadowHost.setAttribute("data-qaid-embed-overlay",""),this.overlayShadowHost.style.position="fixed",this.overlayShadowHost.style.inset="0",this.overlayShadowHost.style.pointerEvents="none",this.overlayShadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.overlayShadowHost),this.overlayShadowRoot=this.overlayShadowHost.attachShadow({mode:"open"});const t=document.createElement("style");t.setAttribute("data-qaid-base",""),t.textContent=tt(),this.overlayShadowRoot.appendChild(t);for(const e of this.featureStyles)ft(this.overlayShadowRoot,e);if(this.config.css){const e=document.createElement("style");e.textContent=this.config.css,this.overlayShadowRoot.appendChild(e)}return this.overlayShadowRoot}featureStyles=[];addFeatureStyles(t){if(!this.featureStyles.includes(t)){this.featureStyles.push(t);for(const e of[this.shadowRoot,this.overlayShadowRoot])e&&ft(e,t)}}tooltipElement=null;showTooltip(t){const e=this.tooltipElement;e.style.visibility="hidden",e.classList.add("qaid-tooltip-visible");const o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),{top:s,left:a}=Oe(o,n,{width:window.innerWidth,height:window.innerHeight});e.style.top=`${s}px`,e.style.left=`${a}px`,e.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),ht(this.config.apiKey,!0)}handleThumbClick(t,e,o){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),ht(this.config.apiKey,!1)),this.prewarmModal(),this.config.skipTargeting||this.config.feedbackMode==="annotate")this.submitDirectFeedback(t,e);else{this.activeThumbBtn=e,e.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,this.ensureTargeting().then(s=>{this.destroyed||(n?s.startKeyboard(t):s.startPointer(t,o))})}}submitDirectFeedback(t,e){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const o=e.getBoundingClientRect();this.selectedBounds={x:o.left,y:o.top,width:o.width,height:o.height,clickX:o.left+o.width/2,clickY:o.top+o.height/2,visible:!1},this.submitFeedback()}handleKeyDown(t){if(t.key==="Escape"){if(this.recording?.handleEscape())return;this.state==="TARGETING"?this.targeting?.cancel():this.state==="MODAL_OPEN"&&this.modal?.close()}}shouldCaptureViaDom(){return this.config.screenshotMethod==="dom"||We()}async openAnnotationEditor(t){const e=this.ensureOverlayHost(),o=this.overlayShadowHost,n=o.style.pointerEvents;o.style.pointerEvents="auto";try{const{openAnnotationEditor:s,styles:a}=await Promise.resolve().then(()=>Rt);return this.addFeatureStyles(a),await s({dataUrl:t,root:e,quality:this.config.screenshotOptions.quality,color:this.config.annotationColor,palette:this.config.annotationPalette,applyVars:c=>this.applyVars(c),announce:(c,l)=>this.announceMsg(c,l),openDialog:(c,l)=>this.openDialogA11y(c,l),closeDialog:()=>this.closeDialogA11y()})}catch(s){return console.error("Annotation editor failed to open:",s),null}finally{o.style.pointerEvents=n}}async submitFeedback(){let t=null;if(this.config.captureScreenshot||this.config.feedbackMode==="annotate")try{if(this.shouldCaptureViaDom()){const{captureDomScreenshot:a}=await Promise.resolve().then(()=>Lt);t=await a(this.config.screenshotOptions)}else{const{captureScreenshot:a}=await Promise.resolve().then(()=>Bt);t=await a(this.config.screenshotOptions)}t&&this.announceMsg("Screenshot captured")}catch(a){console.error("Screenshot capture failed:",a),t=null}t&&this.config.annotate&&(t=await this.openAnnotationEditor(t)??t);const o=this.feedbackData.elementSelector?{x:this.selectedBounds.x,y:this.selectedBounds.y,width:this.selectedBounds.width,height:this.selectedBounds.height}:null,n={feedbackType:this.feedbackData.feedbackType,pageUrl:window.location.href,apiKey:this.config.apiKey||void 0,elementSelector:this.feedbackData.elementSelector,elementText:this.feedbackData.elementText,consoleErrors:[...this.feedbackData.consoleErrors],screenWidth:window.innerWidth,screenHeight:window.innerHeight,clickX:this.selectedBounds.clickX,clickY:this.selectedBounds.clickY,scrollX:window.scrollX,scrollY:window.scrollY,screenshot:t,visitorId:this.visitorId,elementBounds:o,userAgent:navigator.userAgent};this.feedbackIdPromise=this.postFeedback(n);const s=this.feedbackData.feedbackType;if(s&&s!=="neutral"&&await this.tryLaunchQuest(s,this.feedbackIdPromise)){this.resetFeedbackUi();return}this.state="MODAL_OPEN";try{const a=await this.ensureModal();if(this.destroyed)return;a.open(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto")}catch(a){console.error("Failed to open the feedback modal:",a),this.announceMsg("Thank you for your feedback!",!0),this.resetFeedbackUi()}}async postFeedback(t){try{const e=await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(e.ok){const o=await e.json();return this.announceMsg("Feedback sent"),o.id}}catch(e){console.error("Failed to submit feedback:",e),this.announceMsg("Failed to send feedback",!0)}return null}questIdFor(t){const e=this.config.quests;return e.base&&e[t]||""}async tryLaunchQuest(t,e){const o=this.questIdFor(t);if(!o)return!1;try{return this.activeQuest?.destroy(),this.activeQuest=await je({questId:o,base:this.config.quests.base,apiKey:this.config.quests.apiKey||void 0,moduleUrl:this.config.quests.moduleUrl,feedbackId:e,onClose:()=>{this.activeQuest=null}}),!0}catch(n){return console.error("Failed to launch quest:",n),this.activeQuest=null,!1}}resetFeedbackUi(){this.targeting?.hideMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackIdPromise=Promise.resolve(null),this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}async ensureModal(){if(!this.modal){const{ModalController:t,styles:e}=await Promise.resolve().then(()=>Ht);this.addFeatureStyles(e),this.modal=new t(this.makeModalHost())}return this.modal}makeModalHost(){const t=this;return{get config(){return t.config},get uid(){return t.uid},get isMobile(){return t.isMobile},get state(){return t.state},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},whenFeedbackId:()=>t.feedbackIdPromise,ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),resetFeedbackUi:()=>t.resetFeedbackUi()}}prewarmModal(){this.modalPrewarmed||(this.modalPrewarmed=!0,Promise.resolve().then(()=>Ht).catch(()=>{}))}async ensureTargeting(){if(!this.targeting){const{TargetingController:t,styles:e}=await Promise.resolve().then(()=>$t);this.addFeatureStyles(e),this.targeting=new t(this.makeTargetingHost())}return this.targeting}makeTargetingHost(){const t=this;return{get config(){return t.config},get cssVars(){return t.cssVars},get state(){return t.state},get shadowHost(){return t.shadowHost},get overlayShadowHost(){return t.overlayShadowHost},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),clearActiveThumb:()=>t.clearActiveThumb(),submitFeedback:()=>t.submitFeedback()}}prewarmTargeting(){this.targetingPrewarmed||this.config.skipTargeting||(this.targetingPrewarmed=!0,Promise.resolve().then(()=>$t).catch(()=>{}))}videoSupported(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}async ensureRecording(){if(!this.recording){const{RecordingController:t,styles:e}=await Promise.resolve().then(()=>Pt);this.addFeatureStyles(e),this.recording=new t(this.makeRecordingHost())}return this.recording}makeRecordingHost(){const t=this;return{get config(){return t.config},get visitorId(){return t.visitorId},get uid(){return t.uid},get overlayShadowHost(){return t.overlayShadowHost},get consoleCapture(){return t.consoleCapture},get boundKeyDown(){return t.boundKeyDown},get state(){return t.state},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),setButtonsDisabled:e=>t.setButtonsDisabled(e),tryLaunchQuest:(e,o)=>t.tryLaunchQuest(e,o)}}setButtonsDisabled(t){if(!this.buttonsContainer)return;this.buttonsContainer.querySelectorAll("button.qaid-btn, button.qaid-btn-structural").forEach(o=>{t?o.classList.contains("qaid-btn-record")||(o.disabled=!0,o.style.opacity="0.5"):(o.disabled=!1,o.style.opacity="")})}destroy(){if(this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.targeting?.destroy(),this.targeting=null,this.clearActiveThumb(),this.closeDialogA11y(),this.prewarmHandle!==null){const t=window;this.prewarmIsTimeout?clearTimeout(this.prewarmHandle):t.cancelIdleCallback?.(this.prewarmHandle),this.prewarmHandle=null}this.recording?.destroy(),this.recording=null,this.modal?.destroy(),this.modal=null,this.activeQuest?.destroy(),this.activeQuest=null,this.consoleCapture&&(this.consoleCapture.restore(),this.consoleCapture=null),window.removeEventListener("resize",this.boundResize),document.removeEventListener("keydown",this.boundKeyDown),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.shadowHost&&(this.shadowHost.remove(),this.shadowHost=null,this.shadowRoot=null),this.overlayShadowHost&&(this.overlayShadowHost.remove(),this.overlayShadowHost=null,this.overlayShadowRoot=null),this.buttonsContainer=null,this.dismissBtn=null,this.tooltipElement=null,ye()}}function mt(i){return document.querySelector(i)?.textContent?.trim()??""}function Ye(){const i=document.querySelector('script[type="application/json"][data-feedback-config]');if(!i)return null;const t=i.textContent?.trim();if(!t)return null;try{const e=JSON.parse(t);return e.cssSelector&&!e.css&&(e.css=mt(e.cssSelector),delete e.cssSelector),e}catch{return null}}function bt(i,t,e){console.warn(`[thumbs-embed] Ignoring ${i}="${t}": expected ${e}.`)}function Je(i){const t=[];let e=0,o="";for(const n of i)n==="("&&e++,n===")"&&(e=Math.max(0,e-1)),n===","&&e===0?(t.push(o.trim()),o=""):o+=n;return t.push(o.trim()),t}function Ge(i,t){if(t===null)return;const e=t.trim();let o=null;if(e.startsWith("[")||e.startsWith("{"))try{o=JSON.parse(e)}catch{o=null}else o=Je(e);if(Array.isArray(o)&&o.length>0&&o.every(n=>typeof n=="string"&&n.trim()!==""))return o.map(n=>n.trim());bt(i,t,"a JSON array of colours or a comma-separated list")}function O(i,t){if(t!==null){if(t.trim()===""){bt(i,t,"a non-empty label");return}return t}}function Ze(i){const t=i.getAttribute("data-endpoint");if(!t)return null;const e=i.getAttribute("data-position"),o=i.getAttribute("data-zindex"),n=i.getAttribute("data-positive-color"),s=i.getAttribute("data-negative-color"),a=i.getAttribute("data-marker-color"),c=i.getAttribute("data-container"),l=i.getAttribute("data-button-class"),d=i.getAttribute("data-skip-targeting"),r=i.getAttribute("data-hide-confirmation"),h=i.getAttribute("data-single-button"),p=i.getAttribute("data-feedback-mode"),b=i.getAttribute("data-incognito"),w=i.getAttribute("data-button-size"),v=i.getAttribute("data-offset-x"),k=i.getAttribute("data-offset-y"),C=i.getAttribute("data-modal-width"),f=i.getAttribute("data-backdrop-opacity"),q=i.getAttribute("data-font-family"),y=i.getAttribute("data-font-size"),S=i.getAttribute("data-tooltip"),B=i.getAttribute("data-modal-title"),E=i.getAttribute("data-confirmation-title"),m=i.getAttribute("data-confirmation-message"),L=i.getAttribute("data-confirmation-close"),_t=i.getAttribute("data-error-title"),Ft=i.getAttribute("data-error-message"),Nt=i.getAttribute("data-modal-subtitle"),Vt=i.getAttribute("data-placeholder"),Ut=i.getAttribute("data-submit-button"),jt=i.getAttribute("data-skip-button"),Ki=i.getAttribute("data-positive-icon"),Wi=i.getAttribute("data-negative-icon"),Xi=i.getAttribute("data-feedback-icon"),Kt=i.getAttribute("data-feedback-label"),Qi=i.getAttribute("data-api-key"),Yi=i.getAttribute("data-capture-screenshot"),Ji=i.getAttribute("data-annotate"),Gi=i.getAttribute("data-annotation-color"),X=i.getAttribute("data-screenshot-quality"),Q=i.getAttribute("data-screenshot-max-width"),Y=i.getAttribute("data-screenshot-max-height"),Zi=i.getAttribute("data-capture-video"),Wt=i.getAttribute("data-video-redaction"),to=i.getAttribute("data-hide-thumbs"),eo=i.getAttribute("data-hide-dismiss"),J=i.getAttribute("data-video-max-duration"),io=i.getAttribute("data-screenshot-method"),oo=i.getAttribute("data-direction"),Xt=i.getAttribute("data-css-selector"),no=i.getAttribute("data-css"),Qt=O("data-positive-label",i.getAttribute("data-positive-label")),Yt=O("data-negative-label",i.getAttribute("data-negative-label")),Jt=O("data-record-label",i.getAttribute("data-record-label")),Gt=O("data-dismiss-label",i.getAttribute("data-dismiss-label")),so=Ge("data-annotation-palette",i.getAttribute("data-annotation-palette")),ao=i.getAttribute("data-record-icon"),Zt=i.getAttribute("data-quest-base"),ro=i.getAttribute("data-quest-up"),co=i.getAttribute("data-quest-down"),lo=i.getAttribute("data-quest-video"),ho=i.getAttribute("data-quest-api-key"),uo=i.getAttribute("data-quest-module-url");return{endpoint:t,css:no||(Xt?mt(Xt):void 0),apiKey:Qi??void 0,captureScreenshot:Yi==="true"?!0:void 0,annotate:Ji==="false"?!1:void 0,annotationColor:Gi??void 0,annotationPalette:so,screenshotOptions:X||Q||Y?{quality:X?parseFloat(X):void 0,maxWidth:Q?parseInt(Q,10):void 0,maxHeight:Y?parseInt(Y,10):void 0}:void 0,container:c??void 0,buttonClass:l??void 0,direction:oo??void 0,position:e??void 0,zIndex:o?parseInt(o,10):void 0,skipTargeting:d==="true"?!0:void 0,hideConfirmation:r==="true"?!0:void 0,singleButton:h==="true"?!0:void 0,feedbackMode:p??void 0,incognito:b==="true"?!0:void 0,buttonSize:w??void 0,offset:v||k?{x:v?parseInt(v,10):void 0,y:k?parseInt(k,10):void 0}:void 0,modalWidth:C?parseInt(C,10):void 0,backdropOpacity:f?parseFloat(f):void 0,fontFamily:q??void 0,fontSize:y?parseInt(y,10):void 0,colors:{positive:n??void 0,negative:s??void 0,marker:a??void 0},text:S||B||Nt||Vt||Ut||jt||Kt||E||m||L||_t||Ft||Qt||Yt||Jt||Gt?{tooltip:S??void 0,modalTitle:B??void 0,modalSubtitle:Nt??void 0,placeholder:Vt??void 0,submitButton:Ut??void 0,skipButton:jt??void 0,feedbackLabel:Kt??void 0,confirmationTitle:E??void 0,confirmationMessage:m??void 0,confirmationClose:L??void 0,errorTitle:_t??void 0,errorMessage:Ft??void 0,positiveLabel:Qt,negativeLabel:Yt,recordLabel:Jt,dismissLabel:Gt}:void 0,positiveIcon:Ki??void 0,recordIcon:ao??void 0,negativeIcon:Wi??void 0,feedbackIcon:Xi??void 0,screenshotMethod:io??void 0,captureVideo:Zi==="true"?!0:void 0,hideThumbs:to==="true"?!0:void 0,hideDismiss:eo==="true"?!0:void 0,videoOptions:J||Wt?{maxDuration:J?parseInt(J,10):void 0,redaction:Wt==="true"?!0:void 0}:void 0,quests:Zt?{base:Zt,up:ro??void 0,down:co??void 0,video:lo??void 0,apiKey:ho??void 0,moduleUrl:uo??void 0}:void 0}}function ti(){if(typeof document>"u")return;const i=()=>{const t=document.currentScript??document.querySelector("script[data-endpoint]"),e=Ye()??(t?Ze(t):null);e?.endpoint&&new pt(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}const ei=20,gt=4096;function z(i){const t=typeof i=="string"?i:JSON.stringify(i);return t.length>gt?t.slice(0,gt)+"…[truncated]":t}function vt(i,t){i.length>=ei&&i.shift(),i.push(t)}async function ii(i){try{const t=await i.clone().text();return z(t)}catch{return}}function yt(){const i=[],t=window.fetch;window.fetch=async function(n,s){const a=typeof n=="string"?n:n instanceof URL?n.toString():n.url,c=s?.method??(typeof n=="object"&&"method"in n?n.method:"GET");let l;s?.body&&(l=z(s.body));const d=await t.apply(window,[n,s]);if(d.status>=400){const r=await ii(d);vt(i,{url:a,method:c.toUpperCase(),status:d.status,statusText:d.statusText,requestBody:l,responseBody:r,timestamp:Date.now()})}return d};const e=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,s,...a){return this._qaid_method=n,this._qaid_url=typeof s=="string"?s:s.toString(),e.apply(this,[n,s,...a])},XMLHttpRequest.prototype.send=function(n){const s=this,a=n?z(n):void 0;return s.addEventListener("load",function(){s.status>=400&&vt(i,{url:s._qaid_url,method:s._qaid_method.toUpperCase(),status:s.status,statusText:s.statusText,requestBody:a,responseBody:z(s.responseText),timestamp:Date.now()})}),o.apply(this,[n])},{errors:i,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=e,XMLHttpRequest.prototype.send=o}}}function oi(){const i=navigator.userAgent||"";return/iP(hone|ad|od)/.test(i)||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1}function ni(i,t,e,o,n){const s=i>=t,a=e>=o;return s===a?{width:i,height:t,rotate:0}:{width:t,height:i,rotate:n===270?-90:90}}function si(i,t,e){if(e.rotate===0){i.drawImage(t,0,0,e.width,e.height);return}i.save(),e.rotate===90?(i.translate(e.width,0),i.rotate(Math.PI/2)):(i.translate(0,e.height),i.rotate(-Math.PI/2)),i.drawImage(t,0,0,e.height,e.width),i.restore()}function ai(){const i=typeof screen<"u"?screen.orientation:void 0;return i&&typeof i.angle=="number"?i.angle:0}function wt(i){return new Promise(t=>{if(i.videoWidth>0){t();return}i.addEventListener("loadedmetadata",()=>t(),{once:!0})})}async function kt(i){try{await i.play()}catch{}}async function ri(i,t=15){const e=document.createElement("canvas");if(typeof e.captureStream!="function")return null;const o=e.getContext("2d");if(!o)return null;const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=i,await wt(n);const s=ni(n.videoWidth,n.videoHeight,window.innerWidth,window.innerHeight,ai());e.width=s.width,e.height=s.height,await kt(n);let a=0;const c=()=>{si(o,n,s),a=requestAnimationFrame(c)};c();const l=e.captureStream(t);return{stream:l,stop:()=>{a&&cancelAnimationFrame(a),a=0,l.getTracks().forEach(d=>d.stop()),n.pause(),n.srcObject=null}}}function di(i,t,e,o,n){const s=Math.max(0,Math.min(o,i.left*t)),a=Math.max(0,Math.min(n,i.top*e)),c=Math.max(0,Math.min(o,(i.left+i.width)*t)),l=Math.max(0,Math.min(n,(i.top+i.height)*e)),d=c-s,r=l-a;return d<=0||r<=0?null:{x:s,y:a,w:d,h:r}}function ci(i,t,e,o,n,s,a){i.drawImage(t,0,0,o,n);const c=o/Math.max(1,window.innerWidth),l=n/Math.max(1,window.innerHeight);for(const d of e){const r=di(d.getBoundingClientRect(),c,l,o,n);r&&(i.save(),a?(i.filter=`blur(${s}px)`,i.drawImage(t,r.x,r.y,r.w,r.h,r.x,r.y,r.w,r.h)):(i.fillStyle="#0b0b0b",i.fillRect(r.x,r.y,r.w,r.h)),i.restore())}}async function li(i,t,e={}){const o=e.frameRate??15,n=e.blurRadius??12,s=document.createElement("canvas");if(typeof s.captureStream!="function")return null;const a=s.getContext("2d");if(!a)return null;const c="filter"in a,l=document.createElement("video");l.muted=!0,l.playsInline=!0,l.srcObject=i,await wt(l),s.width=l.videoWidth,s.height=l.videoHeight,await kt(l);let d=0;const r=()=>{ci(a,l,t,s.width,s.height,n,c),d=requestAnimationFrame(r)};r();const h=s.captureStream(o);return{stream:h,stop:()=>{d&&cancelAnimationFrame(d),d=0,h.getTracks().forEach(p=>p.stop()),l.pause(),l.srcObject=null}}}const qt="This browser cannot blur the areas you picked, so the recording was not started.";function xt(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function U(){if(typeof MediaRecorder>"u")return"";const i=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of i)if(MediaRecorder.isTypeSupported(t))return t;return""}function Ct(i={}){const t=i.maxDuration??15,e=i.videoBitsPerSecond??8e5,o=i.redactionElements??[],n=i.redactionBlurRadius;let s=null,a=null,c=null,l=null,d=[],r=null,h=null,p=null,b=0,w=null,v=null,k=!1,C=null;function f(){p!==null&&(clearInterval(p),p=null),C!==null&&(clearTimeout(C),C=null),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&(s.getTracks().forEach(y=>y.stop()),s=null),l=null,d=[],r=null,h=null,w=null,v=null}function q(){k||(k=!0,l&&l.state!=="inactive"&&l.stop())}return{async start(){k=!1,d=[];const y=U();if(!y)throw new Error("No supported video MIME type found");s=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15,displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",monitorTypeSurfaces:"exclude",surfaceSwitching:"exclude"});const S=s.getVideoTracks()[0],B=S?.getSettings?.()?.displaySurface;if(B==="monitor"||B==="window")throw s.getTracks().forEach(m=>m.stop()),s=null,new Error("qaid records only the current tab — please share this tab, not a window or your whole screen.");S&&S.addEventListener("ended",()=>{q()});let E=s;if(oi()){const m=await ri(s);m&&(a=m,E=m.stream)}if(o.length>0){const m=await li(E,o,{blurRadius:n});if(!m)throw a&&(a.stop(),a=null),s.getTracks().forEach(L=>L.stop()),s=null,new Error(qt);c=m,E=m.stream}l=new MediaRecorder(E,{mimeType:y,videoBitsPerSecond:e}),l.ondataavailable=m=>{m.data.size>0&&d.push(m.data)},l.onstop=()=>{const m=new Blob(d,{type:y});w&&w(m),h&&h(m),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&s.getTracks().forEach(L=>L.stop())},l.onerror=()=>{v&&v(new Error("MediaRecorder error"))},l.start(1e3),b=Date.now(),p=setInterval(()=>{const m=Math.floor((Date.now()-b)/1e3);r&&r(m)},1e3),C=setTimeout(()=>{q()},t*1e3)},stop(){return new Promise((y,S)=>{w=y,v=S,q()})},onTick(y){r=y},onStop(y){h=y},destroy(){q(),f()}}}const St=Object.freeze(Object.defineProperty({__proto__:null,REDACTION_UNAVAILABLE:qt,createVideoRecorder:Ct,getSupportedMimeType:U,isVideoRecordingSupported:xt},Symbol.toStringTag,{value:"Module"})),Tt="https://qaid.dev/lib/html2canvas.min.js",hi=1e4,ui=50;let M=null;function Et(){if(typeof document>"u"||typeof window>"u")return!1;const i=document.createElement("canvas");return typeof i.getContext=="function"&&!!i.getContext("2d")}function fi(){return window.html2canvas?Promise.resolve(!0):M||(M=new Promise(i=>{if(!document.querySelector(`script[src="${Tt}"]`)){const n=document.createElement("script");n.src=Tt,n.async=!0,document.head.appendChild(n)}const e=Date.now(),o=()=>{if(window.html2canvas){i(!0);return}if(Date.now()-e>hi){M=null,i(!1);return}setTimeout(o,ui)};o()}),M)}async function At(i={}){const{quality:t=.8,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!await fi()||!window.html2canvas)return console.warn("html2canvas failed to load"),null;const s=await window.html2canvas(document.body,{useCORS:!0,allowTaint:!1,logging:!1,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,x:window.scrollX,y:window.scrollY,ignoreElements:d=>d instanceof HTMLElement?d.classList.contains("qaid-buttons")||d.classList.contains("qaid-targeting-overlay")||d.classList.contains("qaid-modal-container")||d.classList.contains("qaid-bottom-sheet")||d.classList.contains("qaid-backdrop")||d.classList.contains("qaid-selected-marker")||d.classList.contains("qaid-tooltip-text")||d.classList.contains("qaid-recording-indicator")||d.classList.contains("qaid-video-preview")||d.className?.toString().startsWith?.("qaid-"):!1}),a=s.width,c=s.height,l=Math.min(e/a,o/c,1);if(l<1){const d=Math.round(a*l),r=Math.round(c*l),h=document.createElement("canvas");h.width=d,h.height=r;const p=h.getContext("2d");return p?(p.drawImage(s,0,0,d,r),h.toDataURL("image/webp",t)):null}return s.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const Lt=Object.freeze(Object.defineProperty({__proto__:null,captureDomScreenshot:At,isDomScreenshotSupported:Et},Symbol.toStringTag,{value:"Module"})),pi=".qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:var(--qaid-font-size, 16px);font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:calc(var(--qaid-font-size, 16px) * .8125);line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:calc(var(--qaid-font-size, 16px) * .8125);font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}.qaid-annotate-colors{display:flex;gap:.25rem;align-items:center}button.qaid-annotate-swatch{width:28px;height:28px;min-width:28px;padding:0;border-radius:9999px;border:2px solid light-dark(#d1d5db,#4b5563);background:var(--qaid-swatch, #000);cursor:pointer;-webkit-appearance:none;appearance:none;transition:transform .1s,box-shadow .15s,border-color .15s}button.qaid-annotate-swatch:hover{transform:scale(1.12)}button.qaid-annotate-swatch[aria-pressed=true]{border-color:light-dark(#111827,#f9fafb);box-shadow:0 0 0 2px var(--qaid-swatch)}@media(forced-colors:active){button.qaid-annotate-swatch[aria-pressed=true]{outline:2px solid Highlight;outline-offset:1px}}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6365f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6365f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6365f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}",A=12,mi="#ef4444",bi=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"],gi={"#ef4444":"red","#f59e0b":"amber","#22c55e":"green","#3b82f6":"blue","#111827":"black","#ffffff":"white","#6365f1":"indigo","#6366f1":"indigo"};function It(i){return gi[i.toLowerCase()]??i}const vi=4,yi=.8,wi={title:"Annotate screenshot",instructions:"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",rectangle:"Rectangle",arrow:"Arrow",pen:"Pen",blur:"Blur or redact",undo:"Undo last",skip:"Skip annotation",done:"Done",colors:"Drawing colour"};function R(i,t){return{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y),w:Math.abs(i.x-t.x),h:Math.abs(i.y-t.y)}}function ki(i){if(i.type==="pen")return i.points.length<2;const t=R(i.points[0],i.points[1]);return t.w<3&&t.h<3}function qi(i,t,e,o){i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke();const n=Math.atan2(e.y-t.y,e.x-t.x),s=Math.max(10,o*3);i.beginPath(),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n-Math.PI/6),e.y-s*Math.sin(n-Math.PI/6)),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n+Math.PI/6),e.y-s*Math.sin(n+Math.PI/6)),i.stroke()}function xi(i,t){if(t.length!==0){i.beginPath(),i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)i.lineTo(t[e].x,t[e].y);i.stroke()}}function Ci(i,t,e,o,n){i.fillStyle="rgb(15, 23, 42)",i.fillRect(t,e,o,n),i.fillStyle="rgb(37, 47, 63)";for(let s=e;s<e+n;s+=A)for(let a=t;a<t+o;a+=A)(Math.floor((a-t)/A)+Math.floor((s-e)/A))%2===0&&i.fillRect(a,s,Math.min(A,t+o-a),Math.min(A,e+n-s))}function P(i,t){switch(i.save(),i.strokeStyle=t.color,i.fillStyle=t.color,i.lineWidth=t.strokeWidth,i.lineJoin="round",i.lineCap="round",t.type){case"rect":{const e=R(t.points[0],t.points[1]);i.strokeRect(e.x,e.y,e.w,e.h);break}case"arrow":qi(i,t.points[0],t.points[1],t.strokeWidth);break;case"pen":xi(i,t.points);break;case"blur":{const e=R(t.points[0],t.points[1]);Ci(i,e.x,e.y,e.w,e.h);break}}i.restore()}function Dt(i){return new Promise((t,e)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>e(new Error("Failed to load screenshot")),o.src=i})}async function j(i,t,e={}){const o=e.quality??yi;let n;try{n=await Dt(i)}catch{return i}const s=document.createElement("canvas");s.width=n.naturalWidth||n.width||1,s.height=n.naturalHeight||n.height||1;const a=s.getContext("2d");if(!a)return i;a.drawImage(n,0,0,s.width,s.height);for(const c of t)P(a,c);return s.toDataURL("image/webp",o)}let Si=0;class K{shapes=[];tool="rect";opts;labels;color;palette;strokeWidth;uid=`qaid-annotate-${++Si}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...wi,...t.labels??{}},this.color=t.color??mi,this.palette=(t.palette&&t.palette.length?t.palette:bi).slice(),this.palette.some(e=>e.toLowerCase()===this.color.toLowerCase())||this.palette.unshift(this.color),this.strokeWidth=t.strokeWidth??vi}open(){const t=new Promise(e=>{this.resolveResult=e});return this.mount(),t}toolButton(t,e,o){const n=x("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${o} tool`,title:o});return n.innerHTML=`${e}<span class="qaid-annotate-btn-text">${o}</span>`,n}swatchButton(t){const e=It(t),o=x("button",{type:"button",class:"qaid-annotate-swatch","data-qaid-color":t,"aria-pressed":t.toLowerCase()===this.color.toLowerCase()?"true":"false","aria-label":`Draw in ${e}`,title:e});return o.style.setProperty("--qaid-swatch",t),o}actionButton(t,e,o,n){const s=x("button",{type:"button",class:`qaid-annotate-action ${n}`,"data-qaid-action":t,"aria-label":o,title:o});return s.innerHTML=`${e}<span class="qaid-annotate-btn-text">${o}</span>`,s}mount(){const t=`${this.uid}-title`,e=`${this.uid}-desc`;this.container=x("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const o=x("h2",{id:t,class:"qaid-annotate-title"});o.textContent=this.labels.title;const n=x("p",{id:e,class:"qaid-annotate-desc"});n.textContent=this.labels.instructions;const s=x("div",{class:"qaid-annotate-stage"});this.canvas=document.createElement("canvas"),this.canvas.className="qaid-annotate-canvas",this.canvas.width=1,this.canvas.height=1,this.canvas.setAttribute("role","img"),this.canvas.setAttribute("aria-label",this.labels.title),this.ctx=this.canvas.getContext("2d"),s.appendChild(this.canvas),this.toolbar=x("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const a=x("div",{class:"qaid-annotate-tools"});a.appendChild(this.toolButton("rect",ee,this.labels.rectangle)),a.appendChild(this.toolButton("arrow",ie,this.labels.arrow)),a.appendChild(this.toolButton("pen",oe,this.labels.pen)),a.appendChild(this.toolButton("blur",ne,this.labels.blur));const c=x("div",{class:"qaid-annotate-colors",role:"group","aria-label":this.labels.colors});for(const h of this.palette)c.appendChild(this.swatchButton(h));this.undoBtn=this.actionButton("undo",se,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const l=this.actionButton("skip",re,this.labels.skip,"qaid-annotate-skip"),d=this.actionButton("done",Z,this.labels.done,"qaid-annotate-done"),r=x("div",{class:"qaid-annotate-actions"});r.appendChild(this.undoBtn),r.appendChild(l),r.appendChild(d),this.toolbar.appendChild(a),this.toolbar.appendChild(c),this.toolbar.appendChild(r),this.container.appendChild(o),this.container.appendChild(n),this.container.appendChild(s),this.container.appendChild(this.toolbar),this.opts.root.appendChild(this.container),this.toolbar.addEventListener("click",this.onToolbarClick),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp),this.container.addEventListener("keydown",this.onKeyDown),this.opts.openDialog?.(this.container,{labelledbyId:t,describedbyId:e}),this.opts.announce?.(this.labels.instructions),Dt(this.opts.dataUrl).then(h=>{this.img=h,this.canvas.width=h.naturalWidth||h.width||1,this.canvas.height=h.naturalHeight||h.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const e=this.canvas.getBoundingClientRect(),o=this.canvas.width/(e.width||this.canvas.width),n=this.canvas.height/(e.height||this.canvas.height);return{x:(t.clientX-e.left)*o,y:(t.clientY-e.top)*n}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const e of this.shapes)P(t,e);this.current&&P(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(n=>{n.setAttribute("aria-pressed",n.getAttribute("data-qaid-tool")===t?"true":"false")});const o=this.labels[Ti[t]];this.opts.announce?.(`${o} tool selected`)}selectColor(t){this.color=t,this.toolbar.querySelectorAll("[data-qaid-color]").forEach(o=>{o.setAttribute("aria-pressed",(o.getAttribute("data-qaid-color")??"").toLowerCase()===t.toLowerCase()?"true":"false")}),this.opts.announce?.(`${It(t)} colour selected`)}onToolbarClick=t=>{const o=t.target?.closest("[data-qaid-tool],[data-qaid-action],[data-qaid-color]");if(!o)return;const n=o.getAttribute("data-qaid-color");if(n){this.selectColor(n);return}const s=o.getAttribute("data-qaid-tool");if(s){this.selectTool(s);return}const a=o.getAttribute("data-qaid-action");a==="undo"?this.undo():a==="skip"?this.skip():a==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const e=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[e]:[e,{...e}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const e=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(e):this.current.points[1]=e,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,ki(t)){this.redraw();return}this.shapes.push(t),this.undoBtn.disabled=!1,this.opts.announce?.("Annotation added"),this.redraw()};onKeyDown=t=>{if(t.key==="Escape"){t.preventDefault(),this.skip();return}if(t.key==="Enter"){const e=t.target;if(e?.getAttribute("data-qaid-tool")||e?.getAttribute("data-qaid-action"))return;t.preventDefault(),this.done()}};undo(){if(this.shapes.length===0){this.opts.announce?.("Nothing to undo");return}this.shapes.pop(),this.undoBtn.disabled=this.shapes.length===0,this.opts.announce?.("Removed last annotation"),this.redraw()}async done(){if(this.settled)return;const t=await j(this.opts.dataUrl,this.shapes,{quality:this.opts.quality});this.opts.announce?.("Annotated screenshot attached"),this.settle(t)}skip(){this.settled||(this.opts.announce?.("Annotation skipped"),this.settle(null))}settle(t){this.settled=!0,this.teardown(),this.resolveResult(t)}teardown(){this.toolbar.removeEventListener("click",this.onToolbarClick),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.container.removeEventListener("pointermove",this.onPointerMove),this.container.removeEventListener("pointerup",this.onPointerUp),this.container.removeEventListener("keydown",this.onKeyDown),this.opts.closeDialog?.(),this.container.remove()}}const Ti={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function Mt(i){return new K(i).open()}const Rt=Object.freeze(Object.defineProperty({__proto__:null,AnnotationEditor:K,compositeAnnotations:j,drawShape:P,openAnnotationEditor:Mt,rectFromPoints:R,styles:pi},Symbol.toStringTag,{value:"Module"}));ti();const Ei=document;function u(i,t,...e){const o=Ei.createElement(i);if(t){if(t.class&&(o.className=t.class),t.style&&(o.style.cssText=t.style),t.html!=null&&(o.innerHTML=t.html),t.text!=null&&(o.textContent=t.text),t.attrs)for(const n in t.attrs)o.setAttribute(n,t.attrs[n]);if(t.on)for(const n in t.on)o.addEventListener(n,t.on[n])}for(const n of e)n!=null&&n!==!1&&o.append(n);return o}const Ai=".qaid-recording-indicator{position:fixed;pointer-events:auto;top:12px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:light-dark(#1f2937,#374151);color:#fff;border-radius:9999px;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;box-shadow:0 4px 12px #0000004d;z-index:99999;animation:qaid-slideDown .2s ease-out}.qaid-recording-dot{width:10px;height:10px;background:#dc2626;border-radius:50%;animation:qaid-dotPulse 1.5s ease-in-out infinite}@keyframes qaid-dotPulse{0%,to{opacity:1}50%{opacity:.3}}.qaid-recording-time{font-variant-numeric:tabular-nums;min-width:2.5rem;text-align:center}button.qaid-recording-stop{padding:.25rem .75rem;background:#dc2626;color:#fff;border:none;border-radius:9999px;font-size:calc(var(--qaid-font-size, 16px) * .75);font-weight:600;cursor:pointer;transition:background-color .2s;-webkit-appearance:none;appearance:none}button.qaid-recording-stop:hover{background:#b91c1c}.qaid-video-preview{position:fixed;inset:0 0 auto;height:100vh;height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#0009;z-index:99998;animation:qaid-fadeIn .2s ease-out}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}.qaid-video-preview-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px #00000080;width:560px;max-width:100%;max-height:100%;overflow-y:auto;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-video-preview-box h3{font-size:calc(var(--qaid-font-size, 16px) * 1.125);font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;max-height:50vh;max-height:50dvh;object-fit:contain;border-radius:.5rem;background:#000;margin-bottom:1rem}.qaid-video-preview-box textarea{width:100%;height:4rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:calc(var(--qaid-font-size, 16px) * .875);resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-video-error{margin:0 0 .75rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;color:light-dark(#b91c1c,#fca5a5)}.qaid-video-preview-actions{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-video-btn{padding:.5rem 1rem;border:none;border-radius:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-video-btn-cancel{background:light-dark(#f3f4f6,#374151);color:light-dark(#374151,#d1d5db)}button.qaid-video-btn-cancel:hover{background:light-dark(#e5e7eb,#4b5563)}button.qaid-video-btn-rerecord{background:light-dark(#fef3c7,#78350f);color:light-dark(#92400e,#fde68a)}button.qaid-video-btn-rerecord:hover{filter:brightness(.9)}button.qaid-video-btn-send{background:var(--qaid-marker);color:var(--qaid-marker-text, white)}button.qaid-video-btn-send:hover{filter:brightness(.85)}button.qaid-video-btn-send:disabled{opacity:.5;cursor:not-allowed}.qaid-video-sending{display:flex;align-items:center;gap:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);color:light-dark(#6b7280,#9ca3af)}@keyframes qaid-slideDown{0%{transform:translateY(-100%)}to{transform:translateY(0)}}button.qaid-recording-stop{min-height:24px}.qaid-video-preview-box textarea:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}@media(forced-colors:active){.qaid-video-preview-box textarea:focus{outline:2px solid CanvasText;outline-offset:2px}}";class Li{constructor(t){this.host=t}host;videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;redactPicks=[];redactPickerRoot=null;redactRafId=0;boundRedactClick=t=>this.handleRedactPickClick(t);handleEscape(){return this.isRecording?(this.stopRecording(),!0):this.videoPreview?(this.cancelRecordingPreview(),!0):this.redactPickerRoot?(this.finishRedactionPicking(!1),!0):!1}destroy(){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null),this.redactPicks=[],this.cleanupRecording(),this.removeVideoPreview()}async startRecording(t=[]){if(!(this.isRecording||this.host.state!=="IDLE"))try{this.networkCapture=yt();const{createVideoRecorder:e}=await Promise.resolve().then(()=>St);this.videoRecorder=e({maxDuration:this.host.config.videoOptions.maxDuration,redactionElements:t}),this.videoRecorder.onTick(o=>{this.updateRecordingTimer(o)}),this.videoRecorder.onStop(o=>{this.isRecording&&(this.recordedBlob=o,this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.host.setButtonsDisabled(!1),o&&o.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.host.announceMsg("Recording started"),this.host.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.host.boundKeyDown)}catch(e){e instanceof Error&&/current tab|cannot blur/i.test(e.message)&&this.host.announceMsg(e.message),this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}startPicking(){if(this.isRecording||this.host.state!=="IDLE")return;this.host.setState("REDACT_PICKING"),this.redactPicks=[];const t=this.host.ensureOverlayHost(),e=u("div",{style:"position:absolute;inset:0;"}),o=u("div",{class:"qaid-redact-picker",style:"position:fixed;inset:0;pointer-events:none;"},e,u("div",{style:"position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;gap:12px;align-items:center;pointer-events:auto;background:#0b1220;color:#fff;border:1px solid #ff6b6b;border-radius:9999px;padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 8px 30px rgba(0,0,0,.5);"},u("span",{text:"Click sensitive areas to blur",attrs:{"data-qaid-redact-label":""}}),u("button",{text:"Start recording",attrs:{type:"button"},style:"cursor:pointer;border:0;border-radius:9999px;padding:8px 14px;background:#ff6b6b;color:#0b1220;font:inherit;",on:{click:()=>this.finishRedactionPicking(!0)}}),u("button",{text:"Cancel",attrs:{type:"button"},style:"cursor:pointer;border:0;background:transparent;color:#9fb3c8;font:inherit;",on:{click:()=>this.finishRedactionPicking(!1)}})));t.appendChild(o),this.redactPickerRoot=o;const n=()=>{this.renderRedactPicks(e),this.redactRafId=requestAnimationFrame(n)};n(),document.addEventListener("click",this.boundRedactClick,!0),document.addEventListener("keydown",this.host.boundKeyDown),this.host.announceMsg("Click sensitive areas to blur, then start recording")}handleRedactPickClick(t){const e=t.target instanceof Element?t.target:null;if(!e||H(e)||this.redactPickerRoot?.contains(e))return;t.preventDefault(),t.stopPropagation();const o=this.redactPicks.indexOf(e);o>=0?this.redactPicks.splice(o,1):this.redactPicks.push(e);const n=this.redactPickerRoot?.querySelector("[data-qaid-redact-label]");if(n){const s=this.redactPicks.length;n.textContent=s===0?"Click sensitive areas to blur":`${s} area${s===1?"":"s"} will be blurred`}}renderRedactPicks(t){t.textContent="";for(const e of this.redactPicks){const o=e.getBoundingClientRect();o.width<=0||o.height<=0||t.appendChild(u("div",{style:`position:fixed;left:${o.left}px;top:${o.top}px;width:${o.width}px;height:${o.height}px;border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;`}))}}finishRedactionPicking(t){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),document.removeEventListener("keydown",this.host.boundKeyDown),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null);const e=this.redactPicks;this.redactPicks=[],this.host.setState("IDLE"),t&&this.startRecording(e)}showRecordingIndicator(){const t=this.host.ensureOverlayHost();this.recordingIndicator=u("div",{class:"qaid-recording-indicator",style:`z-index:${this.host.config.zIndex+100}`},u("div",{class:"qaid-recording-dot"}),u("span",{class:"qaid-recording-time",text:this.formatTime(this.host.config.videoOptions.maxDuration)}),u("button",{class:"qaid-recording-stop",text:"Stop",attrs:{type:"button"},on:{click:()=>this.stopRecording()}})),this.host.applyVars(this.recordingIndicator),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const e=this.recordingIndicator.querySelector(".qaid-recording-time");if(e){const o=Math.max(0,this.host.config.videoOptions.maxDuration-t);e.textContent=this.formatTime(o),o>0&&o<=5&&this.host.announceMsg(`${o} second${o===1?"":"s"} remaining`)}}formatTime(t){const e=Math.floor(t/60),o=t%60;return`${e}:${o.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.host.ensureOverlayHost(),e=URL.createObjectURL(this.recordedBlob),o=`qaid-video-title-${this.host.uid}`,n=u("h3",{text:"Review your recording",attrs:{id:o}}),s=u("video");s.src=e,s.controls=!0,s.autoplay=!0,s.muted=!0;const a=u("textarea",{attrs:{placeholder:"Optional: Describe the issue you recorded...","aria-label":"Describe the issue you recorded"}}),c=u("button",{class:"qaid-video-btn qaid-video-btn-send",text:"Send",attrs:{type:"button"},on:{click:()=>this.submitVideoFeedback(a.value.trim()||null,c)}}),l=u("div",{class:"qaid-video-preview-box"},n,s,a,u("div",{class:"qaid-video-preview-actions"},u("button",{class:"qaid-video-btn qaid-video-btn-cancel",text:"Cancel",attrs:{type:"button"},on:{click:()=>this.cancelRecordingPreview()}}),u("button",{class:"qaid-video-btn qaid-video-btn-rerecord",text:"Re-record",attrs:{type:"button"},on:{click:()=>{this.cancelRecordingPreview(),this.startRecording()}}}),c));this.videoPreview=u("div",{class:"qaid-video-preview",style:`z-index:${this.host.config.zIndex+100}`},l),this.host.applyVars(this.videoPreview),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.host.openDialogA11y(l,{labelledbyId:n.id}),document.addEventListener("keydown",this.host.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.host.closeDialogA11y(),this.videoPreview){const t=this.videoPreview.querySelector("video");t?.src&&URL.revokeObjectURL(t.src),this.videoPreview.remove(),this.videoPreview=null}document.removeEventListener("keydown",this.host.boundKeyDown)}async submitVideoFeedback(t,e){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,e.disabled=!0,e.textContent="Sending...";const o=new FormData;o.append("video",this.recordedBlob,`recording.${this.recordedBlob.type.includes("mp4")?"mp4":"webm"}`),o.append("pageUrl",window.location.href),o.append("visitorId",this.host.visitorId),this.host.config.apiKey&&o.append("apiKey",this.host.config.apiKey),t&&o.append("message",t),this.host.consoleCapture&&o.append("consoleErrors",JSON.stringify(this.host.consoleCapture.errors)),this.networkCapture&&o.append("networkErrors",JSON.stringify(this.networkCapture.errors));let n=null,s=null;try{const a=await fetch(`${this.host.config.endpoint}/video`,{method:"POST",body:o});if(a.ok){this.host.announceMsg("Recording sent");try{n=(await a.json())?.id??null}catch{}}else console.error("Failed to submit video feedback:",await a.text()),s=a.status===413?"This recording is too large to send. Try a shorter one.":"Your recording could not be sent."}catch(a){console.error("Failed to submit video feedback:",a),s="Your recording could not be sent. Check your connection and try again."}if(this.isSendingVideo=!1,s){this.showSendError(s,e);return}this.removeVideoPreview(),this.cleanupRecording(),await this.host.tryLaunchQuest("video",n)}showSendError(t,e){this.host.announceMsg(`Failed to send recording. ${t}`,!0),e.disabled=!1,e.textContent="Send";const o=this.videoPreview?.querySelector(".qaid-video-preview-actions");if(o){let n=this.videoPreview.querySelector(".qaid-video-error");n||(n=u("p",{class:"qaid-video-error"}),o.before(n)),n.textContent=t}}cleanupRecording(){this.isRecording=!1,this.removeRecordingIndicator(),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.networkCapture&&(this.networkCapture.restore(),this.networkCapture=null),this.recordedBlob&&(this.recordedBlob=null),this.host.setButtonsDisabled(!1),this.host.overlayShadowHost&&this.host.state==="IDLE"&&(this.host.overlayShadowHost.style.pointerEvents="none")}}const Pt=Object.freeze(Object.defineProperty({__proto__:null,RecordingController:Li,styles:Ai},Symbol.toStringTag,{value:"Module"}));async function Ii(i={}){const{quality:t=.8,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!navigator.mediaDevices?.getDisplayMedia)return console.warn("Screen Capture API not available"),null;const n=await navigator.mediaDevices.getDisplayMedia({preferCurrentTab:!0,video:{displaySurface:"browser"}}),s=n.getVideoTracks()[0],a=s.getSettings(),c=document.createElement("video");c.srcObject=n,c.muted=!0,await new Promise(v=>{c.onloadedmetadata=()=>{c.play(),v()}}),await new Promise(v=>{const k=()=>{c.readyState>=2?v():requestAnimationFrame(k)};k()}),await new Promise(v=>setTimeout(v,100));const l=a.width||c.videoWidth,d=a.height||c.videoHeight,r=Math.min(e/l,o/d,1),h=Math.round(l*r),p=Math.round(d*r),b=document.createElement("canvas");b.width=h,b.height=p;const w=b.getContext("2d");return w?(w.drawImage(c,0,0,h,p),s.stop(),b.toDataURL("image/webp",t)):(s.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const Bt=Object.freeze(Object.defineProperty({__proto__:null,captureScreenshot:Ii},Symbol.toStringTag,{value:"Module"})),Di=".qaid-backdrop{position:fixed;inset:0;z-index:45;background:#0000004d}.qaid-modal-container{position:fixed;z-index:50;display:flex;flex-direction:column;align-items:flex-start;max-height:calc(100vh - 32px);font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-modal-container.qaid-above{flex-direction:column-reverse}.qaid-modal-arrow{width:0;height:0;border-left:12px solid transparent;border-right:12px solid transparent;position:relative;align-self:flex-start}.qaid-modal-container.qaid-below .qaid-modal-arrow{border-bottom:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-container.qaid-above .qaid-modal-arrow{border-top:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5));width:var(--qaid-modal-width, 400px);max-width:calc(100vw - 32px);max-height:calc(100vh - 60px);overflow-y:auto}.qaid-modal-header{display:flex;align-items:flex-start;gap:.75rem;margin-bottom:1rem}button.qaid-type-toggle{border:none;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s;flex-shrink:0;-webkit-appearance:none;appearance:none}button.qaid-type-toggle:hover{transform:scale(1.1)}button.qaid-type-toggle:not(.qaid-type-toggle-custom){width:2.5rem;height:2.5rem;border-radius:50%}button.qaid-type-toggle:not(.qaid-type-toggle-custom) svg{width:1.25rem;height:1.25rem}button.qaid-type-toggle.qaid-type-up{background:var(--qaid-positive);color:#fff}button.qaid-type-toggle.qaid-type-down{background:var(--qaid-negative);color:#fff}.qaid-type-static{width:2.5rem;height:2.5rem;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:var(--qaid-marker, #6365f1);color:var(--qaid-marker-text, white)}.qaid-type-static svg{width:1.25rem;height:1.25rem}.qaid-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size:calc(var(--qaid-font-size, 16px) * 1.125);font-weight:700;margin:0 0 .25rem;color:light-dark(#1f2937,#f9fafb)}.qaid-modal-subtitle{color:light-dark(#6b7280,#9ca3af);margin:0;font-size:calc(var(--qaid-font-size, 16px) * .875)}.qaid-textarea{width:100%;height:6rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:var(--qaid-font-size, 16px);resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-btn-row{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-btn-submit{padding:.5rem 1rem;background:var(--qaid-marker);color:var(--qaid-marker-text, white);border:none;border-radius:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-btn-submit:hover{filter:brightness(.85)}button.qaid-btn-submit:focus{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 30%,transparent)}.qaid-bottom-sheet{position:fixed;bottom:0;left:0;right:0;z-index:50;animation:qaid-slideUpSheet .3s ease-out;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-bottom-sheet-content{background:light-dark(#ffffff,#1f2937);border-radius:1rem 1rem 0 0;padding:1.5rem;padding-bottom:max(1.5rem,env(safe-area-inset-bottom))}.qaid-bottom-sheet-handle{width:36px;height:4px;background:light-dark(rgba(0,0,0,.2),rgba(255,255,255,.2));border-radius:2px;margin:0 auto 1rem}@keyframes qaid-slideUpSheet{0%{transform:translateY(100%)}to{transform:translateY(0)}}.qaid-confirm{display:flex;flex-direction:column;align-items:center;text-align:center;gap:.5rem;padding:.5rem 0}.qaid-confirm-icon{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:9999px;color:#fff;background:var(--qaid-success, #22c55e);margin-bottom:.25rem;animation:qaid-confirm-pop .28s cubic-bezier(.34,1.56,.64,1)}.qaid-confirm-icon .qaid-icon{width:24px;height:24px}.qaid-confirm-error .qaid-confirm-icon{background:var(--qaid-error, #dc2626)}.qaid-confirm-title{margin:0;font-size:var(--qaid-font-size, 16px);font-weight:600;color:var(--qaid-text, light-dark(#111827, #f9fafb))}.qaid-confirm-title:focus-visible{outline:2px solid var(--qaid-primary, #6365f1);outline-offset:3px;border-radius:4px}.qaid-confirm-message{margin:0;font-size:calc(var(--qaid-font-size, 16px) * .875);color:var(--qaid-text-muted, light-dark(#6b7280, #9ca3af))}.qaid-confirm .qaid-confirm-close{margin-top:.5rem;min-width:96px}@keyframes qaid-confirm-pop{0%{transform:scale(.6);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.qaid-confirm-icon{animation:none}}.qaid-textarea:focus-visible,button.qaid-btn-submit:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}@media(forced-colors:active){.qaid-textarea:focus,button.qaid-btn-submit:focus{outline:2px solid CanvasText;outline-offset:2px}}";class Mi{constructor(t){this.host=t}host;modalContainer=null;backdrop=null;finalized=!1;open(){this.finalized=!1;const t=this.host.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.host.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.host.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.close()),this.host.applyVars(this.backdrop),this.host.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.host.boundKeyDown)}close(){this.host.state==="MODAL_OPEN"&&!this.finalized&&(this.finalized=!0,this.host.whenFeedbackId().then(t=>{t&&fetch(`${this.host.config.endpoint}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(e=>console.error("Failed to finalize feedback:",e))})),this.teardown(),this.host.resetFeedbackUi()}destroy(){this.teardown()}teardown(){this.host.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.host.boundKeyDown)}showBottomSheet(){const t=this.host.ensureOverlayHost(),e=document.createElement("div");e.className="qaid-bottom-sheet",e.style.zIndex=String(this.host.config.zIndex+3),e.appendChild(u("div",{class:"qaid-bottom-sheet-content"},u("div",{class:"qaid-bottom-sheet-handle"}),this.buildModalContent())),this.host.applyVars(e),t.appendChild(e),this.modalContainer=e,this.setupModalInteractions()}showPositionedModal(){const t=this.host.ensureOverlayHost(),{modal:e,arrow:o}=ze(this.host.selectedBounds,window.innerWidth,window.innerHeight,{width:this.host.config.modalWidth,height:280,arrowHeight:12,gap:8,viewportPadding:16});this.modalContainer=document.createElement("div"),this.modalContainer.className=`qaid-modal-container qaid-${e.position}`,this.modalContainer.style.top=`${e.top}px`,this.modalContainer.style.left=`${e.left}px`,this.modalContainer.style.zIndex=String(this.host.config.zIndex+3);const n=document.createElement("div");n.className="qaid-modal-arrow",n.style.left=`${o.left}px`;const s=document.createElement("div");s.className="qaid-modal-box",s.appendChild(this.buildModalContent()),this.modalContainer.appendChild(n),this.modalContainer.appendChild(s),this.host.applyVars(this.modalContainer),t.appendChild(this.modalContainer),this.setupModalInteractions()}buildModalContent(){const{config:t,uid:e}=this.host,o=t.text,n=this.host.feedbackData.feedbackType,s=n==="up",a=t.positiveIcon||T,c=t.negativeIcon||$,l=t.buttonClass?`qaid-type-toggle qaid-type-toggle-custom ${t.buttonClass} ${s?"qaid-btn-up":"qaid-btn-down"}`:`qaid-type-toggle ${s?"qaid-type-up":"qaid-type-down"}`,d=s?"Feedback type: positive":"Feedback type: negative",r=n==="neutral"?u("span",{class:"qaid-type-static",html:t.feedbackIcon||G,attrs:{"aria-hidden":"true"}}):u("button",{class:l,html:s?a:c,attrs:{type:"button",title:"Click to switch","aria-pressed":String(s),"aria-label":d}}),h=document.createDocumentFragment();return h.append(u("div",{class:"qaid-modal-header"},r,u("div",{class:"qaid-modal-header-text"},u("h3",{class:"qaid-modal-title",text:o.modalTitle,attrs:{id:`qaid-modal-title-${e}`}}),u("p",{class:"qaid-modal-subtitle",text:o.modalSubtitle,attrs:{id:`qaid-modal-subtitle-${e}`}}))),u("textarea",{class:"qaid-textarea",attrs:{"aria-label":o.modalSubtitle,placeholder:o.placeholder}}),u("div",{class:"qaid-btn-row"},u("button",{class:"qaid-btn-submit",text:o.skipButton,attrs:{type:"button"}}))),h}setupModalInteractions(){this.host.openDialogA11y(this.modalContainer,{labelledbyId:`qaid-modal-title-${this.host.uid}`,describedbyId:`qaid-modal-subtitle-${this.host.uid}`});const t=this.modalContainer.querySelector(".qaid-textarea"),e=this.modalContainer.querySelector(".qaid-btn-submit");t&&(setTimeout(()=>t.focus(),100),t.addEventListener("input",()=>{e&&(e.textContent=t.value.trim()?this.host.config.text.submitButton:this.host.config.text.skipButton)})),e&&e.addEventListener("click",()=>{const n=t?.value.trim()||null;this.submitMessage(n)});const o=this.modalContainer.querySelector(".qaid-type-toggle");o&&o.addEventListener("click",()=>{const n=this.host.feedbackData.feedbackType==="up"?"down":"up";this.host.feedbackData.feedbackType=n,this.host.config.buttonClass?(o.classList.toggle("qaid-btn-up",n==="up"),o.classList.toggle("qaid-btn-down",n==="down")):(o.classList.toggle("qaid-type-up",n==="up"),o.classList.toggle("qaid-type-down",n==="down"));const s=this.host.config.positiveIcon||T,a=this.host.config.negativeIcon||$;o.innerHTML=n==="up"?s:a;const c=n==="up"?"Feedback type: positive":"Feedback type: negative";o.setAttribute("aria-pressed",String(n==="up")),o.setAttribute("aria-label",c),this.host.announceMsg(c),this.host.whenFeedbackId().then(l=>{l&&fetch(`${this.host.config.endpoint}/${l}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedbackType:n})}).catch(d=>console.error("Failed to update feedback type:",d))})})}async submitMessage(t){let e=null;this.finalized=!0;const o=await this.host.whenFeedbackId();if(o)try{const n=await fetch(`${this.host.config.endpoint}/${o}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t})});e=n.ok,n.ok||console.error("Failed to submit feedback message: HTTP",n.status)}catch(n){console.error("Failed to submit feedback message:",n),e=!1}if(e===!1){this.showResult(!1);return}if(e&&!this.host.config.hideConfirmation){this.showResult(!0);return}this.close()}showResult(t){const e=this.modalContainer?.querySelector(".qaid-modal-box")??this.modalContainer?.querySelector(".qaid-bottom-sheet-content")??this.modalContainer;if(!e){this.close();return}const o=this.host.config.text,n=t?o.confirmationTitle:o.errorTitle,s=t?o.confirmationMessage:o.errorMessage,a=u("h3",{class:"qaid-confirm-title",text:n,attrs:{id:`qaid-confirm-title-${this.host.uid}`,tabindex:"-1"}});e.textContent="",e.appendChild(u("div",{class:t?"qaid-confirm":"qaid-confirm qaid-confirm-error"},u("span",{class:"qaid-confirm-icon",html:t?Z:ae,attrs:{"aria-hidden":"true"}}),a,u("p",{class:"qaid-confirm-message",text:s}),u("button",{class:"qaid-btn-submit qaid-confirm-close",text:o.confirmationClose,attrs:{type:"button"},on:{click:()=>this.close()}}))),requestAnimationFrame(()=>a.focus()),this.host.announceMsg(`${n} ${s}`,!0)}}const Ht=Object.freeze(Object.defineProperty({__proto__:null,ModalController:Mi,styles:Di},Symbol.toStringTag,{value:"Module"})),Ot=["data-comp","data-qa","data-testid","data-id"];function zt(i,t=document.body){let e=i;for(;e&&e!==t;){for(const o of Ot){const n=e.getAttribute(o);if(n)return`${o}="${n}"`}e=e.parentElement}return null}function Ri(i,t=100){const e=i.textContent?.trim().slice(0,t)||"";return e.length===t?e+"...":e}function Pi(i){let t=1,e=i.previousElementSibling;for(;e;)t++,e=e.previousElementSibling;return t}function Bi(i){const t=[];let e=i;for(;e&&e!==document.body&&e!==document.documentElement;){const o=e.tagName.toLowerCase(),n=Pi(e);t.unshift(`${o}:nth-child(${n})`),e=e.parentElement}return t.length>0?`body > ${t.join(" > ")}`:"body"}function Hi(i){return i.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function Oi(i){const t=zt(i);return t?`[${t}]`:i.id?`#${Hi(i.id)}`:Bi(i)}function W(i){const t=Ri(i),e=zt(i);return{selector:Oi(i),text:t,dataAttr:e}}const zi=["a[href]","button","input:not([type=hidden])","select","textarea","summary","[tabindex]","[role]","img","h1","h2","h3","h4","h5","h6","p","li","label",...Ot.map(i=>`[${i}]`)].join(","),$i=/^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;function _i(i){if(i.hasAttribute("hidden")||i.getAttribute("aria-hidden")==="true")return!1;const t=i.ownerDocument?.defaultView;if(t&&typeof t.getComputedStyle=="function"){const e=t.getComputedStyle(i);if(e.display==="none"||e.visibility==="hidden")return!1}return!0}function Fi(i={}){const t=i.root??document.body,e=i.selector??zi,o=i.isExcluded??(()=>!1),n=i.isVisible??_i;return Array.from(t.querySelectorAll(e)).filter(s=>!o(s)&&n(s))}function Ni(i){const t=i.candidates??Fi({root:i.root,selector:i.selector,isExcluded:i.isExcluded,isVisible:i.isVisible}),e=i.moveFocus??!0,o=i.eventTarget??document,n=new Set;let s=-1,a=!1;const c=i.initial!==void 0?i.initial:typeof document<"u"?document.activeElement:null;if(c){const f=t.indexOf(c);f>=0&&(s=f)}s<0&&t.length>0&&(s=0);function l(f){if(!e)return;const q=f;if(typeof q.focus=="function"){f.getAttribute("tabindex")===null&&!$i.test(f.tagName)&&(f.setAttribute("tabindex","-1"),n.add(f));try{q.focus()}catch{}}}function d(){const f=t[s];f&&(l(f),i.onHighlight?.(f,s))}function r(f){if(a||t.length===0)return;const q=t.length;s=(f%q+q)%q,d()}function h(){r(s+1)}function p(){r(s-1)}function b(){return t[s]??null}function w(){a||(a=!0,o.removeEventListener("keydown",C,!0),n.forEach(f=>f.removeAttribute("tabindex")),n.clear())}function v(){if(a)return;const f=b();w(),f&&i.onSelect(f)}function k(){a||(w(),i.onCancel?.())}function C(f){if(!a)switch(f.key){case"Tab":f.preventDefault(),f.stopPropagation(),f.shiftKey?p():h();break;case"ArrowDown":case"ArrowRight":f.preventDefault(),f.stopPropagation(),h();break;case"ArrowUp":case"ArrowLeft":f.preventDefault(),f.stopPropagation(),p();break;case"Enter":case" ":case"Spacebar":f.preventDefault(),f.stopPropagation(),v();break;case"Escape":case"Esc":f.preventDefault(),f.stopPropagation(),k();break}}return o.addEventListener("keydown",C,!0),s>=0&&d(),{candidates:t,getIndex:()=>s,getCurrent:b,next:h,prev:p,moveTo:r,select:v,cancel:k,handleKey:C,stop:w}}const Vi=".qaid-targeting-overlay{position:fixed;inset:0;z-index:40;pointer-events:none}.qaid-capture-layer{position:fixed;inset:0;pointer-events:none;z-index:9999}.qaid-vignette{position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at center,transparent 30%,rgba(0,0,0,.3) 70%,rgba(0,0,0,.6) 100%);z-index:41}.qaid-crosshair-h,.qaid-crosshair-v{position:fixed;pointer-events:none;z-index:42}.qaid-crosshair-h{left:0;right:0;height:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-crosshair-v{top:0;bottom:0;width:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-type-up .qaid-crosshair-h,.qaid-type-up .qaid-crosshair-v{background:color-mix(in srgb,var(--qaid-positive) 60%,transparent)}.qaid-highlight-box{position:fixed;top:0;left:0;pointer-events:none;z-index:41;display:none;border:3px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:2px;background:color-mix(in srgb,var(--qaid-negative) 8%,transparent);will-change:transform,width,height}.qaid-type-up .qaid-highlight-box{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent);background:color-mix(in srgb,var(--qaid-positive) 8%,transparent)}.qaid-scope{position:fixed;width:80px;height:80px;pointer-events:none;z-index:43;transform:translate(-50%,-50%)}.qaid-scope-ring{position:absolute;inset:10px;border:2px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent)}.qaid-scope-ring-inner{position:absolute;inset:20px;border:1px solid color-mix(in srgb,var(--qaid-negative) 50%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring-inner{border-color:color-mix(in srgb,var(--qaid-positive) 50%,transparent)}.qaid-scope-dot{position:absolute;top:50%;left:50%;width:4px;height:4px;background:var(--qaid-negative);border-radius:50%;transform:translate(-50%,-50%)}.qaid-type-up .qaid-scope-dot{background:var(--qaid-positive)}.qaid-selected-marker{position:fixed;border:3px solid var(--qaid-marker, #6365f1);border-radius:50%;pointer-events:none;z-index:44;animation:qaid-markerPulse 1.5s ease-in-out infinite}@keyframes qaid-markerPulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.7;transform:scale(1.05)}}@media(forced-colors:active){.qaid-selected-marker,.qaid-highlight-box{border-color:Highlight}}",Ui=12;class ji{constructor(t){this.host=t}host;mousePos={x:0,y:0};touchStartPos=null;overlayContainer=null;captureLayer=null;crosshairH=null;crosshairV=null;scope=null;highlightBox=null;marker=null;keyboardController=null;boundMouseMove=t=>this.handleMouseMove(t);boundClick=t=>this.handleClick(t);boundTouchStart=t=>this.handleTouchStart(t);boundTouchEnd=t=>this.handleTouchEnd(t);startPointer(t,e){this.host.setState("TARGETING"),this.host.feedbackData.feedbackType=t,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1,this.mousePos.x=e.clientX,this.mousePos.y=e.clientY,document.body.classList.add("qaid-targeting"),t==="up"?document.body.classList.add("qaid-type-up"):document.body.classList.remove("qaid-type-up"),document.body.style.setProperty("--qaid-positive",this.host.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.host.cssVars["--qaid-negative"]),this.createTargetingOverlay(),document.addEventListener("keydown",this.host.boundKeyDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("click",this.boundClick,!0),document.addEventListener("touchstart",this.boundTouchStart,{passive:!0}),document.addEventListener("touchend",this.boundTouchEnd,{passive:!1})}startKeyboard(t){this.host.setState("TARGETING"),this.host.feedbackData.feedbackType=t,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1,document.body.style.setProperty("--qaid-positive",this.host.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.host.cssVars["--qaid-negative"]),this.createTargetingOverlay(),this.crosshairH&&(this.crosshairH.style.display="none"),this.crosshairV&&(this.crosshairV.style.display="none"),this.scope&&(this.scope.style.display="none"),this.keyboardController=Ni({isExcluded:e=>H(e),onHighlight:e=>{const o=e.getBoundingClientRect(),n=this.highlightBox;n&&(n.style.transform=`translate(${o.left}px, ${o.top}px)`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`,n.style.display="block");const{text:s}=W(e);this.host.announceMsg(`Targeting ${s||e.tagName.toLowerCase()}`)},onSelect:e=>this.selectKeyboardTarget(e),onCancel:()=>this.cancel()})}selectKeyboardTarget(t){const e=at(t,8);Object.assign(this.host.selectedBounds,e,{clickX:e.x+e.width/2,clickY:e.y+e.height/2,visible:!0});const{selector:o,text:n}=W(t);this.host.feedbackData.elementSelector=o,this.host.feedbackData.elementText=n,this.removeTargetingOverlay(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.keyboardController=null,this.host.clearActiveThumb(),this.host.setState("SELECTED"),this.showSelectedMarker(),this.host.submitFeedback()}createTargetingOverlay(){const t=this.host.ensureOverlayHost();this.overlayContainer=document.createElement("div"),this.overlayContainer.className=`qaid-targeting-overlay qaid-type-${this.host.feedbackData.feedbackType}`,this.captureLayer=document.createElement("div"),this.captureLayer.className="qaid-capture-layer";const e=document.createElement("div");e.className="qaid-vignette",this.crosshairH=document.createElement("div"),this.crosshairH.className="qaid-crosshair-h",this.crosshairV=document.createElement("div"),this.crosshairV.className="qaid-crosshair-v",this.scope=document.createElement("div"),this.scope.className="qaid-scope",this.scope.innerHTML=`
|
|
25
|
+
</svg>`,ke="button{cursor:pointer}.qaid-buttons{display:flex;gap:.5rem}.qaid-buttons.qaid-vertical{flex-direction:column}.qaid-buttons.qaid-auto-container{position:fixed;z-index:50}.qaid-buttons.qaid-auto-container.qaid-bottom-right{bottom:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-bottom-left{bottom:1rem;left:1rem}.qaid-buttons.qaid-auto-container.qaid-top-right{top:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-top-left{top:1rem;left:1rem}.qaid-buttons.qaid-incognito{opacity:0;transition:opacity .2s ease-in-out}.qaid-buttons.qaid-incognito:hover{opacity:1}.qaid-buttons.qaid-dismissed{display:none!important}.qaid-dismiss-btn{width:20px;height:20px;padding:0;border:none;border-radius:50%;background:#0006;color:#fff;display:flex;align-items:center;justify-content:center;align-self:center;opacity:0;transition:opacity .15s,background .15s;cursor:pointer;pointer-events:auto;-webkit-appearance:none;appearance:none}.qaid-dismiss-btn:hover{background:#0009}.qaid-buttons:hover .qaid-dismiss-btn{opacity:1}button.qaid-btn-structural{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;-webkit-appearance:none;appearance:none}.qaid-icon{width:24px;height:24px}:where(button.qaid-btn-structural)>svg:where(:not(.qaid-icon):not([width])){width:var(--qaid-icon-size, 24px);height:var(--qaid-icon-size, 24px)}.qaid-btn-structural:not(:has(svg)),.qaid-btn:not(:has(svg)){font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-emoji-icon{font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-buttons,.qaid-buttons *,.qaid-modal-container,.qaid-modal-container *{cursor:pointer!important}.qaid-tooltip-wrapper{position:relative}.qaid-tooltip-text{position:fixed;padding:.5rem .75rem;background:#1f2937;color:#fff;font-size:var(--qaid-font-size, 16px);font-weight:600;border-radius:.5rem;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s;z-index:99999}.qaid-tooltip-text.qaid-tooltip-visible{opacity:1}button.qaid-btn-record:hover{background:#dc2626;color:#fff}button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}.qaid-buttons.qaid-incognito:focus-within{opacity:1}.qaid-buttons:focus-within .qaid-dismiss-btn,.qaid-dismiss-btn:focus-visible{opacity:1}.qaid-dismiss-btn{min-width:24px;min-height:24px}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}@media(forced-colors:active){button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid CanvasText;outline-offset:2px}}",qe="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let M=0;const xe="button.qaid-btn{width:var(--qaid-btn-size);height:var(--qaid-btn-size);border-radius:50%;border:none;background:#f3f4f6;color:#374151;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);transition:background-color .2s,color .2s,transform .2s;-webkit-appearance:none;appearance:none;--qaid-hover-up-bg:var(--qaid-positive);--qaid-hover-up-color:#fff;--qaid-hover-down-bg:var(--qaid-negative);--qaid-hover-down-color:#fff}button.qaid-btn:hover{transform:scale(1.05)}button.qaid-btn-up:hover{background:var(--qaid-hover-up-bg);color:var(--qaid-hover-up-color)}button.qaid-btn-down:hover{background:var(--qaid-hover-down-bg);color:var(--qaid-hover-down-color)}button.qaid-btn-feedback:hover{background:var(--qaid-marker,#6365f1);color:var(--qaid-marker-text,#fff)}button.qaid-btn svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",Ce={small:36,medium:48,large:64},Se={small:18,medium:24,large:32};function Ee(o,t,e){const[i,n,a]=[o,t,e].map(s=>(s=s/255,s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4)));return .2126*i+.7152*n+.0722*a}function Te(o){if(o.startsWith("#")){const e=o.slice(1),i=e.length===3?e.split("").map(a=>a+a).join(""):e,n=parseInt(i,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=o.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function Ae(o){const t=Te(o);return t&&Ee(t.r,t.g,t.b)>.4?"black":"white"}function Le(o={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:e="rgb(255, 0, 0)",markerColor:i="#6365f1",buttonSize:n="medium",modalWidth:a=400,backdropOpacity:s=.3,fontFamily:d="system-ui, -apple-system, sans-serif",fontSize:c=16}=o,l=Ce[n],r=Se[n],h=Ae(i);return{"--qaid-positive":t,"--qaid-negative":e,"--qaid-marker":i,"--qaid-marker-text":h,"--qaid-btn-size":`${l}px`,"--qaid-icon-size":`${r}px`,"--qaid-modal-width":`${a}px`,"--qaid-backdrop-opacity":String(s),"--qaid-font-family":d,"--qaid-font-size":`${c}px`}}function De(o,t){for(const[e,i]of Object.entries(t))o.style.setProperty(e,i)}function ot(){return ke+xe}function Me(){if(M++,M>1)return;const o=document.createElement("style");o.id="qaid-styles",o.textContent=qe,document.head.appendChild(o)}function Ie(){M<=0||(M--,M===0&&document.getElementById("qaid-styles")?.remove())}const it="data-qaid-a11y-live",Pe="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;";function Re(o){return o.ownerDocument||document}function Be(o,t){const e=t?"assertive":"polite",i=o.querySelector(`[${it}="${e}"]`);if(i)return i;const a=Re(o).createElement("div");return a.setAttribute(it,e),a.setAttribute("role",t?"alert":"status"),a.setAttribute("aria-live",t?"assertive":"polite"),a.setAttribute("aria-atomic","true"),a.style.cssText=Pe,o.appendChild(a),a}function He(o,t,e={}){const i=Be(o,!!e.assertive);i.textContent="",i.textContent=t}function Oe(o,t,e,i={}){const n=i.gap??8;let a=o.bottom+n;a+t.height>e.height-n&&(a=o.top-t.height-n);let s=o.left;return s<n?s=n:s+t.width>e.width-n&&(s=e.width-t.width-n),a<n?a=n:a+t.height>e.height-n&&(a=e.height-t.height-n),{top:a,left:s}}const ze=20;function $e(o){const t=[],e=console.error,i=console.warn,n=console.log,a=(s,d)=>{const c={message:d.map(l=>String(l)).join(" "),timestamp:Date.now(),level:s};t.length>=ze&&t.shift(),t.push(c),o&&o(c)};return console.error=function(...s){a("error",s),e.apply(console,s)},console.warn=function(...s){a("warn",s),i.apply(console,s)},console.log=function(...s){a("log",s),n.apply(console,s)},{errors:t,restore:()=>{console.error=e,console.warn=i,console.log=n}}}function x(o,t,e){const i=document.createElement(o);if(t)for(const[n,a]of Object.entries(t))n==="className"?i.className=a:i.setAttribute(n,a);return i}function _e(o=640){return typeof window<"u"&&window.innerWidth<o}function nt(o,t,e){const i=e.map(a=>a.style.visibility);e.forEach(a=>a.style.visibility="hidden");const n=document.elementFromPoint(o,t);return e.forEach((a,s)=>a.style.visibility=i[s]),n}function H(o){return o?o.hasAttribute("data-qaid-embed")||o.hasAttribute("data-qaid-embed-overlay")?!0:!!o.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function at(o,t=0){const e=o.getBoundingClientRect();return{x:e.left-t,y:e.top-t,width:e.width+t*2,height:e.height+t*2}}const st="https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js",rt="qaid_visitor_id",dt="qaid_hide_feedback",Fe=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"];function Ve(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function N(o){return o?`${dt}_${o}`:dt}function Ne(o){try{return localStorage.getItem(N(o))==="1"}catch{return!1}}function ct(o,t=!0){try{t?localStorage.setItem(N(o),"1"):localStorage.removeItem(N(o))}catch{}}function lt(){const o=typeof crypto<"u"?crypto:void 0;if(o&&typeof o.randomUUID=="function")return o.randomUUID();const t=new Uint8Array(16);if(o&&typeof o.getRandomValues=="function")o.getRandomValues(t);else for(let i=0;i<t.length;i++)t[i]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function Ue(){try{let o=localStorage.getItem(rt);return o||(o=lt(),localStorage.setItem(rt,o)),o}catch{return lt()}}function ht(o,t){const e=document.createElement("style");e.setAttribute("data-qaid-feature",""),e.textContent=t;const i=o.querySelectorAll("style[data-qaid-base], style[data-qaid-feature]"),n=i[i.length-1];o.insertBefore(e,n?n.nextSibling:o.firstChild)}class ut{config;state="IDLE";feedbackData={feedbackType:null,elementSelector:null,elementText:null,consoleErrors:[]};selectedBounds={x:0,y:0,width:0,height:0,clickX:0,clickY:0,visible:!1};feedbackIdPromise=Promise.resolve(null);questsPrewarmed=!1;activeQuest=null;isMobile=!1;visitorId;consoleCapture=null;recording=null;targeting=null;clickPathPrewarmed=!1;prewarmHandle=null;prewarmIsTimeout=!1;videoPrewarmed=!1;screenshotPrewarmed=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;modal=null;dismissBtn=null;cssVars={};activeThumbBtn=null;keyboardActivation=!1;dialogModule=null;dialogClose=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundResize;_startDismissed=!1;destroyed=!1;domObserver=null;boundBeforeSwap=null;constructor(t){this.config={endpoint:t.endpoint,apiKey:t.apiKey??"",container:t.container??"",buttonClass:t.buttonClass??"",direction:t.direction??"horizontal",position:t.position??"bottom-right",offset:{x:t.offset?.x??16,y:t.offset?.y??16},zIndex:t.zIndex??50,skipTargeting:t.skipTargeting??!1,singleButton:t.singleButton??!1,feedbackMode:t.feedbackMode??"target",colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#6365f1"},buttonSize:t.buttonSize??"medium",text:{tooltip:t.text?.tooltip??"",modalTitle:t.text?.modalTitle??"Thank you for your feedback!",modalSubtitle:t.text?.modalSubtitle??"Would you like to add a message to help us understand your feedback better?",placeholder:t.text?.placeholder??"Optional: Tell us more about your experience...",submitButton:t.text?.submitButton??"Submit",skipButton:t.text?.skipButton??"Skip",positiveLabel:t.text?.positiveLabel??"Send positive feedback",negativeLabel:t.text?.negativeLabel??"Send negative feedback",recordLabel:t.text?.recordLabel??"Record a screen recording",dismissLabel:t.text?.dismissLabel??"Hide Feedback",feedbackLabel:t.text?.feedbackLabel??"Send feedback",confirmationTitle:t.text?.confirmationTitle??"Thank you!",confirmationMessage:t.text?.confirmationMessage??"Your feedback has been received.",confirmationClose:t.text?.confirmationClose??"Close",errorTitle:t.text?.errorTitle??"Message not sent",errorMessage:t.text?.errorMessage??"Something went wrong, so we did not get your message. Please try again later."},hideConfirmation:t.hideConfirmation??!1,modalWidth:t.modalWidth??400,backdropOpacity:t.backdropOpacity??.3,fontFamily:t.fontFamily??"system-ui, -apple-system, sans-serif",fontSize:t.fontSize??16,captureScreenshot:t.captureScreenshot??!1,annotate:t.annotate??!0,annotationColor:t.annotationColor??t.colors?.marker??"#6365f1",annotationPalette:t.annotationPalette??Fe,screenshotMethod:t.screenshotMethod??"permission",screenshotOptions:{quality:t.screenshotOptions?.quality??.8,maxWidth:t.screenshotOptions?.maxWidth??1280,maxHeight:t.screenshotOptions?.maxHeight??800},incognito:t.incognito??!1,hideDismiss:t.hideDismiss??!1,positiveIcon:t.positiveIcon??"",negativeIcon:t.negativeIcon??"",feedbackIcon:t.feedbackIcon??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15,redaction:t.videoOptions?.redaction??!1},recordIcon:t.recordIcon??"",quests:{base:t.quests?.base??"",up:t.quests?.up??"",down:t.quests?.down??"",video:t.quests?.video??"",apiKey:t.quests?.apiKey??t.apiKey??"",moduleUrl:t.quests?.moduleUrl??st}},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=Ue(),this.init()}applyVars(t){De(t,this.cssVars)}announceMsg(t,e=!1){const i=this.overlayShadowRoot??this.shadowRoot;i&&He(i,t,{assertive:e})}async loadDialogA11y(){this.dialogModule??=await Promise.resolve().then(()=>zt)}openDialogA11y(t,e){this.dialogClose=this.dialogModule.openDialog(t,e)}closeDialogA11y(){const t=this.dialogClose;this.dialogClose=null,t?.()}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){Me(),this.cssVars=Le({positiveColor:this.config.colors.positive,negativeColor:this.config.colors.negative,markerColor:this.config.colors.marker,buttonSize:this.config.buttonSize,modalWidth:this.config.modalWidth,backdropOpacity:this.config.backdropOpacity,fontFamily:this.config.fontFamily,fontSize:this.config.fontSize}),!this.config.hideDismiss&&Ne(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=$e(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom(),this.schedulePrewarm(()=>{this.prewarmClickPath(),this.config.captureVideo&&this.videoSupported()&&this.prewarmVideo(),this.config.captureScreenshot&&this.prewarmScreenshot(),this.prewarmQuests()})}prewarmClickPath(){this.clickPathPrewarmed||(this.clickPathPrewarmed=!0,Promise.resolve().then(()=>Q).catch(()=>{}),Promise.resolve().then(()=>zt).catch(()=>{}),Promise.resolve().then(()=>Wt).catch(()=>{}),this.skipsTargeting()||Promise.resolve().then(()=>Yt).catch(()=>{}))}skipsTargeting(){return this.config.skipTargeting||this.config.feedbackMode==="annotate"}prewarmVideo(){this.videoPrewarmed||(this.videoPrewarmed=!0,Promise.resolve().then(()=>Jt).catch(()=>{}),Promise.resolve().then(()=>xt).catch(()=>{}))}prewarmScreenshot(){this.screenshotPrewarmed||(this.screenshotPrewarmed=!0,(this.shouldCaptureViaDom()?Promise.resolve().then(()=>Tt):Promise.resolve().then(()=>Gt)).catch(()=>{}),this.config.annotate&&Promise.resolve().then(()=>Mt).catch(()=>{}))}linkedQuestIds(){const t=this.config.quests;return t.base?[t.up,t.down,t.video].filter(e=>e):[]}prewarmQuests(){if(this.questsPrewarmed)return;const t=this.linkedQuestIds();if(t.length===0)return;this.questsPrewarmed=!0;const{base:e,moduleUrl:i}=this.config.quests;Promise.resolve().then(()=>Do).then(n=>{n.loadQuestsModule(i).catch(()=>{});for(const a of t)n.prefetchQuestDefinition(n.questDefinitionUrl(e,a))}).catch(()=>{})}schedulePrewarm(t){const e=window,i=()=>{this.destroyed||t()};typeof e.requestIdleCallback=="function"?(this.prewarmIsTimeout=!1,this.prewarmHandle=e.requestIdleCallback(i,{timeout:2e3})):(this.prewarmIsTimeout=!0,this.prewarmHandle=window.setTimeout(i,1200))}observeDom(){this.boundBeforeSwap=t=>{const e=t.newDocument;!e||this.destroyed||(this.shadowHost&&e.body.appendChild(this.shadowHost),this.overlayShadowHost&&e.body.appendChild(this.overlayShadowHost))},document.addEventListener("astro:before-swap",this.boundBeforeSwap),this.domObserver=new MutationObserver(()=>{this.destroyed||(this.shadowHost&&!this.shadowHost.isConnected&&document.body.appendChild(this.shadowHost),this.overlayShadowHost&&!this.overlayShadowHost.isConnected&&document.body.appendChild(this.overlayShadowHost))}),this.domObserver.observe(document.body,{childList:!0})}checkMobile(){this.isMobile=_e()}handleResize(){this.checkMobile()}createEmbed(){this.shadowHost=document.createElement("div"),this.shadowHost.setAttribute("data-qaid-embed",""),this.shadowHost.style.position="static",this.shadowHost.style.display="contents";let t=null;this.config.container&&(t=document.querySelector(this.config.container)),t?(t.appendChild(this.shadowHost),this.isUserProvidedContainer=!0,this.config.hideDismiss=!0):(this.shadowHost.style.position="fixed",this.shadowHost.style.display="block",this.shadowHost.style.inset="0",this.shadowHost.style.pointerEvents="none",this.shadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.shadowHost)),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"});const e=document.createElement("style");if(e.setAttribute("data-qaid-base",""),e.textContent=ot(),this.shadowRoot.appendChild(e),this.config.css){const r=document.createElement("style");r.textContent=this.config.css,this.shadowRoot.appendChild(r)}const i=this.config.direction==="vertical"?"qaid-vertical":"";if(this.isUserProvidedContainer)this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-${this.config.position} ${i}`.trim(),this.config.incognito&&this.buttonsContainer.classList.add("qaid-incognito");else{this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-auto-container qaid-${this.config.position} ${i}${this.config.incognito?" qaid-incognito":""}`.trim(),this.buttonsContainer.style.pointerEvents="auto";const{x:r,y:h}=this.config.offset;this.config.position.includes("right")?this.buttonsContainer.style.right=`${r}px`:this.buttonsContainer.style.left=`${r}px`,this.config.position.includes("bottom")?this.buttonsContainer.style.bottom=`${h}px`:this.buttonsContainer.style.top=`${h}px`}this.applyVars(this.buttonsContainer),this.shadowRoot.appendChild(this.buttonsContainer),this.buttonsContainer.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" "||r.key==="Spacebar")&&(this.keyboardActivation=!0)}),this.buttonsContainer.addEventListener("mousedown",()=>{this.keyboardActivation=!1}),this.buttonsContainer.addEventListener("pointerdown",()=>{this.keyboardActivation=!1});const n=()=>this.prewarmClickPath();this.buttonsContainer.addEventListener("pointerenter",n),this.buttonsContainer.addEventListener("focusin",n);const a=!!this.config.buttonClass,s=a?`qaid-btn-structural ${this.config.buttonClass}`:"qaid-btn",c=this.config.text.tooltip||"Feedback for us?",l=document.createElement("div");if(l.className="qaid-tooltip-text",l.textContent=c,this.applyVars(l),this.shadowRoot.appendChild(l),this.tooltipElement=l,this.config.singleButton){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const h=document.createElement("button");h.type="button",h.className=a?`${s} qaid-btn-feedback`:"qaid-btn qaid-btn-feedback",h.setAttribute("aria-label",this.config.text.feedbackLabel),h.innerHTML=this.config.feedbackIcon||tt,h.addEventListener("click",f=>this.handleThumbClick("neutral",f.currentTarget,f)),h.addEventListener("mouseenter",()=>this.showTooltip(h)),h.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(h),this.buttonsContainer.appendChild(r)}else if(!this.config.hideThumbs){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const h=document.createElement("button");h.type="button",h.className=a?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",h.setAttribute("aria-label",this.config.text.positiveLabel),h.innerHTML=this.config.positiveIcon||E,h.addEventListener("click",g=>this.handleThumbClick("up",g.currentTarget,g)),h.addEventListener("mouseenter",()=>{this.prewarmQuests(),this.showTooltip(h)}),h.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(h);const f=document.createElement("div");f.className="qaid-tooltip-wrapper";const m=document.createElement("button");m.type="button",m.className=a?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",m.setAttribute("aria-label",this.config.text.negativeLabel),m.innerHTML=this.config.negativeIcon||V,m.addEventListener("click",g=>this.handleThumbClick("down",g.currentTarget,g)),m.addEventListener("mouseenter",()=>{this.prewarmQuests(),this.showTooltip(m)}),m.addEventListener("mouseleave",()=>this.hideTooltip()),f.appendChild(m),this.buttonsContainer.appendChild(r),this.buttonsContainer.appendChild(f)}if(this.config.captureVideo&&this.videoSupported()){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const h=document.createElement("button");h.type="button",h.className=a?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",h.setAttribute("aria-label",this.config.text.recordLabel),h.innerHTML=this.config.recordIcon||pe,h.addEventListener("click",()=>{this.ensureRecording().then(m=>this.config.videoOptions.redaction?m.startPicking():m.startRecording())});const f=()=>this.prewarmVideo();h.addEventListener("mouseenter",()=>{f(),this.showTooltip(h)}),h.addEventListener("focus",f),h.addEventListener("touchstart",f,{passive:!0}),h.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(h),this.buttonsContainer.appendChild(r)}this.config.hideDismiss||(this.dismissBtn=document.createElement("button"),this.dismissBtn.type="button",this.dismissBtn.className="qaid-dismiss-btn",this.dismissBtn.setAttribute("aria-label",this.config.text.dismissLabel),this.dismissBtn.title=this.config.text.dismissLabel,this.dismissBtn.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 2l8 8M10 2l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',this.dismissBtn.addEventListener("click",r=>{r.stopPropagation(),this.handleDismiss()}),this.buttonsContainer.insertBefore(this.dismissBtn,this.buttonsContainer.firstChild),this._startDismissed&&this.buttonsContainer.classList.add("qaid-dismissed"))}ensureOverlayHost(){if(this.overlayShadowRoot)return this.overlayShadowRoot;this.overlayShadowHost=document.createElement("div"),this.overlayShadowHost.setAttribute("data-qaid-embed-overlay",""),this.overlayShadowHost.style.position="fixed",this.overlayShadowHost.style.inset="0",this.overlayShadowHost.style.pointerEvents="none",this.overlayShadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.overlayShadowHost),this.overlayShadowRoot=this.overlayShadowHost.attachShadow({mode:"open"});const t=document.createElement("style");t.setAttribute("data-qaid-base",""),t.textContent=ot(),this.overlayShadowRoot.appendChild(t);for(const e of this.featureStyles)ht(this.overlayShadowRoot,e);if(this.config.css){const e=document.createElement("style");e.textContent=this.config.css,this.overlayShadowRoot.appendChild(e)}return this.overlayShadowRoot}featureStyles=[];addFeatureStyles(t){if(!this.featureStyles.includes(t)){this.featureStyles.push(t);for(const e of[this.shadowRoot,this.overlayShadowRoot])e&&ht(e,t)}}tooltipElement=null;showTooltip(t){const e=this.tooltipElement;e.style.visibility="hidden",e.classList.add("qaid-tooltip-visible");const i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),{top:a,left:s}=Oe(i,n,{width:window.innerWidth,height:window.innerHeight});e.style.top=`${a}px`,e.style.left=`${s}px`,e.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),ct(this.config.apiKey,!0)}handleThumbClick(t,e,i){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),ct(this.config.apiKey,!1)),this.prewarmClickPath(),this.skipsTargeting())this.submitDirectFeedback(t,e);else{this.activeThumbBtn=e,e.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,this.ensureTargeting().then(a=>{this.destroyed||(n?a.startKeyboard(t):a.startPointer(t,i))})}}submitDirectFeedback(t,e){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const i=e.getBoundingClientRect();this.selectedBounds={x:i.left,y:i.top,width:i.width,height:i.height,clickX:i.left+i.width/2,clickY:i.top+i.height/2,visible:!1},this.submitFeedback()}handleKeyDown(t){if(t.key==="Escape"){if(this.recording?.handleEscape())return;this.state==="TARGETING"?this.targeting?.cancel():this.state==="MODAL_OPEN"&&this.modal?.close()}}shouldCaptureViaDom(){return this.config.screenshotMethod==="dom"||Ve()}async submitFeedback(){try{const[t]=await Promise.all([Promise.resolve().then(()=>Q),this.loadDialogA11y()]);await t.submitFeedback(this.makeSendHost())}catch(t){console.error("Failed to send feedback:",t),this.announceMsg("Failed to send feedback",!0),this.resetFeedbackUi()}}async tryLaunchQuest(t,e){try{return await(await Promise.resolve().then(()=>Q)).tryLaunchQuest(this.makeSendHost(),t,e)}catch(i){return console.error("Failed to launch quest:",i),!1}}makeSendHost(){const t=this;return{get config(){return t.config},get visitorId(){return t.visitorId},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},get destroyed(){return t.destroyed},get overlayShadowHost(){return t.overlayShadowHost},get activeQuest(){return t.activeQuest},set activeQuest(e){t.activeQuest=e},setState:e=>{t.state=e},setFeedbackId:e=>{t.feedbackIdPromise=e},shouldCaptureViaDom:()=>t.shouldCaptureViaDom(),ensureOverlayHost:()=>t.ensureOverlayHost(),ensureModal:()=>t.ensureModal(),addFeatureStyles:e=>t.addFeatureStyles(e),applyVars:e=>t.applyVars(e),announceMsg:(e,i)=>t.announceMsg(e,i),openDialogA11y:(e,i)=>t.openDialogA11y(e,i),closeDialogA11y:()=>t.closeDialogA11y(),resetFeedbackUi:()=>t.resetFeedbackUi()}}resetFeedbackUi(){this.targeting?.hideMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackIdPromise=Promise.resolve(null),this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}async ensureModal(){if(!this.modal){const[{ModalController:t,styles:e}]=await Promise.all([Promise.resolve().then(()=>Wt),this.loadDialogA11y()]);this.addFeatureStyles(e),this.modal=new t(this.makeModalHost())}return this.modal}makeModalHost(){const t=this;return{get config(){return t.config},get uid(){return t.uid},get isMobile(){return t.isMobile},get state(){return t.state},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},whenFeedbackId:()=>t.feedbackIdPromise,ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,i)=>t.announceMsg(e,i),openDialogA11y:(e,i)=>t.openDialogA11y(e,i),closeDialogA11y:()=>t.closeDialogA11y(),resetFeedbackUi:()=>t.resetFeedbackUi()}}async ensureTargeting(){if(!this.targeting){const{TargetingController:t,styles:e}=await Promise.resolve().then(()=>Yt);this.addFeatureStyles(e),this.targeting=new t(this.makeTargetingHost())}return this.targeting}makeTargetingHost(){const t=this;return{get config(){return t.config},get cssVars(){return t.cssVars},get state(){return t.state},get shadowHost(){return t.shadowHost},get overlayShadowHost(){return t.overlayShadowHost},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,i)=>t.announceMsg(e,i),clearActiveThumb:()=>t.clearActiveThumb(),submitFeedback:()=>t.submitFeedback()}}videoSupported(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}async ensureRecording(){if(!this.recording){const[{RecordingController:t,styles:e}]=await Promise.all([Promise.resolve().then(()=>Jt),this.loadDialogA11y()]);this.addFeatureStyles(e),this.recording=new t(this.makeRecordingHost())}return this.recording}makeRecordingHost(){const t=this;return{get config(){return t.config},get visitorId(){return t.visitorId},get uid(){return t.uid},get overlayShadowHost(){return t.overlayShadowHost},get consoleCapture(){return t.consoleCapture},get boundKeyDown(){return t.boundKeyDown},get state(){return t.state},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,i)=>t.announceMsg(e,i),openDialogA11y:(e,i)=>t.openDialogA11y(e,i),closeDialogA11y:()=>t.closeDialogA11y(),setButtonsDisabled:e=>t.setButtonsDisabled(e),tryLaunchQuest:(e,i)=>t.tryLaunchQuest(e,i)}}setButtonsDisabled(t){if(!this.buttonsContainer)return;this.buttonsContainer.querySelectorAll("button.qaid-btn, button.qaid-btn-structural").forEach(i=>{t?i.classList.contains("qaid-btn-record")||(i.disabled=!0,i.style.opacity="0.5"):(i.disabled=!1,i.style.opacity="")})}destroy(){if(this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.targeting?.destroy(),this.targeting=null,this.clearActiveThumb(),this.closeDialogA11y(),this.prewarmHandle!==null){const t=window;this.prewarmIsTimeout?clearTimeout(this.prewarmHandle):t.cancelIdleCallback?.(this.prewarmHandle),this.prewarmHandle=null}this.recording?.destroy(),this.recording=null,this.modal?.destroy(),this.modal=null,this.activeQuest?.destroy(),this.activeQuest=null,this.consoleCapture&&(this.consoleCapture.restore(),this.consoleCapture=null),window.removeEventListener("resize",this.boundResize),document.removeEventListener("keydown",this.boundKeyDown),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.shadowHost&&(this.shadowHost.remove(),this.shadowHost=null,this.shadowRoot=null),this.overlayShadowHost&&(this.overlayShadowHost.remove(),this.overlayShadowHost=null,this.overlayShadowRoot=null),this.buttonsContainer=null,this.dismissBtn=null,this.tooltipElement=null,Ie()}}function pt(o){return document.querySelector(o)?.textContent?.trim()??""}function je(){const o=document.querySelector('script[type="application/json"][data-feedback-config]');if(!o)return null;const t=o.textContent?.trim();if(!t)return null;try{const e=JSON.parse(t);return e.cssSelector&&!e.css&&(e.css=pt(e.cssSelector),delete e.cssSelector),e}catch{return null}}function ft(o,t,e){console.warn(`[thumbs-embed] Ignoring ${o}="${t}": expected ${e}.`)}function Ke(o){const t=[];let e=0,i="";for(const n of o)n==="("&&e++,n===")"&&(e=Math.max(0,e-1)),n===","&&e===0?(t.push(i.trim()),i=""):i+=n;return t.push(i.trim()),t}function We(o,t){if(t===null)return;const e=t.trim();let i=null;if(e.startsWith("[")||e.startsWith("{"))try{i=JSON.parse(e)}catch{i=null}else i=Ke(e);if(Array.isArray(i)&&i.length>0&&i.every(n=>typeof n=="string"&&n.trim()!==""))return i.map(n=>n.trim());ft(o,t,"a JSON array of colours or a comma-separated list")}function O(o,t){if(t!==null){if(t.trim()===""){ft(o,t,"a non-empty label");return}return t}}function Qe(o){const t=o.getAttribute("data-endpoint");if(!t)return null;const e=o.getAttribute("data-position"),i=o.getAttribute("data-zindex"),n=o.getAttribute("data-positive-color"),a=o.getAttribute("data-negative-color"),s=o.getAttribute("data-marker-color"),d=o.getAttribute("data-container"),c=o.getAttribute("data-button-class"),l=o.getAttribute("data-skip-targeting"),r=o.getAttribute("data-hide-confirmation"),h=o.getAttribute("data-single-button"),f=o.getAttribute("data-feedback-mode"),m=o.getAttribute("data-incognito"),g=o.getAttribute("data-button-size"),y=o.getAttribute("data-offset-x"),k=o.getAttribute("data-offset-y"),C=o.getAttribute("data-modal-width"),p=o.getAttribute("data-backdrop-opacity"),q=o.getAttribute("data-font-family"),w=o.getAttribute("data-font-size"),S=o.getAttribute("data-tooltip"),B=o.getAttribute("data-modal-title"),T=o.getAttribute("data-confirmation-title"),b=o.getAttribute("data-confirmation-message"),D=o.getAttribute("data-confirmation-close"),Zt=o.getAttribute("data-error-title"),te=o.getAttribute("data-error-message"),ee=o.getAttribute("data-modal-subtitle"),oe=o.getAttribute("data-placeholder"),ie=o.getAttribute("data-submit-button"),ne=o.getAttribute("data-skip-button"),ii=o.getAttribute("data-positive-icon"),ni=o.getAttribute("data-negative-icon"),ai=o.getAttribute("data-feedback-icon"),ae=o.getAttribute("data-feedback-label"),si=o.getAttribute("data-api-key"),ri=o.getAttribute("data-capture-screenshot"),di=o.getAttribute("data-annotate"),ci=o.getAttribute("data-annotation-color"),Y=o.getAttribute("data-screenshot-quality"),J=o.getAttribute("data-screenshot-max-width"),G=o.getAttribute("data-screenshot-max-height"),li=o.getAttribute("data-capture-video"),se=o.getAttribute("data-video-redaction"),hi=o.getAttribute("data-hide-thumbs"),ui=o.getAttribute("data-hide-dismiss"),Z=o.getAttribute("data-video-max-duration"),pi=o.getAttribute("data-screenshot-method"),fi=o.getAttribute("data-direction"),re=o.getAttribute("data-css-selector"),mi=o.getAttribute("data-css"),de=O("data-positive-label",o.getAttribute("data-positive-label")),ce=O("data-negative-label",o.getAttribute("data-negative-label")),le=O("data-record-label",o.getAttribute("data-record-label")),he=O("data-dismiss-label",o.getAttribute("data-dismiss-label")),bi=We("data-annotation-palette",o.getAttribute("data-annotation-palette")),gi=o.getAttribute("data-record-icon"),ue=o.getAttribute("data-quest-base"),vi=o.getAttribute("data-quest-up"),yi=o.getAttribute("data-quest-down"),wi=o.getAttribute("data-quest-video"),ki=o.getAttribute("data-quest-api-key"),qi=o.getAttribute("data-quest-module-url");return{endpoint:t,css:mi||(re?pt(re):void 0),apiKey:si??void 0,captureScreenshot:ri==="true"?!0:void 0,annotate:di==="false"?!1:void 0,annotationColor:ci??void 0,annotationPalette:bi,screenshotOptions:Y||J||G?{quality:Y?parseFloat(Y):void 0,maxWidth:J?parseInt(J,10):void 0,maxHeight:G?parseInt(G,10):void 0}:void 0,container:d??void 0,buttonClass:c??void 0,direction:fi??void 0,position:e??void 0,zIndex:i?parseInt(i,10):void 0,skipTargeting:l==="true"?!0:void 0,hideConfirmation:r==="true"?!0:void 0,singleButton:h==="true"?!0:void 0,feedbackMode:f??void 0,incognito:m==="true"?!0:void 0,buttonSize:g??void 0,offset:y||k?{x:y?parseInt(y,10):void 0,y:k?parseInt(k,10):void 0}:void 0,modalWidth:C?parseInt(C,10):void 0,backdropOpacity:p?parseFloat(p):void 0,fontFamily:q??void 0,fontSize:w?parseInt(w,10):void 0,colors:{positive:n??void 0,negative:a??void 0,marker:s??void 0},text:S||B||ee||oe||ie||ne||ae||T||b||D||Zt||te||de||ce||le||he?{tooltip:S??void 0,modalTitle:B??void 0,modalSubtitle:ee??void 0,placeholder:oe??void 0,submitButton:ie??void 0,skipButton:ne??void 0,feedbackLabel:ae??void 0,confirmationTitle:T??void 0,confirmationMessage:b??void 0,confirmationClose:D??void 0,errorTitle:Zt??void 0,errorMessage:te??void 0,positiveLabel:de,negativeLabel:ce,recordLabel:le,dismissLabel:he}:void 0,positiveIcon:ii??void 0,recordIcon:gi??void 0,negativeIcon:ni??void 0,feedbackIcon:ai??void 0,screenshotMethod:pi??void 0,captureVideo:li==="true"?!0:void 0,hideThumbs:hi==="true"?!0:void 0,hideDismiss:ui==="true"?!0:void 0,videoOptions:Z||se?{maxDuration:Z?parseInt(Z,10):void 0,redaction:se==="true"?!0:void 0}:void 0,quests:ue?{base:ue,up:vi??void 0,down:yi??void 0,video:wi??void 0,apiKey:ki??void 0,moduleUrl:qi??void 0}:void 0}}function Xe(){if(typeof document>"u")return;const o=()=>{const t=document.currentScript??document.querySelector("script[data-endpoint]"),e=je()??(t?Qe(t):null);e?.endpoint&&new ut(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o()}const Ye=20,mt=4096;function z(o){const t=typeof o=="string"?o:JSON.stringify(o);return t.length>mt?t.slice(0,mt)+"…[truncated]":t}function bt(o,t){o.length>=Ye&&o.shift(),o.push(t)}async function Je(o){try{const t=await o.clone().text();return z(t)}catch{return}}function gt(){const o=[],t=window.fetch;window.fetch=async function(n,a){const s=typeof n=="string"?n:n instanceof URL?n.toString():n.url,d=a?.method??(typeof n=="object"&&"method"in n?n.method:"GET");let c;a?.body&&(c=z(a.body));const l=await t.apply(window,[n,a]);if(l.status>=400){const r=await Je(l);bt(o,{url:s,method:d.toUpperCase(),status:l.status,statusText:l.statusText,requestBody:c,responseBody:r,timestamp:Date.now()})}return l};const e=XMLHttpRequest.prototype.open,i=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,a,...s){return this._qaid_method=n,this._qaid_url=typeof a=="string"?a:a.toString(),e.apply(this,[n,a,...s])},XMLHttpRequest.prototype.send=function(n){const a=this,s=n?z(n):void 0;return a.addEventListener("load",function(){a.status>=400&&bt(o,{url:a._qaid_url,method:a._qaid_method.toUpperCase(),status:a.status,statusText:a.statusText,requestBody:s,responseBody:z(a.responseText),timestamp:Date.now()})}),i.apply(this,[n])},{errors:o,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=e,XMLHttpRequest.prototype.send=i}}}function Ge(){const o=navigator.userAgent||"";return/iP(hone|ad|od)/.test(o)||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1}function Ze(o,t,e,i,n){const a=o>=t,s=e>=i;return a===s?{width:o,height:t,rotate:0}:{width:t,height:o,rotate:n===270?-90:90}}function to(o,t,e){if(e.rotate===0){o.drawImage(t,0,0,e.width,e.height);return}o.save(),e.rotate===90?(o.translate(e.width,0),o.rotate(Math.PI/2)):(o.translate(0,e.height),o.rotate(-Math.PI/2)),o.drawImage(t,0,0,e.height,e.width),o.restore()}function eo(){const o=typeof screen<"u"?screen.orientation:void 0;return o&&typeof o.angle=="number"?o.angle:0}function vt(o){return new Promise(t=>{if(o.videoWidth>0){t();return}o.addEventListener("loadedmetadata",()=>t(),{once:!0})})}async function yt(o){try{await o.play()}catch{}}async function oo(o,t=15){const e=document.createElement("canvas");if(typeof e.captureStream!="function")return null;const i=e.getContext("2d");if(!i)return null;const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=o,await vt(n);const a=Ze(n.videoWidth,n.videoHeight,window.innerWidth,window.innerHeight,eo());e.width=a.width,e.height=a.height,await yt(n);let s=0;const d=()=>{to(i,n,a),s=requestAnimationFrame(d)};d();const c=e.captureStream(t);return{stream:c,stop:()=>{s&&cancelAnimationFrame(s),s=0,c.getTracks().forEach(l=>l.stop()),n.pause(),n.srcObject=null}}}function io(o,t,e,i,n){const a=Math.max(0,Math.min(i,o.left*t)),s=Math.max(0,Math.min(n,o.top*e)),d=Math.max(0,Math.min(i,(o.left+o.width)*t)),c=Math.max(0,Math.min(n,(o.top+o.height)*e)),l=d-a,r=c-s;return l<=0||r<=0?null:{x:a,y:s,w:l,h:r}}function no(o,t,e,i,n,a,s){o.drawImage(t,0,0,i,n);const d=i/Math.max(1,window.innerWidth),c=n/Math.max(1,window.innerHeight);for(const l of e){const r=io(l.getBoundingClientRect(),d,c,i,n);r&&(o.save(),s?(o.filter=`blur(${a}px)`,o.drawImage(t,r.x,r.y,r.w,r.h,r.x,r.y,r.w,r.h)):(o.fillStyle="#0b0b0b",o.fillRect(r.x,r.y,r.w,r.h)),o.restore())}}async function ao(o,t,e={}){const i=e.frameRate??15,n=e.blurRadius??12,a=document.createElement("canvas");if(typeof a.captureStream!="function")return null;const s=a.getContext("2d");if(!s)return null;const d="filter"in s,c=document.createElement("video");c.muted=!0,c.playsInline=!0,c.srcObject=o,await vt(c),a.width=c.videoWidth,a.height=c.videoHeight,await yt(c);let l=0;const r=()=>{no(s,c,t,a.width,a.height,n,d),l=requestAnimationFrame(r)};r();const h=a.captureStream(i);return{stream:h,stop:()=>{l&&cancelAnimationFrame(l),l=0,h.getTracks().forEach(f=>f.stop()),c.pause(),c.srcObject=null}}}const wt="This browser cannot blur the areas you picked, so the recording was not started.";function kt(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function U(){if(typeof MediaRecorder>"u")return"";const o=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of o)if(MediaRecorder.isTypeSupported(t))return t;return""}function qt(o={}){const t=o.maxDuration??15,e=o.videoBitsPerSecond??8e5,i=o.redactionElements??[],n=o.redactionBlurRadius;let a=null,s=null,d=null,c=null,l=[],r=null,h=null,f=null,m=0,g=null,y=null,k=!1,C=null;function p(){f!==null&&(clearInterval(f),f=null),C!==null&&(clearTimeout(C),C=null),s&&(s.stop(),s=null),d&&(d.stop(),d=null),a&&(a.getTracks().forEach(w=>w.stop()),a=null),c=null,l=[],r=null,h=null,g=null,y=null}function q(){k||(k=!0,c&&c.state!=="inactive"&&c.stop())}return{async start(){k=!1,l=[];const w=U();if(!w)throw new Error("No supported video MIME type found");a=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15,displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",monitorTypeSurfaces:"exclude",surfaceSwitching:"exclude"});const S=a.getVideoTracks()[0],B=S?.getSettings?.()?.displaySurface;if(B==="monitor"||B==="window")throw a.getTracks().forEach(b=>b.stop()),a=null,new Error("qaid records only the current tab — please share this tab, not a window or your whole screen.");S&&S.addEventListener("ended",()=>{q()});let T=a;if(Ge()){const b=await oo(a);b&&(s=b,T=b.stream)}if(i.length>0){const b=await ao(T,i,{blurRadius:n});if(!b)throw s&&(s.stop(),s=null),a.getTracks().forEach(D=>D.stop()),a=null,new Error(wt);d=b,T=b.stream}c=new MediaRecorder(T,{mimeType:w,videoBitsPerSecond:e}),c.ondataavailable=b=>{b.data.size>0&&l.push(b.data)},c.onstop=()=>{const b=new Blob(l,{type:w});g&&g(b),h&&h(b),s&&(s.stop(),s=null),d&&(d.stop(),d=null),a&&a.getTracks().forEach(D=>D.stop())},c.onerror=()=>{y&&y(new Error("MediaRecorder error"))},c.start(1e3),m=Date.now(),f=setInterval(()=>{const b=Math.floor((Date.now()-m)/1e3);r&&r(b)},1e3),C=setTimeout(()=>{q()},t*1e3)},stop(){return new Promise((w,S)=>{g=w,y=S,q()})},onTick(w){r=w},onStop(w){h=w},destroy(){q(),p()}}}const xt=Object.freeze(Object.defineProperty({__proto__:null,REDACTION_UNAVAILABLE:wt,createVideoRecorder:qt,getSupportedMimeType:U,isVideoRecordingSupported:kt},Symbol.toStringTag,{value:"Module"})),Ct="https://qaid.dev/lib/html2canvas.min.js",so=1e4,ro=50;let I=null;function St(){if(typeof document>"u"||typeof window>"u")return!1;const o=document.createElement("canvas");return typeof o.getContext=="function"&&!!o.getContext("2d")}function co(){return window.html2canvas?Promise.resolve(!0):I||(I=new Promise(o=>{if(!document.querySelector(`script[src="${Ct}"]`)){const n=document.createElement("script");n.src=Ct,n.async=!0,document.head.appendChild(n)}const e=Date.now(),i=()=>{if(window.html2canvas){o(!0);return}if(Date.now()-e>so){I=null,o(!1);return}setTimeout(i,ro)};i()}),I)}async function Et(o={}){const{quality:t=.8,maxWidth:e=1280,maxHeight:i=800}=o;try{if(!await co()||!window.html2canvas)return console.warn("html2canvas failed to load"),null;const a=await window.html2canvas(document.body,{useCORS:!0,allowTaint:!1,logging:!1,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,x:window.scrollX,y:window.scrollY,ignoreElements:l=>l instanceof HTMLElement?l.classList.contains("qaid-buttons")||l.classList.contains("qaid-targeting-overlay")||l.classList.contains("qaid-modal-container")||l.classList.contains("qaid-bottom-sheet")||l.classList.contains("qaid-backdrop")||l.classList.contains("qaid-selected-marker")||l.classList.contains("qaid-tooltip-text")||l.classList.contains("qaid-recording-indicator")||l.classList.contains("qaid-video-preview")||l.className?.toString().startsWith?.("qaid-"):!1}),s=a.width,d=a.height,c=Math.min(e/s,i/d,1);if(c<1){const l=Math.round(s*c),r=Math.round(d*c),h=document.createElement("canvas");h.width=l,h.height=r;const f=h.getContext("2d");return f?(f.drawImage(a,0,0,l,r),h.toDataURL("image/webp",t)):null}return a.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const Tt=Object.freeze(Object.defineProperty({__proto__:null,captureDomScreenshot:Et,isDomScreenshotSupported:St},Symbol.toStringTag,{value:"Module"})),lo=".qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:var(--qaid-font-size, 16px);font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:calc(var(--qaid-font-size, 16px) * .8125);line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:calc(var(--qaid-font-size, 16px) * .8125);font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}.qaid-annotate-colors{display:flex;gap:.25rem;align-items:center}button.qaid-annotate-swatch{width:28px;height:28px;min-width:28px;padding:0;border-radius:9999px;border:2px solid light-dark(#d1d5db,#4b5563);background:var(--qaid-swatch, #000);cursor:pointer;-webkit-appearance:none;appearance:none;transition:transform .1s,box-shadow .15s,border-color .15s}button.qaid-annotate-swatch:hover{transform:scale(1.12)}button.qaid-annotate-swatch[aria-pressed=true]{border-color:light-dark(#111827,#f9fafb);box-shadow:0 0 0 2px var(--qaid-swatch)}@media(forced-colors:active){button.qaid-annotate-swatch[aria-pressed=true]{outline:2px solid Highlight;outline-offset:1px}}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6365f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6365f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6365f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}",A=12,ho="#ef4444",uo=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"],po={"#ef4444":"red","#f59e0b":"amber","#22c55e":"green","#3b82f6":"blue","#111827":"black","#ffffff":"white","#6365f1":"indigo","#6366f1":"indigo"};function At(o){return po[o.toLowerCase()]??o}const fo=4,mo=.8,bo={title:"Annotate screenshot",instructions:"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",rectangle:"Rectangle",arrow:"Arrow",pen:"Pen",blur:"Blur or redact",undo:"Undo last",skip:"Skip annotation",done:"Done",colors:"Drawing colour"};function P(o,t){return{x:Math.min(o.x,t.x),y:Math.min(o.y,t.y),w:Math.abs(o.x-t.x),h:Math.abs(o.y-t.y)}}function go(o){if(o.type==="pen")return o.points.length<2;const t=P(o.points[0],o.points[1]);return t.w<3&&t.h<3}function vo(o,t,e,i){o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(e.x,e.y),o.stroke();const n=Math.atan2(e.y-t.y,e.x-t.x),a=Math.max(10,i*3);o.beginPath(),o.moveTo(e.x,e.y),o.lineTo(e.x-a*Math.cos(n-Math.PI/6),e.y-a*Math.sin(n-Math.PI/6)),o.moveTo(e.x,e.y),o.lineTo(e.x-a*Math.cos(n+Math.PI/6),e.y-a*Math.sin(n+Math.PI/6)),o.stroke()}function yo(o,t){if(t.length!==0){o.beginPath(),o.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)o.lineTo(t[e].x,t[e].y);o.stroke()}}function wo(o,t,e,i,n){o.fillStyle="rgb(15, 23, 42)",o.fillRect(t,e,i,n),o.fillStyle="rgb(37, 47, 63)";for(let a=e;a<e+n;a+=A)for(let s=t;s<t+i;s+=A)(Math.floor((s-t)/A)+Math.floor((a-e)/A))%2===0&&o.fillRect(s,a,Math.min(A,t+i-s),Math.min(A,e+n-a))}function R(o,t){switch(o.save(),o.strokeStyle=t.color,o.fillStyle=t.color,o.lineWidth=t.strokeWidth,o.lineJoin="round",o.lineCap="round",t.type){case"rect":{const e=P(t.points[0],t.points[1]);o.strokeRect(e.x,e.y,e.w,e.h);break}case"arrow":vo(o,t.points[0],t.points[1],t.strokeWidth);break;case"pen":yo(o,t.points);break;case"blur":{const e=P(t.points[0],t.points[1]);wo(o,e.x,e.y,e.w,e.h);break}}o.restore()}function Lt(o){return new Promise((t,e)=>{const i=new Image;i.onload=()=>t(i),i.onerror=()=>e(new Error("Failed to load screenshot")),i.src=o})}async function j(o,t,e={}){const i=e.quality??mo;let n;try{n=await Lt(o)}catch{return o}const a=document.createElement("canvas");a.width=n.naturalWidth||n.width||1,a.height=n.naturalHeight||n.height||1;const s=a.getContext("2d");if(!s)return o;s.drawImage(n,0,0,a.width,a.height);for(const d of t)R(s,d);return a.toDataURL("image/webp",i)}let ko=0;class K{shapes=[];tool="rect";opts;labels;color;palette;strokeWidth;uid=`qaid-annotate-${++ko}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...bo,...t.labels??{}},this.color=t.color??ho,this.palette=(t.palette&&t.palette.length?t.palette:uo).slice(),this.palette.some(e=>e.toLowerCase()===this.color.toLowerCase())||this.palette.unshift(this.color),this.strokeWidth=t.strokeWidth??fo}open(){const t=new Promise(e=>{this.resolveResult=e});return this.mount(),t}toolButton(t,e,i){const n=x("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${i} tool`,title:i});return n.innerHTML=`${e}<span class="qaid-annotate-btn-text">${i}</span>`,n}swatchButton(t){const e=At(t),i=x("button",{type:"button",class:"qaid-annotate-swatch","data-qaid-color":t,"aria-pressed":t.toLowerCase()===this.color.toLowerCase()?"true":"false","aria-label":`Draw in ${e}`,title:e});return i.style.setProperty("--qaid-swatch",t),i}actionButton(t,e,i,n){const a=x("button",{type:"button",class:`qaid-annotate-action ${n}`,"data-qaid-action":t,"aria-label":i,title:i});return a.innerHTML=`${e}<span class="qaid-annotate-btn-text">${i}</span>`,a}mount(){const t=`${this.uid}-title`,e=`${this.uid}-desc`;this.container=x("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const i=x("h2",{id:t,class:"qaid-annotate-title"});i.textContent=this.labels.title;const n=x("p",{id:e,class:"qaid-annotate-desc"});n.textContent=this.labels.instructions;const a=x("div",{class:"qaid-annotate-stage"});this.canvas=document.createElement("canvas"),this.canvas.className="qaid-annotate-canvas",this.canvas.width=1,this.canvas.height=1,this.canvas.setAttribute("role","img"),this.canvas.setAttribute("aria-label",this.labels.title),this.ctx=this.canvas.getContext("2d"),a.appendChild(this.canvas),this.toolbar=x("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const s=x("div",{class:"qaid-annotate-tools"});s.appendChild(this.toolButton("rect",fe,this.labels.rectangle)),s.appendChild(this.toolButton("arrow",me,this.labels.arrow)),s.appendChild(this.toolButton("pen",be,this.labels.pen)),s.appendChild(this.toolButton("blur",ge,this.labels.blur));const d=x("div",{class:"qaid-annotate-colors",role:"group","aria-label":this.labels.colors});for(const h of this.palette)d.appendChild(this.swatchButton(h));this.undoBtn=this.actionButton("undo",ve,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const c=this.actionButton("skip",we,this.labels.skip,"qaid-annotate-skip"),l=this.actionButton("done",et,this.labels.done,"qaid-annotate-done"),r=x("div",{class:"qaid-annotate-actions"});r.appendChild(this.undoBtn),r.appendChild(c),r.appendChild(l),this.toolbar.appendChild(s),this.toolbar.appendChild(d),this.toolbar.appendChild(r),this.container.appendChild(i),this.container.appendChild(n),this.container.appendChild(a),this.container.appendChild(this.toolbar),this.opts.root.appendChild(this.container),this.toolbar.addEventListener("click",this.onToolbarClick),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp),this.container.addEventListener("keydown",this.onKeyDown),this.opts.openDialog?.(this.container,{labelledbyId:t,describedbyId:e}),this.opts.announce?.(this.labels.instructions),Lt(this.opts.dataUrl).then(h=>{this.img=h,this.canvas.width=h.naturalWidth||h.width||1,this.canvas.height=h.naturalHeight||h.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const e=this.canvas.getBoundingClientRect(),i=this.canvas.width/(e.width||this.canvas.width),n=this.canvas.height/(e.height||this.canvas.height);return{x:(t.clientX-e.left)*i,y:(t.clientY-e.top)*n}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const e of this.shapes)R(t,e);this.current&&R(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(n=>{n.setAttribute("aria-pressed",n.getAttribute("data-qaid-tool")===t?"true":"false")});const i=this.labels[qo[t]];this.opts.announce?.(`${i} tool selected`)}selectColor(t){this.color=t,this.toolbar.querySelectorAll("[data-qaid-color]").forEach(i=>{i.setAttribute("aria-pressed",(i.getAttribute("data-qaid-color")??"").toLowerCase()===t.toLowerCase()?"true":"false")}),this.opts.announce?.(`${At(t)} colour selected`)}onToolbarClick=t=>{const i=t.target?.closest("[data-qaid-tool],[data-qaid-action],[data-qaid-color]");if(!i)return;const n=i.getAttribute("data-qaid-color");if(n){this.selectColor(n);return}const a=i.getAttribute("data-qaid-tool");if(a){this.selectTool(a);return}const s=i.getAttribute("data-qaid-action");s==="undo"?this.undo():s==="skip"?this.skip():s==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const e=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[e]:[e,{...e}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const e=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(e):this.current.points[1]=e,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,go(t)){this.redraw();return}this.shapes.push(t),this.undoBtn.disabled=!1,this.opts.announce?.("Annotation added"),this.redraw()};onKeyDown=t=>{if(t.key==="Escape"){t.preventDefault(),this.skip();return}if(t.key==="Enter"){const e=t.target;if(e?.getAttribute("data-qaid-tool")||e?.getAttribute("data-qaid-action"))return;t.preventDefault(),this.done()}};undo(){if(this.shapes.length===0){this.opts.announce?.("Nothing to undo");return}this.shapes.pop(),this.undoBtn.disabled=this.shapes.length===0,this.opts.announce?.("Removed last annotation"),this.redraw()}async done(){if(this.settled)return;const t=await j(this.opts.dataUrl,this.shapes,{quality:this.opts.quality});this.opts.announce?.("Annotated screenshot attached"),this.settle(t)}skip(){this.settled||(this.opts.announce?.("Annotation skipped"),this.settle(null))}settle(t){this.settled=!0,this.teardown(),this.resolveResult(t)}teardown(){this.toolbar.removeEventListener("click",this.onToolbarClick),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.container.removeEventListener("pointermove",this.onPointerMove),this.container.removeEventListener("pointerup",this.onPointerUp),this.container.removeEventListener("keydown",this.onKeyDown),this.opts.closeDialog?.(),this.container.remove()}}const qo={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function Dt(o){return new K(o).open()}const Mt=Object.freeze(Object.defineProperty({__proto__:null,AnnotationEditor:K,compositeAnnotations:j,drawShape:R,openAnnotationEditor:Dt,rectFromPoints:P,styles:lo},Symbol.toStringTag,{value:"Module"}));Xe();const xo=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function Co(o){return o.hasAttribute("disabled")?!0:o.disabled===!0}function So(o){let t=o;for(;t;){if(t.hasAttribute("hidden"))return!0;const e=t.style;if(e&&(e.display==="none"||e.visibility==="hidden"||e.visibility==="collapse"))return!0;t=t.parentElement}return!1}function W(o){return Array.from(o.querySelectorAll(xo)).filter(e=>!(e.getAttribute("tabindex")==="-1"||e instanceof HTMLInputElement&&e.type==="hidden"||e instanceof HTMLAnchorElement&&!e.getAttribute("href")||Co(e)||So(e)))}function It(o){let t=o.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function Pt(o){const t=o.ownerDocument||document;let e=!1;const i=a=>{if(a.key!=="Tab")return;const s=W(o);if(s.length===0){a.preventDefault(),o.focus();return}const d=s[0],c=s[s.length-1],l=It(t),r=l?s.indexOf(l)!==-1:!1;a.shiftKey?(!r||l===d)&&(a.preventDefault(),c.focus()):(!r||l===c)&&(a.preventDefault(),d.focus())};o.addEventListener("keydown",i);const n=W(o);return n.length>0?n[0].focus():(o.hasAttribute("tabindex")||(o.setAttribute("tabindex","-1"),e=!0),o.focus()),{release(){o.removeEventListener("keydown",i),e&&(o.removeAttribute("tabindex"),e=!1)}}}function Rt(){return It(document)}function Bt(o){if(!(!o||typeof o.focus!="function"))try{o.focus()}catch{}}function Ht(o,t={}){o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),t.labelledbyId&&o.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&o.setAttribute("aria-describedby",t.describedbyId),t.label&&o.setAttribute("aria-label",t.label)}function Eo(o,t){let e=o;for(;e&&e!==t;){const i=e.parentNode;if(i===t)return e;if(i&&i.host){e=i.host;continue}if(!i)return null;e=i}return null}function Ot(o){const e=(o.ownerDocument||document).body;if(!e)return()=>{};const i=Eo(o,e),n=[];return Array.from(e.children).forEach(a=>{if(!(a instanceof HTMLElement)||i&&a===i)return;const s=a.inert===!0,d=a.getAttribute("aria-hidden");s&&d==="true"||(a.inert=!0,a.setAttribute("aria-hidden","true"),n.push({el:a,prevInert:s,prevAriaHidden:d}))}),function(){for(;n.length;){const s=n.pop();s.el.inert=s.prevInert,s.prevAriaHidden===null?s.el.removeAttribute("aria-hidden"):s.el.setAttribute("aria-hidden",s.prevAriaHidden)}}}function To(o,t){const e=Rt();Ht(o,t);const i=Pt(o),n=Ot(o);return()=>{i.release(),n(),Bt(e)}}const zt=Object.freeze(Object.defineProperty({__proto__:null,applyDialog:Ht,createFocusTrap:Pt,getFocusable:W,openDialog:To,restoreFocus:Bt,saveFocus:Rt,setBackgroundInert:Ot},Symbol.toStringTag,{value:"Module"})),$t=o=>import(o);let _t=$t,L=null,$=null;const _=new Map,F=new Map;function Ao(o){_t=o??$t,L=null,$=null,_.clear(),F.clear()}function Ft(o,t){return`${o.replace(/\/+$/,"")}/${encodeURIComponent(t)}/definition`}function Lo(o){if(_.has(o))return Promise.resolve();const t=F.get(o);if(t)return t;const e=fetch(o,{headers:{Accept:"application/json"}}).then(i=>i.ok?i.json():null).then(i=>{i&&_.set(o,i)}).catch(()=>{}).finally(()=>{F.delete(o)});return F.set(o,e),e}function Vt(o){return L&&$===o||($=o,L=Promise.resolve(_t(o)).then(t=>{const e=t;if(!e||typeof e.QaidQuests!="function")throw new Error("quests module has no QaidQuests export");return e}).catch(t=>{throw L=null,$=null,t})),L}async function Nt(o){const t=await Vt(o.moduleUrl),e=o.base.replace(/\/+$/,""),i=Ft(e,o.questId),n=d=>d!=null?{feedbackId:d}:void 0;let a;const s=o.feedbackId;return s instanceof Promise?a=t.QaidQuests.supports?.asyncMetadata?s.then(n,()=>{}):n(await s.catch(()=>null)):a=n(s??null),new t.QaidQuests({endpoint:`${e}/responses`,configUrl:i,questionnaire:_.get(i),apiKey:o.apiKey||void 0,metadata:a,onClose:o.onClose})}const Do=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_QUESTS_MODULE_URL:st,_setQuestsImporter:Ao,launchQuest:Nt,loadQuestsModule:Vt,prefetchQuestDefinition:Lo,questDefinitionUrl:Ft},Symbol.toStringTag,{value:"Module"}));async function Ut(o,t){const e=o.ensureOverlayHost(),i=o.overlayShadowHost,n=i.style.pointerEvents;i.style.pointerEvents="auto";try{const{openAnnotationEditor:a,styles:s}=await Promise.resolve().then(()=>Mt);return o.addFeatureStyles(s),await a({dataUrl:t,root:e,quality:o.config.screenshotOptions.quality,color:o.config.annotationColor,palette:o.config.annotationPalette,applyVars:d=>o.applyVars(d),announce:(d,c)=>o.announceMsg(d,c),openDialog:(d,c)=>o.openDialogA11y(d,c),closeDialog:()=>o.closeDialogA11y()})}catch(a){return console.error("Annotation editor failed to open:",a),null}finally{i.style.pointerEvents=n}}async function Mo(o){const{config:t,feedbackData:e,selectedBounds:i}=o;let n=null;if(t.captureScreenshot||t.feedbackMode==="annotate")try{if(o.shouldCaptureViaDom()){const{captureDomScreenshot:r}=await Promise.resolve().then(()=>Tt);n=await r(t.screenshotOptions)}else{const{captureScreenshot:r}=await Promise.resolve().then(()=>Gt);n=await r(t.screenshotOptions)}n&&o.announceMsg("Screenshot captured")}catch(r){console.error("Screenshot capture failed:",r),n=null}n&&t.annotate&&(n=await Ut(o,n)??n);const s=e.elementSelector?{x:i.x,y:i.y,width:i.width,height:i.height}:null,d={feedbackType:e.feedbackType,pageUrl:window.location.href,apiKey:t.apiKey||void 0,elementSelector:e.elementSelector,elementText:e.elementText,consoleErrors:[...e.consoleErrors],screenWidth:window.innerWidth,screenHeight:window.innerHeight,clickX:i.clickX,clickY:i.clickY,scrollX:window.scrollX,scrollY:window.scrollY,screenshot:n,visitorId:o.visitorId,elementBounds:s,userAgent:navigator.userAgent},c=Io(o,d);o.setFeedbackId(c);const l=e.feedbackType;if(l&&l!=="neutral"&&await jt(o,l,c)){o.resetFeedbackUi();return}o.setState("MODAL_OPEN");try{const r=await o.ensureModal();if(o.destroyed)return;r.open(),o.overlayShadowHost&&(o.overlayShadowHost.style.pointerEvents="auto")}catch(r){console.error("Failed to open the feedback modal:",r),o.announceMsg("Thank you for your feedback!",!0),o.resetFeedbackUi()}}async function Io(o,t){try{const e=await fetch(o.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(e.ok){const i=await e.json();return o.announceMsg("Feedback sent"),i.id}}catch(e){console.error("Failed to submit feedback:",e),o.announceMsg("Failed to send feedback",!0)}return null}async function jt(o,t,e){const i=o.config.quests,n=i.base&&i[t]||"";if(!n)return!1;try{return o.activeQuest?.destroy(),o.activeQuest=await Nt({questId:n,base:i.base,apiKey:i.apiKey||void 0,moduleUrl:i.moduleUrl,feedbackId:e,onClose:()=>{o.activeQuest=null}}),!0}catch(a){return console.error("Failed to launch quest:",a),o.activeQuest=null,!1}}const Q=Object.freeze(Object.defineProperty({__proto__:null,openAnnotationEditor:Ut,submitFeedback:Mo,tryLaunchQuest:jt},Symbol.toStringTag,{value:"Module"})),Kt={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function Po(o,t,e,i,n){const a=o.y,s=t-(o.y+o.height);if(s>=e+i)return{top:o.y+o.height+i,position:"below"};if(a>=e+i)return{top:o.y-e-i,position:"above"};const d=s>a?"below":"above";let c;return d==="below"?c=Math.min(o.y+o.height+i,t-e-n):c=Math.max(n,o.y-e-i),{top:c,position:d}}function Ro(o,t,e,i){let a=o.x+o.width/2-e/2;return a=Math.max(i,Math.min(a,t-e-i)),a}function Bo(o,t,e,i=24,n=24){const s=o.clickX-t-n/2;return Math.max(i,Math.min(s,e-i-n/2))}function Ho(o,t,e,i=Kt){const n=i.height+i.arrowHeight,a=Po(o,e,n,i.gap,i.viewportPadding),s=Ro(o,t,i.width,i.viewportPadding);return{top:a.top,left:s,position:a.position}}function Oo(o,t,e,i=Kt){const n=Ho(o,t,e,i),a=Bo(o,n.left,i.width);return{modal:n,arrow:{left:a}}}const zo=document;function u(o,t,...e){const i=zo.createElement(o);if(t){if(t.class&&(i.className=t.class),t.style&&(i.style.cssText=t.style),t.html!=null&&(i.innerHTML=t.html),t.text!=null&&(i.textContent=t.text),t.attrs)for(const n in t.attrs)i.setAttribute(n,t.attrs[n]);if(t.on)for(const n in t.on)i.addEventListener(n,t.on[n])}for(const n of e)n!=null&&n!==!1&&i.append(n);return i}const $o=".qaid-backdrop{position:fixed;inset:0;z-index:45;background:#0000004d}.qaid-modal-container{position:fixed;z-index:50;display:flex;flex-direction:column;align-items:flex-start;max-height:calc(100vh - 32px);font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-modal-container.qaid-above{flex-direction:column-reverse}.qaid-modal-arrow{width:0;height:0;border-left:12px solid transparent;border-right:12px solid transparent;position:relative;align-self:flex-start}.qaid-modal-container.qaid-below .qaid-modal-arrow{border-bottom:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-container.qaid-above .qaid-modal-arrow{border-top:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5));width:var(--qaid-modal-width, 400px);max-width:calc(100vw - 32px);max-height:calc(100vh - 60px);overflow-y:auto}.qaid-modal-header{display:flex;align-items:flex-start;gap:.75rem;margin-bottom:1rem}button.qaid-type-toggle{border:none;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s;flex-shrink:0;-webkit-appearance:none;appearance:none}button.qaid-type-toggle:hover{transform:scale(1.1)}button.qaid-type-toggle:not(.qaid-type-toggle-custom){width:2.5rem;height:2.5rem;border-radius:50%}button.qaid-type-toggle:not(.qaid-type-toggle-custom) svg{width:1.25rem;height:1.25rem}button.qaid-type-toggle.qaid-type-up{background:var(--qaid-positive);color:#fff}button.qaid-type-toggle.qaid-type-down{background:var(--qaid-negative);color:#fff}.qaid-type-static{width:2.5rem;height:2.5rem;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:var(--qaid-marker, #6365f1);color:var(--qaid-marker-text, white)}.qaid-type-static svg{width:1.25rem;height:1.25rem}.qaid-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size:calc(var(--qaid-font-size, 16px) * 1.125);font-weight:700;margin:0 0 .25rem;color:light-dark(#1f2937,#f9fafb)}.qaid-modal-subtitle{color:light-dark(#6b7280,#9ca3af);margin:0;font-size:calc(var(--qaid-font-size, 16px) * .875)}.qaid-textarea{width:100%;height:6rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:var(--qaid-font-size, 16px);resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-btn-row{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-btn-submit{padding:.5rem 1rem;background:var(--qaid-marker);color:var(--qaid-marker-text, white);border:none;border-radius:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-btn-submit:hover{filter:brightness(.85)}button.qaid-btn-submit:focus{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 30%,transparent)}.qaid-bottom-sheet{position:fixed;bottom:0;left:0;right:0;z-index:50;animation:qaid-slideUpSheet .3s ease-out;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-bottom-sheet-content{background:light-dark(#ffffff,#1f2937);border-radius:1rem 1rem 0 0;padding:1.5rem;padding-bottom:max(1.5rem,env(safe-area-inset-bottom))}.qaid-bottom-sheet-handle{width:36px;height:4px;background:light-dark(rgba(0,0,0,.2),rgba(255,255,255,.2));border-radius:2px;margin:0 auto 1rem}@keyframes qaid-slideUpSheet{0%{transform:translateY(100%)}to{transform:translateY(0)}}.qaid-confirm{display:flex;flex-direction:column;align-items:center;text-align:center;gap:.5rem;padding:.5rem 0}.qaid-confirm-icon{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:9999px;color:#fff;background:var(--qaid-success, #22c55e);margin-bottom:.25rem;animation:qaid-confirm-pop .28s cubic-bezier(.34,1.56,.64,1)}.qaid-confirm-icon .qaid-icon{width:24px;height:24px}.qaid-confirm-error .qaid-confirm-icon{background:var(--qaid-error, #dc2626)}.qaid-confirm-title{margin:0;font-size:var(--qaid-font-size, 16px);font-weight:600;color:var(--qaid-text, light-dark(#111827, #f9fafb))}.qaid-confirm-title:focus-visible{outline:2px solid var(--qaid-primary, #6365f1);outline-offset:3px;border-radius:4px}.qaid-confirm-message{margin:0;font-size:calc(var(--qaid-font-size, 16px) * .875);color:var(--qaid-text-muted, light-dark(#6b7280, #9ca3af))}.qaid-confirm .qaid-confirm-close{margin-top:.5rem;min-width:96px}@keyframes qaid-confirm-pop{0%{transform:scale(.6);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.qaid-confirm-icon{animation:none}}.qaid-textarea:focus-visible,button.qaid-btn-submit:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}@media(forced-colors:active){.qaid-textarea:focus,button.qaid-btn-submit:focus{outline:2px solid CanvasText;outline-offset:2px}}";class _o{constructor(t){this.host=t}host;modalContainer=null;backdrop=null;finalized=!1;open(){this.finalized=!1;const t=this.host.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.host.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.host.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.close()),this.host.applyVars(this.backdrop),this.host.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.host.boundKeyDown)}close(){this.host.state==="MODAL_OPEN"&&!this.finalized&&(this.finalized=!0,this.host.whenFeedbackId().then(t=>{t&&fetch(`${this.host.config.endpoint}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(e=>console.error("Failed to finalize feedback:",e))})),this.teardown(),this.host.resetFeedbackUi()}destroy(){this.teardown()}teardown(){this.host.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.host.boundKeyDown)}showBottomSheet(){const t=this.host.ensureOverlayHost(),e=document.createElement("div");e.className="qaid-bottom-sheet",e.style.zIndex=String(this.host.config.zIndex+3),e.appendChild(u("div",{class:"qaid-bottom-sheet-content"},u("div",{class:"qaid-bottom-sheet-handle"}),this.buildModalContent())),this.host.applyVars(e),t.appendChild(e),this.modalContainer=e,this.setupModalInteractions()}showPositionedModal(){const t=this.host.ensureOverlayHost(),{modal:e,arrow:i}=Oo(this.host.selectedBounds,window.innerWidth,window.innerHeight,{width:this.host.config.modalWidth,height:280,arrowHeight:12,gap:8,viewportPadding:16});this.modalContainer=document.createElement("div"),this.modalContainer.className=`qaid-modal-container qaid-${e.position}`,this.modalContainer.style.top=`${e.top}px`,this.modalContainer.style.left=`${e.left}px`,this.modalContainer.style.zIndex=String(this.host.config.zIndex+3);const n=document.createElement("div");n.className="qaid-modal-arrow",n.style.left=`${i.left}px`;const a=document.createElement("div");a.className="qaid-modal-box",a.appendChild(this.buildModalContent()),this.modalContainer.appendChild(n),this.modalContainer.appendChild(a),this.host.applyVars(this.modalContainer),t.appendChild(this.modalContainer),this.setupModalInteractions()}buildModalContent(){const{config:t,uid:e}=this.host,i=t.text,n=this.host.feedbackData.feedbackType,a=n==="up",s=t.positiveIcon||E,d=t.negativeIcon||V,c=t.buttonClass?`qaid-type-toggle qaid-type-toggle-custom ${t.buttonClass} ${a?"qaid-btn-up":"qaid-btn-down"}`:`qaid-type-toggle ${a?"qaid-type-up":"qaid-type-down"}`,l=a?"Feedback type: positive":"Feedback type: negative",r=n==="neutral"?u("span",{class:"qaid-type-static",html:t.feedbackIcon||tt,attrs:{"aria-hidden":"true"}}):u("button",{class:c,html:a?s:d,attrs:{type:"button",title:"Click to switch","aria-pressed":String(a),"aria-label":l}}),h=document.createDocumentFragment();return h.append(u("div",{class:"qaid-modal-header"},r,u("div",{class:"qaid-modal-header-text"},u("h3",{class:"qaid-modal-title",text:i.modalTitle,attrs:{id:`qaid-modal-title-${e}`}}),u("p",{class:"qaid-modal-subtitle",text:i.modalSubtitle,attrs:{id:`qaid-modal-subtitle-${e}`}}))),u("textarea",{class:"qaid-textarea",attrs:{"aria-label":i.modalSubtitle,placeholder:i.placeholder}}),u("div",{class:"qaid-btn-row"},u("button",{class:"qaid-btn-submit",text:i.skipButton,attrs:{type:"button"}}))),h}setupModalInteractions(){this.host.openDialogA11y(this.modalContainer,{labelledbyId:`qaid-modal-title-${this.host.uid}`,describedbyId:`qaid-modal-subtitle-${this.host.uid}`});const t=this.modalContainer.querySelector(".qaid-textarea"),e=this.modalContainer.querySelector(".qaid-btn-submit");t&&(setTimeout(()=>t.focus(),100),t.addEventListener("input",()=>{e&&(e.textContent=t.value.trim()?this.host.config.text.submitButton:this.host.config.text.skipButton)})),e&&e.addEventListener("click",()=>{const n=t?.value.trim()||null;this.submitMessage(n)});const i=this.modalContainer.querySelector(".qaid-type-toggle");i&&i.addEventListener("click",()=>{const n=this.host.feedbackData.feedbackType==="up"?"down":"up";this.host.feedbackData.feedbackType=n,this.host.config.buttonClass?(i.classList.toggle("qaid-btn-up",n==="up"),i.classList.toggle("qaid-btn-down",n==="down")):(i.classList.toggle("qaid-type-up",n==="up"),i.classList.toggle("qaid-type-down",n==="down"));const a=this.host.config.positiveIcon||E,s=this.host.config.negativeIcon||V;i.innerHTML=n==="up"?a:s;const d=n==="up"?"Feedback type: positive":"Feedback type: negative";i.setAttribute("aria-pressed",String(n==="up")),i.setAttribute("aria-label",d),this.host.announceMsg(d),this.host.whenFeedbackId().then(c=>{c&&fetch(`${this.host.config.endpoint}/${c}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedbackType:n})}).catch(l=>console.error("Failed to update feedback type:",l))})})}async submitMessage(t){let e=null;this.finalized=!0;const i=await this.host.whenFeedbackId();if(i)try{const n=await fetch(`${this.host.config.endpoint}/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t})});e=n.ok,n.ok||console.error("Failed to submit feedback message: HTTP",n.status)}catch(n){console.error("Failed to submit feedback message:",n),e=!1}if(e===!1){this.showResult(!1);return}if(e&&!this.host.config.hideConfirmation){this.showResult(!0);return}this.close()}showResult(t){const e=this.modalContainer?.querySelector(".qaid-modal-box")??this.modalContainer?.querySelector(".qaid-bottom-sheet-content")??this.modalContainer;if(!e){this.close();return}const i=this.host.config.text,n=t?i.confirmationTitle:i.errorTitle,a=t?i.confirmationMessage:i.errorMessage,s=u("h3",{class:"qaid-confirm-title",text:n,attrs:{id:`qaid-confirm-title-${this.host.uid}`,tabindex:"-1"}});e.textContent="",e.appendChild(u("div",{class:t?"qaid-confirm":"qaid-confirm qaid-confirm-error"},u("span",{class:"qaid-confirm-icon",html:t?et:ye,attrs:{"aria-hidden":"true"}}),s,u("p",{class:"qaid-confirm-message",text:a}),u("button",{class:"qaid-btn-submit qaid-confirm-close",text:i.confirmationClose,attrs:{type:"button"},on:{click:()=>this.close()}}))),requestAnimationFrame(()=>s.focus()),this.host.announceMsg(`${n} ${a}`,!0)}}const Wt=Object.freeze(Object.defineProperty({__proto__:null,ModalController:_o,styles:$o},Symbol.toStringTag,{value:"Module"})),Qt=["data-comp","data-qa","data-testid","data-id"];function Xt(o,t=document.body){let e=o;for(;e&&e!==t;){for(const i of Qt){const n=e.getAttribute(i);if(n)return`${i}="${n}"`}e=e.parentElement}return null}function Fo(o,t=100){const e=o.textContent?.trim().slice(0,t)||"";return e.length===t?e+"...":e}function Vo(o){let t=1,e=o.previousElementSibling;for(;e;)t++,e=e.previousElementSibling;return t}function No(o){const t=[];let e=o;for(;e&&e!==document.body&&e!==document.documentElement;){const i=e.tagName.toLowerCase(),n=Vo(e);t.unshift(`${i}:nth-child(${n})`),e=e.parentElement}return t.length>0?`body > ${t.join(" > ")}`:"body"}function Uo(o){return o.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function jo(o){const t=Xt(o);return t?`[${t}]`:o.id?`#${Uo(o.id)}`:No(o)}function X(o){const t=Fo(o),e=Xt(o);return{selector:jo(o),text:t,dataAttr:e}}const Ko=["a[href]","button","input:not([type=hidden])","select","textarea","summary","[tabindex]","[role]","img","h1","h2","h3","h4","h5","h6","p","li","label",...Qt.map(o=>`[${o}]`)].join(","),Wo=/^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;function Qo(o){if(o.hasAttribute("hidden")||o.getAttribute("aria-hidden")==="true")return!1;const t=o.ownerDocument?.defaultView;if(t&&typeof t.getComputedStyle=="function"){const e=t.getComputedStyle(o);if(e.display==="none"||e.visibility==="hidden")return!1}return!0}function Xo(o={}){const t=o.root??document.body,e=o.selector??Ko,i=o.isExcluded??(()=>!1),n=o.isVisible??Qo;return Array.from(t.querySelectorAll(e)).filter(a=>!i(a)&&n(a))}function Yo(o){const t=o.candidates??Xo({root:o.root,selector:o.selector,isExcluded:o.isExcluded,isVisible:o.isVisible}),e=o.moveFocus??!0,i=o.eventTarget??document,n=new Set;let a=-1,s=!1;const d=o.initial!==void 0?o.initial:typeof document<"u"?document.activeElement:null;if(d){const p=t.indexOf(d);p>=0&&(a=p)}a<0&&t.length>0&&(a=0);function c(p){if(!e)return;const q=p;if(typeof q.focus=="function"){p.getAttribute("tabindex")===null&&!Wo.test(p.tagName)&&(p.setAttribute("tabindex","-1"),n.add(p));try{q.focus()}catch{}}}function l(){const p=t[a];p&&(c(p),o.onHighlight?.(p,a))}function r(p){if(s||t.length===0)return;const q=t.length;a=(p%q+q)%q,l()}function h(){r(a+1)}function f(){r(a-1)}function m(){return t[a]??null}function g(){s||(s=!0,i.removeEventListener("keydown",C,!0),n.forEach(p=>p.removeAttribute("tabindex")),n.clear())}function y(){if(s)return;const p=m();g(),p&&o.onSelect(p)}function k(){s||(g(),o.onCancel?.())}function C(p){if(!s)switch(p.key){case"Tab":p.preventDefault(),p.stopPropagation(),p.shiftKey?f():h();break;case"ArrowDown":case"ArrowRight":p.preventDefault(),p.stopPropagation(),h();break;case"ArrowUp":case"ArrowLeft":p.preventDefault(),p.stopPropagation(),f();break;case"Enter":case" ":case"Spacebar":p.preventDefault(),p.stopPropagation(),y();break;case"Escape":case"Esc":p.preventDefault(),p.stopPropagation(),k();break}}return i.addEventListener("keydown",C,!0),a>=0&&l(),{candidates:t,getIndex:()=>a,getCurrent:m,next:h,prev:f,moveTo:r,select:y,cancel:k,handleKey:C,stop:g}}const Jo=".qaid-targeting-overlay{position:fixed;inset:0;z-index:40;pointer-events:none}.qaid-capture-layer{position:fixed;inset:0;pointer-events:none;z-index:9999}.qaid-vignette{position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at center,transparent 30%,rgba(0,0,0,.3) 70%,rgba(0,0,0,.6) 100%);z-index:41}.qaid-crosshair-h,.qaid-crosshair-v{position:fixed;pointer-events:none;z-index:42}.qaid-crosshair-h{left:0;right:0;height:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-crosshair-v{top:0;bottom:0;width:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-type-up .qaid-crosshair-h,.qaid-type-up .qaid-crosshair-v{background:color-mix(in srgb,var(--qaid-positive) 60%,transparent)}.qaid-highlight-box{position:fixed;top:0;left:0;pointer-events:none;z-index:41;display:none;border:3px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:2px;background:color-mix(in srgb,var(--qaid-negative) 8%,transparent);will-change:transform,width,height}.qaid-type-up .qaid-highlight-box{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent);background:color-mix(in srgb,var(--qaid-positive) 8%,transparent)}.qaid-scope{position:fixed;width:80px;height:80px;pointer-events:none;z-index:43;transform:translate(-50%,-50%)}.qaid-scope-ring{position:absolute;inset:10px;border:2px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent)}.qaid-scope-ring-inner{position:absolute;inset:20px;border:1px solid color-mix(in srgb,var(--qaid-negative) 50%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring-inner{border-color:color-mix(in srgb,var(--qaid-positive) 50%,transparent)}.qaid-scope-dot{position:absolute;top:50%;left:50%;width:4px;height:4px;background:var(--qaid-negative);border-radius:50%;transform:translate(-50%,-50%)}.qaid-type-up .qaid-scope-dot{background:var(--qaid-positive)}.qaid-selected-marker{position:fixed;border:3px solid var(--qaid-marker, #6365f1);border-radius:50%;pointer-events:none;z-index:44;animation:qaid-markerPulse 1.5s ease-in-out infinite}@keyframes qaid-markerPulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.7;transform:scale(1.05)}}@media(forced-colors:active){.qaid-selected-marker,.qaid-highlight-box{border-color:Highlight}}",Go=12;class Zo{constructor(t){this.host=t}host;mousePos={x:0,y:0};touchStartPos=null;overlayContainer=null;captureLayer=null;crosshairH=null;crosshairV=null;scope=null;highlightBox=null;marker=null;keyboardController=null;boundMouseMove=t=>this.handleMouseMove(t);boundClick=t=>this.handleClick(t);boundTouchStart=t=>this.handleTouchStart(t);boundTouchEnd=t=>this.handleTouchEnd(t);startPointer(t,e){this.host.setState("TARGETING"),this.host.feedbackData.feedbackType=t,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1,this.mousePos.x=e.clientX,this.mousePos.y=e.clientY,document.body.classList.add("qaid-targeting"),t==="up"?document.body.classList.add("qaid-type-up"):document.body.classList.remove("qaid-type-up"),document.body.style.setProperty("--qaid-positive",this.host.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.host.cssVars["--qaid-negative"]),this.createTargetingOverlay(),document.addEventListener("keydown",this.host.boundKeyDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("click",this.boundClick,!0),document.addEventListener("touchstart",this.boundTouchStart,{passive:!0}),document.addEventListener("touchend",this.boundTouchEnd,{passive:!1})}startKeyboard(t){this.host.setState("TARGETING"),this.host.feedbackData.feedbackType=t,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1,document.body.style.setProperty("--qaid-positive",this.host.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.host.cssVars["--qaid-negative"]),this.createTargetingOverlay(),this.crosshairH&&(this.crosshairH.style.display="none"),this.crosshairV&&(this.crosshairV.style.display="none"),this.scope&&(this.scope.style.display="none"),this.keyboardController=Yo({isExcluded:e=>H(e),onHighlight:e=>{const i=e.getBoundingClientRect(),n=this.highlightBox;n&&(n.style.transform=`translate(${i.left}px, ${i.top}px)`,n.style.width=`${i.width}px`,n.style.height=`${i.height}px`,n.style.display="block");const{text:a}=X(e);this.host.announceMsg(`Targeting ${a||e.tagName.toLowerCase()}`)},onSelect:e=>this.selectKeyboardTarget(e),onCancel:()=>this.cancel()})}selectKeyboardTarget(t){const e=at(t,8);Object.assign(this.host.selectedBounds,e,{clickX:e.x+e.width/2,clickY:e.y+e.height/2,visible:!0});const{selector:i,text:n}=X(t);this.host.feedbackData.elementSelector=i,this.host.feedbackData.elementText=n,this.removeTargetingOverlay(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.keyboardController=null,this.host.clearActiveThumb(),this.host.setState("SELECTED"),this.showSelectedMarker(),this.host.submitFeedback()}createTargetingOverlay(){const t=this.host.ensureOverlayHost();this.overlayContainer=document.createElement("div"),this.overlayContainer.className=`qaid-targeting-overlay qaid-type-${this.host.feedbackData.feedbackType}`,this.captureLayer=document.createElement("div"),this.captureLayer.className="qaid-capture-layer";const e=document.createElement("div");e.className="qaid-vignette",this.crosshairH=document.createElement("div"),this.crosshairH.className="qaid-crosshair-h",this.crosshairV=document.createElement("div"),this.crosshairV.className="qaid-crosshair-v",this.scope=document.createElement("div"),this.scope.className="qaid-scope",this.scope.innerHTML=`
|
|
26
26
|
<div class="qaid-scope-ring"></div>
|
|
27
27
|
<div class="qaid-scope-ring-inner"></div>
|
|
28
28
|
<div class="qaid-scope-dot"></div>
|
|
29
|
-
`,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(e),this.overlayContainer.appendChild(this.highlightBox),this.overlayContainer.appendChild(this.crosshairH),this.overlayContainer.appendChild(this.crosshairV),this.overlayContainer.appendChild(this.scope),this.crosshairH.style.top=`${this.mousePos.y}px`,this.crosshairV.style.left=`${this.mousePos.x}px`,this.scope.style.left=`${this.mousePos.x}px`,this.scope.style.top=`${this.mousePos.y}px`,this.host.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleMouseMove(t){this.updateReticleAt(t.clientX,t.clientY)}updateReticleAt(t,e){if(this.mousePos.x=t,this.mousePos.y=e,this.crosshairH&&(this.crosshairH.style.top=`${e}px`),this.crosshairV&&(this.crosshairV.style.left=`${t}px`),this.scope&&(this.scope.style.left=`${t}px`,this.scope.style.top=`${e}px`),this.captureLayer&&this.host.shadowHost){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=st(t,e,o);if(n&&!H(n)){if(this.highlightBox){const s=n.getBoundingClientRect();this.highlightBox.style.transform=`translate(${s.left}px, ${s.top}px)`,this.highlightBox.style.width=`${s.width}px`,this.highlightBox.style.height=`${s.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation(),this.selectAt(t.clientX,t.clientY)}handleTouchStart(t){const e=t.touches[0];e&&(this.touchStartPos={x:e.clientX,y:e.clientY},this.updateReticleAt(e.clientX,e.clientY))}handleTouchEnd(t){const e=t.changedTouches[0],o=this.touchStartPos;this.touchStartPos=null,!(!e||!o||Math.hypot(e.clientX-o.x,e.clientY-o.y)>Ui)&&(t.preventDefault(),this.selectAt(e.clientX,e.clientY))}selectAt(t,e){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=st(t,e,o);if(!n||H(n))return;const s=at(n,8);Object.assign(this.host.selectedBounds,s,{clickX:t,clickY:e,visible:!0});const{selector:a,text:c}=W(n);this.host.feedbackData.elementSelector=a,this.host.feedbackData.elementText=c,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.setState("SELECTED"),this.host.clearActiveThumb(),this.showSelectedMarker(),this.host.submitFeedback()}stopTargetingListeners(){this.removeTargetingOverlay(),this.touchStartPos=null,document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),document.removeEventListener("touchstart",this.boundTouchStart),document.removeEventListener("touchend",this.boundTouchEnd),document.removeEventListener("keydown",this.host.boundKeyDown)}cancel(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.clearActiveThumb(),this.host.setState("IDLE"),this.host.feedbackData.feedbackType=null,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1}removeTargetingOverlay(){this.overlayContainer&&(this.overlayContainer.remove(),this.overlayContainer=null),this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null}showSelectedMarker(){const t=this.host.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.host.selectedBounds.x}px`,this.marker.style.top=`${this.host.selectedBounds.y}px`,this.marker.style.width=`${this.host.selectedBounds.width}px`,this.marker.style.height=`${this.host.selectedBounds.height}px`,this.marker.style.zIndex=String(this.host.config.zIndex+1),this.host.applyVars(this.marker),t.appendChild(this.marker)}hideMarker(){this.marker&&(this.marker.remove(),this.marker=null)}destroy(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),this.hideMarker()}}const $t=Object.freeze(Object.defineProperty({__proto__:null,TargetingController:ji,styles:Vi},Symbol.toStringTag,{value:"Module"}));g.AnnotationEditor=K,g.QaidFeedback=pt,g.captureDomScreenshot=At,g.captureNetworkErrors=yt,g.compositeAnnotations=j,g.createVideoRecorder=Ct,g.drawShape=P,g.getSupportedMimeType=U,g.isDomScreenshotSupported=Et,g.isVideoRecordingSupported=xt,g.openAnnotationEditor=Mt,g.rectFromPoints=R,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
29
|
+
`,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(e),this.overlayContainer.appendChild(this.highlightBox),this.overlayContainer.appendChild(this.crosshairH),this.overlayContainer.appendChild(this.crosshairV),this.overlayContainer.appendChild(this.scope),this.crosshairH.style.top=`${this.mousePos.y}px`,this.crosshairV.style.left=`${this.mousePos.x}px`,this.scope.style.left=`${this.mousePos.x}px`,this.scope.style.top=`${this.mousePos.y}px`,this.host.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleMouseMove(t){this.updateReticleAt(t.clientX,t.clientY)}updateReticleAt(t,e){if(this.mousePos.x=t,this.mousePos.y=e,this.crosshairH&&(this.crosshairH.style.top=`${e}px`),this.crosshairV&&(this.crosshairV.style.left=`${t}px`),this.scope&&(this.scope.style.left=`${t}px`,this.scope.style.top=`${e}px`),this.captureLayer&&this.host.shadowHost){const i=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=nt(t,e,i);if(n&&!H(n)){if(this.highlightBox){const a=n.getBoundingClientRect();this.highlightBox.style.transform=`translate(${a.left}px, ${a.top}px)`,this.highlightBox.style.width=`${a.width}px`,this.highlightBox.style.height=`${a.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation(),this.selectAt(t.clientX,t.clientY)}handleTouchStart(t){const e=t.touches[0];e&&(this.touchStartPos={x:e.clientX,y:e.clientY},this.updateReticleAt(e.clientX,e.clientY))}handleTouchEnd(t){const e=t.changedTouches[0],i=this.touchStartPos;this.touchStartPos=null,!(!e||!i||Math.hypot(e.clientX-i.x,e.clientY-i.y)>Go)&&(t.preventDefault(),this.selectAt(e.clientX,e.clientY))}selectAt(t,e){const i=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=nt(t,e,i);if(!n||H(n))return;const a=at(n,8);Object.assign(this.host.selectedBounds,a,{clickX:t,clickY:e,visible:!0});const{selector:s,text:d}=X(n);this.host.feedbackData.elementSelector=s,this.host.feedbackData.elementText=d,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.setState("SELECTED"),this.host.clearActiveThumb(),this.showSelectedMarker(),this.host.submitFeedback()}stopTargetingListeners(){this.removeTargetingOverlay(),this.touchStartPos=null,document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),document.removeEventListener("touchstart",this.boundTouchStart),document.removeEventListener("touchend",this.boundTouchEnd),document.removeEventListener("keydown",this.host.boundKeyDown)}cancel(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.clearActiveThumb(),this.host.setState("IDLE"),this.host.feedbackData.feedbackType=null,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1}removeTargetingOverlay(){this.overlayContainer&&(this.overlayContainer.remove(),this.overlayContainer=null),this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null}showSelectedMarker(){const t=this.host.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.host.selectedBounds.x}px`,this.marker.style.top=`${this.host.selectedBounds.y}px`,this.marker.style.width=`${this.host.selectedBounds.width}px`,this.marker.style.height=`${this.host.selectedBounds.height}px`,this.marker.style.zIndex=String(this.host.config.zIndex+1),this.host.applyVars(this.marker),t.appendChild(this.marker)}hideMarker(){this.marker&&(this.marker.remove(),this.marker=null)}destroy(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),this.hideMarker()}}const Yt=Object.freeze(Object.defineProperty({__proto__:null,TargetingController:Zo,styles:Jo},Symbol.toStringTag,{value:"Module"})),ti=".qaid-recording-indicator{position:fixed;pointer-events:auto;top:12px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:light-dark(#1f2937,#374151);color:#fff;border-radius:9999px;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;box-shadow:0 4px 12px #0000004d;z-index:99999;animation:qaid-slideDown .2s ease-out}.qaid-recording-dot{width:10px;height:10px;background:#dc2626;border-radius:50%;animation:qaid-dotPulse 1.5s ease-in-out infinite}@keyframes qaid-dotPulse{0%,to{opacity:1}50%{opacity:.3}}.qaid-recording-time{font-variant-numeric:tabular-nums;min-width:2.5rem;text-align:center}button.qaid-recording-stop{padding:.25rem .75rem;background:#dc2626;color:#fff;border:none;border-radius:9999px;font-size:calc(var(--qaid-font-size, 16px) * .75);font-weight:600;cursor:pointer;transition:background-color .2s;-webkit-appearance:none;appearance:none}button.qaid-recording-stop:hover{background:#b91c1c}.qaid-video-preview{position:fixed;inset:0 0 auto;height:100vh;height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#0009;z-index:99998;animation:qaid-fadeIn .2s ease-out}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}.qaid-video-preview-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px #00000080;width:560px;max-width:100%;max-height:100%;overflow-y:auto;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-video-preview-box h3{font-size:calc(var(--qaid-font-size, 16px) * 1.125);font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;max-height:50vh;max-height:50dvh;object-fit:contain;border-radius:.5rem;background:#000;margin-bottom:1rem}.qaid-video-preview-box textarea{width:100%;height:4rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:calc(var(--qaid-font-size, 16px) * .875);resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-video-error{margin:0 0 .75rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;color:light-dark(#b91c1c,#fca5a5)}.qaid-video-preview-actions{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-video-btn{padding:.5rem 1rem;border:none;border-radius:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-video-btn-cancel{background:light-dark(#f3f4f6,#374151);color:light-dark(#374151,#d1d5db)}button.qaid-video-btn-cancel:hover{background:light-dark(#e5e7eb,#4b5563)}button.qaid-video-btn-rerecord{background:light-dark(#fef3c7,#78350f);color:light-dark(#92400e,#fde68a)}button.qaid-video-btn-rerecord:hover{filter:brightness(.9)}button.qaid-video-btn-send{background:var(--qaid-marker);color:var(--qaid-marker-text, white)}button.qaid-video-btn-send:hover{filter:brightness(.85)}button.qaid-video-btn-send:disabled{opacity:.5;cursor:not-allowed}.qaid-video-sending{display:flex;align-items:center;gap:.5rem;font-size:calc(var(--qaid-font-size, 16px) * .875);color:light-dark(#6b7280,#9ca3af)}@keyframes qaid-slideDown{0%{transform:translateY(-100%)}to{transform:translateY(0)}}button.qaid-recording-stop{min-height:24px}.qaid-video-preview-box textarea:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}@media(forced-colors:active){.qaid-video-preview-box textarea:focus{outline:2px solid CanvasText;outline-offset:2px}}";class ei{constructor(t){this.host=t}host;videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;redactPicks=[];redactPickerRoot=null;redactRafId=0;boundRedactClick=t=>this.handleRedactPickClick(t);handleEscape(){return this.isRecording?(this.stopRecording(),!0):this.videoPreview?(this.cancelRecordingPreview(),!0):this.redactPickerRoot?(this.finishRedactionPicking(!1),!0):!1}destroy(){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null),this.redactPicks=[],this.cleanupRecording(),this.removeVideoPreview()}async startRecording(t=[]){if(!(this.isRecording||this.host.state!=="IDLE"))try{this.networkCapture=gt();const{createVideoRecorder:e}=await Promise.resolve().then(()=>xt);this.videoRecorder=e({maxDuration:this.host.config.videoOptions.maxDuration,redactionElements:t}),this.videoRecorder.onTick(i=>{this.updateRecordingTimer(i)}),this.videoRecorder.onStop(i=>{this.isRecording&&(this.recordedBlob=i,this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.host.setButtonsDisabled(!1),i&&i.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.host.announceMsg("Recording started"),this.host.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.host.boundKeyDown)}catch(e){e instanceof Error&&/current tab|cannot blur/i.test(e.message)&&this.host.announceMsg(e.message),this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}startPicking(){if(this.isRecording||this.host.state!=="IDLE")return;this.host.setState("REDACT_PICKING"),this.redactPicks=[];const t=this.host.ensureOverlayHost(),e=u("div",{style:"position:absolute;inset:0;"}),i=u("div",{class:"qaid-redact-picker",style:"position:fixed;inset:0;pointer-events:none;"},e,u("div",{style:"position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;gap:12px;align-items:center;pointer-events:auto;background:#0b1220;color:#fff;border:1px solid #ff6b6b;border-radius:9999px;padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 8px 30px rgba(0,0,0,.5);"},u("span",{text:"Click sensitive areas to blur",attrs:{"data-qaid-redact-label":""}}),u("button",{text:"Start recording",attrs:{type:"button"},style:"cursor:pointer;border:0;border-radius:9999px;padding:8px 14px;background:#ff6b6b;color:#0b1220;font:inherit;",on:{click:()=>this.finishRedactionPicking(!0)}}),u("button",{text:"Cancel",attrs:{type:"button"},style:"cursor:pointer;border:0;background:transparent;color:#9fb3c8;font:inherit;",on:{click:()=>this.finishRedactionPicking(!1)}})));t.appendChild(i),this.redactPickerRoot=i;const n=()=>{this.renderRedactPicks(e),this.redactRafId=requestAnimationFrame(n)};n(),document.addEventListener("click",this.boundRedactClick,!0),document.addEventListener("keydown",this.host.boundKeyDown),this.host.announceMsg("Click sensitive areas to blur, then start recording")}handleRedactPickClick(t){const e=t.target instanceof Element?t.target:null;if(!e||H(e)||this.redactPickerRoot?.contains(e))return;t.preventDefault(),t.stopPropagation();const i=this.redactPicks.indexOf(e);i>=0?this.redactPicks.splice(i,1):this.redactPicks.push(e);const n=this.redactPickerRoot?.querySelector("[data-qaid-redact-label]");if(n){const a=this.redactPicks.length;n.textContent=a===0?"Click sensitive areas to blur":`${a} area${a===1?"":"s"} will be blurred`}}renderRedactPicks(t){t.textContent="";for(const e of this.redactPicks){const i=e.getBoundingClientRect();i.width<=0||i.height<=0||t.appendChild(u("div",{style:`position:fixed;left:${i.left}px;top:${i.top}px;width:${i.width}px;height:${i.height}px;border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;`}))}}finishRedactionPicking(t){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),document.removeEventListener("keydown",this.host.boundKeyDown),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null);const e=this.redactPicks;this.redactPicks=[],this.host.setState("IDLE"),t&&this.startRecording(e)}showRecordingIndicator(){const t=this.host.ensureOverlayHost();this.recordingIndicator=u("div",{class:"qaid-recording-indicator",style:`z-index:${this.host.config.zIndex+100}`},u("div",{class:"qaid-recording-dot"}),u("span",{class:"qaid-recording-time",text:this.formatTime(this.host.config.videoOptions.maxDuration)}),u("button",{class:"qaid-recording-stop",text:"Stop",attrs:{type:"button"},on:{click:()=>this.stopRecording()}})),this.host.applyVars(this.recordingIndicator),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const e=this.recordingIndicator.querySelector(".qaid-recording-time");if(e){const i=Math.max(0,this.host.config.videoOptions.maxDuration-t);e.textContent=this.formatTime(i),i>0&&i<=5&&this.host.announceMsg(`${i} second${i===1?"":"s"} remaining`)}}formatTime(t){const e=Math.floor(t/60),i=t%60;return`${e}:${i.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.host.ensureOverlayHost(),e=URL.createObjectURL(this.recordedBlob),i=`qaid-video-title-${this.host.uid}`,n=u("h3",{text:"Review your recording",attrs:{id:i}}),a=u("video");a.src=e,a.controls=!0,a.autoplay=!0,a.muted=!0;const s=u("textarea",{attrs:{placeholder:"Optional: Describe the issue you recorded...","aria-label":"Describe the issue you recorded"}}),d=u("button",{class:"qaid-video-btn qaid-video-btn-send",text:"Send",attrs:{type:"button"},on:{click:()=>this.submitVideoFeedback(s.value.trim()||null,d)}}),c=u("div",{class:"qaid-video-preview-box"},n,a,s,u("div",{class:"qaid-video-preview-actions"},u("button",{class:"qaid-video-btn qaid-video-btn-cancel",text:"Cancel",attrs:{type:"button"},on:{click:()=>this.cancelRecordingPreview()}}),u("button",{class:"qaid-video-btn qaid-video-btn-rerecord",text:"Re-record",attrs:{type:"button"},on:{click:()=>{this.cancelRecordingPreview(),this.startRecording()}}}),d));this.videoPreview=u("div",{class:"qaid-video-preview",style:`z-index:${this.host.config.zIndex+100}`},c),this.host.applyVars(this.videoPreview),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.host.openDialogA11y(c,{labelledbyId:n.id}),document.addEventListener("keydown",this.host.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.host.closeDialogA11y(),this.videoPreview){const t=this.videoPreview.querySelector("video");t?.src&&URL.revokeObjectURL(t.src),this.videoPreview.remove(),this.videoPreview=null}document.removeEventListener("keydown",this.host.boundKeyDown)}async submitVideoFeedback(t,e){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,e.disabled=!0,e.textContent="Sending...";const i=new FormData;i.append("video",this.recordedBlob,`recording.${this.recordedBlob.type.includes("mp4")?"mp4":"webm"}`),i.append("pageUrl",window.location.href),i.append("visitorId",this.host.visitorId),this.host.config.apiKey&&i.append("apiKey",this.host.config.apiKey),t&&i.append("message",t),this.host.consoleCapture&&i.append("consoleErrors",JSON.stringify(this.host.consoleCapture.errors)),this.networkCapture&&i.append("networkErrors",JSON.stringify(this.networkCapture.errors));let n=null,a=null;try{const s=await fetch(`${this.host.config.endpoint}/video`,{method:"POST",body:i});if(s.ok){this.host.announceMsg("Recording sent");try{n=(await s.json())?.id??null}catch{}}else console.error("Failed to submit video feedback:",await s.text()),a=s.status===413?"This recording is too large to send. Try a shorter one.":"Your recording could not be sent."}catch(s){console.error("Failed to submit video feedback:",s),a="Your recording could not be sent. Check your connection and try again."}if(this.isSendingVideo=!1,a){this.showSendError(a,e);return}this.removeVideoPreview(),this.cleanupRecording(),await this.host.tryLaunchQuest("video",n)}showSendError(t,e){this.host.announceMsg(`Failed to send recording. ${t}`,!0),e.disabled=!1,e.textContent="Send";const i=this.videoPreview?.querySelector(".qaid-video-preview-actions");if(i){let n=this.videoPreview.querySelector(".qaid-video-error");n||(n=u("p",{class:"qaid-video-error"}),i.before(n)),n.textContent=t}}cleanupRecording(){this.isRecording=!1,this.removeRecordingIndicator(),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.networkCapture&&(this.networkCapture.restore(),this.networkCapture=null),this.recordedBlob&&(this.recordedBlob=null),this.host.setButtonsDisabled(!1),this.host.overlayShadowHost&&this.host.state==="IDLE"&&(this.host.overlayShadowHost.style.pointerEvents="none")}}const Jt=Object.freeze(Object.defineProperty({__proto__:null,RecordingController:ei,styles:ti},Symbol.toStringTag,{value:"Module"}));async function oi(o={}){const{quality:t=.8,maxWidth:e=1280,maxHeight:i=800}=o;try{if(!navigator.mediaDevices?.getDisplayMedia)return console.warn("Screen Capture API not available"),null;const n=await navigator.mediaDevices.getDisplayMedia({preferCurrentTab:!0,video:{displaySurface:"browser"}}),a=n.getVideoTracks()[0],s=a.getSettings(),d=document.createElement("video");d.srcObject=n,d.muted=!0,await new Promise(y=>{d.onloadedmetadata=()=>{d.play(),y()}}),await new Promise(y=>{const k=()=>{d.readyState>=2?y():requestAnimationFrame(k)};k()}),await new Promise(y=>setTimeout(y,100));const c=s.width||d.videoWidth,l=s.height||d.videoHeight,r=Math.min(e/c,i/l,1),h=Math.round(c*r),f=Math.round(l*r),m=document.createElement("canvas");m.width=h,m.height=f;const g=m.getContext("2d");return g?(g.drawImage(d,0,0,h,f),a.stop(),m.toDataURL("image/webp",t)):(a.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const Gt=Object.freeze(Object.defineProperty({__proto__:null,captureScreenshot:oi},Symbol.toStringTag,{value:"Module"}));v.AnnotationEditor=K,v.QaidFeedback=ut,v.captureDomScreenshot=Et,v.captureNetworkErrors=gt,v.compositeAnnotations=j,v.createVideoRecorder=qt,v.drawShape=R,v.getSupportedMimeType=U,v.isDomScreenshotSupported=St,v.isVideoRecordingSupported=kt,v.openAnnotationEditor=Dt,v.rectFromPoints=P,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
30
30
|
//# sourceMappingURL=qaid.umd.cjs.map
|