@qaiddev/thumbs-embed 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/loader.js CHANGED
@@ -1,7 +1,5 @@
1
- import { a } from "./chunks/bootstrap-rINL2pCt.js";
2
- import { Q as e } from "./chunks/bootstrap-rINL2pCt.js";
3
- a();
1
+ import { Q as d } from "./chunks/loader-DnJ3MHkt.js";
4
2
  export {
5
- e as QaidFeedback
3
+ d as QaidFeedback
6
4
  };
7
5
  //# sourceMappingURL=loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sources":["../src/loader.ts"],"sourcesContent":["/**\n * Minimal ESM loader entry for progressive delivery.\n *\n * ```html\n * <script type=\"module\" src=\"…/loader.js\" data-endpoint=\"/api/feedback\"></script>\n * ```\n *\n * Ships only the core (thumbs buttons, modal, element targeting, submit).\n * Screenshot capture, the annotation editor, and the video subsystem\n * (including redaction) load on demand as separate chunks the first time each\n * is used — so a visitor who only gives a thumbs-up never downloads them.\n *\n * The full programmatic API (createVideoRecorder, openAnnotationEditor, …)\n * lives on the package's main entry (`@qaiddev/thumbs-embed`).\n */\n\nimport { QaidFeedback } from \"./embed\";\nimport { autoInit } from \"./bootstrap\";\n\nexport { QaidFeedback };\nexport type { FeedbackConfig } from \"./types\";\n\nautoInit();\n"],"names":["autoInit"],"mappings":";;AAsBAA,EAAA;"}
1
+ {"version":3,"file":"loader.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/dist/qaid.umd.cjs CHANGED
@@ -18,9 +18,9 @@
18
18
  <path stroke-linecap="round" stroke-linejoin="round" d="M9 14L4 9l5-5M4 9h11a5 5 0 010 10h-4"/>
19
19
  </svg>`,_t=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
20
20
  <path stroke-linecap="round" stroke-linejoin="round" d="M20 6L9 17l-5-5"/>
21
- </svg>`,Vt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
21
+ </svg>`,Ft=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
22
22
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6L6 18"/>
23
- </svg>`,Ft="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-type-static{width:2.5rem;height:2.5rem;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:var(--qaid-marker, #6366f1);color:var(--qaid-marker-text, white)}.qaid-type-static svg{width:1.25rem;height:1.25rem}.qaid-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size: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 0 auto;height:100vh;height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#0009;z-index:99998;animation:qaid-fadeIn .2s ease-out}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}.qaid-video-preview-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px #00000080;width:560px;max-width:100%;max-height:100%;overflow-y:auto;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-video-preview-box h3{font-size:1.125rem;font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;max-height:50vh;max-height:50dvh;object-fit:contain;border-radius:.5rem;background:#000;margin-bottom:1rem}.qaid-video-preview-box textarea{width:100%;height:4rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:.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)}.qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:1rem;font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:.8125rem;line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:.8125rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}.qaid-annotate-colors{display:flex;gap:.25rem;align-items:center}button.qaid-annotate-swatch{width:28px;height:28px;min-width:28px;padding:0;border-radius:9999px;border:2px solid light-dark(#d1d5db,#4b5563);background:var(--qaid-swatch, #000);cursor:pointer;-webkit-appearance:none;appearance:none;transition:transform .1s,box-shadow .15s,border-color .15s}button.qaid-annotate-swatch:hover{transform:scale(1.12)}button.qaid-annotate-swatch[aria-pressed=true]{border-color:light-dark(#111827,#f9fafb);box-shadow:0 0 0 2px var(--qaid-swatch)}@media(forced-colors:active){button.qaid-annotate-swatch[aria-pressed=true]{outline:2px solid Highlight;outline-offset:1px}}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6366f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6366f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6366f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}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}}",Nt="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let L=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-feedback:hover{background:var(--qaid-marker,#6366f1);color:var(--qaid-marker-text,#fff)}button.qaid-btn svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",jt={small:36,medium:48,large:64},Kt={small:18,medium:24,large:32};function Wt(i,t,e){const[o,n,s]=[i,t,e].map(a=>(a=a/255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)));return .2126*o+.7152*n+.0722*s}function Xt(i){if(i.startsWith("#")){const e=i.slice(1),o=e.length===3?e.split("").map(s=>s+s).join(""):e,n=parseInt(o,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=i.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function Yt(i){const t=Xt(i);return t&&Wt(t.r,t.g,t.b)>.4?"black":"white"}function Qt(i={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:e="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}=i,d=jt[n],r=Kt[n],h=Yt(o);return{"--qaid-positive":t,"--qaid-negative":e,"--qaid-marker":o,"--qaid-marker-text":h,"--qaid-btn-size":`${d}px`,"--qaid-icon-size":`${r}px`,"--qaid-modal-width":`${s}px`,"--qaid-backdrop-opacity":String(a),"--qaid-font-family":c,"--qaid-font-size":`${l}px`}}function Gt(i,t){for(const[e,o]of Object.entries(t))i.style.setProperty(e,o)}function Q(){return Ft+Ut}function Jt(){if(L++,L>1)return;const i=document.createElement("style");i.id="qaid-styles",i.textContent=Nt,document.head.appendChild(i)}function Zt(){L<=0||(L--,L===0&&document.getElementById("qaid-styles").remove())}const G="data-qaid-a11y-live",te="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;",ee=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function ie(i){return i.ownerDocument||document}function oe(i,t){const e=t?"assertive":"polite",o=i.querySelector(`[${G}="${e}"]`);if(o)return o;const s=ie(i).createElement("div");return s.setAttribute(G,e),s.setAttribute("role",t?"alert":"status"),s.setAttribute("aria-live",t?"assertive":"polite"),s.setAttribute("aria-atomic","true"),s.style.cssText=te,i.appendChild(s),s}function ne(i,t,e={}){const o=oe(i,!!e.assertive);o.textContent="",o.textContent=t}function se(i){return i.hasAttribute("disabled")?!0:i.disabled===!0}function ae(i){let t=i;for(;t;){if(t.hasAttribute("hidden"))return!0;const e=t.style;if(e&&(e.display==="none"||e.visibility==="hidden"||e.visibility==="collapse"))return!0;t=t.parentElement}return!1}function J(i){return Array.from(i.querySelectorAll(ee)).filter(e=>!(e.getAttribute("tabindex")==="-1"||e instanceof HTMLInputElement&&e.type==="hidden"||e instanceof HTMLAnchorElement&&!e.getAttribute("href")||se(e)||ae(e)))}function Z(i){let t=i.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function re(i){const t=i.ownerDocument||document;let e=!1;const o=s=>{if(s.key!=="Tab")return;const a=J(i);if(a.length===0){s.preventDefault(),i.focus();return}const c=a[0],l=a[a.length-1],d=Z(t),r=d?a.indexOf(d)!==-1:!1;s.shiftKey?(!r||d===c)&&(s.preventDefault(),l.focus()):(!r||d===l)&&(s.preventDefault(),c.focus())};i.addEventListener("keydown",o);const n=J(i);return n.length>0?n[0].focus():(i.hasAttribute("tabindex")||(i.setAttribute("tabindex","-1"),e=!0),i.focus()),{release(){i.removeEventListener("keydown",o),e&&(i.removeAttribute("tabindex"),e=!1)}}}function de(){return Z(document)}function ce(i){if(!(!i||typeof i.focus!="function"))try{i.focus()}catch{}}function le(i,t={}){i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),t.labelledbyId&&i.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&i.setAttribute("aria-describedby",t.describedbyId),t.label&&i.setAttribute("aria-label",t.label)}function he(i,t){let e=i;for(;e&&e!==t;){const o=e.parentNode;if(o===t)return e;if(o&&o.host){e=o.host;continue}if(!o)return null;e=o}return null}function ue(i){const e=(i.ownerDocument||document).body;if(!e)return()=>{};const o=he(i,e),n=[];return Array.from(e.children).forEach(s=>{if(!(s instanceof HTMLElement)||o&&s===o)return;const a=s.inert===!0,c=s.getAttribute("aria-hidden");a&&c==="true"||(s.inert=!0,s.setAttribute("aria-hidden","true"),n.push({el:s,prevInert:a,prevAriaHidden:c}))}),function(){for(;n.length;){const a=n.pop();a.el.inert=a.prevInert,a.prevAriaHidden===null?a.el.removeAttribute("aria-hidden"):a.el.setAttribute("aria-hidden",a.prevAriaHidden)}}}const tt={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function pe(i,t,e,o,n){const s=i.y,a=t-(i.y+i.height);if(a>=e+o)return{top:i.y+i.height+o,position:"below"};if(s>=e+o)return{top:i.y-e-o,position:"above"};const c=a>s?"below":"above";let l;return c==="below"?l=Math.min(i.y+i.height+o,t-e-n):l=Math.max(n,i.y-e-o),{top:l,position:c}}function fe(i,t,e,o){let s=i.x+i.width/2-e/2;return s=Math.max(o,Math.min(s,t-e-o)),s}function be(i,t,e,o=24,n=24){const a=i.clickX-t-n/2;return Math.max(o,Math.min(a,e-o-n/2))}function ge(i,t,e,o=tt){const n=o.height+o.arrowHeight,s=pe(i,e,n,o.gap,o.viewportPadding),a=fe(i,t,o.width,o.viewportPadding);return{top:s.top,left:a,position:s.position}}function me(i,t,e,o={}){const n=o.gap??8;let s=i.bottom+n;s+t.height>e.height-n&&(s=i.top-t.height-n);let a=i.left;return a<n?a=n:a+t.width>e.width-n&&(a=e.width-t.width-n),s<n?s=n:s+t.height>e.height-n&&(s=e.height-t.height-n),{top:s,left:a}}function ve(i,t,e,o=tt){const n=ge(i,t,e,o),s=be(i,n.left,o.width);return{modal:n,arrow:{left:s}}}const ye=20;function we(i){const t=[],e=console.error,o=console.warn,n=console.log,s=(a,c)=>{const l={message:c.map(d=>String(d)).join(" "),timestamp:Date.now(),level:a};t.length>=ye&&t.shift(),t.push(l),i&&i(l)};return console.error=function(...a){s("error",a),e.apply(console,a)},console.warn=function(...a){s("warn",a),o.apply(console,a)},console.log=function(...a){s("log",a),n.apply(console,a)},{errors:t,restore:()=>{console.error=e,console.warn=o,console.log=n}}}function q(i,t,e){const o=document.createElement(i);if(t)for(const[n,s]of Object.entries(t))n==="className"?o.className=s:o.setAttribute(n,s);return o}function ke(i=640){return typeof window<"u"&&window.innerWidth<i}function et(i,t,e){const o=e.map(s=>s.style.visibility);e.forEach(s=>s.style.visibility="hidden");const n=document.elementFromPoint(i,t);return e.forEach((s,a)=>s.style.visibility=o[a]),n}function B(i){return i?i.hasAttribute("data-qaid-embed")||i.hasAttribute("data-qaid-embed-overlay")?!0:!!i.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function it(i,t=0){const e=i.getBoundingClientRect();return{x:e.left-t,y:e.top-t,width:e.width+t*2,height:e.height+t*2}}const xe="https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";let qe=i=>import(i),I=null,z=null;function Ce(i){return I&&z===i||(z=i,I=Promise.resolve(qe(i)).then(t=>{const e=t;if(!e||typeof e.QaidQuests!="function")throw new Error("quests module has no QaidQuests export");return e}).catch(t=>{throw I=null,z=null,t})),I}async function Se(i){const t=await Ce(i.moduleUrl),e=i.base.replace(/\/+$/,""),o=i.feedbackId!=null?{feedbackId:i.feedbackId}:void 0;return new t.QaidQuests({endpoint:`${e}/responses`,configUrl:`${e}/${encodeURIComponent(i.questId)}/definition`,apiKey:i.apiKey||void 0,metadata:o,onClose:i.onClose})}const ot="qaid_visitor_id",nt="qaid_hide_feedback",Ee=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"];function Te(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function _(i){return i?`${nt}_${i}`:nt}function Ae(i){try{return localStorage.getItem(_(i))==="1"}catch{return!1}}function st(i,t=!0){try{t?localStorage.setItem(_(i),"1"):localStorage.removeItem(_(i))}catch{}}function Le(){try{let i=localStorage.getItem(ot);return i||(i=crypto.randomUUID(),localStorage.setItem(ot,i)),i}catch{return crypto.randomUUID()}}class at{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;isMobile=!1;visitorId;consoleCapture=null;recording=null;targeting=null;targetingPrewarmed=!1;prewarmHandle=null;prewarmIsTimeout=!1;videoPrewarmed=!1;screenshotPrewarmed=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;modal=null;modalPrewarmed=!1;dismissBtn=null;cssVars={};activeThumbBtn=null;keyboardActivation=!1;dialogTrigger=null;dialogTrap=null;dialogRestoreInert=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundResize;_startDismissed=!1;destroyed=!1;domObserver=null;boundBeforeSwap=null;constructor(t){this.config={endpoint:t.endpoint,apiKey:t.apiKey??"",container:t.container??"",buttonClass:t.buttonClass??"",direction:t.direction??"horizontal",position:t.position??"bottom-right",offset:{x:t.offset?.x??16,y:t.offset?.y??16},zIndex:t.zIndex??50,skipTargeting:t.skipTargeting??!1,singleButton:t.singleButton??!1,feedbackMode:t.feedbackMode??"target",colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#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",feedbackLabel:t.text?.feedbackLabel??"Send 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,annotate:t.annotate??!0,annotationColor:t.annotationColor??t.colors?.marker??"#6366f1",annotationPalette:t.annotationPalette??Ee,screenshotMethod:t.screenshotMethod??"permission",screenshotOptions:{quality:t.screenshotOptions?.quality??.8,maxWidth:t.screenshotOptions?.maxWidth??1280,maxHeight:t.screenshotOptions?.maxHeight??800},incognito:t.incognito??!1,hideDismiss:t.hideDismiss??!1,positiveIcon:t.positiveIcon??"",negativeIcon:t.negativeIcon??"",feedbackIcon:t.feedbackIcon??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15,redaction:t.videoOptions?.redaction??!1},recordIcon:t.recordIcon??"",quests:{base:t.quests?.base??"",up:t.quests?.up??"",down:t.quests?.down??"",video:t.quests?.video??"",apiKey:t.quests?.apiKey??t.apiKey??"",moduleUrl:t.quests?.moduleUrl??xe}},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=Le(),this.init()}applyVars(t){Gt(t,this.cssVars)}announceMsg(t,e=!1){const o=this.overlayShadowRoot??this.shadowRoot;o&&ne(o,t,{assertive:e})}openDialogA11y(t,e){this.dialogTrigger=de(),le(t,e),this.dialogTrap=re(t),this.dialogRestoreInert=ue(t)}closeDialogA11y(){this.dialogTrap?.release(),this.dialogTrap=null,this.dialogRestoreInert&&(this.dialogRestoreInert(),this.dialogRestoreInert=null),ce(this.dialogTrigger),this.dialogTrigger=null}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){Jt(),this.cssVars=Qt({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&&Ae(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=we(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom(),(this.config.captureVideo&&this.videoSupported()||this.config.captureScreenshot)&&this.schedulePrewarm(()=>{this.config.captureVideo&&this.videoSupported()&&this.prewarmVideo(),this.config.captureScreenshot&&this.prewarmScreenshot()})}prewarmVideo(){this.videoPrewarmed||(this.videoPrewarmed=!0,Promise.resolve().then(()=>Ct).catch(()=>{}),Promise.resolve().then(()=>bt).catch(()=>{}))}prewarmScreenshot(){this.screenshotPrewarmed||(this.screenshotPrewarmed=!0,(this.shouldCaptureViaDom()?Promise.resolve().then(()=>yt):Promise.resolve().then(()=>St)).catch(()=>{}),this.config.annotate&&Promise.resolve().then(()=>qt).catch(()=>{}))}schedulePrewarm(t){const e=window,o=()=>{this.destroyed||t()};typeof e.requestIdleCallback=="function"?(this.prewarmIsTimeout=!1,this.prewarmHandle=e.requestIdleCallback(o,{timeout:2e3})):(this.prewarmIsTimeout=!0,this.prewarmHandle=window.setTimeout(o,1200))}observeDom(){this.boundBeforeSwap=t=>{const e=t.newDocument;!e||this.destroyed||(this.shadowHost&&e.body.appendChild(this.shadowHost),this.overlayShadowHost&&e.body.appendChild(this.overlayShadowHost))},document.addEventListener("astro:before-swap",this.boundBeforeSwap),this.domObserver=new MutationObserver(()=>{this.destroyed||(this.shadowHost&&!this.shadowHost.isConnected&&document.body.appendChild(this.shadowHost),this.overlayShadowHost&&!this.overlayShadowHost.isConnected&&document.body.appendChild(this.overlayShadowHost))}),this.domObserver.observe(document.body,{childList:!0})}checkMobile(){this.isMobile=ke()}handleResize(){this.checkMobile()}createEmbed(){this.shadowHost=document.createElement("div"),this.shadowHost.setAttribute("data-qaid-embed",""),this.shadowHost.style.position="static",this.shadowHost.style.display="contents";let t=null;this.config.container&&(t=document.querySelector(this.config.container)),t?(t.appendChild(this.shadowHost),this.isUserProvidedContainer=!0,this.config.hideDismiss=!0):(this.shadowHost.style.position="fixed",this.shadowHost.style.display="block",this.shadowHost.style.inset="0",this.shadowHost.style.pointerEvents="none",this.shadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.shadowHost)),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"});const e=document.createElement("style");if(e.textContent=Q(),this.shadowRoot.appendChild(e),this.config.css){const d=document.createElement("style");d.textContent=this.config.css,this.shadowRoot.appendChild(d)}const o=this.config.direction==="vertical"?"qaid-vertical":"";if(this.isUserProvidedContainer)this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-${this.config.position} ${o}`.trim(),this.config.incognito&&this.buttonsContainer.classList.add("qaid-incognito");else{this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-auto-container qaid-${this.config.position} ${o}${this.config.incognito?" qaid-incognito":""}`.trim(),this.buttonsContainer.style.pointerEvents="auto";const{x:d,y:r}=this.config.offset;this.config.position.includes("right")?this.buttonsContainer.style.right=`${d}px`:this.buttonsContainer.style.left=`${d}px`,this.config.position.includes("bottom")?this.buttonsContainer.style.bottom=`${r}px`:this.buttonsContainer.style.top=`${r}px`}this.applyVars(this.buttonsContainer),this.shadowRoot.appendChild(this.buttonsContainer),this.buttonsContainer.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" "||d.key==="Spacebar")&&(this.keyboardActivation=!0)}),this.buttonsContainer.addEventListener("mousedown",()=>{this.keyboardActivation=!1}),this.buttonsContainer.addEventListener("pointerdown",()=>{this.keyboardActivation=!1});const n=!!this.config.buttonClass,s=n?`qaid-btn-structural ${this.config.buttonClass}`:"qaid-btn",c=this.config.text.tooltip||"Feedback for us?",l=document.createElement("div");if(l.className="qaid-tooltip-text",l.textContent=c,this.applyVars(l),this.shadowRoot.appendChild(l),this.tooltipElement=l,this.config.singleButton){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-feedback`:"qaid-btn qaid-btn-feedback",r.setAttribute("aria-label",this.config.text.feedbackLabel),r.innerHTML=this.config.feedbackIcon||Y,r.addEventListener("click",h=>this.handleThumbClick("neutral",h.currentTarget,h)),r.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(r)}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r),this.buttonsContainer.appendChild(d)}else if(!this.config.hideThumbs){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",r.setAttribute("aria-label",this.config.text.positiveLabel),r.innerHTML=this.config.positiveIcon||E,r.addEventListener("click",g=>this.handleThumbClick("up",g.currentTarget,g)),r.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(r)}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r);const h=document.createElement("div");h.className="qaid-tooltip-wrapper";const p=document.createElement("button");p.type="button",p.className=n?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",p.setAttribute("aria-label",this.config.text.negativeLabel),p.innerHTML=this.config.negativeIcon||$,p.addEventListener("click",g=>this.handleThumbClick("down",g.currentTarget,g)),p.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(p)}),p.addEventListener("mouseleave",()=>this.hideTooltip()),h.appendChild(p),this.buttonsContainer.appendChild(d),this.buttonsContainer.appendChild(h)}if(this.config.captureVideo&&this.videoSupported()){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",r.setAttribute("aria-label",this.config.text.recordLabel),r.innerHTML=this.config.recordIcon||Pt,r.addEventListener("click",()=>{this.ensureRecording().then(p=>this.config.videoOptions.redaction?p.startPicking():p.startRecording())});const h=()=>this.prewarmVideo();r.addEventListener("mouseenter",()=>{h(),this.showTooltip(r)}),r.addEventListener("focus",h),r.addEventListener("touchstart",h,{passive:!0}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r),this.buttonsContainer.appendChild(d)}this.config.hideDismiss||(this.dismissBtn=document.createElement("button"),this.dismissBtn.type="button",this.dismissBtn.className="qaid-dismiss-btn",this.dismissBtn.setAttribute("aria-label",this.config.text.dismissLabel),this.dismissBtn.title=this.config.text.dismissLabel,this.dismissBtn.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 2l8 8M10 2l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',this.dismissBtn.addEventListener("click",d=>{d.stopPropagation(),this.handleDismiss()}),this.buttonsContainer.insertBefore(this.dismissBtn,this.buttonsContainer.firstChild),this._startDismissed&&this.buttonsContainer.classList.add("qaid-dismissed"))}ensureOverlayHost(){if(this.overlayShadowRoot)return this.overlayShadowRoot;this.overlayShadowHost=document.createElement("div"),this.overlayShadowHost.setAttribute("data-qaid-embed-overlay",""),this.overlayShadowHost.style.position="fixed",this.overlayShadowHost.style.inset="0",this.overlayShadowHost.style.pointerEvents="none",this.overlayShadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.overlayShadowHost),this.overlayShadowRoot=this.overlayShadowHost.attachShadow({mode:"open"});const t=document.createElement("style");if(t.textContent=Q(),this.overlayShadowRoot.appendChild(t),this.config.css){const e=document.createElement("style");e.textContent=this.config.css,this.overlayShadowRoot.appendChild(e)}return this.overlayShadowRoot}tooltipElement=null;showTooltip(t){const e=this.tooltipElement;e.style.visibility="hidden",e.classList.add("qaid-tooltip-visible");const o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),{top:s,left:a}=me(o,n,{width:window.innerWidth,height:window.innerHeight});e.style.top=`${s}px`,e.style.left=`${a}px`,e.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),st(this.config.apiKey,!0)}handleThumbClick(t,e,o){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),st(this.config.apiKey,!1)),this.prewarmModal(),this.config.skipTargeting||this.config.feedbackMode==="annotate")this.submitDirectFeedback(t,e);else{this.activeThumbBtn=e,e.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,this.ensureTargeting().then(s=>{this.destroyed||(n?s.startKeyboard(t):s.startPointer(t,o))})}}submitDirectFeedback(t,e){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const o=e.getBoundingClientRect();this.selectedBounds={x:o.left,y:o.top,width:o.width,height:o.height,clickX:o.left+o.width/2,clickY:o.top+o.height/2,visible:!1},this.submitFeedback()}handleKeyDown(t){if(t.key==="Escape"){if(this.recording?.handleEscape())return;this.state==="TARGETING"?this.targeting?.cancel():this.state==="MODAL_OPEN"&&this.modal?.close()}}shouldCaptureViaDom(){return this.config.screenshotMethod==="dom"||Te()}async openAnnotationEditor(t){const e=this.ensureOverlayHost(),o=this.overlayShadowHost,n=o.style.pointerEvents;o.style.pointerEvents="auto";try{const{openAnnotationEditor:s}=await Promise.resolve().then(()=>qt);return await s({dataUrl:t,root:e,quality:this.config.screenshotOptions.quality,color:this.config.annotationColor,palette:this.config.annotationPalette,applyVars:a=>this.applyVars(a),announce:(a,c)=>this.announceMsg(a,c),openDialog:(a,c)=>this.openDialogA11y(a,c),closeDialog:()=>this.closeDialogA11y()})}finally{o.style.pointerEvents=n}}async submitFeedback(){let t=null;if(this.config.captureScreenshot||this.config.feedbackMode==="annotate"){if(this.shouldCaptureViaDom()){const{captureDomScreenshot:c}=await Promise.resolve().then(()=>yt);t=await c(this.config.screenshotOptions)}else{const{captureScreenshot:c}=await Promise.resolve().then(()=>St);t=await c(this.config.screenshotOptions)}t&&this.announceMsg("Screenshot captured")}t&&this.config.annotate&&(t=await this.openAnnotationEditor(t)??t);const o=this.feedbackData.elementSelector?{x:this.selectedBounds.x,y:this.selectedBounds.y,width:this.selectedBounds.width,height:this.selectedBounds.height}:null,n={feedbackType:this.feedbackData.feedbackType,pageUrl:window.location.href,apiKey:this.config.apiKey||void 0,elementSelector:this.feedbackData.elementSelector,elementText:this.feedbackData.elementText,consoleErrors:[...this.feedbackData.consoleErrors],screenWidth:window.innerWidth,screenHeight:window.innerHeight,clickX:this.selectedBounds.clickX,clickY:this.selectedBounds.clickY,scrollX:window.scrollX,scrollY:window.scrollY,screenshot:t,visitorId:this.visitorId,elementBounds:o,userAgent:navigator.userAgent};try{const c=await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(c.ok){const l=await c.json();this.feedbackId=l.id,this.announceMsg("Feedback sent")}}catch(c){console.error("Failed to submit feedback:",c),this.announceMsg("Failed to send feedback",!0)}const s=this.feedbackData.feedbackType;if(s&&s!=="neutral"&&await this.tryLaunchQuest(s,this.feedbackId)){this.resetFeedbackUi();return}this.state="MODAL_OPEN";const a=await this.ensureModal();this.destroyed||(a.open(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"))}questIdFor(t){const e=this.config.quests;return e.base&&e[t]||""}async tryLaunchQuest(t,e){const o=this.questIdFor(t);if(!o)return!1;try{return this.activeQuest?.destroy(),this.activeQuest=await Se({questId:o,base:this.config.quests.base,apiKey:this.config.quests.apiKey||void 0,moduleUrl:this.config.quests.moduleUrl,feedbackId:e,onClose:()=>{this.activeQuest=null}}),!0}catch(n){return console.error("Failed to launch quest:",n),this.activeQuest=null,!1}}resetFeedbackUi(){this.targeting?.hideMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackId=null,this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}async ensureModal(){if(!this.modal){const{ModalController:t}=await Promise.resolve().then(()=>Et);this.modal=new t(this.makeModalHost())}return this.modal}makeModalHost(){const t=this;return{get config(){return t.config},get uid(){return t.uid},get isMobile(){return t.isMobile},get state(){return t.state},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},get feedbackId(){return t.feedbackId},setFeedbackId:e=>{t.feedbackId=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),resetFeedbackUi:()=>t.resetFeedbackUi()}}prewarmModal(){this.modalPrewarmed||(this.modalPrewarmed=!0,Promise.resolve().then(()=>Et).catch(()=>{}))}async ensureTargeting(){if(!this.targeting){const{TargetingController:t}=await Promise.resolve().then(()=>Lt);this.targeting=new t(this.makeTargetingHost())}return this.targeting}makeTargetingHost(){const t=this;return{get config(){return t.config},get cssVars(){return t.cssVars},get state(){return t.state},get shadowHost(){return t.shadowHost},get overlayShadowHost(){return t.overlayShadowHost},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),clearActiveThumb:()=>t.clearActiveThumb(),submitFeedback:()=>t.submitFeedback()}}prewarmTargeting(){this.targetingPrewarmed||this.config.skipTargeting||(this.targetingPrewarmed=!0,Promise.resolve().then(()=>Lt).catch(()=>{}))}videoSupported(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}async ensureRecording(){if(!this.recording){const{RecordingController:t}=await Promise.resolve().then(()=>Ct);this.recording=new t(this.makeRecordingHost())}return this.recording}makeRecordingHost(){const t=this;return{get config(){return t.config},get visitorId(){return t.visitorId},get uid(){return t.uid},get overlayShadowHost(){return t.overlayShadowHost},get consoleCapture(){return t.consoleCapture},get boundKeyDown(){return t.boundKeyDown},get state(){return t.state},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),setButtonsDisabled:e=>t.setButtonsDisabled(e),tryLaunchQuest:(e,o)=>t.tryLaunchQuest(e,o)}}setButtonsDisabled(t){if(!this.buttonsContainer)return;this.buttonsContainer.querySelectorAll("button.qaid-btn, button.qaid-btn-structural").forEach(o=>{t?o.classList.contains("qaid-btn-record")||(o.disabled=!0,o.style.opacity="0.5"):(o.disabled=!1,o.style.opacity="")})}destroy(){if(this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.targeting?.destroy(),this.targeting=null,this.clearActiveThumb(),this.closeDialogA11y(),this.prewarmHandle!==null){const t=window;this.prewarmIsTimeout?clearTimeout(this.prewarmHandle):t.cancelIdleCallback?.(this.prewarmHandle),this.prewarmHandle=null}this.recording?.destroy(),this.recording=null,this.modal?.destroy(),this.modal=null,this.activeQuest?.destroy(),this.activeQuest=null,this.consoleCapture&&(this.consoleCapture.restore(),this.consoleCapture=null),window.removeEventListener("resize",this.boundResize),document.removeEventListener("keydown",this.boundKeyDown),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.shadowHost&&(this.shadowHost.remove(),this.shadowHost=null,this.shadowRoot=null),this.overlayShadowHost&&(this.overlayShadowHost.remove(),this.overlayShadowHost=null,this.overlayShadowRoot=null),this.buttonsContainer=null,this.dismissBtn=null,this.tooltipElement=null,Zt()}}function rt(i){return document.querySelector(i)?.textContent?.trim()??""}function Ie(){const i=document.querySelector('script[type="application/json"][data-feedback-config]');if(!i)return null;const t=i.textContent?.trim();if(!t)return null;try{const e=JSON.parse(t);return e.cssSelector&&!e.css&&(e.css=rt(e.cssSelector),delete e.cssSelector),e}catch{return null}}function De(i){const t=i.getAttribute("data-endpoint");if(!t)return null;const e=i.getAttribute("data-position"),o=i.getAttribute("data-zindex"),n=i.getAttribute("data-positive-color"),s=i.getAttribute("data-negative-color"),a=i.getAttribute("data-marker-color"),c=i.getAttribute("data-container"),l=i.getAttribute("data-button-class"),d=i.getAttribute("data-skip-targeting"),r=i.getAttribute("data-single-button"),h=i.getAttribute("data-feedback-mode"),p=i.getAttribute("data-incognito"),g=i.getAttribute("data-button-size"),y=i.getAttribute("data-offset-x"),v=i.getAttribute("data-offset-y"),x=i.getAttribute("data-modal-width"),C=i.getAttribute("data-backdrop-opacity"),u=i.getAttribute("data-font-family"),w=i.getAttribute("data-font-size"),k=i.getAttribute("data-tooltip"),S=i.getAttribute("data-modal-title"),P=i.getAttribute("data-modal-subtitle"),A=i.getAttribute("data-placeholder"),b=i.getAttribute("data-submit-button"),O=i.getAttribute("data-skip-button"),wi=i.getAttribute("data-positive-icon"),ki=i.getAttribute("data-negative-icon"),xi=i.getAttribute("data-feedback-icon"),It=i.getAttribute("data-feedback-label"),qi=i.getAttribute("data-api-key"),Ci=i.getAttribute("data-capture-screenshot"),Si=i.getAttribute("data-annotate"),Ei=i.getAttribute("data-annotation-color"),j=i.getAttribute("data-screenshot-quality"),K=i.getAttribute("data-screenshot-max-width"),W=i.getAttribute("data-screenshot-max-height"),Ti=i.getAttribute("data-capture-video"),Dt=i.getAttribute("data-video-redaction"),Ai=i.getAttribute("data-hide-thumbs"),Li=i.getAttribute("data-hide-dismiss"),X=i.getAttribute("data-video-max-duration"),Ii=i.getAttribute("data-screenshot-method"),Di=i.getAttribute("data-direction"),Mt=i.getAttribute("data-css-selector"),Rt=i.getAttribute("data-quest-base"),Mi=i.getAttribute("data-quest-up"),Ri=i.getAttribute("data-quest-down"),Pi=i.getAttribute("data-quest-video"),Bi=i.getAttribute("data-quest-api-key"),Hi=i.getAttribute("data-quest-module-url");return{endpoint:t,css:Mt?rt(Mt):void 0,apiKey:qi??void 0,captureScreenshot:Ci==="true"?!0:void 0,annotate:Si==="false"?!1:void 0,annotationColor:Ei??void 0,screenshotOptions:j||K||W?{quality:j?parseFloat(j):void 0,maxWidth:K?parseInt(K,10):void 0,maxHeight:W?parseInt(W,10):void 0}:void 0,container:c??void 0,buttonClass:l??void 0,direction:Di??void 0,position:e??void 0,zIndex:o?parseInt(o,10):void 0,skipTargeting:d==="true"?!0:void 0,singleButton:r==="true"?!0:void 0,feedbackMode:h??void 0,incognito:p==="true"?!0:void 0,buttonSize:g??void 0,offset:y||v?{x:y?parseInt(y,10):void 0,y:v?parseInt(v,10):void 0}:void 0,modalWidth:x?parseInt(x,10):void 0,backdropOpacity:C?parseFloat(C):void 0,fontFamily:u??void 0,fontSize:w?parseInt(w,10):void 0,colors:{positive:n??void 0,negative:s??void 0,marker:a??void 0},text:k||S||P||A||b||O||It?{tooltip:k??void 0,modalTitle:S??void 0,modalSubtitle:P??void 0,placeholder:A??void 0,submitButton:b??void 0,skipButton:O??void 0,feedbackLabel:It??void 0}:void 0,positiveIcon:wi??void 0,negativeIcon:ki??void 0,feedbackIcon:xi??void 0,screenshotMethod:Ii??void 0,captureVideo:Ti==="true"?!0:void 0,hideThumbs:Ai==="true"?!0:void 0,hideDismiss:Li==="true"?!0:void 0,videoOptions:X||Dt?{maxDuration:X?parseInt(X,10):void 0,redaction:Dt==="true"?!0:void 0}:void 0,quests:Rt?{base:Rt,up:Mi??void 0,down:Ri??void 0,video:Pi??void 0,apiKey:Bi??void 0,moduleUrl:Hi??void 0}:void 0}}function Me(){if(typeof document>"u")return;const i=()=>{const t=document.currentScript??document.querySelector("script[data-endpoint]"),e=Ie(),o=t?De(t):null,n=e??o;n?.endpoint&&new at(n)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}const Re=20,dt=4096;function H(i){const t=typeof i=="string"?i:JSON.stringify(i);return t.length>dt?t.slice(0,dt)+"…[truncated]":t}function ct(i,t){i.length>=Re&&i.shift(),i.push(t)}async function Pe(i){try{const t=await i.clone().text();return H(t)}catch{return}}function lt(){const i=[],t=window.fetch;window.fetch=async function(n,s){const a=typeof n=="string"?n:n instanceof URL?n.toString():n.url,c=s?.method??(typeof n=="object"&&"method"in n?n.method:"GET");let l;s?.body&&(l=H(s.body));const d=await t.apply(window,[n,s]);if(d.status>=400){const r=await Pe(d);ct(i,{url:a,method:c.toUpperCase(),status:d.status,statusText:d.statusText,requestBody:l,responseBody:r,timestamp:Date.now()})}return d};const e=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,s,...a){return this._qaid_method=n,this._qaid_url=typeof s=="string"?s:s.toString(),e.apply(this,[n,s,...a])},XMLHttpRequest.prototype.send=function(n){const s=this,a=n?H(n):void 0;return s.addEventListener("load",function(){s.status>=400&&ct(i,{url:s._qaid_url,method:s._qaid_method.toUpperCase(),status:s.status,statusText:s.statusText,requestBody:a,responseBody:H(s.responseText),timestamp:Date.now()})}),o.apply(this,[n])},{errors:i,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=e,XMLHttpRequest.prototype.send=o}}}function Be(){const i=navigator.userAgent||"";return/iP(hone|ad|od)/.test(i)||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1}function He(i,t,e,o,n){const s=i>=t,a=e>=o;return s===a?{width:i,height:t,rotate:0}:{width:t,height:i,rotate:n===270?-90:90}}function Oe(i,t,e){if(e.rotate===0){i.drawImage(t,0,0,e.width,e.height);return}i.save(),e.rotate===90?(i.translate(e.width,0),i.rotate(Math.PI/2)):(i.translate(0,e.height),i.rotate(-Math.PI/2)),i.drawImage(t,0,0,e.height,e.width),i.restore()}function $e(){const i=typeof screen<"u"?screen.orientation:void 0;return i&&typeof i.angle=="number"?i.angle:0}function ht(i){return new Promise(t=>{if(i.videoWidth>0){t();return}i.addEventListener("loadedmetadata",()=>t(),{once:!0})})}async function ut(i){try{await i.play()}catch{}}async function ze(i,t=15){const e=document.createElement("canvas");if(typeof e.captureStream!="function")return null;const o=e.getContext("2d");if(!o)return null;const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=i,await ht(n);const s=He(n.videoWidth,n.videoHeight,window.innerWidth,window.innerHeight,$e());e.width=s.width,e.height=s.height,await ut(n);let a=0;const c=()=>{Oe(o,n,s),a=requestAnimationFrame(c)};c();const l=e.captureStream(t);return{stream:l,stop:()=>{a&&cancelAnimationFrame(a),a=0,l.getTracks().forEach(d=>d.stop()),n.pause(),n.srcObject=null}}}function _e(i,t,e,o,n){const s=Math.max(0,Math.min(o,i.left*t)),a=Math.max(0,Math.min(n,i.top*e)),c=Math.max(0,Math.min(o,(i.left+i.width)*t)),l=Math.max(0,Math.min(n,(i.top+i.height)*e)),d=c-s,r=l-a;return d<=0||r<=0?null:{x:s,y:a,w:d,h:r}}function Ve(i,t,e,o,n,s,a){i.drawImage(t,0,0,o,n);const c=o/Math.max(1,window.innerWidth),l=n/Math.max(1,window.innerHeight);for(const d of e){const r=_e(d.getBoundingClientRect(),c,l,o,n);r&&(i.save(),a?(i.filter=`blur(${s}px)`,i.drawImage(t,r.x,r.y,r.w,r.h,r.x,r.y,r.w,r.h)):(i.fillStyle="#0b0b0b",i.fillRect(r.x,r.y,r.w,r.h)),i.restore())}}async function Fe(i,t,e={}){const o=e.frameRate??15,n=e.blurRadius??12,s=document.createElement("canvas");if(typeof s.captureStream!="function")return null;const a=s.getContext("2d");if(!a)return null;const c="filter"in a,l=document.createElement("video");l.muted=!0,l.playsInline=!0,l.srcObject=i,await ht(l),s.width=l.videoWidth,s.height=l.videoHeight,await ut(l);let d=0;const r=()=>{Ve(a,l,t,s.width,s.height,n,c),d=requestAnimationFrame(r)};r();const h=s.captureStream(o);return{stream:h,stop:()=>{d&&cancelAnimationFrame(d),d=0,h.getTracks().forEach(p=>p.stop()),l.pause(),l.srcObject=null}}}function pt(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function V(){if(typeof MediaRecorder>"u")return"";const i=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of i)if(MediaRecorder.isTypeSupported(t))return t;return""}function ft(i={}){const t=i.maxDuration??15,e=i.videoBitsPerSecond??8e5,o=i.redactionElements??[],n=i.redactionBlurRadius;let s=null,a=null,c=null,l=null,d=[],r=null,h=null,p=null,g=0,y=null,v=null,x=!1,C=null;function u(){p!==null&&(clearInterval(p),p=null),C!==null&&(clearTimeout(C),C=null),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&(s.getTracks().forEach(k=>k.stop()),s=null),l=null,d=[],r=null,h=null,y=null,v=null}function w(){x||(x=!0,l&&l.state!=="inactive"&&l.stop())}return{async start(){x=!1,d=[];const k=V();if(!k)throw new Error("No supported video MIME type found");s=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15,displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",monitorTypeSurfaces:"exclude",surfaceSwitching:"exclude"});const S=s.getVideoTracks()[0],P=S?.getSettings?.()?.displaySurface;if(P==="monitor"||P==="window")throw s.getTracks().forEach(b=>b.stop()),s=null,new Error("qaid records only the current tab — please share this tab, not a window or your whole screen.");S&&S.addEventListener("ended",()=>{w()});let A=s;if(Be()){const b=await ze(s);b&&(a=b,A=b.stream)}else if(o.length>0){const b=await Fe(s,o,{blurRadius:n});b&&(c=b,A=b.stream)}l=new MediaRecorder(A,{mimeType:k,videoBitsPerSecond:e}),l.ondataavailable=b=>{b.data.size>0&&d.push(b.data)},l.onstop=()=>{const b=new Blob(d,{type:k});y&&y(b),h&&h(b),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&s.getTracks().forEach(O=>O.stop())},l.onerror=()=>{v&&v(new Error("MediaRecorder error"))},l.start(1e3),g=Date.now(),p=setInterval(()=>{const b=Math.floor((Date.now()-g)/1e3);r&&r(b)},1e3),C=setTimeout(()=>{w()},t*1e3)},stop(){return new Promise((k,S)=>{y=k,v=S,w()})},onTick(k){r=k},onStop(k){h=k},destroy(){w(),u()}}}const bt=Object.freeze(Object.defineProperty({__proto__:null,createVideoRecorder:ft,getSupportedMimeType:V,isVideoRecordingSupported:pt},Symbol.toStringTag,{value:"Module"})),gt="https://qaid.dev/lib/html2canvas.min.js",Ne=1e4,Ue=50;let D=null;function mt(){if(typeof document>"u"||typeof window>"u")return!1;const i=document.createElement("canvas");return typeof i.getContext=="function"&&!!i.getContext("2d")}function je(){return window.html2canvas?Promise.resolve(!0):D||(D=new Promise(i=>{if(!document.querySelector(`script[src="${gt}"]`)){const n=document.createElement("script");n.src=gt,n.async=!0,document.head.appendChild(n)}const e=Date.now(),o=()=>{if(window.html2canvas){i(!0);return}if(Date.now()-e>Ne){D=null,i(!1);return}setTimeout(o,Ue)};o()}),D)}async function vt(i={}){const{quality:t=.8,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!await je()||!window.html2canvas)return console.warn("html2canvas failed to load"),null;const s=await window.html2canvas(document.body,{useCORS:!0,allowTaint:!1,logging:!1,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,x:window.scrollX,y:window.scrollY,ignoreElements:d=>d instanceof HTMLElement?d.classList.contains("qaid-buttons")||d.classList.contains("qaid-targeting-overlay")||d.classList.contains("qaid-modal-container")||d.classList.contains("qaid-bottom-sheet")||d.classList.contains("qaid-backdrop")||d.classList.contains("qaid-selected-marker")||d.classList.contains("qaid-tooltip-text")||d.classList.contains("qaid-recording-indicator")||d.classList.contains("qaid-video-preview")||d.className?.toString().startsWith?.("qaid-"):!1}),a=s.width,c=s.height,l=Math.min(e/a,o/c,1);if(l<1){const d=Math.round(a*l),r=Math.round(c*l),h=document.createElement("canvas");h.width=d,h.height=r;const p=h.getContext("2d");return p?(p.drawImage(s,0,0,d,r),h.toDataURL("image/webp",t)):null}return s.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const yt=Object.freeze(Object.defineProperty({__proto__:null,captureDomScreenshot:vt,isDomScreenshotSupported:mt},Symbol.toStringTag,{value:"Module"})),T=12,Ke="#ef4444",We=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"],Xe={"#ef4444":"red","#f59e0b":"amber","#22c55e":"green","#3b82f6":"blue","#111827":"black","#ffffff":"white","#6366f1":"indigo"};function wt(i){return Xe[i.toLowerCase()]??i}const Ye=4,Qe=.8,Ge={title:"Annotate screenshot",instructions:"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",rectangle:"Rectangle",arrow:"Arrow",pen:"Pen",blur:"Blur or redact",undo:"Undo last",skip:"Skip annotation",done:"Done",colors:"Drawing colour"};function M(i,t){return{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y),w:Math.abs(i.x-t.x),h:Math.abs(i.y-t.y)}}function Je(i){if(i.type==="pen")return i.points.length<2;const t=M(i.points[0],i.points[1]);return t.w<3&&t.h<3}function Ze(i,t,e,o){i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke();const n=Math.atan2(e.y-t.y,e.x-t.x),s=Math.max(10,o*3);i.beginPath(),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n-Math.PI/6),e.y-s*Math.sin(n-Math.PI/6)),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n+Math.PI/6),e.y-s*Math.sin(n+Math.PI/6)),i.stroke()}function ti(i,t){if(t.length!==0){i.beginPath(),i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)i.lineTo(t[e].x,t[e].y);i.stroke()}}function ei(i,t,e,o,n){i.fillStyle="rgb(15, 23, 42)",i.fillRect(t,e,o,n),i.fillStyle="rgb(37, 47, 63)";for(let s=e;s<e+n;s+=T)for(let a=t;a<t+o;a+=T)(Math.floor((a-t)/T)+Math.floor((s-e)/T))%2===0&&i.fillRect(a,s,Math.min(T,t+o-a),Math.min(T,e+n-s))}function R(i,t){switch(i.save(),i.strokeStyle=t.color,i.fillStyle=t.color,i.lineWidth=t.strokeWidth,i.lineJoin="round",i.lineCap="round",t.type){case"rect":{const e=M(t.points[0],t.points[1]);i.strokeRect(e.x,e.y,e.w,e.h);break}case"arrow":Ze(i,t.points[0],t.points[1],t.strokeWidth);break;case"pen":ti(i,t.points);break;case"blur":{const e=M(t.points[0],t.points[1]);ei(i,e.x,e.y,e.w,e.h);break}}i.restore()}function kt(i){return new Promise((t,e)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>e(new Error("Failed to load screenshot")),o.src=i})}async function F(i,t,e={}){const o=e.quality??Qe;let n;try{n=await kt(i)}catch{return i}const s=document.createElement("canvas");s.width=n.naturalWidth||n.width||1,s.height=n.naturalHeight||n.height||1;const a=s.getContext("2d");if(!a)return i;a.drawImage(n,0,0,s.width,s.height);for(const c of t)R(a,c);return s.toDataURL("image/webp",o)}let ii=0;class N{shapes=[];tool="rect";opts;labels;color;palette;strokeWidth;uid=`qaid-annotate-${++ii}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...Ge,...t.labels??{}},this.color=t.color??Ke,this.palette=(t.palette&&t.palette.length?t.palette:We).slice(),this.palette.some(e=>e.toLowerCase()===this.color.toLowerCase())||this.palette.unshift(this.color),this.strokeWidth=t.strokeWidth??Ye}open(){const t=new Promise(e=>{this.resolveResult=e});return this.mount(),t}toolButton(t,e,o){const n=q("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${o} tool`,title:o});return n.innerHTML=`${e}<span class="qaid-annotate-btn-text">${o}</span>`,n}swatchButton(t){const e=wt(t),o=q("button",{type:"button",class:"qaid-annotate-swatch","data-qaid-color":t,"aria-pressed":t.toLowerCase()===this.color.toLowerCase()?"true":"false","aria-label":`Draw in ${e}`,title:e});return o.style.setProperty("--qaid-swatch",t),o}actionButton(t,e,o,n){const s=q("button",{type:"button",class:`qaid-annotate-action ${n}`,"data-qaid-action":t,"aria-label":o,title:o});return s.innerHTML=`${e}<span class="qaid-annotate-btn-text">${o}</span>`,s}mount(){const t=`${this.uid}-title`,e=`${this.uid}-desc`;this.container=q("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const o=q("h2",{id:t,class:"qaid-annotate-title"});o.textContent=this.labels.title;const n=q("p",{id:e,class:"qaid-annotate-desc"});n.textContent=this.labels.instructions;const s=q("div",{class:"qaid-annotate-stage"});this.canvas=document.createElement("canvas"),this.canvas.className="qaid-annotate-canvas",this.canvas.width=1,this.canvas.height=1,this.canvas.setAttribute("role","img"),this.canvas.setAttribute("aria-label",this.labels.title),this.ctx=this.canvas.getContext("2d"),s.appendChild(this.canvas),this.toolbar=q("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const a=q("div",{class:"qaid-annotate-tools"});a.appendChild(this.toolButton("rect",Bt,this.labels.rectangle)),a.appendChild(this.toolButton("arrow",Ht,this.labels.arrow)),a.appendChild(this.toolButton("pen",Ot,this.labels.pen)),a.appendChild(this.toolButton("blur",$t,this.labels.blur));const c=q("div",{class:"qaid-annotate-colors",role:"group","aria-label":this.labels.colors});for(const h of this.palette)c.appendChild(this.swatchButton(h));this.undoBtn=this.actionButton("undo",zt,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const l=this.actionButton("skip",Vt,this.labels.skip,"qaid-annotate-skip"),d=this.actionButton("done",_t,this.labels.done,"qaid-annotate-done"),r=q("div",{class:"qaid-annotate-actions"});r.appendChild(this.undoBtn),r.appendChild(l),r.appendChild(d),this.toolbar.appendChild(a),this.toolbar.appendChild(c),this.toolbar.appendChild(r),this.container.appendChild(o),this.container.appendChild(n),this.container.appendChild(s),this.container.appendChild(this.toolbar),this.opts.root.appendChild(this.container),this.toolbar.addEventListener("click",this.onToolbarClick),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp),this.container.addEventListener("keydown",this.onKeyDown),this.opts.openDialog?.(this.container,{labelledbyId:t,describedbyId:e}),this.opts.announce?.(this.labels.instructions),kt(this.opts.dataUrl).then(h=>{this.img=h,this.canvas.width=h.naturalWidth||h.width||1,this.canvas.height=h.naturalHeight||h.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const e=this.canvas.getBoundingClientRect(),o=this.canvas.width/(e.width||this.canvas.width),n=this.canvas.height/(e.height||this.canvas.height);return{x:(t.clientX-e.left)*o,y:(t.clientY-e.top)*n}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const e of this.shapes)R(t,e);this.current&&R(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(n=>{n.setAttribute("aria-pressed",n.getAttribute("data-qaid-tool")===t?"true":"false")});const o=this.labels[oi[t]];this.opts.announce?.(`${o} tool selected`)}selectColor(t){this.color=t,this.toolbar.querySelectorAll("[data-qaid-color]").forEach(o=>{o.setAttribute("aria-pressed",(o.getAttribute("data-qaid-color")??"").toLowerCase()===t.toLowerCase()?"true":"false")}),this.opts.announce?.(`${wt(t)} colour selected`)}onToolbarClick=t=>{const o=t.target?.closest("[data-qaid-tool],[data-qaid-action],[data-qaid-color]");if(!o)return;const n=o.getAttribute("data-qaid-color");if(n){this.selectColor(n);return}const s=o.getAttribute("data-qaid-tool");if(s){this.selectTool(s);return}const a=o.getAttribute("data-qaid-action");a==="undo"?this.undo():a==="skip"?this.skip():a==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const e=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[e]:[e,{...e}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const e=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(e):this.current.points[1]=e,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,Je(t)){this.redraw();return}this.shapes.push(t),this.undoBtn.disabled=!1,this.opts.announce?.("Annotation added"),this.redraw()};onKeyDown=t=>{if(t.key==="Escape"){t.preventDefault(),this.skip();return}if(t.key==="Enter"){const e=t.target;if(e?.getAttribute("data-qaid-tool")||e?.getAttribute("data-qaid-action"))return;t.preventDefault(),this.done()}};undo(){if(this.shapes.length===0){this.opts.announce?.("Nothing to undo");return}this.shapes.pop(),this.undoBtn.disabled=this.shapes.length===0,this.opts.announce?.("Removed last annotation"),this.redraw()}async done(){if(this.settled)return;const t=await F(this.opts.dataUrl,this.shapes,{quality:this.opts.quality});this.opts.announce?.("Annotated screenshot attached"),this.settle(t)}skip(){this.settled||(this.opts.announce?.("Annotation skipped"),this.settle(null))}settle(t){this.settled=!0,this.teardown(),this.resolveResult(t)}teardown(){this.toolbar.removeEventListener("click",this.onToolbarClick),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.container.removeEventListener("pointermove",this.onPointerMove),this.container.removeEventListener("pointerup",this.onPointerUp),this.container.removeEventListener("keydown",this.onKeyDown),this.opts.closeDialog?.(),this.container.remove()}}const oi={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function xt(i){return new N(i).open()}const qt=Object.freeze(Object.defineProperty({__proto__:null,AnnotationEditor:N,compositeAnnotations:F,drawShape:R,openAnnotationEditor:xt,rectFromPoints:M},Symbol.toStringTag,{value:"Module"}));Me();const ni=document;function f(i,t,...e){const o=ni.createElement(i);if(t){if(t.class&&(o.className=t.class),t.style&&(o.style.cssText=t.style),t.html!=null&&(o.innerHTML=t.html),t.text!=null&&(o.textContent=t.text),t.attrs)for(const n in t.attrs)o.setAttribute(n,t.attrs[n]);if(t.on)for(const n in t.on)o.addEventListener(n,t.on[n])}for(const n of e)n!=null&&n!==!1&&o.append(n);return o}class si{constructor(t){this.host=t}videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;redactPicks=[];redactPickerRoot=null;redactRafId=0;boundRedactClick=t=>this.handleRedactPickClick(t);handleEscape(){return this.isRecording?(this.stopRecording(),!0):this.videoPreview?(this.cancelRecordingPreview(),!0):this.redactPickerRoot?(this.finishRedactionPicking(!1),!0):!1}destroy(){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null),this.redactPicks=[],this.cleanupRecording(),this.removeVideoPreview()}async startRecording(t=[]){if(!(this.isRecording||this.host.state!=="IDLE"))try{this.networkCapture=lt();const{createVideoRecorder:e}=await Promise.resolve().then(()=>bt);this.videoRecorder=e({maxDuration:this.host.config.videoOptions.maxDuration,redactionElements:t}),this.videoRecorder.onTick(o=>{this.updateRecordingTimer(o)}),this.videoRecorder.onStop(o=>{this.isRecording&&(this.recordedBlob=o,this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.host.setButtonsDisabled(!1),o&&o.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.host.announceMsg("Recording started"),this.host.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.host.boundKeyDown)}catch(e){e instanceof Error&&/current tab/i.test(e.message)&&this.host.announceMsg(e.message),this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}startPicking(){if(this.isRecording||this.host.state!=="IDLE")return;this.host.setState("REDACT_PICKING"),this.redactPicks=[];const t=this.host.ensureOverlayHost(),e=f("div",{style:"position:absolute;inset:0;"}),o=f("div",{class:"qaid-redact-picker",style:"position:fixed;inset:0;pointer-events:none;"},e,f("div",{style:"position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;gap:12px;align-items:center;pointer-events:auto;background:#0b1220;color:#fff;border:1px solid #ff6b6b;border-radius:9999px;padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 8px 30px rgba(0,0,0,.5);"},f("span",{text:"Click sensitive areas to blur",attrs:{"data-qaid-redact-label":""}}),f("button",{text:"Start recording",attrs:{type:"button"},style:"cursor:pointer;border:0;border-radius:9999px;padding:8px 14px;background:#ff6b6b;color:#0b1220;font:inherit;",on:{click:()=>this.finishRedactionPicking(!0)}}),f("button",{text:"Cancel",attrs:{type:"button"},style:"cursor:pointer;border:0;background:transparent;color:#9fb3c8;font:inherit;",on:{click:()=>this.finishRedactionPicking(!1)}})));t.appendChild(o),this.redactPickerRoot=o;const n=()=>{this.renderRedactPicks(e),this.redactRafId=requestAnimationFrame(n)};n(),document.addEventListener("click",this.boundRedactClick,!0),document.addEventListener("keydown",this.host.boundKeyDown),this.host.announceMsg("Click sensitive areas to blur, then start recording")}handleRedactPickClick(t){const e=t.target instanceof Element?t.target:null;if(!e||B(e)||this.redactPickerRoot?.contains(e))return;t.preventDefault(),t.stopPropagation();const o=this.redactPicks.indexOf(e);o>=0?this.redactPicks.splice(o,1):this.redactPicks.push(e);const n=this.redactPickerRoot?.querySelector("[data-qaid-redact-label]");if(n){const s=this.redactPicks.length;n.textContent=s===0?"Click sensitive areas to blur":`${s} area${s===1?"":"s"} will be blurred`}}renderRedactPicks(t){t.textContent="";for(const e of this.redactPicks){const o=e.getBoundingClientRect();o.width<=0||o.height<=0||t.appendChild(f("div",{style:`position:fixed;left:${o.left}px;top:${o.top}px;width:${o.width}px;height:${o.height}px;border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;`}))}}finishRedactionPicking(t){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),document.removeEventListener("keydown",this.host.boundKeyDown),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null);const e=this.redactPicks;this.redactPicks=[],this.host.setState("IDLE"),t&&this.startRecording(e)}showRecordingIndicator(){const t=this.host.ensureOverlayHost();this.recordingIndicator=f("div",{class:"qaid-recording-indicator",style:`z-index:${this.host.config.zIndex+100}`},f("div",{class:"qaid-recording-dot"}),f("span",{class:"qaid-recording-time",text:this.formatTime(this.host.config.videoOptions.maxDuration)}),f("button",{class:"qaid-recording-stop",text:"Stop",attrs:{type:"button"},on:{click:()=>this.stopRecording()}})),this.host.applyVars(this.recordingIndicator),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const e=this.recordingIndicator.querySelector(".qaid-recording-time");if(e){const o=Math.max(0,this.host.config.videoOptions.maxDuration-t);e.textContent=this.formatTime(o),o>0&&o<=5&&this.host.announceMsg(`${o} second${o===1?"":"s"} remaining`)}}formatTime(t){const e=Math.floor(t/60),o=t%60;return`${e}:${o.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.host.ensureOverlayHost(),e=URL.createObjectURL(this.recordedBlob),o=`qaid-video-title-${this.host.uid}`,n=f("h3",{text:"Review your recording",attrs:{id:o}}),s=f("video");s.src=e,s.controls=!0,s.autoplay=!0,s.muted=!0;const a=f("textarea",{attrs:{placeholder:"Optional: Describe the issue you recorded...","aria-label":"Describe the issue you recorded"}}),c=f("button",{class:"qaid-video-btn qaid-video-btn-send",text:"Send",attrs:{type:"button"},on:{click:()=>this.submitVideoFeedback(a.value.trim()||null,c)}}),l=f("div",{class:"qaid-video-preview-box"},n,s,a,f("div",{class:"qaid-video-preview-actions"},f("button",{class:"qaid-video-btn qaid-video-btn-cancel",text:"Cancel",attrs:{type:"button"},on:{click:()=>this.cancelRecordingPreview()}}),f("button",{class:"qaid-video-btn qaid-video-btn-rerecord",text:"Re-record",attrs:{type:"button"},on:{click:()=>{this.cancelRecordingPreview(),this.startRecording()}}}),c));this.videoPreview=f("div",{class:"qaid-video-preview",style:`z-index:${this.host.config.zIndex+100}`},l),this.host.applyVars(this.videoPreview),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.host.openDialogA11y(l,{labelledbyId:n.id}),document.addEventListener("keydown",this.host.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.host.closeDialogA11y(),this.videoPreview){const t=this.videoPreview.querySelector("video");t?.src&&URL.revokeObjectURL(t.src),this.videoPreview.remove(),this.videoPreview=null}document.removeEventListener("keydown",this.host.boundKeyDown)}async submitVideoFeedback(t,e){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,e.disabled=!0,e.textContent="Sending...";const o=new FormData;o.append("video",this.recordedBlob,`recording.${this.recordedBlob.type.includes("mp4")?"mp4":"webm"}`),o.append("pageUrl",window.location.href),o.append("visitorId",this.host.visitorId),this.host.config.apiKey&&o.append("apiKey",this.host.config.apiKey),t&&o.append("message",t),this.host.consoleCapture&&o.append("consoleErrors",JSON.stringify(this.host.consoleCapture.errors)),this.networkCapture&&o.append("networkErrors",JSON.stringify(this.networkCapture.errors));let n=null;try{const s=await fetch(`${this.host.config.endpoint}/video`,{method:"POST",body:o});if(s.ok){this.host.announceMsg("Recording sent");try{n=(await s.json())?.id??null}catch{}}else console.error("Failed to submit video feedback:",await s.text()),this.host.announceMsg("Failed to send recording",!0)}catch(s){console.error("Failed to submit video feedback:",s),this.host.announceMsg("Failed to send recording",!0)}this.isSendingVideo=!1,this.removeVideoPreview(),this.cleanupRecording(),await this.host.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.host.setButtonsDisabled(!1),this.host.overlayShadowHost&&this.host.state==="IDLE"&&(this.host.overlayShadowHost.style.pointerEvents="none")}}const Ct=Object.freeze(Object.defineProperty({__proto__:null,RecordingController:si},Symbol.toStringTag,{value:"Module"}));async function ai(i={}){const{quality:t=1,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!navigator.mediaDevices?.getDisplayMedia)return console.warn("Screen Capture API not available"),null;const n=await navigator.mediaDevices.getDisplayMedia({preferCurrentTab:!0,video:{displaySurface:"browser"}}),s=n.getVideoTracks()[0],a=s.getSettings(),c=document.createElement("video");c.srcObject=n,c.muted=!0,await new Promise(v=>{c.onloadedmetadata=()=>{c.play(),v()}}),await new Promise(v=>{const x=()=>{c.readyState>=2?v():requestAnimationFrame(x)};x()}),await new Promise(v=>setTimeout(v,100));const l=a.width||c.videoWidth,d=a.height||c.videoHeight,r=Math.min(e/l,o/d,1),h=Math.round(l*r),p=Math.round(d*r),g=document.createElement("canvas");g.width=h,g.height=p;const y=g.getContext("2d");return y?(y.drawImage(c,0,0,h,p),s.stop(),g.toDataURL("image/webp",t)):(s.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const St=Object.freeze(Object.defineProperty({__proto__:null,captureScreenshot:ai},Symbol.toStringTag,{value:"Module"}));class ri{constructor(t){this.host=t}modalContainer=null;backdrop=null;open(){const t=this.host.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.host.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.host.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.close()),this.host.applyVars(this.backdrop),this.host.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.host.boundKeyDown)}close(){this.host.state==="MODAL_OPEN"&&this.host.feedbackId&&fetch(`${this.host.config.endpoint}/${this.host.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(t=>console.error("Failed to finalize feedback:",t)),this.teardown(),this.host.resetFeedbackUi()}destroy(){this.teardown()}teardown(){this.host.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.host.boundKeyDown)}showBottomSheet(){const t=this.host.ensureOverlayHost(),e=document.createElement("div");e.className="qaid-bottom-sheet",e.style.zIndex=String(this.host.config.zIndex+3),e.innerHTML=`
23
+ </svg>`,Vt="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-type-static{width:2.5rem;height:2.5rem;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:var(--qaid-marker, #6366f1);color:var(--qaid-marker-text, white)}.qaid-type-static svg{width:1.25rem;height:1.25rem}.qaid-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size: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 0 auto;height:100vh;height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#0009;z-index:99998;animation:qaid-fadeIn .2s ease-out}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}.qaid-video-preview-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px #00000080;width:560px;max-width:100%;max-height:100%;overflow-y:auto;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-video-preview-box h3{font-size:1.125rem;font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;max-height:50vh;max-height:50dvh;object-fit:contain;border-radius:.5rem;background:#000;margin-bottom:1rem}.qaid-video-preview-box textarea{width:100%;height:4rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:.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)}.qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:1rem;font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:.8125rem;line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:.8125rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}.qaid-annotate-colors{display:flex;gap:.25rem;align-items:center}button.qaid-annotate-swatch{width:28px;height:28px;min-width:28px;padding:0;border-radius:9999px;border:2px solid light-dark(#d1d5db,#4b5563);background:var(--qaid-swatch, #000);cursor:pointer;-webkit-appearance:none;appearance:none;transition:transform .1s,box-shadow .15s,border-color .15s}button.qaid-annotate-swatch:hover{transform:scale(1.12)}button.qaid-annotate-swatch[aria-pressed=true]{border-color:light-dark(#111827,#f9fafb);box-shadow:0 0 0 2px var(--qaid-swatch)}@media(forced-colors:active){button.qaid-annotate-swatch[aria-pressed=true]{outline:2px solid Highlight;outline-offset:1px}}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6366f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6366f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6366f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}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}}",Nt="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let L=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-feedback:hover{background:var(--qaid-marker,#6366f1);color:var(--qaid-marker-text,#fff)}button.qaid-btn svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",jt={small:36,medium:48,large:64},Kt={small:18,medium:24,large:32};function Wt(i,t,e){const[o,n,s]=[i,t,e].map(a=>(a=a/255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)));return .2126*o+.7152*n+.0722*s}function Xt(i){if(i.startsWith("#")){const e=i.slice(1),o=e.length===3?e.split("").map(s=>s+s).join(""):e,n=parseInt(o,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=i.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function Yt(i){const t=Xt(i);return t&&Wt(t.r,t.g,t.b)>.4?"black":"white"}function Qt(i={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:e="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}=i,d=jt[n],r=Kt[n],h=Yt(o);return{"--qaid-positive":t,"--qaid-negative":e,"--qaid-marker":o,"--qaid-marker-text":h,"--qaid-btn-size":`${d}px`,"--qaid-icon-size":`${r}px`,"--qaid-modal-width":`${s}px`,"--qaid-backdrop-opacity":String(a),"--qaid-font-family":c,"--qaid-font-size":`${l}px`}}function Gt(i,t){for(const[e,o]of Object.entries(t))i.style.setProperty(e,o)}function Q(){return Vt+Ut}function Jt(){if(L++,L>1)return;const i=document.createElement("style");i.id="qaid-styles",i.textContent=Nt,document.head.appendChild(i)}function Zt(){L<=0||(L--,L===0&&document.getElementById("qaid-styles").remove())}const G="data-qaid-a11y-live",te="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;",ee=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function ie(i){return i.ownerDocument||document}function oe(i,t){const e=t?"assertive":"polite",o=i.querySelector(`[${G}="${e}"]`);if(o)return o;const s=ie(i).createElement("div");return s.setAttribute(G,e),s.setAttribute("role",t?"alert":"status"),s.setAttribute("aria-live",t?"assertive":"polite"),s.setAttribute("aria-atomic","true"),s.style.cssText=te,i.appendChild(s),s}function ne(i,t,e={}){const o=oe(i,!!e.assertive);o.textContent="",o.textContent=t}function se(i){return i.hasAttribute("disabled")?!0:i.disabled===!0}function ae(i){let t=i;for(;t;){if(t.hasAttribute("hidden"))return!0;const e=t.style;if(e&&(e.display==="none"||e.visibility==="hidden"||e.visibility==="collapse"))return!0;t=t.parentElement}return!1}function J(i){return Array.from(i.querySelectorAll(ee)).filter(e=>!(e.getAttribute("tabindex")==="-1"||e instanceof HTMLInputElement&&e.type==="hidden"||e instanceof HTMLAnchorElement&&!e.getAttribute("href")||se(e)||ae(e)))}function Z(i){let t=i.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function re(i){const t=i.ownerDocument||document;let e=!1;const o=s=>{if(s.key!=="Tab")return;const a=J(i);if(a.length===0){s.preventDefault(),i.focus();return}const c=a[0],l=a[a.length-1],d=Z(t),r=d?a.indexOf(d)!==-1:!1;s.shiftKey?(!r||d===c)&&(s.preventDefault(),l.focus()):(!r||d===l)&&(s.preventDefault(),c.focus())};i.addEventListener("keydown",o);const n=J(i);return n.length>0?n[0].focus():(i.hasAttribute("tabindex")||(i.setAttribute("tabindex","-1"),e=!0),i.focus()),{release(){i.removeEventListener("keydown",o),e&&(i.removeAttribute("tabindex"),e=!1)}}}function de(){return Z(document)}function ce(i){if(!(!i||typeof i.focus!="function"))try{i.focus()}catch{}}function le(i,t={}){i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),t.labelledbyId&&i.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&i.setAttribute("aria-describedby",t.describedbyId),t.label&&i.setAttribute("aria-label",t.label)}function he(i,t){let e=i;for(;e&&e!==t;){const o=e.parentNode;if(o===t)return e;if(o&&o.host){e=o.host;continue}if(!o)return null;e=o}return null}function ue(i){const e=(i.ownerDocument||document).body;if(!e)return()=>{};const o=he(i,e),n=[];return Array.from(e.children).forEach(s=>{if(!(s instanceof HTMLElement)||o&&s===o)return;const a=s.inert===!0,c=s.getAttribute("aria-hidden");a&&c==="true"||(s.inert=!0,s.setAttribute("aria-hidden","true"),n.push({el:s,prevInert:a,prevAriaHidden:c}))}),function(){for(;n.length;){const a=n.pop();a.el.inert=a.prevInert,a.prevAriaHidden===null?a.el.removeAttribute("aria-hidden"):a.el.setAttribute("aria-hidden",a.prevAriaHidden)}}}const tt={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function pe(i,t,e,o,n){const s=i.y,a=t-(i.y+i.height);if(a>=e+o)return{top:i.y+i.height+o,position:"below"};if(s>=e+o)return{top:i.y-e-o,position:"above"};const c=a>s?"below":"above";let l;return c==="below"?l=Math.min(i.y+i.height+o,t-e-n):l=Math.max(n,i.y-e-o),{top:l,position:c}}function fe(i,t,e,o){let s=i.x+i.width/2-e/2;return s=Math.max(o,Math.min(s,t-e-o)),s}function be(i,t,e,o=24,n=24){const a=i.clickX-t-n/2;return Math.max(o,Math.min(a,e-o-n/2))}function ge(i,t,e,o=tt){const n=o.height+o.arrowHeight,s=pe(i,e,n,o.gap,o.viewportPadding),a=fe(i,t,o.width,o.viewportPadding);return{top:s.top,left:a,position:s.position}}function me(i,t,e,o={}){const n=o.gap??8;let s=i.bottom+n;s+t.height>e.height-n&&(s=i.top-t.height-n);let a=i.left;return a<n?a=n:a+t.width>e.width-n&&(a=e.width-t.width-n),s<n?s=n:s+t.height>e.height-n&&(s=e.height-t.height-n),{top:s,left:a}}function ve(i,t,e,o=tt){const n=ge(i,t,e,o),s=be(i,n.left,o.width);return{modal:n,arrow:{left:s}}}const ye=20;function we(i){const t=[],e=console.error,o=console.warn,n=console.log,s=(a,c)=>{const l={message:c.map(d=>String(d)).join(" "),timestamp:Date.now(),level:a};t.length>=ye&&t.shift(),t.push(l),i&&i(l)};return console.error=function(...a){s("error",a),e.apply(console,a)},console.warn=function(...a){s("warn",a),o.apply(console,a)},console.log=function(...a){s("log",a),n.apply(console,a)},{errors:t,restore:()=>{console.error=e,console.warn=o,console.log=n}}}function q(i,t,e){const o=document.createElement(i);if(t)for(const[n,s]of Object.entries(t))n==="className"?o.className=s:o.setAttribute(n,s);return o}function ke(i=640){return typeof window<"u"&&window.innerWidth<i}function et(i,t,e){const o=e.map(s=>s.style.visibility);e.forEach(s=>s.style.visibility="hidden");const n=document.elementFromPoint(i,t);return e.forEach((s,a)=>s.style.visibility=o[a]),n}function B(i){return i?i.hasAttribute("data-qaid-embed")||i.hasAttribute("data-qaid-embed-overlay")?!0:!!i.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function it(i,t=0){const e=i.getBoundingClientRect();return{x:e.left-t,y:e.top-t,width:e.width+t*2,height:e.height+t*2}}const xe="https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";let qe=i=>import(i),I=null,z=null;function Ce(i){return I&&z===i||(z=i,I=Promise.resolve(qe(i)).then(t=>{const e=t;if(!e||typeof e.QaidQuests!="function")throw new Error("quests module has no QaidQuests export");return e}).catch(t=>{throw I=null,z=null,t})),I}async function Se(i){const t=await Ce(i.moduleUrl),e=i.base.replace(/\/+$/,""),o=i.feedbackId!=null?{feedbackId:i.feedbackId}:void 0;return new t.QaidQuests({endpoint:`${e}/responses`,configUrl:`${e}/${encodeURIComponent(i.questId)}/definition`,apiKey:i.apiKey||void 0,metadata:o,onClose:i.onClose})}const ot="qaid_visitor_id",nt="qaid_hide_feedback",Ee=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"];function Te(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function _(i){return i?`${nt}_${i}`:nt}function Ae(i){try{return localStorage.getItem(_(i))==="1"}catch{return!1}}function st(i,t=!0){try{t?localStorage.setItem(_(i),"1"):localStorage.removeItem(_(i))}catch{}}function Le(){try{let i=localStorage.getItem(ot);return i||(i=crypto.randomUUID(),localStorage.setItem(ot,i)),i}catch{return crypto.randomUUID()}}class at{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;isMobile=!1;visitorId;consoleCapture=null;recording=null;targeting=null;targetingPrewarmed=!1;prewarmHandle=null;prewarmIsTimeout=!1;videoPrewarmed=!1;screenshotPrewarmed=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;modal=null;modalPrewarmed=!1;dismissBtn=null;cssVars={};activeThumbBtn=null;keyboardActivation=!1;dialogTrigger=null;dialogTrap=null;dialogRestoreInert=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundResize;_startDismissed=!1;destroyed=!1;domObserver=null;boundBeforeSwap=null;constructor(t){this.config={endpoint:t.endpoint,apiKey:t.apiKey??"",container:t.container??"",buttonClass:t.buttonClass??"",direction:t.direction??"horizontal",position:t.position??"bottom-right",offset:{x:t.offset?.x??16,y:t.offset?.y??16},zIndex:t.zIndex??50,skipTargeting:t.skipTargeting??!1,singleButton:t.singleButton??!1,feedbackMode:t.feedbackMode??"target",colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#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",feedbackLabel:t.text?.feedbackLabel??"Send 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,annotate:t.annotate??!0,annotationColor:t.annotationColor??t.colors?.marker??"#6366f1",annotationPalette:t.annotationPalette??Ee,screenshotMethod:t.screenshotMethod??"permission",screenshotOptions:{quality:t.screenshotOptions?.quality??.8,maxWidth:t.screenshotOptions?.maxWidth??1280,maxHeight:t.screenshotOptions?.maxHeight??800},incognito:t.incognito??!1,hideDismiss:t.hideDismiss??!1,positiveIcon:t.positiveIcon??"",negativeIcon:t.negativeIcon??"",feedbackIcon:t.feedbackIcon??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15,redaction:t.videoOptions?.redaction??!1},recordIcon:t.recordIcon??"",quests:{base:t.quests?.base??"",up:t.quests?.up??"",down:t.quests?.down??"",video:t.quests?.video??"",apiKey:t.quests?.apiKey??t.apiKey??"",moduleUrl:t.quests?.moduleUrl??xe}},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=Le(),this.init()}applyVars(t){Gt(t,this.cssVars)}announceMsg(t,e=!1){const o=this.overlayShadowRoot??this.shadowRoot;o&&ne(o,t,{assertive:e})}openDialogA11y(t,e){this.dialogTrigger=de(),le(t,e),this.dialogTrap=re(t),this.dialogRestoreInert=ue(t)}closeDialogA11y(){this.dialogTrap?.release(),this.dialogTrap=null,this.dialogRestoreInert&&(this.dialogRestoreInert(),this.dialogRestoreInert=null),ce(this.dialogTrigger),this.dialogTrigger=null}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){Jt(),this.cssVars=Qt({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&&Ae(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=we(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom(),(this.config.captureVideo&&this.videoSupported()||this.config.captureScreenshot)&&this.schedulePrewarm(()=>{this.config.captureVideo&&this.videoSupported()&&this.prewarmVideo(),this.config.captureScreenshot&&this.prewarmScreenshot()})}prewarmVideo(){this.videoPrewarmed||(this.videoPrewarmed=!0,Promise.resolve().then(()=>Ct).catch(()=>{}),Promise.resolve().then(()=>bt).catch(()=>{}))}prewarmScreenshot(){this.screenshotPrewarmed||(this.screenshotPrewarmed=!0,(this.shouldCaptureViaDom()?Promise.resolve().then(()=>yt):Promise.resolve().then(()=>St)).catch(()=>{}),this.config.annotate&&Promise.resolve().then(()=>qt).catch(()=>{}))}schedulePrewarm(t){const e=window,o=()=>{this.destroyed||t()};typeof e.requestIdleCallback=="function"?(this.prewarmIsTimeout=!1,this.prewarmHandle=e.requestIdleCallback(o,{timeout:2e3})):(this.prewarmIsTimeout=!0,this.prewarmHandle=window.setTimeout(o,1200))}observeDom(){this.boundBeforeSwap=t=>{const e=t.newDocument;!e||this.destroyed||(this.shadowHost&&e.body.appendChild(this.shadowHost),this.overlayShadowHost&&e.body.appendChild(this.overlayShadowHost))},document.addEventListener("astro:before-swap",this.boundBeforeSwap),this.domObserver=new MutationObserver(()=>{this.destroyed||(this.shadowHost&&!this.shadowHost.isConnected&&document.body.appendChild(this.shadowHost),this.overlayShadowHost&&!this.overlayShadowHost.isConnected&&document.body.appendChild(this.overlayShadowHost))}),this.domObserver.observe(document.body,{childList:!0})}checkMobile(){this.isMobile=ke()}handleResize(){this.checkMobile()}createEmbed(){this.shadowHost=document.createElement("div"),this.shadowHost.setAttribute("data-qaid-embed",""),this.shadowHost.style.position="static",this.shadowHost.style.display="contents";let t=null;this.config.container&&(t=document.querySelector(this.config.container)),t?(t.appendChild(this.shadowHost),this.isUserProvidedContainer=!0,this.config.hideDismiss=!0):(this.shadowHost.style.position="fixed",this.shadowHost.style.display="block",this.shadowHost.style.inset="0",this.shadowHost.style.pointerEvents="none",this.shadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.shadowHost)),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"});const e=document.createElement("style");if(e.textContent=Q(),this.shadowRoot.appendChild(e),this.config.css){const d=document.createElement("style");d.textContent=this.config.css,this.shadowRoot.appendChild(d)}const o=this.config.direction==="vertical"?"qaid-vertical":"";if(this.isUserProvidedContainer)this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-${this.config.position} ${o}`.trim(),this.config.incognito&&this.buttonsContainer.classList.add("qaid-incognito");else{this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-auto-container qaid-${this.config.position} ${o}${this.config.incognito?" qaid-incognito":""}`.trim(),this.buttonsContainer.style.pointerEvents="auto";const{x:d,y:r}=this.config.offset;this.config.position.includes("right")?this.buttonsContainer.style.right=`${d}px`:this.buttonsContainer.style.left=`${d}px`,this.config.position.includes("bottom")?this.buttonsContainer.style.bottom=`${r}px`:this.buttonsContainer.style.top=`${r}px`}this.applyVars(this.buttonsContainer),this.shadowRoot.appendChild(this.buttonsContainer),this.buttonsContainer.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" "||d.key==="Spacebar")&&(this.keyboardActivation=!0)}),this.buttonsContainer.addEventListener("mousedown",()=>{this.keyboardActivation=!1}),this.buttonsContainer.addEventListener("pointerdown",()=>{this.keyboardActivation=!1});const n=!!this.config.buttonClass,s=n?`qaid-btn-structural ${this.config.buttonClass}`:"qaid-btn",c=this.config.text.tooltip||"Feedback for us?",l=document.createElement("div");if(l.className="qaid-tooltip-text",l.textContent=c,this.applyVars(l),this.shadowRoot.appendChild(l),this.tooltipElement=l,this.config.singleButton){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-feedback`:"qaid-btn qaid-btn-feedback",r.setAttribute("aria-label",this.config.text.feedbackLabel),r.innerHTML=this.config.feedbackIcon||Y,r.addEventListener("click",h=>this.handleThumbClick("neutral",h.currentTarget,h)),r.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(r)}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r),this.buttonsContainer.appendChild(d)}else if(!this.config.hideThumbs){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",r.setAttribute("aria-label",this.config.text.positiveLabel),r.innerHTML=this.config.positiveIcon||E,r.addEventListener("click",g=>this.handleThumbClick("up",g.currentTarget,g)),r.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(r)}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r);const h=document.createElement("div");h.className="qaid-tooltip-wrapper";const p=document.createElement("button");p.type="button",p.className=n?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",p.setAttribute("aria-label",this.config.text.negativeLabel),p.innerHTML=this.config.negativeIcon||$,p.addEventListener("click",g=>this.handleThumbClick("down",g.currentTarget,g)),p.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(p)}),p.addEventListener("mouseleave",()=>this.hideTooltip()),h.appendChild(p),this.buttonsContainer.appendChild(d),this.buttonsContainer.appendChild(h)}if(this.config.captureVideo&&this.videoSupported()){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const r=document.createElement("button");r.type="button",r.className=n?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",r.setAttribute("aria-label",this.config.text.recordLabel),r.innerHTML=this.config.recordIcon||Pt,r.addEventListener("click",()=>{this.ensureRecording().then(p=>this.config.videoOptions.redaction?p.startPicking():p.startRecording())});const h=()=>this.prewarmVideo();r.addEventListener("mouseenter",()=>{h(),this.showTooltip(r)}),r.addEventListener("focus",h),r.addEventListener("touchstart",h,{passive:!0}),r.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(r),this.buttonsContainer.appendChild(d)}this.config.hideDismiss||(this.dismissBtn=document.createElement("button"),this.dismissBtn.type="button",this.dismissBtn.className="qaid-dismiss-btn",this.dismissBtn.setAttribute("aria-label",this.config.text.dismissLabel),this.dismissBtn.title=this.config.text.dismissLabel,this.dismissBtn.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 2l8 8M10 2l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',this.dismissBtn.addEventListener("click",d=>{d.stopPropagation(),this.handleDismiss()}),this.buttonsContainer.insertBefore(this.dismissBtn,this.buttonsContainer.firstChild),this._startDismissed&&this.buttonsContainer.classList.add("qaid-dismissed"))}ensureOverlayHost(){if(this.overlayShadowRoot)return this.overlayShadowRoot;this.overlayShadowHost=document.createElement("div"),this.overlayShadowHost.setAttribute("data-qaid-embed-overlay",""),this.overlayShadowHost.style.position="fixed",this.overlayShadowHost.style.inset="0",this.overlayShadowHost.style.pointerEvents="none",this.overlayShadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.overlayShadowHost),this.overlayShadowRoot=this.overlayShadowHost.attachShadow({mode:"open"});const t=document.createElement("style");if(t.textContent=Q(),this.overlayShadowRoot.appendChild(t),this.config.css){const e=document.createElement("style");e.textContent=this.config.css,this.overlayShadowRoot.appendChild(e)}return this.overlayShadowRoot}tooltipElement=null;showTooltip(t){const e=this.tooltipElement;e.style.visibility="hidden",e.classList.add("qaid-tooltip-visible");const o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),{top:s,left:a}=me(o,n,{width:window.innerWidth,height:window.innerHeight});e.style.top=`${s}px`,e.style.left=`${a}px`,e.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),st(this.config.apiKey,!0)}handleThumbClick(t,e,o){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),st(this.config.apiKey,!1)),this.prewarmModal(),this.config.skipTargeting||this.config.feedbackMode==="annotate")this.submitDirectFeedback(t,e);else{this.activeThumbBtn=e,e.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,this.ensureTargeting().then(s=>{this.destroyed||(n?s.startKeyboard(t):s.startPointer(t,o))})}}submitDirectFeedback(t,e){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const o=e.getBoundingClientRect();this.selectedBounds={x:o.left,y:o.top,width:o.width,height:o.height,clickX:o.left+o.width/2,clickY:o.top+o.height/2,visible:!1},this.submitFeedback()}handleKeyDown(t){if(t.key==="Escape"){if(this.recording?.handleEscape())return;this.state==="TARGETING"?this.targeting?.cancel():this.state==="MODAL_OPEN"&&this.modal?.close()}}shouldCaptureViaDom(){return this.config.screenshotMethod==="dom"||Te()}async openAnnotationEditor(t){const e=this.ensureOverlayHost(),o=this.overlayShadowHost,n=o.style.pointerEvents;o.style.pointerEvents="auto";try{const{openAnnotationEditor:s}=await Promise.resolve().then(()=>qt);return await s({dataUrl:t,root:e,quality:this.config.screenshotOptions.quality,color:this.config.annotationColor,palette:this.config.annotationPalette,applyVars:a=>this.applyVars(a),announce:(a,c)=>this.announceMsg(a,c),openDialog:(a,c)=>this.openDialogA11y(a,c),closeDialog:()=>this.closeDialogA11y()})}catch(s){return console.error("Annotation editor failed to open:",s),null}finally{o.style.pointerEvents=n}}async submitFeedback(){let t=null;if(this.config.captureScreenshot||this.config.feedbackMode==="annotate")try{if(this.shouldCaptureViaDom()){const{captureDomScreenshot:a}=await Promise.resolve().then(()=>yt);t=await a(this.config.screenshotOptions)}else{const{captureScreenshot:a}=await Promise.resolve().then(()=>St);t=await a(this.config.screenshotOptions)}t&&this.announceMsg("Screenshot captured")}catch(a){console.error("Screenshot capture failed:",a),t=null}t&&this.config.annotate&&(t=await this.openAnnotationEditor(t)??t);const o=this.feedbackData.elementSelector?{x:this.selectedBounds.x,y:this.selectedBounds.y,width:this.selectedBounds.width,height:this.selectedBounds.height}:null,n={feedbackType:this.feedbackData.feedbackType,pageUrl:window.location.href,apiKey:this.config.apiKey||void 0,elementSelector:this.feedbackData.elementSelector,elementText:this.feedbackData.elementText,consoleErrors:[...this.feedbackData.consoleErrors],screenWidth:window.innerWidth,screenHeight:window.innerHeight,clickX:this.selectedBounds.clickX,clickY:this.selectedBounds.clickY,scrollX:window.scrollX,scrollY:window.scrollY,screenshot:t,visitorId:this.visitorId,elementBounds:o,userAgent:navigator.userAgent};try{const a=await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(a.ok){const c=await a.json();this.feedbackId=c.id,this.announceMsg("Feedback sent")}}catch(a){console.error("Failed to submit feedback:",a),this.announceMsg("Failed to send feedback",!0)}const s=this.feedbackData.feedbackType;if(s&&s!=="neutral"&&await this.tryLaunchQuest(s,this.feedbackId)){this.resetFeedbackUi();return}this.state="MODAL_OPEN";try{const a=await this.ensureModal();if(this.destroyed)return;a.open(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto")}catch(a){console.error("Failed to open the feedback modal:",a),this.announceMsg("Thank you for your feedback!",!0),this.resetFeedbackUi()}}questIdFor(t){const e=this.config.quests;return e.base&&e[t]||""}async tryLaunchQuest(t,e){const o=this.questIdFor(t);if(!o)return!1;try{return this.activeQuest?.destroy(),this.activeQuest=await Se({questId:o,base:this.config.quests.base,apiKey:this.config.quests.apiKey||void 0,moduleUrl:this.config.quests.moduleUrl,feedbackId:e,onClose:()=>{this.activeQuest=null}}),!0}catch(n){return console.error("Failed to launch quest:",n),this.activeQuest=null,!1}}resetFeedbackUi(){this.targeting?.hideMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackId=null,this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}async ensureModal(){if(!this.modal){const{ModalController:t}=await Promise.resolve().then(()=>Et);this.modal=new t(this.makeModalHost())}return this.modal}makeModalHost(){const t=this;return{get config(){return t.config},get uid(){return t.uid},get isMobile(){return t.isMobile},get state(){return t.state},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},get feedbackId(){return t.feedbackId},setFeedbackId:e=>{t.feedbackId=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),resetFeedbackUi:()=>t.resetFeedbackUi()}}prewarmModal(){this.modalPrewarmed||(this.modalPrewarmed=!0,Promise.resolve().then(()=>Et).catch(()=>{}))}async ensureTargeting(){if(!this.targeting){const{TargetingController:t}=await Promise.resolve().then(()=>Lt);this.targeting=new t(this.makeTargetingHost())}return this.targeting}makeTargetingHost(){const t=this;return{get config(){return t.config},get cssVars(){return t.cssVars},get state(){return t.state},get shadowHost(){return t.shadowHost},get overlayShadowHost(){return t.overlayShadowHost},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),clearActiveThumb:()=>t.clearActiveThumb(),submitFeedback:()=>t.submitFeedback()}}prewarmTargeting(){this.targetingPrewarmed||this.config.skipTargeting||(this.targetingPrewarmed=!0,Promise.resolve().then(()=>Lt).catch(()=>{}))}videoSupported(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}async ensureRecording(){if(!this.recording){const{RecordingController:t}=await Promise.resolve().then(()=>Ct);this.recording=new t(this.makeRecordingHost())}return this.recording}makeRecordingHost(){const t=this;return{get config(){return t.config},get visitorId(){return t.visitorId},get uid(){return t.uid},get overlayShadowHost(){return t.overlayShadowHost},get consoleCapture(){return t.consoleCapture},get boundKeyDown(){return t.boundKeyDown},get state(){return t.state},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),setButtonsDisabled:e=>t.setButtonsDisabled(e),tryLaunchQuest:(e,o)=>t.tryLaunchQuest(e,o)}}setButtonsDisabled(t){if(!this.buttonsContainer)return;this.buttonsContainer.querySelectorAll("button.qaid-btn, button.qaid-btn-structural").forEach(o=>{t?o.classList.contains("qaid-btn-record")||(o.disabled=!0,o.style.opacity="0.5"):(o.disabled=!1,o.style.opacity="")})}destroy(){if(this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.targeting?.destroy(),this.targeting=null,this.clearActiveThumb(),this.closeDialogA11y(),this.prewarmHandle!==null){const t=window;this.prewarmIsTimeout?clearTimeout(this.prewarmHandle):t.cancelIdleCallback?.(this.prewarmHandle),this.prewarmHandle=null}this.recording?.destroy(),this.recording=null,this.modal?.destroy(),this.modal=null,this.activeQuest?.destroy(),this.activeQuest=null,this.consoleCapture&&(this.consoleCapture.restore(),this.consoleCapture=null),window.removeEventListener("resize",this.boundResize),document.removeEventListener("keydown",this.boundKeyDown),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.shadowHost&&(this.shadowHost.remove(),this.shadowHost=null,this.shadowRoot=null),this.overlayShadowHost&&(this.overlayShadowHost.remove(),this.overlayShadowHost=null,this.overlayShadowRoot=null),this.buttonsContainer=null,this.dismissBtn=null,this.tooltipElement=null,Zt()}}function rt(i){return document.querySelector(i)?.textContent?.trim()??""}function Ie(){const i=document.querySelector('script[type="application/json"][data-feedback-config]');if(!i)return null;const t=i.textContent?.trim();if(!t)return null;try{const e=JSON.parse(t);return e.cssSelector&&!e.css&&(e.css=rt(e.cssSelector),delete e.cssSelector),e}catch{return null}}function De(i){const t=i.getAttribute("data-endpoint");if(!t)return null;const e=i.getAttribute("data-position"),o=i.getAttribute("data-zindex"),n=i.getAttribute("data-positive-color"),s=i.getAttribute("data-negative-color"),a=i.getAttribute("data-marker-color"),c=i.getAttribute("data-container"),l=i.getAttribute("data-button-class"),d=i.getAttribute("data-skip-targeting"),r=i.getAttribute("data-single-button"),h=i.getAttribute("data-feedback-mode"),p=i.getAttribute("data-incognito"),g=i.getAttribute("data-button-size"),y=i.getAttribute("data-offset-x"),v=i.getAttribute("data-offset-y"),x=i.getAttribute("data-modal-width"),C=i.getAttribute("data-backdrop-opacity"),u=i.getAttribute("data-font-family"),w=i.getAttribute("data-font-size"),k=i.getAttribute("data-tooltip"),S=i.getAttribute("data-modal-title"),P=i.getAttribute("data-modal-subtitle"),A=i.getAttribute("data-placeholder"),b=i.getAttribute("data-submit-button"),O=i.getAttribute("data-skip-button"),wi=i.getAttribute("data-positive-icon"),ki=i.getAttribute("data-negative-icon"),xi=i.getAttribute("data-feedback-icon"),It=i.getAttribute("data-feedback-label"),qi=i.getAttribute("data-api-key"),Ci=i.getAttribute("data-capture-screenshot"),Si=i.getAttribute("data-annotate"),Ei=i.getAttribute("data-annotation-color"),j=i.getAttribute("data-screenshot-quality"),K=i.getAttribute("data-screenshot-max-width"),W=i.getAttribute("data-screenshot-max-height"),Ti=i.getAttribute("data-capture-video"),Dt=i.getAttribute("data-video-redaction"),Ai=i.getAttribute("data-hide-thumbs"),Li=i.getAttribute("data-hide-dismiss"),X=i.getAttribute("data-video-max-duration"),Ii=i.getAttribute("data-screenshot-method"),Di=i.getAttribute("data-direction"),Mt=i.getAttribute("data-css-selector"),Rt=i.getAttribute("data-quest-base"),Mi=i.getAttribute("data-quest-up"),Ri=i.getAttribute("data-quest-down"),Pi=i.getAttribute("data-quest-video"),Bi=i.getAttribute("data-quest-api-key"),Hi=i.getAttribute("data-quest-module-url");return{endpoint:t,css:Mt?rt(Mt):void 0,apiKey:qi??void 0,captureScreenshot:Ci==="true"?!0:void 0,annotate:Si==="false"?!1:void 0,annotationColor:Ei??void 0,screenshotOptions:j||K||W?{quality:j?parseFloat(j):void 0,maxWidth:K?parseInt(K,10):void 0,maxHeight:W?parseInt(W,10):void 0}:void 0,container:c??void 0,buttonClass:l??void 0,direction:Di??void 0,position:e??void 0,zIndex:o?parseInt(o,10):void 0,skipTargeting:d==="true"?!0:void 0,singleButton:r==="true"?!0:void 0,feedbackMode:h??void 0,incognito:p==="true"?!0:void 0,buttonSize:g??void 0,offset:y||v?{x:y?parseInt(y,10):void 0,y:v?parseInt(v,10):void 0}:void 0,modalWidth:x?parseInt(x,10):void 0,backdropOpacity:C?parseFloat(C):void 0,fontFamily:u??void 0,fontSize:w?parseInt(w,10):void 0,colors:{positive:n??void 0,negative:s??void 0,marker:a??void 0},text:k||S||P||A||b||O||It?{tooltip:k??void 0,modalTitle:S??void 0,modalSubtitle:P??void 0,placeholder:A??void 0,submitButton:b??void 0,skipButton:O??void 0,feedbackLabel:It??void 0}:void 0,positiveIcon:wi??void 0,negativeIcon:ki??void 0,feedbackIcon:xi??void 0,screenshotMethod:Ii??void 0,captureVideo:Ti==="true"?!0:void 0,hideThumbs:Ai==="true"?!0:void 0,hideDismiss:Li==="true"?!0:void 0,videoOptions:X||Dt?{maxDuration:X?parseInt(X,10):void 0,redaction:Dt==="true"?!0:void 0}:void 0,quests:Rt?{base:Rt,up:Mi??void 0,down:Ri??void 0,video:Pi??void 0,apiKey:Bi??void 0,moduleUrl:Hi??void 0}:void 0}}function Me(){if(typeof document>"u")return;const i=()=>{const t=document.currentScript??document.querySelector("script[data-endpoint]"),e=Ie(),o=t?De(t):null,n=e??o;n?.endpoint&&new at(n)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}const Re=20,dt=4096;function H(i){const t=typeof i=="string"?i:JSON.stringify(i);return t.length>dt?t.slice(0,dt)+"…[truncated]":t}function ct(i,t){i.length>=Re&&i.shift(),i.push(t)}async function Pe(i){try{const t=await i.clone().text();return H(t)}catch{return}}function lt(){const i=[],t=window.fetch;window.fetch=async function(n,s){const a=typeof n=="string"?n:n instanceof URL?n.toString():n.url,c=s?.method??(typeof n=="object"&&"method"in n?n.method:"GET");let l;s?.body&&(l=H(s.body));const d=await t.apply(window,[n,s]);if(d.status>=400){const r=await Pe(d);ct(i,{url:a,method:c.toUpperCase(),status:d.status,statusText:d.statusText,requestBody:l,responseBody:r,timestamp:Date.now()})}return d};const e=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,s,...a){return this._qaid_method=n,this._qaid_url=typeof s=="string"?s:s.toString(),e.apply(this,[n,s,...a])},XMLHttpRequest.prototype.send=function(n){const s=this,a=n?H(n):void 0;return s.addEventListener("load",function(){s.status>=400&&ct(i,{url:s._qaid_url,method:s._qaid_method.toUpperCase(),status:s.status,statusText:s.statusText,requestBody:a,responseBody:H(s.responseText),timestamp:Date.now()})}),o.apply(this,[n])},{errors:i,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=e,XMLHttpRequest.prototype.send=o}}}function Be(){const i=navigator.userAgent||"";return/iP(hone|ad|od)/.test(i)||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1}function He(i,t,e,o,n){const s=i>=t,a=e>=o;return s===a?{width:i,height:t,rotate:0}:{width:t,height:i,rotate:n===270?-90:90}}function Oe(i,t,e){if(e.rotate===0){i.drawImage(t,0,0,e.width,e.height);return}i.save(),e.rotate===90?(i.translate(e.width,0),i.rotate(Math.PI/2)):(i.translate(0,e.height),i.rotate(-Math.PI/2)),i.drawImage(t,0,0,e.height,e.width),i.restore()}function $e(){const i=typeof screen<"u"?screen.orientation:void 0;return i&&typeof i.angle=="number"?i.angle:0}function ht(i){return new Promise(t=>{if(i.videoWidth>0){t();return}i.addEventListener("loadedmetadata",()=>t(),{once:!0})})}async function ut(i){try{await i.play()}catch{}}async function ze(i,t=15){const e=document.createElement("canvas");if(typeof e.captureStream!="function")return null;const o=e.getContext("2d");if(!o)return null;const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=i,await ht(n);const s=He(n.videoWidth,n.videoHeight,window.innerWidth,window.innerHeight,$e());e.width=s.width,e.height=s.height,await ut(n);let a=0;const c=()=>{Oe(o,n,s),a=requestAnimationFrame(c)};c();const l=e.captureStream(t);return{stream:l,stop:()=>{a&&cancelAnimationFrame(a),a=0,l.getTracks().forEach(d=>d.stop()),n.pause(),n.srcObject=null}}}function _e(i,t,e,o,n){const s=Math.max(0,Math.min(o,i.left*t)),a=Math.max(0,Math.min(n,i.top*e)),c=Math.max(0,Math.min(o,(i.left+i.width)*t)),l=Math.max(0,Math.min(n,(i.top+i.height)*e)),d=c-s,r=l-a;return d<=0||r<=0?null:{x:s,y:a,w:d,h:r}}function Fe(i,t,e,o,n,s,a){i.drawImage(t,0,0,o,n);const c=o/Math.max(1,window.innerWidth),l=n/Math.max(1,window.innerHeight);for(const d of e){const r=_e(d.getBoundingClientRect(),c,l,o,n);r&&(i.save(),a?(i.filter=`blur(${s}px)`,i.drawImage(t,r.x,r.y,r.w,r.h,r.x,r.y,r.w,r.h)):(i.fillStyle="#0b0b0b",i.fillRect(r.x,r.y,r.w,r.h)),i.restore())}}async function Ve(i,t,e={}){const o=e.frameRate??15,n=e.blurRadius??12,s=document.createElement("canvas");if(typeof s.captureStream!="function")return null;const a=s.getContext("2d");if(!a)return null;const c="filter"in a,l=document.createElement("video");l.muted=!0,l.playsInline=!0,l.srcObject=i,await ht(l),s.width=l.videoWidth,s.height=l.videoHeight,await ut(l);let d=0;const r=()=>{Fe(a,l,t,s.width,s.height,n,c),d=requestAnimationFrame(r)};r();const h=s.captureStream(o);return{stream:h,stop:()=>{d&&cancelAnimationFrame(d),d=0,h.getTracks().forEach(p=>p.stop()),l.pause(),l.srcObject=null}}}function pt(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function F(){if(typeof MediaRecorder>"u")return"";const i=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of i)if(MediaRecorder.isTypeSupported(t))return t;return""}function ft(i={}){const t=i.maxDuration??15,e=i.videoBitsPerSecond??8e5,o=i.redactionElements??[],n=i.redactionBlurRadius;let s=null,a=null,c=null,l=null,d=[],r=null,h=null,p=null,g=0,y=null,v=null,x=!1,C=null;function u(){p!==null&&(clearInterval(p),p=null),C!==null&&(clearTimeout(C),C=null),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&(s.getTracks().forEach(k=>k.stop()),s=null),l=null,d=[],r=null,h=null,y=null,v=null}function w(){x||(x=!0,l&&l.state!=="inactive"&&l.stop())}return{async start(){x=!1,d=[];const k=F();if(!k)throw new Error("No supported video MIME type found");s=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15,displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",monitorTypeSurfaces:"exclude",surfaceSwitching:"exclude"});const S=s.getVideoTracks()[0],P=S?.getSettings?.()?.displaySurface;if(P==="monitor"||P==="window")throw s.getTracks().forEach(b=>b.stop()),s=null,new Error("qaid records only the current tab — please share this tab, not a window or your whole screen.");S&&S.addEventListener("ended",()=>{w()});let A=s;if(Be()){const b=await ze(s);b&&(a=b,A=b.stream)}else if(o.length>0){const b=await Ve(s,o,{blurRadius:n});b&&(c=b,A=b.stream)}l=new MediaRecorder(A,{mimeType:k,videoBitsPerSecond:e}),l.ondataavailable=b=>{b.data.size>0&&d.push(b.data)},l.onstop=()=>{const b=new Blob(d,{type:k});y&&y(b),h&&h(b),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&s.getTracks().forEach(O=>O.stop())},l.onerror=()=>{v&&v(new Error("MediaRecorder error"))},l.start(1e3),g=Date.now(),p=setInterval(()=>{const b=Math.floor((Date.now()-g)/1e3);r&&r(b)},1e3),C=setTimeout(()=>{w()},t*1e3)},stop(){return new Promise((k,S)=>{y=k,v=S,w()})},onTick(k){r=k},onStop(k){h=k},destroy(){w(),u()}}}const bt=Object.freeze(Object.defineProperty({__proto__:null,createVideoRecorder:ft,getSupportedMimeType:F,isVideoRecordingSupported:pt},Symbol.toStringTag,{value:"Module"})),gt="https://qaid.dev/lib/html2canvas.min.js",Ne=1e4,Ue=50;let D=null;function mt(){if(typeof document>"u"||typeof window>"u")return!1;const i=document.createElement("canvas");return typeof i.getContext=="function"&&!!i.getContext("2d")}function je(){return window.html2canvas?Promise.resolve(!0):D||(D=new Promise(i=>{if(!document.querySelector(`script[src="${gt}"]`)){const n=document.createElement("script");n.src=gt,n.async=!0,document.head.appendChild(n)}const e=Date.now(),o=()=>{if(window.html2canvas){i(!0);return}if(Date.now()-e>Ne){D=null,i(!1);return}setTimeout(o,Ue)};o()}),D)}async function vt(i={}){const{quality:t=.8,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!await je()||!window.html2canvas)return console.warn("html2canvas failed to load"),null;const s=await window.html2canvas(document.body,{useCORS:!0,allowTaint:!1,logging:!1,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,x:window.scrollX,y:window.scrollY,ignoreElements:d=>d instanceof HTMLElement?d.classList.contains("qaid-buttons")||d.classList.contains("qaid-targeting-overlay")||d.classList.contains("qaid-modal-container")||d.classList.contains("qaid-bottom-sheet")||d.classList.contains("qaid-backdrop")||d.classList.contains("qaid-selected-marker")||d.classList.contains("qaid-tooltip-text")||d.classList.contains("qaid-recording-indicator")||d.classList.contains("qaid-video-preview")||d.className?.toString().startsWith?.("qaid-"):!1}),a=s.width,c=s.height,l=Math.min(e/a,o/c,1);if(l<1){const d=Math.round(a*l),r=Math.round(c*l),h=document.createElement("canvas");h.width=d,h.height=r;const p=h.getContext("2d");return p?(p.drawImage(s,0,0,d,r),h.toDataURL("image/webp",t)):null}return s.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const yt=Object.freeze(Object.defineProperty({__proto__:null,captureDomScreenshot:vt,isDomScreenshotSupported:mt},Symbol.toStringTag,{value:"Module"})),T=12,Ke="#ef4444",We=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"],Xe={"#ef4444":"red","#f59e0b":"amber","#22c55e":"green","#3b82f6":"blue","#111827":"black","#ffffff":"white","#6366f1":"indigo"};function wt(i){return Xe[i.toLowerCase()]??i}const Ye=4,Qe=.8,Ge={title:"Annotate screenshot",instructions:"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",rectangle:"Rectangle",arrow:"Arrow",pen:"Pen",blur:"Blur or redact",undo:"Undo last",skip:"Skip annotation",done:"Done",colors:"Drawing colour"};function M(i,t){return{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y),w:Math.abs(i.x-t.x),h:Math.abs(i.y-t.y)}}function Je(i){if(i.type==="pen")return i.points.length<2;const t=M(i.points[0],i.points[1]);return t.w<3&&t.h<3}function Ze(i,t,e,o){i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke();const n=Math.atan2(e.y-t.y,e.x-t.x),s=Math.max(10,o*3);i.beginPath(),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n-Math.PI/6),e.y-s*Math.sin(n-Math.PI/6)),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n+Math.PI/6),e.y-s*Math.sin(n+Math.PI/6)),i.stroke()}function ti(i,t){if(t.length!==0){i.beginPath(),i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)i.lineTo(t[e].x,t[e].y);i.stroke()}}function ei(i,t,e,o,n){i.fillStyle="rgb(15, 23, 42)",i.fillRect(t,e,o,n),i.fillStyle="rgb(37, 47, 63)";for(let s=e;s<e+n;s+=T)for(let a=t;a<t+o;a+=T)(Math.floor((a-t)/T)+Math.floor((s-e)/T))%2===0&&i.fillRect(a,s,Math.min(T,t+o-a),Math.min(T,e+n-s))}function R(i,t){switch(i.save(),i.strokeStyle=t.color,i.fillStyle=t.color,i.lineWidth=t.strokeWidth,i.lineJoin="round",i.lineCap="round",t.type){case"rect":{const e=M(t.points[0],t.points[1]);i.strokeRect(e.x,e.y,e.w,e.h);break}case"arrow":Ze(i,t.points[0],t.points[1],t.strokeWidth);break;case"pen":ti(i,t.points);break;case"blur":{const e=M(t.points[0],t.points[1]);ei(i,e.x,e.y,e.w,e.h);break}}i.restore()}function kt(i){return new Promise((t,e)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>e(new Error("Failed to load screenshot")),o.src=i})}async function V(i,t,e={}){const o=e.quality??Qe;let n;try{n=await kt(i)}catch{return i}const s=document.createElement("canvas");s.width=n.naturalWidth||n.width||1,s.height=n.naturalHeight||n.height||1;const a=s.getContext("2d");if(!a)return i;a.drawImage(n,0,0,s.width,s.height);for(const c of t)R(a,c);return s.toDataURL("image/webp",o)}let ii=0;class N{shapes=[];tool="rect";opts;labels;color;palette;strokeWidth;uid=`qaid-annotate-${++ii}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...Ge,...t.labels??{}},this.color=t.color??Ke,this.palette=(t.palette&&t.palette.length?t.palette:We).slice(),this.palette.some(e=>e.toLowerCase()===this.color.toLowerCase())||this.palette.unshift(this.color),this.strokeWidth=t.strokeWidth??Ye}open(){const t=new Promise(e=>{this.resolveResult=e});return this.mount(),t}toolButton(t,e,o){const n=q("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${o} tool`,title:o});return n.innerHTML=`${e}<span class="qaid-annotate-btn-text">${o}</span>`,n}swatchButton(t){const e=wt(t),o=q("button",{type:"button",class:"qaid-annotate-swatch","data-qaid-color":t,"aria-pressed":t.toLowerCase()===this.color.toLowerCase()?"true":"false","aria-label":`Draw in ${e}`,title:e});return o.style.setProperty("--qaid-swatch",t),o}actionButton(t,e,o,n){const s=q("button",{type:"button",class:`qaid-annotate-action ${n}`,"data-qaid-action":t,"aria-label":o,title:o});return s.innerHTML=`${e}<span class="qaid-annotate-btn-text">${o}</span>`,s}mount(){const t=`${this.uid}-title`,e=`${this.uid}-desc`;this.container=q("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const o=q("h2",{id:t,class:"qaid-annotate-title"});o.textContent=this.labels.title;const n=q("p",{id:e,class:"qaid-annotate-desc"});n.textContent=this.labels.instructions;const s=q("div",{class:"qaid-annotate-stage"});this.canvas=document.createElement("canvas"),this.canvas.className="qaid-annotate-canvas",this.canvas.width=1,this.canvas.height=1,this.canvas.setAttribute("role","img"),this.canvas.setAttribute("aria-label",this.labels.title),this.ctx=this.canvas.getContext("2d"),s.appendChild(this.canvas),this.toolbar=q("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const a=q("div",{class:"qaid-annotate-tools"});a.appendChild(this.toolButton("rect",Bt,this.labels.rectangle)),a.appendChild(this.toolButton("arrow",Ht,this.labels.arrow)),a.appendChild(this.toolButton("pen",Ot,this.labels.pen)),a.appendChild(this.toolButton("blur",$t,this.labels.blur));const c=q("div",{class:"qaid-annotate-colors",role:"group","aria-label":this.labels.colors});for(const h of this.palette)c.appendChild(this.swatchButton(h));this.undoBtn=this.actionButton("undo",zt,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const l=this.actionButton("skip",Ft,this.labels.skip,"qaid-annotate-skip"),d=this.actionButton("done",_t,this.labels.done,"qaid-annotate-done"),r=q("div",{class:"qaid-annotate-actions"});r.appendChild(this.undoBtn),r.appendChild(l),r.appendChild(d),this.toolbar.appendChild(a),this.toolbar.appendChild(c),this.toolbar.appendChild(r),this.container.appendChild(o),this.container.appendChild(n),this.container.appendChild(s),this.container.appendChild(this.toolbar),this.opts.root.appendChild(this.container),this.toolbar.addEventListener("click",this.onToolbarClick),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp),this.container.addEventListener("keydown",this.onKeyDown),this.opts.openDialog?.(this.container,{labelledbyId:t,describedbyId:e}),this.opts.announce?.(this.labels.instructions),kt(this.opts.dataUrl).then(h=>{this.img=h,this.canvas.width=h.naturalWidth||h.width||1,this.canvas.height=h.naturalHeight||h.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const e=this.canvas.getBoundingClientRect(),o=this.canvas.width/(e.width||this.canvas.width),n=this.canvas.height/(e.height||this.canvas.height);return{x:(t.clientX-e.left)*o,y:(t.clientY-e.top)*n}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const e of this.shapes)R(t,e);this.current&&R(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(n=>{n.setAttribute("aria-pressed",n.getAttribute("data-qaid-tool")===t?"true":"false")});const o=this.labels[oi[t]];this.opts.announce?.(`${o} tool selected`)}selectColor(t){this.color=t,this.toolbar.querySelectorAll("[data-qaid-color]").forEach(o=>{o.setAttribute("aria-pressed",(o.getAttribute("data-qaid-color")??"").toLowerCase()===t.toLowerCase()?"true":"false")}),this.opts.announce?.(`${wt(t)} colour selected`)}onToolbarClick=t=>{const o=t.target?.closest("[data-qaid-tool],[data-qaid-action],[data-qaid-color]");if(!o)return;const n=o.getAttribute("data-qaid-color");if(n){this.selectColor(n);return}const s=o.getAttribute("data-qaid-tool");if(s){this.selectTool(s);return}const a=o.getAttribute("data-qaid-action");a==="undo"?this.undo():a==="skip"?this.skip():a==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const e=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[e]:[e,{...e}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const e=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(e):this.current.points[1]=e,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,Je(t)){this.redraw();return}this.shapes.push(t),this.undoBtn.disabled=!1,this.opts.announce?.("Annotation added"),this.redraw()};onKeyDown=t=>{if(t.key==="Escape"){t.preventDefault(),this.skip();return}if(t.key==="Enter"){const e=t.target;if(e?.getAttribute("data-qaid-tool")||e?.getAttribute("data-qaid-action"))return;t.preventDefault(),this.done()}};undo(){if(this.shapes.length===0){this.opts.announce?.("Nothing to undo");return}this.shapes.pop(),this.undoBtn.disabled=this.shapes.length===0,this.opts.announce?.("Removed last annotation"),this.redraw()}async done(){if(this.settled)return;const t=await V(this.opts.dataUrl,this.shapes,{quality:this.opts.quality});this.opts.announce?.("Annotated screenshot attached"),this.settle(t)}skip(){this.settled||(this.opts.announce?.("Annotation skipped"),this.settle(null))}settle(t){this.settled=!0,this.teardown(),this.resolveResult(t)}teardown(){this.toolbar.removeEventListener("click",this.onToolbarClick),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.container.removeEventListener("pointermove",this.onPointerMove),this.container.removeEventListener("pointerup",this.onPointerUp),this.container.removeEventListener("keydown",this.onKeyDown),this.opts.closeDialog?.(),this.container.remove()}}const oi={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function xt(i){return new N(i).open()}const qt=Object.freeze(Object.defineProperty({__proto__:null,AnnotationEditor:N,compositeAnnotations:V,drawShape:R,openAnnotationEditor:xt,rectFromPoints:M},Symbol.toStringTag,{value:"Module"}));Me();const ni=document;function f(i,t,...e){const o=ni.createElement(i);if(t){if(t.class&&(o.className=t.class),t.style&&(o.style.cssText=t.style),t.html!=null&&(o.innerHTML=t.html),t.text!=null&&(o.textContent=t.text),t.attrs)for(const n in t.attrs)o.setAttribute(n,t.attrs[n]);if(t.on)for(const n in t.on)o.addEventListener(n,t.on[n])}for(const n of e)n!=null&&n!==!1&&o.append(n);return o}class si{constructor(t){this.host=t}videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;redactPicks=[];redactPickerRoot=null;redactRafId=0;boundRedactClick=t=>this.handleRedactPickClick(t);handleEscape(){return this.isRecording?(this.stopRecording(),!0):this.videoPreview?(this.cancelRecordingPreview(),!0):this.redactPickerRoot?(this.finishRedactionPicking(!1),!0):!1}destroy(){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null),this.redactPicks=[],this.cleanupRecording(),this.removeVideoPreview()}async startRecording(t=[]){if(!(this.isRecording||this.host.state!=="IDLE"))try{this.networkCapture=lt();const{createVideoRecorder:e}=await Promise.resolve().then(()=>bt);this.videoRecorder=e({maxDuration:this.host.config.videoOptions.maxDuration,redactionElements:t}),this.videoRecorder.onTick(o=>{this.updateRecordingTimer(o)}),this.videoRecorder.onStop(o=>{this.isRecording&&(this.recordedBlob=o,this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.host.setButtonsDisabled(!1),o&&o.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.host.announceMsg("Recording started"),this.host.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.host.boundKeyDown)}catch(e){e instanceof Error&&/current tab/i.test(e.message)&&this.host.announceMsg(e.message),this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}startPicking(){if(this.isRecording||this.host.state!=="IDLE")return;this.host.setState("REDACT_PICKING"),this.redactPicks=[];const t=this.host.ensureOverlayHost(),e=f("div",{style:"position:absolute;inset:0;"}),o=f("div",{class:"qaid-redact-picker",style:"position:fixed;inset:0;pointer-events:none;"},e,f("div",{style:"position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;gap:12px;align-items:center;pointer-events:auto;background:#0b1220;color:#fff;border:1px solid #ff6b6b;border-radius:9999px;padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 8px 30px rgba(0,0,0,.5);"},f("span",{text:"Click sensitive areas to blur",attrs:{"data-qaid-redact-label":""}}),f("button",{text:"Start recording",attrs:{type:"button"},style:"cursor:pointer;border:0;border-radius:9999px;padding:8px 14px;background:#ff6b6b;color:#0b1220;font:inherit;",on:{click:()=>this.finishRedactionPicking(!0)}}),f("button",{text:"Cancel",attrs:{type:"button"},style:"cursor:pointer;border:0;background:transparent;color:#9fb3c8;font:inherit;",on:{click:()=>this.finishRedactionPicking(!1)}})));t.appendChild(o),this.redactPickerRoot=o;const n=()=>{this.renderRedactPicks(e),this.redactRafId=requestAnimationFrame(n)};n(),document.addEventListener("click",this.boundRedactClick,!0),document.addEventListener("keydown",this.host.boundKeyDown),this.host.announceMsg("Click sensitive areas to blur, then start recording")}handleRedactPickClick(t){const e=t.target instanceof Element?t.target:null;if(!e||B(e)||this.redactPickerRoot?.contains(e))return;t.preventDefault(),t.stopPropagation();const o=this.redactPicks.indexOf(e);o>=0?this.redactPicks.splice(o,1):this.redactPicks.push(e);const n=this.redactPickerRoot?.querySelector("[data-qaid-redact-label]");if(n){const s=this.redactPicks.length;n.textContent=s===0?"Click sensitive areas to blur":`${s} area${s===1?"":"s"} will be blurred`}}renderRedactPicks(t){t.textContent="";for(const e of this.redactPicks){const o=e.getBoundingClientRect();o.width<=0||o.height<=0||t.appendChild(f("div",{style:`position:fixed;left:${o.left}px;top:${o.top}px;width:${o.width}px;height:${o.height}px;border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;`}))}}finishRedactionPicking(t){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),document.removeEventListener("keydown",this.host.boundKeyDown),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null);const e=this.redactPicks;this.redactPicks=[],this.host.setState("IDLE"),t&&this.startRecording(e)}showRecordingIndicator(){const t=this.host.ensureOverlayHost();this.recordingIndicator=f("div",{class:"qaid-recording-indicator",style:`z-index:${this.host.config.zIndex+100}`},f("div",{class:"qaid-recording-dot"}),f("span",{class:"qaid-recording-time",text:this.formatTime(this.host.config.videoOptions.maxDuration)}),f("button",{class:"qaid-recording-stop",text:"Stop",attrs:{type:"button"},on:{click:()=>this.stopRecording()}})),this.host.applyVars(this.recordingIndicator),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const e=this.recordingIndicator.querySelector(".qaid-recording-time");if(e){const o=Math.max(0,this.host.config.videoOptions.maxDuration-t);e.textContent=this.formatTime(o),o>0&&o<=5&&this.host.announceMsg(`${o} second${o===1?"":"s"} remaining`)}}formatTime(t){const e=Math.floor(t/60),o=t%60;return`${e}:${o.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.host.ensureOverlayHost(),e=URL.createObjectURL(this.recordedBlob),o=`qaid-video-title-${this.host.uid}`,n=f("h3",{text:"Review your recording",attrs:{id:o}}),s=f("video");s.src=e,s.controls=!0,s.autoplay=!0,s.muted=!0;const a=f("textarea",{attrs:{placeholder:"Optional: Describe the issue you recorded...","aria-label":"Describe the issue you recorded"}}),c=f("button",{class:"qaid-video-btn qaid-video-btn-send",text:"Send",attrs:{type:"button"},on:{click:()=>this.submitVideoFeedback(a.value.trim()||null,c)}}),l=f("div",{class:"qaid-video-preview-box"},n,s,a,f("div",{class:"qaid-video-preview-actions"},f("button",{class:"qaid-video-btn qaid-video-btn-cancel",text:"Cancel",attrs:{type:"button"},on:{click:()=>this.cancelRecordingPreview()}}),f("button",{class:"qaid-video-btn qaid-video-btn-rerecord",text:"Re-record",attrs:{type:"button"},on:{click:()=>{this.cancelRecordingPreview(),this.startRecording()}}}),c));this.videoPreview=f("div",{class:"qaid-video-preview",style:`z-index:${this.host.config.zIndex+100}`},l),this.host.applyVars(this.videoPreview),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.host.openDialogA11y(l,{labelledbyId:n.id}),document.addEventListener("keydown",this.host.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.host.closeDialogA11y(),this.videoPreview){const t=this.videoPreview.querySelector("video");t?.src&&URL.revokeObjectURL(t.src),this.videoPreview.remove(),this.videoPreview=null}document.removeEventListener("keydown",this.host.boundKeyDown)}async submitVideoFeedback(t,e){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,e.disabled=!0,e.textContent="Sending...";const o=new FormData;o.append("video",this.recordedBlob,`recording.${this.recordedBlob.type.includes("mp4")?"mp4":"webm"}`),o.append("pageUrl",window.location.href),o.append("visitorId",this.host.visitorId),this.host.config.apiKey&&o.append("apiKey",this.host.config.apiKey),t&&o.append("message",t),this.host.consoleCapture&&o.append("consoleErrors",JSON.stringify(this.host.consoleCapture.errors)),this.networkCapture&&o.append("networkErrors",JSON.stringify(this.networkCapture.errors));let n=null;try{const s=await fetch(`${this.host.config.endpoint}/video`,{method:"POST",body:o});if(s.ok){this.host.announceMsg("Recording sent");try{n=(await s.json())?.id??null}catch{}}else console.error("Failed to submit video feedback:",await s.text()),this.host.announceMsg("Failed to send recording",!0)}catch(s){console.error("Failed to submit video feedback:",s),this.host.announceMsg("Failed to send recording",!0)}this.isSendingVideo=!1,this.removeVideoPreview(),this.cleanupRecording(),await this.host.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.host.setButtonsDisabled(!1),this.host.overlayShadowHost&&this.host.state==="IDLE"&&(this.host.overlayShadowHost.style.pointerEvents="none")}}const Ct=Object.freeze(Object.defineProperty({__proto__:null,RecordingController:si},Symbol.toStringTag,{value:"Module"}));async function ai(i={}){const{quality:t=1,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!navigator.mediaDevices?.getDisplayMedia)return console.warn("Screen Capture API not available"),null;const n=await navigator.mediaDevices.getDisplayMedia({preferCurrentTab:!0,video:{displaySurface:"browser"}}),s=n.getVideoTracks()[0],a=s.getSettings(),c=document.createElement("video");c.srcObject=n,c.muted=!0,await new Promise(v=>{c.onloadedmetadata=()=>{c.play(),v()}}),await new Promise(v=>{const x=()=>{c.readyState>=2?v():requestAnimationFrame(x)};x()}),await new Promise(v=>setTimeout(v,100));const l=a.width||c.videoWidth,d=a.height||c.videoHeight,r=Math.min(e/l,o/d,1),h=Math.round(l*r),p=Math.round(d*r),g=document.createElement("canvas");g.width=h,g.height=p;const y=g.getContext("2d");return y?(y.drawImage(c,0,0,h,p),s.stop(),g.toDataURL("image/webp",t)):(s.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const St=Object.freeze(Object.defineProperty({__proto__:null,captureScreenshot:ai},Symbol.toStringTag,{value:"Module"}));class ri{constructor(t){this.host=t}modalContainer=null;backdrop=null;open(){const t=this.host.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.host.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.host.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.close()),this.host.applyVars(this.backdrop),this.host.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.host.boundKeyDown)}close(){this.host.state==="MODAL_OPEN"&&this.host.feedbackId&&fetch(`${this.host.config.endpoint}/${this.host.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(t=>console.error("Failed to finalize feedback:",t)),this.teardown(),this.host.resetFeedbackUi()}destroy(){this.teardown()}teardown(){this.host.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.host.boundKeyDown)}showBottomSheet(){const t=this.host.ensureOverlayHost(),e=document.createElement("div");e.className="qaid-bottom-sheet",e.style.zIndex=String(this.host.config.zIndex+3),e.innerHTML=`
24
24
  <div class="qaid-bottom-sheet-content">
25
25
  <div class="qaid-bottom-sheet-handle"></div>
26
26
  ${this.getModalContent()}
@@ -43,5 +43,5 @@
43
43
  <div class="qaid-scope-ring"></div>
44
44
  <div class="qaid-scope-ring-inner"></div>
45
45
  <div class="qaid-scope-dot"></div>
46
- `,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(e),this.overlayContainer.appendChild(this.highlightBox),this.overlayContainer.appendChild(this.crosshairH),this.overlayContainer.appendChild(this.crosshairV),this.overlayContainer.appendChild(this.scope),this.crosshairH.style.top=`${this.mousePos.y}px`,this.crosshairV.style.left=`${this.mousePos.x}px`,this.scope.style.left=`${this.mousePos.x}px`,this.scope.style.top=`${this.mousePos.y}px`,this.host.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleMouseMove(t){this.updateReticleAt(t.clientX,t.clientY)}updateReticleAt(t,e){if(this.mousePos.x=t,this.mousePos.y=e,this.crosshairH&&(this.crosshairH.style.top=`${e}px`),this.crosshairV&&(this.crosshairV.style.left=`${t}px`),this.scope&&(this.scope.style.left=`${t}px`,this.scope.style.top=`${e}px`),this.captureLayer&&this.host.shadowHost){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=et(t,e,o);if(n&&!B(n)){if(this.highlightBox){const s=n.getBoundingClientRect();this.highlightBox.style.transform=`translate(${s.left}px, ${s.top}px)`,this.highlightBox.style.width=`${s.width}px`,this.highlightBox.style.height=`${s.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation(),this.selectAt(t.clientX,t.clientY)}handleTouchStart(t){const e=t.touches[0];e&&(this.touchStartPos={x:e.clientX,y:e.clientY},this.updateReticleAt(e.clientX,e.clientY))}handleTouchEnd(t){const e=t.changedTouches[0],o=this.touchStartPos;this.touchStartPos=null,!(!e||!o||Math.hypot(e.clientX-o.x,e.clientY-o.y)>vi)&&(t.preventDefault(),this.selectAt(e.clientX,e.clientY))}selectAt(t,e){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=et(t,e,o);if(!n||B(n))return;const s=it(n,8);Object.assign(this.host.selectedBounds,s,{clickX:t,clickY:e,visible:!0});const{selector:a,text:c}=U(n);this.host.feedbackData.elementSelector=a,this.host.feedbackData.elementText=c,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.setState("SELECTED"),this.host.clearActiveThumb(),this.showSelectedMarker(),this.host.submitFeedback()}stopTargetingListeners(){this.removeTargetingOverlay(),this.touchStartPos=null,document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),document.removeEventListener("touchstart",this.boundTouchStart),document.removeEventListener("touchend",this.boundTouchEnd),document.removeEventListener("keydown",this.host.boundKeyDown)}cancel(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.clearActiveThumb(),this.host.setState("IDLE"),this.host.feedbackData.feedbackType=null,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1}removeTargetingOverlay(){this.overlayContainer&&(this.overlayContainer.remove(),this.overlayContainer=null),this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null}showSelectedMarker(){const t=this.host.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.host.selectedBounds.x}px`,this.marker.style.top=`${this.host.selectedBounds.y}px`,this.marker.style.width=`${this.host.selectedBounds.width}px`,this.marker.style.height=`${this.host.selectedBounds.height}px`,this.marker.style.zIndex=String(this.host.config.zIndex+1),this.host.applyVars(this.marker),t.appendChild(this.marker)}hideMarker(){this.marker&&(this.marker.remove(),this.marker=null)}destroy(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),this.hideMarker()}}const Lt=Object.freeze(Object.defineProperty({__proto__:null,TargetingController:yi},Symbol.toStringTag,{value:"Module"}));m.AnnotationEditor=N,m.QaidFeedback=at,m.captureDomScreenshot=vt,m.captureNetworkErrors=lt,m.compositeAnnotations=F,m.createVideoRecorder=ft,m.drawShape=R,m.getSupportedMimeType=V,m.isDomScreenshotSupported=mt,m.isVideoRecordingSupported=pt,m.openAnnotationEditor=xt,m.rectFromPoints=M,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
46
+ `,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(e),this.overlayContainer.appendChild(this.highlightBox),this.overlayContainer.appendChild(this.crosshairH),this.overlayContainer.appendChild(this.crosshairV),this.overlayContainer.appendChild(this.scope),this.crosshairH.style.top=`${this.mousePos.y}px`,this.crosshairV.style.left=`${this.mousePos.x}px`,this.scope.style.left=`${this.mousePos.x}px`,this.scope.style.top=`${this.mousePos.y}px`,this.host.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleMouseMove(t){this.updateReticleAt(t.clientX,t.clientY)}updateReticleAt(t,e){if(this.mousePos.x=t,this.mousePos.y=e,this.crosshairH&&(this.crosshairH.style.top=`${e}px`),this.crosshairV&&(this.crosshairV.style.left=`${t}px`),this.scope&&(this.scope.style.left=`${t}px`,this.scope.style.top=`${e}px`),this.captureLayer&&this.host.shadowHost){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=et(t,e,o);if(n&&!B(n)){if(this.highlightBox){const s=n.getBoundingClientRect();this.highlightBox.style.transform=`translate(${s.left}px, ${s.top}px)`,this.highlightBox.style.width=`${s.width}px`,this.highlightBox.style.height=`${s.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation(),this.selectAt(t.clientX,t.clientY)}handleTouchStart(t){const e=t.touches[0];e&&(this.touchStartPos={x:e.clientX,y:e.clientY},this.updateReticleAt(e.clientX,e.clientY))}handleTouchEnd(t){const e=t.changedTouches[0],o=this.touchStartPos;this.touchStartPos=null,!(!e||!o||Math.hypot(e.clientX-o.x,e.clientY-o.y)>vi)&&(t.preventDefault(),this.selectAt(e.clientX,e.clientY))}selectAt(t,e){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=et(t,e,o);if(!n||B(n))return;const s=it(n,8);Object.assign(this.host.selectedBounds,s,{clickX:t,clickY:e,visible:!0});const{selector:a,text:c}=U(n);this.host.feedbackData.elementSelector=a,this.host.feedbackData.elementText=c,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.setState("SELECTED"),this.host.clearActiveThumb(),this.showSelectedMarker(),this.host.submitFeedback()}stopTargetingListeners(){this.removeTargetingOverlay(),this.touchStartPos=null,document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),document.removeEventListener("touchstart",this.boundTouchStart),document.removeEventListener("touchend",this.boundTouchEnd),document.removeEventListener("keydown",this.host.boundKeyDown)}cancel(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.clearActiveThumb(),this.host.setState("IDLE"),this.host.feedbackData.feedbackType=null,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1}removeTargetingOverlay(){this.overlayContainer&&(this.overlayContainer.remove(),this.overlayContainer=null),this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null}showSelectedMarker(){const t=this.host.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.host.selectedBounds.x}px`,this.marker.style.top=`${this.host.selectedBounds.y}px`,this.marker.style.width=`${this.host.selectedBounds.width}px`,this.marker.style.height=`${this.host.selectedBounds.height}px`,this.marker.style.zIndex=String(this.host.config.zIndex+1),this.host.applyVars(this.marker),t.appendChild(this.marker)}hideMarker(){this.marker&&(this.marker.remove(),this.marker=null)}destroy(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),this.hideMarker()}}const Lt=Object.freeze(Object.defineProperty({__proto__:null,TargetingController:yi},Symbol.toStringTag,{value:"Module"}));m.AnnotationEditor=N,m.QaidFeedback=at,m.captureDomScreenshot=vt,m.captureNetworkErrors=lt,m.compositeAnnotations=V,m.createVideoRecorder=ft,m.drawShape=R,m.getSupportedMimeType=F,m.isDomScreenshotSupported=mt,m.isVideoRecordingSupported=pt,m.openAnnotationEditor=xt,m.rectFromPoints=M,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
47
47
  //# sourceMappingURL=qaid.umd.cjs.map