@daybook/feedback 1.3.0 → 1.4.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
@@ -221,7 +221,15 @@ three days later when the reporter has moved on.
221
221
  - **The element**, as a CSS selector plus the click position as a fraction of that element's bounding
222
222
  box. Not page pixels: an anchor recorded on a desktop layout has to still mean something on a phone.
223
223
  An 80-character text snapshot comes too, so a human can find the thing after a redesign breaks the
224
- selector.
224
+ selector, and the page it was on. Where nothing readable identifies the element — no test id, no
225
+ stable id, only generated class names — the selector falls back to its position in the tree, so a
226
+ pin always names an element.
227
+
228
+ **More than one, when one is not enough** (1.4). After the first pin the composer offers *Add
229
+ another pin*; the reporter's message, kind and files stay as they were. Pins are numbered on the
230
+ page, in the panel and in the screenshot, so "pin 2" in a message means something. On the wire
231
+ `context.anchor` is still the first pin — exactly what earlier versions sent — and
232
+ `context.anchors` carries all of them when there is more than one.
225
233
  - **Page and device** — route, title, referrer, locale, timezone, viewport with DPR, and a readable
226
234
  browser and OS rather than a raw user-agent string.
227
235
  - **Breadcrumbs** — the last 40 navigations, clicks, console errors and failed or slow requests.
@@ -243,8 +251,8 @@ three days later when the reporter has moved on.
243
251
  `data-daybook-private` withholds a subtree without turning the whole thing off.
244
252
  - **A screenshot**, if the reporter ticks "Capture the screen" and consents to the browser's share
245
253
  prompt. The widget hides itself for the frame, so the picture is of the page underneath rather
246
- than of the form that was just filled in — and if the reporter pinned an element, that element is
247
- ringed in the picture.
254
+ than of the form that was just filled in — and every element the reporter pinned is ringed in the
255
+ picture, numbered when there is more than one.
248
256
 
249
257
  The ring is the difference between a report you can act on and one you have to reconstruct. A
250
258
  selector and a text snapshot tell you which node; they do not tell you which of the forty things
package/dist/anchor.js CHANGED
@@ -21,6 +21,7 @@ export function captureAnchor(clientX, clientY) {
21
21
  offsetX: clamp01(clientX / window.innerWidth),
22
22
  offsetY: clamp01(clientY / window.innerHeight),
23
23
  elementText: null,
24
+ page: pageOf(),
24
25
  };
25
26
  }
26
27
  const box = element.getBoundingClientRect();
@@ -29,6 +30,7 @@ export function captureAnchor(clientX, clientY) {
29
30
  offsetX: box.width > 0 ? clamp01((clientX - box.left) / box.width) : 0,
30
31
  offsetY: box.height > 0 ? clamp01((clientY - box.top) / box.height) : 0,
31
32
  elementText: textOf(element),
33
+ page: pageOf(),
32
34
  };
33
35
  }
34
36
  /**
@@ -107,7 +109,55 @@ function selectorFor(element) {
107
109
  current = parent;
108
110
  }
109
111
  const full = path.length > 0 ? `body > ${path.join(' > ')}` : null;
110
- return full && isUnique(full) ? full : null;
112
+ if (full && isUnique(full))
113
+ return full;
114
+ return structuralPath(element);
115
+ }
116
+ /**
117
+ * The last resort, and the reason a pin never arrives without an element: position alone.
118
+ *
119
+ * PM-B-0084. The readable path above gives up past eight levels or when every class looks
120
+ * generated, and a customer's app — Tailwind, CSS modules, no test ids — is exactly where that
121
+ * happens. `:nth-child` from the nearest ancestor with a stable handle (or from body) is ugly and
122
+ * breaks on the next layout change, but it names this element on this page, which is what a report
123
+ * needs. The element's text travels beside it for when the selector has stopped working.
124
+ */
125
+ function structuralPath(element) {
126
+ const steps = [];
127
+ let current = element;
128
+ while (current && current !== document.body && current !== document.documentElement) {
129
+ const handle = stableHandle(current);
130
+ if (handle && current !== element) {
131
+ steps.unshift(handle);
132
+ break;
133
+ }
134
+ const parent = current.parentElement;
135
+ if (!parent)
136
+ break;
137
+ steps.unshift(`${current.tagName.toLowerCase()}:nth-child(${Array.from(parent.children).indexOf(current) + 1})`);
138
+ current = parent;
139
+ }
140
+ if (current === document.body)
141
+ steps.unshift('body');
142
+ const candidate = steps.join(' > ');
143
+ return candidate && isUnique(candidate) ? candidate : null;
144
+ }
145
+ /** A test attribute or a non-generated id that is unique on the page, as a selector. */
146
+ function stableHandle(element) {
147
+ for (const attribute of ['data-testid', 'data-test', 'data-daybook-id', 'data-cy']) {
148
+ const value = element.getAttribute(attribute);
149
+ if (value) {
150
+ const candidate = `[${attribute}="${cssEscape(value)}"]`;
151
+ if (isUnique(candidate))
152
+ return candidate;
153
+ }
154
+ }
155
+ if (element.id && !looksGenerated(element.id)) {
156
+ const candidate = `#${cssEscape(element.id)}`;
157
+ if (isUnique(candidate))
158
+ return candidate;
159
+ }
160
+ return null;
111
161
  }
112
162
  function isUnique(selector) {
113
163
  try {
@@ -148,6 +198,13 @@ function textOf(element) {
148
198
  }
149
199
  return text.length > 80 ? `${text.slice(0, 77)}…` : text;
150
200
  }
201
+ /**
202
+ * Where the pin was dropped. A single-page app keeps the widget open across a route change, so
203
+ * pins on one report can come from more than one screen, and a selector means nothing without it.
204
+ */
205
+ function pageOf() {
206
+ return location.pathname + location.search;
207
+ }
151
208
  function clamp01(value) {
152
209
  if (!Number.isFinite(value))
153
210
  return 0;
package/dist/context.d.ts CHANGED
@@ -8,7 +8,7 @@ import type { Anchor, Breadcrumb } from './types.js';
8
8
  * on. All of it is available for free at the moment of capture.
9
9
  */
10
10
  export declare function captureContext(options: {
11
- anchor?: Anchor | null;
11
+ anchors?: Anchor[];
12
12
  breadcrumbs?: Breadcrumb[];
13
13
  app?: {
14
14
  version?: string;
package/dist/context.js CHANGED
@@ -28,8 +28,16 @@ export function captureContext(options) {
28
28
  context.referrer = redactUrl(document.referrer);
29
29
  if (options.app)
30
30
  context.app = options.app;
31
- if (options.anchor)
32
- context.anchor = options.anchor;
31
+ /*
32
+ * `anchor` is the first pin and stays exactly what every bundle before 1.4 sent, so anything
33
+ * reading one pin keeps reading one pin (PM-R-0004 #11: the wire only ever grows). `anchors` is
34
+ * all of them, in the order they were numbered, and is only sent when there is a list to send.
35
+ */
36
+ const anchors = options.anchors ?? [];
37
+ if (anchors[0])
38
+ context.anchor = anchors[0];
39
+ if (anchors.length > 1)
40
+ context.anchors = anchors;
33
41
  if (options.breadcrumbs && options.breadcrumbs.length > 0) {
34
42
  context.breadcrumbs = options.breadcrumbs;
35
43
  }
package/dist/feedback.js CHANGED
@@ -1,28 +1,31 @@
1
- "use strict";var DaybookFeedback=(()=>{var P=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var Fe=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})},Pe=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of He(e))!Ie.call(n,r)&&r!==t&&P(n,r,{get:()=>e[r],enumerable:!(o=Ce(e,r))||o.enumerable});return n};var je=n=>Pe(P({},"__esModule",{value:!0}),n);var gt={};Fe(gt,{DEFAULT_API_URL:()=>Re,DaybookFeedback:()=>I,captureAnchor:()=>$,init:()=>mt,previewLauncher:()=>_e,resolveAnchor:()=>ye});function x(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}var Be=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function ne(n,e){return n.length===0?"":e&&Be.test(e)?"[redacted]":`[${n.length} chars]`}function j(n){var o,r,i,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return j(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",u=n instanceof HTMLInputElement?n.type:e;return`${e}[${u}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function oe(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var k="data-daybook-private";var T=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?oe(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",j(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,r=()=>this.add("nav",x(location.href));history.pushState=(...a)=>{t.apply(history,a),r()},history.replaceState=(...a)=>{o.apply(history,a),r()},window.addEventListener("popstate",r),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",r)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(B).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let i=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${B(a.reason)}`);window.addEventListener("error",i),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let r=await e.apply(window,t),i=Math.round(performance.now()-o);return(!r.ok||i>3e3)&&this.add("network",`${r.status} ${x(re(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${x(re(t[0]))}: ${B(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function re(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function B(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var q="pm.feedback.queue";var L=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,u;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:ie(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(h=>({filename:h.filename,contentType:h.contentType,size:h.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await S(i);let s=await i.json(),a=((u=e.attachments)!=null?u:[]).length;return await Promise.all(t.map(async(h,d)=>{let m=Oe(s,a+d);if(!m){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(m,h)}catch(y){o==null||o(h,y)}})),s}async flush(){let e=ae();if(e.length!==0){ce([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&O(t)}catch{O(t)}}}queue(e){var t;O({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:ie(),attachments:void 0})}async signIn(){let e=se(64),t=await qe(e),o=se(16),r=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,i=window.open(r,"daybook-feedback","width=460,height=640");if(!i)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,u)=>{let h=setInterval(()=>{i.closed&&(m(),u(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),d=y=>{if(y.origin!==new URL(this.base()).origin)return;let b=y.data;if((b==null?void 0:b.source)==="daybook-feedback"&&b.state===o){if(m(),b.error||!b.code){u(Object.assign(new Error("Sign-in was refused"),{code:b.error||"refused"}));return}l(b.code)}},m=()=>{clearInterval(h),window.removeEventListener("message",d)};window.addEventListener("message",d)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await S(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await S(t);let o=await t.json();return this.session=(i=o.sessionToken)!=null?i:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await S(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function Oe(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function O(n){let e=ae();e.push(n),ce(e.slice(-20))}function ae(){try{let n=localStorage.getItem(q);return n?JSON.parse(n):[]}catch{return[]}}function ce(n){try{n.length===0?localStorage.removeItem(q):localStorage.setItem(q,JSON.stringify(n))}catch{}}async function S(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function ie(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function se(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function qe(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function U(n){var t;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:Ne(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(t=window.devicePixelRatio)!=null?t:1},device:Ue()};return document.referrer&&(e.referrer=x(document.referrer)),n.app&&(e.app=n.app),n.anchor&&(e.anchor=n.anchor),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function Ue(){var r;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(r=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:r[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function Ne(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function pe(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?Ke():()=>{},o=e(),r=null;try{return r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),r.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await De(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var le=1920,ze=.82;async function De(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,r=t>le?le/t:1,i=document.createElement("canvas");i.width=Math.round(t*r),i.height=Math.round(o*r);let s=i.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,i.width,i.height),e.pause(),e.srcObject=null;let a=await Xe(i);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function Xe(n){for(let e of["image/webp","image/jpeg"]){let t=await de(n,e,ze);if((t==null?void 0:t.type)===e)return t}return de(n,"image/png")}function de(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function Ke(){let n=[...document.querySelectorAll(`[${k}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var r;t.style.filter=(r=e[o])!=null?r:""})}}var z=4e5,ue=300,he=600,me=8e3,We=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),Ve=["display","position","z-index","opacity","visibility","overflow","width","height","margin","padding","box-sizing","color","background-color","border","border-radius","box-shadow","font-family","font-size","font-weight","line-height","text-align","white-space","flex-direction","justify-content","align-items","gap","grid-template-columns","transform","transition","pointer-events","cursor"],Ye="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last because only the head of this file is inlined beside the report \u2014 download the attachment for the rest of it.";function D(n){let e=[],t=n;for(let o=0;t&&o<4&&t.nodeType===1;o+=1){let r=t.localName;if(t.id){e.unshift(`${r}#${t.id}`);break}let i=Array.from(t.classList).slice(0,3).join(".");i&&(r+=`.${i}`),e.unshift(r),t=t.parentElement}return e.join(" > ")}var Je=(n,e)=>e.length>ue?`${e.slice(0,ue)}\u2026[${e.length}]`:e,N=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Qe(n,e){let t=n;if(n.localName==="input"&&(t.type==="checkbox"||t.type==="radio"))return t.checked?"checked":"unchecked";let o=t.value;return typeof o!="string"||o===""?null:e?ne(o,t.name||t.id||t.type):o}function fe(n,e,t,o){var u,h;if(t.used>z)return!1;if(n.nodeType===3){let d=((u=n.textContent)!=null?u:"").replace(/\s+/g," ");if(!d.trim())return!0;let m=d.length>he?`${d.slice(0,he)}\u2026`:d;return e.push(N(m)),t.used+=m.length,!0}if(n.nodeType!==1)return!0;let r=n,i=r.tagName;if(r.hasAttribute("data-daybook-feedback")||We.has(i))return!0;let s=r.localName;if(o&&r.hasAttribute(k))return e.push(`<${s} ${k}>[withheld]</${s}>`),t.used+=32,!0;let a=[];for(let d of Array.from(r.attributes))d.name!=="value"&&a.push(`${d.name}="${N(Je(d.name,d.value))}"`);let c=Qe(r,o);c!==null&&a.push(`value="${N(c)}"`);let l=a.length>0?`<${s} ${a.join(" ")}>`:`<${s}>`;if(e.push(l),t.used+=l.length,s==="style"){let d=(h=r.textContent)!=null?h:"",m=d.length>me?`${d.slice(0,me)}
2
- /* \u2026${d.length} chars */`:d;e.push(m),t.used+=m.length}else for(let d of Array.from(r.childNodes))if(!fe(d,e,t,o))break;return e.push(`</${s}>`),t.used+=s.length+3,t.used<=z}function Ge(){var e,t;let n=[];for(let o of Array.from((t=(e=document.body)==null?void 0:e.querySelectorAll("*"))!=null?t:[]).slice(0,4e3)){let r=getComputedStyle(o);if(r.position!=="fixed"&&r.position!=="sticky"||r.visibility==="hidden"||r.display==="none"||Number(r.opacity)===0)continue;let i=o.getBoundingClientRect();if(!(i.width<4||i.height<4)&&!o.closest("[data-daybook-feedback]")&&(n.push({selector:D(o),zIndex:r.zIndex,rect:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)}}),n.length>=20))break}return n}function Ze(n){if(!(n!=null&&n.selector))return;let e=null;try{e=document.querySelector(n.selector)}catch{return}if(!e)return;let t=[];for(let o=e;o&&t.length<5;o=o.parentElement){let r=getComputedStyle(o),i={};for(let s of Ve){let a=r.getPropertyValue(s);a&&(i[s]=a)}t.push({selector:D(o),computed:i})}return{selector:n.selector,path:t}}function et(){return Array.from(document.styleSheets).slice(0,40).map(n=>{try{return{href:n.href,rules:n.cssRules.length}}catch{return{href:n.href,rules:"unreadable"}}})}function ge(n,e){try{let t=[],o={used:0};return fe(document.documentElement,t,o,e),{note:Ye,capturedAtUtc:new Date().toISOString(),url:location.href,title:document.title,redacted:e,truncated:o.used>z,scroll:{x:Math.round(window.scrollX),y:Math.round(window.scrollY)},focus:document.activeElement&&document.activeElement!==document.body?D(document.activeElement):null,anchor:Ze(n),layers:Ge(),stylesheets:et(),html:t.join("")}}catch{return null}}function $(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:A(n/window.innerWidth),offsetY:A(e/window.innerHeight),elementText:null};let o=t.getBoundingClientRect();return{selector:tt(t),offsetX:o.width>0?A((n-o.left)/o.width):0,offsetY:o.height>0?A((e-o.top)/o.height):0,elementText:nt(t)}}function ye(n){if(!n.selector)return{x:n.offsetX*window.innerWidth,y:n.offsetY*window.innerHeight};let e=null;try{e=document.querySelector(n.selector)}catch{return null}if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+n.offsetX*t.width,y:t.top+n.offsetY*t.height}}function tt(n){if(n===document.body)return"body";for(let r of["data-testid","data-test","data-daybook-id","data-cy"]){let i=n.getAttribute(r);if(i){let s=`[${r}="${X(i)}"]`;if(_(s))return s}}if(n.id&&!be(n.id)){let r=`#${X(n.id)}`;if(_(r))return r}let e=[],t=n;for(;t&&t!==document.body&&e.length<8;){let r=t.tagName.toLowerCase(),i=Array.from(t.classList).filter(c=>!be(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${X(c)}`).join(""));let s=t.parentElement;if(s){let c=Array.from(s.children).filter(l=>l.tagName===t.tagName);c.length>1&&(r+=`:nth-of-type(${c.indexOf(t)+1})`)}e.unshift(r);let a=e.join(" > ");if(_(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&_(o)?o:null}function _(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function be(n){return/^[a-z]{1,3}[0-9a-f]{5,}$/i.test(n)||/--[0-9a-f]{5,}$/i.test(n)||/^_[0-9a-z]{5,}/i.test(n)||/^v-[0-9a-f]{6,}$/i.test(n)||/^ng-/.test(n)||/[0-9a-f]{8,}/i.test(n)}function nt(n){var o,r,i;let t=((r=(o=n.innerText)!=null?o:n.textContent)!=null?r:"").replace(/\s+/g," ").trim();if(!t){let s=(i=n.getAttribute("aria-label"))!=null?i:n.getAttribute("title");return(s==null?void 0:s.trim())||null}return t.length>80?`${t.slice(0,77)}\u2026`:t}function A(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function X(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var ot=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function we(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=ot.test(o.type)?o.size>26214400?`Too large (${(o.size/1048576).toFixed(1)} MB, max 25).`:null:"Only images and short videos.";t.push({blob:o,filename:o.name||`pasted-${t.length+1}.${rt(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function ve(n){var o;let e=(o=n.clipboardData)==null?void 0:o.items;if(!e)return[];let t=[];for(let r of e){if(r.kind!=="file")continue;let i=r.getAsFile();i&&t.push(i)}return t}function M(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function rt(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function xe(n){var o;let t=(o=(typeof n.composedPath=="function"?n.composedPath():[])[0])!=null?o:n.target;return!t||t.nodeType!==1?!1:/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)?!0:typeof t.closest=="function"&&t.closest('[contenteditable=""], [contenteditable="true"]')!==null}function it(n,e,t){let o=0;for(let s of e){if(s.right<=n.left||s.left>=n.right)continue;let a=n.v==="bottom"?t.height-s.top:s.bottom;a>o&&(o=a)}if(o===0)return 0;let r=n.v==="bottom"?t.height-n.bottom:n.top,i=Math.round(o+12-r);return i<=0||i>t.height*.35?0:i}function st(n,e,t){if(n===e||e.contains(n)||n.contains(e)||n===document.body||n===document.documentElement)return!1;let o=getComputedStyle(n);if(o.position!=="fixed"&&o.position!=="sticky"||o.visibility==="hidden"||o.display==="none"||Number(o.opacity)===0)return!1;let r=n.getBoundingClientRect();return!(r.width<8||r.height<8||r.width*r.height>t.width*t.height*.25)}function at(n,e,t){if(typeof document.elementsFromPoint!="function")return[];let o=new Map,r=[];for(let s=n.left+4;s<n.right;s+=32)r.push(s);r.push(n.right-4);let i=t.height*.35;for(let s=0;s<=i;s+=32){let a=n.v==="bottom"?n.bottom-s:n.top+s;if(a<0||a>t.height)break;for(let c of r)if(!(c<0||c>t.width))for(let l of document.elementsFromPoint(c,a)){if(o.has(l)||!st(l,e,t))continue;let u=l.getBoundingClientRect();o.set(l,{top:u.top,bottom:u.bottom,left:u.left,right:u.right})}}return[...o.values()]}function ke(n,e){let t={width:window.innerWidth,height:window.innerHeight};return it(n,at(n,e,t),t)}var H=class{constructor(e,t){this.options=e;this.onSubmit=t;this.mode="idle";this.anchor=null;this.detach=[];this.buttonStyle="pill";this.clearance=0;this.state="ready";this.policy=null;this.dragged=null;this.reference=null;this.uploadsFailed=0;this.host=document.createElement("div"),this.host.setAttribute("data-daybook-feedback",""),this.host.style.cssText="position:fixed;inset:0;z-index:2147483000;pointer-events:none",this.root=this.host.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${Me}</style><style id="theme"></style><style id="place"></style><div id="layer"></div>`}setTheme(e){let t=this.root.getElementById("theme");if(t){if(!e){t.textContent="";return}t.textContent=Te(e),this.buttonStyle=Se(e),this.themePlacement=e.position,this.applyPlacement(),this.launcherLabel=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):void 0}}get placement(){var e,t;return(t=(e=this.options.placement)!=null?e:this.themePlacement)!=null?t:"bottom-right"}applyPlacement(){let e=this.root.getElementById("place");if(!e)return;let t=this.placement,o=t.startsWith("bottom")?"bottom":"top",r=t.endsWith("right")?"right":"left",i=g+this.clearance;e.textContent=`:host {
3
- --pm-${r}: ${g}px; --pm-${r==="right"?"left":"right"}: auto;
1
+ "use strict";var DaybookFeedback=(()=>{var z=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ue=Object.prototype.hasOwnProperty;var ze=(n,e)=>{for(var t in e)z(n,t,{get:e[t],enumerable:!0})},De=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ne(e))!Ue.call(n,r)&&r!==t&&z(n,r,{get:()=>e[r],enumerable:!(o=qe(e,r))||o.enumerable});return n};var Xe=n=>De(z({},"__esModule",{value:!0}),n);var _t={};ze(_t,{DEFAULT_API_URL:()=>je,DaybookFeedback:()=>j,captureAnchor:()=>P,init:()=>St,previewLauncher:()=>Ie,resolveAnchor:()=>Ee});function S(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}var Ke=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function se(n,e){return n.length===0?"":e&&Ke.test(e)?"[redacted]":`[${n.length} chars]`}function D(n){var o,r,i,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return D(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",p=n instanceof HTMLInputElement?n.type:e;return`${e}[${p}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function ae(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var A="data-daybook-private";var M=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?ae(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",D(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,r=()=>this.add("nav",S(location.href));history.pushState=(...a)=>{t.apply(history,a),r()},history.replaceState=(...a)=>{o.apply(history,a),r()},window.addEventListener("popstate",r),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",r)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(X).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let i=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${X(a.reason)}`);window.addEventListener("error",i),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let r=await e.apply(window,t),i=Math.round(performance.now()-o);return(!r.ok||i>3e3)&&this.add("network",`${r.status} ${S(ce(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${S(ce(t[0]))}: ${X(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function ce(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function X(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var W="pm.feedback.queue";var R=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,p;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:le(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(h=>({filename:h.filename,contentType:h.contentType,size:h.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await C(i);let s=await i.json(),a=((p=e.attachments)!=null?p:[]).length;return await Promise.all(t.map(async(h,d)=>{let f=We(s,a+d);if(!f){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(f,h)}catch(w){o==null||o(h,w)}})),s}async flush(){let e=pe();if(e.length!==0){he([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&K(t)}catch{K(t)}}}queue(e){var t;K({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:le(),attachments:void 0})}async signIn(){let e=de(64),t=await Ve(e),o=de(16),r=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,i=window.open(r,"daybook-feedback","width=460,height=640");if(!i)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,p)=>{let h=setInterval(()=>{i.closed&&(f(),p(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),d=w=>{if(w.origin!==new URL(this.base()).origin)return;let y=w.data;if((y==null?void 0:y.source)==="daybook-feedback"&&y.state===o){if(f(),y.error||!y.code){p(Object.assign(new Error("Sign-in was refused"),{code:y.error||"refused"}));return}l(y.code)}},f=()=>{clearInterval(h),window.removeEventListener("message",d)};window.addEventListener("message",d)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await C(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await C(t);let o=await t.json();return this.session=(i=o.sessionToken)!=null?i:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await C(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function We(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function K(n){let e=pe();e.push(n),he(e.slice(-20))}function pe(){try{let n=localStorage.getItem(W);return n?JSON.parse(n):[]}catch{return[]}}function he(n){try{n.length===0?localStorage.removeItem(W):localStorage.setItem(W,JSON.stringify(n))}catch{}}async function C(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function le(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function de(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function Ve(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function V(n){var o,r;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:Je(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(o=window.devicePixelRatio)!=null?o:1},device:Ye()};document.referrer&&(e.referrer=S(document.referrer)),n.app&&(e.app=n.app);let t=(r=n.anchors)!=null?r:[];return t[0]&&(e.anchor=t[0]),t.length>1&&(e.anchors=t),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function Ye(){var r;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(r=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:r[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function Je(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function fe(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?et():()=>{},o=e(),r=null;try{return r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),r.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await Ge(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var ue=1920,Qe=.82;async function Ge(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,r=t>ue?ue/t:1,i=document.createElement("canvas");i.width=Math.round(t*r),i.height=Math.round(o*r);let s=i.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,i.width,i.height),e.pause(),e.srcObject=null;let a=await Ze(i);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function Ze(n){for(let e of["image/webp","image/jpeg"]){let t=await me(n,e,Qe);if((t==null?void 0:t.type)===e)return t}return me(n,"image/png")}function me(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function et(){let n=[...document.querySelectorAll(`[${A}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var r;t.style.filter=(r=e[o])!=null?r:""})}}var J=4e5,ge=300,be=600,ye=8e3,tt=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),nt=["display","position","z-index","opacity","visibility","overflow","width","height","margin","padding","box-sizing","color","background-color","border","border-radius","box-shadow","font-family","font-size","font-weight","line-height","text-align","white-space","flex-direction","justify-content","align-items","gap","grid-template-columns","transform","transition","pointer-events","cursor"],ot="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last because only the head of this file is inlined beside the report \u2014 download the attachment for the rest of it.";function Q(n){let e=[],t=n;for(let o=0;t&&o<4&&t.nodeType===1;o+=1){let r=t.localName;if(t.id){e.unshift(`${r}#${t.id}`);break}let i=Array.from(t.classList).slice(0,3).join(".");i&&(r+=`.${i}`),e.unshift(r),t=t.parentElement}return e.join(" > ")}var rt=(n,e)=>e.length>ge?`${e.slice(0,ge)}\u2026[${e.length}]`:e,Y=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function it(n,e){let t=n;if(n.localName==="input"&&(t.type==="checkbox"||t.type==="radio"))return t.checked?"checked":"unchecked";let o=t.value;return typeof o!="string"||o===""?null:e?se(o,t.name||t.id||t.type):o}function ve(n,e,t,o){var p,h;if(t.used>J)return!1;if(n.nodeType===3){let d=((p=n.textContent)!=null?p:"").replace(/\s+/g," ");if(!d.trim())return!0;let f=d.length>be?`${d.slice(0,be)}\u2026`:d;return e.push(Y(f)),t.used+=f.length,!0}if(n.nodeType!==1)return!0;let r=n,i=r.tagName;if(r.hasAttribute("data-daybook-feedback")||tt.has(i))return!0;let s=r.localName;if(o&&r.hasAttribute(A))return e.push(`<${s} ${A}>[withheld]</${s}>`),t.used+=32,!0;let a=[];for(let d of Array.from(r.attributes))d.name!=="value"&&a.push(`${d.name}="${Y(rt(d.name,d.value))}"`);let c=it(r,o);c!==null&&a.push(`value="${Y(c)}"`);let l=a.length>0?`<${s} ${a.join(" ")}>`:`<${s}>`;if(e.push(l),t.used+=l.length,s==="style"){let d=(h=r.textContent)!=null?h:"",f=d.length>ye?`${d.slice(0,ye)}
2
+ /* \u2026${d.length} chars */`:d;e.push(f),t.used+=f.length}else for(let d of Array.from(r.childNodes))if(!ve(d,e,t,o))break;return e.push(`</${s}>`),t.used+=s.length+3,t.used<=J}function st(){var e,t;let n=[];for(let o of Array.from((t=(e=document.body)==null?void 0:e.querySelectorAll("*"))!=null?t:[]).slice(0,4e3)){let r=getComputedStyle(o);if(r.position!=="fixed"&&r.position!=="sticky"||r.visibility==="hidden"||r.display==="none"||Number(r.opacity)===0)continue;let i=o.getBoundingClientRect();if(!(i.width<4||i.height<4)&&!o.closest("[data-daybook-feedback]")&&(n.push({selector:Q(o),zIndex:r.zIndex,rect:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)}}),n.length>=20))break}return n}function we(n){if(!(n!=null&&n.selector))return;let e=null;try{e=document.querySelector(n.selector)}catch{return}if(!e)return;let t=[];for(let o=e;o&&t.length<5;o=o.parentElement){let r=getComputedStyle(o),i={};for(let s of nt){let a=r.getPropertyValue(s);a&&(i[s]=a)}t.push({selector:Q(o),computed:i})}return{selector:n.selector,path:t}}function at(){return Array.from(document.styleSheets).slice(0,40).map(n=>{try{return{href:n.href,rules:n.cssRules.length}}catch{return{href:n.href,rules:"unreadable"}}})}function xe(n,e){var o;let t=n==null?[]:Array.isArray(n)?n:[n];try{let r=[],i={used:0};return ve(document.documentElement,r,i,e),{note:ot,capturedAtUtc:new Date().toISOString(),url:location.href,title:document.title,redacted:e,truncated:i.used>J,scroll:{x:Math.round(window.scrollX),y:Math.round(window.scrollY)},focus:document.activeElement&&document.activeElement!==document.body?Q(document.activeElement):null,anchor:we((o=t[0])!=null?o:null),anchors:t.length>1?t.map(s=>we(s)).filter(s=>!!s):void 0,layers:st(),stylesheets:at(),html:r.join("")}}catch{return null}}function P(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:H(n/window.innerWidth),offsetY:H(e/window.innerHeight),elementText:null,page:ke()};let o=t.getBoundingClientRect();return{selector:ct(t),offsetX:o.width>0?H((n-o.left)/o.width):0,offsetY:o.height>0?H((e-o.top)/o.height):0,elementText:pt(t),page:ke()}}function Ee(n){if(!n.selector)return{x:n.offsetX*window.innerWidth,y:n.offsetY*window.innerHeight};let e=null;try{e=document.querySelector(n.selector)}catch{return null}if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+n.offsetX*t.width,y:t.top+n.offsetY*t.height}}function ct(n){if(n===document.body)return"body";for(let r of["data-testid","data-test","data-daybook-id","data-cy"]){let i=n.getAttribute(r);if(i){let s=`[${r}="${$(i)}"]`;if(T(s))return s}}if(n.id&&!G(n.id)){let r=`#${$(n.id)}`;if(T(r))return r}let e=[],t=n;for(;t&&t!==document.body&&e.length<8;){let r=t.tagName.toLowerCase(),i=Array.from(t.classList).filter(c=>!G(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${$(c)}`).join(""));let s=t.parentElement;if(s){let c=Array.from(s.children).filter(l=>l.tagName===t.tagName);c.length>1&&(r+=`:nth-of-type(${c.indexOf(t)+1})`)}e.unshift(r);let a=e.join(" > ");if(T(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&T(o)?o:lt(n)}function lt(n){let e=[],t=n;for(;t&&t!==document.body&&t!==document.documentElement;){let r=dt(t);if(r&&t!==n){e.unshift(r);break}let i=t.parentElement;if(!i)break;e.unshift(`${t.tagName.toLowerCase()}:nth-child(${Array.from(i.children).indexOf(t)+1})`),t=i}t===document.body&&e.unshift("body");let o=e.join(" > ");return o&&T(o)?o:null}function dt(n){for(let e of["data-testid","data-test","data-daybook-id","data-cy"]){let t=n.getAttribute(e);if(t){let o=`[${e}="${$(t)}"]`;if(T(o))return o}}if(n.id&&!G(n.id)){let e=`#${$(n.id)}`;if(T(e))return e}return null}function T(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function G(n){return/^[a-z]{1,3}[0-9a-f]{5,}$/i.test(n)||/--[0-9a-f]{5,}$/i.test(n)||/^_[0-9a-z]{5,}/i.test(n)||/^v-[0-9a-f]{6,}$/i.test(n)||/^ng-/.test(n)||/[0-9a-f]{8,}/i.test(n)}function pt(n){var o,r,i;let t=((r=(o=n.innerText)!=null?o:n.textContent)!=null?r:"").replace(/\s+/g," ").trim();if(!t){let s=(i=n.getAttribute("aria-label"))!=null?i:n.getAttribute("title");return(s==null?void 0:s.trim())||null}return t.length>80?`${t.slice(0,77)}\u2026`:t}function ke(){return location.pathname+location.search}function H(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function $(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var ht=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function Te(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=ht.test(o.type)?o.size>26214400?`Too large (${(o.size/1048576).toFixed(1)} MB, max 25).`:null:"Only images and short videos.";t.push({blob:o,filename:o.name||`pasted-${t.length+1}.${ut(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function Se(n){var o;let e=(o=n.clipboardData)==null?void 0:o.items;if(!e)return[];let t=[];for(let r of e){if(r.kind!=="file")continue;let i=r.getAsFile();i&&t.push(i)}return t}function I(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function ut(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function Le(n){var o;let t=(o=(typeof n.composedPath=="function"?n.composedPath():[])[0])!=null?o:n.target;return!t||t.nodeType!==1?!1:/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)?!0:typeof t.closest=="function"&&t.closest('[contenteditable=""], [contenteditable="true"]')!==null}function mt(n,e,t){let o=0;for(let s of e){if(s.right<=n.left||s.left>=n.right)continue;let a=n.v==="bottom"?t.height-s.top:s.bottom;a>o&&(o=a)}if(o===0)return 0;let r=n.v==="bottom"?t.height-n.bottom:n.top,i=Math.round(o+12-r);return i<=0||i>t.height*.35?0:i}function ft(n,e,t){if(n===e||e.contains(n)||n.contains(e)||n===document.body||n===document.documentElement)return!1;let o=getComputedStyle(n);if(o.position!=="fixed"&&o.position!=="sticky"||o.visibility==="hidden"||o.display==="none"||Number(o.opacity)===0)return!1;let r=n.getBoundingClientRect();return!(r.width<8||r.height<8||r.width*r.height>t.width*t.height*.25)}function gt(n,e,t){if(typeof document.elementsFromPoint!="function")return[];let o=new Map,r=[];for(let s=n.left+4;s<n.right;s+=32)r.push(s);r.push(n.right-4);let i=t.height*.35;for(let s=0;s<=i;s+=32){let a=n.v==="bottom"?n.bottom-s:n.top+s;if(a<0||a>t.height)break;for(let c of r)if(!(c<0||c>t.width))for(let l of document.elementsFromPoint(c,a)){if(o.has(l)||!ft(l,e,t))continue;let p=l.getBoundingClientRect();o.set(l,{top:p.top,bottom:p.bottom,left:p.left,right:p.right})}}return[...o.values()]}function _e(n,e){let t={width:window.innerWidth,height:window.innerHeight};return mt(n,gt(n,e,t),t)}var O=class{constructor(e,t){this.options=e;this.onSubmit=t;this.mode="idle";this.pins=[];this.cancelAdding=null;this.unmark=null;this.detach=[];this.buttonStyle="pill";this.clearance=0;this.state="ready";this.policy=null;this.redrawMarks=null;this.dragged=null;this.reference=null;this.uploadsFailed=0;this.host=document.createElement("div"),this.host.setAttribute("data-daybook-feedback",""),this.host.style.cssText="position:fixed;inset:0;z-index:2147483000;pointer-events:none",this.root=this.host.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${Oe}</style><style id="theme"></style><style id="place"></style><div id="layer"></div>`}setTheme(e){let t=this.root.getElementById("theme");if(t){if(!e){t.textContent="";return}t.textContent=Re(e),this.buttonStyle=He(e),this.themePlacement=e.position,this.applyPlacement(),this.launcherLabel=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):void 0}}get placement(){var e,t;return(t=(e=this.options.placement)!=null?e:this.themePlacement)!=null?t:"bottom-right"}applyPlacement(){let e=this.root.getElementById("place");if(!e)return;let t=this.placement,o=t.startsWith("bottom")?"bottom":"top",r=t.endsWith("right")?"right":"left",i=b+this.clearance;e.textContent=`:host {
3
+ --pm-${r}: ${b}px; --pm-${r==="right"?"left":"right"}: auto;
4
4
  --pm-${o}: ${i}px; --pm-${o==="bottom"?"top":"bottom"}: auto;
5
- }`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-g:g+t,i=e.startsWith("bottom")?window.innerHeight-g:g+o;return{left:r-t,right:r,top:i-o,bottom:i,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle")try{let i=ke(this.homeSlot(),this.host);if(Math.abs(i-this.clearance)<4)return;this.clearance=i,this.applyPlacement()}catch{}},o=typeof requestAnimationFrame=="function"?i=>requestAnimationFrame(i):i=>setTimeout(i,16),r=()=>{e||(e=!0,o(t))};if(window.addEventListener("scroll",r,{passive:!0,capture:!0}),window.addEventListener("resize",r),this.detach.push(()=>{window.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r)}),typeof MutationObserver=="function"){let i=new MutationObserver(r);i.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]}),this.detach.push(()=>i.disconnect())}r()}setState(e){this.state=e,this.host.isConnected&&this.render()}mount(){var e;if(document.body.appendChild(this.host),this.applyPlacement(),this.render(),this.watchClearance(),this.options.hotkey!==null){let t=((e=this.options.hotkey)!=null?e:"f").toLowerCase(),o=r=>{if(r.key==="Escape"){this.mode==="picking"&&(this.mode="idle",this.anchor=null,this.dragged=null,this.render());return}r.metaKey||r.ctrlKey||r.altKey||xe(r)||this.mode!=="composing"&&r.key.toLowerCase()===t&&(this.mode=this.mode==="picking"?"idle":"picking",this.render())};window.addEventListener("keydown",o),this.detach.push(()=>window.removeEventListener("keydown",o))}}unmount(){for(let e of this.detach.splice(0))e();this.host.remove()}open(){this.mode="picking",this.render()}setReporter(e){this.reporter=e}setPolicy(e){this.policy=e}capture(){var t,o;let e=(t=this.options.screenshots)!=null?t:!0;return e===!1||((o=this.policy)==null?void 0:o.screenshots)===!1?{offered:!1,checked:!1}:{offered:!0,checked:e!=="optional"}}conceal(){let e=this.root.getElementById("layer"),t=e.style.visibility;e.style.visibility="hidden";let o=this.ringAnchor();return()=>{e.style.visibility=t,o==null||o.remove()}}ringAnchor(){var i;let e=(i=this.anchor)==null?void 0:i.selector;if(!e)return null;let t=null;try{t=document.querySelector(e)}catch{return null}if(!t)return null;let o=t.getBoundingClientRect();if(o.width<1||o.height<1)return null;let r=document.createElement("div");return r.className="ring",r.style.left=`${o.left-R}px`,r.style.top=`${o.top-R}px`,r.style.width=`${o.width+R*2}px`,r.style.height=`${o.height+R*2}px`,this.root.appendChild(r),r}movable(e,t){this.place(e),t.classList.add("drag"),t.title="Drag to move \xB7 double-click to reset",t.addEventListener("dblclick",()=>{this.dragged=null,this.place(e)}),t.addEventListener("pointerdown",o=>{if(o.target.closest("button")||o.button!==0)return;o.preventDefault();let r=e.getBoundingClientRect(),i=o.clientX-r.left,s=o.clientY-r.top;t.setPointerCapture(o.pointerId),e.classList.add("panel--dragging");let a=l=>{let u=C(l.clientX-i,g-r.width+K,window.innerWidth-K),h=C(l.clientY-s,0,window.innerHeight-K);e.style.left=`${u}px`,e.style.top=`${h}px`,e.style.right="auto",e.style.bottom="auto"},c=()=>{t.releasePointerCapture(o.pointerId),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),e.classList.remove("panel--dragging"),this.dragged=dt(e.getBoundingClientRect()),this.place(e)};t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c)})}place(e){let t=this.dragged;if(!t){e.style.left=e.style.right=e.style.top=e.style.bottom="";return}let o=e.offsetWidth||380,r=e.offsetHeight||240,i=C(t.dx,g,Math.max(g,window.innerWidth-o-g)),s=C(t.dy,g,Math.max(g,window.innerHeight-r-g));e.style.left=t.h==="left"?`${i}px`:"auto",e.style.right=t.h==="right"?`${i}px`:"auto",e.style.top=t.v==="top"?`${s}px`:"auto",e.style.bottom=t.v==="bottom"?`${s}px`:"auto"}render(){let e=this.root.getElementById("layer");if(e.innerHTML="",this.mode==="idle"){e.appendChild(this.state==="pending"?this.pending():this.launcher());return}if(this.mode==="sent"){this.dragged=null,e.appendChild(this.sent());return}if(this.mode==="picking"){e.appendChild(this.picker());return}let t=this.composer();e.appendChild(t),this.place(t)}pending(){let e=document.createElement("div");return e.className="launcher launcher--pending",e.setAttribute("role","status"),e.textContent="Feedback access pending approval",e}sent(){var c;let e=document.createElement("div");e.className="panel panel--sent",e.setAttribute("role","status");let t=this.reference,o=this.uploadsFailed;e.innerHTML=`
5
+ }`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-b:b+t,i=e.startsWith("bottom")?window.innerHeight-b:b+o;return{left:r-t,right:r,top:i-o,bottom:i,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle")try{let i=_e(this.homeSlot(),this.host);if(Math.abs(i-this.clearance)<4)return;this.clearance=i,this.applyPlacement()}catch{}},o=typeof requestAnimationFrame=="function"?i=>requestAnimationFrame(i):i=>setTimeout(i,16),r=()=>{e||(e=!0,o(t))};if(window.addEventListener("scroll",r,{passive:!0,capture:!0}),window.addEventListener("resize",r),this.detach.push(()=>{window.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r)}),typeof MutationObserver=="function"){let i=new MutationObserver(r);i.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]}),this.detach.push(()=>i.disconnect())}r()}setState(e){this.state=e,this.host.isConnected&&this.render()}mount(){var e;if(document.body.appendChild(this.host),this.applyPlacement(),this.render(),this.watchClearance(),this.options.hotkey!==null){let t=((e=this.options.hotkey)!=null?e:"f").toLowerCase(),o=r=>{if(r.key==="Escape"&&this.cancelAdding){this.cancelAdding();return}if(r.key==="Escape"){this.mode==="picking"&&(this.mode="idle",this.pins=[],this.dragged=null,this.render());return}r.metaKey||r.ctrlKey||r.altKey||Le(r)||this.mode!=="composing"&&r.key.toLowerCase()===t&&(this.mode=this.mode==="picking"?"idle":"picking",this.render())};window.addEventListener("keydown",o),this.detach.push(()=>window.removeEventListener("keydown",o))}}unmount(){for(let e of this.detach.splice(0))e();this.host.remove()}open(){this.mode="picking",this.render()}setReporter(e){this.reporter=e}setPolicy(e){this.policy=e}capture(){var t,o;let e=(t=this.options.screenshots)!=null?t:!0;return e===!1||((o=this.policy)==null?void 0:o.screenshots)===!1?{offered:!1,checked:!1}:{offered:!0,checked:e!=="optional"}}conceal(){let e=this.root.getElementById("layer"),t=e.style.visibility;e.style.visibility="hidden";let o=this.ringPins();return()=>{e.style.visibility=t,o.forEach(r=>r.remove())}}ringPins(){let e=this.pins.length>1;return this.pins.flatMap((t,o)=>{let r=this.pinRect(t);if(!r)return[];let i=this.origin(),s=document.createElement("div");if(s.className="ring",s.style.left=`${r.left-i.left-k}px`,s.style.top=`${r.top-i.top-k}px`,s.style.width=`${r.width+k*2}px`,s.style.height=`${r.height+k*2}px`,e){let a=document.createElement("span");a.className="ring__n",a.textContent=String(o+1),s.appendChild(a)}return this.root.appendChild(s),[s]})}pinRect(e){var o,r;if(((o=e.anchor.page)!=null?o:Ae())!==Ae())return null;let t=(r=e.element)!=null&&r.isConnected?e.element:null;if(!t&&e.anchor.selector&&e.anchor.selector!=="body")try{t=document.querySelector(e.anchor.selector)}catch{t=null}if(t){let i=t.getBoundingClientRect();if(i.width>=1&&i.height>=1)return{left:i.left,top:i.top,width:i.width,height:i.height}}return{left:e.box.left-window.scrollX,top:e.box.top-window.scrollY,width:e.box.width,height:e.box.height}}origin(){let e=this.host.getBoundingClientRect();return{left:e.left,top:e.top}}markPins(e){var s;(s=this.unmark)==null||s.call(this);let t=document.createElement("div");e.appendChild(t);let o=0,r=()=>{if(o=0,t.innerHTML="",this.pins.length<1)return;let a=this.origin();this.pins.forEach((c,l)=>{let p=this.pinRect(c);if(!p)return;let h=document.createElement("div");h.className="marker",h.style.left=`${p.left-a.left-k}px`,h.style.top=`${p.top-a.top-k}px`,h.style.width=`${p.width+k*2}px`,h.style.height=`${p.height+k*2}px`;let d=document.createElement("span");d.className="marker__n",d.textContent=String(l+1),h.appendChild(d),t.appendChild(h)})},i=()=>{o||(o=requestAnimationFrame(r))};window.addEventListener("scroll",i,{capture:!0,passive:!0}),window.addEventListener("resize",i),r(),this.redrawMarks=r,this.unmark=()=>{o&&cancelAnimationFrame(o),window.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("resize",i),t.remove(),this.redrawMarks=null,this.unmark=null}}pickAnother(e,t){let o=this.root.getElementById("layer"),r=()=>{var s;i.remove(),e.style.visibility="",this.cancelAdding=null,(s=this.redrawMarks)==null||s.call(this)},i=this.picker(s=>{this.pins.push(s),r(),t()},`Click what else is involved (pin ${this.pins.length+1})`);e.style.visibility="hidden",this.cancelAdding=r,o.appendChild(i)}movable(e,t){this.place(e),t.classList.add("drag"),t.title="Drag to move \xB7 double-click to reset",t.addEventListener("dblclick",()=>{this.dragged=null,this.place(e)}),t.addEventListener("pointerdown",o=>{if(o.target.closest("button")||o.button!==0)return;o.preventDefault();let r=e.getBoundingClientRect(),i=o.clientX-r.left,s=o.clientY-r.top;t.setPointerCapture(o.pointerId),e.classList.add("panel--dragging");let a=l=>{let p=F(l.clientX-i,b-r.width+Z,window.innerWidth-Z),h=F(l.clientY-s,0,window.innerHeight-Z);e.style.left=`${p}px`,e.style.top=`${h}px`,e.style.right="auto",e.style.bottom="auto"},c=()=>{t.releasePointerCapture(o.pointerId),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),e.classList.remove("panel--dragging"),this.dragged=xt(e.getBoundingClientRect()),this.place(e)};t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c)})}place(e){let t=this.dragged;if(!t){e.style.left=e.style.right=e.style.top=e.style.bottom="";return}let o=e.offsetWidth||380,r=e.offsetHeight||240,i=F(t.dx,b,Math.max(b,window.innerWidth-o-b)),s=F(t.dy,b,Math.max(b,window.innerHeight-r-b));e.style.left=t.h==="left"?`${i}px`:"auto",e.style.right=t.h==="right"?`${i}px`:"auto",e.style.top=t.v==="top"?`${s}px`:"auto",e.style.bottom=t.v==="bottom"?`${s}px`:"auto"}render(){var o;let e=this.root.getElementById("layer");if((o=this.unmark)==null||o.call(this),this.cancelAdding=null,e.innerHTML="",this.mode==="idle"){e.appendChild(this.state==="pending"?this.pending():this.launcher());return}if(this.mode==="sent"){this.dragged=null,e.appendChild(this.sent());return}if(this.mode==="picking"){e.appendChild(this.picker());return}let t=this.composer();e.appendChild(t),this.place(t),this.markPins(e)}pending(){let e=document.createElement("div");return e.className="launcher launcher--pending",e.setAttribute("role","status"),e.textContent="Feedback access pending approval",e}sent(){var c;let e=document.createElement("div");e.className="panel panel--sent",e.setAttribute("role","status");let t=this.reference,o=this.uploadsFailed;e.innerHTML=`
6
6
  <div class="sent__tick" aria-hidden="true">&check;</div>
7
7
  <div class="sent__body">
8
8
  <div class="panel__title">Thank you \u2014 that is on its way.</div>
9
9
  ${t?`<div class="sent__ref">
10
- <code class="sent__id">${W(t)}</code>
10
+ <code class="sent__id">${B(t)}</code>
11
11
  <button type="button" class="sent__copy" data-copy>Copy</button>
12
12
  </div>
13
13
  <div class="panel__anchor">Quote it if you follow it up.</div>`:""}
14
14
  ${o>0?`<div class="sent__warn">${o===1?"One attachment could not be uploaded.":`${o} attachments could not be uploaded.`} The report was filed without it.</div>`:""}
15
15
  </div>
16
- ${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">&times;</button>':""}`;let r=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},i=window.setTimeout(r,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(i);if(this.detach.push(()=>window.clearTimeout(i)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",r);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await lt(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=Le(this.buttonStyle,(t=this.launcherLabel)!=null?t:"Feedback");return e.title=this.options.hotkey===null?"Report a problem":`Report a problem (${((o=this.options.hotkey)!=null?o:"f").toUpperCase()})`,e.onclick=()=>{this.mode="picking",this.render()},e}picker(){let e=document.createElement("div");return e.className="mask",e.innerHTML='<div class="hint">Click the thing that is wrong \xB7 <kbd>Esc</kbd> to cancel</div>',e.onclick=t=>{e.style.pointerEvents="none",this.anchor=$(t.clientX,t.clientY),e.style.pointerEvents="",this.mode="composing",this.render()},e}composer(){var J,Q,G,Z,ee;let e=document.createElement("div");e.className="panel";let t=(J=this.anchor)!=null&&J.elementText?`on \u201C${this.anchor.elementText}\u201D`:(Q=this.anchor)!=null&&Q.selector?`on ${this.anchor.selector}`:"on this page",o=this.capture();e.innerHTML=`
16
+ ${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">&times;</button>':""}`;let r=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},i=window.setTimeout(r,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(i);if(this.detach.push(()=>window.clearTimeout(i)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",r);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await yt(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=Pe(this.buttonStyle,(t=this.launcherLabel)!=null?t:"Feedback");return e.title=this.options.hotkey===null?"Report a problem":`Report a problem (${((o=this.options.hotkey)!=null?o:"f").toUpperCase()})`,e.onclick=()=>{this.mode="picking",this.render()},e}picker(e,t="Click the thing that is wrong"){let o=document.createElement("div");o.className="mask",o.innerHTML=`<div class="hover" hidden></div><div class="hint">${B(t)} \xB7 <kbd>Esc</kbd> to cancel</div>`;let r=o.querySelector(".hover"),i=(a,c)=>{o.style.pointerEvents="none";let l=document.elementFromPoint(a,c);return o.style.pointerEvents="",l},s=0;return o.onmousemove=a=>{if(s)return;let{clientX:c,clientY:l}=a;s=requestAnimationFrame(()=>{s=0;let p=i(c,l);if(!p||p===document.body||p===document.documentElement){r.hidden=!0;return}let h=p.getBoundingClientRect(),d=this.origin();r.hidden=!1,r.style.left=`${h.left-d.left}px`,r.style.top=`${h.top-d.top}px`,r.style.width=`${h.width}px`,r.style.height=`${h.height}px`})},o.onclick=a=>{o.style.pointerEvents="none";let c=vt(a.clientX,a.clientY);if(o.style.pointerEvents="",e){e(c);return}this.pins=[c],this.mode="composing",this.render()},o}composer(){var ne,oe,re;let e=document.createElement("div");e.className="panel";let t=$e(this.pins),o=this.capture();e.innerHTML=`
17
17
  <div class="panel__head" id="head">
18
18
  <span class="panel__grip" aria-hidden="true">\u283F</span>
19
19
  <div class="panel__heading">
20
- <div class="panel__anchor">${W(t)}</div>
20
+ <div class="panel__anchor">${B(t)}</div>
21
21
  <div class="panel__title">Report a problem</div>
22
22
  </div>
23
23
  <button id="close" class="panel__close" aria-label="Close">&times;</button>
24
24
  </div>
25
25
 
26
+ <!-- The pins, when there is more than one to tell apart, and the way to add one. -->
27
+ <div id="pins" class="pins"></div>
28
+
26
29
  <textarea id="message" rows="5" placeholder="What happened?"></textarea>
27
30
 
28
31
  <!--
@@ -31,7 +34,7 @@
31
34
  what somebody came here to do is type.
32
35
  -->
33
36
  <div class="panel__kinds">
34
- ${["bug","idea","praise","question"].map((p,f)=>`<button class="kind${f===0?" kind--on":""}" data-kind="${p}">${p}</button>`).join("")}
37
+ ${["bug","idea","praise","question"].map((u,m)=>`<button class="kind${m===0?" kind--on":""}" data-kind="${u}">${u}</button>`).join("")}
35
38
  </div>
36
39
 
37
40
  <input id="email" type="email" placeholder="Email (optional, so we can reply)" autocomplete="email" />
@@ -57,7 +60,7 @@
57
60
  <span class="panel__note">Sends this page's contents, your browser, and recent errors.</span>
58
61
  <button id="cancel" class="ghost">Cancel</button>
59
62
  <button id="send" class="primary">Send</button>
60
- </div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((p,f)=>{var te;let w=document.createElement("div");w.className=p.error?"file file--bad":"file",w.innerHTML=p.preview?`<img src="${p.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let F=document.createElement("span");F.className="file__name",F.textContent=(te=p.error)!=null?te:p.filename,w.appendChild(F);let E=document.createElement("button");E.className="link",E.textContent="\xD7",E.onclick=()=>{M([p]),r.splice(f,1),c()},w.appendChild(E),i.appendChild(w)}),s.style.display=r.length>=5?"none":""},l=p=>{r.push(...we(p,r.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",p=>{let f=ve(p);f.length>0&&(p.preventDefault(),l(f))}),s.addEventListener("dragover",p=>{p.preventDefault(),s.classList.add("drop--over")}),s.addEventListener("dragleave",()=>s.classList.remove("drop--over")),s.addEventListener("drop",p=>{var f,w;p.preventDefault(),s.classList.remove("drop--over"),l(Array.from((w=(f=p.dataTransfer)==null?void 0:f.files)!=null?w:[]))});let u="bug";e.querySelectorAll(".kind").forEach(p=>{p.onclick=()=>{var f;u=(f=p.dataset.kind)!=null?f:"bug",e.querySelectorAll(".kind").forEach(w=>w.classList.remove("kind--on")),p.classList.add("kind--on")}});let h=e.querySelector("#message"),d=e.querySelector("#email"),m=(ee=(G=this.reporter)==null?void 0:G.email)!=null?ee:(Z=this.options.reporter)==null?void 0:Z.email;m&&!d.value&&(d.value=m);let y=e.querySelector("#shot"),b=e.querySelector("#status"),v=e.querySelector("#send"),V=()=>{M(r),this.mode="idle",this.anchor=null,this.dragged=null,this.render()};e.querySelector("#cancel").onclick=V,e.querySelector("#close").onclick=V;let Y=async()=>{var p;if(!h.value.trim()){b.textContent="Say what happened first.";return}v.disabled=!0,b.textContent="Sending\u2026";try{let f=await this.onSubmit({message:h.value.trim(),kind:u,email:d.value.trim()||void 0,anchor:this.anchor,withScreenshot:(p=y==null?void 0:y.checked)!=null?p:!1,files:r.filter(w=>!w.error)});this.reference=f.reference,this.uploadsFailed=f.uploadsFailed,M(r),this.mode="sent",this.anchor=null,this.render()}catch(f){v.disabled=!1,b.textContent=f instanceof Error?`${f.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return v.onclick=Y,h.onkeydown=p=>{(p.metaKey||p.ctrlKey)&&p.key==="Enter"&&Y()},setTimeout(()=>h.focus(),0),this.contain(e),this.movable(e,e.querySelector("#head")),e}contain(e){for(let t of["pointerdown","mousedown","click"])e.addEventListener(t,o=>o.stopPropagation())}};async function lt(n){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(n),!0}catch{}let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0",document.body.appendChild(e);try{return e.select(),document.execCommand("copy")}catch{return!1}finally{e.remove()}}var g=16,R=3,K=56;function dt(n){let e={left:n.left,right:window.innerWidth-n.right,top:n.top,bottom:window.innerHeight-n.bottom},t=Object.keys(e).reduce((i,s)=>e[s]<e[i]?s:i),o=t==="left"||t==="right"?t:e.left<=e.right?"left":"right",r=t==="top"||t==="bottom"?t:e.top<=e.bottom?"top":"bottom";return{h:o,v:r,dx:t===o?g:Math.max(g,Math.round(e[o])),dy:t===r?g:Math.max(g,Math.round(e[r]))}}function C(n,e,t){return Math.min(Math.max(n,e),t)}function W(n){return n.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function pt(n){return typeof n=="string"&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%/]+\)|hsla?\([\d\s.,%/deg]+\)|[a-z]{3,20})$/i.test(n.trim())}var Ee='<svg class="launcher__icon" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M2 6.2C2 4.4 3.4 3 5.2 3h5.6C12.6 3 14 4.4 14 6.2v2.6c0 1.8-1.4 3.2-3.2 3.2H7l-3 2.4v-2.5A3.2 3.2 0 0 1 2 8.8V6.2Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>';function Te(n){var o;let e=[];pt(n.accent)&&e.push(`--pm-accent: ${n.accent}`);let t={none:"0",sm:"6px",md:"12px",lg:"18px"}[(o=n.cornerRadius)!=null?o:"md"];return t&&e.push(`--pm-radius: ${t}`),n.colorScheme==="dark"?e.push($e):n.colorScheme==="light"&&e.push(Ae),e.length>0?`:host { ${e.join("; ")} }`:""}var Se=n=>ut.includes(n.buttonStyle)?n.buttonStyle:"pill";function Le(n,e){let t=document.createElement("button");return t.className=`launcher launcher--${n}`,n==="icon"?(t.innerHTML=Ee,t.setAttribute("aria-label",e)):n==="pill-icon"?t.innerHTML=`${Ee}<span>${W(e)}</span>`:t.textContent=e,t}function _e(n,e={}){var i;let t=(i=n.shadowRoot)!=null?i:n.attachShadow({mode:"open"}),o=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):"Feedback";t.innerHTML=`<style>${Me}</style><style>${Te(e)}</style>`;let r=Le(Se(e),o);r.classList.add("launcher--preview"),r.disabled=!0,t.appendChild(r)}var ut=["pill","pill-icon","icon","text","outline"],Ae="--pm-surface: #fff; --pm-ink: #171717; --pm-muted: #525252; --pm-faint: #a3a3a3; --pm-line: #e5e5e5; --pm-line-strong: #d4d4d4; --pm-sunken: #f5f5f5; --pm-kbd: #404040; --pm-warn: #b45309; --pm-good: #047857; --pm-good-bg: #ecfdf5; --pm-good-line: #a7f3d0; --pm-accent: #171717; --pm-on-accent: #fafafa;",$e="--pm-surface: #1c1c1c; --pm-ink: #fafafa; --pm-muted: #a3a3a3; --pm-faint: #737373; --pm-line: #333; --pm-line-strong: #454545; --pm-sunken: #262626; --pm-kbd: #d4d4d4; --pm-warn: #fbbf24; --pm-good: #34d399; --pm-good-bg: #05271f; --pm-good-line: #065f46; --pm-accent: #fafafa; --pm-on-accent: #171717;",Me=`
63
+ </div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((u,m)=>{var E;let g=document.createElement("div");g.className=u.error?"file file--bad":"file",g.innerHTML=u.preview?`<img src="${u.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let v=document.createElement("span");v.className="file__name",v.textContent=(E=u.error)!=null?E:u.filename,g.appendChild(v);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{I([u]),r.splice(m,1),c()},g.appendChild(x),i.appendChild(g)}),s.style.display=r.length>=5?"none":""},l=u=>{r.push(...Te(u,r.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",u=>{let m=Se(u);m.length>0&&(u.preventDefault(),l(m))}),s.addEventListener("dragover",u=>{u.preventDefault(),s.classList.add("drop--over")}),s.addEventListener("dragleave",()=>s.classList.remove("drop--over")),s.addEventListener("drop",u=>{var m,g;u.preventDefault(),s.classList.remove("drop--over"),l(Array.from((g=(m=u.dataTransfer)==null?void 0:m.files)!=null?g:[]))});let p="bug";e.querySelectorAll(".kind").forEach(u=>{u.onclick=()=>{var m;p=(m=u.dataset.kind)!=null?m:"bug",e.querySelectorAll(".kind").forEach(g=>g.classList.remove("kind--on")),u.classList.add("kind--on")}});let h=e.querySelector("#pins"),d=e.querySelector(".panel__anchor"),f=()=>{var u;if(d.textContent=$e(this.pins),h.innerHTML="",this.pins.length>1&&this.pins.forEach((m,g)=>{var ie;let v=document.createElement("div");v.className="pin";let x=document.createElement("span");x.className="pin__n",x.textContent=String(g+1),v.appendChild(x);let E=document.createElement("span");E.className="pin__label",E.textContent=Ce(m.anchor),E.title=(ie=m.anchor.page)!=null?ie:"",v.appendChild(E);let _=document.createElement("button");_.className="link",_.textContent="\xD7",_.setAttribute("aria-label",`Remove pin ${g+1}`),_.onclick=()=>{this.pins.splice(g,1),f()},v.appendChild(_),h.appendChild(v)}),this.pins.length<wt){let m=document.createElement("button");m.className="link pins__add",m.id="add-pin",m.textContent=this.pins.length>0?"+ Add another pin":"+ Pin something on the page",m.onclick=()=>this.pickAnother(e,f),h.appendChild(m)}(u=this.redrawMarks)==null||u.call(this)};f();let w=e.querySelector("#message"),y=e.querySelector("#email"),L=(re=(ne=this.reporter)==null?void 0:ne.email)!=null?re:(oe=this.options.reporter)==null?void 0:oe.email;L&&!y.value&&(y.value=L);let q=e.querySelector("#shot"),N=e.querySelector("#status"),U=e.querySelector("#send"),ee=()=>{I(r),this.mode="idle",this.pins=[],this.dragged=null,this.render()};e.querySelector("#cancel").onclick=ee,e.querySelector("#close").onclick=ee;let te=async()=>{var u;if(!w.value.trim()){N.textContent="Say what happened first.";return}U.disabled=!0,N.textContent="Sending\u2026";try{let m=await this.onSubmit({message:w.value.trim(),kind:p,email:y.value.trim()||void 0,anchors:this.pins.map(g=>g.anchor),withScreenshot:(u=q==null?void 0:q.checked)!=null?u:!1,files:r.filter(g=>!g.error)});this.reference=m.reference,this.uploadsFailed=m.uploadsFailed,I(r),this.mode="sent",this.pins=[],this.render()}catch(m){U.disabled=!1,N.textContent=m instanceof Error?`${m.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return U.onclick=te,w.onkeydown=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&te()},setTimeout(()=>w.focus(),0),this.contain(e),this.movable(e,e.querySelector("#head")),e}contain(e){for(let t of["pointerdown","mousedown","click"])e.addEventListener(t,o=>o.stopPropagation())}};async function yt(n){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(n),!0}catch{}let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0",document.body.appendChild(e);try{return e.select(),document.execCommand("copy")}catch{return!1}finally{e.remove()}}var b=16,k=3,wt=10;function Ae(){return location.pathname+location.search}function vt(n,e){let t=P(n,e),o=document.elementFromPoint(n,e),r=o&&o!==document.body&&o!==document.documentElement?o:null,i=r==null?void 0:r.getBoundingClientRect(),s=i&&i.width>=1&&i.height>=1?{left:i.left+window.scrollX,top:i.top+window.scrollY,width:i.width,height:i.height}:{left:n-12+window.scrollX,top:e-12+window.scrollY,width:24,height:24};return{anchor:t,element:r,box:s}}function Ce(n){return n.elementText?`\u201C${n.elementText}\u201D`:n.selector&&n.selector!=="body"?n.selector:"a spot on the page"}function $e(n){if(n.length===0)return"on this page";let[e]=n;if(!e)return"on this page";let t=`on ${Ce(e.anchor)}`;return n.length===1?t:`${t} and ${n.length-1} more`}var Z=56;function xt(n){let e={left:n.left,right:window.innerWidth-n.right,top:n.top,bottom:window.innerHeight-n.bottom},t=Object.keys(e).reduce((i,s)=>e[s]<e[i]?s:i),o=t==="left"||t==="right"?t:e.left<=e.right?"left":"right",r=t==="top"||t==="bottom"?t:e.top<=e.bottom?"top":"bottom";return{h:o,v:r,dx:t===o?b:Math.max(b,Math.round(e[o])),dy:t===r?b:Math.max(b,Math.round(e[r]))}}function F(n,e,t){return Math.min(Math.max(n,e),t)}function B(n){return n.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function kt(n){return typeof n=="string"&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%/]+\)|hsla?\([\d\s.,%/deg]+\)|[a-z]{3,20})$/i.test(n.trim())}var Me='<svg class="launcher__icon" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M2 6.2C2 4.4 3.4 3 5.2 3h5.6C12.6 3 14 4.4 14 6.2v2.6c0 1.8-1.4 3.2-3.2 3.2H7l-3 2.4v-2.5A3.2 3.2 0 0 1 2 8.8V6.2Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>';function Re(n){var o;let e=[];kt(n.accent)&&e.push(`--pm-accent: ${n.accent}`);let t={none:"0",sm:"6px",md:"12px",lg:"18px"}[(o=n.cornerRadius)!=null?o:"md"];return t&&e.push(`--pm-radius: ${t}`),n.colorScheme==="dark"?e.push(Be):n.colorScheme==="light"&&e.push(Fe),e.length>0?`:host { ${e.join("; ")} }`:""}var He=n=>Et.includes(n.buttonStyle)?n.buttonStyle:"pill";function Pe(n,e){let t=document.createElement("button");return t.className=`launcher launcher--${n}`,n==="icon"?(t.innerHTML=Me,t.setAttribute("aria-label",e)):n==="pill-icon"?t.innerHTML=`${Me}<span>${B(e)}</span>`:t.textContent=e,t}function Ie(n,e={}){var i;let t=(i=n.shadowRoot)!=null?i:n.attachShadow({mode:"open"}),o=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):"Feedback";t.innerHTML=`<style>${Oe}</style><style>${Re(e)}</style>`;let r=Pe(He(e),o);r.classList.add("launcher--preview"),r.disabled=!0,t.appendChild(r)}var Et=["pill","pill-icon","icon","text","outline"],Fe="--pm-surface: #fff; --pm-ink: #171717; --pm-muted: #525252; --pm-faint: #a3a3a3; --pm-line: #e5e5e5; --pm-line-strong: #d4d4d4; --pm-sunken: #f5f5f5; --pm-kbd: #404040; --pm-warn: #b45309; --pm-good: #047857; --pm-good-bg: #ecfdf5; --pm-good-line: #a7f3d0; --pm-accent: #171717; --pm-on-accent: #fafafa;",Be="--pm-surface: #1c1c1c; --pm-ink: #fafafa; --pm-muted: #a3a3a3; --pm-faint: #737373; --pm-line: #333; --pm-line-strong: #454545; --pm-sunken: #262626; --pm-kbd: #d4d4d4; --pm-warn: #fbbf24; --pm-good: #34d399; --pm-good-bg: #05271f; --pm-good-line: #065f46; --pm-accent: #fafafa; --pm-on-accent: #171717;",Oe=`
61
64
  /*
62
65
  Every colour in this file is one of these, and there are two sets of them.
63
66
 
@@ -79,7 +82,7 @@
79
82
  :host {
80
83
  all: initial;
81
84
 
82
- ${Ae}
85
+ ${Fe}
83
86
 
84
87
  --pm-radius: 12px;
85
88
 
@@ -92,7 +95,7 @@
92
95
  }
93
96
 
94
97
  @media (prefers-color-scheme: dark) {
95
- :host { ${$e} }
98
+ :host { ${Be} }
96
99
  }
97
100
  }
98
101
  * { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif }
@@ -167,6 +170,22 @@
167
170
  border: 2px solid #ef4444;
168
171
  box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 0 0 5px rgba(239,68,68,.35);
169
172
  }
173
+ /* The number, on the ring's corner so it never covers what the ring is about. */
174
+ .ring__n, .marker__n {
175
+ position: absolute; top: -11px; left: -11px; min-width: 20px; height: 20px; padding: 0 5px;
176
+ border-radius: 10px; background: #ef4444; color: #fff; border: 2px solid #fff;
177
+ font: 600 11px/16px system-ui, sans-serif; text-align: center; box-sizing: border-box;
178
+ }
179
+ /* What a click would pin, while picking. Dashed, so it reads as "this one?" rather than "pinned". */
180
+ .hover {
181
+ position: fixed; pointer-events: none; border-radius: 3px;
182
+ outline: 2px dashed #ef4444; outline-offset: 2px; background: rgba(239,68,68,.06);
183
+ }
184
+ /* A pin already made, while the composer is open. */
185
+ .marker {
186
+ position: fixed; pointer-events: none; border-radius: 3px;
187
+ border: 2px solid #ef4444; box-shadow: 0 0 0 2px rgba(255,255,255,.85);
188
+ }
170
189
  /*
171
190
  Bottom, not top.
172
191
 
@@ -213,6 +232,14 @@ kbd {
213
232
  .sent__warn { margin-top: 6px; color: var(--pm-warn); font-size: 11px; line-height: 1.4 }
214
233
 
215
234
  /* The anchor leads: it is what the reporter pointed at, and the part they need to recognise. */
235
+ .pins { display: flex; flex-direction: column; gap: 4px; margin: 0 0 8px; }
236
+ .pin { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--pm-ink); }
237
+ .pin__n {
238
+ flex: none; min-width: 18px; height: 18px; border-radius: 9px; background: #ef4444; color: #fff;
239
+ font: 600 11px/18px system-ui, sans-serif; text-align: center;
240
+ }
241
+ .pin__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
242
+ .pins__add { align-self: flex-start; font-size: 12px; }
216
243
  .panel__anchor {
217
244
  color: var(--pm-muted); font-size: 11px;
218
245
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
@@ -257,6 +284,22 @@ textarea, input[type=email] {
257
284
  border-radius: 8px; font-size: 13px; resize: vertical; color: var(--pm-ink); background: var(--pm-surface);
258
285
  }
259
286
  textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset: -1px }
287
+
288
+ /*
289
+ * Sixteen pixels on a touch device, or iOS zooms the host page.
290
+ *
291
+ * Safari zooms in whenever a focused field's text is under 16px and never zooms back out. At 13px
292
+ * that happened the moment somebody tapped the message box \u2014 so the act of reporting a bug left
293
+ * the reporter's view of OUR CUSTOMER's site magnified and scrolled sideways, which is a rude
294
+ * thing for an embedded widget to do to the page hosting it.
295
+ *
296
+ * The widget cannot fix this with a viewport meta even if that were acceptable: the meta belongs
297
+ * to the host page and is not ours to touch. Making the text big enough is the only move
298
+ * available, and it is the right one anyway.
299
+ */
300
+ @media (pointer: coarse) {
301
+ textarea, input[type=email] { font-size: 16px }
302
+ }
260
303
  .shot { display: flex; align-items: center; gap: 6px; color: var(--pm-muted); font-size: 12px }
261
304
 
262
305
  /*
@@ -294,4 +337,4 @@ textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset:
294
337
  .file__icon { width: 28px; text-align: center }
295
338
  .file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
296
339
  .link { border: 0; background: transparent; color: var(--pm-muted); cursor: pointer; font-size: 11px; text-decoration: underline }
297
- `;var Re="https://api.daybook.team",I=class{constructor(e){this.options=e;this.widget=null;this.started=!1;this.inFlight=null;this.epoch=0;this.ready=null;this.stopped=!1;var t;if(!e.ingestKey)throw new Error("ingestKey is required");this.client=new L((t=e.apiUrl)!=null?t:Re,e.ingestKey),this.trail=e.breadcrumbs===!1?null:new T(40,e.redact!==!1)}start(){var e;return this.stopped=!1,(e=this.trail)==null||e.start(),this.mount(),this.started||(this.started=!0,this.client.flush()),this.handshake(),this}mount(){this.widget||this.stopped||(this.widget=new H(this.options,e=>this.submit(e)),this.widget.setReporter(this.options.reporter),this.widget.mount())}handshake(){var o,r,i;let e=JSON.stringify([(o=this.options.reporter)!=null?o:null,(r=this.options.signature)!=null?r:null,this.epoch]);if(((i=this.inFlight)==null?void 0:i.key)===e)return this.inFlight.promise;let t=this.runHandshake().finally(()=>{var s;((s=this.inFlight)==null?void 0:s.promise)===t&&(this.inFlight=null)});return this.inFlight={key:e,promise:t},t}async runHandshake(){var e,t,o,r,i,s,a;try{let c=await this.client.handshake({identity:this.options.reporter,signature:this.options.signature,locale:typeof navigator!="undefined"?navigator.language:void 0});if(this.ready=c,(t=(e=this.options).onReady)==null||t.call(e,c),c.reporterStatus==="Blocked"){(o=this.widget)==null||o.unmount(),this.widget=null;return}this.mount(),this.widget.setTheme(ft(c.theme)),this.widget.setPolicy((r=c.policy)!=null?r:null),this.widget.setState(c.reporterStatus==="Pending"?"pending":"ready")}catch(c){(s=(i=this.options).onError)==null||s.call(i,c),console.warn("[feedback] handshake failed; the widget will not appear",c),(a=this.widget)==null||a.unmount(),this.widget=null}}identify(e){var t;this.options={...this.options,reporter:e?{...this.options.reporter,...e}:void 0},(t=this.widget)==null||t.setReporter(this.options.reporter),this.widget&&this.handshake()}async signIn(){await this.client.signIn(),this.epoch++,await this.handshake()}authenticate(e){this.options={...this.options,signature:e!=null?e:void 0},this.widget&&this.handshake()}stop(){var e,t;this.started=!1,this.stopped=!0,(e=this.trail)==null||e.stop(),(t=this.widget)==null||t.unmount(),this.widget=null}open(){var e;(e=this.widget)==null||e.open()}async report(e,t={}){var o,r,i;return this.client.send({message:e,surface:this.options.surface,...t,context:{...U({breadcrumbs:(o=this.trail)==null?void 0:o.list(),app:this.options.app}),...(r=t.context)!=null?r:{}},reporter:(i=t.reporter)!=null?i:this.options.reporter})}async submit(e){var a,c,l,u,h;let t=e.withScreenshot?await pe(this.options.redact!==!1,()=>{var d,m;return(m=(d=this.widget)==null?void 0:d.conceal())!=null?m:(()=>{})}):null,o=this.options.dom===!1?null:ge(e.anchor,this.options.redact!==!1),r=[...e.files,...t?[t]:[],...o?[ht(o)]:[]],i={message:e.message,kind:e.kind,app:this.options.app,surface:this.options.surface,reporter:e.email?{...this.options.reporter,email:e.email}:this.options.reporter,context:U({anchor:e.anchor,breadcrumbs:(a=this.trail)==null?void 0:a.list(),app:this.options.app})},s=[];try{let d=await this.client.send(i,r,(m,y)=>{var b,v;s.push(y),console.warn(`[feedback] "${m.filename}" did not upload`,y),(v=(b=this.options).onError)==null||v.call(b,y)});return d.uploadsFailed=s.length,(l=(c=this.options).onSent)==null||l.call(c,d),{reference:d.reference,uploadsFailed:s.length}}catch(d){throw this.client.queue(i),(h=(u=this.options).onError)==null||h.call(u,d),d}}};function ht(n){let e=JSON.stringify(n);return{blob:new Blob([e],{type:"application/json"}),filename:"page-snapshot.json",contentType:"application/json"}}function mt(n){return new I(n).start()}function ft(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return je(gt);})();
340
+ `;var je="https://api.daybook.team",j=class{constructor(e){this.options=e;this.widget=null;this.started=!1;this.inFlight=null;this.epoch=0;this.ready=null;this.stopped=!1;var t;if(!e.ingestKey)throw new Error("ingestKey is required");this.client=new R((t=e.apiUrl)!=null?t:je,e.ingestKey),this.trail=e.breadcrumbs===!1?null:new M(40,e.redact!==!1)}start(){var e;return this.stopped=!1,(e=this.trail)==null||e.start(),this.mount(),this.started||(this.started=!0,this.client.flush()),this.handshake(),this}mount(){this.widget||this.stopped||(this.widget=new O(this.options,e=>this.submit(e)),this.widget.setReporter(this.options.reporter),this.widget.mount())}handshake(){var o,r,i;let e=JSON.stringify([(o=this.options.reporter)!=null?o:null,(r=this.options.signature)!=null?r:null,this.epoch]);if(((i=this.inFlight)==null?void 0:i.key)===e)return this.inFlight.promise;let t=this.runHandshake().finally(()=>{var s;((s=this.inFlight)==null?void 0:s.promise)===t&&(this.inFlight=null)});return this.inFlight={key:e,promise:t},t}async runHandshake(){var e,t,o,r,i,s,a;try{let c=await this.client.handshake({identity:this.options.reporter,signature:this.options.signature,locale:typeof navigator!="undefined"?navigator.language:void 0});if(this.ready=c,(t=(e=this.options).onReady)==null||t.call(e,c),c.reporterStatus==="Blocked"){(o=this.widget)==null||o.unmount(),this.widget=null;return}this.mount(),this.widget.setTheme(Lt(c.theme)),this.widget.setPolicy((r=c.policy)!=null?r:null),this.widget.setState(c.reporterStatus==="Pending"?"pending":"ready")}catch(c){(s=(i=this.options).onError)==null||s.call(i,c),console.warn("[feedback] handshake failed; the widget will not appear",c),(a=this.widget)==null||a.unmount(),this.widget=null}}identify(e){var t;this.options={...this.options,reporter:e?{...this.options.reporter,...e}:void 0},(t=this.widget)==null||t.setReporter(this.options.reporter),this.widget&&this.handshake()}async signIn(){await this.client.signIn(),this.epoch++,await this.handshake()}authenticate(e){this.options={...this.options,signature:e!=null?e:void 0},this.widget&&this.handshake()}stop(){var e,t;this.started=!1,this.stopped=!0,(e=this.trail)==null||e.stop(),(t=this.widget)==null||t.unmount(),this.widget=null}open(){var e;(e=this.widget)==null||e.open()}async report(e,t={}){var o,r,i;return this.client.send({message:e,surface:this.options.surface,...t,context:{...V({breadcrumbs:(o=this.trail)==null?void 0:o.list(),app:this.options.app}),...(r=t.context)!=null?r:{}},reporter:(i=t.reporter)!=null?i:this.options.reporter})}async submit(e){var a,c,l,p,h;let t=e.withScreenshot?await fe(this.options.redact!==!1,()=>{var d,f;return(f=(d=this.widget)==null?void 0:d.conceal())!=null?f:(()=>{})}):null,o=this.options.dom===!1?null:xe(e.anchors,this.options.redact!==!1),r=[...e.files,...t?[t]:[],...o?[Tt(o)]:[]],i={message:e.message,kind:e.kind,app:this.options.app,surface:this.options.surface,reporter:e.email?{...this.options.reporter,email:e.email}:this.options.reporter,context:V({anchors:e.anchors,breadcrumbs:(a=this.trail)==null?void 0:a.list(),app:this.options.app})},s=[];try{let d=await this.client.send(i,r,(f,w)=>{var y,L;s.push(w),console.warn(`[feedback] "${f.filename}" did not upload`,w),(L=(y=this.options).onError)==null||L.call(y,w)});return d.uploadsFailed=s.length,(l=(c=this.options).onSent)==null||l.call(c,d),{reference:d.reference,uploadsFailed:s.length}}catch(d){throw this.client.queue(i),(h=(p=this.options).onError)==null||h.call(p,d),d}}};function Tt(n){let e=JSON.stringify(n);return{blob:new Blob([e],{type:"application/json"}),filename:"page-snapshot.json",contentType:"application/json"}}function St(n){return new j(n).start()}function Lt(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return Xe(_t);})();
package/dist/index.js CHANGED
@@ -266,7 +266,7 @@ export class DaybookFeedback {
266
266
  */
267
267
  const snapshot = this.options.dom === false
268
268
  ? null
269
- : captureSnapshot(input.anchor, this.options.redact !== false);
269
+ : captureSnapshot(input.anchors, this.options.redact !== false);
270
270
  /*
271
271
  * Order matters, because the server takes the first five and drops the rest without saying so.
272
272
  *
@@ -289,7 +289,7 @@ export class DaybookFeedback {
289
289
  ? { ...this.options.reporter, email: input.email }
290
290
  : this.options.reporter,
291
291
  context: captureContext({
292
- anchor: input.anchor,
292
+ anchors: input.anchors,
293
293
  breadcrumbs: this.trail?.list(),
294
294
  app: this.options.app,
295
295
  }),
@@ -27,7 +27,7 @@ export interface DomSnapshot {
27
27
  };
28
28
  /** What the keyboard was in, which no screenshot shows. */
29
29
  focus: string | null;
30
- /** The pinned element, its ancestors, and what their styles actually resolved to. */
30
+ /** The first pinned element, its ancestors, and what their styles actually resolved to. */
31
31
  anchor?: {
32
32
  selector: string;
33
33
  path: {
@@ -35,6 +35,14 @@ export interface DomSnapshot {
35
35
  computed: Record<string, string>;
36
36
  }[];
37
37
  };
38
+ /** The same for every pin, in pin order, when there is more than one. */
39
+ anchors?: {
40
+ selector: string;
41
+ path: {
42
+ selector: string;
43
+ computed: Record<string, string>;
44
+ }[];
45
+ }[];
38
46
  /** Everything floating over the page right now: dialogs, drawers, toasts, someone's chat bubble. */
39
47
  layers: {
40
48
  selector: string;
@@ -55,4 +63,4 @@ export interface DomSnapshot {
55
63
  html: string;
56
64
  }
57
65
  /** The whole snapshot. Never throws — a report without one beats no report. */
58
- export declare function captureSnapshot(anchor: Anchor | null, redacted: boolean): DomSnapshot | null;
66
+ export declare function captureSnapshot(pinned: Anchor[] | Anchor | null, redacted: boolean): DomSnapshot | null;
package/dist/snapshot.js CHANGED
@@ -210,7 +210,9 @@ function stylesheets() {
210
210
  });
211
211
  }
212
212
  /** The whole snapshot. Never throws — a report without one beats no report. */
213
- export function captureSnapshot(anchor, redacted) {
213
+ export function captureSnapshot(pinned, redacted) {
214
+ // One anchor or none is what every caller before multi-pin passed, and still means the same.
215
+ const anchors = pinned == null ? [] : Array.isArray(pinned) ? pinned : [pinned];
214
216
  try {
215
217
  const out = [];
216
218
  const size = { used: 0 };
@@ -226,7 +228,10 @@ export function captureSnapshot(anchor, redacted) {
226
228
  focus: document.activeElement && document.activeElement !== document.body
227
229
  ? selectorFor(document.activeElement)
228
230
  : null,
229
- anchor: anchorPath(anchor),
231
+ anchor: anchorPath(anchors[0] ?? null),
232
+ anchors: anchors.length > 1
233
+ ? anchors.map(a => anchorPath(a)).filter((a) => !!a)
234
+ : undefined,
230
235
  layers: layers(),
231
236
  stylesheets: stylesheets(),
232
237
  html: out.join(''),
package/dist/types.d.ts CHANGED
@@ -68,6 +68,8 @@ export interface Anchor {
68
68
  offsetY: number;
69
69
  /** Short text snapshot, so a human can find the thing after a redesign breaks the selector. */
70
70
  elementText: string | null;
71
+ /** Path and query of the page it was dropped on. Absent from bundles before 1.4. */
72
+ page?: string;
71
73
  }
72
74
  /** What the SDK asks at boot. */
73
75
  export interface HandshakeRequest {
package/dist/widget.d.ts CHANGED
@@ -15,13 +15,21 @@ export declare class FeedbackWidget {
15
15
  private readonly host;
16
16
  private readonly root;
17
17
  private mode;
18
- private anchor;
18
+ /**
19
+ * What the reporter pointed at — none, one, or several. PM-T-0335: "it will help with filling of
20
+ * more complex feedbacks". One stays the normal answer; the composer offers another.
21
+ */
22
+ private pins;
23
+ /** Set while the composer is hidden for "Add another pin"; calling it puts the panel back. */
24
+ private cancelAdding;
25
+ /** Takes the page markers down when the composer goes. */
26
+ private unmark;
19
27
  private detach;
20
28
  constructor(options: FeedbackOptions, onSubmit: (input: {
21
29
  message: string;
22
30
  kind: string;
23
31
  email?: string;
24
- anchor: Anchor | null;
32
+ anchors: Anchor[];
25
33
  withScreenshot: boolean;
26
34
  files: StagedFile[];
27
35
  }) => Promise<{
@@ -133,7 +141,40 @@ export declare class FeedbackWidget {
133
141
  * Resolved at capture time rather than at pick time: the composer may have been open for a while,
134
142
  * and where the element is NOW is where the picture will show it.
135
143
  */
136
- private ringAnchor;
144
+ private ringPins;
145
+ /**
146
+ * Where a pin is on screen now, or null when it is not on this screen at all.
147
+ *
148
+ * PM-B-0084: this used to be the selector alone, re-run at capture time, and on a customer's page
149
+ * a selector is the fragile part. A class the page adds on hover is gone once the pointer has
150
+ * moved to the panel, a re-render swaps the node, and either way the capture came back with no
151
+ * ring. So the element itself is held from the moment it was picked, the selector is the fallback
152
+ * for when that node has been replaced, and the box recorded at pick time the last one — a ring
153
+ * roughly in the right place beats a picture that does not say which of forty things was meant.
154
+ *
155
+ * A pin from another page of a single-page app draws nothing: the same selector on a different
156
+ * route can match a different element, and ringing that would be worse than ringing nothing.
157
+ */
158
+ private pinRect;
159
+ /**
160
+ * Where our own host actually is. It is `position: fixed; inset: 0`, which is the viewport —
161
+ * unless an ancestor has a transform, filter or will-change, when fixed positioning resolves
162
+ * against that ancestor and everything drawn at viewport coordinates lands somewhere else
163
+ * (PM-B-0084). Subtracting the host's own box makes a ring land on the element either way.
164
+ */
165
+ private origin;
166
+ /**
167
+ * Numbered dots on the page, one per pin, for as long as the composer is open.
168
+ *
169
+ * Without them the only record of what was pinned is a line of text in the panel, and with two or
170
+ * three pins the reporter cannot tell which number is which without them. Drawn in the layer, so
171
+ * the capture's conceal takes them away and the rings, which are the picture's version of the
172
+ * same thing, go in instead.
173
+ */
174
+ private markPins;
175
+ private redrawMarks;
176
+ /** The picker over a hidden composer, for one more pin. Esc or a click puts the panel back. */
177
+ private pickAnother;
137
178
  /**
138
179
  * Where the reporter dragged the panel to, if they did — for this report only.
139
180
  *
@@ -187,6 +228,10 @@ export declare class FeedbackWidget {
187
228
  */
188
229
  private sent;
189
230
  private launcher;
231
+ /**
232
+ * The crosshair over the page. The first pin opens the composer; "Add another pin" passes
233
+ * `onPin` and gets the new pin back instead, with the composer left exactly as it was.
234
+ */
190
235
  private picker;
191
236
  private composer;
192
237
  /**
package/dist/widget.js CHANGED
@@ -16,7 +16,15 @@ export class FeedbackWidget {
16
16
  this.options = options;
17
17
  this.onSubmit = onSubmit;
18
18
  this.mode = 'idle';
19
- this.anchor = null;
19
+ /**
20
+ * What the reporter pointed at — none, one, or several. PM-T-0335: "it will help with filling of
21
+ * more complex feedbacks". One stays the normal answer; the composer offers another.
22
+ */
23
+ this.pins = [];
24
+ /** Set while the composer is hidden for "Add another pin"; calling it puts the panel back. */
25
+ this.cancelAdding = null;
26
+ /** Takes the page markers down when the composer goes. */
27
+ this.unmark = null;
20
28
  this.detach = [];
21
29
  /** Which of the five shapes the launcher takes. */
22
30
  this.buttonStyle = 'pill';
@@ -36,6 +44,7 @@ export class FeedbackWidget {
36
44
  * that says no should mean the reporter is never shown a tick box that cannot do anything.
37
45
  */
38
46
  this.policy = null;
47
+ this.redrawMarks = null;
39
48
  /**
40
49
  * Where the reporter dragged the panel to, if they did — for this report only.
41
50
  *
@@ -211,6 +220,11 @@ export class FeedbackWidget {
211
220
  if (this.options.hotkey !== null) {
212
221
  const hotkey = (this.options.hotkey ?? 'f').toLowerCase();
213
222
  const onKey = (event) => {
223
+ if (event.key === 'Escape' && this.cancelAdding) {
224
+ // Out of "add another" only: back to the composer as it was, with what was typed.
225
+ this.cancelAdding();
226
+ return;
227
+ }
214
228
  if (event.key === 'Escape') {
215
229
  // The picker, and only the picker.
216
230
  //
@@ -220,7 +234,7 @@ export class FeedbackWidget {
220
234
  // The composer closes by the cross or by Cancel, deliberately, and by nothing else.
221
235
  if (this.mode === 'picking') {
222
236
  this.mode = 'idle';
223
- this.anchor = null;
237
+ this.pins = [];
224
238
  this.dragged = null;
225
239
  this.render();
226
240
  }
@@ -284,10 +298,10 @@ export class FeedbackWidget {
284
298
  const layer = this.root.getElementById('layer');
285
299
  const previous = layer.style.visibility;
286
300
  layer.style.visibility = 'hidden';
287
- const ring = this.ringAnchor();
301
+ const rings = this.ringPins();
288
302
  return () => {
289
303
  layer.style.visibility = previous;
290
- ring?.remove();
304
+ rings.forEach(ring => ring.remove());
291
305
  };
292
306
  }
293
307
  /**
@@ -307,31 +321,148 @@ export class FeedbackWidget {
307
321
  * Resolved at capture time rather than at pick time: the composer may have been open for a while,
308
322
  * and where the element is NOW is where the picture will show it.
309
323
  */
310
- ringAnchor() {
311
- const selector = this.anchor?.selector;
312
- if (!selector)
324
+ ringPins() {
325
+ // Numbered only when there is more than one: a lone ring with a "1" on it is a question.
326
+ const numbered = this.pins.length > 1;
327
+ return this.pins.flatMap((pin, index) => {
328
+ const rect = this.pinRect(pin);
329
+ if (!rect)
330
+ return [];
331
+ const origin = this.origin();
332
+ const ring = document.createElement('div');
333
+ ring.className = 'ring';
334
+ ring.style.left = `${rect.left - origin.left - RING_PAD}px`;
335
+ ring.style.top = `${rect.top - origin.top - RING_PAD}px`;
336
+ ring.style.width = `${rect.width + RING_PAD * 2}px`;
337
+ ring.style.height = `${rect.height + RING_PAD * 2}px`;
338
+ if (numbered) {
339
+ const badge = document.createElement('span');
340
+ badge.className = 'ring__n';
341
+ badge.textContent = String(index + 1);
342
+ ring.appendChild(badge);
343
+ }
344
+ this.root.appendChild(ring);
345
+ return [ring];
346
+ });
347
+ }
348
+ /**
349
+ * Where a pin is on screen now, or null when it is not on this screen at all.
350
+ *
351
+ * PM-B-0084: this used to be the selector alone, re-run at capture time, and on a customer's page
352
+ * a selector is the fragile part. A class the page adds on hover is gone once the pointer has
353
+ * moved to the panel, a re-render swaps the node, and either way the capture came back with no
354
+ * ring. So the element itself is held from the moment it was picked, the selector is the fallback
355
+ * for when that node has been replaced, and the box recorded at pick time the last one — a ring
356
+ * roughly in the right place beats a picture that does not say which of forty things was meant.
357
+ *
358
+ * A pin from another page of a single-page app draws nothing: the same selector on a different
359
+ * route can match a different element, and ringing that would be worse than ringing nothing.
360
+ */
361
+ pinRect(pin) {
362
+ if ((pin.anchor.page ?? currentPage()) !== currentPage())
313
363
  return null;
314
- let target = null;
315
- try {
316
- target = document.querySelector(selector);
364
+ let element = pin.element?.isConnected ? pin.element : null;
365
+ if (!element && pin.anchor.selector && pin.anchor.selector !== 'body') {
366
+ try {
367
+ element = document.querySelector(pin.anchor.selector);
368
+ }
369
+ catch {
370
+ element = null;
371
+ }
317
372
  }
318
- catch {
319
- // A selector the page has since invalidated. No ring beats an exception mid-capture.
320
- return null;
373
+ if (element) {
374
+ const rect = element.getBoundingClientRect();
375
+ if (rect.width >= 1 && rect.height >= 1) {
376
+ return { left: rect.left, top: rect.top, width: rect.width, height: rect.height };
377
+ }
321
378
  }
322
- if (!target)
323
- return null;
324
- const rect = target.getBoundingClientRect();
325
- if (rect.width < 1 || rect.height < 1)
326
- return null;
327
- const ring = document.createElement('div');
328
- ring.className = 'ring';
329
- ring.style.left = `${rect.left - RING_PAD}px`;
330
- ring.style.top = `${rect.top - RING_PAD}px`;
331
- ring.style.width = `${rect.width + RING_PAD * 2}px`;
332
- ring.style.height = `${rect.height + RING_PAD * 2}px`;
333
- this.root.appendChild(ring);
334
- return ring;
379
+ // Recorded in page coordinates, so a scroll since the pick does not move it.
380
+ return {
381
+ left: pin.box.left - window.scrollX,
382
+ top: pin.box.top - window.scrollY,
383
+ width: pin.box.width,
384
+ height: pin.box.height,
385
+ };
386
+ }
387
+ /**
388
+ * Where our own host actually is. It is `position: fixed; inset: 0`, which is the viewport —
389
+ * unless an ancestor has a transform, filter or will-change, when fixed positioning resolves
390
+ * against that ancestor and everything drawn at viewport coordinates lands somewhere else
391
+ * (PM-B-0084). Subtracting the host's own box makes a ring land on the element either way.
392
+ */
393
+ origin() {
394
+ const box = this.host.getBoundingClientRect();
395
+ return { left: box.left, top: box.top };
396
+ }
397
+ /**
398
+ * Numbered dots on the page, one per pin, for as long as the composer is open.
399
+ *
400
+ * Without them the only record of what was pinned is a line of text in the panel, and with two or
401
+ * three pins the reporter cannot tell which number is which without them. Drawn in the layer, so
402
+ * the capture's conceal takes them away and the rings, which are the picture's version of the
403
+ * same thing, go in instead.
404
+ */
405
+ markPins(layer) {
406
+ this.unmark?.();
407
+ const holder = document.createElement('div');
408
+ layer.appendChild(holder);
409
+ let frame = 0;
410
+ const draw = () => {
411
+ frame = 0;
412
+ holder.innerHTML = '';
413
+ if (this.pins.length < 1)
414
+ return;
415
+ const origin = this.origin();
416
+ this.pins.forEach((pin, index) => {
417
+ const rect = this.pinRect(pin);
418
+ if (!rect)
419
+ return;
420
+ const box = document.createElement('div');
421
+ box.className = 'marker';
422
+ box.style.left = `${rect.left - origin.left - RING_PAD}px`;
423
+ box.style.top = `${rect.top - origin.top - RING_PAD}px`;
424
+ box.style.width = `${rect.width + RING_PAD * 2}px`;
425
+ box.style.height = `${rect.height + RING_PAD * 2}px`;
426
+ const badge = document.createElement('span');
427
+ badge.className = 'marker__n';
428
+ badge.textContent = String(index + 1);
429
+ box.appendChild(badge);
430
+ holder.appendChild(box);
431
+ });
432
+ };
433
+ const schedule = () => { if (!frame)
434
+ frame = requestAnimationFrame(draw); };
435
+ window.addEventListener('scroll', schedule, { capture: true, passive: true });
436
+ window.addEventListener('resize', schedule);
437
+ draw();
438
+ this.redrawMarks = draw;
439
+ this.unmark = () => {
440
+ if (frame)
441
+ cancelAnimationFrame(frame);
442
+ window.removeEventListener('scroll', schedule, { capture: true });
443
+ window.removeEventListener('resize', schedule);
444
+ holder.remove();
445
+ this.redrawMarks = null;
446
+ this.unmark = null;
447
+ };
448
+ }
449
+ /** The picker over a hidden composer, for one more pin. Esc or a click puts the panel back. */
450
+ pickAnother(panel, done) {
451
+ const layer = this.root.getElementById('layer');
452
+ const restore = () => {
453
+ mask.remove();
454
+ panel.style.visibility = '';
455
+ this.cancelAdding = null;
456
+ this.redrawMarks?.();
457
+ };
458
+ const mask = this.picker(pin => {
459
+ this.pins.push(pin);
460
+ restore();
461
+ done();
462
+ }, `Click what else is involved (pin ${this.pins.length + 1})`);
463
+ panel.style.visibility = 'hidden';
464
+ this.cancelAdding = restore;
465
+ layer.appendChild(mask);
335
466
  }
336
467
  /**
337
468
  * Makes the panel draggable by its header, and snaps it to a side when it is let go near one.
@@ -404,6 +535,8 @@ export class FeedbackWidget {
404
535
  }
405
536
  render() {
406
537
  const layer = this.root.getElementById('layer');
538
+ this.unmark?.();
539
+ this.cancelAdding = null;
407
540
  layer.innerHTML = '';
408
541
  if (this.mode === 'idle') {
409
542
  layer.appendChild(this.state === 'pending' ? this.pending() : this.launcher());
@@ -427,6 +560,7 @@ export class FeedbackWidget {
427
560
  const panel = this.composer();
428
561
  layer.appendChild(panel);
429
562
  this.place(panel);
563
+ this.markPins(layer);
430
564
  }
431
565
  /**
432
566
  * Shown in place of the launcher when this person is waiting on approval.
@@ -523,16 +657,62 @@ export class FeedbackWidget {
523
657
  button.onclick = () => { this.mode = 'picking'; this.render(); };
524
658
  return button;
525
659
  }
526
- picker() {
660
+ /**
661
+ * The crosshair over the page. The first pin opens the composer; "Add another pin" passes
662
+ * `onPin` and gets the new pin back instead, with the composer left exactly as it was.
663
+ */
664
+ picker(onPin, hint = 'Click the thing that is wrong') {
527
665
  const mask = document.createElement('div');
528
666
  mask.className = 'mask';
529
- mask.innerHTML = `<div class="hint">Click the thing that is wrong · <kbd>Esc</kbd> to cancel</div>`;
667
+ mask.innerHTML = `<div class="hover" hidden></div>`
668
+ + `<div class="hint">${escapeHtml(hint)} · <kbd>Esc</kbd> to cancel</div>`;
669
+ const hover = mask.querySelector('.hover');
670
+ // What is under the pointer, found the only way it can be with the mask on top: look through it.
671
+ const beneath = (x, y) => {
672
+ mask.style.pointerEvents = 'none';
673
+ const element = document.elementFromPoint(x, y);
674
+ mask.style.pointerEvents = '';
675
+ return element;
676
+ };
677
+ /*
678
+ * An outline on what a click would pin, before the click.
679
+ *
680
+ * Picking was a crosshair and a tint and nothing else, so the reporter found out what they had
681
+ * pointed at only from the label in the panel afterwards — and a click that landed on the card
682
+ * around the button rather than the button was a pin on the wrong thing nobody noticed.
683
+ */
684
+ let frame = 0;
685
+ mask.onmousemove = (event) => {
686
+ if (frame)
687
+ return;
688
+ const { clientX, clientY } = event;
689
+ frame = requestAnimationFrame(() => {
690
+ frame = 0;
691
+ const element = beneath(clientX, clientY);
692
+ if (!element || element === document.body || element === document.documentElement) {
693
+ hover.hidden = true;
694
+ return;
695
+ }
696
+ const rect = element.getBoundingClientRect();
697
+ const origin = this.origin();
698
+ hover.hidden = false;
699
+ hover.style.left = `${rect.left - origin.left}px`;
700
+ hover.style.top = `${rect.top - origin.top}px`;
701
+ hover.style.width = `${rect.width}px`;
702
+ hover.style.height = `${rect.height}px`;
703
+ });
704
+ };
530
705
  mask.onclick = (event) => {
531
706
  // The mask has to stop intercepting before elementFromPoint runs, or every anchor resolves to
532
707
  // the mask itself. The predecessor hit this too.
533
708
  mask.style.pointerEvents = 'none';
534
- this.anchor = captureAnchor(event.clientX, event.clientY);
709
+ const pin = pinAt(event.clientX, event.clientY);
535
710
  mask.style.pointerEvents = '';
711
+ if (onPin) {
712
+ onPin(pin);
713
+ return;
714
+ }
715
+ this.pins = [pin];
536
716
  this.mode = 'composing';
537
717
  this.render();
538
718
  };
@@ -541,11 +721,7 @@ export class FeedbackWidget {
541
721
  composer() {
542
722
  const panel = document.createElement('div');
543
723
  panel.className = 'panel';
544
- const anchorLabel = this.anchor?.elementText
545
- ? `on “${this.anchor.elementText}”`
546
- : this.anchor?.selector
547
- ? `on ${this.anchor.selector}`
548
- : 'on this page';
724
+ const anchorLabel = headingFor(this.pins);
549
725
  // The anchor leads, because it is the thing this widget has that a contact form does not: the
550
726
  // reporter pointed at something, and saying what they pointed at is how they know we understood.
551
727
  // "Report a problem" is a heading anybody could have written; the anchor is theirs.
@@ -560,6 +736,9 @@ export class FeedbackWidget {
560
736
  <button id="close" class="panel__close" aria-label="Close">&times;</button>
561
737
  </div>
562
738
 
739
+ <!-- The pins, when there is more than one to tell apart, and the way to add one. -->
740
+ <div id="pins" class="pins"></div>
741
+
563
742
  <textarea id="message" rows="5" placeholder="What happened?"></textarea>
564
743
 
565
744
  <!--
@@ -660,6 +839,55 @@ export class FeedbackWidget {
660
839
  button.classList.add('kind--on');
661
840
  };
662
841
  });
842
+ /*
843
+ * The pins, and "Add another pin".
844
+ *
845
+ * Adding one hides this panel rather than re-rendering it: render() builds the composer from
846
+ * scratch, and the message, the kind, the email and the staged files live in it. Hidden and
847
+ * shown again, the panel is the same panel, with everything in it where the reporter left it.
848
+ */
849
+ const pinList = panel.querySelector('#pins');
850
+ const heading = panel.querySelector('.panel__anchor');
851
+ const renderPins = () => {
852
+ heading.textContent = headingFor(this.pins);
853
+ pinList.innerHTML = '';
854
+ // A list only once there is something to tell apart; one pin is already the heading.
855
+ if (this.pins.length > 1) {
856
+ this.pins.forEach((pin, index) => {
857
+ const row = document.createElement('div');
858
+ row.className = 'pin';
859
+ const number = document.createElement('span');
860
+ number.className = 'pin__n';
861
+ number.textContent = String(index + 1);
862
+ row.appendChild(number);
863
+ const label = document.createElement('span');
864
+ label.className = 'pin__label';
865
+ label.textContent = labelFor(pin.anchor);
866
+ label.title = pin.anchor.page ?? '';
867
+ row.appendChild(label);
868
+ const remove = document.createElement('button');
869
+ remove.className = 'link';
870
+ remove.textContent = '×';
871
+ remove.setAttribute('aria-label', `Remove pin ${index + 1}`);
872
+ remove.onclick = () => {
873
+ this.pins.splice(index, 1);
874
+ renderPins();
875
+ };
876
+ row.appendChild(remove);
877
+ pinList.appendChild(row);
878
+ });
879
+ }
880
+ if (this.pins.length < MAX_PINS) {
881
+ const add = document.createElement('button');
882
+ add.className = 'link pins__add';
883
+ add.id = 'add-pin';
884
+ add.textContent = this.pins.length > 0 ? '+ Add another pin' : '+ Pin something on the page';
885
+ add.onclick = () => this.pickAnother(panel, renderPins);
886
+ pinList.appendChild(add);
887
+ }
888
+ this.redrawMarks?.();
889
+ };
890
+ renderPins();
663
891
  const message = panel.querySelector('#message');
664
892
  const email = panel.querySelector('#email');
665
893
  /*
@@ -681,7 +909,7 @@ export class FeedbackWidget {
681
909
  const dismiss = () => {
682
910
  revoke(files);
683
911
  this.mode = 'idle';
684
- this.anchor = null;
912
+ this.pins = [];
685
913
  this.dragged = null;
686
914
  this.render();
687
915
  };
@@ -699,7 +927,7 @@ export class FeedbackWidget {
699
927
  message: message.value.trim(),
700
928
  kind,
701
929
  email: email.value.trim() || undefined,
702
- anchor: this.anchor,
930
+ anchors: this.pins.map(pin => pin.anchor),
703
931
  withScreenshot: shot?.checked ?? false,
704
932
  files: files.filter(f => !f.error),
705
933
  });
@@ -713,7 +941,7 @@ export class FeedbackWidget {
713
941
  // calls human-quotable: it exists so somebody can say "F-0007" to support, which they
714
942
  // cannot do if they never see it.
715
943
  this.mode = 'sent';
716
- this.anchor = null;
944
+ this.pins = [];
717
945
  this.render();
718
946
  }
719
947
  catch (error) {
@@ -794,6 +1022,42 @@ export async function copyText(text) {
794
1022
  const EDGE = 16;
795
1023
  /** How far the ring sits outside the element it marks, so it frames rather than covers. */
796
1024
  const RING_PAD = 3;
1025
+ /**
1026
+ * How many pins one report may carry. Ten is more than any report has needed, and a limit keeps a
1027
+ * slipped hand from filing a report whose picture is nothing but rings.
1028
+ */
1029
+ const MAX_PINS = 10;
1030
+ function currentPage() {
1031
+ return location.pathname + location.search;
1032
+ }
1033
+ function pinAt(clientX, clientY) {
1034
+ const anchor = captureAnchor(clientX, clientY);
1035
+ const hit = document.elementFromPoint(clientX, clientY);
1036
+ // The page itself is not a thing somebody pointed at; a click on empty space is a spot.
1037
+ const element = hit && hit !== document.body && hit !== document.documentElement ? hit : null;
1038
+ const rect = element?.getBoundingClientRect();
1039
+ const box = rect && rect.width >= 1 && rect.height >= 1
1040
+ ? { left: rect.left + window.scrollX, top: rect.top + window.scrollY, width: rect.width, height: rect.height }
1041
+ : { left: clientX - 12 + window.scrollX, top: clientY - 12 + window.scrollY, width: 24, height: 24 };
1042
+ return { anchor, element, box };
1043
+ }
1044
+ function labelFor(anchor) {
1045
+ if (anchor.elementText)
1046
+ return `“${anchor.elementText}”`;
1047
+ if (anchor.selector && anchor.selector !== 'body')
1048
+ return anchor.selector;
1049
+ return 'a spot on the page';
1050
+ }
1051
+ /** "on “Save”", "on “Save” and 2 more" — bounded, however many there are. */
1052
+ function headingFor(pins) {
1053
+ if (pins.length === 0)
1054
+ return 'on this page';
1055
+ const [head] = pins;
1056
+ if (!head)
1057
+ return 'on this page';
1058
+ const first = `on ${labelFor(head.anchor)}`;
1059
+ return pins.length === 1 ? first : `${first} and ${pins.length - 1} more`;
1060
+ }
797
1061
  /** Enough of the header must stay reachable to drag it back. */
798
1062
  const HANDLE = 56;
799
1063
  /**
@@ -1059,6 +1323,22 @@ const STYLES = `
1059
1323
  border: 2px solid #ef4444;
1060
1324
  box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 0 0 5px rgba(239,68,68,.35);
1061
1325
  }
1326
+ /* The number, on the ring's corner so it never covers what the ring is about. */
1327
+ .ring__n, .marker__n {
1328
+ position: absolute; top: -11px; left: -11px; min-width: 20px; height: 20px; padding: 0 5px;
1329
+ border-radius: 10px; background: #ef4444; color: #fff; border: 2px solid #fff;
1330
+ font: 600 11px/16px system-ui, sans-serif; text-align: center; box-sizing: border-box;
1331
+ }
1332
+ /* What a click would pin, while picking. Dashed, so it reads as "this one?" rather than "pinned". */
1333
+ .hover {
1334
+ position: fixed; pointer-events: none; border-radius: 3px;
1335
+ outline: 2px dashed #ef4444; outline-offset: 2px; background: rgba(239,68,68,.06);
1336
+ }
1337
+ /* A pin already made, while the composer is open. */
1338
+ .marker {
1339
+ position: fixed; pointer-events: none; border-radius: 3px;
1340
+ border: 2px solid #ef4444; box-shadow: 0 0 0 2px rgba(255,255,255,.85);
1341
+ }
1062
1342
  /*
1063
1343
  Bottom, not top.
1064
1344
 
@@ -1105,6 +1385,14 @@ kbd {
1105
1385
  .sent__warn { margin-top: 6px; color: var(--pm-warn); font-size: 11px; line-height: 1.4 }
1106
1386
 
1107
1387
  /* The anchor leads: it is what the reporter pointed at, and the part they need to recognise. */
1388
+ .pins { display: flex; flex-direction: column; gap: 4px; margin: 0 0 8px; }
1389
+ .pin { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--pm-ink); }
1390
+ .pin__n {
1391
+ flex: none; min-width: 18px; height: 18px; border-radius: 9px; background: #ef4444; color: #fff;
1392
+ font: 600 11px/18px system-ui, sans-serif; text-align: center;
1393
+ }
1394
+ .pin__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1395
+ .pins__add { align-self: flex-start; font-size: 12px; }
1108
1396
  .panel__anchor {
1109
1397
  color: var(--pm-muted); font-size: 11px;
1110
1398
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
@@ -1149,6 +1437,22 @@ textarea, input[type=email] {
1149
1437
  border-radius: 8px; font-size: 13px; resize: vertical; color: var(--pm-ink); background: var(--pm-surface);
1150
1438
  }
1151
1439
  textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset: -1px }
1440
+
1441
+ /*
1442
+ * Sixteen pixels on a touch device, or iOS zooms the host page.
1443
+ *
1444
+ * Safari zooms in whenever a focused field's text is under 16px and never zooms back out. At 13px
1445
+ * that happened the moment somebody tapped the message box — so the act of reporting a bug left
1446
+ * the reporter's view of OUR CUSTOMER's site magnified and scrolled sideways, which is a rude
1447
+ * thing for an embedded widget to do to the page hosting it.
1448
+ *
1449
+ * The widget cannot fix this with a viewport meta even if that were acceptable: the meta belongs
1450
+ * to the host page and is not ours to touch. Making the text big enough is the only move
1451
+ * available, and it is the right one anyway.
1452
+ */
1453
+ @media (pointer: coarse) {
1454
+ textarea, input[type=email] { font-size: 16px }
1455
+ }
1152
1456
  .shot { display: flex; align-items: center; gap: 6px; color: var(--pm-muted); font-size: 12px }
1153
1457
 
1154
1458
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daybook/feedback",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "In-app feedback for the web: point at what is wrong, and everything a triager needs is captured automatically.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",