@getpinax/widget 1.0.0-beta.1 → 1.0.0-beta.2

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.
@@ -2736,9 +2736,7 @@ function jn(e) {
2736
2736
  for (let i of t) n += e.slice(r, i.start) + "*".repeat(i.end - i.start), r = i.end;
2737
2737
  return n + e.slice(r);
2738
2738
  }
2739
- var Mn = "(?:(?:full|your|first|last|guest|customer|client|contact|booking|patient|member|account|lead)\\s+name|name|customer|guest|client|booked by|card ?holder|account holder)";
2740
- RegExp(`^${Mn}\\s*[::]?$`, "i"), RegExp(`^${Mn}\\s*[::]\\s*`, "i");
2741
- var Nn = class {
2739
+ var Mn = class {
2742
2740
  constructor(e = 3e4, t = Date.now, n = 5e4) {
2743
2741
  this.windowMs = e, this.now = t, this.maxEvents = n, this.segments = [];
2744
2742
  }
@@ -2767,12 +2765,12 @@ var Nn = class {
2767
2765
  this.segments = [];
2768
2766
  }
2769
2767
  };
2770
- function Pn(e) {
2768
+ function Nn(e) {
2771
2769
  let t = "", n = 32768;
2772
2770
  for (let r = 0; r < e.length; r += n) t += String.fromCharCode(...e.subarray(r, r + n));
2773
2771
  return btoa(t);
2774
2772
  }
2775
- async function Fn(e) {
2773
+ async function Pn(e) {
2776
2774
  if (typeof CompressionStream != "function") return null;
2777
2775
  try {
2778
2776
  let t = new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));
@@ -2782,19 +2780,19 @@ async function Fn(e) {
2782
2780
  }
2783
2781
  }
2784
2782
  // src/capture/text.ts
2785
- var In = /^(access_?token|token|id_token|refresh_token|auth|authorization|api_?key|key|secret|password|passwd|pwd|session|sessionid|sid|code|signature|sig)$/i;
2786
- function Ln(e, t) {
2783
+ var Fn = /^(access_?token|token|id_token|refresh_token|auth|authorization|api_?key|key|secret|password|passwd|pwd|session|sessionid|sid|code|signature|sig)$/i;
2784
+ function In(e, t) {
2787
2785
  try {
2788
2786
  let n = new URL(e, t);
2789
2787
  n.hash = "", n.username = "", n.password = "";
2790
- for (let e of [...n.searchParams.keys()]) In.test(e) && n.searchParams.set(e, "[hidden]");
2788
+ for (let e of [...n.searchParams.keys()]) Fn.test(e) && n.searchParams.set(e, "[hidden]");
2791
2789
  return n.toString();
2792
2790
  } catch {
2793
2791
  return String(e);
2794
2792
  }
2795
2793
  }
2796
2794
  // src/replay/sanitize.ts
2797
- var Rn = /* @__PURE__ */ new Set([
2795
+ var Ln = /* @__PURE__ */ new Set([
2798
2796
  "href",
2799
2797
  "src",
2800
2798
  "action",
@@ -2806,10 +2804,23 @@ var Rn = /* @__PURE__ */ new Set([
2806
2804
  "longdesc",
2807
2805
  "ping",
2808
2806
  "xlink:href"
2807
+ ]), Rn = /* @__PURE__ */ new Set([
2808
+ "alt",
2809
+ "title",
2810
+ "placeholder",
2811
+ "label",
2812
+ "value",
2813
+ "summary",
2814
+ "abbr",
2815
+ "aria-label",
2816
+ "aria-description",
2817
+ "aria-roledescription",
2818
+ "aria-valuetext",
2819
+ "aria-placeholder"
2809
2820
  ]), zn = (e) => e === "style" || e === "_cssText" || e.startsWith("rr_");
2810
2821
  function Bn(e, t) {
2811
2822
  let n = e.trim();
2812
- return !n || /^(data|blob):/i.test(n) ? e : n.startsWith("#") ? "#" : jn(Ln(n, t));
2823
+ return !n || /^(data|blob):/i.test(n) ? e : n.startsWith("#") ? "#" : jn(In(n, t));
2813
2824
  }
2814
2825
  function Vn(e, t) {
2815
2826
  return e.split(",").map((e) => {
@@ -2817,34 +2828,34 @@ function Vn(e, t) {
2817
2828
  return n ? [Bn(n, t), ...r].join(" ") : e;
2818
2829
  }).join(", ");
2819
2830
  }
2820
- function Hn(e, t, n) {
2821
- let r = {}, i = t?.toLowerCase() === "input" && String(e.type ?? "").toLowerCase() === "hidden";
2831
+ function Hn(e, t, n, r = !1) {
2832
+ let i = {}, a = t?.toLowerCase() === "input" && String(e.type ?? "").toLowerCase() === "hidden";
2822
2833
  for (let t in e) {
2823
- let a = e[t], o = t.toLowerCase();
2824
- i && o === "value" || (r[t] = typeof a != "string" || zn(o) ? a : Rn.has(o) ? Bn(a, n) : o === "srcset" ? Vn(a, n) : jn(a));
2834
+ let o = e[t], s = t.toLowerCase();
2835
+ a && s === "value" || (i[t] = typeof o != "string" || zn(s) ? o : Ln.has(s) ? Bn(o, n) : s === "srcset" ? Vn(o, n) : r && Rn.has(s) ? o.replace(/\S/g, "*") : jn(o));
2825
2836
  }
2826
- return r;
2837
+ return i;
2827
2838
  }
2828
- function Un(e, t = typeof location > "u" ? void 0 : location.href) {
2829
- return JSON.stringify(e, function(e, n) {
2830
- if (e === "attributes" && n && typeof n == "object" && !Array.isArray(n)) return Hn(n, this.tagName, t);
2831
- if (e === "data" && this.type === 4 && n && typeof n == "object" && typeof n.href == "string") {
2832
- let e = n;
2839
+ function Un(e, t = typeof location > "u" ? void 0 : location.href, n = {}) {
2840
+ return JSON.stringify(e, function(e, r) {
2841
+ if (e === "attributes" && r && typeof r == "object" && !Array.isArray(r)) return Hn(r, this.tagName, t, n.maskText === !0);
2842
+ if (e === "data" && this.type === 4 && r && typeof r == "object" && typeof r.href == "string") {
2843
+ let e = r;
2833
2844
  return {
2834
2845
  ...e,
2835
2846
  href: Bn(e.href, t)
2836
2847
  };
2837
2848
  }
2838
- return n;
2849
+ return r;
2839
2850
  });
2840
2851
  }
2841
2852
  // src/replay/recorder.ts
2842
- var Wn = 3e4, Gn = 1e4, Kn = "[contenteditable]:not([contenteditable=false])";
2843
- function qn(e = {}) {
2844
- let t = new Nn(Wn), n = Tn({
2853
+ var Wn = 3e4, Gn = 1e4, Kn = "[contenteditable]:not([contenteditable=false])", qn = "img,picture,video,canvas,iframe", Jn = (e) => e.replace(/\S/g, "*");
2854
+ function Yn(e = {}) {
2855
+ let t = e.mask !== "inputs", n = new Mn(Wn), r = Tn({
2845
2856
  emit: (e) => {
2846
2857
  try {
2847
- t.push(e);
2858
+ n.push(e);
2848
2859
  } catch {}
2849
2860
  },
2850
2861
  checkoutEveryNms: Gn,
@@ -2853,15 +2864,17 @@ function qn(e = {}) {
2853
2864
  blockSelector: [
2854
2865
  "[data-pinax-mask]",
2855
2866
  "input[type=hidden]",
2867
+ t ? qn : "",
2856
2868
  e.exclude
2857
2869
  ].filter(Boolean).join(","),
2858
2870
  maskTextClass: "pinax-mask",
2859
2871
  maskTextSelector: "*",
2860
- maskTextFn: (e, t) => {
2872
+ maskTextFn: (e, n) => {
2873
+ if (t) return Jn(e);
2861
2874
  try {
2862
- return t?.closest?.(`${Kn},[data-pinax-mask],.pinax-mask`) ? e.replace(/\S/g, "*") : jn(e);
2875
+ return n?.closest?.(`${Kn},[data-pinax-mask],.pinax-mask`) ? Jn(e) : jn(e);
2863
2876
  } catch {
2864
- return e.replace(/\S/g, "*");
2877
+ return Jn(e);
2865
2878
  }
2866
2879
  },
2867
2880
  slimDOMOptions: "all",
@@ -2878,25 +2891,25 @@ function qn(e = {}) {
2878
2891
  });
2879
2892
  return {
2880
2893
  async exportReplay(e) {
2881
- let n = t.segmentCount;
2882
- for (let r = n; r >= 1; r--) {
2883
- let n = t.events(r);
2884
- if (!n.length) return null;
2885
- let i = await Fn(Un(n));
2886
- if (!i) return null;
2887
- let a = Pn(i);
2888
- if (a.length <= e) return a;
2894
+ let r = n.segmentCount;
2895
+ for (let i = r; i >= 1; i--) {
2896
+ let r = n.events(i);
2897
+ if (!r.length) return null;
2898
+ let a = await Pn(Un(r, void 0, { maskText: t }));
2899
+ if (!a) return null;
2900
+ let o = Nn(a);
2901
+ if (o.length <= e) return o;
2889
2902
  }
2890
2903
  return null;
2891
2904
  },
2892
2905
  stop() {
2893
2906
  try {
2894
- n?.();
2907
+ r?.();
2895
2908
  } catch {}
2896
- t.clear();
2909
+ n.clear();
2897
2910
  }
2898
2911
  };
2899
2912
  }
2900
- export { Gn as CHECKOUT_MS, Wn as WINDOW_MS, qn as startRecorder };
2913
+ export { Gn as CHECKOUT_MS, qn as MEDIA, Wn as WINDOW_MS, Yn as startRecorder };
2901
2914
 
2902
2915
  //# sourceMappingURL=pinax-recorder.js.map
package/dist/pinax.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(){var e=``;function t(t){e=t}var n=new Map;function r(t){let r=n.get(t);return r||(r=import(new URL(`${t}?v=1.0.0-beta.1`,e||document.baseURI).href),n.set(t,r),r.catch(()=>{n.delete(t)})),r}function i(){return r(`pinax-editor.js`)}function a(){return r(`pinax-recorder.js`)}function o(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}var s=/^(access_?token|token|id_token|refresh_token|auth|authorization|api_?key|key|secret|password|passwd|pwd|session|sessionid|sid|code|signature|sig)$/i;function c(e,t){try{let n=new URL(e,t);n.hash=``,n.username=``,n.password=``;for(let e of[...n.searchParams.keys()])s.test(e)&&n.searchParams.set(e,`[hidden]`);return n.toString()}catch{return String(e)}}function l(e){return(e||`https://api.getpinax.com`).replace(/\/+$/,``)}function u(e,t){let n=e??(t?``:`https://cdn.getpinax.com`);return n?n.replace(/\/+$/,``):null}function d(e,t){return`${e}/config/${encodeURIComponent(t)}.json`}function f(e,t,n){return`${e}/v1/widget/${encodeURIComponent(t)}/${n}`}async function p(e,t){let n=await e(t,{credentials:`omit`});if(!n.ok)return{status:n.status,config:null};let r=await n.json();return{status:n.status,config:r?.data??null}}async function ee(e,t,n,r=null){if(r)try{let{config:t}=await p(e,d(r,n));if(t)return t}catch{}return(await p(e,f(t,n,`config`))).config}function te(e,t,n,r){try{if(!new URL(r).searchParams.has(`pinax_verify`))return;e(f(t,n,`ping`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:c(r)})}).catch(()=>{})}catch{}}var ne={403:`Feedback isn't switched on for this website yet.`,404:`Feedback isn't switched on for this website yet.`,413:`That screenshot is too big to send. Remove it and try again.`,429:`Too many reports from this device. Please try again in a few minutes.`};async function re(e,t,n,r){let i;try{i=await e(f(t,n,`reports`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})}catch{return{ok:!1,retry:!0,status:0,message:`You're offline. We'll send it when you're back.`}}let a=null;try{a=await i.json()}catch{}if(i.ok)return{ok:!0,id:a?.data?.id??``};let o=i.status;return{ok:!1,retry:o>=500,status:o,message:ne[o]??(o===400&&a?.message?a.message:`Something went wrong. Please try again.`)}}var ie=4e3;async function ae(e,t,n,r,i=ie){let a=typeof AbortController==`function`?new AbortController:null,o,s=new Promise(e=>{o=setTimeout(()=>{a?.abort(),e(null)},i)}),c=(async()=>{try{let i=await e(f(t,n,`follow-up`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:r.type,message:r.message.trim().slice(0,2e3),pagePath:r.pagePath.slice(0,500)||`/`}),signal:a?.signal});if(!i.ok)return null;let o=(await i.json())?.data?.question;return typeof o==`string`&&o.trim()?o.trim().slice(0,300):null}catch{return null}})();try{return await Promise.race([c,s])}finally{clearTimeout(o)}}function oe(e,t,n,r){try{e(f(t,n,`fix-check`),{method:`POST`,credentials:`omit`,keepalive:!0,headers:{"Content-Type":`application/json`},body:JSON.stringify({checkId:r.checkId.slice(0,64),signature:r.signature.slice(0,300)})}).catch(()=>{})}catch{}}var se=`input,textarea,select,[contenteditable]:not([contenteditable=false]),[data-pinax-mask],.pinax-mask`,ce=`[data-pinax-mask],.pinax-mask`,le=`a[href],button,input,select,textarea,summary,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=radio],[role=switch],[role=option],[contenteditable]:not([contenteditable=false])`,ue={button:`button`,submit:`button`,reset:`button`,image:`button`,checkbox:`checkbox`,radio:`radio`,range:`slider`,search:`searchbox`};function m(e,t){try{return e.matches(t)}catch{return!1}}function h(e,t){try{return e.closest(t)}catch{return null}}var g=e=>e.replace(/\s+/g,` `).trim();function de(e){if(e.tagName!==`INPUT`)return!1;let t=e,n=(t.getAttribute(`autocomplete`)??``).toLowerCase(),r=`${t.name} ${t.id}`.toLowerCase();return t.type===`password`||n.includes(`cc-`)||n.includes(`password`)||/\b(card|cc|cvc|cvv|iban)/.test(r)}function fe(e){let t=e.getAttribute(`role`)?.trim().split(/\s+/)[0];if(t)return t;let n=e.tagName.toLowerCase();switch(n){case`a`:return e.hasAttribute(`href`)?`link`:`text`;case`button`:case`summary`:return`button`;case`input`:return ue[e.type?.toLowerCase()]??`textbox`;case`textarea`:return`textbox`;case`select`:return`combobox`;case`img`:return`image`;case`h1`:case`h2`:case`h3`:case`h4`:case`h5`:case`h6`:return`heading`;default:return m(e,`[contenteditable]:not([contenteditable=false])`)?`textbox`:n}}function _(e,t=120){if(m(e,se)||h(e,ce))return``;let n=``,r=e=>{if(n.length>t)return;if(e.nodeType===3){n+=e.nodeValue??``;return}if(e.nodeType!==1)return;let i=e,a=i.tagName;if(a!==`SCRIPT`&&a!==`STYLE`&&a!==`TEMPLATE`&&!m(i,se)&&i.getAttribute(`aria-hidden`)!==`true`){if(a===`IMG`)n+=` ${i.getAttribute(`alt`)??``} `;else{for(let e of i.childNodes)r(e);/^(P|DIV|LI|BR|TD|TH|DT|DD)$/.test(a)&&(n+=` `)}}};for(let t of e.childNodes)r(t);return g(n)}function pe(e){let t=e.getAttribute(`aria-labelledby`);if(!t)return``;let n=e.ownerDocument;return g(t.split(/\s+/).map(e=>{let t=n.getElementById(e);return t?_(t):``}).join(` `))}function me(e){let t=e;return g((t.labels?[...t.labels]:[]).map(e=>_(e)).join(` `))||g(t.getAttribute(`placeholder`)??``)||g(t.getAttribute(`title`)??``)||g(t.getAttribute(`name`)??``)}function he(e){if(h(e,ce))return``;let t=g(e.getAttribute(`aria-label`)??``);if(t)return t;let n=pe(e);if(n)return n;let r=e.tagName;if(r===`INPUT`){let t=e.type?.toLowerCase();return t===`submit`||t===`button`||t===`reset`?g(e.getAttribute(`value`)??``):t===`image`?g(e.getAttribute(`alt`)??``):me(e)}return r===`TEXTAREA`||r===`SELECT`?me(e):m(e,`[contenteditable]:not([contenteditable=false])`)?g(e.getAttribute(`title`)??``):r===`IMG`?g(e.getAttribute(`alt`)??``):_(e)||g(e.getAttribute(`title`)??``)}function ge(e){let t=h(e,le);if(!t)return o(fe(e),200);let n=t;if(de(n))return n.type===`password`?`password field`:`card field`;let r=fe(n),i=o(he(n),60).replace(/"/g,`'`);return o(i?`${r} "${i}"`:r,200)}function v(e=location.href){try{let t=new URL(c(e));return o(`${t.pathname}${t.search}`,500)}catch{return`/`}}function _e(e,t={}){let n=t.doc??document,r=t.ignore??(()=>!1),i=``,a=null,o=t=>{try{e.push(t)}catch{}},s=e=>{if(!e||typeof e.nodeType!=`number`)return null;let t=e;return t.nodeType===1?t:t.parentElement},c=e=>{try{if(r(e.target))return;let t=s(e.target);if(!t)return;a=null,o({kind:`click`,at:new Date().toISOString(),path:v(),target:ge(t)})}catch{}},l=e=>{try{if(r(e.target))return;let t=s(e.target);if(!t)return;let n=h(t,le)??t;if(n.tagName===`INPUT`&&/^(checkbox|radio)$/i.test(n.type)||n===a)return;a=n,o({kind:`input`,at:new Date().toISOString(),path:v(),target:ge(n)})}catch{}},u=()=>{try{let e=v();if(e===i)return;i=e,a=null,o({kind:`navigation`,at:new Date().toISOString(),path:e})}catch{}};return n.addEventListener(`click`,c,!0),n.addEventListener(`input`,l,!0),u(),{navigated:u,stop:()=>{n.removeEventListener(`click`,c,!0),n.removeEventListener(`input`,l,!0)}}}var ve=[`error`,`warn`,`log`,`info`,`debug`],y=2e3,b=4e3;function x(e,t=0){if(typeof e==`string`)return e;if(e instanceof Error)return`${e.name}: ${e.message}`;if(e==null)return String(e);if(typeof e==`function`)return`[function ${e.name||``}]`;if(typeof e!=`object`)return String(e);if(typeof Node<`u`&&e instanceof Node)return`[${e.nodeName.toLowerCase()}]`;if(t>0)return Array.isArray(e)?`[…]`:`{…}`;try{let t=new WeakSet;return o(JSON.stringify(e,(e,n)=>{if(n&&typeof n==`object`){if(t.has(n))return`[circular]`;t.add(n)}return n})??String(e),y)}catch{return Object.prototype.toString.call(e)}}function ye(e){return o(e.map(e=>x(e)).join(` `),y)}function be(e){let t=e.find(e=>e instanceof Error);return t?.stack?o(t.stack,b):void 0}function xe(){let e=Error().stack;if(!e)return;let t=e.split(`
1
+ (function(){var e=``;function t(t){e=t}var n=new Map;function r(t){let r=n.get(t);return r||(r=import(new URL(`${t}?v=1.0.0-beta.2`,e||document.baseURI).href),n.set(t,r),r.catch(()=>{n.delete(t)})),r}function i(){return r(`pinax-editor.js`)}function a(){return r(`pinax-recorder.js`)}function o(){return r(`pinax-axe.js`)}function s(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}var c=/^(access_?token|token|id_token|refresh_token|auth|authorization|api_?key|key|secret|password|passwd|pwd|session|sessionid|sid|code|signature|sig)$/i;function l(e,t){try{let n=new URL(e,t);n.hash=``,n.username=``,n.password=``;for(let e of[...n.searchParams.keys()])c.test(e)&&n.searchParams.set(e,`[hidden]`);return n.toString()}catch{return String(e)}}var u=/^(utm_\w*|page|lang|ref|variant|tab|sort)$/i;function d(e,t){let n=e.indexOf(`?`);if(n<0)return e;let r=e.slice(n+1).split(`&`).map(e=>{let n=e.indexOf(`=`);if(n<0||n===e.length-1)return e;let r=e.slice(0,n),i=r;try{i=decodeURIComponent(r.replace(/\+/g,` `))}catch{}return t?.test(i)?e:`${r}=…`}).join(`&`);return`${e.slice(0,n)}?${r}`}function f(e,t){return d(l(e,t))}var p=/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g,ee=/(?<![\w+])(?:\+\d{1,3}|\(?0\d{1,4}\)?|\(?\d{3}\)?)(?:[ .-]?\(?\d{1,5}\)?){1,6}(?![\w])/g,te=/^\(?\d{3}\)?[ .-]\d{3}[ .-]\d{4}$/;function ne(e){let t=e.trim(),n=t.replace(/\D/g,``).length;return t.startsWith(`+`)?n>=8&&n<=15:/^\(?0/.test(t)?n>=10&&n<=12:n===10&&te.test(t)}function re(e){let t=[];if(e.length<7)return t;if(e.includes(`@`))for(let n of e.matchAll(p))t.push({start:n.index??0,end:(n.index??0)+n[0].length,kind:`email`});if(/\d{2}/.test(e))for(let n of e.matchAll(ee)){let e=n.index??0,r=e+n[0].length;ne(n[0])&&(t.some(t=>e<t.end&&r>t.start)||t.push({start:e,end:r,kind:`phone`}))}return t.sort((e,t)=>e.start-t.start)}function m(e){let t=re(e);if(!t.length)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+`*`.repeat(i.end-i.start),r=i.end;return n+e.slice(r)}var ie=[`see`,`keyboard`,`screen-reader`,`media`,`other`],h={message:5e3,email:320,entries:50,annotations:200,screenshotChars:6e6,screenshotBytes:4718592,breadcrumbs:20,followUpQuestion:300,followUpAnswer:2e3,replayChars:45e5,fields:10,fieldId:40,fieldText:200,bodyBytes:11534336},ae=65536,oe=/^[A-Za-z0-9+/=]+$/,se=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/,ce=/^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/;function g(e){return e.length<=h.email&&se.test(e)}function le(e){let t=e.slice(e.indexOf(`,`)+1),n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return Math.floor(t.length*3/4)-n}function ue(e){return e.length<=h.screenshotChars&&ce.test(e)&&le(e)<=h.screenshotBytes}function de(e){return e.message.trim().length>0||e.type===`GENERAL`&&e.rating!==void 0||e.type===`ACCESSIBILITY`&&e.barrier!==void 0||e.screenshot!==void 0}var _=(e,t)=>Number.isFinite(e)?Math.round(Math.min(1,Math.max(t,e))*1e4)/1e4:0;function v(e){let t=d(l(e),u);return t.length<=2e3?t:s(t.split(`?`)[0],2e3)}function fe(e){if(!e)return;let t={};return e.id!=null&&String(e.id)&&(t.id=s(String(e.id),200)),e.name&&(t.name=s(String(e.name),200)),Object.keys(t).length?t:void 0}function pe(e,t){let n={type:e.type,message:s(e.message.trim(),h.message),page:{url:v(t.page.url),title:t.page.title?s(t.page.title,500):void 0},environment:t.environment};e.type===`GENERAL`&&e.rating!==void 0&&Number.isInteger(e.rating)&&e.rating>=1&&e.rating<=5&&(n.rating=e.rating);let r=e.email?.trim().toLowerCase();r&&g(r)&&(n.email=r);let i=fe(e.user);i&&(n.user=i),t.console.length&&(n.console=t.console.slice(-h.entries).map(e=>{let t={...e,message:m(e.message)};return e.stack&&(t.stack=m(e.stack)),t})),t.network.length&&(n.network=t.network.slice(-h.entries)),t.breadcrumbs?.length&&(n.breadcrumbs=t.breadcrumbs.slice(-h.breadcrumbs).map(e=>{let t={kind:e.kind,at:s(e.at,40),path:s(e.path,500)};return e.target&&(t.target=s(m(e.target),200)),t}));let a=e.followUp?.question.trim(),o=e.followUp?.answer.trim();a&&o&&(n.followUp={question:s(a,h.followUpQuestion),answer:s(o,h.followUpAnswer)});let c=(e.fields??[]).filter(e=>typeof e.id==`string`&&e.id.length<=h.fieldId&&(typeof e.value==`boolean`||typeof e.value==`string`&&e.value.trim())).slice(0,h.fields).map(e=>({id:e.id,value:typeof e.value==`boolean`?e.value:s(e.value.trim(),h.fieldText)}));return c.length&&(n.fields=c),e.type===`ACCESSIBILITY`&&(e.barrier&&ie.includes(e.barrier)&&(n.barrier=e.barrier),e.a11yScan&&(n.a11yScan=e.a11yScan)),e.consent&&(n.consent={diagnostics:e.consent.diagnostics===!0,replay:e.consent.replay===!0}),e.includeLogs===!0&&(n.includeLogs=!0),e.hp&&(n.hp=s(e.hp,500)),e.elapsedMs!==void 0&&Number.isFinite(e.elapsedMs)&&e.elapsedMs>=0&&(n.elapsedMs=Math.min(Math.round(e.elapsedMs),864e5)),e.screenshot&&ue(e.screenshot)&&(n.screenshot=e.screenshot,e.annotations?.length&&(n.annotations=e.annotations.slice(0,h.annotations).map(e=>{let t=e.type===`arrow`?-1:0,n={type:e.type,x:_(e.x,0),y:_(e.y,0),w:_(e.w,t),h:_(e.h,t)};return e.type===`text`&&e.text&&(n.text=s(e.text,500)),n}))),n}function me(e){return new TextEncoder().encode(JSON.stringify(e)).length}function he(e,t){return!t||t.length>h.replayChars||!oe.test(t)||me(e)+t.length+12>h.bodyBytes-ae?!1:(e.replay=t,!0)}function ge(e){return(e||`https://api.getpinax.com`).replace(/\/+$/,``)}function _e(e,t){let n=e??(t?``:`https://cdn.getpinax.com`);return n?n.replace(/\/+$/,``):null}function ve(e,t){return`${e}/config/${encodeURIComponent(t)}.json`}function y(e,t,n){return`${e}/v1/widget/${encodeURIComponent(t)}/${n}`}async function ye(e,t){let n=await e(t,{credentials:`omit`});if(!n.ok)return{status:n.status,config:null};let r=await n.json();return{status:n.status,config:r?.data??null}}async function be(e,t,n,r=null){if(r)try{let{config:t}=await ye(e,ve(r,n));if(t)return t}catch{}return(await ye(e,y(t,n,`config`))).config}function xe(e,t,n,r){try{if(!new URL(r).searchParams.has(`pinax_verify`))return;e(y(t,n,`ping`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:v(r)})}).catch(()=>{})}catch{}}var Se={403:`Feedback isn't switched on for this website yet.`,404:`Feedback isn't switched on for this website yet.`,413:`That screenshot is too big to send. Remove it and try again.`,429:`Too many reports from this device. Please try again in a few minutes.`};async function Ce(e,t,n,r){let i;try{i=await e(y(t,n,`reports`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})}catch{return{ok:!1,retry:!0,status:0,message:`You're offline. We'll send it when you're back.`}}let a=null;try{a=await i.json()}catch{}if(i.ok)return{ok:!0,id:a?.data?.id??``};let o=i.status;return{ok:!1,retry:o>=500,status:o,message:Se[o]??(o===400&&a?.message?a.message:`Something went wrong. Please try again.`)}}var we=4e3;async function Te(e,t,n,r,i=we){let a=typeof AbortController==`function`?new AbortController:null,o,s=new Promise(e=>{o=setTimeout(()=>{a?.abort(),e(null)},i)}),c=(async()=>{try{let i=await e(y(t,n,`follow-up`),{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:r.type,message:r.message.trim().slice(0,2e3),pagePath:r.pagePath.slice(0,500)||`/`}),signal:a?.signal});if(!i.ok)return null;let o=(await i.json())?.data?.question;return typeof o==`string`&&o.trim()?o.trim().slice(0,300):null}catch{return null}})();try{return await Promise.race([c,s])}finally{clearTimeout(o)}}function Ee(e,t,n,r,i=`fix-check`){try{e(y(t,n,i),{method:`POST`,credentials:`omit`,keepalive:!0,headers:{"Content-Type":`application/json`},body:JSON.stringify({checkId:r.checkId.slice(0,64),signature:r.signature.slice(0,300),...i===`sighting`&&r.basket?{basket:r.basket}:{},...r.consent?{consent:!0}:{}})}).catch(()=>{})}catch{}}function De(e,t,n){return n?`${n}/count/${encodeURIComponent(t)}`:y(e,t,`count`)}function Oe(e,t,n,r){try{e(De(t,n,r),{method:`POST`,credentials:`omit`,keepalive:!0}).catch(()=>{})}catch{}}async function ke(e,t,n){try{return(await e(t,{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})).ok}catch{return!1}}function Ae(e,t,n,r,i){return ke(e,y(t,n,`known/${encodeURIComponent(r)}/me-too`),i?{email:i.trim().slice(0,254)}:{})}var je=`input,textarea,select,[contenteditable]:not([contenteditable=false]),[data-pinax-mask],.pinax-mask`,Me=`[data-pinax-mask],.pinax-mask`,Ne=`a[href],button,input,select,textarea,summary,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=radio],[role=switch],[role=option],[contenteditable]:not([contenteditable=false])`,Pe={button:`button`,submit:`button`,reset:`button`,image:`button`,checkbox:`checkbox`,radio:`radio`,range:`slider`,search:`searchbox`};function b(e,t){try{return e.matches(t)}catch{return!1}}function x(e,t){try{return e.closest(t)}catch{return null}}var S=e=>e.replace(/\s+/g,` `).trim();function Fe(e){if(e.tagName!==`INPUT`)return!1;let t=e,n=(t.getAttribute(`autocomplete`)??``).toLowerCase(),r=`${t.name} ${t.id}`.toLowerCase();return t.type===`password`||n.includes(`cc-`)||n.includes(`password`)||/\b(card|cc|cvc|cvv|iban)/.test(r)}function Ie(e){let t=e.getAttribute(`role`)?.trim().split(/\s+/)[0];if(t)return t;let n=e.tagName.toLowerCase();switch(n){case`a`:return e.hasAttribute(`href`)?`link`:`text`;case`button`:case`summary`:return`button`;case`input`:return Pe[e.type?.toLowerCase()]??`textbox`;case`textarea`:return`textbox`;case`select`:return`combobox`;case`img`:return`image`;case`h1`:case`h2`:case`h3`:case`h4`:case`h5`:case`h6`:return`heading`;default:return b(e,`[contenteditable]:not([contenteditable=false])`)?`textbox`:n}}function C(e,t=120){if(b(e,je)||x(e,Me))return``;let n=``,r=e=>{if(n.length>t)return;if(e.nodeType===3){n+=e.nodeValue??``;return}if(e.nodeType!==1)return;let i=e,a=i.tagName;if(a!==`SCRIPT`&&a!==`STYLE`&&a!==`TEMPLATE`&&!b(i,je)&&i.getAttribute(`aria-hidden`)!==`true`){if(a===`IMG`)n+=` ${i.getAttribute(`alt`)??``} `;else{for(let e of i.childNodes)r(e);/^(P|DIV|LI|BR|TD|TH|DT|DD)$/.test(a)&&(n+=` `)}}};for(let t of e.childNodes)r(t);return S(n)}function Le(e){let t=e.getAttribute(`aria-labelledby`);if(!t)return``;let n=e.ownerDocument;return S(t.split(/\s+/).map(e=>{let t=n.getElementById(e);return t?C(t):``}).join(` `))}function Re(e){let t=e;return S((t.labels?[...t.labels]:[]).map(e=>C(e)).join(` `))||S(t.getAttribute(`placeholder`)??``)||S(t.getAttribute(`title`)??``)||S(t.getAttribute(`name`)??``)}function ze(e){if(x(e,Me))return``;let t=S(e.getAttribute(`aria-label`)??``);if(t)return t;let n=Le(e);if(n)return n;let r=e.tagName;if(r===`INPUT`){let t=e.type?.toLowerCase();return t===`submit`||t===`button`||t===`reset`?S(e.getAttribute(`value`)??``):t===`image`?S(e.getAttribute(`alt`)??``):Re(e)}return r===`TEXTAREA`||r===`SELECT`?Re(e):b(e,`[contenteditable]:not([contenteditable=false])`)?S(e.getAttribute(`title`)??``):r===`IMG`?S(e.getAttribute(`alt`)??``):C(e)||S(e.getAttribute(`title`)??``)}function Be(e){let t=x(e,Ne);if(!t)return s(Ie(e),200);let n=t;if(Fe(n))return n.type===`password`?`password field`:`card field`;let r=Ie(n),i=s(ze(n),60).replace(/"/g,`'`);return s(i?`${r} "${i}"`:r,200)}function w(e=location.href){try{let t=new URL(l(e));return s(d(`${t.pathname}${t.search}`),500)}catch{return`/`}}function Ve(e,t={}){let n=t.doc??document,r=t.ignore??(()=>!1),i=``,a=null,o=t=>{try{e.push(t)}catch{}},s=e=>{if(!e||typeof e.nodeType!=`number`)return null;let t=e;return t.nodeType===1?t:t.parentElement},c=e=>{try{if(r(e.target))return;let t=s(e.target);if(!t)return;a=null,o({kind:`click`,at:new Date().toISOString(),path:w(),target:Be(t)})}catch{}},l=e=>{try{if(r(e.target))return;let t=s(e.target);if(!t)return;let n=x(t,Ne)??t;if(n.tagName===`INPUT`&&/^(checkbox|radio)$/i.test(n.type)||n===a)return;a=n,o({kind:`input`,at:new Date().toISOString(),path:w(),target:Be(n)})}catch{}},u=()=>{try{let e=location.pathname+location.search;if(e===i)return;i=e,a=null,o({kind:`navigation`,at:new Date().toISOString(),path:w()})}catch{}};return n.addEventListener(`click`,c,!0),n.addEventListener(`input`,l,!0),u(),{navigated:u,stop:()=>{n.removeEventListener(`click`,c,!0),n.removeEventListener(`input`,l,!0)}}}var He=[`error`,`warn`,`log`,`info`,`debug`],T=2e3,E=4e3;function Ue(e,t=0){if(typeof e==`string`)return e;if(e instanceof Error)return`${e.name}: ${e.message}`;if(e==null)return String(e);if(typeof e==`function`)return`[function ${e.name||``}]`;if(typeof e!=`object`)return String(e);if(typeof Node<`u`&&e instanceof Node)return`[${e.nodeName.toLowerCase()}]`;if(t>0)return Array.isArray(e)?`[…]`:`{…}`;try{let t=new WeakSet;return s(JSON.stringify(e,(e,n)=>{if(n&&typeof n==`object`){if(t.has(n))return`[circular]`;t.add(n)}return n})??String(e),T)}catch{return Object.prototype.toString.call(e)}}function We(e){return s(e.map(e=>Ue(e)).join(` `),T)}function Ge(e){let t=e.find(e=>e instanceof Error);return t?.stack?s(t.stack,E):void 0}function Ke(){let e=Error().stack;if(!e)return;let t=e.split(`
2
2
  `),n=t[0].startsWith(`Error`)?3:2,r=t.slice(n).join(`
3
- `);return r?o(r,b):void 0}function Se(e,t=window){let n=t.console,r=new Map,i=new Map,a=!1,s=t=>{try{e.push(t)}catch{}};for(let e of ve){let t=n?.[e];if(typeof t!=`function`)continue;let o=function(...n){if(!a){a=!0;try{s({level:e,message:ye(n),stack:be(n)??(e===`error`||e===`warn`?xe():void 0),at:new Date().toISOString()})}catch{}finally{a=!1}}return t.apply(this,n)};o.__pinaxOriginal=t,r.set(e,t),i.set(e,o);try{n[e]=o}catch{}}let c=e=>{try{if(!e.message&&!e.error)return;let t=e.error,n=e.filename?` (${e.filename}:${e.lineno}:${e.colno})`:``;s({level:`error`,message:o(`Uncaught ${t?.name?`${t.name}: ${t.message}`:e.message}${n}`,y),stack:t?.stack?o(t.stack,b):void 0,at:new Date().toISOString()})}catch{}},l=e=>{try{let t=e.reason;s({level:`error`,message:o(`Unhandled promise rejection: ${x(t)}`,y),stack:t instanceof Error&&t.stack?o(t.stack,b):void 0,at:new Date().toISOString()})}catch{}};return t.addEventListener(`error`,c),t.addEventListener(`unhandledrejection`,l),()=>{t.removeEventListener(`error`,c),t.removeEventListener(`unhandledrejection`,l);for(let[e,t]of r)try{n[e]===i.get(e)&&(n[e]=t)}catch{}}}var Ce={"10.0":`10/11`,"6.3":`8.1`,"6.2":`8`,"6.1":`7`};function S(e,t){return t.exec(e)?.[1]}function C(e){if(e)return e.replace(/_/g,`.`).split(`.`).slice(0,2).join(`.`)}function we(e,t=0){let n={deviceType:`desktop`};for(let[t,r]of[[`Edge`,/Edg(?:e|A|iOS)?\/([\d.]+)/],[`Opera`,/(?:OPR|OPiOS)\/([\d.]+)/],[`Samsung Internet`,/SamsungBrowser\/([\d.]+)/],[`Firefox`,/(?:Firefox|FxiOS)\/([\d.]+)/],[`Chrome`,/(?:Chrome|CriOS)\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari\//]]){let i=S(e,r);if(i){n.browser=t,n.browserVersion=C(i);break}}!n.browser&&/AppleWebKit/.test(e)&&/Mobile\//.test(e)&&(n.browser=`Safari (in-app)`);let r=/iPad/.test(e)||/Macintosh/.test(e)&&t>1;if(/iPhone|iPod/.test(e))n.os=`iOS ${C(S(e,/OS ([\d_]+) like Mac/))??``}`.trim(),n.deviceType=`mobile`,n.deviceModel=/iPod/.test(e)?`iPod`:`iPhone`;else if(r){let t=C(S(e,/OS ([\d_]+) like Mac/));n.os=t?`iPadOS ${t}`:`iPadOS`,n.deviceType=`tablet`,n.deviceModel=`iPad`}else if(/Android/.test(e)){n.os=`Android ${S(e,/Android ([\d.]+)/)??``}`.trim(),n.deviceType=/Mobile/.test(e)?`mobile`:`tablet`;let t=S(e,/Android [\d.]+;(?: [a-z]{2}[-_][a-z]{2};)? ([^;)]+?)(?: Build\/[^;)]*)?\)/i);t&&t!==`K`&&!/^wv$/.test(t)&&(n.deviceModel=t.trim())}else if(/CrOS/.test(e))n.os=`ChromeOS`;else if(/Windows NT/.test(e)){let t=S(e,/Windows NT ([\d.]+)/);n.os=t&&Ce[t]?`Windows ${Ce[t]}`:`Windows`}else/Mac OS X/.test(e)?n.os=`macOS ${C(S(e,/Mac OS X ([\d_.]+)/))??``}`.trim():/Linux/.test(e)&&(n.os=`Linux`);return n.deviceType===`desktop`&&/Mobi|Tablet|Kindle|Silk/.test(e)&&(n.deviceType=/Tablet|Kindle|Silk/.test(e)?`tablet`:`mobile`),n}var w=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.round(e)):0;function Te(e=new Date){let t=(e,t=2)=>String(Math.abs(e)).padStart(t,`0`),n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`;return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${t(e.getMilliseconds(),3)}${r}${t(Math.trunc(n/60))}:${t(n%60)}`}function Ee(e=window){let t=e.navigator,n=t?.userAgent??``,r=we(n,t?.maxTouchPoints??0),i=`UTC`;try{i=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{}let a=(e,t)=>e?o(e,t):void 0;return{userAgent:o(n,1e3),browser:a(r.browser,100),browserVersion:a(r.browserVersion,50),os:a(r.os,100),deviceType:r.deviceType,deviceModel:a(r.deviceModel,100),screen:{w:w(e.screen?.width),h:w(e.screen?.height)},viewport:{w:w(e.innerWidth),h:w(e.innerHeight)},pixelRatio:Math.min(10,Math.max(0,e.devicePixelRatio||1)),timeZone:o(i,100),language:a(t?.language,35),occurredAt:Te()}}function De(e,t){return e===0||e>=400||t>2e3}function Oe(e,t=window,n={}){let r=n.now??(()=>typeof performance<`u`?performance.now():Date.now()),i=t.location?.href,a=n.ignore??(()=>!1),s=(t,n,s,l,u)=>{try{let d=Math.max(0,Math.round(r()-l));if(!De(s,d))return;let f=c(n,i);if(a(f))return;e.push({method:o(t.toUpperCase(),10),url:o(f,2e3),status:Math.min(999,Math.max(0,s|0)),durationMs:Math.min(6e5,d),at:u})}catch{}},l=[],u=t.fetch;if(typeof u==`function`){let e=(e,n)=>{let i=`GET`,a=``,o=r(),c=new Date().toISOString();try{typeof e==`string`?a=e:e instanceof URL?a=e.href:e&&typeof e.url==`string`&&(a=e.url,i=e.method||i),n?.method&&(i=n.method)}catch{}let l=u.call(t,e,n);try{l.then(e=>s(i,a,e?.status??0,o,c),()=>s(i,a,0,o,c))}catch{}return l};try{t.fetch=e,l.push(()=>{t.fetch===e&&(t.fetch=u)})}catch{}}let d=t.XMLHttpRequest;if(d?.prototype){let e=d.prototype,t=e.open,n=e.send,i=new WeakMap,a=new WeakMap,o=new WeakSet,c=function(e,n,...r){try{i.set(this,{method:String(e),url:String(n)})}catch{}return t.call(this,e,n,...r)},u=function(e){try{let e=i.get(this);e&&(a.set(this,{m:e,start:r(),startedAt:new Date().toISOString(),aborted:!1}),o.has(this)||(o.add(this),this.addEventListener(`abort`,()=>{let e=a.get(this);e&&(e.aborted=!0)}),this.addEventListener(`loadend`,()=>{let e=a.get(this);a.delete(this),e&&!e.aborted&&s(e.m.method,e.m.url,this.status,e.start,e.startedAt)})))}catch{}return n.call(this,e)};e.open=c,e.send=u,l.push(()=>{e.open===c&&(e.open=t),e.send===u&&(e.send=n)})}return()=>{for(let e of l)try{e()}catch{}}}var T=class{constructor(e){this.capacity=e,this.items=[],this.listeners=new Set}push(e){this.items.push(e),this.items.length>this.capacity&&this.items.shift();for(let t of this.listeners)try{t(e)}catch{}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}toArray(){return this.items.slice()}clear(){this.items=[]}get size(){return this.items.length}};function ke(e){return e.replace(/https?:\/\/\S+/g,`<url>`).replace(/\b[0-9a-f]{8,}\b/gi,`<id>`).replace(/\d+/g,`<n>`).replace(/\s+/g,` `).trim().slice(0,200)}function Ae(e,t){let n=(Array.isArray(e)?e:[]).filter(e=>e.level===`error`);if(n[0]?.message)return`console:${ke(n[0].message)}`;let r=(Array.isArray(t)?t:[]).find(e=>e.status===0||e.status>=500);if(r){let e=r.url;try{e=new URL(r.url).pathname}catch{}return`network:${r.method.toUpperCase()} ${ke(e)} ${r.status===0?`failed`:`5xx`}`}return null}function je(e){return e.level===`error`?Ae([e],[]):null}function Me(e){return Ae([],[e])}function Ne(e){let t=e.path??(()=>location.pathname),n=e.random??Math.random,r=e.now??Date.now,i=[],a=new Set,o=r(),s=null,c=t=>{if(t){for(let n of i)if(!(n.signature!==t||a.has(n.id))){a.add(n.id);try{e.report(n)}catch{}}}},l=e=>{let t=Date.parse(e);return Number.isNaN(t)||t>=o-1},u=r=>{let u=t();if(s=u,o=r,a=new Set,i=e.checks.filter(t=>Pe(t.path,u)&&e.sampleRate>0&&n()<e.sampleRate),i.length){for(let t of e.console.toArray())l(t.at)&&c(je(t));for(let t of e.network.toArray())l(t.at)&&c(Me(t))}},d=e.console.subscribe(e=>{i.length&&c(je(e))}),f=e.network.subscribe(e=>{i.length&&c(Me(e))}),p=typeof performance<`u`&&performance.timeOrigin?performance.timeOrigin:r();return u(Math.min(p,r())),{navigated:()=>{t()!==s&&u(r())},stop:()=>{d(),f(),i=[]}}}function Pe(e,t){let n=e=>e.length>1?e.replace(/\/+$/,``):e;return n(e)===n(t)}var E=`pinax-widget-root`;function Fe(e=document){let t=e.getElementById(E);if(t?.shadowRoot)return t.shadowRoot;let n=e.createElement(`div`);return n.id=E,n.className=`ph-no-capture fs-exclude`,n.setAttribute(`data-hj-suppress`,``),n.setAttribute(`data-clarity-mask`,`true`),n.setAttribute(`data-private`,``),n.style.cssText=`all: initial; position: fixed; z-index: 2147483647;`,e.body.appendChild(n),n.attachShadow({mode:`open`})}function Ie(e=document){e.getElementById(E)?.remove()}function Le(e,t=window){let n=!0,r=!1,i=()=>{if(!n||r)return;r=!0;let t=()=>{if(r=!1,n)try{e()}catch{}};try{queueMicrotask(t)}catch{setTimeout(t,0)}},a=[],o=t.history;for(let e of[`pushState`,`replaceState`]){let t=o?.[e];if(typeof t!=`function`)continue;let n=function(...e){let n=t.apply(this,e);return i(),n};try{o[e]=n,a.push(()=>{o[e]===n&&(o[e]=t)})}catch{}}return t.addEventListener(`popstate`,i),a.push(()=>t.removeEventListener(`popstate`,i)),()=>{n=!1;for(let e of a)try{e()}catch{}}}var D=new Map;function Re(e){let t=D.get(e);if(!t){let n=ze(e.trim()).split(`*`).map(e=>e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`)).join(`.*`);t=RegExp(`^${n}$`),D.size>200&&D.clear(),D.set(e,t)}return t}function ze(e){return e.length>1?e.replace(/\/+$/,``)||`/`:e}function Be(e){try{return decodeURI(e)}catch{return e}}function Ve(e,t){if(typeof e!=`string`||!e.trim())return!1;let n=Re(e),r=ze(t||`/`),i=[r,`${r===`/`?``:r}/`],a=Be(r);return a!==r&&i.push(a,`${a}/`),i.some(e=>n.test(e))}function He(e,t){return e?.length?e.some(e=>Ve(e,t)):!1}var O={message:5e3,email:320,entries:50,annotations:200,screenshotChars:6e6,screenshotBytes:4718592,breadcrumbs:20,followUpQuestion:300,followUpAnswer:2e3,replayChars:45e5,fields:10,fieldId:40,fieldText:200,bodyBytes:11534336},Ue=65536,We=/^[A-Za-z0-9+/=]+$/,Ge=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/,Ke=/^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/;function k(e){return e.length<=O.email&&Ge.test(e)}function qe(e){let t=e.slice(e.indexOf(`,`)+1),n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return Math.floor(t.length*3/4)-n}function Je(e){return e.length<=O.screenshotChars&&Ke.test(e)&&qe(e)<=O.screenshotBytes}function Ye(e){return e.message.trim().length>0||e.type===`GENERAL`&&e.rating!==void 0||e.screenshot!==void 0}var A=(e,t)=>Number.isFinite(e)?Math.round(Math.min(1,Math.max(t,e))*1e4)/1e4:0;function Xe(e){let t=c(e);if(t.length<=2e3)return t;try{let e=new URL(t);return e.toString().length>2e3&&(e.search=``),o(e.toString(),2e3)}catch{return t.slice(0,2e3)}}function Ze(e){if(!e)return;let t={};e.id!=null&&String(e.id)&&(t.id=o(String(e.id),200)),e.name&&(t.name=o(String(e.name),200));let n=e.email?.trim();return n&&k(n)&&(t.email=n),Object.keys(t).length?t:void 0}function Qe(e,t){let n={type:e.type,message:o(e.message.trim(),O.message),page:{url:Xe(t.page.url),title:t.page.title?o(t.page.title,500):void 0},environment:t.environment};e.type===`GENERAL`&&e.rating!==void 0&&Number.isInteger(e.rating)&&e.rating>=1&&e.rating<=5&&(n.rating=e.rating);let r=e.email?.trim().toLowerCase();r&&k(r)&&(n.email=r);let i=Ze(e.user);i&&(n.user=i),t.console.length&&(n.console=t.console.slice(-O.entries)),t.network.length&&(n.network=t.network.slice(-O.entries)),t.breadcrumbs?.length&&(n.breadcrumbs=t.breadcrumbs.slice(-O.breadcrumbs).map(e=>{let t={kind:e.kind,at:o(e.at,40),path:o(e.path,500)};return e.target&&(t.target=o(e.target,200)),t}));let a=e.followUp?.question.trim(),s=e.followUp?.answer.trim();a&&s&&(n.followUp={question:o(a,O.followUpQuestion),answer:o(s,O.followUpAnswer)});let c=(e.fields??[]).filter(e=>typeof e.id==`string`&&e.id.length<=O.fieldId&&(typeof e.value==`boolean`||typeof e.value==`string`&&e.value.trim())).slice(0,O.fields).map(e=>({id:e.id,value:typeof e.value==`boolean`?e.value:o(e.value.trim(),O.fieldText)}));return c.length&&(n.fields=c),e.hp&&(n.hp=o(e.hp,500)),e.elapsedMs!==void 0&&Number.isFinite(e.elapsedMs)&&e.elapsedMs>=0&&(n.elapsedMs=Math.min(Math.round(e.elapsedMs),864e5)),e.screenshot&&Je(e.screenshot)&&(n.screenshot=e.screenshot,e.annotations?.length&&(n.annotations=e.annotations.slice(0,O.annotations).map(e=>{let t=e.type===`arrow`?-1:0,n={type:e.type,x:A(e.x,0),y:A(e.y,0),w:A(e.w,t),h:A(e.h,t)};return e.type===`text`&&e.text&&(n.text=o(e.text,500)),n}))),n}function $e(e){return new TextEncoder().encode(JSON.stringify(e)).length}function et(e,t){return!t||t.length>O.replayChars||!We.test(t)||$e(e)+t.length+12>O.bodyBytes-Ue?!1:(e.replay=t,!0)}var tt=864e5,nt=8,j=e=>`pinax:queue:${e}`;function M(e,t){try{let n=e.getItem(j(t)),r=n?JSON.parse(n):[];return Array.isArray(r)?r:[]}catch{return[]}}function rt(e,t,n){try{return n.length?e.setItem(j(t),JSON.stringify(n)):e.removeItem(j(t)),!0}catch{return!1}}function N(){try{return window.localStorage}catch{return null}}function it(e){let{user:t,console:n,screenshot:r,annotations:i,replay:a,...o}=e;return{...o,page:{...o.page,url:Xe(o.page.url)}}}function at(e,t){let n=N();return n?rt(n,e,[...M(n,e).slice(-4),{body:it(t),queuedAt:Date.now(),tries:0}]):!1}function ot(e){let t=N();return t?M(t,e).length:0}var P=!1;async function st(e,t,n){let r=N();if(r&&!P&&(typeof navigator>`u`||navigator.onLine!==!1)){P=!0;try{let i=M(r,n),a=[];for(let r of i){if(Date.now()-r.queuedAt>tt)continue;let i=await re(e,t,n,r.body);!i.ok&&i.retry&&r.tries+1<nt&&a.push({...r,tries:r.tries+1})}let o=M(r,n).slice(i.length);rt(r,n,[...a,...o])}finally{P=!1}}}var ct={opened:`Pinax Widget Opened`,submitted:`Feedback Submitted`};function F(e=window){try{let t=e.analytics;return!t||typeof t!=`object`&&typeof t!=`function`?null:typeof t.track==`function`?t:null}catch{return null}}function lt(e,t){return typeof e==`boolean`?e:t===!0}function ut(e,t){try{F()?.track?.(e,t)}catch{}}function dt(){ut(ct.opened,{source:`pinax`})}function ft(e){let t={source:`pinax`,type:e.type.toLowerCase()};typeof e.rating==`number`&&(t.rating=e.rating),e.reportId&&(t.reportId=e.reportId),e.queued&&(t.queued=!0),ut(ct.submitted,t)}function pt(){try{let e=F()?.user?.()?.id?.();return typeof e==`string`&&e.trim()?e.trim().slice(0,200):typeof e==`number`&&Number.isFinite(e)?String(e):null}catch{return null}}var mt={color:`#B8F35C`,text:`Feedback`,position:`bottom-right`,types:{problem:!0,idea:!0,general:!0},rating:!0,hidePaths:[],smallOnMobile:!1,hideButton:!1,segment:!1,wording:{chooserTitle:``,problemTitle:``,ideaTitle:``,generalTitle:``,messagePlaceholder:``,confirmation:``},fields:[],capture:{console:!0,network:!0}},I={fields:10,label:80,options:20,option:80,text:200},ht=[`bottom-right`,`bottom-left`,`right-edge`],gt=Object.keys(mt.wording),L=(e,t)=>typeof e==`string`?e.trim().slice(0,t):``,R=(e,t)=>typeof e==`boolean`?e:t,_t=[`select`,`text`,`checkbox`];function vt(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=typeof e.id==`string`?e.id.slice(0,40):``,a=e.type,o=L(e.label,I.label);if(!i||n.has(i)||!_t.includes(a)||!o)continue;let s=a===`select`&&Array.isArray(e.options)?[...new Set(e.options.map(e=>L(e,I.option)).filter(Boolean))].slice(0,I.options):[];if(a===`select`&&!s.length)continue;let c=e.types??{};if(n.add(i),t.push({id:i,type:a,label:o,required:e.required===!0,options:s,types:{problem:R(c.problem,!0),idea:R(c.idea,!0),general:R(c.general,!0)}}),t.length>=I.fields)break}return t}function yt(e){let t=e??{},n=mt,r=t.types??{},i={problem:R(r.problem,!0),idea:R(r.idea,!0),general:R(r.general,!0)},a=i.problem||i.idea||i.general,o=t.wording??{},s={...n.wording};for(let e of gt)s[e]=L(o[e],120);return{color:typeof t.color==`string`?t.color:n.color,text:L(t.text,40)||n.text,position:ht.includes(t.position)?t.position:n.position,types:a?i:{...n.types},rating:R(t.rating,n.rating),hidePaths:Array.isArray(t.hidePaths)?t.hidePaths.filter(e=>typeof e==`string`):[],smallOnMobile:R(t.smallOnMobile,n.smallOnMobile),hideButton:R(t.hideButton,n.hideButton),segment:R(t.segment,n.segment),wording:s,fields:vt(t.fields),capture:{console:R(t.capture?.console,!0),network:R(t.capture?.network,!0)}}}var bt=/^#[0-9a-fA-F]{6}$/,xt=e=>typeof e==`string`&&bt.test(e)?e:null;function St(e){let t=e&&typeof e==`object`?e:{},n=typeof t.logoUrl==`string`&&/^https?:\/\//i.test(t.logoUrl)?t.logoUrl.slice(0,2e3):null;return{poweredBy:t.poweredBy===!0,logoUrl:n,primary:xt(t.primary),accent:xt(t.accent)}}var z=e=>typeof e==`number`&&Number.isFinite(e)?Math.min(1,Math.max(0,e)):0;function Ct(e,t){let n=e&&typeof e==`object`?e:{},r=typeof t==`number`?z(t):1,i=Array.isArray(n.fixChecks)?n.fixChecks:[];return{followUp:n.followUp===!0,autoBlur:n.autoBlur===!0,replay:n.replay===!0,replaySampleRate:Math.min(n.replaySampleRate===void 0?1:z(n.replaySampleRate),r),fixChecks:i.filter(e=>!!e&&typeof e.id==`string`&&typeof e.path==`string`&&typeof e.signature==`string`),fixCheckSampleRate:Math.min(z(n.fixCheckSampleRate),r)}}function B(e){let t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;let n=t[1];n.length===3&&(n=[...n].map(e=>e+e).join(``));let[r,i,a]=[0,2,4].map(e=>{let t=Number.parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function wt(e,t){let[n,r]=e>t?[e,t]:[t,e];return(n+.05)/(r+.05)}function V(e){let t=B(e);return t===null?`#FFFFFF`:wt(t,B(`#0B1300`))>=wt(t,1)?`#0B1300`:`#FFFFFF`}function H(e,t=`#B8F35C`){return typeof e==`string`&&B(e)!==null?e.trim():t}function U(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.setAttribute(e,n===!0?``:String(n));for(let e of n)e!=null&&e!==!1&&r.append(e);return r}var Tt=`http://www.w3.org/2000/svg`;function W(e,t=16){let n=document.createElementNS(Tt,`svg`);n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2.2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`);let r=document.createElementNS(Tt,`path`);return r.setAttribute(`d`,e),n.append(r),n}var G={close:`M18 6L6 18M6 6l12 12`,back:`M15 18l-6-6 6-6`,pen:`M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`,camera:`M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2zM12 17a4 4 0 100-8 4 4 0 000 8z`,trash:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`},Et=`
3
+ `);return r?s(r,E):void 0}function qe(e,t=window){let n=t.console,r=new Map,i=new Map,a=!1,o=t=>{try{e.push(t)}catch{}};for(let e of He){let t=n?.[e];if(typeof t!=`function`)continue;let s=function(...n){if(!a){a=!0;try{o({level:e,message:We(n),stack:Ge(n)??(e===`error`||e===`warn`?Ke():void 0),at:new Date().toISOString()})}catch{}finally{a=!1}}return t.apply(this,n)};s.__pinaxOriginal=t,r.set(e,t),i.set(e,s);try{n[e]=s}catch{}}let c=e=>{try{if(!e.message&&!e.error)return;let t=e.error,n=e.filename?` (${e.filename}:${e.lineno}:${e.colno})`:``;o({level:`error`,message:s(`Uncaught ${t?.name?`${t.name}: ${t.message}`:e.message}${n}`,T),stack:t?.stack?s(t.stack,E):void 0,at:new Date().toISOString()})}catch{}},l=e=>{try{let t=e.reason;o({level:`error`,message:s(`Unhandled promise rejection: ${Ue(t)}`,T),stack:t instanceof Error&&t.stack?s(t.stack,E):void 0,at:new Date().toISOString()})}catch{}};return t.addEventListener(`error`,c),t.addEventListener(`unhandledrejection`,l),()=>{t.removeEventListener(`error`,c),t.removeEventListener(`unhandledrejection`,l);for(let[e,t]of r)try{n[e]===i.get(e)&&(n[e]=t)}catch{}}}var Je={"10.0":`10/11`,"6.3":`8.1`,"6.2":`8`,"6.1":`7`};function D(e,t){return t.exec(e)?.[1]}function O(e){if(e)return e.replace(/_/g,`.`).split(`.`).slice(0,2).join(`.`)}function Ye(e,t=0){let n={deviceType:`desktop`};for(let[t,r]of[[`Edge`,/Edg(?:e|A|iOS)?\/([\d.]+)/],[`Opera`,/(?:OPR|OPiOS)\/([\d.]+)/],[`Samsung Internet`,/SamsungBrowser\/([\d.]+)/],[`Firefox`,/(?:Firefox|FxiOS)\/([\d.]+)/],[`Chrome`,/(?:Chrome|CriOS)\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari\//]]){let i=D(e,r);if(i){n.browser=t,n.browserVersion=O(i);break}}!n.browser&&/AppleWebKit/.test(e)&&/Mobile\//.test(e)&&(n.browser=`Safari (in-app)`);let r=/iPad/.test(e)||/Macintosh/.test(e)&&t>1;if(/iPhone|iPod/.test(e))n.os=`iOS ${O(D(e,/OS ([\d_]+) like Mac/))??``}`.trim(),n.deviceType=`mobile`,n.deviceModel=/iPod/.test(e)?`iPod`:`iPhone`;else if(r){let t=O(D(e,/OS ([\d_]+) like Mac/));n.os=t?`iPadOS ${t}`:`iPadOS`,n.deviceType=`tablet`,n.deviceModel=`iPad`}else if(/Android/.test(e)){n.os=`Android ${D(e,/Android ([\d.]+)/)??``}`.trim(),n.deviceType=/Mobile/.test(e)?`mobile`:`tablet`;let t=D(e,/Android [\d.]+;(?: [a-z]{2}[-_][a-z]{2};)? ([^;)]+?)(?: Build\/[^;)]*)?\)/i);t&&t!==`K`&&!/^wv$/.test(t)&&(n.deviceModel=t.trim())}else if(/CrOS/.test(e))n.os=`ChromeOS`;else if(/Windows NT/.test(e)){let t=D(e,/Windows NT ([\d.]+)/);n.os=t&&Je[t]?`Windows ${Je[t]}`:`Windows`}else/Mac OS X/.test(e)?n.os=`macOS ${O(D(e,/Mac OS X ([\d_.]+)/))??``}`.trim():/Linux/.test(e)&&(n.os=`Linux`);return n.deviceType===`desktop`&&/Mobi|Tablet|Kindle|Silk/.test(e)&&(n.deviceType=/Tablet|Kindle|Silk/.test(e)?`tablet`:`mobile`),n}var k=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.round(e)):0;function Xe(e=new Date){let t=(e,t=2)=>String(Math.abs(e)).padStart(t,`0`),n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`;return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${t(e.getMilliseconds(),3)}${r}${t(Math.trunc(n/60))}:${t(n%60)}`}function Ze(e=window){let t=e.navigator,n=t?.userAgent??``,r=Ye(n,t?.maxTouchPoints??0),i=`UTC`;try{i=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{}let a=(e,t)=>e?s(e,t):void 0;return{userAgent:s(n,1e3),browser:a(r.browser,100),browserVersion:a(r.browserVersion,50),os:a(r.os,100),deviceType:r.deviceType,deviceModel:a(r.deviceModel,100),screen:{w:k(e.screen?.width),h:k(e.screen?.height)},viewport:{w:k(e.innerWidth),h:k(e.innerHeight)},pixelRatio:Math.min(10,Math.max(0,e.devicePixelRatio||1)),timeZone:s(i,100),language:a(t?.language,35),occurredAt:Xe()}}function Qe(e,t){return e===0||e>=400||t>2e3}function $e(e,t=window,n={}){let r=n.now??(()=>typeof performance<`u`?performance.now():Date.now()),i=t.location?.href,a=n.ignore??(()=>!1),o=(t,n,o,c,l)=>{try{let u=Math.max(0,Math.round(r()-c));if(!Qe(o,u))return;let d=f(n,i);if(a(d))return;e.push({method:s(t.toUpperCase(),10),url:s(d,2e3),status:Math.min(999,Math.max(0,o|0)),durationMs:Math.min(6e5,u),at:l})}catch{}},c=[],l=t.fetch;if(typeof l==`function`){let e=(e,n)=>{let i=`GET`,a=``,s=r(),c=new Date().toISOString();try{typeof e==`string`?a=e:e instanceof URL?a=e.href:e&&typeof e.url==`string`&&(a=e.url,i=e.method||i),n?.method&&(i=n.method)}catch{}let u=l.call(t,e,n);try{u.then(e=>o(i,a,e?.status??0,s,c),()=>o(i,a,0,s,c))}catch{}return u};try{t.fetch=e,c.push(()=>{t.fetch===e&&(t.fetch=l)})}catch{}}let u=t.XMLHttpRequest;if(u?.prototype){let e=u.prototype,t=e.open,n=e.send,i=new WeakMap,a=new WeakMap,s=new WeakSet,l=function(e,n,...r){try{i.set(this,{method:String(e),url:String(n)})}catch{}return t.call(this,e,n,...r)},d=function(e){try{let e=i.get(this);e&&(a.set(this,{m:e,start:r(),startedAt:new Date().toISOString(),aborted:!1}),s.has(this)||(s.add(this),this.addEventListener(`abort`,()=>{let e=a.get(this);e&&(e.aborted=!0)}),this.addEventListener(`loadend`,()=>{let e=a.get(this);a.delete(this),e&&!e.aborted&&o(e.m.method,e.m.url,this.status,e.start,e.startedAt)})))}catch{}return n.call(this,e)};e.open=l,e.send=d,c.push(()=>{e.open===l&&(e.open=t),e.send===d&&(e.send=n)})}return()=>{for(let e of c)try{e()}catch{}}}var et=class{constructor(e){this.capacity=e,this.items=[],this.listeners=new Set}push(e){this.items.push(e),this.items.length>this.capacity&&this.items.shift();for(let t of this.listeners)try{t(e)}catch{}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}toArray(){return this.items.slice()}clear(){this.items=[]}get size(){return this.items.length}};function tt(e){return m(e).replace(/https?:\/\/\S+/g,`<url>`).replace(/\b[0-9a-f]{8,}\b/gi,`<id>`).replace(/\d+/g,`<n>`).replace(/\s+/g,` `).trim().slice(0,200)}function nt(e,t){let n=(Array.isArray(e)?e:[]).filter(e=>e.level===`error`);if(n[0]?.message)return`console:${tt(n[0].message)}`;let r=(Array.isArray(t)?t:[]).find(e=>e.status===0||e.status>=500);if(r){let e=r.url;try{e=new URL(r.url).pathname}catch{}return`network:${r.method.toUpperCase()} ${tt(e)} ${r.status===0?`failed`:`5xx`}`}return null}function rt(e){return e.level===`error`?nt([e],[]):null}function it(e){return nt([],[e])}function A(e){let t=e.path??(()=>location.pathname),n=e.random??Math.random,r=e.now??Date.now,i=[],a=new Set,o=r(),s=null,c=t=>{if(t){for(let n of i)if(!(n.signature!==t||a.has(n.id))){a.add(n.id);try{e.report(n)}catch{}}}},l=e=>{let t=Date.parse(e);return Number.isNaN(t)||t>=o-1},u=r=>{let u=t();if(s=u,o=r,a=new Set,i=e.checks.filter(t=>at(t.path,u)&&e.sampleRate>0&&n()<e.sampleRate),i.length){for(let t of e.console.toArray())l(t.at)&&c(rt(t));for(let t of e.network.toArray())l(t.at)&&c(it(t))}},d=e.console.subscribe(e=>{i.length&&c(rt(e))}),f=e.network.subscribe(e=>{i.length&&c(it(e))}),p=typeof performance<`u`&&performance.timeOrigin?performance.timeOrigin:r();return u(e.since??Math.min(p,r())),{navigated:()=>{t()!==s&&u(r())},stop:()=>{d(),f(),i=[]}}}function at(e,t){return e===`*`||ot(e,t)}function ot(e,t){let n=e=>e.length>1?e.replace(/\/+$/,``):e;return n(e)===n(t)}function st(e){let t=e.path??(()=>location.pathname),n=new Set,r=t(),i=e.known.flatMap(e=>e.signature?[{id:e.id,path:`*`,signature:e.signature}]:[]),a=i.length?A({checks:i,sampleRate:1,random:()=>0,console:e.console,network:e.network,report:e=>n.add(e.id),path:t,now:e.now}):null;return{matches:()=>ct(e.known,t(),n),navigated:()=>{t()!==r&&(r=t(),n.clear()),a?.navigated()},stop:()=>a?.stop()}}function ct(e,t,n=new Set){return e.filter(e=>n.has(e.id)||e.paths.some(e=>ot(e,t))).slice(0,3)}var j=`pinax-widget-root`;function lt(e=document){let t=e.getElementById(j);if(t?.shadowRoot)return t.shadowRoot;let n=e.createElement(`div`);return n.id=j,n.className=`ph-no-capture fs-exclude`,n.setAttribute(`data-hj-suppress`,``),n.setAttribute(`data-clarity-mask`,`true`),n.setAttribute(`data-private`,``),n.style.cssText=`all: initial; position: fixed; z-index: 2147483647;`,e.body.appendChild(n),n.attachShadow({mode:`open`})}function ut(e=document){e.getElementById(j)?.remove()}function dt(e,t=window){let n=!0,r=!1,i=()=>{if(!n||r)return;r=!0;let t=()=>{if(r=!1,n)try{e()}catch{}};try{queueMicrotask(t)}catch{setTimeout(t,0)}},a=[],o=t.history;for(let e of[`pushState`,`replaceState`]){let t=o?.[e];if(typeof t!=`function`)continue;let n=function(...e){let n=t.apply(this,e);return i(),n};try{o[e]=n,a.push(()=>{o[e]===n&&(o[e]=t)})}catch{}}return t.addEventListener(`popstate`,i),a.push(()=>t.removeEventListener(`popstate`,i)),()=>{n=!1;for(let e of a)try{e()}catch{}}}var M=new Map;function ft(e){let t=M.get(e);if(!t){let n=pt(e.trim()).split(`*`).map(e=>e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`)).join(`.*`);t=RegExp(`^${n}$`),M.size>200&&M.clear(),M.set(e,t)}return t}function pt(e){return e.length>1?e.replace(/\/+$/,``)||`/`:e}function mt(e){try{return decodeURI(e)}catch{return e}}function ht(e,t){if(typeof e!=`string`||!e.trim())return!1;let n=ft(e),r=pt(t||`/`),i=[r,`${r===`/`?``:r}/`],a=mt(r);return a!==r&&i.push(a,`${a}/`),i.some(e=>n.test(e))}function gt(e,t){return e?.length?e.some(e=>ht(e,t)):!1}var _t=36e5,vt=8,N=e=>`pinax:queue:${e}`,P=new Map,yt=e=>Date.now()-e.queuedAt<=_t,bt=e=>{let t=e;return!!t&&typeof t.queuedAt==`number`&&typeof t.tries==`number`&&typeof t.body?.page?.url==`string`};function F(e,t){let n;try{let r=e.getItem(N(t)),i=r?JSON.parse(r):[];n=Array.isArray(i)?i:[]}catch{return[]}let r=n.filter(e=>bt(e)&&yt(e)),i=r.some(e=>`email`in e.body||`user`in e.body);if(r.length===n.length&&!i)return r;for(let e of n)!r.includes(e)&&e?.id&&P.delete(e.id);let a=r.map(e=>({...e,body:xt(e.body)}));return I(e,t,a),a}function I(e,t,n){try{return n.length?e.setItem(N(t),JSON.stringify(n)):e.removeItem(N(t)),!0}catch{return!1}}function L(){try{return window.localStorage}catch{return null}}function xt(e){let{email:t,user:n,console:r,screenshot:i,annotations:a,replay:o,...s}=e;return{...s,page:{...s.page,url:v(s.page.url)}}}var St=()=>`${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`;function Ct(e,t){let n=L();if(!n)return!1;let r=F(n,e),i=r.slice(0,Math.max(0,r.length-4));for(let e of i)e.id&&P.delete(e.id);let a=St(),o=I(n,e,[...r.slice(-4),{id:a,body:xt(t),queuedAt:Date.now(),tries:0}]);return o&&(t.email||t.user)&&P.set(a,{...t.email&&{email:t.email},...t.user&&{user:t.user}}),o}function wt(e){let t=L();return t?F(t,e).length:0}var R=!1;async function Tt(e,t,n){let r=L();if(r&&!R&&(typeof navigator>`u`||navigator.onLine!==!1)){R=!0;try{let i=F(r,n),a=[];for(let r of i){let i=r.id?P.get(r.id):void 0,o=await Ce(e,t,n,{...r.body,...i});!o.ok&&o.retry&&r.tries+1<vt?a.push({...r,tries:r.tries+1}):r.id&&P.delete(r.id)}let o=new Set(i.map(e=>e.id)),s=F(r,n).filter(e=>!o.has(e.id));I(r,n,[...a,...s])}finally{R=!1}}}var Et={opened:`Pinax Widget Opened`,submitted:`Feedback Submitted`};function Dt(e=window){try{let t=e.analytics;return!t||typeof t!=`object`&&typeof t!=`function`?null:typeof t.track==`function`?t:null}catch{return null}}function Ot(e,t){return typeof e==`boolean`?e:t===!0}function kt(e,t){try{Dt()?.track?.(e,t)}catch{}}function At(){kt(Et.opened,{source:`pinax`})}function jt(e){let t={source:`pinax`,type:e.type.toLowerCase()};typeof e.rating==`number`&&(t.rating=e.rating),e.reportId&&(t.reportId=e.reportId),e.queued&&(t.queued=!0),kt(Et.submitted,t)}function Mt(){try{let e=Dt()?.user?.()?.id?.();return typeof e==`string`&&e.trim()?e.trim().slice(0,200):typeof e==`number`&&Number.isFinite(e)?String(e):null}catch{return null}}var Nt={color:`#B8F35C`,text:`Feedback`,position:`bottom-right`,types:{problem:!0,idea:!0,general:!0,accessibility:!1},rating:!0,hidePaths:[],smallOnMobile:!1,hideButton:!1,segment:!1,wording:{chooserTitle:``,problemTitle:``,ideaTitle:``,generalTitle:``,accessibilityTitle:``,messagePlaceholder:``,confirmation:``},fields:[],capture:{console:!0,network:!0},knownIssues:{enabled:!0,notify:!0},consent:{required:!1},privacyUrl:``,identifyPrefill:!0},z={fields:10,label:80,options:20,option:80,text:200},Pt=[`bottom-right`,`bottom-left`,`right-edge`],Ft=Object.keys(Nt.wording),B=(e,t)=>typeof e==`string`?e.trim().slice(0,t):``,V=(e,t)=>typeof e==`boolean`?e:t,It=[`select`,`text`,`checkbox`];function Lt(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=typeof e.id==`string`?e.id.slice(0,40):``,a=e.type,o=B(e.label,z.label);if(!i||n.has(i)||!It.includes(a)||!o)continue;let s=a===`select`&&Array.isArray(e.options)?[...new Set(e.options.map(e=>B(e,z.option)).filter(Boolean))].slice(0,z.options):[];if(a===`select`&&!s.length)continue;let c=e.types??{};if(n.add(i),t.push({id:i,type:a,label:o,required:e.required===!0,options:s,types:{problem:V(c.problem,!0),idea:V(c.idea,!0),general:V(c.general,!0)}}),t.length>=z.fields)break}return t}function Rt(e){let t=e??{},n=Nt,r=t.types??{},i={problem:V(r.problem,!0),idea:V(r.idea,!0),general:V(r.general,!0),accessibility:V(r.accessibility,!1)},a=i.problem||i.idea||i.general||i.accessibility,o=t.wording??{},s={...n.wording};for(let e of Ft)s[e]=B(o[e],120);return{color:typeof t.color==`string`?t.color:n.color,text:B(t.text,40)||n.text,position:Pt.includes(t.position)?t.position:n.position,types:a?i:{...n.types},rating:V(t.rating,n.rating),hidePaths:Array.isArray(t.hidePaths)?t.hidePaths.filter(e=>typeof e==`string`):[],smallOnMobile:V(t.smallOnMobile,n.smallOnMobile),hideButton:V(t.hideButton,n.hideButton),segment:V(t.segment,n.segment),wording:s,fields:Lt(t.fields),capture:{console:V(t.capture?.console,!0),network:V(t.capture?.network,!0)},knownIssues:{enabled:V(t.knownIssues?.enabled,!0),notify:V(t.knownIssues?.notify,!0)},consent:{required:t.consent?.required===!0},privacyUrl:zt(t.privacyUrl),identifyPrefill:V(t.identifyPrefill,!0)}}function zt(e){let t=typeof e==`string`?e.trim():``;try{return t.length<=500&&new URL(t).protocol===`https:`?t:``}catch{return``}}var Bt=/^#[0-9a-fA-F]{6}$/,Vt=e=>typeof e==`string`&&Bt.test(e)?e:null;function Ht(e){let t=e&&typeof e==`object`?e:{},n=typeof t.logoUrl==`string`&&/^https?:\/\//i.test(t.logoUrl)?t.logoUrl.slice(0,2e3):null;return{poweredBy:t.poweredBy===!0,logoUrl:n,primary:Vt(t.primary),accent:Vt(t.accent)}}var Ut=e=>typeof e==`number`&&Number.isFinite(e)?Math.min(1,Math.max(0,e)):0;function Wt(e,t){let n=e&&typeof e==`object`?e:{},r=typeof t==`number`?Ut(t):1,i=Array.isArray(n.fixChecks)?n.fixChecks:[];return{followUp:n.followUp===!0,autoBlur:n.autoBlur===!0,replay:n.replay===!0,replaySampleRate:Math.min(n.replaySampleRate===void 0?1:Ut(n.replaySampleRate),r),replayMask:n.replayMask===`inputs`?`inputs`:`all`,fixChecks:i.filter(e=>!!e&&typeof e.id==`string`&&typeof e.path==`string`&&typeof e.signature==`string`),watches:Gt(n.watches),fixCheckSampleRate:Math.min(Ut(n.fixCheckSampleRate),r)}}function Gt(e){return(Array.isArray(e)?e:[]).filter(e=>!!e&&typeof e.id==`string`&&typeof e.signature==`string`).slice(0,50)}function Kt(e,t){if(!Array.isArray(e)||t?.enabled===!1)return[];let n=[];for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,r=typeof e.id==`string`?e.id.slice(0,64):``,i=B(e.title,120);if(r&&i&&(n.push({id:r,title:i,paths:(Array.isArray(e.paths)?e.paths:[]).filter(e=>typeof e==`string`&&e[0]===`/`).slice(0,10),signature:typeof e.signature==`string`&&e.signature?e.signature:null}),n.length>=20))break}return n}function qt(e){let t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;let n=t[1];n.length===3&&(n=[...n].map(e=>e+e).join(``));let[r,i,a]=[0,2,4].map(e=>{let t=Number.parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function Jt(e,t){let[n,r]=e>t?[e,t]:[t,e];return(n+.05)/(r+.05)}function Yt(e){let t=qt(e);return t===null?`#FFFFFF`:Jt(t,qt(`#0B1300`))>=Jt(t,1)?`#0B1300`:`#FFFFFF`}function Xt(e,t=`#B8F35C`){return typeof e==`string`&&qt(e)!==null?e.trim():t}function H(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.setAttribute(e,n===!0?``:String(n));for(let e of n)e!=null&&e!==!1&&r.append(e);return r}var Zt=`http://www.w3.org/2000/svg`;function U(e,t=16){let n=document.createElementNS(Zt,`svg`);n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2.2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`);let r=document.createElementNS(Zt,`path`);return r.setAttribute(`d`,e),n.append(r),n}var W={close:`M18 6L6 18M6 6l12 12`,back:`M15 18l-6-6 6-6`,pen:`M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z`,camera:`M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2zM12 17a4 4 0 100-8 4 4 0 000 8z`,trash:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`},Qt=`
4
4
  $ .panel, $.pos-bottom-right .panel, $.pos-bottom-left .panel, $.pos-right-edge .panel { left: 0; right: 0; bottom: 0; width: 100%; max-width: none; max-height: 88vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
5
5
  $.open .launcher { display: none; }
6
6
  $ .field textarea, $ .field input, $ .field select { font-size: 16px; }
@@ -11,7 +11,7 @@
11
11
  $.small.pos-bottom-right .launcher { right: 12px; bottom: 12px; }
12
12
  $.small.pos-bottom-left .launcher { left: 12px; bottom: 12px; }
13
13
  $.small.pos-right-edge .launcher { padding: 8px 10px; }
14
- `;function Dt(e,t){let n=Et.replace(/\$/g,t);return e?`${e}${n}}`:n}var Ot=`
14
+ `;function $t(e,t){let n=Qt.replace(/\$/g,t);return e?`${e}${n}}`:n}var en=`
15
15
  :host { all: initial; }
16
16
  * { box-sizing: border-box; }
17
17
  .pnx { font-family: Manrope, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #111827; font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
@@ -73,6 +73,14 @@ button:disabled { cursor: default; }
73
73
  .field.check input { flex: none; width: 20px; height: 20px; margin: 0; padding: 0; accent-color: #2E46BF; box-shadow: none; }
74
74
  .field.check label { font-size: 13px; color: #111827; font-weight: 600; line-height: 1.45; }
75
75
  .field.check input[aria-invalid="true"] { outline: 2px solid #B42318; outline-offset: 2px; }
76
+ .a11y-note { margin: 0; font-size: 13px; line-height: 1.45; color: #374151; }
77
+ fieldset.barriers { border: 0; margin: 0; padding: 0; min-width: 0; gap: 2px; }
78
+ fieldset.barriers legend { padding: 0; margin-bottom: 4px; }
79
+ .radio { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 8px; border-radius: 8px; }
80
+ .radio:hover { background: #F2F4F8; }
81
+ .field .radio input, .field .radio input:focus { flex: none; width: 20px; height: 20px; margin: 0; padding: 0; border-radius: 50%; background: none; accent-color: #0F766E; box-shadow: none; }
82
+ .radio input:focus-visible { outline: 2px solid #2E46BF; outline-offset: 2px; }
83
+ .radio label { flex: 1; font-size: 14px; color: #111827; font-weight: 500; line-height: 1.35; padding: 8px 0; cursor: pointer; }
76
84
  .brand { display: flex; align-items: center; min-height: 28px; }
77
85
  .brand .logo { display: block; max-height: 32px; max-width: 160px; width: auto; height: auto; object-fit: contain; }
78
86
  .accented .panel { border-top: 4px solid var(--pnx-accent); }
@@ -103,11 +111,25 @@ button:disabled { cursor: default; }
103
111
  .field textarea.answer { min-height: 64px; }
104
112
  .skip { width: 100%; padding: 8px; text-align: center; }
105
113
  .skip:disabled, .send:disabled + .skip { opacity: .7; }
114
+
115
+ .known { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
116
+ .known > li { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border-radius: 10px; background: #F2F4F8; }
117
+ .known-title { margin: 0; font-size: 14px; font-weight: 700; color: #111827; overflow-wrap: anywhere; }
118
+ .known-thanks { margin: 0; font-size: 13px; font-weight: 600; color: #374151; }
119
+ .known .field { align-self: stretch; }
120
+ .known .field input { background: #FFFFFF; box-shadow: inset 0 0 0 1px #6B7280; }
121
+ .known .field input:focus { box-shadow: inset 0 0 0 2px #2E46BF; }
122
+ .known .field [aria-invalid="true"] { box-shadow: inset 0 0 0 2px #B42318; }
123
+ .subtitle { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: #5B6474; }
124
+ .privacy { display: flex; flex-direction: column; gap: 10px; }
125
+ .notice { margin: 0; font-size: 12px; line-height: 1.45; color: #5B6474; overflow-wrap: anywhere; }
126
+ .notice a { color: #2E46BF; font-weight: 700; text-decoration: underline; }
127
+ .notice a:hover { color: #111827; }
106
128
  .hint.auto-blur { display: flex; align-items: center; gap: 6px; }
107
129
  .hint.auto-blur i { flex: none; width: 16px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(90deg, #D8DEE9 0 4px, #C7CFDC 4px 8px); box-shadow: 0 0 0 1px #C7CFDC; }
108
130
 
109
- ${Dt(`@media (max-width: 520px) {`,`.pnx`)}
131
+ ${$t(`@media (max-width: 520px) {`,`.pnx`)}
110
132
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
111
- @media (forced-colors: active) { .launcher, .choice, .send, .chip, .star { border: 1px solid ButtonText; } }
112
- `,kt=[{type:`PROBLEM`,key:`problem`,label:`Report a problem`,desc:`Point at what is broken`,dot:`#FF5C35`,send:`#CC3F1B`,ink:`#FFFFFF`},{type:`IDEA`,key:`idea`,label:`Share an idea`,desc:`Suggest something better`,dot:`#7C9CFF`,send:`#7C9CFF`,ink:`#0B1122`},{type:`GENERAL`,key:`general`,label:`General feedback`,desc:`A rating and a few words`,dot:`#3DBF6E`,send:`#3DBF6E`,ink:`#0B1300`}],At=4e3,jt=`What would you like to do?`,Mt=`Thanks! We've got it.`,Nt={problem:`problemTitle`,idea:`ideaTitle`,general:`generalTitle`},Pt=class{constructor(e,t,n,r={}){this.root=e,this.config=t,this.handlers=n,this.kind=null,this.shot={kind:`none`},this.message=``,this.email=``,this.answers={},this.sendColour=null,this.sending=!1,this.openedAt=0,this.hp=``,this.uid=Math.random().toString(36).slice(2,8),this.pathHidden=!1,this.returnFocus=null,this.view=`choose`,this.queued=!1,this.asked=null,this.answer=``;let i=t.settings,a=t.branding?.primary?H(t.branding.primary,``):``,o=t.branding?.accent?H(t.branding.accent,``):``,s=a||H(i.color);this.sendColour=a||null,this.kinds=kt.filter(e=>i.types?.[e.key]!==!1),this.kinds.length||(this.kinds=kt);let c=U(`style`);c.textContent=r.css?Ot+r.css:Ot,this.launcher=U(`button`,{type:`button`,class:`launcher`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":`pnx-panel-${this.uid}`},(i.text||`Feedback`).slice(0,40)),this.launcher.addEventListener(`click`,()=>this.isOpen()?this.close():this.open()),this.panel=U(`div`,{class:`panel`,id:`pnx-panel-${this.uid}`,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`pnx-title-${this.uid}`,hidden:!0}),this.panel.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close())}),this.panel.addEventListener(`pointerdown`,()=>this.holdOpen()),this.panel.addEventListener(`focusin`,()=>this.holdOpen()),this.live=U(`div`,{class:`sr`,role:`status`,"aria-live":`polite`});let l=[`bottom-right`,`bottom-left`,`right-edge`].includes(i.position)?i.position:`bottom-right`;this.wrap=U(`div`,{class:`pnx pos-${l}${r.className?` ${r.className}`:``}`}),i.smallOnMobile&&this.wrap.classList.add(`small`),this.updateButton(),this.wrap.style.setProperty(`--pnx-brand`,s),this.wrap.style.setProperty(`--pnx-ink`,V(s)),o&&(this.wrap.classList.add(`accented`),this.wrap.style.setProperty(`--pnx-accent`,o),this.wrap.style.setProperty(`--pnx-accent-ink`,V(o))),this.wrap.append(this.launcher,this.panel,this.live),e.append(c,this.wrap)}isOpen(){return!this.panel.hidden}hasButton(){return!this.launcher.hidden}setPathHidden(e){this.pathHidden=e,this.updateButton()}updateButton(){let e=this.config.settings.hideButton||this.pathHidden;this.launcher.hidden=e,this.wrap.classList.toggle(`no-button`,e)}open(e=!0){if(this.isOpen()){e&&this.focusFirst();return}let t=document.activeElement;this.returnFocus=t instanceof HTMLElement&&t!==this.root.host?t:null,this.openedAt||(this.openedAt=Date.now()),this.panel.hidden=!1,this.wrap.classList.add(`open`),this.launcher.setAttribute(`aria-expanded`,`true`),!this.kind&&this.kinds.length===1&&this.pick(this.kinds[0],!1),this.render(),e&&this.focusFirst();try{this.handlers.opened?.()}catch{}}close(e=!0){clearTimeout(this.closeTimer),this.isOpen()&&(this.panel.hidden=!0,this.wrap.classList.remove(`open`),this.launcher.setAttribute(`aria-expanded`,`false`),this.view===`done`&&this.reset(),e&&(this.hasButton()?this.launcher.focus():this.returnFocus?.isConnected&&this.returnFocus.focus(),this.returnFocus=null))}currentView(){return this.isOpen()?this.view===`done`?`done`:(this.view===`form`||this.view===`question`)&&this.kind?this.kind.key:`choose`:`button`}showView(e){if(clearTimeout(this.closeTimer),e===`button`)this.close(!1);else{if(this.reset(),e===`done`)this.view=`done`;else if(e!==`choose`){let t=this.kinds.find(t=>t.key===e);t&&this.pick(t,!1)}this.isOpen()?this.render():this.open(!1)}}word(e,t){return this.config.settings.wording?.[e]?.trim()||t}kindTitle(e,t=e.label){return this.word(Nt[e.key],t)}setSuspended(e){this.wrap.style.display=e?`none`:``}destroy(){clearTimeout(this.closeTimer),this.wrap.remove()}reset(){this.view=`choose`,this.kind=null,this.shot={kind:`none`},this.message=``,this.rating=void 0,this.answers={},this.queued=!1,this.asked=null,this.answer=``,this.openedAt=this.isOpen()?Date.now():0,this.hp=``,this.kinds.length===1&&this.pick(this.kinds[0],!1)}holdOpen(){clearTimeout(this.closeTimer)}focusFirst(){for(let e of[`[data-autofocus]`,`.choice`,`textarea`,`button`]){let t=this.panel.querySelector(e);if(t){t.focus();return}}}announce(e){this.live.textContent=``,setTimeout(()=>{this.live.textContent=e},30)}pick(e,t=!0){this.kind=e,this.view=`form`,this.rating=void 0,this.email=this.email||this.handlers.user()?.email||``,e.type===`PROBLEM`&&this.shot.kind===`none`&&this.capture(),e.type!==`PROBLEM`&&this.shot.kind===`busy`&&(this.shot={kind:`none`}),t&&(this.render(),this.focusFirst())}async capture(){this.shot={kind:`busy`},this.render();try{let e=await this.handlers.takeScreenshot();if(this.shot.kind!==`busy`)return;this.shot={kind:`ready`,shot:e},this.announce(`Screenshot added.`)}catch{if(this.shot.kind!==`busy`)return;this.shot={kind:`failed`},this.announce(`Couldn't take a screenshot.`)}this.renderKeepingFocus()}async markUp(){if(this.shot.kind===`ready`){this.setSuspended(!0);try{let e=await this.handlers.markUp(this.shot.shot);e&&(this.shot={kind:`ready`,shot:e},this.announce(e.annotations.length?`Screenshot marked up with ${e.annotations.length} ${e.annotations.length===1?`mark`:`marks`}.`:`Screenshot updated.`))}catch{}finally{this.setSuspended(!1),this.render(),this.panel.querySelector(`[data-markup]`)?.focus()}}}renderKeepingFocus(){let e=this.root.activeElement,t=e?.dataset?.key,n=e?.tagName===`TEXTAREA`?[e.selectionStart,e.selectionEnd]:null;if(this.render(),t){let e=this.panel.querySelector(`[data-key="${t}"]`);e?.focus(),n&&e instanceof HTMLTextAreaElement&&e.setSelectionRange(n[0],n[1])}}header(e,t,n){let r=U(`div`,{class:`head`});if(t){let e=U(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Back`,"data-key":`back`});e.append(W(G.back)),e.addEventListener(`click`,()=>{n?n():(this.view=`choose`,this.kind=null,this.render(),this.focusFirst())}),r.append(e)}r.append(U(`h2`,{class:`title`,id:`pnx-title-${this.uid}`},e));let i=U(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close feedback`,"data-key":`close`});return i.append(W(G.close)),i.addEventListener(`click`,()=>this.close()),r.append(i),r}powered(){return this.config.branding?.poweredBy?U(`div`,{class:`powered`},U(`a`,{href:`https://getpinax.com`,target:`_blank`,rel:`noopener`},`Powered by Pinax`)):null}logo(){let e=this.config.branding?.logoUrl;if(!e||!/^https?:\/\//i.test(e))return null;let t=U(`img`,{src:e,alt:``,class:`logo`,referrerpolicy:`no-referrer`});return t.addEventListener(`error`,()=>t.remove()),U(`div`,{class:`brand`},t)}render(){let e=[],t=this.logo();t&&e.push(t),this.view===`done`?e.push(...this.renderDone()):this.view===`question`&&this.kind&&this.asked?.question?e.push(...this.renderQuestion(this.kind,this.asked.question)):this.view===`form`&&this.kind?e.push(...this.renderForm(this.kind)):e.push(...this.renderChoose());let n=this.powered();n&&e.push(n),this.panel.replaceChildren(...e)}renderChoose(){let e=U(`ul`,{class:`choices`});for(let t of this.kinds){let n=U(`button`,{type:`button`,class:`choice`},U(`span`,{class:`dot`,"aria-hidden":`true`}),U(`span`,{},this.kindTitle(t),U(`small`,{},t.desc)));n.style.setProperty(`--dot`,t.dot),n.addEventListener(`click`,()=>this.pick(t)),e.append(U(`li`,{},n))}return[this.header(this.word(`chooserTitle`,jt),!1),e]}renderShot(e){let t=this.shot;if(t.kind===`none`){if(e.type===`GENERAL`)return null;let t=U(`button`,{type:`button`,class:`chip`,"data-key":`add-shot`},W(G.camera),`Add a screenshot`);return t.addEventListener(`click`,()=>this.capture()),U(`div`,{class:`shot-actions`},t)}if(t.kind===`busy`)return U(`div`,{class:`shot`,"aria-busy":`true`},U(`span`,{class:`wait`},`Taking a screenshot…`));if(t.kind===`failed`){let e=U(`button`,{type:`button`,class:`chip`,"data-key":`retry-shot`},`Try again`);return e.addEventListener(`click`,()=>this.capture()),U(`div`,{class:`field`},U(`span`,{class:`hint`},`Couldn't take a screenshot of this page.`),U(`div`,{class:`shot-actions`},e))}let n=t.shot.annotations.length,r=t.shot.autoBlurred??0,i=U(`img`,{src:t.shot.dataUrl,alt:`Screenshot of this page${n?` with ${n} ${n===1?`mark`:`marks`}`:``}${r?`, ${r} private ${r===1?`detail`:`details`} blurred`:``}`}),a=U(`button`,{type:`button`,class:`chip primary`,"data-markup":!0,"data-key":`markup`},W(G.pen),n?`Edit marks`:`Mark up`);a.addEventListener(`click`,()=>this.markUp());let o=U(`button`,{type:`button`,class:`chip`,"data-key":`remove-shot`},W(G.trash),`Remove`);return o.addEventListener(`click`,()=>{this.shot={kind:`none`},this.announce(`Screenshot removed.`),this.render(),this.panel.querySelector(`[data-key="add-shot"]`)?.focus()}),U(`div`,{class:`field`},U(`div`,{class:`shot`},i,U(`span`,{class:`tag`,"aria-hidden":`true`},`Screenshot`)),U(`div`,{class:`shot-actions`},a,o),r?U(`span`,{class:`hint auto-blur`},U(`i`,{"aria-hidden":`true`}),`We blurred ${r===1?`1 private detail`:`${r} private details`} for you.`):null)}renderStars(){let e=U(`div`,{class:`stars`,role:`radiogroup`,"aria-labelledby":`pnx-rate-${this.uid}`}),t=[],n=(this.rating??1)-1;for(let e=1;e<=5;e++){let r=U(`button`,{type:`button`,class:this.rating!==void 0&&e<=this.rating?`star on`:`star`,role:`radio`,"aria-checked":this.rating===e?`true`:`false`,"aria-label":`${e} ${e===1?`star`:`stars`}`,tabindex:e-1===n?0:-1,"data-key":`star-${e}`},`★`);r.addEventListener(`click`,()=>{this.rating=this.rating===e?void 0:e,this.renderKeepingFocus()}),r.addEventListener(`keydown`,e=>{let t=e.key===`ArrowRight`||e.key===`ArrowUp`?1:e.key===`ArrowLeft`||e.key===`ArrowDown`?-1:0;if(!t)return;e.preventDefault();let n=Math.min(5,Math.max(1,(this.rating??0)+t||1));this.rating=n,this.render(),this.panel.querySelector(`[data-key="star-${n}"]`)?.focus()}),t.push(r)}return e.append(...t),U(`div`,{class:`field`},U(`span`,{class:`legend`,id:`pnx-rate-${this.uid}`},`How's your visit so far? (optional)`),e)}renderForm(e){let t=e.type===`GENERAL`&&this.config.settings.rating!==!1,n=this.kindTitle(e,t?`How was your visit?`:e.label),r=[this.header(n,this.kinds.length>1)],i=this.renderShot(e);i&&r.push(i),t&&r.push(this.renderStars());let a=`pnx-msg-${this.uid}`,o=U(`textarea`,{id:a,maxlength:5e3,"data-key":`message`,"data-autofocus":e.type!==`PROBLEM`&&!t||void 0,placeholder:this.word(`messagePlaceholder`,e.type===`PROBLEM`?`What happened?`:e.type===`IDEA`?`What would make this better?`:`Tell us what you think`)});o.value=this.message,o.addEventListener(`input`,()=>{this.message=o.value}),r.push(U(`div`,{class:`field`},U(`label`,{for:a},e.type===`PROBLEM`?`What went wrong?`:e.type===`IDEA`?`Your idea`:`Anything to add?`),o)),r.push(...this.renderFields(e));let s=`pnx-email-${this.uid}`,c=`pnx-email-hint-${this.uid}`,l=U(`input`,{id:s,type:`email`,inputmode:`email`,autocomplete:`email`,maxlength:320,"aria-describedby":c,"data-key":`email`,placeholder:`you@example.com`});l.value=this.email,l.addEventListener(`input`,()=>{this.email=l.value}),r.push(U(`div`,{class:`field`},U(`label`,{for:s},`Your email (optional)`),l,U(`span`,{class:`hint`,id:c},`So we can let you know when it's sorted.`)));let u=U(`p`,{class:`error`,role:`alert`,id:`pnx-err-${this.uid}`}),d=U(`button`,{type:`button`,class:`send`,"data-key":`send`,disabled:this.sending},this.sending?`Sending…`:`Send`);return this.colourSend(d,e),d.addEventListener(`click`,()=>this.send(e,u,l,o)),r.push(this.honeypot(),u,d),r}honeypot(){let e=U(`input`,{type:`text`,name:`website`,tabindex:-1,autocomplete:`off`,"aria-label":`Leave this empty`});e.value=this.hp,e.addEventListener(`input`,()=>{this.hp=e.value});let t=U(`div`,{"aria-hidden":`true`},e);return t.style.cssText=`position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden`,t}async send(e,t,n,r){if(this.sending)return;t.textContent=``,n.removeAttribute(`aria-invalid`);let i=this.email.trim();if(i&&!k(i)){t.textContent=`Please check your email address, or leave it empty.`,n.setAttribute(`aria-invalid`,`true`),n.setAttribute(`aria-errormessage`,t.id),n.focus();return}if(this.shot.kind===`busy`){t.textContent=`One moment, the screenshot is still being taken.`;return}for(let n of this.fieldsFor(e)){let e=this.answers[n.id];if(!n.required||(n.type===`checkbox`?e===!0:e))continue;let r=this.panel.querySelector(`[data-key="field-${n.id}"]`);t.textContent=n.type===`checkbox`?`Please tick “${n.label}”.`:n.type===`select`?`Please choose an answer for “${n.label}”.`:`Please fill in “${n.label}”.`,r?.setAttribute(`aria-invalid`,`true`),r?.setAttribute(`aria-errormessage`,t.id),r?.focus();return}let a=this.shot.kind===`ready`?this.shot.shot:void 0,o=e.type===`GENERAL`?this.rating:void 0;if(!Ye({type:e.type,message:this.message,rating:o,screenshot:a?.dataUrl})){t.textContent=e.type===`GENERAL`&&this.config.settings.rating!==!1?`Add a few words or a star rating.`:`Add a few words so we know what you mean.`,r.focus();return}this.sending=!0,this.renderKeepingFocus(),this.announce(`Sending…`);let s=await this.askFollowUp(e);this.view!==`form`||this.kind!==e||!this.isOpen()?(this.sending=!1,this.isOpen()&&this.renderKeepingFocus()):s?(this.sending=!1,this.view=`question`,this.render(),this.focusFirst()):await this.submitNow(e,i,o,a)}async askFollowUp(e){let t=this.handlers.followUp,n=this.message.trim();if(!t||e.type===`GENERAL`||!n||n.length>140)return null;if(this.asked?.message===n)return this.asked.question;let r=null;try{r=(await t({type:e.type,message:n}))?.trim()||null}catch{r=null}return this.asked={message:n,question:r?.slice(0,300)||null},this.asked.question}async submitNow(e,t,n,r,i){this.sending=!0,this.renderKeepingFocus();let a;try{a=await this.handlers.submit({type:e.type,message:this.message,rating:n,email:t||void 0,shot:r,followUp:i,fields:this.fieldAnswers(e),hp:this.hp||void 0,elapsedMs:this.openedAt?Math.max(0,Date.now()-this.openedAt):void 0})}catch{a={status:`error`,message:`Something went wrong. Please try again.`}}if(this.sending=!1,a.status===`error`){this.view=`form`,this.render();let e=this.panel.querySelector(`.error`);e&&(e.textContent=a.message),this.panel.querySelector(`[data-key="send"]`)?.focus()}else this.queued=a.status===`queued`,this.view=`done`,this.render(),this.focusFirst(),this.announce(this.queued?`Saved. We'll send it when you're back online.`:this.word(`confirmation`,Mt)),this.closeTimer=setTimeout(()=>this.close(this.panel.contains(this.root.activeElement)),At)}renderQuestion(e,t){let n=[this.header(`One quick question`,!0,()=>{this.view=`form`,this.render(),this.panel.querySelector(`[data-key="message"]`)?.focus()})],r=U(`div`,{class:`note`},U(`span`,{class:`dot`,"aria-hidden":`true`}),U(`span`,{},U(`span`,{class:`sr`},`Your note: `),`“${this.message.trim()}”`));r.style.setProperty(`--dot`,e.dot),n.push(r);let i=`pnx-answer-${this.uid}`,a=`pnx-answer-hint-${this.uid}`,o=U(`textarea`,{id:i,class:`answer`,maxlength:2e3,"data-key":`answer`,"data-autofocus":!0,"aria-describedby":a,placeholder:`Your answer`});o.value=this.answer,o.addEventListener(`input`,()=>{this.answer=o.value}),n.push(U(`div`,{class:`field`},U(`label`,{for:i,class:`question`},t),o,U(`span`,{class:`hint`,id:a},`Optional. It helps us fix it faster.`)));let s=U(`p`,{class:`error`,role:`alert`}),c=this.email.trim(),l=e.type===`GENERAL`?this.rating:void 0,u=this.shot.kind===`ready`?this.shot.shot:void 0,d=U(`button`,{type:`button`,class:`send`,"data-key":`send`,disabled:this.sending},this.sending?`Sending…`:`Send`);this.colourSend(d,e),d.addEventListener(`click`,()=>{if(this.sending)return;let n=this.answer.trim();this.announce(`Sending…`),this.submitNow(e,c,l,u,n?{question:t,answer:n.slice(0,2e3)}:void 0)});let f=U(`button`,{type:`button`,class:`link skip`,"data-key":`skip`,disabled:this.sending},`Skip and send`);return f.addEventListener(`click`,()=>{this.sending||(this.announce(`Sending…`),this.submitNow(e,c,l,u))}),n.push(s,d,f),n}colourSend(e,t){let n=this.sendColour??t.send;e.style.setProperty(`--type`,n),e.style.setProperty(`--type-ink`,this.sendColour?V(n):t.ink)}fieldsFor(e){return(this.config.settings.fields??[]).filter(t=>t.types?.[e.key]!==!1)}fieldAnswers(e){let t=[];for(let n of this.fieldsFor(e)){let e=this.answers[n.id];n.type===`checkbox`?t.push({id:n.id,value:e===!0}):typeof e==`string`&&e.trim()&&t.push({id:n.id,value:e.trim()})}return t.length?t:void 0}renderFields(e){return this.fieldsFor(e).map((e,t)=>{let n=`pnx-f${t}-${this.uid}`,r=`field-${e.id}`,i=e=>{e.removeAttribute(`aria-invalid`),e.removeAttribute(`aria-errormessage`)},a=t=>U(`label`,{for:n,class:t},e.label,e.required?null:U(`span`,{class:`optional`},` (optional)`));if(e.type===`checkbox`){let t=U(`input`,{id:n,type:`checkbox`,"data-key":r,"aria-required":e.required?`true`:void 0});return t.checked=this.answers[e.id]===!0,t.addEventListener(`change`,()=>{this.answers[e.id]=t.checked,i(t)}),U(`div`,{class:`field check`},t,a())}if(e.type===`select`){let t=U(`select`,{id:n,"data-key":r,"aria-required":e.required?`true`:void 0},U(`option`,{value:``},`Choose…`),...e.options.map(e=>U(`option`,{value:e},e)));return t.value=String(this.answers[e.id]??``),t.addEventListener(`change`,()=>{this.answers[e.id]=t.value,i(t)}),U(`div`,{class:`field`},a(),t)}let o=U(`input`,{id:n,type:`text`,maxlength:200,"data-key":r,"aria-required":e.required?`true`:void 0});return o.value=String(this.answers[e.id]??``),o.addEventListener(`input`,()=>{this.answers[e.id]=o.value,i(o)}),U(`div`,{class:`field`},a(),o)})}renderDone(){let e=U(`button`,{type:`button`,class:`link`,"data-key":`again`},`Send another`);e.addEventListener(`click`,()=>{this.reset(),this.render(),this.focusFirst()});let t=U(`div`,{class:`head`});t.append(U(`span`,{class:`title`}));let n=U(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close feedback`});return n.append(W(G.close)),n.addEventListener(`click`,()=>this.close()),t.append(n),[t,U(`div`,{class:`done`},U(`span`,{class:`tick`,"aria-hidden":`true`},`✓`),U(`h2`,{class:`title`,id:`pnx-title-${this.uid}`,tabindex:-1,"data-autofocus":!0},this.queued?`Saved for later`:this.word(`confirmation`,Mt)),this.queued?U(`p`,{},`You're offline. We'll send it as soon as you're back.`):null,e)]}},K=null,q,Ft,J=(e,t)=>(Ft??window.fetch).call(window,e,t);function Y(e,t){try{(console.warn.__pinaxOriginal??console.warn).call(console,`Pinax: ${e}`,t??``)}catch{}}function X(e){try{e()}catch(e){Y(`capture could not start`,e)}}function It(e){if(K)return;if(!e?.key)throw Error(`Pinax: init() needs a website key`);let t=l(e.apiUrl),n=u(e.cdnUrl,e.apiUrl);Ft=typeof window.fetch==`function`?window.fetch:void 0;let r={options:e,api:t,root:Fe(),user:q,console:new T(50),network:new T(50),breadcrumbs:new T(20),stopCapture:{},onNavigate:[],cleanups:[],openWhenReady:!1,alive:!0};K=r,q=void 0,X(()=>{let e=Lt(Se(r.console));r.stopCapture.console=e,r.cleanups.push(e)}),X(()=>{let i=Lt(Oe(r.network,window,{ignore:r=>r.startsWith(`${t}/v1/widget/`)||n!==null&&r.startsWith(d(n,e.key))}));r.stopCapture.network=i,r.cleanups.push(i)});let a=r.root.host;X(()=>{let e=_e(r.breadcrumbs,{ignore:e=>e instanceof Node&&a.contains(e)});r.onNavigate.push(e.navigated),r.cleanups.push(e.stop)}),X(()=>r.cleanups.push(Le(()=>{for(let e of r.onNavigate)try{e()}catch{}})));let o=()=>{st(J,t,e.key).catch(()=>{})};window.addEventListener(`online`,o),r.cleanups.push(()=>window.removeEventListener(`online`,o)),ee(J,t,e.key,n).then(n=>{if(!r.alive)return;if(!n){Y(`this website key was not found`);return}let a=Ct(n.ai,n.samplingRate);if(r.config={...n,settings:yt(n.settings),branding:St(n.branding),ai:a},Rt(r),te(J,t,e.key,location.href),ot(e.key)&&o(),!n.enabled)return;if(!qt(n.allowedDomains,location.hostname)){Y(`${location.hostname} isn't one of this website's allowed domains, so the button is hidden. Add it under Websites in Pinax.`);return}zt(r);let s=lt(e.segment,r.config.settings.segment);a.replay&&Math.random()<a.replaySampleRate&&Vt(r);let c=new Pt(r.root,r.config,{takeScreenshot:async()=>(await i()).takeScreenshot(r.root.host,{autoBlur:a.autoBlur}),markUp:async e=>(await i()).markUp(r.root,e),submit:e=>Ut(r,e,s),user:()=>r.user,opened:s?dt:void 0,followUp:a.followUp?({type:n,message:r})=>ae(J,t,e.key,{type:n,message:r,pagePath:location.pathname}):void 0});r.ui=c;let{hidePaths:l,hideButton:u}=r.config.settings;if(l.length&&!u){let e=()=>c.setPathHidden(He(l,location.pathname));e(),r.onNavigate.push(e)}r.openWhenReady&&c.open()}).catch(e=>{r.alive&&Y(`could not load widget settings`,e)})}function Lt(e){let t=!1;return()=>{t||(t=!0,e())}}function Rt(e){let t=e.config?.settings.capture;t&&(t.console||(X(()=>e.stopCapture.console?.()),e.console.clear()),t.network||(X(()=>e.stopCapture.network?.()),e.network.clear()))}function zt(e){let t=e.config?.ai;!t?.fixChecks.length||t.fixCheckSampleRate<=0||X(()=>{let n=Ne({checks:t.fixChecks,sampleRate:t.fixCheckSampleRate,console:e.console,network:e.network,report:t=>oe(J,e.api,e.options.key,{checkId:t.id,signature:t.signature})});e.onNavigate.push(n.navigated),e.cleanups.push(n.stop)})}function Bt(e){let t=()=>{let t=window.requestIdleCallback;typeof t==`function`?t(e,{timeout:3e3}):setTimeout(e,200)};document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function Vt(e){Bt(()=>{e.alive&&a().then(t=>{if(!e.alive)return;let n=t.startRecorder({exclude:`#${e.root.host.id}`});e.recorder=n,e.cleanups.push(()=>n.stop())}).catch(e=>Y(`session replay could not start`,e))})}async function Ht(e){if(!e.recorder)return null;let t;try{return await Promise.race([e.recorder.exportReplay(O.replayChars).catch(()=>null),new Promise(e=>{t=setTimeout(()=>e(null),5e3)})])}finally{clearTimeout(t)}}async function Ut(e,t,n=!1){let r=n&&!e.user?.id?pt():null,i=r?{...e.user,id:r}:e.user,a=e.config?.settings.capture,o=Qe({type:t.type,message:t.message,rating:t.rating,email:t.email,user:i,screenshot:t.shot?.dataUrl,annotations:t.shot?.annotations,followUp:t.followUp,fields:t.fields,hp:t.hp,elapsedMs:t.elapsedMs},{page:{url:c(location.href),title:document.title||void 0},environment:Ee(),console:a?.console===!1?[]:e.console.toArray(),network:a?.network===!1?[]:e.network.toArray(),breadcrumbs:e.breadcrumbs.toArray()});et(o,await Ht(e));let s=await re(J,e.api,e.options.key,o),l=(e,r)=>{n&&ft({type:t.type,rating:t.rating,reportId:r,queued:e})};return s.ok?(l(!1,s.id||void 0),{status:`sent`}):s.retry&&at(e.options.key,o)?(l(!0),{status:`queued`}):{status:`error`,message:s.message}}function Wt(){K?K.ui?K.ui.open():K.config||(K.openWhenReady=!0):Y(`call init() before open()`)}function Gt(e){let t=e?{...e}:void 0;K?K.user=t:q=t}function Kt(){if(K){K.alive=!1,K.ui?.destroy();for(let e of K.cleanups.reverse())try{e()}catch{}}Ie(),K=null,q=void 0}function qt(e,t){if(!e)return!0;let n=t.toLowerCase();return e.some(e=>e.toLowerCase()===n)}var Z=document.currentScript;Z?.src&&t(Z.src);var Q=Z?.dataset.key,Jt=Z?.dataset.api,Yt=Z?.dataset.segment,Xt=Yt===`true`||Yt!==`false`&&void 0,Zt=Z?.dataset.cdn,$=()=>{Q&&It({key:Q,apiUrl:Jt,cdnUrl:Zt,segment:Xt})},Qt={init:It,open:()=>{$(),Wt()},identify:Gt,destroy:Kt},$t=Array.isArray(window.Pinax?.q)?window.Pinax.q:[];window.Pinax=Qt;for(let[e,t]of $t){let n=Qt[e];try{n?.(...t)}catch{}}Q&&(document.readyState===`complete`?$():window.addEventListener(`load`,$,{once:!0}))})();
133
+ @media (forced-colors: active) { .launcher, .choice, .send, .chip, .star { border: 1px solid ButtonText; } .known > li { border: 1px solid CanvasText; } }
134
+ `,tn=[{type:`PROBLEM`,key:`problem`,label:`Report a problem`,desc:`Point at what is broken`,dot:`#FF5C35`,send:`#CC3F1B`,ink:`#FFFFFF`},{type:`IDEA`,key:`idea`,label:`Share an idea`,desc:`Suggest something better`,dot:`#7C9CFF`,send:`#7C9CFF`,ink:`#0B1122`},{type:`GENERAL`,key:`general`,label:`General feedback`,desc:`A rating and a few words`,dot:`#3DBF6E`,send:`#3DBF6E`,ink:`#0B1300`},{type:`ACCESSIBILITY`,key:`accessibility`,label:`Report an accessibility barrier`,desc:`Something you can't see, reach or use`,dot:`#2FB8AC`,send:`#0F766E`,ink:`#FFFFFF`}],nn=[[`see`,`Hard to see or read`],[`keyboard`,`Can't use it with a keyboard`],[`screen-reader`,`Doesn't work with my screen reader`],[`media`,`Video or audio`],[`other`,`Something else`]],rn=4e3,an=`What would you like to do?`,on=`Thanks! We've got it.`,sn={problem:`problemTitle`,idea:`ideaTitle`,general:`generalTitle`,accessibility:`accessibilityTitle`},cn=class{constructor(e,t,n,r={}){this.root=e,this.config=t,this.handlers=n,this.kind=null,this.shot={kind:`none`},this.message=``,this.email=``,this.emailEdited=!1,this.answers={},this.sendColour=null,this.sending=!1,this.openedAt=0,this.hp=``,this.uid=Math.random().toString(36).slice(2,8),this.pathHidden=!1,this.returnFocus=null,this.known=[],this.knownHidden=new Set,this.meToo={},this.includeLogs=!1,this.privacy=null,this.noticeText=null,this.shown={logs:!0,askLogs:!1,replay:!1},this.view=`choose`,this.queued=!1,this.asked=null,this.answer=``;let i=t.settings,a=t.branding?.primary?Xt(t.branding.primary,``):``,o=t.branding?.accent?Xt(t.branding.accent,``):``,s=a||Xt(i.color);this.sendColour=a||null;let c=e=>e.key===`accessibility`?i.types?.accessibility===!0:i.types?.[e.key]!==!1;this.kinds=tn.filter(c),this.kinds.length||(this.kinds=tn.slice(0,3));let l=H(`style`);l.textContent=r.css?en+r.css:en,this.launcher=H(`button`,{type:`button`,class:`launcher`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-controls":`pnx-panel-${this.uid}`},(i.text||`Feedback`).slice(0,40)),this.launcher.addEventListener(`click`,()=>this.isOpen()?this.close():this.open()),this.panel=H(`div`,{class:`panel`,id:`pnx-panel-${this.uid}`,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`pnx-title-${this.uid}`,hidden:!0}),this.panel.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close())}),this.panel.addEventListener(`pointerdown`,()=>this.holdOpen()),this.panel.addEventListener(`focusin`,()=>this.holdOpen()),this.live=H(`div`,{class:`sr`,role:`status`,"aria-live":`polite`});let u=[`bottom-right`,`bottom-left`,`right-edge`].includes(i.position)?i.position:`bottom-right`;this.wrap=H(`div`,{class:`pnx pos-${u}${r.className?` ${r.className}`:``}`}),i.smallOnMobile&&this.wrap.classList.add(`small`),this.updateButton(),this.wrap.style.setProperty(`--pnx-brand`,s),this.wrap.style.setProperty(`--pnx-ink`,Yt(s)),o&&(this.wrap.classList.add(`accented`),this.wrap.style.setProperty(`--pnx-accent`,o),this.wrap.style.setProperty(`--pnx-accent-ink`,Yt(o))),this.wrap.append(this.launcher,this.panel,this.live),e.append(l,this.wrap)}isOpen(){return!this.panel.hidden}hasButton(){return!this.launcher.hidden}setPathHidden(e){this.pathHidden=e,this.updateButton()}updateButton(){let e=this.config.settings.hideButton||this.pathHidden;this.launcher.hidden=e,this.wrap.classList.toggle(`no-button`,e)}open(e=!0){if(this.isOpen()){e&&this.focusFirst();return}let t=document.activeElement;this.returnFocus=t instanceof HTMLElement&&t!==this.root.host?t:null,this.openedAt||(this.openedAt=Date.now()),(this.view===`choose`||this.kinds.length===1&&this.view===`form`&&!this.message.trim())&&this.offerKnown(),this.panel.hidden=!1,this.wrap.classList.add(`open`),this.launcher.setAttribute(`aria-expanded`,`true`),!this.kind&&this.kinds.length===1&&!this.knownShown().length&&this.pick(this.kinds[0],!1),this.render(),e&&this.focusFirst();try{this.handlers.opened?.()}catch{}}close(e=!0){clearTimeout(this.closeTimer),this.isOpen()&&(this.panel.hidden=!0,this.wrap.classList.remove(`open`),this.launcher.setAttribute(`aria-expanded`,`false`),this.view===`done`&&this.reset(),e&&(this.hasButton()?this.launcher.focus():this.returnFocus?.isConnected&&this.returnFocus.focus(),this.returnFocus=null))}currentView(){return this.isOpen()?this.view===`done`?`done`:(this.view===`form`||this.view===`question`)&&this.kind?this.kind.key:`choose`:`button`}showView(e){if(clearTimeout(this.closeTimer),e===`button`)this.close(!1);else{if(this.reset(),this.knownHidden.clear(),this.meToo={},e===`choose`&&this.offerKnown(),e===`done`)this.view=`done`;else if(e!==`choose`){let t=this.kinds.find(t=>t.key===e);t&&this.pick(t,!1)}this.isOpen()?this.render():this.open(!1)}}word(e,t){return this.config.settings.wording?.[e]?.trim()||t}kindTitle(e,t=e.label){return this.word(sn[e.key],t)}setSuspended(e){this.wrap.style.display=e?`none`:``}destroy(){clearTimeout(this.closeTimer),this.wrap.remove()}reset(){this.view=`choose`,this.kind=null,this.shot={kind:`none`},this.message=``,this.rating=void 0,this.barrier=void 0,this.answers={},this.includeLogs=!1,this.queued=!1,this.asked=null,this.answer=``,this.openedAt=this.isOpen()?Date.now():0,this.hp=``,this.kinds.length===1&&this.pick(this.kinds[0],!1)}holdOpen(){clearTimeout(this.closeTimer)}focusFirst(){for(let e of[`[data-autofocus]`,`.choice`,`textarea`,`button`]){let t=this.panel.querySelector(e);if(t){t.focus();return}}}announce(e){this.live.textContent=``,setTimeout(()=>{this.live.textContent=e},30)}pick(e,t=!0){this.kind=e,this.view=`form`,this.rating=void 0,!this.email&&!this.emailEdited&&this.config.settings.identifyPrefill!==!1&&(this.email=this.handlers.user()?.email||``),e.type===`PROBLEM`&&this.shot.kind===`none`&&this.capture(),e.type!==`PROBLEM`&&this.shot.kind===`busy`&&(this.shot={kind:`none`}),t&&(this.render(),this.focusFirst())}async capture(){this.shot={kind:`busy`},this.render();try{let e=await this.handlers.takeScreenshot();if(this.shot.kind!==`busy`)return;this.shot={kind:`ready`,shot:e},this.announce(`Screenshot added.`)}catch{if(this.shot.kind!==`busy`)return;this.shot={kind:`failed`},this.announce(`Couldn't take a screenshot.`)}this.renderKeepingFocus()}async markUp(){if(this.shot.kind===`ready`){this.setSuspended(!0);try{let e=await this.handlers.markUp(this.shot.shot);e&&(this.shot={kind:`ready`,shot:e},this.announce(e.annotations.length?`Screenshot marked up with ${e.annotations.length} ${e.annotations.length===1?`mark`:`marks`}.`:`Screenshot updated.`))}catch{}finally{this.setSuspended(!1),this.render(),this.panel.querySelector(`[data-markup]`)?.focus()}}}renderKeepingFocus(){let e=this.root.activeElement,t=e?.dataset?.key,n=e?.tagName===`TEXTAREA`?[e.selectionStart,e.selectionEnd]:null;if(this.render(),t){let e=this.panel.querySelector(`[data-key="${t}"]`);e?.focus(),n&&e instanceof HTMLTextAreaElement&&e.setSelectionRange(n[0],n[1])}}header(e,t,n){let r=H(`div`,{class:`head`});if(t){let e=H(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Back`,"data-key":`back`});e.append(U(W.back)),e.addEventListener(`click`,()=>{n?n():(this.view=`choose`,this.kind=null,this.render(),this.focusFirst())}),r.append(e)}r.append(H(`h2`,{class:`title`,id:`pnx-title-${this.uid}`},e));let i=H(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close feedback`,"data-key":`close`});return i.append(U(W.close)),i.addEventListener(`click`,()=>this.close()),r.append(i),r}powered(){return this.config.branding?.poweredBy?H(`div`,{class:`powered`},H(`a`,{href:`https://getpinax.com`,target:`_blank`,rel:`noopener`},`Powered by Pinax`)):null}logo(){let e=this.config.branding?.logoUrl;if(!e||!/^https?:\/\//i.test(e))return null;let t=H(`img`,{src:e,alt:``,class:`logo`,referrerpolicy:`no-referrer`});return t.addEventListener(`error`,()=>t.remove()),H(`div`,{class:`brand`},t)}render(){let e=[],t=this.logo();t&&e.push(t),this.view===`done`?e.push(...this.renderDone()):this.view===`question`&&this.kind&&this.asked?.question?e.push(...this.renderQuestion(this.kind,this.asked.question)):this.view===`form`&&this.kind?e.push(...this.renderForm(this.kind)):e.push(...this.renderChoose());let n=this.powered();n&&e.push(n),this.panel.replaceChildren(...e)}renderChoose(){let e=this.knownShown(),t=this.word(`chooserTitle`,an),n=H(`ul`,{class:`choices`});for(let e of this.kinds){let t=H(`button`,{type:`button`,class:`choice`},H(`span`,{class:`dot`,"aria-hidden":`true`}),H(`span`,{},this.kindTitle(e),H(`small`,{},e.desc)));t.style.setProperty(`--dot`,e.dot),t.addEventListener(`click`,()=>this.pick(e)),n.append(H(`li`,{},t))}return e.length?[this.header(`We know about this`,!1),...this.renderKnown(e),H(`h3`,{class:`subtitle`},t),n]:[this.header(t,!1),n]}knownShown(){return this.config.settings.knownIssues?.enabled===!1?[]:this.known.filter(e=>!this.knownHidden.has(e.id))}offerKnown(){try{this.known=this.handlers.knownIssues?.().slice(0,3)??[]}catch{this.known=[]}this.knownShown().length&&(this.view=`choose`,this.kind=null)}renderKnown(e){let t=this.config.settings.knownIssues?.notify!==!1,n=H(`ul`,{class:`known`}),r=!0;e.forEach((e,i)=>{let a=this.meToo[e.id],o=`pnx-k${i}-${this.uid}`,s=H(`p`,{class:`error`,role:`alert`,id:`pnx-k${i}-err-${this.uid}`}),c=H(`li`,{},H(`p`,{class:`known-title`,id:o},e.title));if(!a||a===`busy`){let t=H(`button`,{type:`button`,class:`chip primary`,"aria-describedby":o,"data-key":`metoo-${i}`,"data-autofocus":r||void 0,disabled:a===`busy`},`Me too`);r=!1,t.addEventListener(`click`,()=>this.sendMeToo(e,i,s)),c.append(t,s)}else if(a===`emailed`||!t)c.append(H(`p`,{class:`known-thanks`},a===`emailed`?`Thanks. We'll email you when it's fixed.`:`Thanks, we've added you.`));else{let t=`pnx-k${i}-email-${this.uid}`,n=`${t}-hint`,r=H(`input`,{id:t,type:`email`,inputmode:`email`,autocomplete:`email`,maxlength:254,"aria-describedby":n,"data-key":`known-email-${i}`,placeholder:`you@example.com`});r.value=this.email,r.addEventListener(`input`,()=>{this.email=r.value,this.emailEdited=!0});let o=H(`button`,{type:`button`,class:`chip primary`,"data-key":`known-send-${i}`,disabled:a===`sending`},a===`sending`?`Sending…`:`Send`);o.addEventListener(`click`,()=>this.sendMeToo(e,i,s,r)),c.append(H(`p`,{class:`known-thanks`},`Thanks, we've added you.`),H(`div`,{class:`field`},H(`label`,{for:t},`Email me when it's fixed`),r,H(`span`,{class:`hint`,id:n},`Only used to tell you when it's fixed.`)),s,o)}n.append(c)});let i=H(`button`,{type:`button`,class:`link`,"data-key":`known-else`},`Report something else`);return i.addEventListener(`click`,()=>{for(let t of e)this.knownHidden.add(t.id);this.kinds.length===1?this.pick(this.kinds[0]):(this.render(),this.panel.querySelector(`.choice`)?.focus())}),[n,i]}async sendMeToo(e,t,n,r){let i=this.meToo[e.id];if(i===`busy`||i===`sending`)return;n.textContent=``;let a=r?this.email.trim():void 0;if(r&&(!a||!g(a))){n.textContent=`Please check your email address.`,r.setAttribute(`aria-invalid`,`true`),r.setAttribute(`aria-errormessage`,n.id),r.focus();return}this.meToo[e.id]=r?`sending`:`busy`,this.renderKeepingFocus();let o=!1;try{o=await this.handlers.meToo?.(e.id,a)??!1}catch{o=!1}if(o||r?this.meToo[e.id]=o&&r?`emailed`:`done`:delete this.meToo[e.id],!this.isOpen()||this.view!==`choose`)return;this.render();let s=e=>this.panel.querySelector(`[data-key="${e}"]`);if(o)(s(`known-email-${t}`)??s(`known-else`))?.focus(),this.announce(r?`Thanks. We'll email you when it's fixed.`:`Thanks, we've added you.`);else{let e=this.panel.querySelector(`#pnx-k${t}-err-${this.uid}`);e&&(e.textContent=`Something went wrong. Please try again.`),s(r?`known-send-${t}`:`metoo-${t}`)?.focus()}}renderShot(e){let t=this.shot;if(t.kind===`none`){if(e.type===`GENERAL`)return null;let t=H(`button`,{type:`button`,class:`chip`,"data-key":`add-shot`},U(W.camera),`Add a screenshot`);return t.addEventListener(`click`,()=>this.capture()),H(`div`,{class:`shot-actions`},t)}if(t.kind===`busy`)return H(`div`,{class:`shot`,"aria-busy":`true`},H(`span`,{class:`wait`},`Taking a screenshot…`));if(t.kind===`failed`){let e=H(`button`,{type:`button`,class:`chip`,"data-key":`retry-shot`},`Try again`);return e.addEventListener(`click`,()=>this.capture()),H(`div`,{class:`field`},H(`span`,{class:`hint`},`Couldn't take a screenshot of this page.`),H(`div`,{class:`shot-actions`},e))}let n=t.shot.annotations.length,r=t.shot.autoBlurred??0,i=H(`img`,{src:t.shot.dataUrl,alt:`Screenshot of this page${n?` with ${n} ${n===1?`mark`:`marks`}`:``}${r?`, ${r} private ${r===1?`detail`:`details`} blurred`:``}`}),a=H(`button`,{type:`button`,class:`chip primary`,"data-markup":!0,"data-key":`markup`},U(W.pen),n?`Edit marks`:`Mark up`);a.addEventListener(`click`,()=>this.markUp());let o=H(`button`,{type:`button`,class:`chip`,"data-key":`remove-shot`},U(W.trash),`Remove`,H(`span`,{class:`sr`},` screenshot`));return o.addEventListener(`click`,()=>{this.shot={kind:`none`},this.announce(`Screenshot removed.`),this.render(),this.panel.querySelector(`[data-key="add-shot"]`)?.focus()}),H(`div`,{class:`field`},H(`div`,{class:`shot`},i,H(`span`,{class:`tag`,"aria-hidden":`true`},`Screenshot`)),H(`div`,{class:`shot-actions`},a,o),r?H(`span`,{class:`hint auto-blur`},H(`i`,{"aria-hidden":`true`}),`We blurred ${r===1?`1 private detail`:`${r} private details`} for you.`):null)}renderStars(){let e=H(`div`,{class:`stars`,role:`radiogroup`,"aria-labelledby":`pnx-rate-${this.uid}`}),t=[],n=(this.rating??1)-1;for(let e=1;e<=5;e++){let r=H(`button`,{type:`button`,class:this.rating!==void 0&&e<=this.rating?`star on`:`star`,role:`radio`,"aria-checked":this.rating===e?`true`:`false`,"aria-label":`${e} ${e===1?`star`:`stars`}`,tabindex:e-1===n?0:-1,"data-key":`star-${e}`},`★`);r.addEventListener(`click`,()=>{this.rating=this.rating===e?void 0:e,this.renderKeepingFocus()}),r.addEventListener(`keydown`,e=>{let t=e.key===`ArrowRight`||e.key===`ArrowUp`?1:e.key===`ArrowLeft`||e.key===`ArrowDown`?-1:0;if(!t)return;e.preventDefault();let n=Math.min(5,Math.max(1,(this.rating??0)+t||1));this.rating=n,this.render(),this.panel.querySelector(`[data-key="star-${n}"]`)?.focus()}),t.push(r)}return e.append(...t),H(`div`,{class:`field`},H(`span`,{class:`legend`,id:`pnx-rate-${this.uid}`},`How's your visit so far? (optional)`),e)}renderForm(e){if(e.type===`ACCESSIBILITY`)return this.renderAccessibility(e);let t=e.type===`GENERAL`&&this.config.settings.rating!==!1,n=this.kindTitle(e,t?`How was your visit?`:e.label),r=[this.header(n,this.kinds.length>1)],i=this.renderShot(e);i&&r.push(i),t&&r.push(this.renderStars());let a=`pnx-msg-${this.uid}`,o=H(`textarea`,{id:a,maxlength:5e3,"data-key":`message`,"data-autofocus":e.type!==`PROBLEM`&&!t||void 0,placeholder:this.word(`messagePlaceholder`,e.type===`PROBLEM`?`What happened?`:e.type===`IDEA`?`What would make this better?`:`Tell us what you think`)});return o.value=this.message,o.addEventListener(`input`,()=>{this.message=o.value}),r.push(H(`div`,{class:`field`},H(`label`,{for:a},e.type===`PROBLEM`?`What went wrong?`:e.type===`IDEA`?`Your idea`:`Anything to add?`),o)),r.push(...this.renderFields(e)),r.push(...this.renderEmailAndSend(e,o,e.type===`PROBLEM`?`Only used to tell you about this report.`:`Only used to reply to you about this.`)),r}renderEmailAndSend(e,t,n){let r=[],i=`pnx-email-${this.uid}`,a=`pnx-email-hint-${this.uid}`,o=H(`input`,{id:i,type:`email`,inputmode:`email`,autocomplete:`email`,maxlength:320,"aria-describedby":a,"data-key":`email`,placeholder:`you@example.com`});o.value=this.email,o.addEventListener(`input`,()=>{this.email=o.value,this.emailEdited=!0}),r.push(H(`div`,{class:`field`},H(`label`,{for:i},`Your email (optional)`),o,H(`span`,{class:`hint`,id:a},n)));let s=H(`p`,{class:`error`,role:`alert`,id:`pnx-err-${this.uid}`}),c=H(`button`,{type:`button`,class:`send`,"data-key":`send`,"aria-describedby":`pnx-notice-${this.uid}`,disabled:this.sending},this.sending?`Sending…`:`Send`);return this.colourSend(c,e),c.addEventListener(`click`,()=>this.send(e,s,o,t)),r.push(this.renderPrivacy(),this.honeypot(),s,c),r}attachments(){try{return this.handlers.attachments?.()??{logs:!0,askLogs:!1,replay:!1}}catch{return{logs:!1,askLogs:!1,replay:!1}}}renderPrivacy(){let e=this.attachments();this.shown=e;let t=H(`div`,{class:`privacy`});if(e.askLogs){let e=`pnx-logs-${this.uid}`,n=H(`input`,{id:e,type:`checkbox`,"data-key":`include-logs`});n.checked=this.includeLogs,n.addEventListener(`change`,()=>{this.includeLogs=n.checked,this.updateNotice()}),t.append(H(`div`,{class:`field check`},n,H(`label`,{for:e},`Include technical details (console messages and failed requests) to help fix this`)))}this.noticeText=H(`span`,{});let n=H(`p`,{class:`notice`,id:`pnx-notice-${this.uid}`},this.noticeText),r=this.config.settings.privacyUrl;return r&&/^https:\/\//i.test(r)&&n.append(` `,H(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`},`Privacy policy`,H(`span`,{class:`sr`},` (opens in a new tab)`))),t.append(n),this.privacy=t,this.updateNotice(),t}updateNotice(){if(!this.noticeText)return;let e=this.shown,t=[`the page address`,`your browser details`];this.shot.kind===`ready`&&t.push(`the screenshot`),(e.logs||e.askLogs&&this.includeLogs)&&t.push(`technical logs`),e.replay&&t.push(`a recording of the last 30 seconds`);let n=``;try{n=this.handlers.site?.()??``}catch{}n=n||location.hostname.replace(/^www\./,``)||`this website`,this.noticeText.textContent=`Sent to ${n} with your note: ${t.join(`, `)}.`}refresh(){let e=this.privacy;if(!e?.isConnected)return;let t=this.attachments();if(t.askLogs===this.shown.askLogs){this.shown=t,this.updateNotice();return}let n=e.contains(this.root.activeElement),r=this.renderPrivacy();e.replaceWith(r),n&&(r.querySelector(`input`)??this.panel.querySelector(`[data-key="send"]`))?.focus()}renderAccessibility(e){let t=[this.header(this.kindTitle(e),this.kinds.length>1)],n=`pnx-a11y-note-${this.uid}`;t.push(H(`p`,{class:`a11y-note`,id:n},`We'll pass this to the team that runs this website. We also check this page for common accessibility problems and send the results with it.`));let r=`pnx-barrier-${this.uid}`,i=H(`fieldset`,{class:`field barriers`,"aria-labelledby":r,"aria-describedby":n},H(`legend`,{class:`legend`,id:r},`What's getting in the way? `,H(`span`,{class:`optional`},`(optional)`)));nn.forEach(([e,t],n)=>{let r=`pnx-b${n}-${this.uid}`,a=H(`input`,{id:r,type:`radio`,name:`pnx-barrier-${this.uid}`,value:e,"data-key":`barrier-${e}`,"data-autofocus":(this.barrier?this.barrier===e:n===0)||void 0});a.checked=this.barrier===e,a.addEventListener(`change`,()=>{a.checked&&(this.barrier=e)}),i.append(H(`div`,{class:`radio`},a,H(`label`,{for:r},t)))}),t.push(i);let a=`pnx-msg-${this.uid}`,o=H(`textarea`,{id:a,maxlength:5e3,"data-key":`message`,"aria-describedby":n,placeholder:this.word(`messagePlaceholder`,`For example: I couldn't reach the Pay button with the Tab key`)});o.value=this.message,o.addEventListener(`input`,()=>{this.message=o.value}),t.push(H(`div`,{class:`field`},H(`label`,{for:a},`What were you trying to do, and what stopped you?`),o));let s=this.renderShot(e);return s&&t.push(s),t.push(...this.renderEmailAndSend(e,o,`Only used to reply to you about this.`)),t}honeypot(){let e=H(`input`,{type:`text`,name:`website`,tabindex:-1,autocomplete:`off`,"aria-label":`Leave this empty`});e.value=this.hp,e.addEventListener(`input`,()=>{this.hp=e.value});let t=H(`div`,{"aria-hidden":`true`},e);return t.style.cssText=`position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden`,t}async send(e,t,n,r){if(this.sending)return;t.textContent=``,n.removeAttribute(`aria-invalid`);let i=this.email.trim();if(i&&!g(i)){t.textContent=`Please check your email address, or leave it empty.`,n.setAttribute(`aria-invalid`,`true`),n.setAttribute(`aria-errormessage`,t.id),n.focus();return}if(this.shot.kind===`busy`){t.textContent=`One moment, the screenshot is still being taken.`;return}for(let n of this.fieldsFor(e)){let e=this.answers[n.id];if(!n.required||(n.type===`checkbox`?e===!0:e))continue;let r=this.panel.querySelector(`[data-key="field-${n.id}"]`);t.textContent=n.type===`checkbox`?`Please tick “${n.label}”.`:n.type===`select`?`Please choose an answer for “${n.label}”.`:`Please fill in “${n.label}”.`,r?.setAttribute(`aria-invalid`,`true`),r?.setAttribute(`aria-errormessage`,t.id),r?.focus();return}let a=this.shot.kind===`ready`?this.shot.shot:void 0,o=e.type===`GENERAL`?this.rating:void 0;if(!de({type:e.type,message:this.message,rating:o,screenshot:a?.dataUrl,barrier:e.type===`ACCESSIBILITY`?this.barrier:void 0})){t.textContent=e.type===`GENERAL`&&this.config.settings.rating!==!1?`Add a few words or a star rating.`:e.type===`ACCESSIBILITY`?`Choose what's in the way, or add a few words.`:`Add a few words so we know what you mean.`,r.focus();return}this.sending=!0,this.renderKeepingFocus(),this.announce(`Sending…`);let s=await this.askFollowUp(e);this.view!==`form`||this.kind!==e||!this.isOpen()?(this.sending=!1,this.isOpen()&&this.renderKeepingFocus()):s?(this.sending=!1,this.view=`question`,this.render(),this.focusFirst()):await this.submitNow(e,i,o,a)}async askFollowUp(e){let t=this.handlers.followUp,n=this.message.trim();if(!t||e.type===`GENERAL`||e.type===`ACCESSIBILITY`||!n||n.length>140)return null;if(this.asked?.message===n)return this.asked.question;let r=null;try{r=(await t({type:e.type,message:n}))?.trim()||null}catch{r=null}return this.asked={message:n,question:r?.slice(0,300)||null},this.asked.question}async submitNow(e,t,n,r,i){this.sending=!0,this.renderKeepingFocus();let a;try{a=await this.handlers.submit({type:e.type,message:this.message,rating:n,email:t||void 0,shot:r,followUp:i,fields:this.fieldAnswers(e),barrier:e.type===`ACCESSIBILITY`?this.barrier:void 0,includeLogs:this.shown.askLogs&&this.includeLogs?!0:void 0,listed:{logs:this.shown.logs||this.shown.askLogs&&this.includeLogs,replay:this.shown.replay},hp:this.hp||void 0,elapsedMs:this.openedAt?Math.max(0,Date.now()-this.openedAt):void 0})}catch{a={status:`error`,message:`Something went wrong. Please try again.`}}if(this.sending=!1,a.status===`error`){this.view=`form`,this.render();let e=this.panel.querySelector(`.error`);e&&(e.textContent=a.message),this.panel.querySelector(`[data-key="send"]`)?.focus()}else this.queued=a.status===`queued`,this.view=`done`,this.render(),this.focusFirst(),this.announce(this.queued?`Saved. We'll send it when you're back online.`:this.word(`confirmation`,on)),this.closeTimer=setTimeout(()=>this.close(this.panel.contains(this.root.activeElement)),rn)}renderQuestion(e,t){let n=[this.header(`One quick question`,!0,()=>{this.view=`form`,this.render(),this.panel.querySelector(`[data-key="message"]`)?.focus()})],r=H(`div`,{class:`note`},H(`span`,{class:`dot`,"aria-hidden":`true`}),H(`span`,{},H(`span`,{class:`sr`},`Your note: `),`“${this.message.trim()}”`));r.style.setProperty(`--dot`,e.dot),n.push(r);let i=`pnx-answer-${this.uid}`,a=`pnx-answer-hint-${this.uid}`,o=H(`textarea`,{id:i,class:`answer`,maxlength:2e3,"data-key":`answer`,"data-autofocus":!0,"aria-describedby":a,placeholder:`Your answer`});o.value=this.answer,o.addEventListener(`input`,()=>{this.answer=o.value}),n.push(H(`div`,{class:`field`},H(`label`,{for:i,class:`question`},t),o,H(`span`,{class:`hint`,id:a},`Optional. It helps us fix it faster.`)));let s=H(`p`,{class:`error`,role:`alert`}),c=this.email.trim(),l=e.type===`GENERAL`?this.rating:void 0,u=this.shot.kind===`ready`?this.shot.shot:void 0,d=H(`button`,{type:`button`,class:`send`,"data-key":`send`,disabled:this.sending},this.sending?`Sending…`:`Send`);this.colourSend(d,e),d.addEventListener(`click`,()=>{if(this.sending)return;let n=this.answer.trim();this.announce(`Sending…`),this.submitNow(e,c,l,u,n?{question:t,answer:n.slice(0,2e3)}:void 0)});let f=H(`button`,{type:`button`,class:`link skip`,"data-key":`skip`,disabled:this.sending},`Skip and send`);return f.addEventListener(`click`,()=>{this.sending||(this.announce(`Sending…`),this.submitNow(e,c,l,u))}),n.push(s,d,f),n}colourSend(e,t){let n=this.sendColour??t.send;e.style.setProperty(`--type`,n),e.style.setProperty(`--type-ink`,this.sendColour?Yt(n):t.ink)}fieldsFor(e){if(e.key===`accessibility`)return[];let t=e.key;return(this.config.settings.fields??[]).filter(e=>e.types?.[t]!==!1)}fieldAnswers(e){let t=[];for(let n of this.fieldsFor(e)){let e=this.answers[n.id];n.type===`checkbox`?t.push({id:n.id,value:e===!0}):typeof e==`string`&&e.trim()&&t.push({id:n.id,value:e.trim()})}return t.length?t:void 0}renderFields(e){return this.fieldsFor(e).map((e,t)=>{let n=`pnx-f${t}-${this.uid}`,r=`field-${e.id}`,i=e=>{e.removeAttribute(`aria-invalid`),e.removeAttribute(`aria-errormessage`)},a=t=>H(`label`,{for:n,class:t},e.label,e.required?null:H(`span`,{class:`optional`},` (optional)`));if(e.type===`checkbox`){let t=H(`input`,{id:n,type:`checkbox`,"data-key":r,"aria-required":e.required?`true`:void 0});return t.checked=this.answers[e.id]===!0,t.addEventListener(`change`,()=>{this.answers[e.id]=t.checked,i(t)}),H(`div`,{class:`field check`},t,a())}if(e.type===`select`){let t=H(`select`,{id:n,"data-key":r,"aria-required":e.required?`true`:void 0},H(`option`,{value:``},`Choose…`),...e.options.map(e=>H(`option`,{value:e},e)));return t.value=String(this.answers[e.id]??``),t.addEventListener(`change`,()=>{this.answers[e.id]=t.value,i(t)}),H(`div`,{class:`field`},a(),t)}let o=H(`input`,{id:n,type:`text`,maxlength:200,"data-key":r,"aria-required":e.required?`true`:void 0});return o.value=String(this.answers[e.id]??``),o.addEventListener(`input`,()=>{this.answers[e.id]=o.value,i(o)}),H(`div`,{class:`field`},a(),o)})}renderDone(){let e=H(`button`,{type:`button`,class:`link`,"data-key":`again`},`Send another`);e.addEventListener(`click`,()=>{this.reset(),this.render(),this.focusFirst()});let t=H(`div`,{class:`head`});t.append(H(`span`,{class:`title`}));let n=H(`button`,{type:`button`,class:`icon-btn`,"aria-label":`Close feedback`});return n.append(U(W.close)),n.addEventListener(`click`,()=>this.close()),t.append(n),[t,H(`div`,{class:`done`},H(`span`,{class:`tick`,"aria-hidden":`true`},`✓`),H(`h2`,{class:`title`,id:`pnx-title-${this.uid}`,tabindex:-1,"data-autofocus":!0},this.queued?`Saved for later`:this.word(`confirmation`,on)),this.queued?H(`p`,{},`You're offline. We'll send it as soon as you're back.`,this.email.trim()?` If you leave this page first, it goes without your email address.`:``):null,e)]}},ln=8e3,G=null,K,q,un,dn,J=(e,t)=>(dn??window.fetch).call(window,e,t);function Y(e,t){try{(console.warn.__pinaxOriginal??console.warn).call(console,`Pinax: ${e}`,t??``)}catch{}}function X(e){try{e()}catch(e){Y(`capture could not start`,e)}}function fn(e){if(G)return;if(!e?.key)throw Error(`Pinax: init() needs a website key`);let t=ge(e.apiUrl),n=_e(e.cdnUrl,e.apiUrl);dn=typeof window.fetch==`function`?window.fetch:void 0;let r={options:e,api:t,cdn:n,root:lt(),user:K,console:new et(50),network:new et(50),breadcrumbs:new et(20),replayStarting:!1,replaySampled:!1,consent:{diagnostics:!1,replay:!1,...q},running:!1,watchers:{},counted:!1,stopCapture:{},onNavigate:[],cleanups:[],openWhenReady:!1,alive:!0};G=r,K=void 0,q=void 0,X(()=>{let e=pn(qe(r.console));r.stopCapture.console=e,r.cleanups.push(e)}),X(()=>{let i=pn($e(r.network,window,{ignore:r=>r.startsWith(`${t}/v1/widget/`)||n!==null&&(r.startsWith(ve(n,e.key))||r.startsWith(De(t,e.key,n)))}));r.stopCapture.network=i,r.cleanups.push(i)});let a=r.root.host;X(()=>{let e=Ve(r.breadcrumbs,{ignore:e=>e instanceof Node&&a.contains(e)});r.onNavigate.push(e.navigated),r.cleanups.push(e.stop)}),r.onNavigate.push(()=>{r.watchers.fixChecks?.navigated(),r.watchers.sightings?.navigated()}),r.cleanups.push(()=>{Sn(r),En(r)}),X(()=>r.cleanups.push(dt(()=>{for(let e of r.onNavigate)try{e()}catch{}})));let o=()=>{Tt(J,t,e.key).catch(()=>{})};window.addEventListener(`online`,o),r.cleanups.push(()=>window.removeEventListener(`online`,o)),be(J,t,e.key,n).then(n=>{if(!r.alive)return;if(!n){Y(`this website key was not found`);return}let a=Wt(n.ai,n.samplingRate),s=Rt(n.settings);r.config={...n,settings:s,branding:Ht(n.branding),ai:a,known:Kt(n.known,s.knownIssues)},mn(r),r.replaySampled=a.replay&&Math.random()<a.replaySampleRate,xe(J,t,e.key,location.href),wt(e.key)&&o();let c=Ln(n.allowedDomains,location.hostname);if(n.enabled&&!c&&Y(`${location.hostname} isn't one of this website's allowed domains, so the button is hidden. Add it under Websites in Pinax.`),r.running=n.enabled&&c,_n(r),!r.running)return;let l=Cn(r),u=Ot(e.segment,r.config.settings.segment),d=new cn(r.root,r.config,{takeScreenshot:async()=>(await i()).takeScreenshot(r.root.host,{autoBlur:a.autoBlur}),markUp:async e=>(await i()).markUp(r.root,e),submit:e=>An(r,e,u),user:()=>r.user,opened:u?At:void 0,followUp:a.followUp?({type:n,message:r})=>Te(J,t,e.key,{type:n,message:r,pagePath:location.pathname}):void 0,knownIssues:l,meToo:(n,r)=>Ae(J,t,e.key,n,r),attachments:()=>kn(r)});r.ui=d;let{hidePaths:f,hideButton:p}=r.config.settings;if(f.length&&!p){let e=()=>d.setPathHidden(gt(f,location.pathname));e(),r.onNavigate.push(e)}r.openWhenReady&&d.open()}).catch(e=>{r.alive&&Y(`could not load widget settings`,e)})}function pn(e){let t=!1;return()=>{t||(t=!0,e())}}function mn(e){let t=e.config?.settings.capture;t&&(t.console||(X(()=>e.stopCapture.console?.()),e.console.clear()),t.network||(X(()=>e.stopCapture.network?.()),e.network.clear()))}function hn(e){let t=e.options.consent;return t===`wait`||t!==`none`&&e.config?.settings.consent?.required===!0}function gn(e){return hn(e)||e.config?.settings.consent?.required===!0}function Z(e){let t=hn(e);return{diagnostics:!t||e.consent.diagnostics,replay:!t||e.consent.replay}}function _n(e){try{vn(e)}catch(e){Y(`could not apply consent`,e)}}function vn(e){if(!e.alive||!e.config)return;let t=Z(e);e.config.settings.consent?.required&&t.diagnostics&&!e.counted&&(e.counted=!0,Oe(J,e.api,e.options.key,e.cdn)),e.running&&(t.diagnostics?(bn(e),xn(e)):Sn(e),t.replay&&e.replaySampled?Tn(e):En(e)),e.ui?.refresh()}var yn=e=>gn(e)&&Z(e).diagnostics?!0:void 0;function bn(e){let t=e.config?.ai;!e.watchers.fixChecks&&t?.fixChecks.length&&(t.fixCheckSampleRate<=0||X(()=>{e.watchers.fixChecks=A({checks:t.fixChecks,sampleRate:t.fixCheckSampleRate,console:e.console,network:e.network,since:e.watchersSince,report:t=>Ee(J,e.api,e.options.key,{checkId:t.id,signature:t.signature,consent:yn(e)})})}))}function xn(e){let t=e.config?.ai;!e.watchers.sightings&&t?.watches.length&&(t.fixCheckSampleRate<=0||X(()=>{e.watchers.sightings=A({checks:t.watches.map(e=>({...e,path:`*`})),sampleRate:t.fixCheckSampleRate,console:e.console,network:e.network,since:e.watchersSince,report:t=>Ee(J,e.api,e.options.key,{checkId:t.id,signature:t.signature,basket:un,consent:yn(e)},`sighting`)})}))}function Sn(e){let{fixChecks:t,sightings:n}=e.watchers;(t||n)&&(e.watchers={},e.watchersSince=Date.now()+2,X(()=>t?.stop()),X(()=>n?.stop()))}function Cn(e){let t=e.config?.known;if(!t?.length)return;let n;return X(()=>{let r=st({known:t,console:e.console,network:e.network});e.onNavigate.push(r.navigated),e.cleanups.push(r.stop),n=r.matches}),n}function wn(e){let t=()=>{let t=window.requestIdleCallback;typeof t==`function`?t(e,{timeout:3e3}):setTimeout(e,200)};document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function Tn(e){if(e.recorder||e.replayStarting)return;e.replayStarting=!0;let t=()=>e.alive&&e.running&&e.replaySampled&&Z(e).replay;wn(()=>{t()?a().then(n=>{e.replayStarting=!1,!e.recorder&&t()&&(e.recorder=n.startRecorder({exclude:`#${e.root.host.id}`,mask:e.config?.ai?.replayMask}),e.ui?.refresh())}).catch(t=>{e.replayStarting=!1,Y(`session replay could not start`,t)}):e.replayStarting=!1})}function En(e){let t=e.recorder;e.recorder=void 0,t&&X(()=>t.stop())}async function Dn(e){if(!e.recorder)return null;let t;try{return await Promise.race([e.recorder.exportReplay(h.replayChars).catch(()=>null),new Promise(e=>{t=setTimeout(()=>e(null),5e3)})])}finally{clearTimeout(t)}}async function On(e){let t;try{return await Promise.race([o().then(t=>t.scanPage({exclude:`#${e.root.host.id}`})).catch(()=>null),new Promise(e=>{t=setTimeout(()=>e(null),ln)})])}finally{clearTimeout(t)}}function kn(e){let t=Z(e),n=e.config?.settings.capture,r=n?.console!==!1,i=n?.network!==!1;return{logs:t.diagnostics&&(r&&e.console.size>0||i&&e.network.size>0||e.breadcrumbs.size>0),askLogs:!t.diagnostics&&(r||i),replay:t.replay&&!!e.recorder&&typeof CompressionStream==`function`}}async function An(e,t,n=!1){let r=t.type===`ACCESSIBILITY`?await On(e):void 0,i=Z(e),a=(i.diagnostics||t.includeLogs===!0)&&t.listed?.logs!==!1,o=i.replay&&t.listed?.replay!==!1,s=n&&i.diagnostics&&!e.user?.id?Mt():null,c=s?{...e.user,id:s}:e.user,l=e.config?.settings.capture,u=pe({type:t.type,message:t.message,rating:t.rating,email:t.email,user:c,screenshot:t.shot?.dataUrl,annotations:t.shot?.annotations,followUp:t.followUp,fields:t.fields,barrier:t.barrier,a11yScan:r,hp:t.hp,elapsedMs:t.elapsedMs,consent:gn(e)?i:void 0,includeLogs:t.includeLogs},{page:{url:v(location.href),title:document.title||void 0},environment:Ze(),console:!a||l?.console===!1?[]:e.console.toArray(),network:!a||l?.network===!1?[]:e.network.toArray(),breadcrumbs:a?e.breadcrumbs.toArray():[]});o&&he(u,await Dn(e));let d=await Ce(J,e.api,e.options.key,u),f=(e,r)=>{n&&jt({type:t.type,rating:t.rating,reportId:r,queued:e})};return d.ok?(f(!1,d.id||void 0),{status:`sent`}):d.retry&&Ct(e.options.key,u)?(f(!0),{status:`queued`}):{status:`error`,message:d.message}}function jn(){G?G.ui?G.ui.open():G.config||(G.openWhenReady=!0):Y(`call init() before open()`)}function Mn(e){let t;if(typeof e==`boolean`)t={diagnostics:e,replay:e};else if(e&&typeof e==`object`){t={};for(let n of[`diagnostics`,`replay`])e[n]!==void 0&&(t[n]=e[n]===!0)}else{Y(`consent() takes true, false or { diagnostics, replay }`);return}G?(G.consent={...G.consent,...t},_n(G)):q={...q,...t}}function Nn(e){let t=e?{...e}:void 0;G?G.user=t:K=t}function Pn(e){un=Fn(e)}function Fn(e){if(!e||typeof e!=`object`)return;let{value:t,currency:n}=e,r=typeof n==`string`?n.trim().toUpperCase():``;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0||t>1e7||!/^[A-Z]{3}$/.test(r)))return{value:Math.round(t*100)/100,currency:r}}function In(){if(G){G.alive=!1,G.ui?.destroy();for(let e of G.cleanups.reverse())try{e()}catch{}}ut(),G=null,K=void 0,q=void 0,un=void 0}function Ln(e,t){if(!e)return!0;let n=t.toLowerCase();return e.some(e=>e.toLowerCase()===n)}var Q=document.currentScript;Q?.src&&t(Q.src);var Rn=Q?.dataset.key,zn=Q?.dataset.api,Bn=Q?.dataset.segment,Vn=Bn===`true`||Bn!==`false`&&void 0,Hn=Q?.dataset.cdn,Un=Q?.dataset.consent,Wn=Un===`wait`||Un===`none`?Un:void 0,$=()=>{Rn&&fn({key:Rn,apiUrl:zn,cdnUrl:Hn,segment:Vn,consent:Wn})},Gn={init:fn,open:()=>{$(),jn()},identify:Nn,setBasket:Pn,consent:Mn,destroy:In},Kn=Array.isArray(window.Pinax?.q)?window.Pinax.q:[];window.Pinax=Gn;for(let[e,t]of Kn){let n=Gn[e];try{n?.(...t)}catch{}}Rn&&(document.readyState===`complete`?$():window.addEventListener(`load`,$,{once:!0}))})();
113
135
  //# sourceMappingURL=pinax.js.map