@qaiddev/thumbs-embed 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/qaid.umd.cjs CHANGED
@@ -1,19 +1,19 @@
1
1
  (function(g,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(g=typeof globalThis<"u"?globalThis:g||self,x(g.Qaid={}))})(this,(function(g){"use strict";const x=`<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>`,S=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
3
+ </svg>`,E=`<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>`,at=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
5
+ </svg>`,ct=`<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>`,rt="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}.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:1rem;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}.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}@keyframes qaid-slideDown{0%{transform:translateY(-100%)}to{transform:translateY(0)}}.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, #6366f1);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)}}.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-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size:1.125rem;font-weight:700;margin:0 0 .25rem;color:light-dark(#1f2937,#f9fafb)}.qaid-modal-subtitle{color:light-dark(#6b7280,#9ca3af);margin:0;font-size:.875rem}.qaid-textarea{width:100%;height:6rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:1rem;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:.875rem;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)}}button.qaid-btn-record:hover{background:#dc2626;color:#fff}.qaid-recording-indicator{position:fixed;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:.875rem;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:.75rem;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;display:flex;align-items:center;justify-content:center;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:calc(100vw - 32px);max-height:calc(100vh - 32px);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:1.125rem;font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;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:.875rem;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-preview-actions{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-video-btn{padding:.5rem 1rem;border:none;border-radius:.5rem;font-size:.875rem;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:.875rem;color:light-dark(#6b7280,#9ca3af)}button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);outline-offset:2px}.qaid-textarea:focus-visible,button.qaid-btn-submit:focus-visible,.qaid-video-preview-box textarea:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);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}button.qaid-recording-stop{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,.qaid-textarea:focus,button.qaid-btn-submit:focus,.qaid-video-preview-box textarea:focus{outline:2px solid CanvasText;outline-offset:2px}.qaid-selected-marker,.qaid-highlight-box{border-color:Highlight}}",dt="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let q=0;const ct="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 svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",lt={small:36,medium:48,large:64},ht={small:18,medium:24,large:32};function ut(e,t,i){const[o,n,s]=[e,t,i].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 pt(e){if(e.startsWith("#")){const i=e.slice(1),o=i.length===3?i.split("").map(s=>s+s).join(""):i,n=parseInt(o,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function mt(e){const t=pt(e);return t&&ut(t.r,t.g,t.b)>.4?"black":"white"}function ft(e={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:i="rgb(255, 0, 0)",markerColor:o="#6366f1",buttonSize:n="medium",modalWidth:s=400,backdropOpacity:a=.3,fontFamily:c="system-ui, -apple-system, sans-serif",fontSize:l=16}=e,r=lt[n],d=ht[n],p=mt(o);return{"--qaid-positive":t,"--qaid-negative":i,"--qaid-marker":o,"--qaid-marker-text":p,"--qaid-btn-size":`${r}px`,"--qaid-icon-size":`${d}px`,"--qaid-modal-width":`${s}px`,"--qaid-backdrop-opacity":String(a),"--qaid-font-family":c,"--qaid-font-size":`${l}px`}}function bt(e,t){for(const[i,o]of Object.entries(t))e.style.setProperty(i,o)}function M(){return rt+ct}function gt(){if(q++,q>1)return;const e=document.createElement("style");e.id="qaid-styles",e.textContent=dt,document.head.appendChild(e)}function vt(){q<=0||(q--,q===0&&document.getElementById("qaid-styles").remove())}const R=["data-comp","data-qa","data-testid","data-id"];function H(e,t=document.body){let i=e;for(;i&&i!==t;){for(const o of R){const n=i.getAttribute(o);if(n)return`${o}="${n}"`}i=i.parentElement}return null}function yt(e,t=100){const i=e.textContent?.trim().slice(0,t)||"";return i.length===t?i+"...":i}function wt(e){let t=1,i=e.previousElementSibling;for(;i;)t++,i=i.previousElementSibling;return t}function xt(e){const t=[];let i=e;for(;i&&i!==document.body&&i!==document.documentElement;){const o=i.tagName.toLowerCase(),n=wt(i);t.unshift(`${o}:nth-child(${n})`),i=i.parentElement}return t.length>0?`body > ${t.join(" > ")}`:"body"}function qt(e){return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function kt(e){const t=H(e);return t?`[${t}]`:e.id?`#${qt(e.id)}`:xt(e)}function E(e){const t=yt(e),i=H(e);return{selector:kt(e),text:t,dataAttr:i}}const Ct=["a[href]","button","input:not([type=hidden])","select","textarea","summary","[tabindex]","[role]","img","h1","h2","h3","h4","h5","h6","p","li","label",...R.map(e=>`[${e}]`)].join(","),St=/^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;function Et(e){if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!1;const t=e.ownerDocument?.defaultView;if(t&&typeof t.getComputedStyle=="function"){const i=t.getComputedStyle(e);if(i.display==="none"||i.visibility==="hidden")return!1}return!0}function Tt(e={}){const t=e.root??document.body,i=e.selector??Ct,o=e.isExcluded??(()=>!1),n=e.isVisible??Et;return Array.from(t.querySelectorAll(i)).filter(s=>!o(s)&&n(s))}function Lt(e){const t=e.candidates??Tt({root:e.root,selector:e.selector,isExcluded:e.isExcluded,isVisible:e.isVisible}),i=e.moveFocus??!0,o=e.eventTarget??document,n=new Set;let s=-1,a=!1;const c=e.initial!==void 0?e.initial:typeof document<"u"?document.activeElement:null;if(c){const h=t.indexOf(c);h>=0&&(s=h)}s<0&&t.length>0&&(s=0);function l(h){if(!i)return;const w=h;if(typeof w.focus=="function"){h.getAttribute("tabindex")===null&&!St.test(h.tagName)&&(h.setAttribute("tabindex","-1"),n.add(h));try{w.focus()}catch{}}}function r(){const h=t[s];h&&(l(h),e.onHighlight?.(h,s))}function d(h){if(a||t.length===0)return;const w=t.length;s=(h%w+w)%w,r()}function p(){d(s+1)}function u(){d(s-1)}function m(){return t[s]??null}function v(){a||(a=!0,o.removeEventListener("keydown",y,!0),n.forEach(h=>h.removeAttribute("tabindex")),n.clear())}function b(){if(a)return;const h=m();v(),h&&e.onSelect(h)}function f(){a||(v(),e.onCancel?.())}function y(h){if(!a)switch(h.key){case"Tab":h.preventDefault(),h.stopPropagation(),h.shiftKey?u():p();break;case"ArrowDown":case"ArrowRight":h.preventDefault(),h.stopPropagation(),p();break;case"ArrowUp":case"ArrowLeft":h.preventDefault(),h.stopPropagation(),u();break;case"Enter":case" ":case"Spacebar":h.preventDefault(),h.stopPropagation(),b();break;case"Escape":case"Esc":h.preventDefault(),h.stopPropagation(),f();break}}return o.addEventListener("keydown",y,!0),s>=0&&r(),{candidates:t,getIndex:()=>s,getCurrent:m,next:p,prev:u,moveTo:d,select:b,cancel:f,handleKey:y,stop:v}}const B="data-qaid-a11y-live",It="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;",Dt=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function At(e){return e.ownerDocument||document}function Mt(e,t){const i=t?"assertive":"polite",o=e.querySelector(`[${B}="${i}"]`);if(o)return o;const s=At(e).createElement("div");return s.setAttribute(B,i),s.setAttribute("role",t?"alert":"status"),s.setAttribute("aria-live",t?"assertive":"polite"),s.setAttribute("aria-atomic","true"),s.style.cssText=It,e.appendChild(s),s}function Rt(e,t,i={}){const o=Mt(e,!!i.assertive);o.textContent="",o.textContent=t}function Ht(e){return e.hasAttribute("disabled")?!0:e.disabled===!0}function Bt(e){let t=e;for(;t;){if(t.hasAttribute("hidden"))return!0;const i=t.style;if(i&&(i.display==="none"||i.visibility==="hidden"||i.visibility==="collapse"))return!0;t=t.parentElement}return!1}function z(e){return Array.from(e.querySelectorAll(Dt)).filter(i=>!(i.getAttribute("tabindex")==="-1"||i instanceof HTMLInputElement&&i.type==="hidden"||i instanceof HTMLAnchorElement&&!i.getAttribute("href")||Ht(i)||Bt(i)))}function P(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function zt(e){const t=e.ownerDocument||document;let i=!1;const o=s=>{if(s.key!=="Tab")return;const a=z(e);if(a.length===0){s.preventDefault(),e.focus();return}const c=a[0],l=a[a.length-1],r=P(t),d=r?a.indexOf(r)!==-1:!1;s.shiftKey?(!d||r===c)&&(s.preventDefault(),l.focus()):(!d||r===l)&&(s.preventDefault(),c.focus())};e.addEventListener("keydown",o);const n=z(e);return n.length>0?n[0].focus():(e.hasAttribute("tabindex")||(e.setAttribute("tabindex","-1"),i=!0),e.focus()),{release(){e.removeEventListener("keydown",o),i&&(e.removeAttribute("tabindex"),i=!1)}}}function Pt(){return P(document)}function Ot(e){if(!(!e||typeof e.focus!="function"))try{e.focus()}catch{}}function $t(e,t={}){e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),t.labelledbyId&&e.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&e.setAttribute("aria-describedby",t.describedbyId),t.label&&e.setAttribute("aria-label",t.label)}function Nt(e,t){let i=e;for(;i&&i!==t;){const o=i.parentNode;if(o===t)return i;if(o&&o.host){i=o.host;continue}if(!o)return null;i=o}return null}function Vt(e){const i=(e.ownerDocument||document).body;if(!i)return()=>{};const o=Nt(e,i),n=[];return Array.from(i.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 O={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function Ft(e,t,i,o,n){const s=e.y,a=t-(e.y+e.height);if(a>=i+o)return{top:e.y+e.height+o,position:"below"};if(s>=i+o)return{top:e.y-i-o,position:"above"};const c=a>s?"below":"above";let l;return c==="below"?l=Math.min(e.y+e.height+o,t-i-n):l=Math.max(n,e.y-i-o),{top:l,position:c}}function _t(e,t,i,o){let s=e.x+e.width/2-i/2;return s=Math.max(o,Math.min(s,t-i-o)),s}function Ut(e,t,i,o=24,n=24){const a=e.clickX-t-n/2;return Math.max(o,Math.min(a,i-o-n/2))}function Kt(e,t,i,o=O){const n=o.height+o.arrowHeight,s=Ft(e,i,n,o.gap,o.viewportPadding),a=_t(e,t,o.width,o.viewportPadding);return{top:s.top,left:a,position:s.position}}function Xt(e,t,i,o={}){const n=o.gap??8;let s=e.bottom+n;s+t.height>i.height-n&&(s=e.top-t.height-n);let a=e.left;return a<n?a=n:a+t.width>i.width-n&&(a=i.width-t.width-n),s<n?s=n:s+t.height>i.height-n&&(s=i.height-t.height-n),{top:s,left:a}}function jt(e,t,i,o=O){const n=Kt(e,t,i,o),s=Ut(e,n.left,o.width);return{modal:n,arrow:{left:s}}}const Wt=20;function Yt(e){const t=[],i=console.error,o=console.warn,n=console.log,s=(a,c)=>{const l={message:c.map(r=>String(r)).join(" "),timestamp:Date.now(),level:a};t.length>=Wt&&t.shift(),t.push(l),e&&e(l)};return console.error=function(...a){s("error",a),i.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=i,console.warn=o,console.log=n}}}const Gt=20,$=4096;function C(e){const t=typeof e=="string"?e:JSON.stringify(e);return t.length>$?t.slice(0,$)+"…[truncated]":t}function N(e,t){e.length>=Gt&&e.shift(),e.push(t)}async function Jt(e){try{const t=await e.clone().text();return C(t)}catch{return}}function V(){const e=[],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=C(s.body));const r=await t.apply(window,[n,s]);if(r.status>=400){const d=await Jt(r);N(e,{url:a,method:c.toUpperCase(),status:r.status,statusText:r.statusText,requestBody:l,responseBody:d,timestamp:Date.now()})}return r};const i=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(),i.apply(this,[n,s,...a])},XMLHttpRequest.prototype.send=function(n){const s=this,a=n?C(n):void 0;return s.addEventListener("load",function(){s.status>=400&&N(e,{url:s._qaid_url,method:s._qaid_method.toUpperCase(),status:s.status,statusText:s.statusText,requestBody:a,responseBody:C(s.responseText),timestamp:Date.now()})}),o.apply(this,[n])},{errors:e,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=i,XMLHttpRequest.prototype.send=o}}}function F(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function _(){if(typeof MediaRecorder>"u")return"";const e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of e)if(MediaRecorder.isTypeSupported(t))return t;return""}function U(e={}){const t=e.maxDuration??15,i=e.videoBitsPerSecond??8e5;let o=null,n=null,s=[],a=null,c=null,l=null,r=0,d=null,p=null,u=!1,m=null;function v(){l!==null&&(clearInterval(l),l=null),m!==null&&(clearTimeout(m),m=null),o&&(o.getTracks().forEach(f=>f.stop()),o=null),n=null,s=[],a=null,c=null,d=null,p=null}function b(){u||(u=!0,n&&n.state!=="inactive"&&n.stop())}return{async start(){u=!1,s=[];const f=_();if(!f)throw new Error("No supported video MIME type found");o=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0});const y=o.getVideoTracks()[0];y&&y.addEventListener("ended",()=>{b()}),n=new MediaRecorder(o,{mimeType:f,videoBitsPerSecond:i}),n.ondataavailable=h=>{h.data.size>0&&s.push(h.data)},n.onstop=()=>{const h=new Blob(s,{type:f});d&&d(h),c&&c(h),o&&o.getTracks().forEach(w=>w.stop())},n.onerror=()=>{p&&p(new Error("MediaRecorder error"))},n.start(1e3),r=Date.now(),l=setInterval(()=>{const h=Math.floor((Date.now()-r)/1e3);a&&a(h)},1e3),m=setTimeout(()=>{b()},t*1e3)},stop(){return new Promise((f,y)=>{d=f,p=y,b()})},onTick(f){a=f},onStop(f){c=f},destroy(){b(),v()}}}function Qt(e=640){return typeof window<"u"&&window.innerWidth<e}function K(e,t,i){const o=i.map(s=>s.style.visibility);i.forEach(s=>s.style.visibility="hidden");const n=document.elementFromPoint(e,t);return i.forEach((s,a)=>s.style.visibility=o[a]),n}function T(e){return e?e.hasAttribute("data-qaid-embed")||e.hasAttribute("data-qaid-embed-overlay")?!0:!!e.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function X(e,t=0){const i=e.getBoundingClientRect();return{x:i.left-t,y:i.top-t,width:i.width+t*2,height:i.height+t*2}}async function Zt(e={}){const{quality:t=1,maxWidth:i=1280,maxHeight:o=800}=e;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(b=>{c.onloadedmetadata=()=>{c.play(),b()}}),await new Promise(b=>{const f=()=>{c.readyState>=2?b():requestAnimationFrame(f)};f()}),await new Promise(b=>setTimeout(b,100));const l=a.width||c.videoWidth,r=a.height||c.videoHeight,d=Math.min(i/l,o/r,1),p=Math.round(l*d),u=Math.round(r*d),m=document.createElement("canvas");m.width=p,m.height=u;const v=m.getContext("2d");return v?(v.drawImage(c,0,0,p,u),s.stop(),m.toDataURL("image/webp",t)):(s.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const j="https://qaid.dev/lib/html2canvas.min.js",te=1e4,ee=50;let k=null;function ie(){if(typeof document>"u"||typeof window>"u")return!1;const e=document.createElement("canvas");return typeof e.getContext=="function"&&!!e.getContext("2d")}function oe(){return window.html2canvas?Promise.resolve(!0):k||(k=new Promise(e=>{if(!document.querySelector(`script[src="${j}"]`)){const n=document.createElement("script");n.src=j,n.async=!0,document.head.appendChild(n)}const i=Date.now(),o=()=>{if(window.html2canvas){e(!0);return}if(Date.now()-i>te){k=null,e(!1);return}setTimeout(o,ee)};o()}),k)}async function W(e={}){const{quality:t=.8,maxWidth:i=1280,maxHeight:o=800}=e;try{if(!await oe()||!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:r=>r instanceof HTMLElement?r.classList.contains("qaid-buttons")||r.classList.contains("qaid-targeting-overlay")||r.classList.contains("qaid-modal-container")||r.classList.contains("qaid-bottom-sheet")||r.classList.contains("qaid-backdrop")||r.classList.contains("qaid-selected-marker")||r.classList.contains("qaid-tooltip-text")||r.classList.contains("qaid-recording-indicator")||r.classList.contains("qaid-video-preview")||r.className?.toString().startsWith?.("qaid-"):!1}),a=s.width,c=s.height,l=Math.min(i/a,o/c,1);if(l<1){const r=Math.round(a*l),d=Math.round(c*l),p=document.createElement("canvas");p.width=r,p.height=d;const u=p.getContext("2d");return u?(u.drawImage(s,0,0,r,d),p.toDataURL("image/webp",t)):null}return s.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const Y="qaid_visitor_id",G="qaid_hide_feedback";function L(e){return e?`${G}_${e}`:G}function ne(e){try{return localStorage.getItem(L(e))==="1"}catch{return!1}}function J(e,t=!0){try{t?localStorage.setItem(L(e),"1"):localStorage.removeItem(L(e))}catch{}}function se(){try{let e=localStorage.getItem(Y);return e||(e=crypto.randomUUID(),localStorage.setItem(Y,e)),e}catch{return crypto.randomUUID()}}class Q{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};feedbackId=null;mousePos={x:0,y:0};isMobile=!1;visitorId;consoleCapture=null;videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;overlayContainer=null;captureLayer=null;crosshairH=null;crosshairV=null;scope=null;highlightBox=null;marker=null;modalContainer=null;backdrop=null;dismissBtn=null;cssVars={};keyboardController=null;activeThumbBtn=null;keyboardActivation=!1;dialogTrigger=null;dialogTrap=null;dialogRestoreInert=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundMouseMove;boundClick;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,colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#6366f1"},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"},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,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??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15},recordIcon:t.recordIcon??""},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this),this.boundClick=this.handleClick.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=se(),this.init()}applyVars(t){bt(t,this.cssVars)}announceMsg(t,i=!1){const o=this.overlayShadowRoot??this.shadowRoot;o&&Rt(o,t,{assertive:i})}openDialogA11y(t,i){this.dialogTrigger=Pt(),$t(t,i),this.dialogTrap=zt(t),this.dialogRestoreInert=Vt(t)}closeDialogA11y(){this.dialogTrap?.release(),this.dialogTrap=null,this.dialogRestoreInert&&(this.dialogRestoreInert(),this.dialogRestoreInert=null),Ot(this.dialogTrigger),this.dialogTrigger=null}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){gt(),this.cssVars=ft({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=Yt(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom()}observeDom(){this.boundBeforeSwap=t=>{const i=t.newDocument;!i||this.destroyed||(this.shadowHost&&i.body.appendChild(this.shadowHost),this.overlayShadowHost&&i.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=Qt()}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 i=document.createElement("style");if(i.textContent=M(),this.shadowRoot.appendChild(i),this.config.css){const r=document.createElement("style");r.textContent=this.config.css,this.shadowRoot.appendChild(r)}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:r,y:d}=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=`${d}px`:this.buttonsContainer.style.top=`${d}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.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.hideThumbs){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const d=document.createElement("button");d.type="button",d.className=n?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",d.setAttribute("aria-label",this.config.text.positiveLabel),d.innerHTML=this.config.positiveIcon||x,d.addEventListener("click",m=>this.handleThumbClick("up",m.currentTarget,m)),d.addEventListener("mouseenter",()=>this.showTooltip(d)),d.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(d);const p=document.createElement("div");p.className="qaid-tooltip-wrapper";const u=document.createElement("button");u.type="button",u.className=n?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",u.setAttribute("aria-label",this.config.text.negativeLabel),u.innerHTML=this.config.negativeIcon||S,u.addEventListener("click",m=>this.handleThumbClick("down",m.currentTarget,m)),u.addEventListener("mouseenter",()=>this.showTooltip(u)),u.addEventListener("mouseleave",()=>this.hideTooltip()),p.appendChild(u),this.buttonsContainer.appendChild(r),this.buttonsContainer.appendChild(p)}if(this.config.captureVideo&&F()){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const d=document.createElement("button");d.type="button",d.className=n?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",d.setAttribute("aria-label",this.config.text.recordLabel),d.innerHTML=this.config.recordIcon||at,d.addEventListener("click",()=>this.startRecording()),d.addEventListener("mouseenter",()=>this.showTooltip(d)),d.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(d),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");if(t.textContent=M(),this.overlayShadowRoot.appendChild(t),this.config.css){const i=document.createElement("style");i.textContent=this.config.css,this.overlayShadowRoot.appendChild(i)}return this.overlayShadowRoot}tooltipElement=null;showTooltip(t){const i=this.tooltipElement;i.style.visibility="hidden",i.classList.add("qaid-tooltip-visible");const o=t.getBoundingClientRect(),n=i.getBoundingClientRect(),{top:s,left:a}=Xt(o,n,{width:window.innerWidth,height:window.innerHeight});i.style.top=`${s}px`,i.style.left=`${a}px`,i.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),J(this.config.apiKey,!0)}handleThumbClick(t,i,o){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),J(this.config.apiKey,!1)),this.config.skipTargeting)this.submitDirectFeedback(t,i);else{this.activeThumbBtn=i,i.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,n?this.startKeyboardTargetingFlow(t):this.startTargeting(t,o)}}submitDirectFeedback(t,i){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const o=i.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()}startTargeting(t,i){this.state="TARGETING",this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1,this.mousePos.x=i.clientX,this.mousePos.y=i.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.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.cssVars["--qaid-negative"]),this.createTargetingOverlay(),document.addEventListener("keydown",this.boundKeyDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("click",this.boundClick,!0)}startKeyboardTargetingFlow(t){this.state="TARGETING",this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1,document.body.style.setProperty("--qaid-positive",this.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.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=Lt({isExcluded:i=>T(i),onHighlight:i=>{const o=i.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}=E(i);this.announceMsg(`Targeting ${s||i.tagName.toLowerCase()}`)},onSelect:i=>this.selectKeyboardTarget(i),onCancel:()=>this.cancelTargeting()})}selectKeyboardTarget(t){const i=X(t,8);this.selectedBounds={...i,clickX:i.x+i.width/2,clickY:i.y+i.height/2,visible:!0};const{selector:o,text:n}=E(t);this.feedbackData.elementSelector=o,this.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.clearActiveThumb(),this.state="SELECTED",this.showSelectedMarker(),this.submitFeedback()}createTargetingOverlay(){const t=this.ensureOverlayHost();this.overlayContainer=document.createElement("div"),this.overlayContainer.className=`qaid-targeting-overlay qaid-type-${this.feedbackData.feedbackType}`,this.captureLayer=document.createElement("div"),this.captureLayer.className="qaid-capture-layer";const i=document.createElement("div");i.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=`
7
+ </svg>`,lt="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}.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:1rem;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}.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}@keyframes qaid-slideDown{0%{transform:translateY(-100%)}to{transform:translateY(0)}}.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, #6366f1);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)}}.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-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size:1.125rem;font-weight:700;margin:0 0 .25rem;color:light-dark(#1f2937,#f9fafb)}.qaid-modal-subtitle{color:light-dark(#6b7280,#9ca3af);margin:0;font-size:.875rem}.qaid-textarea{width:100%;height:6rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:1rem;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:.875rem;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)}}button.qaid-btn-record:hover{background:#dc2626;color:#fff}.qaid-recording-indicator{position:fixed;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:.875rem;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:.75rem;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;display:flex;align-items:center;justify-content:center;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:calc(100vw - 32px);max-height:calc(100vh - 32px);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:1.125rem;font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;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:.875rem;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-preview-actions{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-video-btn{padding:.5rem 1rem;border:none;border-radius:.5rem;font-size:.875rem;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:.875rem;color:light-dark(#6b7280,#9ca3af)}button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);outline-offset:2px}.qaid-textarea:focus-visible,button.qaid-btn-submit:focus-visible,.qaid-video-preview-box textarea:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);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}button.qaid-recording-stop{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,.qaid-textarea:focus,button.qaid-btn-submit:focus,.qaid-video-preview-box textarea:focus{outline:2px solid CanvasText;outline-offset:2px}.qaid-selected-marker,.qaid-highlight-box{border-color:Highlight}}",ht="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let q=0;const ut="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 svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",pt={small:36,medium:48,large:64},mt={small:18,medium:24,large:32};function ft(e,t,i){const[o,n,s]=[e,t,i].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 bt(e){if(e.startsWith("#")){const i=e.slice(1),o=i.length===3?i.split("").map(s=>s+s).join(""):i,n=parseInt(o,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function gt(e){const t=bt(e);return t&&ft(t.r,t.g,t.b)>.4?"black":"white"}function vt(e={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:i="rgb(255, 0, 0)",markerColor:o="#6366f1",buttonSize:n="medium",modalWidth:s=400,backdropOpacity:a=.3,fontFamily:c="system-ui, -apple-system, sans-serif",fontSize:l=16}=e,r=pt[n],d=mt[n],p=gt(o);return{"--qaid-positive":t,"--qaid-negative":i,"--qaid-marker":o,"--qaid-marker-text":p,"--qaid-btn-size":`${r}px`,"--qaid-icon-size":`${d}px`,"--qaid-modal-width":`${s}px`,"--qaid-backdrop-opacity":String(a),"--qaid-font-family":c,"--qaid-font-size":`${l}px`}}function yt(e,t){for(const[i,o]of Object.entries(t))e.style.setProperty(i,o)}function H(){return lt+ut}function wt(){if(q++,q>1)return;const e=document.createElement("style");e.id="qaid-styles",e.textContent=ht,document.head.appendChild(e)}function xt(){q<=0||(q--,q===0&&document.getElementById("qaid-styles").remove())}const B=["data-comp","data-qa","data-testid","data-id"];function z(e,t=document.body){let i=e;for(;i&&i!==t;){for(const o of B){const n=i.getAttribute(o);if(n)return`${o}="${n}"`}i=i.parentElement}return null}function qt(e,t=100){const i=e.textContent?.trim().slice(0,t)||"";return i.length===t?i+"...":i}function kt(e){let t=1,i=e.previousElementSibling;for(;i;)t++,i=i.previousElementSibling;return t}function Ct(e){const t=[];let i=e;for(;i&&i!==document.body&&i!==document.documentElement;){const o=i.tagName.toLowerCase(),n=kt(i);t.unshift(`${o}:nth-child(${n})`),i=i.parentElement}return t.length>0?`body > ${t.join(" > ")}`:"body"}function St(e){return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function Et(e){const t=z(e);return t?`[${t}]`:e.id?`#${St(e.id)}`:Ct(e)}function T(e){const t=qt(e),i=z(e);return{selector:Et(e),text:t,dataAttr:i}}const Tt=["a[href]","button","input:not([type=hidden])","select","textarea","summary","[tabindex]","[role]","img","h1","h2","h3","h4","h5","h6","p","li","label",...B.map(e=>`[${e}]`)].join(","),It=/^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;function Lt(e){if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!1;const t=e.ownerDocument?.defaultView;if(t&&typeof t.getComputedStyle=="function"){const i=t.getComputedStyle(e);if(i.display==="none"||i.visibility==="hidden")return!1}return!0}function At(e={}){const t=e.root??document.body,i=e.selector??Tt,o=e.isExcluded??(()=>!1),n=e.isVisible??Lt;return Array.from(t.querySelectorAll(i)).filter(s=>!o(s)&&n(s))}function Dt(e){const t=e.candidates??At({root:e.root,selector:e.selector,isExcluded:e.isExcluded,isVisible:e.isVisible}),i=e.moveFocus??!0,o=e.eventTarget??document,n=new Set;let s=-1,a=!1;const c=e.initial!==void 0?e.initial:typeof document<"u"?document.activeElement:null;if(c){const h=t.indexOf(c);h>=0&&(s=h)}s<0&&t.length>0&&(s=0);function l(h){if(!i)return;const w=h;if(typeof w.focus=="function"){h.getAttribute("tabindex")===null&&!It.test(h.tagName)&&(h.setAttribute("tabindex","-1"),n.add(h));try{w.focus()}catch{}}}function r(){const h=t[s];h&&(l(h),e.onHighlight?.(h,s))}function d(h){if(a||t.length===0)return;const w=t.length;s=(h%w+w)%w,r()}function p(){d(s+1)}function u(){d(s-1)}function m(){return t[s]??null}function v(){a||(a=!0,o.removeEventListener("keydown",y,!0),n.forEach(h=>h.removeAttribute("tabindex")),n.clear())}function b(){if(a)return;const h=m();v(),h&&e.onSelect(h)}function f(){a||(v(),e.onCancel?.())}function y(h){if(!a)switch(h.key){case"Tab":h.preventDefault(),h.stopPropagation(),h.shiftKey?u():p();break;case"ArrowDown":case"ArrowRight":h.preventDefault(),h.stopPropagation(),p();break;case"ArrowUp":case"ArrowLeft":h.preventDefault(),h.stopPropagation(),u();break;case"Enter":case" ":case"Spacebar":h.preventDefault(),h.stopPropagation(),b();break;case"Escape":case"Esc":h.preventDefault(),h.stopPropagation(),f();break}}return o.addEventListener("keydown",y,!0),s>=0&&r(),{candidates:t,getIndex:()=>s,getCurrent:m,next:p,prev:u,moveTo:d,select:b,cancel:f,handleKey:y,stop:v}}const P="data-qaid-a11y-live",Mt="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;",Rt=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function Ht(e){return e.ownerDocument||document}function Bt(e,t){const i=t?"assertive":"polite",o=e.querySelector(`[${P}="${i}"]`);if(o)return o;const s=Ht(e).createElement("div");return s.setAttribute(P,i),s.setAttribute("role",t?"alert":"status"),s.setAttribute("aria-live",t?"assertive":"polite"),s.setAttribute("aria-atomic","true"),s.style.cssText=Mt,e.appendChild(s),s}function zt(e,t,i={}){const o=Bt(e,!!i.assertive);o.textContent="",o.textContent=t}function Pt(e){return e.hasAttribute("disabled")?!0:e.disabled===!0}function $t(e){let t=e;for(;t;){if(t.hasAttribute("hidden"))return!0;const i=t.style;if(i&&(i.display==="none"||i.visibility==="hidden"||i.visibility==="collapse"))return!0;t=t.parentElement}return!1}function $(e){return Array.from(e.querySelectorAll(Rt)).filter(i=>!(i.getAttribute("tabindex")==="-1"||i instanceof HTMLInputElement&&i.type==="hidden"||i instanceof HTMLAnchorElement&&!i.getAttribute("href")||Pt(i)||$t(i)))}function O(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function Ot(e){const t=e.ownerDocument||document;let i=!1;const o=s=>{if(s.key!=="Tab")return;const a=$(e);if(a.length===0){s.preventDefault(),e.focus();return}const c=a[0],l=a[a.length-1],r=O(t),d=r?a.indexOf(r)!==-1:!1;s.shiftKey?(!d||r===c)&&(s.preventDefault(),l.focus()):(!d||r===l)&&(s.preventDefault(),c.focus())};e.addEventListener("keydown",o);const n=$(e);return n.length>0?n[0].focus():(e.hasAttribute("tabindex")||(e.setAttribute("tabindex","-1"),i=!0),e.focus()),{release(){e.removeEventListener("keydown",o),i&&(e.removeAttribute("tabindex"),i=!1)}}}function Nt(){return O(document)}function Vt(e){if(!(!e||typeof e.focus!="function"))try{e.focus()}catch{}}function Ft(e,t={}){e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),t.labelledbyId&&e.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&e.setAttribute("aria-describedby",t.describedbyId),t.label&&e.setAttribute("aria-label",t.label)}function Ut(e,t){let i=e;for(;i&&i!==t;){const o=i.parentNode;if(o===t)return i;if(o&&o.host){i=o.host;continue}if(!o)return null;i=o}return null}function _t(e){const i=(e.ownerDocument||document).body;if(!i)return()=>{};const o=Ut(e,i),n=[];return Array.from(i.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 N={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function Kt(e,t,i,o,n){const s=e.y,a=t-(e.y+e.height);if(a>=i+o)return{top:e.y+e.height+o,position:"below"};if(s>=i+o)return{top:e.y-i-o,position:"above"};const c=a>s?"below":"above";let l;return c==="below"?l=Math.min(e.y+e.height+o,t-i-n):l=Math.max(n,e.y-i-o),{top:l,position:c}}function jt(e,t,i,o){let s=e.x+e.width/2-i/2;return s=Math.max(o,Math.min(s,t-i-o)),s}function Xt(e,t,i,o=24,n=24){const a=e.clickX-t-n/2;return Math.max(o,Math.min(a,i-o-n/2))}function Wt(e,t,i,o=N){const n=o.height+o.arrowHeight,s=Kt(e,i,n,o.gap,o.viewportPadding),a=jt(e,t,o.width,o.viewportPadding);return{top:s.top,left:a,position:s.position}}function Yt(e,t,i,o={}){const n=o.gap??8;let s=e.bottom+n;s+t.height>i.height-n&&(s=e.top-t.height-n);let a=e.left;return a<n?a=n:a+t.width>i.width-n&&(a=i.width-t.width-n),s<n?s=n:s+t.height>i.height-n&&(s=i.height-t.height-n),{top:s,left:a}}function Qt(e,t,i,o=N){const n=Wt(e,t,i,o),s=Xt(e,n.left,o.width);return{modal:n,arrow:{left:s}}}const Gt=20;function Jt(e){const t=[],i=console.error,o=console.warn,n=console.log,s=(a,c)=>{const l={message:c.map(r=>String(r)).join(" "),timestamp:Date.now(),level:a};t.length>=Gt&&t.shift(),t.push(l),e&&e(l)};return console.error=function(...a){s("error",a),i.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=i,console.warn=o,console.log=n}}}const Zt=20,V=4096;function S(e){const t=typeof e=="string"?e:JSON.stringify(e);return t.length>V?t.slice(0,V)+"…[truncated]":t}function F(e,t){e.length>=Zt&&e.shift(),e.push(t)}async function te(e){try{const t=await e.clone().text();return S(t)}catch{return}}function U(){const e=[],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=S(s.body));const r=await t.apply(window,[n,s]);if(r.status>=400){const d=await te(r);F(e,{url:a,method:c.toUpperCase(),status:r.status,statusText:r.statusText,requestBody:l,responseBody:d,timestamp:Date.now()})}return r};const i=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(),i.apply(this,[n,s,...a])},XMLHttpRequest.prototype.send=function(n){const s=this,a=n?S(n):void 0;return s.addEventListener("load",function(){s.status>=400&&F(e,{url:s._qaid_url,method:s._qaid_method.toUpperCase(),status:s.status,statusText:s.statusText,requestBody:a,responseBody:S(s.responseText),timestamp:Date.now()})}),o.apply(this,[n])},{errors:e,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=i,XMLHttpRequest.prototype.send=o}}}function _(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function K(){if(typeof MediaRecorder>"u")return"";const e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of e)if(MediaRecorder.isTypeSupported(t))return t;return""}function j(e={}){const t=e.maxDuration??15,i=e.videoBitsPerSecond??8e5;let o=null,n=null,s=[],a=null,c=null,l=null,r=0,d=null,p=null,u=!1,m=null;function v(){l!==null&&(clearInterval(l),l=null),m!==null&&(clearTimeout(m),m=null),o&&(o.getTracks().forEach(f=>f.stop()),o=null),n=null,s=[],a=null,c=null,d=null,p=null}function b(){u||(u=!0,n&&n.state!=="inactive"&&n.stop())}return{async start(){u=!1,s=[];const f=K();if(!f)throw new Error("No supported video MIME type found");o=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0});const y=o.getVideoTracks()[0];y&&y.addEventListener("ended",()=>{b()}),n=new MediaRecorder(o,{mimeType:f,videoBitsPerSecond:i}),n.ondataavailable=h=>{h.data.size>0&&s.push(h.data)},n.onstop=()=>{const h=new Blob(s,{type:f});d&&d(h),c&&c(h),o&&o.getTracks().forEach(w=>w.stop())},n.onerror=()=>{p&&p(new Error("MediaRecorder error"))},n.start(1e3),r=Date.now(),l=setInterval(()=>{const h=Math.floor((Date.now()-r)/1e3);a&&a(h)},1e3),m=setTimeout(()=>{b()},t*1e3)},stop(){return new Promise((f,y)=>{d=f,p=y,b()})},onTick(f){a=f},onStop(f){c=f},destroy(){b(),v()}}}function ee(e=640){return typeof window<"u"&&window.innerWidth<e}function X(e,t,i){const o=i.map(s=>s.style.visibility);i.forEach(s=>s.style.visibility="hidden");const n=document.elementFromPoint(e,t);return i.forEach((s,a)=>s.style.visibility=o[a]),n}function I(e){return e?e.hasAttribute("data-qaid-embed")||e.hasAttribute("data-qaid-embed-overlay")?!0:!!e.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function W(e,t=0){const i=e.getBoundingClientRect();return{x:i.left-t,y:i.top-t,width:i.width+t*2,height:i.height+t*2}}async function ie(e={}){const{quality:t=1,maxWidth:i=1280,maxHeight:o=800}=e;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(b=>{c.onloadedmetadata=()=>{c.play(),b()}}),await new Promise(b=>{const f=()=>{c.readyState>=2?b():requestAnimationFrame(f)};f()}),await new Promise(b=>setTimeout(b,100));const l=a.width||c.videoWidth,r=a.height||c.videoHeight,d=Math.min(i/l,o/r,1),p=Math.round(l*d),u=Math.round(r*d),m=document.createElement("canvas");m.width=p,m.height=u;const v=m.getContext("2d");return v?(v.drawImage(c,0,0,p,u),s.stop(),m.toDataURL("image/webp",t)):(s.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const Y="https://qaid.dev/lib/html2canvas.min.js",oe=1e4,ne=50;let k=null;function se(){if(typeof document>"u"||typeof window>"u")return!1;const e=document.createElement("canvas");return typeof e.getContext=="function"&&!!e.getContext("2d")}function ae(){return window.html2canvas?Promise.resolve(!0):k||(k=new Promise(e=>{if(!document.querySelector(`script[src="${Y}"]`)){const n=document.createElement("script");n.src=Y,n.async=!0,document.head.appendChild(n)}const i=Date.now(),o=()=>{if(window.html2canvas){e(!0);return}if(Date.now()-i>oe){k=null,e(!1);return}setTimeout(o,ne)};o()}),k)}async function Q(e={}){const{quality:t=.8,maxWidth:i=1280,maxHeight:o=800}=e;try{if(!await ae()||!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:r=>r instanceof HTMLElement?r.classList.contains("qaid-buttons")||r.classList.contains("qaid-targeting-overlay")||r.classList.contains("qaid-modal-container")||r.classList.contains("qaid-bottom-sheet")||r.classList.contains("qaid-backdrop")||r.classList.contains("qaid-selected-marker")||r.classList.contains("qaid-tooltip-text")||r.classList.contains("qaid-recording-indicator")||r.classList.contains("qaid-video-preview")||r.className?.toString().startsWith?.("qaid-"):!1}),a=s.width,c=s.height,l=Math.min(i/a,o/c,1);if(l<1){const r=Math.round(a*l),d=Math.round(c*l),p=document.createElement("canvas");p.width=r,p.height=d;const u=p.getContext("2d");return u?(u.drawImage(s,0,0,r,d),p.toDataURL("image/webp",t)):null}return s.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const re="https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";let de=e=>import(e),C=null,L=null;function ce(e){return C&&L===e||(L=e,C=Promise.resolve(de(e)).then(t=>{const i=t;if(!i||typeof i.QaidQuests!="function")throw new Error("quests module has no QaidQuests export");return i}).catch(t=>{throw C=null,L=null,t})),C}async function le(e){const t=await ce(e.moduleUrl),i=e.base.replace(/\/+$/,""),o=e.feedbackId!=null?{feedbackId:e.feedbackId}:void 0;return new t.QaidQuests({endpoint:`${i}/responses`,configUrl:`${i}/${encodeURIComponent(e.questId)}/definition`,apiKey:e.apiKey||void 0,metadata:o,onClose:e.onClose})}const G="qaid_visitor_id",J="qaid_hide_feedback";function A(e){return e?`${J}_${e}`:J}function he(e){try{return localStorage.getItem(A(e))==="1"}catch{return!1}}function Z(e,t=!0){try{t?localStorage.setItem(A(e),"1"):localStorage.removeItem(A(e))}catch{}}function ue(){try{let e=localStorage.getItem(G);return e||(e=crypto.randomUUID(),localStorage.setItem(G,e)),e}catch{return crypto.randomUUID()}}class tt{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};feedbackId=null;activeQuest=null;mousePos={x:0,y:0};isMobile=!1;visitorId;consoleCapture=null;videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;overlayContainer=null;captureLayer=null;crosshairH=null;crosshairV=null;scope=null;highlightBox=null;marker=null;modalContainer=null;backdrop=null;dismissBtn=null;cssVars={};keyboardController=null;activeThumbBtn=null;keyboardActivation=!1;dialogTrigger=null;dialogTrap=null;dialogRestoreInert=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundMouseMove;boundClick;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,colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#6366f1"},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"},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,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??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15},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??re}},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this),this.boundClick=this.handleClick.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=ue(),this.init()}applyVars(t){yt(t,this.cssVars)}announceMsg(t,i=!1){const o=this.overlayShadowRoot??this.shadowRoot;o&&zt(o,t,{assertive:i})}openDialogA11y(t,i){this.dialogTrigger=Nt(),Ft(t,i),this.dialogTrap=Ot(t),this.dialogRestoreInert=_t(t)}closeDialogA11y(){this.dialogTrap?.release(),this.dialogTrap=null,this.dialogRestoreInert&&(this.dialogRestoreInert(),this.dialogRestoreInert=null),Vt(this.dialogTrigger),this.dialogTrigger=null}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){wt(),this.cssVars=vt({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&&he(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=Jt(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom()}observeDom(){this.boundBeforeSwap=t=>{const i=t.newDocument;!i||this.destroyed||(this.shadowHost&&i.body.appendChild(this.shadowHost),this.overlayShadowHost&&i.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=ee()}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 i=document.createElement("style");if(i.textContent=H(),this.shadowRoot.appendChild(i),this.config.css){const r=document.createElement("style");r.textContent=this.config.css,this.shadowRoot.appendChild(r)}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:r,y:d}=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=`${d}px`:this.buttonsContainer.style.top=`${d}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.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.hideThumbs){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const d=document.createElement("button");d.type="button",d.className=n?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",d.setAttribute("aria-label",this.config.text.positiveLabel),d.innerHTML=this.config.positiveIcon||x,d.addEventListener("click",m=>this.handleThumbClick("up",m.currentTarget,m)),d.addEventListener("mouseenter",()=>this.showTooltip(d)),d.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(d);const p=document.createElement("div");p.className="qaid-tooltip-wrapper";const u=document.createElement("button");u.type="button",u.className=n?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",u.setAttribute("aria-label",this.config.text.negativeLabel),u.innerHTML=this.config.negativeIcon||E,u.addEventListener("click",m=>this.handleThumbClick("down",m.currentTarget,m)),u.addEventListener("mouseenter",()=>this.showTooltip(u)),u.addEventListener("mouseleave",()=>this.hideTooltip()),p.appendChild(u),this.buttonsContainer.appendChild(r),this.buttonsContainer.appendChild(p)}if(this.config.captureVideo&&_()){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const d=document.createElement("button");d.type="button",d.className=n?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",d.setAttribute("aria-label",this.config.text.recordLabel),d.innerHTML=this.config.recordIcon||ct,d.addEventListener("click",()=>this.startRecording()),d.addEventListener("mouseenter",()=>this.showTooltip(d)),d.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(d),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");if(t.textContent=H(),this.overlayShadowRoot.appendChild(t),this.config.css){const i=document.createElement("style");i.textContent=this.config.css,this.overlayShadowRoot.appendChild(i)}return this.overlayShadowRoot}tooltipElement=null;showTooltip(t){const i=this.tooltipElement;i.style.visibility="hidden",i.classList.add("qaid-tooltip-visible");const o=t.getBoundingClientRect(),n=i.getBoundingClientRect(),{top:s,left:a}=Yt(o,n,{width:window.innerWidth,height:window.innerHeight});i.style.top=`${s}px`,i.style.left=`${a}px`,i.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),Z(this.config.apiKey,!0)}handleThumbClick(t,i,o){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),Z(this.config.apiKey,!1)),this.config.skipTargeting)this.submitDirectFeedback(t,i);else{this.activeThumbBtn=i,i.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,n?this.startKeyboardTargetingFlow(t):this.startTargeting(t,o)}}submitDirectFeedback(t,i){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const o=i.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()}startTargeting(t,i){this.state="TARGETING",this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1,this.mousePos.x=i.clientX,this.mousePos.y=i.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.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.cssVars["--qaid-negative"]),this.createTargetingOverlay(),document.addEventListener("keydown",this.boundKeyDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("click",this.boundClick,!0)}startKeyboardTargetingFlow(t){this.state="TARGETING",this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1,document.body.style.setProperty("--qaid-positive",this.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.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=Dt({isExcluded:i=>I(i),onHighlight:i=>{const o=i.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}=T(i);this.announceMsg(`Targeting ${s||i.tagName.toLowerCase()}`)},onSelect:i=>this.selectKeyboardTarget(i),onCancel:()=>this.cancelTargeting()})}selectKeyboardTarget(t){const i=W(t,8);this.selectedBounds={...i,clickX:i.x+i.width/2,clickY:i.y+i.height/2,visible:!0};const{selector:o,text:n}=T(t);this.feedbackData.elementSelector=o,this.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.clearActiveThumb(),this.state="SELECTED",this.showSelectedMarker(),this.submitFeedback()}createTargetingOverlay(){const t=this.ensureOverlayHost();this.overlayContainer=document.createElement("div"),this.overlayContainer.className=`qaid-targeting-overlay qaid-type-${this.feedbackData.feedbackType}`,this.captureLayer=document.createElement("div"),this.captureLayer.className="qaid-capture-layer";const i=document.createElement("div");i.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=`
8
8
  <div class="qaid-scope-ring"></div>
9
9
  <div class="qaid-scope-ring-inner"></div>
10
10
  <div class="qaid-scope-dot"></div>
11
- `,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(i),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.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleKeyDown(t){t.key==="Escape"&&(this.isRecording?this.stopRecording():this.videoPreview?this.cancelRecordingPreview():this.state==="TARGETING"?this.cancelTargeting():this.state==="MODAL_OPEN"&&this.closeModal())}handleMouseMove(t){if(this.mousePos.x=t.clientX,this.mousePos.y=t.clientY,this.crosshairH&&(this.crosshairH.style.top=`${t.clientY}px`),this.crosshairV&&(this.crosshairV.style.left=`${t.clientX}px`),this.scope&&(this.scope.style.left=`${t.clientX}px`,this.scope.style.top=`${t.clientY}px`),this.captureLayer&&this.shadowHost){const i=[this.shadowHost,this.overlayShadowHost].filter(Boolean),o=K(t.clientX,t.clientY,i);if(o&&!T(o)){if(this.highlightBox){const n=o.getBoundingClientRect();this.highlightBox.style.transform=`translate(${n.left}px, ${n.top}px)`,this.highlightBox.style.width=`${n.width}px`,this.highlightBox.style.height=`${n.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation();const i=[this.shadowHost,this.overlayShadowHost].filter(Boolean),o=K(t.clientX,t.clientY,i);if(!o||T(o))return;const n=X(o,8);this.selectedBounds={...n,clickX:t.clientX,clickY:t.clientY,visible:!0};const{selector:s,text:a}=E(o);this.feedbackData.elementSelector=s,this.feedbackData.elementText=a,this.removeTargetingOverlay(),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),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.state="SELECTED",this.clearActiveThumb(),this.showSelectedMarker(),this.submitFeedback()}cancelTargeting(){this.keyboardController?.stop(),this.keyboardController=null,this.removeTargetingOverlay(),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),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.clearActiveThumb(),this.state="IDLE",this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.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.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.selectedBounds.x}px`,this.marker.style.top=`${this.selectedBounds.y}px`,this.marker.style.width=`${this.selectedBounds.width}px`,this.marker.style.height=`${this.selectedBounds.height}px`,this.marker.style.zIndex=String(this.config.zIndex+1),this.applyVars(this.marker),t.appendChild(this.marker)}hideSelectedMarker(){this.marker&&(this.marker.remove(),this.marker=null)}async submitFeedback(){let t=null;this.config.captureScreenshot&&(this.config.screenshotMethod==="dom"?t=await W(this.config.screenshotOptions):t=await Zt(this.config.screenshotOptions),t&&this.announceMsg("Screenshot captured"));const i=this.feedbackData.elementSelector?{x:this.selectedBounds.x,y:this.selectedBounds.y,width:this.selectedBounds.width,height:this.selectedBounds.height}:null,o={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:i,userAgent:navigator.userAgent};try{const n=await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(n.ok){const s=await n.json();this.feedbackId=s.id,this.announceMsg("Feedback sent")}}catch(n){console.error("Failed to submit feedback:",n),this.announceMsg("Failed to send feedback",!0)}this.state="MODAL_OPEN",this.showModal(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto")}showModal(){const t=this.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.closeModal()),this.applyVars(this.backdrop),this.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.boundKeyDown)}showBottomSheet(){const t=this.ensureOverlayHost(),i=document.createElement("div");i.className="qaid-bottom-sheet",i.style.zIndex=String(this.config.zIndex+3),i.innerHTML=`
11
+ `,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(i),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.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleKeyDown(t){t.key==="Escape"&&(this.isRecording?this.stopRecording():this.videoPreview?this.cancelRecordingPreview():this.state==="TARGETING"?this.cancelTargeting():this.state==="MODAL_OPEN"&&this.closeModal())}handleMouseMove(t){if(this.mousePos.x=t.clientX,this.mousePos.y=t.clientY,this.crosshairH&&(this.crosshairH.style.top=`${t.clientY}px`),this.crosshairV&&(this.crosshairV.style.left=`${t.clientX}px`),this.scope&&(this.scope.style.left=`${t.clientX}px`,this.scope.style.top=`${t.clientY}px`),this.captureLayer&&this.shadowHost){const i=[this.shadowHost,this.overlayShadowHost].filter(Boolean),o=X(t.clientX,t.clientY,i);if(o&&!I(o)){if(this.highlightBox){const n=o.getBoundingClientRect();this.highlightBox.style.transform=`translate(${n.left}px, ${n.top}px)`,this.highlightBox.style.width=`${n.width}px`,this.highlightBox.style.height=`${n.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation();const i=[this.shadowHost,this.overlayShadowHost].filter(Boolean),o=X(t.clientX,t.clientY,i);if(!o||I(o))return;const n=W(o,8);this.selectedBounds={...n,clickX:t.clientX,clickY:t.clientY,visible:!0};const{selector:s,text:a}=T(o);this.feedbackData.elementSelector=s,this.feedbackData.elementText=a,this.removeTargetingOverlay(),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),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.state="SELECTED",this.clearActiveThumb(),this.showSelectedMarker(),this.submitFeedback()}cancelTargeting(){this.keyboardController?.stop(),this.keyboardController=null,this.removeTargetingOverlay(),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),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.clearActiveThumb(),this.state="IDLE",this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.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.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.selectedBounds.x}px`,this.marker.style.top=`${this.selectedBounds.y}px`,this.marker.style.width=`${this.selectedBounds.width}px`,this.marker.style.height=`${this.selectedBounds.height}px`,this.marker.style.zIndex=String(this.config.zIndex+1),this.applyVars(this.marker),t.appendChild(this.marker)}hideSelectedMarker(){this.marker&&(this.marker.remove(),this.marker=null)}async submitFeedback(){let t=null;this.config.captureScreenshot&&(this.config.screenshotMethod==="dom"?t=await Q(this.config.screenshotOptions):t=await ie(this.config.screenshotOptions),t&&this.announceMsg("Screenshot captured"));const i=this.feedbackData.elementSelector?{x:this.selectedBounds.x,y:this.selectedBounds.y,width:this.selectedBounds.width,height:this.selectedBounds.height}:null,o={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:i,userAgent:navigator.userAgent};try{const s=await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(s.ok){const a=await s.json();this.feedbackId=a.id,this.announceMsg("Feedback sent")}}catch(s){console.error("Failed to submit feedback:",s),this.announceMsg("Failed to send feedback",!0)}const n=this.feedbackData.feedbackType;if(n&&await this.tryLaunchQuest(n,this.feedbackId)){this.resetFeedbackUi();return}this.state="MODAL_OPEN",this.showModal(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto")}questIdFor(t){const i=this.config.quests;return i.base&&i[t]||""}async tryLaunchQuest(t,i){const o=this.questIdFor(t);if(!o)return!1;try{return this.activeQuest?.destroy(),this.activeQuest=await le({questId:o,base:this.config.quests.base,apiKey:this.config.quests.apiKey||void 0,moduleUrl:this.config.quests.moduleUrl,feedbackId:i,onClose:()=>{this.activeQuest=null}}),!0}catch(n){return console.error("Failed to launch quest:",n),this.activeQuest=null,!1}}resetFeedbackUi(){this.hideSelectedMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackId=null,this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}showModal(){const t=this.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.closeModal()),this.applyVars(this.backdrop),this.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.boundKeyDown)}showBottomSheet(){const t=this.ensureOverlayHost(),i=document.createElement("div");i.className="qaid-bottom-sheet",i.style.zIndex=String(this.config.zIndex+3),i.innerHTML=`
12
12
  <div class="qaid-bottom-sheet-content">
13
13
  <div class="qaid-bottom-sheet-handle"></div>
14
14
  ${this.getModalContent()}
15
15
  </div>
16
- `,this.applyVars(i),t.appendChild(i),this.modalContainer=i,this.setupModalInteractions()}showPositionedModal(){const t=this.ensureOverlayHost(),{modal:i,arrow:o}=jt(this.selectedBounds,window.innerWidth,window.innerHeight,{width:this.config.modalWidth,height:280,arrowHeight:12,gap:8,viewportPadding:16});this.modalContainer=document.createElement("div"),this.modalContainer.className=`qaid-modal-container qaid-${i.position}`,this.modalContainer.style.top=`${i.top}px`,this.modalContainer.style.left=`${i.left}px`,this.modalContainer.style.zIndex=String(this.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.innerHTML=this.getModalContent(),this.modalContainer.appendChild(n),this.modalContainer.appendChild(s),this.applyVars(this.modalContainer),t.appendChild(this.modalContainer),this.setupModalInteractions()}getModalContent(){const t=this.feedbackData.feedbackType==="up",i=this.config.positiveIcon||x,o=this.config.negativeIcon||S;return`
16
+ `,this.applyVars(i),t.appendChild(i),this.modalContainer=i,this.setupModalInteractions()}showPositionedModal(){const t=this.ensureOverlayHost(),{modal:i,arrow:o}=Qt(this.selectedBounds,window.innerWidth,window.innerHeight,{width:this.config.modalWidth,height:280,arrowHeight:12,gap:8,viewportPadding:16});this.modalContainer=document.createElement("div"),this.modalContainer.className=`qaid-modal-container qaid-${i.position}`,this.modalContainer.style.top=`${i.top}px`,this.modalContainer.style.left=`${i.left}px`,this.modalContainer.style.zIndex=String(this.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.innerHTML=this.getModalContent(),this.modalContainer.appendChild(n),this.modalContainer.appendChild(s),this.applyVars(this.modalContainer),t.appendChild(this.modalContainer),this.setupModalInteractions()}getModalContent(){const t=this.feedbackData.feedbackType==="up",i=this.config.positiveIcon||x,o=this.config.negativeIcon||E;return`
17
17
  <div class="qaid-modal-header">
18
18
  <button type="button" class="${this.config.buttonClass?`qaid-type-toggle qaid-type-toggle-custom ${this.config.buttonClass} ${t?"qaid-btn-up":"qaid-btn-down"}`:`qaid-type-toggle ${t?"qaid-type-up":"qaid-type-down"}`}" title="Click to switch" aria-pressed="${t}" aria-label="${t?"Feedback type: positive":"Feedback type: negative"}">
19
19
  ${t?i:o}
@@ -27,5 +27,5 @@
27
27
  <div class="qaid-btn-row">
28
28
  <button type="button" class="qaid-btn-submit">${this.config.text.skipButton}</button>
29
29
  </div>
30
- `}setupModalInteractions(){this.openDialogA11y(this.modalContainer,{labelledbyId:`qaid-modal-title-${this.uid}`,describedbyId:`qaid-modal-subtitle-${this.uid}`});const t=this.modalContainer.querySelector(".qaid-textarea"),i=this.modalContainer.querySelector(".qaid-btn-submit");t&&(setTimeout(()=>t.focus(),100),t.addEventListener("input",()=>{i&&(i.textContent=t.value.trim()?this.config.text.submitButton:this.config.text.skipButton)})),i&&i.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.feedbackData.feedbackType==="up"?"down":"up";this.feedbackData.feedbackType=n,this.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.config.positiveIcon||x,a=this.config.negativeIcon||S;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.announceMsg(c),this.feedbackId&&fetch(`${this.config.endpoint}/${this.feedbackId}`,{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){if(this.feedbackId){try{await fetch(`${this.config.endpoint}/${this.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t})})}catch(i){console.error("Failed to submit feedback message:",i)}this.feedbackId=null}this.closeModal()}closeModal(){this.state==="MODAL_OPEN"&&this.feedbackId&&fetch(`${this.config.endpoint}/${this.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(t=>console.error("Failed to finalize feedback:",t)),this.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.boundKeyDown),this.hideSelectedMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackId=null,this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}async startRecording(){if(!(this.isRecording||this.state!=="IDLE"))try{this.networkCapture=V(),this.videoRecorder=U({maxDuration:this.config.videoOptions.maxDuration}),this.videoRecorder.onTick(t=>{this.updateRecordingTimer(t)}),this.videoRecorder.onStop(t=>{this.isRecording&&(this.recordedBlob=t,this.isRecording=!1,this.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.boundKeyDown),this.setButtonsDisabled(!1),t&&t.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.announceMsg("Recording started"),this.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.boundKeyDown)}catch{this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}showRecordingIndicator(){const t=this.ensureOverlayHost();this.recordingIndicator=document.createElement("div"),this.recordingIndicator.className="qaid-recording-indicator",this.recordingIndicator.style.zIndex=String(this.config.zIndex+100);const i=document.createElement("div");i.className="qaid-recording-dot";const o=document.createElement("span");o.className="qaid-recording-time",o.textContent=this.formatTime(this.config.videoOptions.maxDuration);const n=document.createElement("button");n.type="button",n.className="qaid-recording-stop",n.textContent="Stop",n.addEventListener("click",()=>this.stopRecording()),this.recordingIndicator.appendChild(i),this.recordingIndicator.appendChild(o),this.recordingIndicator.appendChild(n),this.applyVars(this.recordingIndicator),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const i=this.recordingIndicator.querySelector(".qaid-recording-time");if(i){const o=Math.max(0,this.config.videoOptions.maxDuration-t);i.textContent=this.formatTime(o),o>0&&o<=5&&this.announceMsg(`${o} second${o===1?"":"s"} remaining`)}}formatTime(t){const i=Math.floor(t/60),o=t%60;return`${i}:${o.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.ensureOverlayHost(),i=URL.createObjectURL(this.recordedBlob);this.videoPreview=document.createElement("div"),this.videoPreview.className="qaid-video-preview",this.videoPreview.style.zIndex=String(this.config.zIndex+100);const o=document.createElement("div");o.className="qaid-video-preview-box";const n=document.createElement("h3");n.textContent="Review your recording",n.id=`qaid-video-title-${this.uid}`;const s=document.createElement("video");s.src=i,s.controls=!0,s.autoplay=!0,s.muted=!0;const a=document.createElement("textarea");a.placeholder="Optional: Describe the issue you recorded...",a.setAttribute("aria-label","Describe the issue you recorded");const c=document.createElement("div");c.className="qaid-video-preview-actions";const l=document.createElement("button");l.type="button",l.className="qaid-video-btn qaid-video-btn-cancel",l.textContent="Cancel",l.addEventListener("click",()=>this.cancelRecordingPreview());const r=document.createElement("button");r.type="button",r.className="qaid-video-btn qaid-video-btn-rerecord",r.textContent="Re-record",r.addEventListener("click",()=>{this.cancelRecordingPreview(),this.startRecording()});const d=document.createElement("button");d.type="button",d.className="qaid-video-btn qaid-video-btn-send",d.textContent="Send",d.addEventListener("click",()=>{const p=a.value.trim()||null;this.submitVideoFeedback(p,d)}),c.appendChild(l),c.appendChild(r),c.appendChild(d),o.appendChild(n),o.appendChild(s),o.appendChild(a),o.appendChild(c),this.videoPreview.appendChild(o),this.applyVars(this.videoPreview),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.openDialogA11y(o,{labelledbyId:n.id}),document.addEventListener("keydown",this.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.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.boundKeyDown)}async submitVideoFeedback(t,i){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,i.disabled=!0,i.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.visitorId),this.config.apiKey&&o.append("apiKey",this.config.apiKey),t&&o.append("message",t),this.consoleCapture&&o.append("consoleErrors",JSON.stringify(this.consoleCapture.errors)),this.networkCapture&&o.append("networkErrors",JSON.stringify(this.networkCapture.errors));try{const n=await fetch(`${this.config.endpoint}/video`,{method:"POST",body:o});n.ok?this.announceMsg("Recording sent"):(console.error("Failed to submit video feedback:",await n.text()),this.announceMsg("Failed to send recording",!0))}catch(n){console.error("Failed to submit video feedback:",n),this.announceMsg("Failed to send recording",!0)}this.isSendingVideo=!1,this.removeVideoPreview(),this.cleanupRecording()}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.setButtonsDisabled(!1),this.overlayShadowHost&&this.state==="IDLE"&&(this.overlayShadowHost.style.pointerEvents="none")}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(){this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.keyboardController?.stop(),this.keyboardController=null,this.clearActiveThumb(),this.closeDialogA11y(),this.cleanupRecording(),this.removeVideoPreview(),this.consoleCapture&&(this.consoleCapture.restore(),this.consoleCapture=null),window.removeEventListener("resize",this.boundResize),document.removeEventListener("keydown",this.boundKeyDown),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),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.overlayContainer=null,this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null,this.marker=null,this.modalContainer=null,this.backdrop=null,this.dismissBtn=null,this.tooltipElement=null,vt()}}function Z(e){return document.querySelector(e)?.textContent?.trim()??""}function ae(){const e=document.querySelector('script[type="application/json"][data-feedback-config]');if(!e)return null;const t=e.textContent?.trim();if(!t)return null;try{const i=JSON.parse(t);return i.cssSelector&&!i.css&&(i.css=Z(i.cssSelector),delete i.cssSelector),i}catch{return null}}function re(e){const t=e.getAttribute("data-endpoint");if(!t)return null;const i=e.getAttribute("data-position"),o=e.getAttribute("data-zindex"),n=e.getAttribute("data-positive-color"),s=e.getAttribute("data-negative-color"),a=e.getAttribute("data-marker-color"),c=e.getAttribute("data-container"),l=e.getAttribute("data-button-class"),r=e.getAttribute("data-skip-targeting"),d=e.getAttribute("data-incognito"),p=e.getAttribute("data-button-size"),u=e.getAttribute("data-offset-x"),m=e.getAttribute("data-offset-y"),v=e.getAttribute("data-modal-width"),b=e.getAttribute("data-backdrop-opacity"),f=e.getAttribute("data-font-family"),y=e.getAttribute("data-font-size"),h=e.getAttribute("data-tooltip"),w=e.getAttribute("data-modal-title"),tt=e.getAttribute("data-modal-subtitle"),et=e.getAttribute("data-placeholder"),it=e.getAttribute("data-submit-button"),ot=e.getAttribute("data-skip-button"),de=e.getAttribute("data-positive-icon"),ce=e.getAttribute("data-negative-icon"),le=e.getAttribute("data-api-key"),he=e.getAttribute("data-capture-screenshot"),I=e.getAttribute("data-screenshot-quality"),D=e.getAttribute("data-screenshot-max-width"),A=e.getAttribute("data-screenshot-max-height"),ue=e.getAttribute("data-capture-video"),pe=e.getAttribute("data-hide-thumbs"),me=e.getAttribute("data-hide-dismiss"),nt=e.getAttribute("data-video-max-duration"),fe=e.getAttribute("data-screenshot-method"),be=e.getAttribute("data-direction"),st=e.getAttribute("data-css-selector");return{endpoint:t,css:st?Z(st):void 0,apiKey:le??void 0,captureScreenshot:he==="true"?!0:void 0,screenshotOptions:I||D||A?{quality:I?parseFloat(I):void 0,maxWidth:D?parseInt(D,10):void 0,maxHeight:A?parseInt(A,10):void 0}:void 0,container:c??void 0,buttonClass:l??void 0,direction:be??void 0,position:i??void 0,zIndex:o?parseInt(o,10):void 0,skipTargeting:r==="true"?!0:void 0,incognito:d==="true"?!0:void 0,buttonSize:p??void 0,offset:u||m?{x:u?parseInt(u,10):void 0,y:m?parseInt(m,10):void 0}:void 0,modalWidth:v?parseInt(v,10):void 0,backdropOpacity:b?parseFloat(b):void 0,fontFamily:f??void 0,fontSize:y?parseInt(y,10):void 0,colors:{positive:n??void 0,negative:s??void 0,marker:a??void 0},text:h||w||tt||et||it||ot?{tooltip:h??void 0,modalTitle:w??void 0,modalSubtitle:tt??void 0,placeholder:et??void 0,submitButton:it??void 0,skipButton:ot??void 0}:void 0,positiveIcon:de??void 0,negativeIcon:ce??void 0,screenshotMethod:fe??void 0,captureVideo:ue==="true"?!0:void 0,hideThumbs:pe==="true"?!0:void 0,hideDismiss:me==="true"?!0:void 0,videoOptions:nt?{maxDuration:parseInt(nt,10)}:void 0}}if(typeof document<"u"){const e=()=>{const t=document.currentScript,i=ae(),o=t?re(t):null,n=i??o;n?.endpoint&&new Q(n)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}g.QaidFeedback=Q,g.captureDomScreenshot=W,g.captureNetworkErrors=V,g.createVideoRecorder=U,g.getSupportedMimeType=_,g.isDomScreenshotSupported=ie,g.isVideoRecordingSupported=F,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
30
+ `}setupModalInteractions(){this.openDialogA11y(this.modalContainer,{labelledbyId:`qaid-modal-title-${this.uid}`,describedbyId:`qaid-modal-subtitle-${this.uid}`});const t=this.modalContainer.querySelector(".qaid-textarea"),i=this.modalContainer.querySelector(".qaid-btn-submit");t&&(setTimeout(()=>t.focus(),100),t.addEventListener("input",()=>{i&&(i.textContent=t.value.trim()?this.config.text.submitButton:this.config.text.skipButton)})),i&&i.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.feedbackData.feedbackType==="up"?"down":"up";this.feedbackData.feedbackType=n,this.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.config.positiveIcon||x,a=this.config.negativeIcon||E;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.announceMsg(c),this.feedbackId&&fetch(`${this.config.endpoint}/${this.feedbackId}`,{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){if(this.feedbackId){try{await fetch(`${this.config.endpoint}/${this.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t})})}catch(i){console.error("Failed to submit feedback message:",i)}this.feedbackId=null}this.closeModal()}closeModal(){this.state==="MODAL_OPEN"&&this.feedbackId&&fetch(`${this.config.endpoint}/${this.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(t=>console.error("Failed to finalize feedback:",t)),this.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.boundKeyDown),this.resetFeedbackUi()}async startRecording(){if(!(this.isRecording||this.state!=="IDLE"))try{this.networkCapture=U(),this.videoRecorder=j({maxDuration:this.config.videoOptions.maxDuration}),this.videoRecorder.onTick(t=>{this.updateRecordingTimer(t)}),this.videoRecorder.onStop(t=>{this.isRecording&&(this.recordedBlob=t,this.isRecording=!1,this.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.boundKeyDown),this.setButtonsDisabled(!1),t&&t.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.announceMsg("Recording started"),this.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.boundKeyDown)}catch{this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}showRecordingIndicator(){const t=this.ensureOverlayHost();this.recordingIndicator=document.createElement("div"),this.recordingIndicator.className="qaid-recording-indicator",this.recordingIndicator.style.zIndex=String(this.config.zIndex+100);const i=document.createElement("div");i.className="qaid-recording-dot";const o=document.createElement("span");o.className="qaid-recording-time",o.textContent=this.formatTime(this.config.videoOptions.maxDuration);const n=document.createElement("button");n.type="button",n.className="qaid-recording-stop",n.textContent="Stop",n.addEventListener("click",()=>this.stopRecording()),this.recordingIndicator.appendChild(i),this.recordingIndicator.appendChild(o),this.recordingIndicator.appendChild(n),this.applyVars(this.recordingIndicator),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const i=this.recordingIndicator.querySelector(".qaid-recording-time");if(i){const o=Math.max(0,this.config.videoOptions.maxDuration-t);i.textContent=this.formatTime(o),o>0&&o<=5&&this.announceMsg(`${o} second${o===1?"":"s"} remaining`)}}formatTime(t){const i=Math.floor(t/60),o=t%60;return`${i}:${o.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.ensureOverlayHost(),i=URL.createObjectURL(this.recordedBlob);this.videoPreview=document.createElement("div"),this.videoPreview.className="qaid-video-preview",this.videoPreview.style.zIndex=String(this.config.zIndex+100);const o=document.createElement("div");o.className="qaid-video-preview-box";const n=document.createElement("h3");n.textContent="Review your recording",n.id=`qaid-video-title-${this.uid}`;const s=document.createElement("video");s.src=i,s.controls=!0,s.autoplay=!0,s.muted=!0;const a=document.createElement("textarea");a.placeholder="Optional: Describe the issue you recorded...",a.setAttribute("aria-label","Describe the issue you recorded");const c=document.createElement("div");c.className="qaid-video-preview-actions";const l=document.createElement("button");l.type="button",l.className="qaid-video-btn qaid-video-btn-cancel",l.textContent="Cancel",l.addEventListener("click",()=>this.cancelRecordingPreview());const r=document.createElement("button");r.type="button",r.className="qaid-video-btn qaid-video-btn-rerecord",r.textContent="Re-record",r.addEventListener("click",()=>{this.cancelRecordingPreview(),this.startRecording()});const d=document.createElement("button");d.type="button",d.className="qaid-video-btn qaid-video-btn-send",d.textContent="Send",d.addEventListener("click",()=>{const p=a.value.trim()||null;this.submitVideoFeedback(p,d)}),c.appendChild(l),c.appendChild(r),c.appendChild(d),o.appendChild(n),o.appendChild(s),o.appendChild(a),o.appendChild(c),this.videoPreview.appendChild(o),this.applyVars(this.videoPreview),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.openDialogA11y(o,{labelledbyId:n.id}),document.addEventListener("keydown",this.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.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.boundKeyDown)}async submitVideoFeedback(t,i){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,i.disabled=!0,i.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.visitorId),this.config.apiKey&&o.append("apiKey",this.config.apiKey),t&&o.append("message",t),this.consoleCapture&&o.append("consoleErrors",JSON.stringify(this.consoleCapture.errors)),this.networkCapture&&o.append("networkErrors",JSON.stringify(this.networkCapture.errors));let n=null;try{const s=await fetch(`${this.config.endpoint}/video`,{method:"POST",body:o});if(s.ok){this.announceMsg("Recording sent");try{n=(await s.json())?.id??null}catch{}}else console.error("Failed to submit video feedback:",await s.text()),this.announceMsg("Failed to send recording",!0)}catch(s){console.error("Failed to submit video feedback:",s),this.announceMsg("Failed to send recording",!0)}this.isSendingVideo=!1,this.removeVideoPreview(),this.cleanupRecording(),await this.tryLaunchQuest("video",n)}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.setButtonsDisabled(!1),this.overlayShadowHost&&this.state==="IDLE"&&(this.overlayShadowHost.style.pointerEvents="none")}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(){this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.keyboardController?.stop(),this.keyboardController=null,this.clearActiveThumb(),this.closeDialogA11y(),this.cleanupRecording(),this.removeVideoPreview(),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.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),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.overlayContainer=null,this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null,this.marker=null,this.modalContainer=null,this.backdrop=null,this.dismissBtn=null,this.tooltipElement=null,xt()}}function et(e){return document.querySelector(e)?.textContent?.trim()??""}function pe(){const e=document.querySelector('script[type="application/json"][data-feedback-config]');if(!e)return null;const t=e.textContent?.trim();if(!t)return null;try{const i=JSON.parse(t);return i.cssSelector&&!i.css&&(i.css=et(i.cssSelector),delete i.cssSelector),i}catch{return null}}function me(e){const t=e.getAttribute("data-endpoint");if(!t)return null;const i=e.getAttribute("data-position"),o=e.getAttribute("data-zindex"),n=e.getAttribute("data-positive-color"),s=e.getAttribute("data-negative-color"),a=e.getAttribute("data-marker-color"),c=e.getAttribute("data-container"),l=e.getAttribute("data-button-class"),r=e.getAttribute("data-skip-targeting"),d=e.getAttribute("data-incognito"),p=e.getAttribute("data-button-size"),u=e.getAttribute("data-offset-x"),m=e.getAttribute("data-offset-y"),v=e.getAttribute("data-modal-width"),b=e.getAttribute("data-backdrop-opacity"),f=e.getAttribute("data-font-family"),y=e.getAttribute("data-font-size"),h=e.getAttribute("data-tooltip"),w=e.getAttribute("data-modal-title"),it=e.getAttribute("data-modal-subtitle"),ot=e.getAttribute("data-placeholder"),nt=e.getAttribute("data-submit-button"),st=e.getAttribute("data-skip-button"),fe=e.getAttribute("data-positive-icon"),be=e.getAttribute("data-negative-icon"),ge=e.getAttribute("data-api-key"),ve=e.getAttribute("data-capture-screenshot"),D=e.getAttribute("data-screenshot-quality"),M=e.getAttribute("data-screenshot-max-width"),R=e.getAttribute("data-screenshot-max-height"),ye=e.getAttribute("data-capture-video"),we=e.getAttribute("data-hide-thumbs"),xe=e.getAttribute("data-hide-dismiss"),at=e.getAttribute("data-video-max-duration"),qe=e.getAttribute("data-screenshot-method"),ke=e.getAttribute("data-direction"),rt=e.getAttribute("data-css-selector"),dt=e.getAttribute("data-quest-base"),Ce=e.getAttribute("data-quest-up"),Se=e.getAttribute("data-quest-down"),Ee=e.getAttribute("data-quest-video"),Te=e.getAttribute("data-quest-api-key"),Ie=e.getAttribute("data-quest-module-url");return{endpoint:t,css:rt?et(rt):void 0,apiKey:ge??void 0,captureScreenshot:ve==="true"?!0:void 0,screenshotOptions:D||M||R?{quality:D?parseFloat(D):void 0,maxWidth:M?parseInt(M,10):void 0,maxHeight:R?parseInt(R,10):void 0}:void 0,container:c??void 0,buttonClass:l??void 0,direction:ke??void 0,position:i??void 0,zIndex:o?parseInt(o,10):void 0,skipTargeting:r==="true"?!0:void 0,incognito:d==="true"?!0:void 0,buttonSize:p??void 0,offset:u||m?{x:u?parseInt(u,10):void 0,y:m?parseInt(m,10):void 0}:void 0,modalWidth:v?parseInt(v,10):void 0,backdropOpacity:b?parseFloat(b):void 0,fontFamily:f??void 0,fontSize:y?parseInt(y,10):void 0,colors:{positive:n??void 0,negative:s??void 0,marker:a??void 0},text:h||w||it||ot||nt||st?{tooltip:h??void 0,modalTitle:w??void 0,modalSubtitle:it??void 0,placeholder:ot??void 0,submitButton:nt??void 0,skipButton:st??void 0}:void 0,positiveIcon:fe??void 0,negativeIcon:be??void 0,screenshotMethod:qe??void 0,captureVideo:ye==="true"?!0:void 0,hideThumbs:we==="true"?!0:void 0,hideDismiss:xe==="true"?!0:void 0,videoOptions:at?{maxDuration:parseInt(at,10)}:void 0,quests:dt?{base:dt,up:Ce??void 0,down:Se??void 0,video:Ee??void 0,apiKey:Te??void 0,moduleUrl:Ie??void 0}:void 0}}if(typeof document<"u"){const e=()=>{const t=document.currentScript,i=pe(),o=t?me(t):null,n=i??o;n?.endpoint&&new tt(n)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}g.QaidFeedback=tt,g.captureDomScreenshot=Q,g.captureNetworkErrors=U,g.createVideoRecorder=j,g.getSupportedMimeType=K,g.isDomScreenshotSupported=se,g.isVideoRecordingSupported=_,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
31
31
  //# sourceMappingURL=qaid.umd.cjs.map