@qaiddev/thumbs-embed 1.14.1 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -119,6 +119,10 @@ We offer a Free Plan for a compatible endpoint and a dashboard to manage your si
119
119
  | `endpoint` | `string` | **(required)** | API endpoint URL for submitting feedback data |
120
120
  | `apiKey` | `string` | `""` | API key for authenticating with the feedback service |
121
121
  | `skipTargeting` | `boolean` | `false` | Skip element targeting and go directly to the feedback modal |
122
+ | `remoteConfig` | `boolean` | `false` | Fetch the project's saved settings from `{endpoint}/config?apiKey=…` (see [Load settings instead of pasting them](#load-settings-instead-of-pasting-them)) |
123
+ | `themeUrl` | `string` | `""` | Fetch a theme document (icons, CSS, button class, colours, size, text) from this URL |
124
+ | `remoteTimeoutMs` | `number` | `3000` | How long to wait for `remoteConfig` / `themeUrl` before drawing without them |
125
+ | `captureErrors` | `boolean \| { endpoint?, release?, environment?, sampleRate? }` | `false` | Send the page's uncaught errors and unhandled rejections to qaid's error triage (Enterprise). Needs `apiKey`. Goes to `/api/errors` beside `endpoint`; at most 50 per page, 3 of each, secrets redacted |
122
126
 
123
127
  ### Positioning
124
128
 
@@ -251,8 +255,8 @@ The embed runs on your page with your page's rights, so treat it like any other
251
255
 
252
256
  ```html
253
257
  <script
254
- src="https://unpkg.com/@qaiddev/thumbs-embed@1.14.1/dist/embed.js"
255
- integrity="sha384-67tCE9csiampTZ3ATAT/bsTA/jg+3EQtS1vaw34Jpce0Sy1hKg/LhchwYwURHpQM"
258
+ src="https://unpkg.com/@qaiddev/thumbs-embed@1.16.0/dist/embed.js"
259
+ integrity="sha384-kCAon2t7xSRyDSI59280ii029y4GJvaY8cCHYaRqi/eWZNBOSKEenkKll8Z3d82O"
256
260
  crossorigin="anonymous"
257
261
  defer
258
262
  data-endpoint="https://qaid.dev/api/feedback"
@@ -260,8 +264,8 @@ The embed runs on your page with your page's rights, so treat it like any other
260
264
  ></script>
261
265
  ```
262
266
 
263
- - The `@1.14.1` pins the release. Without it unpkg serves the newest release, and a hash can never match for long.
264
- - `integrity` is the sha384 of `dist/embed.js` for that release. It is in each release's notes; to work it out yourself: `curl -s https://unpkg.com/@qaiddev/thumbs-embed@1.14.1/dist/embed.js | openssl dgst -sha384 -binary | openssl base64 -A`.
267
+ - The `@1.16.0` pins the release. Without it unpkg serves the newest release, and a hash can never match for long.
268
+ - `integrity` is the sha384 of `dist/embed.js` for that release. It is in each release's notes; to work it out yourself: `curl -s https://unpkg.com/@qaiddev/thumbs-embed@1.16.0/dist/embed.js | openssl dgst -sha384 -binary | openssl base64 -A`.
265
269
  - `crossorigin="anonymous"` is required for the browser to check a hash on a file from another origin.
266
270
  - **What the one hash covers.** When the tag carries `integrity`, every file `embed.js` loads after itself is checked too, with hashes baked in when the release was built:
267
271
  - Browsers that enforce import-map `integrity` (Chrome 127+, Safari 18+, Firefox 138+) get the small code-split build (about 14 KB gzipped at start-up). `embed.js` adds an import map listing the sha384 of `loader.js` and every lazy chunk, and the browser refuses any chunk whose bytes differ.
@@ -275,7 +279,7 @@ The embed runs on your page with your page's rights, so treat it like any other
275
279
  A policy that lets the embed work and nothing else from its side:
276
280
 
277
281
  ```
278
- script-src 'self' https://unpkg.com/@qaiddev/thumbs-embed@1.14.1/ https://unpkg.com/@qaiddev/quests-embed@1.12.1/;
282
+ script-src 'self' https://unpkg.com/@qaiddev/thumbs-embed@1.16.0/ https://unpkg.com/@qaiddev/quests-embed@1.12.1/;
279
283
  style-src 'self' 'unsafe-inline';
280
284
  connect-src 'self' https://qaid.dev;
281
285
  img-src 'self' data: blob:;
@@ -367,6 +371,9 @@ Boolean attributes turn on with `"true"`; any other value leaves the default. `d
367
371
  | `data-quest-api-key` | `quests.apiKey` |
368
372
  | `data-quest-module-url` | `quests.moduleUrl` |
369
373
  | `data-config-id` | (the `id` of this tag's JSON config block) |
374
+ | `data-remote-config` | `remoteConfig` (`"true"` turns it on) |
375
+ | `data-theme-url` | `themeUrl` |
376
+ | `data-remote-timeout` | `remoteTimeoutMs` |
370
377
 
371
378
  A value the embed can't use is ignored with one `console.warn` naming the attribute, and the default stays. That covers a malformed `data-annotation-palette` and an empty screen-reader label (`data-positive-label=""` would leave the button with no accessible name).
372
379
 
@@ -416,6 +423,35 @@ When `buttonClass` is provided, default button colors, sizing, and shadows are n
416
423
  }
417
424
  ```
418
425
 
426
+ ## Load settings instead of pasting them
427
+
428
+ Since 1.15.0 the snippet can be just the endpoint and the key. The embed
429
+ fetches the rest when it starts.
430
+
431
+ ```html
432
+ <script src="https://unpkg.com/@qaiddev/thumbs-embed@1.16.0/dist/embed.js" defer
433
+ data-api-key="YOUR_KEY"
434
+ data-endpoint="https://qaid.dev/api/feedback"
435
+ data-remote-config="true"></script>
436
+ ```
437
+
438
+ 1. `remoteConfig` fetches `GET {endpoint}/config?apiKey=…`. On qaid.dev that
439
+ is the project's saved Customize settings, so pressing **Save** there
440
+ updates every site on this snippet within about a minute.
441
+ 2. `themeUrl` fetches one theme: `https://qaid.dev/api/themes/<id>/embed`,
442
+ where `<id>` is a built-in theme (`neon`, `lcars`, `minimal`, …) or a saved
443
+ theme. A private saved theme needs `?key=<embed key>` on the URL.
444
+ 3. Order, lowest first: defaults, then `remoteConfig`, then `themeUrl`, then
445
+ anything in the snippet itself. So you can still pin one setting by hand.
446
+ 4. The buttons wait for the answers, at most `remoteTimeoutMs` (3000 ms),
447
+ so the default look never flashes first. A failure or a timeout logs one
448
+ `console.warn` and draws with what the snippet has.
449
+ 5. A fetched answer can never change `endpoint`, `apiKey`, `container` or
450
+ `quests.moduleUrl`. A fetched `quests.base` is used only on the
451
+ endpoint's own origin. Icons and CSS go through the same sanitizer and
452
+ shadow root as pasted ones.
453
+ 6. `feedback.ready` is a promise that resolves once the buttons are drawn.
454
+
419
455
  ## API
420
456
 
421
457
  ### Constructor
@@ -428,7 +464,8 @@ const feedback = new QaidFeedback(config: FeedbackConfig);
428
464
 
429
465
  | Method | Description |
430
466
  |--------|-------------|
431
- | `destroy()` | Remove all DOM elements, event listeners, and injected styles. Safe to call multiple times. |
467
+ | `destroy()` | Remove all DOM elements, event listeners, and injected styles. Safe to call multiple times, and before fetched settings arrive. |
468
+ | `ready` (property) | `Promise<void>` that resolves once the buttons are drawn. Immediate unless `remoteConfig` or `themeUrl` is set; never rejects. |
432
469
 
433
470
  ### Payload
434
471
 
@@ -1,2 +1,2 @@
1
- import{c as r,i as f,R as y,A as k,P as x,B as C,U as E,S as A,b as L}from"./core-Dz8Cwmr8.js";const I=".qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:var(--qaid-font-size, 16px);font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:calc(var(--qaid-font-size, 16px) * .8125);line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:calc(var(--qaid-font-size, 16px) * .8125);font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}.qaid-annotate-colors{display:flex;gap:.25rem;align-items:center}button.qaid-annotate-swatch{width:28px;height:28px;min-width:28px;padding:0;border-radius:9999px;border:2px solid light-dark(#d1d5db,#4b5563);background:var(--qaid-swatch, #000);cursor:pointer;-webkit-appearance:none;appearance:none;transition:transform .1s,box-shadow .15s,border-color .15s}button.qaid-annotate-swatch:hover{transform:scale(1.12)}button.qaid-annotate-swatch[aria-pressed=true]{border-color:light-dark(#111827,#f9fafb);box-shadow:0 0 0 2px var(--qaid-swatch)}@media(forced-colors:active){button.qaid-annotate-swatch[aria-pressed=true]{outline:2px solid Highlight;outline-offset:1px}}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6365f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6365f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6365f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}",d=12,B="#ef4444",T=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"],D={"#ef4444":"red","#f59e0b":"amber","#22c55e":"green","#3b82f6":"blue","#111827":"black","#ffffff":"white","#6365f1":"indigo","#6366f1":"indigo"};function b(a){return D[a.toLowerCase()]??a}const P=4,M=.8,R={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 u(a,t){return{x:Math.min(a.x,t.x),y:Math.min(a.y,t.y),w:Math.abs(a.x-t.x),h:Math.abs(a.y-t.y)}}function S(a){if(a.type==="pen")return a.points.length<2;const t=u(a.points[0],a.points[1]);return t.w<3&&t.h<3}function N(a,t,e,n){a.beginPath(),a.moveTo(t.x,t.y),a.lineTo(e.x,e.y),a.stroke();const o=Math.atan2(e.y-t.y,e.x-t.x),i=Math.max(10,n*3);a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(e.x-i*Math.cos(o-Math.PI/6),e.y-i*Math.sin(o-Math.PI/6)),a.moveTo(e.x,e.y),a.lineTo(e.x-i*Math.cos(o+Math.PI/6),e.y-i*Math.sin(o+Math.PI/6)),a.stroke()}function _(a,t){if(t.length!==0){a.beginPath(),a.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)a.lineTo(t[e].x,t[e].y);a.stroke()}}function U(a,t,e,n,o){a.fillStyle="rgb(15, 23, 42)",a.fillRect(t,e,n,o),a.fillStyle="rgb(37, 47, 63)";for(let i=e;i<e+o;i+=d)for(let s=t;s<t+n;s+=d)(Math.floor((s-t)/d)+Math.floor((i-e)/d))%2===0&&a.fillRect(s,i,Math.min(d,t+n-s),Math.min(d,e+o-i))}function p(a,t){switch(a.save(),a.strokeStyle=t.color,a.fillStyle=t.color,a.lineWidth=t.strokeWidth,a.lineJoin="round",a.lineCap="round",t.type){case"rect":{const e=u(t.points[0],t.points[1]);a.strokeRect(e.x,e.y,e.w,e.h);break}case"arrow":N(a,t.points[0],t.points[1],t.strokeWidth);break;case"pen":_(a,t.points);break;case"blur":{const e=u(t.points[0],t.points[1]);U(a,e.x,e.y,e.w,e.h);break}}a.restore()}function g(a){return new Promise((t,e)=>{const n=new Image;n.onload=()=>t(n),n.onerror=()=>e(new Error("Failed to load screenshot")),n.src=a})}async function w(a,t,e={}){const n=e.quality??M;let o;try{o=await g(a)}catch{return a}const i=document.createElement("canvas");i.width=o.naturalWidth||o.width||1,i.height=o.naturalHeight||o.height||1;const s=i.getContext("2d");if(!s)return a;s.drawImage(o,0,0,i.width,i.height);for(const h of t)p(s,h);return i.toDataURL("image/webp",n)}let O=0;class v{shapes=[];tool="rect";opts;labels;color;palette;strokeWidth;uid=`qaid-annotate-${++O}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...R,...t.labels??{}},this.color=t.color??B,this.palette=(t.palette&&t.palette.length?t.palette:T).slice(),this.palette.some(e=>e.toLowerCase()===this.color.toLowerCase())||this.palette.unshift(this.color),this.strokeWidth=t.strokeWidth??P}open(){const t=new Promise(e=>{this.resolveResult=e});return this.mount(),t}toolButton(t,e,n){const o=r("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${n} tool`,title:n});return o.append(f(null,e),r("span",{class:"qaid-annotate-btn-text"},[n])),o}swatchButton(t){const e=b(t),n=r("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 n.style.setProperty("--qaid-swatch",t),n}actionButton(t,e,n,o){const i=r("button",{type:"button",class:`qaid-annotate-action ${o}`,"data-qaid-action":t,"aria-label":n,title:n});return i.append(f(null,e),r("span",{class:"qaid-annotate-btn-text"},[n])),i}mount(){const t=`${this.uid}-title`,e=`${this.uid}-desc`;this.container=r("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const n=r("h2",{id:t,class:"qaid-annotate-title"});n.textContent=this.labels.title;const o=r("p",{id:e,class:"qaid-annotate-desc"});o.textContent=this.labels.instructions;const i=r("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"),i.appendChild(this.canvas),this.toolbar=r("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const s=r("div",{class:"qaid-annotate-tools"});s.appendChild(this.toolButton("rect",y,this.labels.rectangle)),s.appendChild(this.toolButton("arrow",k,this.labels.arrow)),s.appendChild(this.toolButton("pen",x,this.labels.pen)),s.appendChild(this.toolButton("blur",C,this.labels.blur));const h=r("div",{class:"qaid-annotate-colors",role:"group","aria-label":this.labels.colors});for(const l of this.palette)h.appendChild(this.swatchButton(l));this.undoBtn=this.actionButton("undo",E,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const m=this.actionButton("skip",A,this.labels.skip,"qaid-annotate-skip"),q=this.actionButton("done",L,this.labels.done,"qaid-annotate-done"),c=r("div",{class:"qaid-annotate-actions"});c.appendChild(this.undoBtn),c.appendChild(m),c.appendChild(q),this.toolbar.appendChild(s),this.toolbar.appendChild(h),this.toolbar.appendChild(c),this.container.appendChild(n),this.container.appendChild(o),this.container.appendChild(i),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),g(this.opts.dataUrl).then(l=>{this.img=l,this.canvas.width=l.naturalWidth||l.width||1,this.canvas.height=l.naturalHeight||l.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/(e.width||this.canvas.width),o=this.canvas.height/(e.height||this.canvas.height);return{x:(t.clientX-e.left)*n,y:(t.clientY-e.top)*o}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const e of this.shapes)p(t,e);this.current&&p(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(o=>{o.setAttribute("aria-pressed",o.getAttribute("data-qaid-tool")===t?"true":"false")});const n=this.labels[W[t]];this.opts.announce?.(`${n} tool selected`)}selectColor(t){this.color=t,this.toolbar.querySelectorAll("[data-qaid-color]").forEach(n=>{n.setAttribute("aria-pressed",(n.getAttribute("data-qaid-color")??"").toLowerCase()===t.toLowerCase()?"true":"false")}),this.opts.announce?.(`${b(t)} colour selected`)}onToolbarClick=t=>{const n=t.target?.closest("[data-qaid-tool],[data-qaid-action],[data-qaid-color]");if(!n)return;const o=n.getAttribute("data-qaid-color");if(o){this.selectColor(o);return}const i=n.getAttribute("data-qaid-tool");if(i){this.selectTool(i);return}const s=n.getAttribute("data-qaid-action");s==="undo"?this.undo():s==="skip"?this.skip():s==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const e=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[e]:[e,{...e}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const e=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(e):this.current.points[1]=e,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,S(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 w(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 W={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function z(a){return new v(a).open()}const $=I;export{v as AnnotationEditor,w as compositeAnnotations,p as drawShape,z as openAnnotationEditor,u as rectFromPoints,$ as styles};
2
- //# sourceMappingURL=annotate-DprzfPKF.js.map
1
+ import{c as r,i as f,R as y,A as k,P as x,B as C,U as E,S as A,b as L}from"./core-Cl_qkUzb.js";const I=".qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:var(--qaid-font-size, 16px);font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:calc(var(--qaid-font-size, 16px) * .8125);line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:calc(var(--qaid-font-size, 16px) * .8125);font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}.qaid-annotate-colors{display:flex;gap:.25rem;align-items:center}button.qaid-annotate-swatch{width:28px;height:28px;min-width:28px;padding:0;border-radius:9999px;border:2px solid light-dark(#d1d5db,#4b5563);background:var(--qaid-swatch, #000);cursor:pointer;-webkit-appearance:none;appearance:none;transition:transform .1s,box-shadow .15s,border-color .15s}button.qaid-annotate-swatch:hover{transform:scale(1.12)}button.qaid-annotate-swatch[aria-pressed=true]{border-color:light-dark(#111827,#f9fafb);box-shadow:0 0 0 2px var(--qaid-swatch)}@media(forced-colors:active){button.qaid-annotate-swatch[aria-pressed=true]{outline:2px solid Highlight;outline-offset:1px}}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6365f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6365f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6365f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}",d=12,B="#ef4444",T=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"],D={"#ef4444":"red","#f59e0b":"amber","#22c55e":"green","#3b82f6":"blue","#111827":"black","#ffffff":"white","#6365f1":"indigo","#6366f1":"indigo"};function b(a){return D[a.toLowerCase()]??a}const P=4,M=.8,R={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 u(a,t){return{x:Math.min(a.x,t.x),y:Math.min(a.y,t.y),w:Math.abs(a.x-t.x),h:Math.abs(a.y-t.y)}}function S(a){if(a.type==="pen")return a.points.length<2;const t=u(a.points[0],a.points[1]);return t.w<3&&t.h<3}function N(a,t,e,n){a.beginPath(),a.moveTo(t.x,t.y),a.lineTo(e.x,e.y),a.stroke();const o=Math.atan2(e.y-t.y,e.x-t.x),i=Math.max(10,n*3);a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(e.x-i*Math.cos(o-Math.PI/6),e.y-i*Math.sin(o-Math.PI/6)),a.moveTo(e.x,e.y),a.lineTo(e.x-i*Math.cos(o+Math.PI/6),e.y-i*Math.sin(o+Math.PI/6)),a.stroke()}function _(a,t){if(t.length!==0){a.beginPath(),a.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)a.lineTo(t[e].x,t[e].y);a.stroke()}}function U(a,t,e,n,o){a.fillStyle="rgb(15, 23, 42)",a.fillRect(t,e,n,o),a.fillStyle="rgb(37, 47, 63)";for(let i=e;i<e+o;i+=d)for(let s=t;s<t+n;s+=d)(Math.floor((s-t)/d)+Math.floor((i-e)/d))%2===0&&a.fillRect(s,i,Math.min(d,t+n-s),Math.min(d,e+o-i))}function p(a,t){switch(a.save(),a.strokeStyle=t.color,a.fillStyle=t.color,a.lineWidth=t.strokeWidth,a.lineJoin="round",a.lineCap="round",t.type){case"rect":{const e=u(t.points[0],t.points[1]);a.strokeRect(e.x,e.y,e.w,e.h);break}case"arrow":N(a,t.points[0],t.points[1],t.strokeWidth);break;case"pen":_(a,t.points);break;case"blur":{const e=u(t.points[0],t.points[1]);U(a,e.x,e.y,e.w,e.h);break}}a.restore()}function g(a){return new Promise((t,e)=>{const n=new Image;n.onload=()=>t(n),n.onerror=()=>e(new Error("Failed to load screenshot")),n.src=a})}async function w(a,t,e={}){const n=e.quality??M;let o;try{o=await g(a)}catch{return a}const i=document.createElement("canvas");i.width=o.naturalWidth||o.width||1,i.height=o.naturalHeight||o.height||1;const s=i.getContext("2d");if(!s)return a;s.drawImage(o,0,0,i.width,i.height);for(const h of t)p(s,h);return i.toDataURL("image/webp",n)}let O=0;class v{shapes=[];tool="rect";opts;labels;color;palette;strokeWidth;uid=`qaid-annotate-${++O}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...R,...t.labels??{}},this.color=t.color??B,this.palette=(t.palette&&t.palette.length?t.palette:T).slice(),this.palette.some(e=>e.toLowerCase()===this.color.toLowerCase())||this.palette.unshift(this.color),this.strokeWidth=t.strokeWidth??P}open(){const t=new Promise(e=>{this.resolveResult=e});return this.mount(),t}toolButton(t,e,n){const o=r("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${n} tool`,title:n});return o.append(f(null,e),r("span",{class:"qaid-annotate-btn-text"},[n])),o}swatchButton(t){const e=b(t),n=r("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 n.style.setProperty("--qaid-swatch",t),n}actionButton(t,e,n,o){const i=r("button",{type:"button",class:`qaid-annotate-action ${o}`,"data-qaid-action":t,"aria-label":n,title:n});return i.append(f(null,e),r("span",{class:"qaid-annotate-btn-text"},[n])),i}mount(){const t=`${this.uid}-title`,e=`${this.uid}-desc`;this.container=r("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const n=r("h2",{id:t,class:"qaid-annotate-title"});n.textContent=this.labels.title;const o=r("p",{id:e,class:"qaid-annotate-desc"});o.textContent=this.labels.instructions;const i=r("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"),i.appendChild(this.canvas),this.toolbar=r("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const s=r("div",{class:"qaid-annotate-tools"});s.appendChild(this.toolButton("rect",y,this.labels.rectangle)),s.appendChild(this.toolButton("arrow",k,this.labels.arrow)),s.appendChild(this.toolButton("pen",x,this.labels.pen)),s.appendChild(this.toolButton("blur",C,this.labels.blur));const h=r("div",{class:"qaid-annotate-colors",role:"group","aria-label":this.labels.colors});for(const l of this.palette)h.appendChild(this.swatchButton(l));this.undoBtn=this.actionButton("undo",E,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const m=this.actionButton("skip",A,this.labels.skip,"qaid-annotate-skip"),q=this.actionButton("done",L,this.labels.done,"qaid-annotate-done"),c=r("div",{class:"qaid-annotate-actions"});c.appendChild(this.undoBtn),c.appendChild(m),c.appendChild(q),this.toolbar.appendChild(s),this.toolbar.appendChild(h),this.toolbar.appendChild(c),this.container.appendChild(n),this.container.appendChild(o),this.container.appendChild(i),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),g(this.opts.dataUrl).then(l=>{this.img=l,this.canvas.width=l.naturalWidth||l.width||1,this.canvas.height=l.naturalHeight||l.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/(e.width||this.canvas.width),o=this.canvas.height/(e.height||this.canvas.height);return{x:(t.clientX-e.left)*n,y:(t.clientY-e.top)*o}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const e of this.shapes)p(t,e);this.current&&p(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(o=>{o.setAttribute("aria-pressed",o.getAttribute("data-qaid-tool")===t?"true":"false")});const n=this.labels[W[t]];this.opts.announce?.(`${n} tool selected`)}selectColor(t){this.color=t,this.toolbar.querySelectorAll("[data-qaid-color]").forEach(n=>{n.setAttribute("aria-pressed",(n.getAttribute("data-qaid-color")??"").toLowerCase()===t.toLowerCase()?"true":"false")}),this.opts.announce?.(`${b(t)} colour selected`)}onToolbarClick=t=>{const n=t.target?.closest("[data-qaid-tool],[data-qaid-action],[data-qaid-color]");if(!n)return;const o=n.getAttribute("data-qaid-color");if(o){this.selectColor(o);return}const i=n.getAttribute("data-qaid-tool");if(i){this.selectTool(i);return}const s=n.getAttribute("data-qaid-action");s==="undo"?this.undo():s==="skip"?this.skip():s==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const e=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[e]:[e,{...e}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const e=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(e):this.current.points[1]=e,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,S(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 w(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 W={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function z(a){return new v(a).open()}const $=I;export{v as AnnotationEditor,w as compositeAnnotations,p as drawShape,z as openAnnotationEditor,u as rectFromPoints,$ as styles};
2
+ //# sourceMappingURL=annotate-G6jz7v3f.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotate-DprzfPKF.js","sources":["../../src/annotate.ts"],"sourcesContent":["/**\n * Screenshot annotation / markup editor for the thumbs embed.\n *\n * After a screenshot is captured the user can draw on it — rectangles, arrows,\n * a freehand pen, and a blur/redact box — in a full-screen, focus-trapped,\n * WCAG 2.2 AA dialog rendered inside the embed's overlay shadow root. On \"Done\"\n * the base image and the vector shapes are composited into a fresh WebP data\n * URL (so downstream code is unchanged); on \"Skip\"/Escape the original is kept.\n *\n * The geometry and compositing are kept as pure-ish exported functions\n * (`drawShape`, `rectFromPoints`, `compositeAnnotations`) so they can be tested\n * without a real rendering engine — happy-dom has no raster, so tests assert on\n * spied canvas-context calls rather than pixels. The {@link AnnotationEditor}\n * controller keeps the DOM wiring thin and its interactive methods are public\n * so they can be driven directly in tests.\n */\n\nimport { createElement } from \"./dom-utils\";\nimport { iconNode } from \"./svg-sanitize\";\nimport featureStyles from \"./styles-annotate.css?inline\";\nimport {\n RECTANGLE_ICON,\n ARROW_ICON,\n PENCIL_ICON,\n BLUR_ICON,\n UNDO_ICON,\n DONE_ICON,\n SKIP_ICON,\n} from \"./icons\";\n\n/** The four drawing tools. */\nexport type ShapeType = \"rect\" | \"arrow\" | \"pen\" | \"blur\";\n\n/** A point in the screenshot's natural-pixel coordinate space. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * A single vector annotation. `rect`, `arrow` and `blur` use `points[0]` as the\n * drag start and `points[1]` as the drag end; `pen` uses every point in order.\n */\nexport interface Shape {\n type: ShapeType;\n color: string;\n strokeWidth: number;\n points: Point[];\n}\n\n/** Tile size (natural px) for the mosaic drawn by the blur/redact tool. */\nconst BLUR_TILE = 12;\n\n/** Default stroke colour: a high-visibility red that reads on most screenshots. */\nconst DEFAULT_STROKE = \"#ef4444\";\n/** Default swatch palette when the embed doesn't supply one. */\nconst DEFAULT_PALETTE = [\"#ef4444\", \"#f59e0b\", \"#22c55e\", \"#3b82f6\", \"#111827\", \"#ffffff\"];\n/** Friendly names for common swatches (for accessible labels). */\nconst COLOR_NAMES: Record<string, string> = {\n \"#ef4444\": \"red\",\n \"#f59e0b\": \"amber\",\n \"#22c55e\": \"green\",\n \"#3b82f6\": \"blue\",\n \"#111827\": \"black\",\n \"#ffffff\": \"white\",\n // The default marker (nudged from #6366f1 so white text on it clears 4.5:1);\n // the old value keeps its name for sites that pass it explicitly.\n \"#6365f1\": \"indigo\",\n \"#6366f1\": \"indigo\",\n};\n/** Accessible name for a swatch colour — a friendly name, else the hex. */\nfunction colorName(hex: string): string {\n return COLOR_NAMES[hex.toLowerCase()] ?? hex;\n}\n/** Default stroke width in natural pixels. */\nconst DEFAULT_STROKE_WIDTH = 4;\n/** Default WebP quality for the re-encoded composite. */\nconst DEFAULT_QUALITY = 0.8;\n\n/** Human-readable labels for the toolbar / announcements (all overridable). */\nexport interface AnnotationLabels {\n title: string;\n instructions: string;\n rectangle: string;\n arrow: string;\n pen: string;\n blur: string;\n undo: string;\n skip: string;\n done: string;\n colors: string;\n}\n\nconst DEFAULT_LABELS: AnnotationLabels = {\n title: \"Annotate screenshot\",\n instructions:\n \"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.\",\n rectangle: \"Rectangle\",\n arrow: \"Arrow\",\n pen: \"Pen\",\n blur: \"Blur or redact\",\n undo: \"Undo last\",\n skip: \"Skip annotation\",\n done: \"Done\",\n colors: \"Drawing colour\",\n};\n\n/**\n * Normalise two drag corners into a top-left origin plus positive width/height,\n * regardless of the direction the user dragged.\n */\nexport function rectFromPoints(\n a: Point,\n b: Point\n): { x: number; y: number; w: number; h: number } {\n return {\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n w: Math.abs(a.x - b.x),\n h: Math.abs(a.y - b.y),\n };\n}\n\n/** A drag/shape too small to be a deliberate mark (a click, not a drag). */\nfunction isDegenerate(shape: Shape): boolean {\n if (shape.type === \"pen\") return shape.points.length < 2;\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n return r.w < 3 && r.h < 3;\n}\n\nfunction drawArrow(\n ctx: CanvasRenderingContext2D,\n from: Point,\n to: Point,\n width: number\n): void {\n ctx.beginPath();\n ctx.moveTo(from.x, from.y);\n ctx.lineTo(to.x, to.y);\n ctx.stroke();\n\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const head = Math.max(10, width * 3);\n ctx.beginPath();\n ctx.moveTo(to.x, to.y);\n ctx.lineTo(\n to.x - head * Math.cos(angle - Math.PI / 6),\n to.y - head * Math.sin(angle - Math.PI / 6)\n );\n ctx.moveTo(to.x, to.y);\n ctx.lineTo(\n to.x - head * Math.cos(angle + Math.PI / 6),\n to.y - head * Math.sin(angle + Math.PI / 6)\n );\n ctx.stroke();\n}\n\nfunction drawPen(ctx: CanvasRenderingContext2D, points: Point[]): void {\n if (points.length === 0) return;\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.stroke();\n}\n\n/**\n * Redact a region so the underlying content is GONE from the composite — not\n * merely dimmed. Both fills are fully opaque (no alpha), so nothing bleeds\n * through; the two-tone mosaic just gives it a recognisable \"redacted\" texture.\n * There is no real Gaussian blur (it can't be verified without a raster), and a\n * translucent wash would leave sensitive text faintly legible — so this paints\n * solid.\n */\nfunction drawBlur(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number\n): void {\n ctx.fillStyle = \"rgb(15, 23, 42)\";\n ctx.fillRect(x, y, w, h);\n ctx.fillStyle = \"rgb(37, 47, 63)\";\n for (let ty = y; ty < y + h; ty += BLUR_TILE) {\n for (let tx = x; tx < x + w; tx += BLUR_TILE) {\n const checker =\n (Math.floor((tx - x) / BLUR_TILE) + Math.floor((ty - y) / BLUR_TILE)) %\n 2 ===\n 0;\n if (checker) {\n ctx.fillRect(\n tx,\n ty,\n Math.min(BLUR_TILE, x + w - tx),\n Math.min(BLUR_TILE, y + h - ty)\n );\n }\n }\n }\n}\n\n/**\n * Draw a single shape onto a 2D context in the shape's own (natural-pixel)\n * coordinates. Used both for the live editing preview and for the final\n * composite, so what the user sees is exactly what is submitted.\n */\nexport function drawShape(ctx: CanvasRenderingContext2D, shape: Shape): void {\n ctx.save();\n ctx.strokeStyle = shape.color;\n ctx.fillStyle = shape.color;\n ctx.lineWidth = shape.strokeWidth;\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n switch (shape.type) {\n case \"rect\": {\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n ctx.strokeRect(r.x, r.y, r.w, r.h);\n break;\n }\n case \"arrow\":\n drawArrow(ctx, shape.points[0], shape.points[1], shape.strokeWidth);\n break;\n case \"pen\":\n drawPen(ctx, shape.points);\n break;\n case \"blur\": {\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n drawBlur(ctx, r.x, r.y, r.w, r.h);\n break;\n }\n }\n\n ctx.restore();\n}\n\n/** Load an image from a data URL. Resolves with the element once decoded. */\nfunction loadImage(src: string): Promise<HTMLImageElement> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = (): void => resolve(img);\n img.onerror = (): void => reject(new Error(\"Failed to load screenshot\"));\n img.src = src;\n });\n}\n\n/**\n * Composite the base screenshot and the drawn shapes into a new WebP data URL\n * at the image's natural size. Falls back to the original data URL if the image\n * can't be loaded or a 2D context isn't available (so a submission is never\n * lost). This is intentionally standalone so it can be unit-tested in isolation.\n */\nexport async function compositeAnnotations(\n dataUrl: string,\n shapes: Shape[],\n opts: { quality?: number } = {}\n): Promise<string> {\n const quality = opts.quality ?? DEFAULT_QUALITY;\n\n let img: HTMLImageElement;\n try {\n img = await loadImage(dataUrl);\n } catch {\n return dataUrl;\n }\n\n const canvas = document.createElement(\"canvas\");\n canvas.width = img.naturalWidth || img.width || 1;\n canvas.height = img.naturalHeight || img.height || 1;\n\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return dataUrl;\n\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n for (const shape of shapes) {\n drawShape(ctx, shape);\n }\n\n return canvas.toDataURL(\"image/webp\", quality);\n}\n\n/** Options for {@link AnnotationEditor} / {@link openAnnotationEditor}. */\nexport interface AnnotationEditorOptions {\n /** The captured screenshot as a WebP data URL. */\n dataUrl: string;\n /** Shadow root (or element) the editor is mounted into. */\n root: ShadowRoot | HTMLElement;\n /** WebP quality for the re-encoded composite. */\n quality?: number;\n /** Default stroke colour for rectangle/arrow/pen. */\n color?: string;\n /** Colour swatches offered in the toolbar. The active `color` is ensured present. */\n palette?: string[];\n /** Default stroke width. */\n strokeWidth?: number;\n /** Label overrides. */\n labels?: Partial<AnnotationLabels>;\n /** Apply the embed's per-instance `--qaid-*` CSS variables to the container. */\n applyVars?: (el: HTMLElement) => void;\n /** Announce a message via the embed's live regions. */\n announce?: (message: string, assertive?: boolean) => void;\n /** Turn the container into an accessible modal dialog (focus trap + inert). */\n openDialog?: (\n container: HTMLElement,\n opts: { labelledbyId?: string; describedbyId?: string }\n ) => void;\n /** Tear down the dialog semantics and restore focus. */\n closeDialog?: () => void;\n}\n\nlet editorSeq = 0;\n\n/**\n * Full-screen screenshot annotation editor. Construct it, call {@link open}\n * (which returns a promise resolving to the composited WebP, or `null` when the\n * user skips), and the controller manages its own DOM and teardown.\n */\nexport class AnnotationEditor {\n readonly shapes: Shape[] = [];\n tool: ShapeType = \"rect\";\n\n private readonly opts: AnnotationEditorOptions;\n private readonly labels: AnnotationLabels;\n private color: string;\n private readonly palette: string[];\n private readonly strokeWidth: number;\n private readonly uid = `qaid-annotate-${++editorSeq}`;\n\n private container!: HTMLDivElement;\n private canvas!: HTMLCanvasElement;\n private ctx: CanvasRenderingContext2D | null = null;\n private toolbar!: HTMLDivElement;\n private undoBtn!: HTMLButtonElement;\n private img: HTMLImageElement | null = null;\n\n private drawing = false;\n private current: Shape | null = null;\n private settled = false;\n // Assigned in open() before any settle() is reachable (done/skip only fire\n // after the editor is mounted).\n private resolveResult!: (value: string | null) => void;\n\n constructor(opts: AnnotationEditorOptions) {\n this.opts = opts;\n this.labels = { ...DEFAULT_LABELS, ...(opts.labels ?? {}) };\n this.color = opts.color ?? DEFAULT_STROKE;\n this.palette = (opts.palette && opts.palette.length ? opts.palette : DEFAULT_PALETTE).slice();\n // Ensure the active colour is offered as a swatch so it stays selectable.\n if (!this.palette.some((c) => c.toLowerCase() === this.color.toLowerCase())) {\n this.palette.unshift(this.color);\n }\n this.strokeWidth = opts.strokeWidth ?? DEFAULT_STROKE_WIDTH;\n }\n\n /** Mount the editor and resolve when the user commits (Done) or skips. */\n open(): Promise<string | null> {\n const promise = new Promise<string | null>((resolve) => {\n this.resolveResult = resolve;\n });\n this.mount();\n return promise;\n }\n\n private toolButton(tool: ShapeType, icon: string, label: string): HTMLButtonElement {\n const btn = createElement(\"button\", {\n type: \"button\",\n class: \"qaid-annotate-tool\",\n \"data-qaid-tool\": tool,\n \"aria-pressed\": tool === this.tool ? \"true\" : \"false\",\n \"aria-label\": `${label} tool`,\n title: label,\n });\n btn.append(\n iconNode(null, icon),\n createElement(\"span\", { class: \"qaid-annotate-btn-text\" }, [label])\n );\n return btn;\n }\n\n /** A round colour swatch button for the toolbar's colour group. */\n private swatchButton(color: string): HTMLButtonElement {\n const name = colorName(color);\n const btn = createElement(\"button\", {\n type: \"button\",\n class: \"qaid-annotate-swatch\",\n \"data-qaid-color\": color,\n \"aria-pressed\": color.toLowerCase() === this.color.toLowerCase() ? \"true\" : \"false\",\n \"aria-label\": `Draw in ${name}`,\n title: name,\n });\n btn.style.setProperty(\"--qaid-swatch\", color);\n return btn;\n }\n\n private actionButton(\n action: string,\n icon: string,\n label: string,\n extraClass: string\n ): HTMLButtonElement {\n const btn = createElement(\"button\", {\n type: \"button\",\n class: `qaid-annotate-action ${extraClass}`,\n \"data-qaid-action\": action,\n \"aria-label\": label,\n title: label,\n });\n btn.append(\n iconNode(null, icon),\n createElement(\"span\", { class: \"qaid-annotate-btn-text\" }, [label])\n );\n return btn;\n }\n\n private mount(): void {\n const titleId = `${this.uid}-title`;\n const descId = `${this.uid}-desc`;\n\n this.container = createElement(\"div\", { class: \"qaid-annotate\" });\n this.opts.applyVars?.(this.container);\n\n const title = createElement(\"h2\", {\n id: titleId,\n class: \"qaid-annotate-title\",\n });\n title.textContent = this.labels.title;\n\n const desc = createElement(\"p\", {\n id: descId,\n class: \"qaid-annotate-desc\",\n });\n desc.textContent = this.labels.instructions;\n\n const stage = createElement(\"div\", { class: \"qaid-annotate-stage\" });\n this.canvas = document.createElement(\"canvas\");\n this.canvas.className = \"qaid-annotate-canvas\";\n this.canvas.width = 1;\n this.canvas.height = 1;\n this.canvas.setAttribute(\"role\", \"img\");\n this.canvas.setAttribute(\"aria-label\", this.labels.title);\n this.ctx = this.canvas.getContext(\"2d\");\n stage.appendChild(this.canvas);\n\n this.toolbar = createElement(\"div\", {\n class: \"qaid-annotate-toolbar\",\n role: \"toolbar\",\n \"aria-label\": this.labels.title,\n });\n\n const tools = createElement(\"div\", { class: \"qaid-annotate-tools\" });\n tools.appendChild(this.toolButton(\"rect\", RECTANGLE_ICON, this.labels.rectangle));\n tools.appendChild(this.toolButton(\"arrow\", ARROW_ICON, this.labels.arrow));\n tools.appendChild(this.toolButton(\"pen\", PENCIL_ICON, this.labels.pen));\n tools.appendChild(this.toolButton(\"blur\", BLUR_ICON, this.labels.blur));\n\n const colors = createElement(\"div\", {\n class: \"qaid-annotate-colors\",\n role: \"group\",\n \"aria-label\": this.labels.colors,\n });\n for (const c of this.palette) colors.appendChild(this.swatchButton(c));\n\n this.undoBtn = this.actionButton(\"undo\", UNDO_ICON, this.labels.undo, \"qaid-annotate-undo\");\n this.undoBtn.disabled = true;\n\n const skipBtn = this.actionButton(\"skip\", SKIP_ICON, this.labels.skip, \"qaid-annotate-skip\");\n const doneBtn = this.actionButton(\"done\", DONE_ICON, this.labels.done, \"qaid-annotate-done\");\n\n const actions = createElement(\"div\", { class: \"qaid-annotate-actions\" });\n actions.appendChild(this.undoBtn);\n actions.appendChild(skipBtn);\n actions.appendChild(doneBtn);\n\n this.toolbar.appendChild(tools);\n this.toolbar.appendChild(colors);\n this.toolbar.appendChild(actions);\n\n this.container.appendChild(title);\n this.container.appendChild(desc);\n this.container.appendChild(stage);\n this.container.appendChild(this.toolbar);\n this.opts.root.appendChild(this.container);\n\n this.toolbar.addEventListener(\"click\", this.onToolbarClick);\n this.canvas.addEventListener(\"pointerdown\", this.onPointerDown);\n this.container.addEventListener(\"pointermove\", this.onPointerMove);\n this.container.addEventListener(\"pointerup\", this.onPointerUp);\n this.container.addEventListener(\"keydown\", this.onKeyDown);\n\n this.opts.openDialog?.(this.container, {\n labelledbyId: titleId,\n describedbyId: descId,\n });\n this.opts.announce?.(this.labels.instructions);\n\n loadImage(this.opts.dataUrl)\n .then((img) => {\n this.img = img;\n this.canvas.width = img.naturalWidth || img.width || 1;\n this.canvas.height = img.naturalHeight || img.height || 1;\n this.redraw();\n })\n .catch(() => {\n this.img = null;\n this.redraw();\n });\n }\n\n /** Convert a pointer event's client coordinates into natural image pixels. */\n private toImageCoords(e: { clientX: number; clientY: number }): Point {\n const rect = this.canvas.getBoundingClientRect();\n const scaleX = this.canvas.width / (rect.width || this.canvas.width);\n const scaleY = this.canvas.height / (rect.height || this.canvas.height);\n return {\n x: (e.clientX - rect.left) * scaleX,\n y: (e.clientY - rect.top) * scaleY,\n };\n }\n\n /** Repaint the display canvas: base image (if loaded) then every shape. */\n redraw(): void {\n const ctx = this.ctx;\n if (!ctx) return;\n ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n if (this.img) {\n ctx.drawImage(this.img, 0, 0, this.canvas.width, this.canvas.height);\n }\n for (const shape of this.shapes) {\n drawShape(ctx, shape);\n }\n if (this.current) {\n drawShape(ctx, this.current);\n }\n }\n\n /** Select the active drawing tool and reflect it on the toolbar. */\n selectTool(tool: ShapeType): void {\n this.tool = tool;\n const buttons = this.toolbar.querySelectorAll<HTMLButtonElement>(\"[data-qaid-tool]\");\n buttons.forEach((btn) => {\n btn.setAttribute(\n \"aria-pressed\",\n btn.getAttribute(\"data-qaid-tool\") === tool ? \"true\" : \"false\"\n );\n });\n const label = this.labels[LABEL_KEY[tool]];\n this.opts.announce?.(`${label} tool selected`);\n }\n\n /** Set the active drawing colour; subsequent shapes use it. */\n selectColor(color: string): void {\n this.color = color;\n const swatches = this.toolbar.querySelectorAll<HTMLButtonElement>(\"[data-qaid-color]\");\n swatches.forEach((s) => {\n s.setAttribute(\n \"aria-pressed\",\n (s.getAttribute(\"data-qaid-color\") ?? \"\").toLowerCase() === color.toLowerCase()\n ? \"true\"\n : \"false\"\n );\n });\n this.opts.announce?.(`${colorName(color)} colour selected`);\n }\n\n private onToolbarClick = (e: Event): void => {\n const target = e.target as HTMLElement | null;\n const btn = target?.closest<HTMLElement>(\n \"[data-qaid-tool],[data-qaid-action],[data-qaid-color]\"\n );\n if (!btn) return;\n const color = btn.getAttribute(\"data-qaid-color\");\n if (color) {\n this.selectColor(color);\n return;\n }\n const tool = btn.getAttribute(\"data-qaid-tool\");\n if (tool) {\n this.selectTool(tool as ShapeType);\n return;\n }\n const action = btn.getAttribute(\"data-qaid-action\");\n if (action === \"undo\") this.undo();\n else if (action === \"skip\") this.skip();\n else if (action === \"done\") void this.done();\n };\n\n onPointerDown = (e: PointerEvent): void => {\n e.preventDefault?.();\n this.drawing = true;\n const p = this.toImageCoords(e);\n this.current = {\n type: this.tool,\n color: this.color,\n strokeWidth: this.strokeWidth,\n points: this.tool === \"pen\" ? [p] : [p, { ...p }],\n };\n this.redraw();\n };\n\n onPointerMove = (e: PointerEvent): void => {\n if (!this.drawing || !this.current) return;\n const p = this.toImageCoords(e);\n if (this.current.type === \"pen\") {\n this.current.points.push(p);\n } else {\n this.current.points[1] = p;\n }\n this.redraw();\n };\n\n onPointerUp = (): void => {\n if (!this.drawing || !this.current) return;\n this.drawing = false;\n const shape = this.current;\n this.current = null;\n if (isDegenerate(shape)) {\n this.redraw();\n return;\n }\n this.shapes.push(shape);\n this.undoBtn.disabled = false;\n this.opts.announce?.(\"Annotation added\");\n this.redraw();\n };\n\n onKeyDown = (e: KeyboardEvent): void => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this.skip();\n return;\n }\n if (e.key === \"Enter\") {\n const target = e.target as HTMLElement | null;\n // Let Enter activate a focused tool/action button natively.\n if (target?.getAttribute(\"data-qaid-tool\") || target?.getAttribute(\"data-qaid-action\")) {\n return;\n }\n e.preventDefault();\n void this.done();\n }\n };\n\n /** Remove the most recently added shape. */\n undo(): void {\n if (this.shapes.length === 0) {\n this.opts.announce?.(\"Nothing to undo\");\n return;\n }\n this.shapes.pop();\n this.undoBtn.disabled = this.shapes.length === 0;\n this.opts.announce?.(\"Removed last annotation\");\n this.redraw();\n }\n\n /** Composite the annotations and resolve with the new WebP data URL. */\n async done(): Promise<void> {\n if (this.settled) return;\n const out = await compositeAnnotations(this.opts.dataUrl, this.shapes, {\n quality: this.opts.quality,\n });\n this.opts.announce?.(\"Annotated screenshot attached\");\n this.settle(out);\n }\n\n /** Discard annotations and resolve with `null` (caller keeps the original). */\n skip(): void {\n if (this.settled) return;\n this.opts.announce?.(\"Annotation skipped\");\n this.settle(null);\n }\n\n private settle(value: string | null): void {\n this.settled = true;\n this.teardown();\n this.resolveResult(value);\n }\n\n private teardown(): void {\n this.toolbar.removeEventListener(\"click\", this.onToolbarClick);\n this.canvas.removeEventListener(\"pointerdown\", this.onPointerDown);\n this.container.removeEventListener(\"pointermove\", this.onPointerMove);\n this.container.removeEventListener(\"pointerup\", this.onPointerUp);\n this.container.removeEventListener(\"keydown\", this.onKeyDown);\n this.opts.closeDialog?.();\n this.container.remove();\n }\n}\n\n/** Maps a tool id to its label key, for announcements. */\nconst LABEL_KEY: Record<ShapeType, keyof AnnotationLabels> = {\n rect: \"rectangle\",\n arrow: \"arrow\",\n pen: \"pen\",\n blur: \"blur\",\n};\n\n/**\n * Open the annotation editor and resolve with the composited WebP data URL, or\n * `null` if the user skipped. Thin entry point used by the embed.\n */\nexport function openAnnotationEditor(\n opts: AnnotationEditorOptions\n): Promise<string | null> {\n return new AnnotationEditor(opts).open();\n}\n\n/** This feature's shadow-DOM styles; the embed adds them when it loads the chunk. */\nexport const styles = featureStyles;\n"],"names":["BLUR_TILE","DEFAULT_STROKE","DEFAULT_PALETTE","COLOR_NAMES","colorName","hex","DEFAULT_STROKE_WIDTH","DEFAULT_QUALITY","DEFAULT_LABELS","rectFromPoints","b","isDegenerate","shape","r","drawArrow","ctx","from","to","width","angle","head","drawPen","points","i","drawBlur","x","y","w","h","ty","tx","drawShape","loadImage","src","resolve","reject","img","compositeAnnotations","dataUrl","shapes","opts","quality","canvas","editorSeq","AnnotationEditor","c","promise","tool","icon","label","btn","createElement","iconNode","color","name","action","extraClass","titleId","descId","title","desc","stage","tools","RECTANGLE_ICON","ARROW_ICON","PENCIL_ICON","BLUR_ICON","colors","UNDO_ICON","skipBtn","SKIP_ICON","doneBtn","DONE_ICON","actions","e","rect","scaleX","scaleY","LABEL_KEY","s","p","target","out","value","openAnnotationEditor","styles","featureStyles"],"mappings":"gzGAmDMA,EAAY,GAGZC,EAAiB,UAEjBC,EAAkB,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,SAAS,EAEnFC,EAAsC,CAC1C,UAAW,MACX,UAAW,QACX,UAAW,QACX,UAAW,OACX,UAAW,QACX,UAAW,QAGX,UAAW,SACX,UAAW,QACb,EAEA,SAASC,EAAUC,EAAqB,CACtC,OAAOF,EAAYE,EAAI,YAAA,CAAa,GAAKA,CAC3C,CAEA,MAAMC,EAAuB,EAEvBC,EAAkB,GAgBlBC,EAAmC,CACvC,MAAO,sBACP,aACE,mHACF,UAAW,YACX,MAAO,QACP,IAAK,MACL,KAAM,iBACN,KAAM,YACN,KAAM,kBACN,KAAM,OACN,OAAQ,gBACV,EAMO,SAASC,EACd,EACAC,EACgD,CAChD,MAAO,CACL,EAAG,KAAK,IAAI,EAAE,EAAGA,EAAE,CAAC,EACpB,EAAG,KAAK,IAAI,EAAE,EAAGA,EAAE,CAAC,EACpB,EAAG,KAAK,IAAI,EAAE,EAAIA,EAAE,CAAC,EACrB,EAAG,KAAK,IAAI,EAAE,EAAIA,EAAE,CAAC,CAAA,CAEzB,CAGA,SAASC,EAAaC,EAAuB,CAC3C,GAAIA,EAAM,OAAS,MAAO,OAAOA,EAAM,OAAO,OAAS,EACvD,MAAMC,EAAIJ,EAAeG,EAAM,OAAO,CAAC,EAAGA,EAAM,OAAO,CAAC,CAAC,EACz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,kBAAkB,EACnF,OAEFP,EAAE,eAAA,EACG,KAAK,KAAA,CACZ,CACF,EAGA,MAAa,CACX,GAAI,KAAK,OAAO,SAAW,EAAG,CAC5B,KAAK,KAAK,WAAW,iBAAiB,EACtC,MACF,CACA,KAAK,OAAO,IAAA,EACZ,KAAK,QAAQ,SAAW,KAAK,OAAO,SAAW,EAC/C,KAAK,KAAK,WAAW,yBAAyB,EAC9C,KAAK,OAAA,CACP,CAGA,MAAM,MAAsB,CAC1B,GAAI,KAAK,QAAS,OAClB,MAAMQ,EAAM,MAAM7C,EAAqB,KAAK,KAAK,QAAS,KAAK,OAAQ,CACrE,QAAS,KAAK,KAAK,OAAA,CACpB,EACD,KAAK,KAAK,WAAW,+BAA+B,EACpD,KAAK,OAAO6C,CAAG,CACjB,CAGA,MAAa,CACP,KAAK,UACT,KAAK,KAAK,WAAW,oBAAoB,EACzC,KAAK,OAAO,IAAI,EAClB,CAEQ,OAAOC,EAA4B,CACzC,KAAK,QAAU,GACf,KAAK,SAAA,EACL,KAAK,cAAcA,CAAK,CAC1B,CAEQ,UAAiB,CACvB,KAAK,QAAQ,oBAAoB,QAAS,KAAK,cAAc,EAC7D,KAAK,OAAO,oBAAoB,cAAe,KAAK,aAAa,EACjE,KAAK,UAAU,oBAAoB,cAAe,KAAK,aAAa,EACpE,KAAK,UAAU,oBAAoB,YAAa,KAAK,WAAW,EAChE,KAAK,UAAU,oBAAoB,UAAW,KAAK,SAAS,EAC5D,KAAK,KAAK,cAAA,EACV,KAAK,UAAU,OAAA,CACjB,CACF,CAGA,MAAML,EAAuD,CAC3D,KAAM,YACN,MAAO,QACP,IAAK,MACL,KAAM,MACR,EAMO,SAASM,EACd5C,EACwB,CACxB,OAAO,IAAII,EAAiBJ,CAAI,EAAE,KAAA,CACpC,CAGO,MAAM6C,EAASC"}
1
+ {"version":3,"file":"annotate-G6jz7v3f.js","sources":["../../src/annotate.ts"],"sourcesContent":["/**\n * Screenshot annotation / markup editor for the thumbs embed.\n *\n * After a screenshot is captured the user can draw on it — rectangles, arrows,\n * a freehand pen, and a blur/redact box — in a full-screen, focus-trapped,\n * WCAG 2.2 AA dialog rendered inside the embed's overlay shadow root. On \"Done\"\n * the base image and the vector shapes are composited into a fresh WebP data\n * URL (so downstream code is unchanged); on \"Skip\"/Escape the original is kept.\n *\n * The geometry and compositing are kept as pure-ish exported functions\n * (`drawShape`, `rectFromPoints`, `compositeAnnotations`) so they can be tested\n * without a real rendering engine — happy-dom has no raster, so tests assert on\n * spied canvas-context calls rather than pixels. The {@link AnnotationEditor}\n * controller keeps the DOM wiring thin and its interactive methods are public\n * so they can be driven directly in tests.\n */\n\nimport { createElement } from \"./dom-utils\";\nimport { iconNode } from \"./svg-sanitize\";\nimport featureStyles from \"./styles-annotate.css?inline\";\nimport {\n RECTANGLE_ICON,\n ARROW_ICON,\n PENCIL_ICON,\n BLUR_ICON,\n UNDO_ICON,\n DONE_ICON,\n SKIP_ICON,\n} from \"./icons\";\n\n/** The four drawing tools. */\nexport type ShapeType = \"rect\" | \"arrow\" | \"pen\" | \"blur\";\n\n/** A point in the screenshot's natural-pixel coordinate space. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * A single vector annotation. `rect`, `arrow` and `blur` use `points[0]` as the\n * drag start and `points[1]` as the drag end; `pen` uses every point in order.\n */\nexport interface Shape {\n type: ShapeType;\n color: string;\n strokeWidth: number;\n points: Point[];\n}\n\n/** Tile size (natural px) for the mosaic drawn by the blur/redact tool. */\nconst BLUR_TILE = 12;\n\n/** Default stroke colour: a high-visibility red that reads on most screenshots. */\nconst DEFAULT_STROKE = \"#ef4444\";\n/** Default swatch palette when the embed doesn't supply one. */\nconst DEFAULT_PALETTE = [\"#ef4444\", \"#f59e0b\", \"#22c55e\", \"#3b82f6\", \"#111827\", \"#ffffff\"];\n/** Friendly names for common swatches (for accessible labels). */\nconst COLOR_NAMES: Record<string, string> = {\n \"#ef4444\": \"red\",\n \"#f59e0b\": \"amber\",\n \"#22c55e\": \"green\",\n \"#3b82f6\": \"blue\",\n \"#111827\": \"black\",\n \"#ffffff\": \"white\",\n // The default marker (nudged from #6366f1 so white text on it clears 4.5:1);\n // the old value keeps its name for sites that pass it explicitly.\n \"#6365f1\": \"indigo\",\n \"#6366f1\": \"indigo\",\n};\n/** Accessible name for a swatch colour — a friendly name, else the hex. */\nfunction colorName(hex: string): string {\n return COLOR_NAMES[hex.toLowerCase()] ?? hex;\n}\n/** Default stroke width in natural pixels. */\nconst DEFAULT_STROKE_WIDTH = 4;\n/** Default WebP quality for the re-encoded composite. */\nconst DEFAULT_QUALITY = 0.8;\n\n/** Human-readable labels for the toolbar / announcements (all overridable). */\nexport interface AnnotationLabels {\n title: string;\n instructions: string;\n rectangle: string;\n arrow: string;\n pen: string;\n blur: string;\n undo: string;\n skip: string;\n done: string;\n colors: string;\n}\n\nconst DEFAULT_LABELS: AnnotationLabels = {\n title: \"Annotate screenshot\",\n instructions:\n \"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.\",\n rectangle: \"Rectangle\",\n arrow: \"Arrow\",\n pen: \"Pen\",\n blur: \"Blur or redact\",\n undo: \"Undo last\",\n skip: \"Skip annotation\",\n done: \"Done\",\n colors: \"Drawing colour\",\n};\n\n/**\n * Normalise two drag corners into a top-left origin plus positive width/height,\n * regardless of the direction the user dragged.\n */\nexport function rectFromPoints(\n a: Point,\n b: Point\n): { x: number; y: number; w: number; h: number } {\n return {\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n w: Math.abs(a.x - b.x),\n h: Math.abs(a.y - b.y),\n };\n}\n\n/** A drag/shape too small to be a deliberate mark (a click, not a drag). */\nfunction isDegenerate(shape: Shape): boolean {\n if (shape.type === \"pen\") return shape.points.length < 2;\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n return r.w < 3 && r.h < 3;\n}\n\nfunction drawArrow(\n ctx: CanvasRenderingContext2D,\n from: Point,\n to: Point,\n width: number\n): void {\n ctx.beginPath();\n ctx.moveTo(from.x, from.y);\n ctx.lineTo(to.x, to.y);\n ctx.stroke();\n\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const head = Math.max(10, width * 3);\n ctx.beginPath();\n ctx.moveTo(to.x, to.y);\n ctx.lineTo(\n to.x - head * Math.cos(angle - Math.PI / 6),\n to.y - head * Math.sin(angle - Math.PI / 6)\n );\n ctx.moveTo(to.x, to.y);\n ctx.lineTo(\n to.x - head * Math.cos(angle + Math.PI / 6),\n to.y - head * Math.sin(angle + Math.PI / 6)\n );\n ctx.stroke();\n}\n\nfunction drawPen(ctx: CanvasRenderingContext2D, points: Point[]): void {\n if (points.length === 0) return;\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.stroke();\n}\n\n/**\n * Redact a region so the underlying content is GONE from the composite — not\n * merely dimmed. Both fills are fully opaque (no alpha), so nothing bleeds\n * through; the two-tone mosaic just gives it a recognisable \"redacted\" texture.\n * There is no real Gaussian blur (it can't be verified without a raster), and a\n * translucent wash would leave sensitive text faintly legible — so this paints\n * solid.\n */\nfunction drawBlur(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number\n): void {\n ctx.fillStyle = \"rgb(15, 23, 42)\";\n ctx.fillRect(x, y, w, h);\n ctx.fillStyle = \"rgb(37, 47, 63)\";\n for (let ty = y; ty < y + h; ty += BLUR_TILE) {\n for (let tx = x; tx < x + w; tx += BLUR_TILE) {\n const checker =\n (Math.floor((tx - x) / BLUR_TILE) + Math.floor((ty - y) / BLUR_TILE)) %\n 2 ===\n 0;\n if (checker) {\n ctx.fillRect(\n tx,\n ty,\n Math.min(BLUR_TILE, x + w - tx),\n Math.min(BLUR_TILE, y + h - ty)\n );\n }\n }\n }\n}\n\n/**\n * Draw a single shape onto a 2D context in the shape's own (natural-pixel)\n * coordinates. Used both for the live editing preview and for the final\n * composite, so what the user sees is exactly what is submitted.\n */\nexport function drawShape(ctx: CanvasRenderingContext2D, shape: Shape): void {\n ctx.save();\n ctx.strokeStyle = shape.color;\n ctx.fillStyle = shape.color;\n ctx.lineWidth = shape.strokeWidth;\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n switch (shape.type) {\n case \"rect\": {\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n ctx.strokeRect(r.x, r.y, r.w, r.h);\n break;\n }\n case \"arrow\":\n drawArrow(ctx, shape.points[0], shape.points[1], shape.strokeWidth);\n break;\n case \"pen\":\n drawPen(ctx, shape.points);\n break;\n case \"blur\": {\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n drawBlur(ctx, r.x, r.y, r.w, r.h);\n break;\n }\n }\n\n ctx.restore();\n}\n\n/** Load an image from a data URL. Resolves with the element once decoded. */\nfunction loadImage(src: string): Promise<HTMLImageElement> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = (): void => resolve(img);\n img.onerror = (): void => reject(new Error(\"Failed to load screenshot\"));\n img.src = src;\n });\n}\n\n/**\n * Composite the base screenshot and the drawn shapes into a new WebP data URL\n * at the image's natural size. Falls back to the original data URL if the image\n * can't be loaded or a 2D context isn't available (so a submission is never\n * lost). This is intentionally standalone so it can be unit-tested in isolation.\n */\nexport async function compositeAnnotations(\n dataUrl: string,\n shapes: Shape[],\n opts: { quality?: number } = {}\n): Promise<string> {\n const quality = opts.quality ?? DEFAULT_QUALITY;\n\n let img: HTMLImageElement;\n try {\n img = await loadImage(dataUrl);\n } catch {\n return dataUrl;\n }\n\n const canvas = document.createElement(\"canvas\");\n canvas.width = img.naturalWidth || img.width || 1;\n canvas.height = img.naturalHeight || img.height || 1;\n\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return dataUrl;\n\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n for (const shape of shapes) {\n drawShape(ctx, shape);\n }\n\n return canvas.toDataURL(\"image/webp\", quality);\n}\n\n/** Options for {@link AnnotationEditor} / {@link openAnnotationEditor}. */\nexport interface AnnotationEditorOptions {\n /** The captured screenshot as a WebP data URL. */\n dataUrl: string;\n /** Shadow root (or element) the editor is mounted into. */\n root: ShadowRoot | HTMLElement;\n /** WebP quality for the re-encoded composite. */\n quality?: number;\n /** Default stroke colour for rectangle/arrow/pen. */\n color?: string;\n /** Colour swatches offered in the toolbar. The active `color` is ensured present. */\n palette?: string[];\n /** Default stroke width. */\n strokeWidth?: number;\n /** Label overrides. */\n labels?: Partial<AnnotationLabels>;\n /** Apply the embed's per-instance `--qaid-*` CSS variables to the container. */\n applyVars?: (el: HTMLElement) => void;\n /** Announce a message via the embed's live regions. */\n announce?: (message: string, assertive?: boolean) => void;\n /** Turn the container into an accessible modal dialog (focus trap + inert). */\n openDialog?: (\n container: HTMLElement,\n opts: { labelledbyId?: string; describedbyId?: string }\n ) => void;\n /** Tear down the dialog semantics and restore focus. */\n closeDialog?: () => void;\n}\n\nlet editorSeq = 0;\n\n/**\n * Full-screen screenshot annotation editor. Construct it, call {@link open}\n * (which returns a promise resolving to the composited WebP, or `null` when the\n * user skips), and the controller manages its own DOM and teardown.\n */\nexport class AnnotationEditor {\n readonly shapes: Shape[] = [];\n tool: ShapeType = \"rect\";\n\n private readonly opts: AnnotationEditorOptions;\n private readonly labels: AnnotationLabels;\n private color: string;\n private readonly palette: string[];\n private readonly strokeWidth: number;\n private readonly uid = `qaid-annotate-${++editorSeq}`;\n\n private container!: HTMLDivElement;\n private canvas!: HTMLCanvasElement;\n private ctx: CanvasRenderingContext2D | null = null;\n private toolbar!: HTMLDivElement;\n private undoBtn!: HTMLButtonElement;\n private img: HTMLImageElement | null = null;\n\n private drawing = false;\n private current: Shape | null = null;\n private settled = false;\n // Assigned in open() before any settle() is reachable (done/skip only fire\n // after the editor is mounted).\n private resolveResult!: (value: string | null) => void;\n\n constructor(opts: AnnotationEditorOptions) {\n this.opts = opts;\n this.labels = { ...DEFAULT_LABELS, ...(opts.labels ?? {}) };\n this.color = opts.color ?? DEFAULT_STROKE;\n this.palette = (opts.palette && opts.palette.length ? opts.palette : DEFAULT_PALETTE).slice();\n // Ensure the active colour is offered as a swatch so it stays selectable.\n if (!this.palette.some((c) => c.toLowerCase() === this.color.toLowerCase())) {\n this.palette.unshift(this.color);\n }\n this.strokeWidth = opts.strokeWidth ?? DEFAULT_STROKE_WIDTH;\n }\n\n /** Mount the editor and resolve when the user commits (Done) or skips. */\n open(): Promise<string | null> {\n const promise = new Promise<string | null>((resolve) => {\n this.resolveResult = resolve;\n });\n this.mount();\n return promise;\n }\n\n private toolButton(tool: ShapeType, icon: string, label: string): HTMLButtonElement {\n const btn = createElement(\"button\", {\n type: \"button\",\n class: \"qaid-annotate-tool\",\n \"data-qaid-tool\": tool,\n \"aria-pressed\": tool === this.tool ? \"true\" : \"false\",\n \"aria-label\": `${label} tool`,\n title: label,\n });\n btn.append(\n iconNode(null, icon),\n createElement(\"span\", { class: \"qaid-annotate-btn-text\" }, [label])\n );\n return btn;\n }\n\n /** A round colour swatch button for the toolbar's colour group. */\n private swatchButton(color: string): HTMLButtonElement {\n const name = colorName(color);\n const btn = createElement(\"button\", {\n type: \"button\",\n class: \"qaid-annotate-swatch\",\n \"data-qaid-color\": color,\n \"aria-pressed\": color.toLowerCase() === this.color.toLowerCase() ? \"true\" : \"false\",\n \"aria-label\": `Draw in ${name}`,\n title: name,\n });\n btn.style.setProperty(\"--qaid-swatch\", color);\n return btn;\n }\n\n private actionButton(\n action: string,\n icon: string,\n label: string,\n extraClass: string\n ): HTMLButtonElement {\n const btn = createElement(\"button\", {\n type: \"button\",\n class: `qaid-annotate-action ${extraClass}`,\n \"data-qaid-action\": action,\n \"aria-label\": label,\n title: label,\n });\n btn.append(\n iconNode(null, icon),\n createElement(\"span\", { class: \"qaid-annotate-btn-text\" }, [label])\n );\n return btn;\n }\n\n private mount(): void {\n const titleId = `${this.uid}-title`;\n const descId = `${this.uid}-desc`;\n\n this.container = createElement(\"div\", { class: \"qaid-annotate\" });\n this.opts.applyVars?.(this.container);\n\n const title = createElement(\"h2\", {\n id: titleId,\n class: \"qaid-annotate-title\",\n });\n title.textContent = this.labels.title;\n\n const desc = createElement(\"p\", {\n id: descId,\n class: \"qaid-annotate-desc\",\n });\n desc.textContent = this.labels.instructions;\n\n const stage = createElement(\"div\", { class: \"qaid-annotate-stage\" });\n this.canvas = document.createElement(\"canvas\");\n this.canvas.className = \"qaid-annotate-canvas\";\n this.canvas.width = 1;\n this.canvas.height = 1;\n this.canvas.setAttribute(\"role\", \"img\");\n this.canvas.setAttribute(\"aria-label\", this.labels.title);\n this.ctx = this.canvas.getContext(\"2d\");\n stage.appendChild(this.canvas);\n\n this.toolbar = createElement(\"div\", {\n class: \"qaid-annotate-toolbar\",\n role: \"toolbar\",\n \"aria-label\": this.labels.title,\n });\n\n const tools = createElement(\"div\", { class: \"qaid-annotate-tools\" });\n tools.appendChild(this.toolButton(\"rect\", RECTANGLE_ICON, this.labels.rectangle));\n tools.appendChild(this.toolButton(\"arrow\", ARROW_ICON, this.labels.arrow));\n tools.appendChild(this.toolButton(\"pen\", PENCIL_ICON, this.labels.pen));\n tools.appendChild(this.toolButton(\"blur\", BLUR_ICON, this.labels.blur));\n\n const colors = createElement(\"div\", {\n class: \"qaid-annotate-colors\",\n role: \"group\",\n \"aria-label\": this.labels.colors,\n });\n for (const c of this.palette) colors.appendChild(this.swatchButton(c));\n\n this.undoBtn = this.actionButton(\"undo\", UNDO_ICON, this.labels.undo, \"qaid-annotate-undo\");\n this.undoBtn.disabled = true;\n\n const skipBtn = this.actionButton(\"skip\", SKIP_ICON, this.labels.skip, \"qaid-annotate-skip\");\n const doneBtn = this.actionButton(\"done\", DONE_ICON, this.labels.done, \"qaid-annotate-done\");\n\n const actions = createElement(\"div\", { class: \"qaid-annotate-actions\" });\n actions.appendChild(this.undoBtn);\n actions.appendChild(skipBtn);\n actions.appendChild(doneBtn);\n\n this.toolbar.appendChild(tools);\n this.toolbar.appendChild(colors);\n this.toolbar.appendChild(actions);\n\n this.container.appendChild(title);\n this.container.appendChild(desc);\n this.container.appendChild(stage);\n this.container.appendChild(this.toolbar);\n this.opts.root.appendChild(this.container);\n\n this.toolbar.addEventListener(\"click\", this.onToolbarClick);\n this.canvas.addEventListener(\"pointerdown\", this.onPointerDown);\n this.container.addEventListener(\"pointermove\", this.onPointerMove);\n this.container.addEventListener(\"pointerup\", this.onPointerUp);\n this.container.addEventListener(\"keydown\", this.onKeyDown);\n\n this.opts.openDialog?.(this.container, {\n labelledbyId: titleId,\n describedbyId: descId,\n });\n this.opts.announce?.(this.labels.instructions);\n\n loadImage(this.opts.dataUrl)\n .then((img) => {\n this.img = img;\n this.canvas.width = img.naturalWidth || img.width || 1;\n this.canvas.height = img.naturalHeight || img.height || 1;\n this.redraw();\n })\n .catch(() => {\n this.img = null;\n this.redraw();\n });\n }\n\n /** Convert a pointer event's client coordinates into natural image pixels. */\n private toImageCoords(e: { clientX: number; clientY: number }): Point {\n const rect = this.canvas.getBoundingClientRect();\n const scaleX = this.canvas.width / (rect.width || this.canvas.width);\n const scaleY = this.canvas.height / (rect.height || this.canvas.height);\n return {\n x: (e.clientX - rect.left) * scaleX,\n y: (e.clientY - rect.top) * scaleY,\n };\n }\n\n /** Repaint the display canvas: base image (if loaded) then every shape. */\n redraw(): void {\n const ctx = this.ctx;\n if (!ctx) return;\n ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n if (this.img) {\n ctx.drawImage(this.img, 0, 0, this.canvas.width, this.canvas.height);\n }\n for (const shape of this.shapes) {\n drawShape(ctx, shape);\n }\n if (this.current) {\n drawShape(ctx, this.current);\n }\n }\n\n /** Select the active drawing tool and reflect it on the toolbar. */\n selectTool(tool: ShapeType): void {\n this.tool = tool;\n const buttons = this.toolbar.querySelectorAll<HTMLButtonElement>(\"[data-qaid-tool]\");\n buttons.forEach((btn) => {\n btn.setAttribute(\n \"aria-pressed\",\n btn.getAttribute(\"data-qaid-tool\") === tool ? \"true\" : \"false\"\n );\n });\n const label = this.labels[LABEL_KEY[tool]];\n this.opts.announce?.(`${label} tool selected`);\n }\n\n /** Set the active drawing colour; subsequent shapes use it. */\n selectColor(color: string): void {\n this.color = color;\n const swatches = this.toolbar.querySelectorAll<HTMLButtonElement>(\"[data-qaid-color]\");\n swatches.forEach((s) => {\n s.setAttribute(\n \"aria-pressed\",\n (s.getAttribute(\"data-qaid-color\") ?? \"\").toLowerCase() === color.toLowerCase()\n ? \"true\"\n : \"false\"\n );\n });\n this.opts.announce?.(`${colorName(color)} colour selected`);\n }\n\n private onToolbarClick = (e: Event): void => {\n const target = e.target as HTMLElement | null;\n const btn = target?.closest<HTMLElement>(\n \"[data-qaid-tool],[data-qaid-action],[data-qaid-color]\"\n );\n if (!btn) return;\n const color = btn.getAttribute(\"data-qaid-color\");\n if (color) {\n this.selectColor(color);\n return;\n }\n const tool = btn.getAttribute(\"data-qaid-tool\");\n if (tool) {\n this.selectTool(tool as ShapeType);\n return;\n }\n const action = btn.getAttribute(\"data-qaid-action\");\n if (action === \"undo\") this.undo();\n else if (action === \"skip\") this.skip();\n else if (action === \"done\") void this.done();\n };\n\n onPointerDown = (e: PointerEvent): void => {\n e.preventDefault?.();\n this.drawing = true;\n const p = this.toImageCoords(e);\n this.current = {\n type: this.tool,\n color: this.color,\n strokeWidth: this.strokeWidth,\n points: this.tool === \"pen\" ? [p] : [p, { ...p }],\n };\n this.redraw();\n };\n\n onPointerMove = (e: PointerEvent): void => {\n if (!this.drawing || !this.current) return;\n const p = this.toImageCoords(e);\n if (this.current.type === \"pen\") {\n this.current.points.push(p);\n } else {\n this.current.points[1] = p;\n }\n this.redraw();\n };\n\n onPointerUp = (): void => {\n if (!this.drawing || !this.current) return;\n this.drawing = false;\n const shape = this.current;\n this.current = null;\n if (isDegenerate(shape)) {\n this.redraw();\n return;\n }\n this.shapes.push(shape);\n this.undoBtn.disabled = false;\n this.opts.announce?.(\"Annotation added\");\n this.redraw();\n };\n\n onKeyDown = (e: KeyboardEvent): void => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this.skip();\n return;\n }\n if (e.key === \"Enter\") {\n const target = e.target as HTMLElement | null;\n // Let Enter activate a focused tool/action button natively.\n if (target?.getAttribute(\"data-qaid-tool\") || target?.getAttribute(\"data-qaid-action\")) {\n return;\n }\n e.preventDefault();\n void this.done();\n }\n };\n\n /** Remove the most recently added shape. */\n undo(): void {\n if (this.shapes.length === 0) {\n this.opts.announce?.(\"Nothing to undo\");\n return;\n }\n this.shapes.pop();\n this.undoBtn.disabled = this.shapes.length === 0;\n this.opts.announce?.(\"Removed last annotation\");\n this.redraw();\n }\n\n /** Composite the annotations and resolve with the new WebP data URL. */\n async done(): Promise<void> {\n if (this.settled) return;\n const out = await compositeAnnotations(this.opts.dataUrl, this.shapes, {\n quality: this.opts.quality,\n });\n this.opts.announce?.(\"Annotated screenshot attached\");\n this.settle(out);\n }\n\n /** Discard annotations and resolve with `null` (caller keeps the original). */\n skip(): void {\n if (this.settled) return;\n this.opts.announce?.(\"Annotation skipped\");\n this.settle(null);\n }\n\n private settle(value: string | null): void {\n this.settled = true;\n this.teardown();\n this.resolveResult(value);\n }\n\n private teardown(): void {\n this.toolbar.removeEventListener(\"click\", this.onToolbarClick);\n this.canvas.removeEventListener(\"pointerdown\", this.onPointerDown);\n this.container.removeEventListener(\"pointermove\", this.onPointerMove);\n this.container.removeEventListener(\"pointerup\", this.onPointerUp);\n this.container.removeEventListener(\"keydown\", this.onKeyDown);\n this.opts.closeDialog?.();\n this.container.remove();\n }\n}\n\n/** Maps a tool id to its label key, for announcements. */\nconst LABEL_KEY: Record<ShapeType, keyof AnnotationLabels> = {\n rect: \"rectangle\",\n arrow: \"arrow\",\n pen: \"pen\",\n blur: \"blur\",\n};\n\n/**\n * Open the annotation editor and resolve with the composited WebP data URL, or\n * `null` if the user skipped. Thin entry point used by the embed.\n */\nexport function openAnnotationEditor(\n opts: AnnotationEditorOptions\n): Promise<string | null> {\n return new AnnotationEditor(opts).open();\n}\n\n/** This feature's shadow-DOM styles; the embed adds them when it loads the chunk. */\nexport const styles = featureStyles;\n"],"names":["BLUR_TILE","DEFAULT_STROKE","DEFAULT_PALETTE","COLOR_NAMES","colorName","hex","DEFAULT_STROKE_WIDTH","DEFAULT_QUALITY","DEFAULT_LABELS","rectFromPoints","b","isDegenerate","shape","r","drawArrow","ctx","from","to","width","angle","head","drawPen","points","i","drawBlur","x","y","w","h","ty","tx","drawShape","loadImage","src","resolve","reject","img","compositeAnnotations","dataUrl","shapes","opts","quality","canvas","editorSeq","AnnotationEditor","c","promise","tool","icon","label","btn","createElement","iconNode","color","name","action","extraClass","titleId","descId","title","desc","stage","tools","RECTANGLE_ICON","ARROW_ICON","PENCIL_ICON","BLUR_ICON","colors","UNDO_ICON","skipBtn","SKIP_ICON","doneBtn","DONE_ICON","actions","e","rect","scaleX","scaleY","LABEL_KEY","s","p","target","out","value","openAnnotationEditor","styles","featureStyles"],"mappings":"gzGAmDMA,EAAY,GAGZC,EAAiB,UAEjBC,EAAkB,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,SAAS,EAEnFC,EAAsC,CAC1C,UAAW,MACX,UAAW,QACX,UAAW,QACX,UAAW,OACX,UAAW,QACX,UAAW,QAGX,UAAW,SACX,UAAW,QACb,EAEA,SAASC,EAAUC,EAAqB,CACtC,OAAOF,EAAYE,EAAI,YAAA,CAAa,GAAKA,CAC3C,CAEA,MAAMC,EAAuB,EAEvBC,EAAkB,GAgBlBC,EAAmC,CACvC,MAAO,sBACP,aACE,mHACF,UAAW,YACX,MAAO,QACP,IAAK,MACL,KAAM,iBACN,KAAM,YACN,KAAM,kBACN,KAAM,OACN,OAAQ,gBACV,EAMO,SAASC,EACd,EACAC,EACgD,CAChD,MAAO,CACL,EAAG,KAAK,IAAI,EAAE,EAAGA,EAAE,CAAC,EACpB,EAAG,KAAK,IAAI,EAAE,EAAGA,EAAE,CAAC,EACpB,EAAG,KAAK,IAAI,EAAE,EAAIA,EAAE,CAAC,EACrB,EAAG,KAAK,IAAI,EAAE,EAAIA,EAAE,CAAC,CAAA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xB,OAAO,IAAII,EAAiBJ,CAAI,EAAE,KAAA,CACpC,CAGO,MAAM6C,EAASC"}
@@ -0,0 +1,26 @@
1
+ const it=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5"/>
3
+ </svg>`,nt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
4
+ <path stroke-linecap="round" stroke-linejoin="round" d="M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.737 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.095c.5 0 .905-.405.905-.905 0-.714.211-1.412.608-2.006L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5"/>
5
+ </svg>`,le=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
6
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z"/>
7
+ </svg>`,st=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
8
+ <path stroke-linecap="round" stroke-linejoin="round" d="M8 10h8M8 14h5m-9 6l3.5-3.5H18a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v14z"/>
9
+ </svg>`,ce='<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>',ue=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
10
+ <rect x="4" y="6" width="16" height="12" rx="1" stroke-linejoin="round"/>
11
+ </svg>`,he=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
12
+ <path stroke-linecap="round" stroke-linejoin="round" d="M5 19L19 5m0 0h-8m8 0v8"/>
13
+ </svg>`,fe=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
14
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 20h9M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/>
15
+ </svg>`,pe=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
16
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 3s6 6.4 6 10a6 6 0 01-12 0c0-3.6 6-10 6-10z"/>
17
+ </svg>`,me=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
18
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 14L4 9l5-5M4 9h11a5 5 0 010 10h-4"/>
19
+ </svg>`,be=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
20
+ <path stroke-linecap="round" stroke-linejoin="round" d="M20 6L9 17l-5-5"/>
21
+ </svg>`,ge=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
22
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 6v8m0 4h.01"/>
23
+ </svg>`,ve=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
24
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6L6 18"/>
25
+ </svg>`,ye="http://www.w3.org/2000/svg",rt={};for(const t of["svg","g","path","circle","ellipse","rect","line","polyline","polygon","title","desc","defs","linearGradient","radialGradient","stop","clipPath"])rt[t.toLowerCase()]=t;const at={};for(const t of["viewBox","width","height","preserveAspectRatio","version","fill","fill-rule","fill-opacity","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","stroke-opacity","clip-rule","clip-path","clipPathUnits","opacity","vector-effect","shape-rendering","d","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","fx","fy","transform","class","id","offset","stop-color","stop-opacity","gradientUnits","gradientTransform","spreadMethod","aria-hidden","aria-label","focusable","role"])at[t.toLowerCase()]=t;const we=new Set(["title","desc"]),dt=5e4,ke=1e3,Ce={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",nbsp:"\xA0"};function lt(t){return t.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi,(e,o)=>{if(o[0]==="#"){const i=o[1]==="x"||o[1]==="X"?parseInt(o.slice(2),16):parseInt(o.slice(1),10);return i>0&&i<=1114111?String.fromCodePoint(i):""}return Ce[o.toLowerCase()]??e})}const ct=/url\(\s*(['"]?)#[A-Za-z_][\w.:-]*\1\s*\)/gi;function Se(t,e){const o=e.replace(/[\u0000- \u007f-\u009f]+/g,"").toLowerCase();if(/(java|vb)script:|data:|expression\(/.test(o))return!1;const i=e.replace(ct,"");return/url\(/.test(i.replace(/[\u0000- \u007f-\u009f]+/g,"").toLowerCase())?!1:t==="clip-path"?/^\s*none\s*$/i.test(e)||new RegExp(`^\\s*${ct.source}\\s*$`,"i").test(e):!0}function ut(t){if(typeof t!="string"||typeof document>"u")return null;const e=t.trim();if(!e||e.length>dt)return null;let o=null,i=!1,s=0;const r=[];let n=0;const l=()=>r[r.length-1];for(;n<e.length&&!i;){const h=e.indexOf("<",n),g=h===-1?e.length:h;if(g>n){const u=e.slice(n,g),b=l();if(b?.node&&we.has(b.name))b.node.appendChild(document.createTextNode(lt(u)));else if(!b&&u.trim())return null}if(h===-1)break;if(n=h,e.startsWith("<!--",n)){const u=e.indexOf("-->",n+4);if(u===-1)return null;n=u+3;continue}if(e.startsWith("<?",n)){if(o)return null;const u=e.indexOf("?>",n+2);if(u===-1)return null;n=u+2;continue}if(e.startsWith("<!",n))return null;if(e[n+1]==="/"){const u=/^<\/\s*([A-Za-z][\w:.-]*)\s*>/.exec(e.slice(n,n+200));if(!u)return null;n+=u[0].length;const b=u[1].toLowerCase(),y=r.map(w=>w.name).lastIndexOf(b);y!==-1&&(r.length=y,y===0&&(i=!0));continue}const d=/^<([A-Za-z][\w:.-]*)/.exec(e.slice(n,n+200));if(!d)return null;const f=d[1].toLowerCase();n+=d[0].length;const p=[];let v=!1,S=!1;for(;n<e.length;){const u=/^\s*/.exec(e.slice(n,n+1e3))[0];if(n+=u.length,e.startsWith("/>",n)){v=!0,S=!0,n+=2;break}if(e[n]===">"){S=!0,n+=1;break}const b=/^([^\s=/>"'<]+)/.exec(e.slice(n,n+200));if(!b)return null;const y=b[1];n+=y.length;let w="";const E=/^\s*=\s*/.exec(e.slice(n,n+1e3));if(E){n+=E[0].length;const x=e[n];if(x==='"'||x==="'"){const q=e.indexOf(x,n+1);if(q===-1)return null;w=e.slice(n+1,q),n=q+1}else{const q=/^[^\s>]+/.exec(e.slice(n,n+dt));if(!q)return null;w=q[0],w.endsWith("/")&&e[n+w.length]===">"&&(w=w.slice(0,-1)),n+=w.length}}p.push([y,lt(w)])}if(!S||++s>ke)return null;const k=l();if(k){if(!k.node){v||r.push({name:f,node:null});continue}}else if(o||f!=="svg")return null;const c=rt[f];if(!c){v||r.push({name:f,node:null});continue}const m=document.createElementNS(ye,c);for(const[u,b]of p){const y=at[u.toLowerCase()];y&&Se(y,b)&&m.setAttribute(y,b)}k?k.node.appendChild(m):o=m,v?k||(i=!0):r.push({name:f,node:m})}return o}function ht(t,e){return(t?ut(t):null)??ut(e)}function A(t,e,o){t.textContent="",t.appendChild(ht(e,o))}const qe="button{cursor:pointer}.qaid-buttons{display:flex;gap:.5rem}.qaid-buttons.qaid-vertical{flex-direction:column}.qaid-buttons.qaid-auto-container{position:fixed;z-index:50}.qaid-buttons.qaid-auto-container.qaid-bottom-right{bottom:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-bottom-left{bottom:1rem;left:1rem}.qaid-buttons.qaid-auto-container.qaid-top-right{top:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-top-left{top:1rem;left:1rem}.qaid-buttons.qaid-incognito{opacity:0;transition:opacity .2s ease-in-out}.qaid-buttons.qaid-incognito:hover{opacity:1}.qaid-buttons.qaid-dismissed{display:none!important}.qaid-dismiss-btn{width:20px;height:20px;padding:0;border:none;border-radius:50%;background:#0006;color:#fff;display:flex;align-items:center;justify-content:center;align-self:center;opacity:0;transition:opacity .15s,background .15s;cursor:pointer;pointer-events:auto;-webkit-appearance:none;appearance:none}.qaid-dismiss-btn:hover{background:#0009}.qaid-buttons:hover .qaid-dismiss-btn{opacity:1}button.qaid-btn-structural{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;-webkit-appearance:none;appearance:none}.qaid-icon{width:24px;height:24px}:where(button.qaid-btn-structural)>svg:where(:not(.qaid-icon):not([width])){width:var(--qaid-icon-size, 24px);height:var(--qaid-icon-size, 24px)}.qaid-btn-structural:not(:has(svg)),.qaid-btn:not(:has(svg)){font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-emoji-icon{font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-buttons,.qaid-buttons *,.qaid-modal-container,.qaid-modal-container *{cursor:pointer!important}.qaid-tooltip-wrapper{position:relative}.qaid-tooltip-text{position:fixed;padding:.5rem .75rem;background:#1f2937;color:#fff;font-size:var(--qaid-font-size, 16px);font-weight:600;border-radius:.5rem;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s;z-index:99999}.qaid-tooltip-text.qaid-tooltip-visible{opacity:1}button.qaid-btn-record:hover{background:#dc2626;color:#fff}button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid var(--qaid-marker, #6365f1);outline-offset:2px}.qaid-buttons.qaid-incognito:focus-within{opacity:1}.qaid-buttons:focus-within .qaid-dismiss-btn,.qaid-dismiss-btn:focus-visible{opacity:1}.qaid-dismiss-btn{min-width:24px;min-height:24px}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}@media(forced-colors:active){button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid CanvasText;outline-offset:2px}}",xe="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let T=0;const Ae="button.qaid-btn{width:var(--qaid-btn-size);height:var(--qaid-btn-size);border-radius:50%;border:none;background:#f3f4f6;color:#374151;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);transition:background-color .2s,color .2s,transform .2s;-webkit-appearance:none;appearance:none;--qaid-hover-up-bg:var(--qaid-positive);--qaid-hover-up-color:#fff;--qaid-hover-down-bg:var(--qaid-negative);--qaid-hover-down-color:#fff}button.qaid-btn:hover{transform:scale(1.05)}button.qaid-btn-up:hover{background:var(--qaid-hover-up-bg);color:var(--qaid-hover-up-color)}button.qaid-btn-down:hover{background:var(--qaid-hover-down-bg);color:var(--qaid-hover-down-color)}button.qaid-btn-feedback:hover{background:var(--qaid-marker,#6365f1);color:var(--qaid-marker-text,#fff)}button.qaid-btn svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",Ee={small:36,medium:48,large:64},Te={small:18,medium:24,large:32};function Ie(t,e,o){const[i,s,r]=[t,e,o].map(n=>(n=n/255,n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)));return .2126*i+.7152*s+.0722*r}function Le(t){if(t.startsWith("#")){const o=t.slice(1),i=o.length===3?o.split("").map(r=>r+r).join(""):o,s=parseInt(i,16);return{r:s>>16&255,g:s>>8&255,b:s&255}}const e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return e?{r:parseInt(e[1]),g:parseInt(e[2]),b:parseInt(e[3])}:null}function De(t){const e=Le(t);return e&&Ie(e.r,e.g,e.b)>.4?"black":"white"}function Me(t={}){const{positiveColor:e="rgb(0, 200, 83)",negativeColor:o="rgb(255, 0, 0)",markerColor:i="#6365f1",buttonSize:s="medium",modalWidth:r=400,backdropOpacity:n=.3,fontFamily:l="system-ui, -apple-system, sans-serif",fontSize:h=16}=t,g=Ee[s],d=Te[s],a=De(i);return{"--qaid-positive":e,"--qaid-negative":o,"--qaid-marker":i,"--qaid-marker-text":a,"--qaid-btn-size":`${g}px`,"--qaid-icon-size":`${d}px`,"--qaid-modal-width":`${r}px`,"--qaid-backdrop-opacity":String(n),"--qaid-font-family":l,"--qaid-font-size":`${h}px`}}function Oe(t,e){for(const[o,i]of Object.entries(e))t.style.setProperty(o,i)}function ft(){return qe+Ae}function Re(){if(T++,T>1)return;const t=document.createElement("style");t.id="qaid-styles",t.textContent=xe,document.head.appendChild(t)}function Be(){T<=0||(T--,T===0&&document.getElementById("qaid-styles")?.remove())}const pt="data-qaid-a11y-live",He="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;";function _e(t){return t.ownerDocument||document}function Pe(t,e){const o=e?"assertive":"polite",i=t.querySelector(`[${pt}="${o}"]`);if(i)return i;const r=_e(t).createElement("div");return r.setAttribute(pt,o),r.setAttribute("role",e?"alert":"status"),r.setAttribute("aria-live",e?"assertive":"polite"),r.setAttribute("aria-atomic","true"),r.style.cssText=He,t.appendChild(r),r}function Ne(t,e,o={}){const i=Pe(t,!!o.assertive);i.textContent="",i.textContent=e}function ze(t,e,o,i={}){const s=i.gap??8;let r=t.bottom+s;r+e.height>o.height-s&&(r=t.top-e.height-s);let n=t.left;return n<s?n=s:n+e.width>o.width-s&&(n=o.width-e.width-s),r<s?r=s:r+e.height>o.height-s&&(r=o.height-e.height-s),{top:r,left:n}}const C="[redacted]",mt=1e3,N=/login|log-in|signin|sign-in|signup|sign-up|auth|token|password|passwd|session|oauth|2fa|mfa|credential/i,Ue=/token|key|secret|pass(word|wd)?|pwd|code|sess|auth|sig|otp|jwt|credential|ticket|nonce|state/i,bt="(?:password|passwd|pwd|pass|secret|token|access_token|refresh_token|id_token|api[_-]?key|apikey|client_secret|private[_-]?key|session(?:id)?|auth(?:orization)?|cookie|set-cookie|otp|pin|cvv|cvc|ssn)",$e=[[/\b(Bearer|Basic|Token|Digest)\s+[A-Za-z0-9._~+/=-]{8,}/gi,(t,e)=>`${e} ${C}`],[/\beyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}(?:\.[A-Za-z0-9_-]*)?/g,C],[new RegExp(`(["']?${bt}["']?\\s*:\\s*)(["'])(?:\\\\.|(?!\\2).)*\\2`,"gi"),(t,e,o)=>`${e}${o}${C}${o}`],[new RegExp(`(\\b${bt}\\s*[=:]\\s*)(?!["'\\s]|(?:Bearer|Basic|Token|Digest)\\s|\\[redacted\\])[^\\s&;,"'}]+`,"gi"),(t,e)=>`${e}${C}`],[/\b\d(?:[ -]?\d){12,18}\b/g,t=>je(t.replace(/\D/g,""))?C:t],[/\b[A-Fa-f0-9]{32,}\b/g,C],[/[A-Za-z0-9_+-]{32,}={0,2}/g,t=>/\d/.test(t)&&/[a-z]/.test(t)&&/[A-Z]/.test(t)?C:t]];function je(t){let e=0;for(let o=0;o<t.length;o++){let i=Number(t[t.length-1-o]);o%2===1&&(i*=2,i>9&&(i-=9)),e+=i}return e%10===0}function L(t){let e=t;for(const[o,i]of $e)e=e.replace(o,i);return e}function gt(t,e){return t.length>e?`${t.slice(0,e)}\u2026[truncated]`:t}function Fe(t){return gt(L(t.slice(0,mt*2)),mt)}function vt(t){let e=!1;for(const o of Array.from(new Set(t.keys())))Ue.test(o)&&(t.set(o,C),e=!0);return e}function D(t){let e;const o="https://qaid.invalid";try{e=new URL(t,o)}catch{return L(t)}if(e.username="",e.password="",vt(e.searchParams)&&(e.search=e.search.replace(/%5Bredacted%5D/g,C)),e.hash.includes("=")){const r=new URLSearchParams(e.hash.slice(1));vt(r)&&(e.hash=r.toString().replace(/%5Bredacted%5D/g,C))}const i=e.href;return!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!t.startsWith("//")&&i.startsWith(o)?i.slice(o.length):i}function Ve(t){try{const e=new URL(t,"https://qaid.invalid");return N.test(e.hostname)||N.test(e.pathname)}catch{return N.test(t)}}function Ke(t,e,o){if(o!==void 0)return e===401||e===403||Ve(t)?C:L(o)}const We=20;function Qe(t){const e=[],o=console.error,i=console.warn,s=console.log,r=(n,l)=>{const h={message:Fe(l.map(g=>String(g)).join(" ")),timestamp:Date.now(),level:n};e.length>=We&&e.shift(),e.push(h),t&&t(h)};return console.error=function(...n){r("error",n),o.apply(console,n)},console.warn=function(...n){r("warn",n),i.apply(console,n)},console.log=function(...n){r("log",n),s.apply(console,n)},{errors:e,restore:()=>{console.error=o,console.warn=i,console.log=s}}}const Ye=50,Xe=3,yt=25,Ge=2e3,wt=2e3,kt=8e3,Ct="qaid_session_id";function Je(t){try{let e=sessionStorage.getItem(Ct);return e||(e=t(),sessionStorage.setItem(Ct,e)),e}catch{return t()}}function St(t){if(t instanceof Error)return{message:t.message||String(t),errorType:t.name,stack:t.stack};if(typeof t=="string")return{message:t};try{return{message:JSON.stringify(t)??String(t)}}catch{return{message:String(t)}}}function M(t,e){return t?gt(L(t.slice(0,e*2)),e):void 0}function Ze(t){const e={flush(){},stop(){}},o=t.sampleRate??1;if(typeof window>"u"||Math.random()>=o)return e;const i=[],s=new Map;let r=0,n=!1,l=!1,h=null;const g=(c,m)=>{const u=JSON.stringify({apiKey:t.apiKey,sessionId:t.sessionId,visitorId:t.visitorId,release:t.release,environment:t.environment,pageUrl:D(window.location.href),events:c});try{if(m&&typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(t.endpoint,new Blob([u],{type:"text/plain"})))return;fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"text/plain"},body:u,keepalive:!0,credentials:"omit"}).then(b=>{(b.status===401||b.status===403||b.status===410)&&(l=!0)}).catch(()=>{})}catch{}},d=c=>{for(h&&(clearTimeout(h),h=null);i.length&&!l;)g(i.splice(0,yt),c);i.length=0},a=c=>{if(n||l||r>=Ye)return;const m=`${c.kind}|${c.message}|${c.file??""}|${c.line??0}`,u=s.get(m)??0;u>=Xe||(s.set(m,u+1),r++,i.push(c),i.length>=yt?d(!1):h||(h=setTimeout(()=>d(!1),Ge)))},f=()=>({occurredAt:new Date().toISOString(),pageUrl:D(window.location.href)}),p=c=>{try{if(!c.message&&!c.error)return;const m=St(c.error??c.message);a({kind:"error",message:M(m.message||c.message,wt)??"Unknown error",errorType:m.errorType,stack:M(m.stack,kt),file:c.filename?D(c.filename):void 0,line:c.lineno||void 0,column:c.colno||void 0,...f()})}catch{}},v=c=>{try{const m=St(c.reason);a({kind:"unhandledrejection",message:M(m.message,wt)??"Unhandled rejection",errorType:m.errorType,stack:M(m.stack,kt),...f()})}catch{}},S=()=>d(!0),k=()=>{document.visibilityState==="hidden"&&d(!0)};return window.addEventListener("error",p),window.addEventListener("unhandledrejection",v),window.addEventListener("pagehide",S),document.addEventListener("visibilitychange",k),{flush:()=>d(!1),stop:()=>{n||(n=!0,window.removeEventListener("error",p),window.removeEventListener("unhandledrejection",v),window.removeEventListener("pagehide",S),document.removeEventListener("visibilitychange",k),d(!0))}}}function to(t,e,o){const i=document.createElement(t);if(e)for(const[s,r]of Object.entries(e))s==="className"?i.className=r:i.setAttribute(s,r);if(o)for(const s of o)typeof s=="string"?i.appendChild(document.createTextNode(s)):i.appendChild(s);return i}function eo(t=640){return typeof window<"u"&&window.innerWidth<t}function oo(t,e,o){const i=o.map(r=>r.style.visibility);o.forEach(r=>r.style.visibility="hidden");const s=document.elementFromPoint(t,e);return o.forEach((r,n)=>r.style.visibility=i[n]),s}function io(t){return t?t.hasAttribute("data-qaid-embed")||t.hasAttribute("data-qaid-embed-overlay")?!0:!!t.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function no(t,e=0){const o=t.getBoundingClientRect();return{x:o.left-e,y:o.top-e,width:o.width+e*2,height:o.height+e*2}}const so="1.12.1",I=`https://unpkg.com/@qaiddev/quests-embed@${so}/dist/qaid-quests.js`,ro="sha384-ulTEyFqoUl1HNdNL8rFOB/mSItoy12PPegqJJIspDm0WtPK4/2jl3bRVrHoEtrm1",ao=/^https:\/\/unpkg\.com\/@qaiddev\/quests-embed@\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?\//;let qt=!1;function lo(t){if(!t)return I;if(t===I)return t;try{const e=typeof location<"u"?location.href:void 0,o=new URL(t,e);if(ao.test(o.href)&&!/%2e|%2f|%5c/i.test(o.pathname)||e&&o.origin===new URL(e).origin&&(o.protocol==="https:"||o.protocol==="http:"))return o.href}catch{}return qt||(qt=!0,console.warn(`[thumbs-embed] Ignoring quests moduleUrl "${t}": use a same-origin URL or https://unpkg.com/@qaiddev/quests-embed@<exact version>/\u2026. Using ${I}.`)),I}const co=3e3,uo={buttonClass:"string",direction:["horizontal","vertical"],position:["bottom-right","bottom-left","top-right","top-left"],zIndex:"number",skipTargeting:"boolean",singleButton:"boolean",feedbackMode:["target","annotate"],buttonSize:["small","medium","large"],hideConfirmation:"boolean",modalWidth:"number",backdropOpacity:"number",fontFamily:"string",fontSize:"number",captureScreenshot:"boolean",annotate:"boolean",annotationColor:"string",captureVideo:"boolean",recordIcon:"string",incognito:"boolean",hideDismiss:"boolean",positiveIcon:"string",negativeIcon:"string",feedbackIcon:"string",hideThumbs:"boolean",css:"string",screenshotMethod:["dom","permission"]},xt={offset:{x:"number",y:"number"},colors:{positive:"string",negative:"string",marker:"string"},text:"strings",videoOptions:{maxDuration:"number",redaction:"boolean"},screenshotOptions:{quality:"number",maxWidth:"number",maxHeight:"number"},quests:{base:"string",up:"string",down:"string",video:"string"}},ho=new Set(["positiveIcon","negativeIcon","css","buttonClass","colors","buttonSize","text"]),O=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function At(t,e){return Array.isArray(e)?typeof t=="string"&&e.includes(t):e==="number"?typeof t=="number"&&Number.isFinite(t):typeof t===e}function fo(t,e){if(!O(t))return;const o={};for(const[i,s]of Object.entries(t))(e==="strings"?typeof s=="string":i in e&&At(s,e[i]))&&(o[i]=s);return Object.keys(o).length>0?o:void 0}function po(t,e){try{const o=typeof location<"u"?location.href:void 0;return new URL(t,o).origin===new URL(e,o).origin}catch{return!1}}function Et(t,e){if(!O(t))return{};const o={};for(const[r,n]of Object.entries(uo))At(t[r],n)&&(o[r]=t[r]);for(const[r,n]of Object.entries(xt)){const l=fo(t[r],n);l&&(o[r]=l)}const i=t.annotationPalette;Array.isArray(i)&&i.length>0&&i.every(r=>typeof r=="string"&&r.trim())&&(o.annotationPalette=i);const s=o.quests;return s?.base&&!po(s.base,e)&&(console.warn("[thumbs-embed] Ignoring a fetched quest base on another origin than the endpoint."),delete o.quests),o}function mo(t,e){const o=Et(t,e);return Object.fromEntries(Object.entries(o).filter(([i])=>ho.has(i)))}function bo(...t){const e={};for(const o of t)if(o){for(const[i,s]of Object.entries(o))if(s!==void 0)if(i in xt&&O(s)){const n={...O(e[i])?e[i]:{}};for(const[l,h]of Object.entries(s))h!==void 0&&(n[l]=h);e[i]=n}else e[i]=s}return e}function go(t,e){return`${t.replace(/\/+$/,"")}/config?apiKey=${encodeURIComponent(e)}`}async function Tt(t,e,o){const i=typeof AbortController<"u"?new AbortController:null;let s;const r=new Promise((n,l)=>{s=setTimeout(()=>{i?.abort(),l(new Error(`timed out after ${e} ms`))},e)});try{const n=await Promise.race([fetch(t,{headers:{Accept:"application/json"},credentials:"omit",signal:i?.signal}),r]);return n.ok?await n.json():(console.warn(`[thumbs-embed] ${o} fetch failed (${n.status}); drawing without it.`),null)}catch(n){return console.warn(`[thumbs-embed] ${o} fetch error; drawing without it.`,n),null}finally{clearTimeout(s)}}function vo(t){return t.remoteConfig===!0||!!t.themeUrl}async function yo(t){const e=t.remoteTimeoutMs??co;let o=null;t.remoteConfig&&(t.apiKey?o=go(t.endpoint,t.apiKey):console.warn("[thumbs-embed] remoteConfig needs an apiKey; drawing without it."));const[i,s]=await Promise.all([o?Tt(o,e,"Project config"):null,t.themeUrl?Tt(t.themeUrl,e,"Theme"):null]);return bo(i?Et(i,t.endpoint):null,s?mo(s,t.endpoint):null,t)}const It="qaid_visitor_id",Lt="qaid_hide_feedback",wo=["#ef4444","#f59e0b","#22c55e","#3b82f6","#111827","#ffffff"];function ko(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function z(t){return t?`${Lt}_${t}`:Lt}function Co(t){try{return localStorage.getItem(z(t))==="1"}catch{return!1}}function Dt(t,e=!0){try{e?localStorage.setItem(z(t),"1"):localStorage.removeItem(z(t))}catch{}}function U(){const t=typeof crypto<"u"?crypto:void 0;if(t&&typeof t.randomUUID=="function")return t.randomUUID();const e=new Uint8Array(16);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(e);else for(let i=0;i<e.length;i++)e[i]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const o=Array.from(e,i=>i.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}function So(t){const e=t.replace(/\/+$/,"");if(/\/feedback$/.test(e))return e.replace(/\/feedback$/,"/errors");try{return new URL("/api/errors",t).href}catch{return"/api/errors"}}function qo(){try{let t=localStorage.getItem(It);return t||(t=U(),localStorage.setItem(It,t)),t}catch{return U()}}function Mt(t,e){const o=document.createElement("style");o.setAttribute("data-qaid-feature",""),o.textContent=e;const i=t.querySelectorAll("style[data-qaid-base], style[data-qaid-feature]"),s=i[i.length-1];t.insertBefore(o,s?s.nextSibling:t.firstChild)}function Ot(t){return{endpoint:t.endpoint,apiKey:t.apiKey??"",container:t.container??"",buttonClass:t.buttonClass??"",direction:t.direction??"horizontal",position:t.position??"bottom-right",offset:{x:t.offset?.x??16,y:t.offset?.y??16},zIndex:t.zIndex??50,skipTargeting:t.skipTargeting??!1,singleButton:t.singleButton??!1,feedbackMode:t.feedbackMode??"target",colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#6365f1"},buttonSize:t.buttonSize??"medium",text:{tooltip:t.text?.tooltip??"",modalTitle:t.text?.modalTitle??"Thank you for your feedback!",modalSubtitle:t.text?.modalSubtitle??"Would you like to add a message to help us understand your feedback better?",placeholder:t.text?.placeholder??"Optional: Tell us more about your experience...",submitButton:t.text?.submitButton??"Submit",skipButton:t.text?.skipButton??"Skip",positiveLabel:t.text?.positiveLabel??"Send positive feedback",negativeLabel:t.text?.negativeLabel??"Send negative feedback",recordLabel:t.text?.recordLabel??"Record a screen recording",dismissLabel:t.text?.dismissLabel??"Hide Feedback",feedbackLabel:t.text?.feedbackLabel??"Send feedback",confirmationTitle:t.text?.confirmationTitle??"Thank you!",confirmationMessage:t.text?.confirmationMessage??"Your feedback has been received.",confirmationClose:t.text?.confirmationClose??"Close",errorTitle:t.text?.errorTitle??"Message not sent",errorMessage:t.text?.errorMessage??"Something went wrong, so we did not get your message. Please try again later."},hideConfirmation:t.hideConfirmation??!1,modalWidth:t.modalWidth??400,backdropOpacity:t.backdropOpacity??.3,fontFamily:t.fontFamily??"system-ui, -apple-system, sans-serif",fontSize:t.fontSize??16,captureScreenshot:t.captureScreenshot??!1,annotate:t.annotate??!0,annotationColor:t.annotationColor??t.colors?.marker??"#6365f1",annotationPalette:t.annotationPalette??wo,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:lo(t.quests?.moduleUrl)}}}class Rt{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};feedbackRecordPromise=Promise.resolve(null);questsPrewarmed=!1;activeQuest=null;isMobile=!1;visitorId;sessionId;errorReporter=null;consoleCapture=null;recording=null;targeting=null;clickPathPrewarmed=!1;prewarmHandle=null;prewarmIsTimeout=!1;videoPrewarmed=!1;screenshotPrewarmed=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;modal=null;dismissBtn=null;cssVars={};activeThumbBtn=null;keyboardActivation=!1;dialogModule=null;dialogClose=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundResize;_startDismissed=!1;destroyed=!1;ready=Promise.resolve();initialized=!1;domObserver=null;boundBeforeSwap=null;constructor(e){if(this.config=Ot(e),this.boundKeyDown=this.handleKeyDown.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=qo(),this.sessionId=Je(U),e.captureErrors&&e.apiKey){const o=typeof e.captureErrors=="object"?e.captureErrors:{};this.errorReporter=Ze({endpoint:o.endpoint??So(e.endpoint),apiKey:e.apiKey,sessionId:this.sessionId,visitorId:this.visitorId,release:o.release,environment:o.environment,sampleRate:o.sampleRate})}vo(e)?this.ready=yo(e).then(o=>{this.destroyed||(this.config=Ot(o),this.init())}):this.init()}applyVars(e){Oe(e,this.cssVars)}announceMsg(e,o=!1){const i=this.overlayShadowRoot??this.shadowRoot;i&&Ne(i,e,{assertive:o})}async loadDialogA11y(){this.dialogModule??=await import("./send-DqRUNsT8.js").then(e=>e.a)}openDialogA11y(e,o){this.closeDialogA11y(),this.dialogClose=this.dialogModule.openDialog(e,o)}closeDialogA11y(){const e=this.dialogClose;this.dialogClose=null,e?.()}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){this.initialized=!0,Re(),this.cssVars=Me({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&&Co(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=Qe(e=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom(),this.schedulePrewarm(()=>{this.prewarmClickPath(),this.config.captureVideo&&this.videoSupported()&&this.prewarmVideo(),this.config.captureScreenshot&&this.prewarmScreenshot(),this.prewarmQuests()})}prewarmClickPath(){this.clickPathPrewarmed||(this.clickPathPrewarmed=!0,import("./send-DqRUNsT8.js").then(e=>e.s).catch(()=>{}),import("./send-DqRUNsT8.js").then(e=>e.a).catch(()=>{}),import("./modal-CnwTJf_B.js").catch(()=>{}),this.skipsTargeting()||import("./targeting-QHJXTusT.js").catch(()=>{}))}skipsTargeting(){return this.config.skipTargeting||this.config.feedbackMode==="annotate"}prewarmVideo(){this.videoPrewarmed||(this.videoPrewarmed=!0,import("./recording-D0vRDckg.js").catch(()=>{}),import("./video-BSP4s2te.js").catch(()=>{}))}prewarmScreenshot(){this.screenshotPrewarmed||(this.screenshotPrewarmed=!0,(this.shouldCaptureViaDom()?import("./screenshot-dom-DO-0UlOz.js"):import("./screenshot-CNe1irEz.js")).catch(()=>{}),this.config.annotate&&import("./annotate-G6jz7v3f.js").catch(()=>{}))}linkedQuestIds(){const e=this.config.quests;return e.base?[e.up,e.down,e.video].filter(o=>o):[]}prewarmQuests(){if(this.questsPrewarmed)return;const e=this.linkedQuestIds();if(e.length===0)return;this.questsPrewarmed=!0;const{base:o,moduleUrl:i}=this.config.quests;import("./send-DqRUNsT8.js").then(s=>s.q).then(s=>{s.loadQuestsModule(i).catch(()=>{});for(const r of e)s.prefetchQuestDefinition(s.questDefinitionUrl(o,r))}).catch(()=>{})}schedulePrewarm(e){const o=window,i=()=>{this.destroyed||e()};typeof o.requestIdleCallback=="function"?(this.prewarmIsTimeout=!1,this.prewarmHandle=o.requestIdleCallback(i,{timeout:2e3})):(this.prewarmIsTimeout=!0,this.prewarmHandle=window.setTimeout(i,1200))}observeDom(){this.boundBeforeSwap=e=>{const o=e.newDocument;!o||this.destroyed||(this.shadowHost&&o.body.appendChild(this.shadowHost),this.overlayShadowHost&&o.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=eo()}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 e=null;this.config.container&&(e=document.querySelector(this.config.container)),e?(e.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 o=document.createElement("style");if(o.setAttribute("data-qaid-base",""),o.textContent=ft(),this.shadowRoot.appendChild(o),this.config.css){const d=document.createElement("style");d.textContent=this.config.css,this.shadowRoot.appendChild(d)}const i=this.config.direction==="vertical"?"qaid-vertical":"";if(this.isUserProvidedContainer)this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-${this.config.position} ${i}`.trim(),this.config.incognito&&this.buttonsContainer.classList.add("qaid-incognito");else{this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-auto-container qaid-${this.config.position} ${i}${this.config.incognito?" qaid-incognito":""}`.trim(),this.buttonsContainer.style.pointerEvents="auto";const{x:d,y:a}=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=`${a}px`:this.buttonsContainer.style.top=`${a}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 s=()=>this.prewarmClickPath();this.buttonsContainer.addEventListener("pointerenter",s),this.buttonsContainer.addEventListener("focusin",s);const r=!!this.config.buttonClass,n=r?`qaid-btn-structural ${this.config.buttonClass}`:"qaid-btn",h=this.config.text.tooltip||"Feedback for us?",g=document.createElement("div");if(g.className="qaid-tooltip-text",g.textContent=h,this.applyVars(g),this.shadowRoot.appendChild(g),this.tooltipElement=g,this.config.singleButton){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const a=document.createElement("button");a.type="button",a.className=r?`${n} qaid-btn-feedback`:"qaid-btn qaid-btn-feedback",a.setAttribute("aria-label",this.config.text.feedbackLabel),A(a,this.config.feedbackIcon,st),a.addEventListener("click",f=>this.handleThumbClick("neutral",f.currentTarget,f)),a.addEventListener("mouseenter",()=>this.showTooltip(a)),a.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(a),this.buttonsContainer.appendChild(d)}else if(!this.config.hideThumbs){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const a=document.createElement("button");a.type="button",a.className=r?`${n} qaid-btn-up`:"qaid-btn qaid-btn-up",a.setAttribute("aria-label",this.config.text.positiveLabel),A(a,this.config.positiveIcon,it),a.addEventListener("click",v=>this.handleThumbClick("up",v.currentTarget,v)),a.addEventListener("mouseenter",()=>{this.prewarmQuests(),this.showTooltip(a)}),a.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(a);const f=document.createElement("div");f.className="qaid-tooltip-wrapper";const p=document.createElement("button");p.type="button",p.className=r?`${n} qaid-btn-down`:"qaid-btn qaid-btn-down",p.setAttribute("aria-label",this.config.text.negativeLabel),A(p,this.config.negativeIcon,nt),p.addEventListener("click",v=>this.handleThumbClick("down",v.currentTarget,v)),p.addEventListener("mouseenter",()=>{this.prewarmQuests(),this.showTooltip(p)}),p.addEventListener("mouseleave",()=>this.hideTooltip()),f.appendChild(p),this.buttonsContainer.appendChild(d),this.buttonsContainer.appendChild(f)}if(this.config.captureVideo&&this.videoSupported()){const d=document.createElement("div");d.className="qaid-tooltip-wrapper";const a=document.createElement("button");a.type="button",a.className=r?`${n} qaid-btn-record`:"qaid-btn qaid-btn-record",a.setAttribute("aria-label",this.config.text.recordLabel),A(a,this.config.recordIcon,le),a.addEventListener("click",()=>{this.ensureRecording().then(p=>this.config.videoOptions.redaction?p.startPicking():p.startRecording())});const f=()=>this.prewarmVideo();a.addEventListener("mouseenter",()=>{f(),this.showTooltip(a)}),a.addEventListener("focus",f),a.addEventListener("touchstart",f,{passive:!0}),a.addEventListener("mouseleave",()=>this.hideTooltip()),d.appendChild(a),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,A(this.dismissBtn,null,ce),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 e=document.createElement("style");e.setAttribute("data-qaid-base",""),e.textContent=ft(),this.overlayShadowRoot.appendChild(e);for(const o of this.featureStyles)Mt(this.overlayShadowRoot,o);if(this.config.css){const o=document.createElement("style");o.textContent=this.config.css,this.overlayShadowRoot.appendChild(o)}return this.overlayShadowRoot}featureStyles=[];addFeatureStyles(e){if(!this.featureStyles.includes(e)){this.featureStyles.push(e);for(const o of[this.shadowRoot,this.overlayShadowRoot])o&&Mt(o,e)}}tooltipElement=null;showTooltip(e){const o=this.tooltipElement;o.style.visibility="hidden",o.classList.add("qaid-tooltip-visible");const i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),{top:r,left:n}=ze(i,s,{width:window.innerWidth,height:window.innerHeight});o.style.top=`${r}px`,o.style.left=`${n}px`,o.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),Dt(this.config.apiKey,!0)}handleThumbClick(e,o,i){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),Dt(this.config.apiKey,!1)),this.prewarmClickPath(),this.skipsTargeting())this.submitDirectFeedback(e,o);else{this.activeThumbBtn=o,o.setAttribute("aria-pressed","true");const s=this.keyboardActivation;this.keyboardActivation=!1,this.ensureTargeting().then(r=>{this.destroyed||(s?r.startKeyboard(e):r.startPointer(e,i))})}}submitDirectFeedback(e,o){this.feedbackData.feedbackType=e,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const i=o.getBoundingClientRect();this.selectedBounds={x:i.left,y:i.top,width:i.width,height:i.height,clickX:i.left+i.width/2,clickY:i.top+i.height/2,visible:!1},this.submitFeedback()}handleKeyDown(e){if(e.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"||ko()}async submitFeedback(){try{const[e]=await Promise.all([import("./send-DqRUNsT8.js").then(o=>o.s),this.loadDialogA11y()]);await e.submitFeedback(this.makeSendHost())}catch(e){console.error("Failed to send feedback:",e),this.announceMsg("Failed to send feedback",!0),this.resetFeedbackUi()}}async tryLaunchQuest(e,o){try{return await(await import("./send-DqRUNsT8.js").then(s=>s.s)).tryLaunchQuest(this.makeSendHost(),e,o)}catch(i){return console.error("Failed to launch quest:",i),!1}}makeSendHost(){const e=this;return{get config(){return e.config},get visitorId(){return e.visitorId},get sessionId(){return e.sessionId},get feedbackData(){return e.feedbackData},get selectedBounds(){return e.selectedBounds},get destroyed(){return e.destroyed},get overlayShadowHost(){return e.overlayShadowHost},get activeQuest(){return e.activeQuest},set activeQuest(o){e.activeQuest=o},setState:o=>{e.state=o},setFeedbackRecord:o=>{e.feedbackRecordPromise=o},shouldCaptureViaDom:()=>e.shouldCaptureViaDom(),ensureOverlayHost:()=>e.ensureOverlayHost(),ensureModal:()=>e.ensureModal(),addFeatureStyles:o=>e.addFeatureStyles(o),applyVars:o=>e.applyVars(o),announceMsg:(o,i)=>e.announceMsg(o,i),openDialogA11y:(o,i)=>e.openDialogA11y(o,i),closeDialogA11y:()=>e.closeDialogA11y(),resetFeedbackUi:()=>e.resetFeedbackUi()}}resetFeedbackUi(){this.targeting?.hideMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackRecordPromise=Promise.resolve(null),this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}async ensureModal(){if(!this.modal){const[{ModalController:e,styles:o}]=await Promise.all([import("./modal-CnwTJf_B.js"),this.loadDialogA11y()]);this.addFeatureStyles(o),this.modal=new e(this.makeModalHost())}return this.modal}makeModalHost(){const e=this;return{get config(){return e.config},get uid(){return e.uid},get isMobile(){return e.isMobile},get state(){return e.state},get boundKeyDown(){return e.boundKeyDown},get feedbackData(){return e.feedbackData},get selectedBounds(){return e.selectedBounds},whenFeedbackRecord:()=>e.feedbackRecordPromise,ensureOverlayHost:()=>e.ensureOverlayHost(),applyVars:o=>e.applyVars(o),announceMsg:(o,i)=>e.announceMsg(o,i),openDialogA11y:(o,i)=>e.openDialogA11y(o,i),closeDialogA11y:()=>e.closeDialogA11y(),resetFeedbackUi:()=>e.resetFeedbackUi()}}async ensureTargeting(){if(!this.targeting){const{TargetingController:e,styles:o}=await import("./targeting-QHJXTusT.js");this.addFeatureStyles(o),this.targeting=new e(this.makeTargetingHost())}return this.targeting}makeTargetingHost(){const e=this;return{get config(){return e.config},get cssVars(){return e.cssVars},get state(){return e.state},get shadowHost(){return e.shadowHost},get overlayShadowHost(){return e.overlayShadowHost},get boundKeyDown(){return e.boundKeyDown},get feedbackData(){return e.feedbackData},get selectedBounds(){return e.selectedBounds},setState:o=>{e.state=o},ensureOverlayHost:()=>e.ensureOverlayHost(),applyVars:o=>e.applyVars(o),announceMsg:(o,i)=>e.announceMsg(o,i),clearActiveThumb:()=>e.clearActiveThumb(),submitFeedback:()=>e.submitFeedback()}}videoSupported(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}async ensureRecording(){if(!this.recording){const[{RecordingController:e,styles:o}]=await Promise.all([import("./recording-D0vRDckg.js"),this.loadDialogA11y()]);this.addFeatureStyles(o),this.recording=new e(this.makeRecordingHost())}return this.recording}makeRecordingHost(){const e=this;return{get config(){return e.config},get visitorId(){return e.visitorId},get uid(){return e.uid},get overlayShadowHost(){return e.overlayShadowHost},get consoleCapture(){return e.consoleCapture},get boundKeyDown(){return e.boundKeyDown},get state(){return e.state},setState:o=>{e.state=o},ensureOverlayHost:()=>e.ensureOverlayHost(),applyVars:o=>e.applyVars(o),announceMsg:(o,i)=>e.announceMsg(o,i),openDialogA11y:(o,i)=>e.openDialogA11y(o,i),closeDialogA11y:()=>e.closeDialogA11y(),setButtonsDisabled:o=>e.setButtonsDisabled(o),tryLaunchQuest:(o,i)=>e.tryLaunchQuest(o,i)}}setButtonsDisabled(e){if(!this.buttonsContainer)return;this.buttonsContainer.querySelectorAll("button.qaid-btn, button.qaid-btn-structural").forEach(i=>{e?i.classList.contains("qaid-btn-record")||(i.disabled=!0,i.style.opacity="0.5"):(i.disabled=!1,i.style.opacity="")})}destroy(){if(this.destroyed=!0,this.errorReporter?.stop(),this.errorReporter=null,!!this.initialized){if(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 e=window;this.prewarmIsTimeout?clearTimeout(this.prewarmHandle):e.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,Be()}}}var xo="__qaidThumbsOrigin";function Bt(t){return document.querySelector(t)?.textContent?.trim()??""}const Ht=xo;function _t(t){const e=t.split(/[?#]/)[0];return e.substring(e.lastIndexOf("/")+1)}function Ao(t){const e=document.currentScript;if(e&&e.tagName==="SCRIPT")return e;if(!t)return null;const o=Array.from(document.getElementsByTagName("script")).filter(l=>l.src),i=o.find(l=>l.src===t);if(i)return i;const s=o.filter(l=>l[Ht]);if(s.length===1)return s[0];const r=_t(t),n=o.filter(l=>_t(l.src)===r);return n.length===1?n[0]:null}function Pt(t){return!!t&&t.tagName==="SCRIPT"&&(t.getAttribute("type")||"").trim().toLowerCase()==="application/json"}function Eo(t){const e=t[Ht],o=e&&e.tagName==="SCRIPT"?e:t,i=o.getAttribute("data-config-id")||t.getAttribute("data-config-id");if(i){const s=document.getElementById(i);return Pt(s)?s:null}for(const s of[o.previousElementSibling,o.nextElementSibling])if(Pt(s)&&s.hasAttribute("data-feedback-config"))return s;return null}function To(t){const e=Eo(t);if(!e)return null;const o=e.textContent?.trim();if(!o)return null;try{const i=JSON.parse(o);return i.cssSelector&&!i.css&&(i.css=Bt(i.cssSelector),delete i.cssSelector),i}catch{return null}}function Nt(t,e,o){console.warn(`[thumbs-embed] Ignoring ${t}="${e}": expected ${o}.`)}function Io(t){const e=[];let o=0,i="";for(const s of t)s==="("&&o++,s===")"&&(o=Math.max(0,o-1)),s===","&&o===0?(e.push(i.trim()),i=""):i+=s;return e.push(i.trim()),e}function Lo(t,e){if(e===null)return;const o=e.trim();let i=null;if(o.startsWith("[")||o.startsWith("{"))try{i=JSON.parse(o)}catch{i=null}else i=Io(o);if(Array.isArray(i)&&i.length>0&&i.every(s=>typeof s=="string"&&s.trim()!==""))return i.map(s=>s.trim());Nt(t,e,"a JSON array of colours or a comma-separated list")}function R(t,e){if(e!==null){if(e.trim()===""){Nt(t,e,"a non-empty label");return}return e}}function Do(t){const e=t.getAttribute("data-endpoint");if(!e)return null;const o=t.getAttribute("data-position"),i=t.getAttribute("data-zindex"),s=t.getAttribute("data-positive-color"),r=t.getAttribute("data-negative-color"),n=t.getAttribute("data-marker-color"),l=t.getAttribute("data-container"),h=t.getAttribute("data-button-class"),g=t.getAttribute("data-skip-targeting"),d=t.getAttribute("data-hide-confirmation"),a=t.getAttribute("data-single-button"),f=t.getAttribute("data-feedback-mode"),p=t.getAttribute("data-incognito"),v=t.getAttribute("data-button-size"),S=t.getAttribute("data-offset-x"),k=t.getAttribute("data-offset-y"),c=t.getAttribute("data-modal-width"),m=t.getAttribute("data-backdrop-opacity"),u=t.getAttribute("data-font-family"),b=t.getAttribute("data-font-size"),y=t.getAttribute("data-tooltip"),w=t.getAttribute("data-modal-title"),E=t.getAttribute("data-confirmation-title"),x=t.getAttribute("data-confirmation-message"),q=t.getAttribute("data-confirmation-close"),$=t.getAttribute("data-error-title"),j=t.getAttribute("data-error-message"),F=t.getAttribute("data-modal-subtitle"),V=t.getAttribute("data-placeholder"),K=t.getAttribute("data-submit-button"),W=t.getAttribute("data-skip-button"),Ut=t.getAttribute("data-positive-icon"),$t=t.getAttribute("data-negative-icon"),jt=t.getAttribute("data-feedback-icon"),Q=t.getAttribute("data-feedback-label"),Ft=t.getAttribute("data-api-key"),Vt=t.getAttribute("data-capture-screenshot"),Kt=t.getAttribute("data-annotate"),Wt=t.getAttribute("data-annotation-color"),B=t.getAttribute("data-screenshot-quality"),H=t.getAttribute("data-screenshot-max-width"),_=t.getAttribute("data-screenshot-max-height"),Qt=t.getAttribute("data-capture-video"),Y=t.getAttribute("data-video-redaction"),Yt=t.getAttribute("data-hide-thumbs"),Xt=t.getAttribute("data-hide-dismiss"),P=t.getAttribute("data-video-max-duration"),Gt=t.getAttribute("data-screenshot-method"),Jt=t.getAttribute("data-direction"),X=t.getAttribute("data-css-selector"),Zt=t.getAttribute("data-css"),G=R("data-positive-label",t.getAttribute("data-positive-label")),J=R("data-negative-label",t.getAttribute("data-negative-label")),Z=R("data-record-label",t.getAttribute("data-record-label")),tt=R("data-dismiss-label",t.getAttribute("data-dismiss-label")),te=Lo("data-annotation-palette",t.getAttribute("data-annotation-palette")),ee=t.getAttribute("data-record-icon"),et=t.getAttribute("data-quest-base"),oe=t.getAttribute("data-quest-up"),ie=t.getAttribute("data-quest-down"),ne=t.getAttribute("data-quest-video"),se=t.getAttribute("data-quest-api-key"),re=t.getAttribute("data-quest-module-url"),ae=t.getAttribute("data-remote-config"),de=t.getAttribute("data-theme-url"),ot=t.getAttribute("data-remote-timeout");return{endpoint:e,remoteConfig:ae==="true"?!0:void 0,themeUrl:de||void 0,remoteTimeoutMs:ot?parseInt(ot,10):void 0,css:Zt||(X?Bt(X):void 0),apiKey:Ft??void 0,captureScreenshot:Vt==="true"?!0:void 0,annotate:Kt==="false"?!1:void 0,annotationColor:Wt??void 0,annotationPalette:te,screenshotOptions:B||H||_?{quality:B?parseFloat(B):void 0,maxWidth:H?parseInt(H,10):void 0,maxHeight:_?parseInt(_,10):void 0}:void 0,container:l??void 0,buttonClass:h??void 0,direction:Jt??void 0,position:o??void 0,zIndex:i?parseInt(i,10):void 0,skipTargeting:g==="true"?!0:void 0,hideConfirmation:d==="true"?!0:void 0,singleButton:a==="true"?!0:void 0,feedbackMode:f??void 0,incognito:p==="true"?!0:void 0,buttonSize:v??void 0,offset:S||k?{x:S?parseInt(S,10):void 0,y:k?parseInt(k,10):void 0}:void 0,modalWidth:c?parseInt(c,10):void 0,backdropOpacity:m?parseFloat(m):void 0,fontFamily:u??void 0,fontSize:b?parseInt(b,10):void 0,colors:{positive:s??void 0,negative:r??void 0,marker:n??void 0},text:y||w||F||V||K||W||Q||E||x||q||$||j||G||J||Z||tt?{tooltip:y??void 0,modalTitle:w??void 0,modalSubtitle:F??void 0,placeholder:V??void 0,submitButton:K??void 0,skipButton:W??void 0,feedbackLabel:Q??void 0,confirmationTitle:E??void 0,confirmationMessage:x??void 0,confirmationClose:q??void 0,errorTitle:$??void 0,errorMessage:j??void 0,positiveLabel:G,negativeLabel:J,recordLabel:Z,dismissLabel:tt}:void 0,positiveIcon:Ut??void 0,recordIcon:ee??void 0,negativeIcon:$t??void 0,feedbackIcon:jt??void 0,screenshotMethod:Gt??void 0,captureVideo:Qt==="true"?!0:void 0,hideThumbs:Yt==="true"?!0:void 0,hideDismiss:Xt==="true"?!0:void 0,videoOptions:P||Y?{maxDuration:P?parseInt(P,10):void 0,redaction:Y==="true"?!0:void 0}:void 0,quests:et?{base:et,up:oe??void 0,down:ie??void 0,video:ne??void 0,apiKey:se??void 0,moduleUrl:re??void 0}:void 0}}function Mo(t){if(typeof document>"u")return;const e=Ao(t);if(!e)return;const o=()=>{const i=To(e)??Do(e);i?.endpoint&&new Rt(i)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o()}var Oo="qaid-embed",zt="__qaidEmbedTrustedTypes";function Ro(){if(typeof window>"u")return null;var t=window,e=t.trustedTypes;if(!e||typeof e.createPolicy!="function")return null;var o=t[zt];if(o)return o;var i=Object.create(null),s=Object.create(null),r=null;try{r=e.createPolicy(Oo,{createScriptURL:function(l){if(i[l]===!0)return l;throw new TypeError("qaid-embed: refused script URL "+l)},createScript:function(l){if(s[l]===!0)return l;throw new TypeError("qaid-embed: refused inline script")}})}catch{r=null}var n={policy:r,allowed:i,allowedScripts:s};try{Object.defineProperty(t,zt,{value:n,configurable:!0})}catch{}return n}function Bo(t){var e=Ro();return!e||!e.policy?t:(e.allowed[t]=!0,e.policy.createScriptURL(t))}export{he as A,pe as B,I as D,ge as E,st as F,fe as P,Rt as Q,ue as R,ve as S,it as T,me as U,ro as a,be as b,to as c,Mo as d,nt as e,oo as f,no as g,io as h,ht as i,D as j,Ke as r,A as s,Bo as t};
26
+ //# sourceMappingURL=core-Cl_qkUzb.js.map