@daybook/feedback 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/feedback.js +21 -5
- package/dist/widget.js +16 -0
- package/package.json +1 -1
package/dist/feedback.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");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
|
|
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 Oe=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 je=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function ne(n,e){return n.length===0?"":e&&je.test(e)?"[redacted]":`[${n.length} chars]`}function O(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 O(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",h=n instanceof HTMLInputElement?n.type:e;return`${e}[${h}]${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",O(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(j).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: ${j(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]))}: ${j(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function re(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function j(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,h;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:ie(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(u=>({filename:u.filename,contentType:u.contentType,size:u.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await S(i);let s=await i.json(),a=((h=e.attachments)!=null?h:[]).length;return await Promise.all(t.map(async(u,d)=>{let m=Be(s,a+d);if(!m){o==null||o(u,new Error("The server would not accept that file."));return}try{await this.upload(m,u)}catch(y){o==null||o(u,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)&&B(t)}catch{B(t)}}}queue(e){var t;B({...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,h)=>{let u=setInterval(()=>{i.closed&&(m(),h(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){h(Object.assign(new Error("Sign-in was refused"),{code:b.error||"refused"}));return}l(b.code)}},m=()=>{clearInterval(u),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 Be(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 B(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,he=300,ue=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>he?`${e.slice(0,he)}\u2026[${e.length}]`:e,N=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");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 h,u;if(t.used>z)return!1;if(n.nodeType===3){let d=((h=n.textContent)!=null?h:"").replace(/\s+/g," ");if(!d.trim())return!0;let m=d.length>ue?`${d.slice(0,ue)}\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=(u=r.textContent)!=null?u:"",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 h=l.getBoundingClientRect();o.set(l,{top:h.top,bottom:h.bottom,left:h.left,right:h.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
3
|
--pm-${r}: ${g}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
|
|
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 h=C(l.clientX-i,g-r.width+K,window.innerWidth-K),u=C(l.clientY-s,0,window.innerHeight-K);e.style.left=`${h}px`,e.style.top=`${u}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=`
|
|
6
6
|
<div class="sent__tick" aria-hidden="true">✓</div>
|
|
7
7
|
<div class="sent__body">
|
|
8
8
|
<div class="panel__title">Thank you \u2014 that is on its way.</div>
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
<span class="panel__note">Sends this page's contents, your browser, and recent errors.</span>
|
|
58
58
|
<button id="cancel" class="ghost">Cancel</button>
|
|
59
59
|
<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
|
|
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 h="bug";e.querySelectorAll(".kind").forEach(p=>{p.onclick=()=>{var f;h=(f=p.dataset.kind)!=null?f:"bug",e.querySelectorAll(".kind").forEach(w=>w.classList.remove("kind--on")),p.classList.add("kind--on")}});let u=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(!u.value.trim()){b.textContent="Say what happened first.";return}v.disabled=!0,b.textContent="Sending\u2026";try{let f=await this.onSubmit({message:u.value.trim(),kind:h,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,u.onkeydown=p=>{(p.metaKey||p.ctrlKey)&&p.key==="Enter"&&Y()},setTimeout(()=>u.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=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[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=>ht.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 ht=["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=`
|
|
61
61
|
/*
|
|
62
62
|
Every colour in this file is one of these, and there are two sets of them.
|
|
63
63
|
|
|
@@ -257,6 +257,22 @@ textarea, input[type=email] {
|
|
|
257
257
|
border-radius: 8px; font-size: 13px; resize: vertical; color: var(--pm-ink); background: var(--pm-surface);
|
|
258
258
|
}
|
|
259
259
|
textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset: -1px }
|
|
260
|
+
|
|
261
|
+
/*
|
|
262
|
+
* Sixteen pixels on a touch device, or iOS zooms the host page.
|
|
263
|
+
*
|
|
264
|
+
* Safari zooms in whenever a focused field's text is under 16px and never zooms back out. At 13px
|
|
265
|
+
* that happened the moment somebody tapped the message box \u2014 so the act of reporting a bug left
|
|
266
|
+
* the reporter's view of OUR CUSTOMER's site magnified and scrolled sideways, which is a rude
|
|
267
|
+
* thing for an embedded widget to do to the page hosting it.
|
|
268
|
+
*
|
|
269
|
+
* The widget cannot fix this with a viewport meta even if that were acceptable: the meta belongs
|
|
270
|
+
* to the host page and is not ours to touch. Making the text big enough is the only move
|
|
271
|
+
* available, and it is the right one anyway.
|
|
272
|
+
*/
|
|
273
|
+
@media (pointer: coarse) {
|
|
274
|
+
textarea, input[type=email] { font-size: 16px }
|
|
275
|
+
}
|
|
260
276
|
.shot { display: flex; align-items: center; gap: 6px; color: var(--pm-muted); font-size: 12px }
|
|
261
277
|
|
|
262
278
|
/*
|
|
@@ -294,4 +310,4 @@ textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset:
|
|
|
294
310
|
.file__icon { width: 28px; text-align: center }
|
|
295
311
|
.file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
|
296
312
|
.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
|
|
313
|
+
`;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,h,u;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?[ut(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),(u=(h=this.options).onError)==null||u.call(h,d),d}}};function ut(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 Oe(gt);})();
|
package/dist/widget.js
CHANGED
|
@@ -1149,6 +1149,22 @@ textarea, input[type=email] {
|
|
|
1149
1149
|
border-radius: 8px; font-size: 13px; resize: vertical; color: var(--pm-ink); background: var(--pm-surface);
|
|
1150
1150
|
}
|
|
1151
1151
|
textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset: -1px }
|
|
1152
|
+
|
|
1153
|
+
/*
|
|
1154
|
+
* Sixteen pixels on a touch device, or iOS zooms the host page.
|
|
1155
|
+
*
|
|
1156
|
+
* Safari zooms in whenever a focused field's text is under 16px and never zooms back out. At 13px
|
|
1157
|
+
* that happened the moment somebody tapped the message box — so the act of reporting a bug left
|
|
1158
|
+
* the reporter's view of OUR CUSTOMER's site magnified and scrolled sideways, which is a rude
|
|
1159
|
+
* thing for an embedded widget to do to the page hosting it.
|
|
1160
|
+
*
|
|
1161
|
+
* The widget cannot fix this with a viewport meta even if that were acceptable: the meta belongs
|
|
1162
|
+
* to the host page and is not ours to touch. Making the text big enough is the only move
|
|
1163
|
+
* available, and it is the right one anyway.
|
|
1164
|
+
*/
|
|
1165
|
+
@media (pointer: coarse) {
|
|
1166
|
+
textarea, input[type=email] { font-size: 16px }
|
|
1167
|
+
}
|
|
1152
1168
|
.shot { display: flex; align-items: center; gap: 6px; color: var(--pm-muted); font-size: 12px }
|
|
1153
1169
|
|
|
1154
1170
|
/*
|
package/package.json
CHANGED