@siteping/widget 0.9.15 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{chunk-NEX6ECQM.js → chunk-BC2J5J47.js} +23 -11
  2. package/dist/chunk-BC2J5J47.js.map +1 -0
  3. package/dist/de-QELS3SWK.js +2 -0
  4. package/dist/de-QELS3SWK.js.map +1 -0
  5. package/dist/es-CYTPFERY.js +2 -0
  6. package/dist/es-CYTPFERY.js.map +1 -0
  7. package/dist/fr-4XLS426K.js +2 -0
  8. package/dist/fr-4XLS426K.js.map +1 -0
  9. package/dist/index.global.js +59 -47
  10. package/dist/index.global.js.map +1 -1
  11. package/dist/index.js +33 -33
  12. package/dist/index.js.map +1 -1
  13. package/dist/it-ZYXUTNWT.js +2 -0
  14. package/dist/it-ZYXUTNWT.js.map +1 -0
  15. package/dist/panel-YIFL7JMG.js +2 -0
  16. package/dist/panel-YIFL7JMG.js.map +1 -0
  17. package/dist/pt-W7J2A2O3.js +2 -0
  18. package/dist/pt-W7J2A2O3.js.map +1 -0
  19. package/dist/react.js +32 -32
  20. package/dist/react.js.map +1 -1
  21. package/dist/ru-AE6EJFY7.js +2 -0
  22. package/dist/ru-AE6EJFY7.js.map +1 -0
  23. package/dist/schema.d.ts +4 -0
  24. package/dist/siteping-core.d.ts +2 -2
  25. package/dist/types.d.ts +56 -1
  26. package/package.json +4 -4
  27. package/dist/chunk-NEX6ECQM.js.map +0 -1
  28. package/dist/de-CO2K72R2.js +0 -2
  29. package/dist/de-CO2K72R2.js.map +0 -1
  30. package/dist/es-2QYDBGOD.js +0 -2
  31. package/dist/es-2QYDBGOD.js.map +0 -1
  32. package/dist/fr-7YJBFS2W.js +0 -2
  33. package/dist/fr-7YJBFS2W.js.map +0 -1
  34. package/dist/it-44RM76KH.js +0 -2
  35. package/dist/it-44RM76KH.js.map +0 -1
  36. package/dist/panel-66LNZR5L.js +0 -2
  37. package/dist/panel-66LNZR5L.js.map +0 -1
  38. package/dist/pt-DRKIF4UZ.js +0 -2
  39. package/dist/pt-DRKIF4UZ.js.map +0 -1
  40. package/dist/ru-EAKBDL3X.js +0 -2
  41. package/dist/ru-EAKBDL3X.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v,h,g,a,f,i,B as B$1,D,C,A,l,m,n,o,E}from'./chunk-NEX6ECQM.js';var Yt=new Set(["role","name","aria-label","rel","href"]);function Wt(t,e){let n=Yt.has(t);n||=t.startsWith("data-")&&X(t);let i=X(e)&&e.length<100;return i||=e.startsWith("#")&&X(e.slice(1)),n&&i}function Ut(t){return X(t)}function Gt(t){return X(t)}function Vt(t){return true}function ft(t,e){if(t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return "html";let n={root:document.body,idName:Ut,className:Gt,tagName:Vt,attr:Wt,timeoutMs:1e3,seedMinLength:3,optimizedMinLength:2,maxNumberOfPathChecks:1/0},i=new Date,o={...n,...e},r=tn(o.root,n),s,a=0;for(let p of Jt(t,o,r)){if(new Date().getTime()-i.getTime()>o.timeoutMs||a>=o.maxNumberOfPathChecks){let u=Qt(t,r);if(!u)throw new Error(`Timeout: Can't find a unique selector after ${o.timeoutMs}ms`);return K(u)}if(a++,Re(p,r)){s=p;break}}if(!s)throw new Error("Selector was not found.");let l=[...gt(s,t,o,r,i)];return l.sort(Ae),l.length>0?K(l[0]):K(s)}function*Jt(t,e,n){let i=[],o=[],r=t,s=0;for(;r&&r!==n;){let a=Zt(r,e);for(let l of a)l.level=s;if(i.push(a),r=r.parentElement,s++,o.push(...bt(i)),s>=e.seedMinLength){o.sort(Ae);for(let l of o)yield l;o=[];}}o.sort(Ae);for(let a of o)yield a;}function X(t){if(/^[a-z\-]{3,}$/i.test(t)){let e=t.split(/-|[A-Z]/);for(let n of e)if(n.length<=2||/[^aeiou]{4,}/i.test(n))return false;return true}return false}function Zt(t,e){let n=[],i=t.getAttribute("id");i&&e.idName(i)&&n.push({name:"#"+CSS.escape(i),penalty:0});for(let s=0;s<t.classList.length;s++){let a=t.classList[s];e.className(a)&&n.push({name:"."+CSS.escape(a),penalty:1});}for(let s=0;s<t.attributes.length;s++){let a=t.attributes[s];e.attr(a.name,a.value)&&n.push({name:`[${CSS.escape(a.name)}="${CSS.escape(a.value)}"]`,penalty:2});}let o=t.tagName.toLowerCase();if(e.tagName(o)){n.push({name:o,penalty:5});let s=Le(t,o);s!==void 0&&n.push({name:mt(o,s),penalty:10});}let r=Le(t);return r!==void 0&&n.push({name:en(o,r),penalty:50}),n}function K(t){let e=t[0],n=e.name;for(let i=1;i<t.length;i++){let o=t[i].level||0;e.level===o-1?n=`${t[i].name} > ${n}`:n=`${t[i].name} ${n}`,e=t[i];}return n}function ht(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ae(t,e){return ht(t)-ht(e)}function Le(t,e){let n=t.parentNode;if(!n)return;let i=n.firstChild;if(!i)return;let o=0;for(;i&&(i.nodeType===Node.ELEMENT_NODE&&(e===void 0||i.tagName.toLowerCase()===e)&&o++,i!==t);)i=i.nextSibling;return o}function Qt(t,e){let n=0,i=t,o=[];for(;i&&i!==e;){let r=i.tagName.toLowerCase(),s=Le(i,r);if(s===void 0)return;o.push({name:mt(r,s),penalty:NaN,level:n}),i=i.parentElement,n++;}if(Re(o,e))return o}function en(t,e){return t==="html"?"html":`${t}:nth-child(${e})`}function mt(t,e){return t==="html"?"html":`${t}:nth-of-type(${e})`}function*bt(t,e=[]){if(t.length>0)for(let n of t[0])yield*bt(t.slice(1,t.length),e.concat(n));else yield e;}function tn(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Re(t,e){let n=K(t);switch(e.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return true;default:return false}}function*gt(t,e,n,i,o){if(t.length>2&&t.length>n.optimizedMinLength)for(let r=1;r<t.length-1;r++){if(new Date().getTime()-o.getTime()>n.timeoutMs)return;let a=[...t];a.splice(r,1),Re(a,i)&&i.querySelector(K(a))===e&&(yield a,yield*gt(a,e,n,i,o));}}var nn=["role","aria-label","type","name","href","src","data-testid","data-id"];function on(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return (e>>>0).toString(36)}function Me(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let s of i.children){if(s===t)break;s.tagName===t.tagName&&n++;}let o=[];for(let s of nn){let a=t.getAttribute(s);a&&o.push(`${s}=${a}`);}let r=o.length>0?on(o.join(",")):"0";return `${e}:${n}:${r}`}function yt(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,o,r]=n,s=Number(i),a=Number(o);if(Number.isNaN(s)||Number.isNaN(a))return 0;let l=Me(t),[p,d,u]=l.split(":"),c=0,b=Math.abs(Number(p)-s);b===0?c+=.2:b<=2?c+=.1:b<=5&&(c+=.03);let w=Math.abs(Number(d)-a);return w===0?c+=.4:w===1?c+=.2:w<=3&&(c+=.08),u===r&&(c+=.4),c}function B(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],o=3;for(;i&&o>0;){let r=i.textContent?.trim();if(r)return e==="before"?r.slice(-32):r.slice(0,32);i=i[n],o--;}return ""}function oe(t){let e=t.previousElementSibling?.textContent?.trim().slice(0,40)??"",n=t.nextElementSibling?.textContent?.trim().slice(0,40)??"";return [e,n].filter(Boolean).join(" | ")}function vt(t){if(t.id){let i=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return `//${t.localName}[@id=${i}]`}let e=[],n=t;for(;n&&n!==document.body&&e.length<6;){let i=n.localName,o=n.parentElement;if(n.id){let s=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${i}[@id=${s}]`),"/"+e.join("")}let r=1;if(o)for(let s of o.children){if(s===n)break;s.localName===i&&r++;}e.unshift(`/${i}[${r}]`),n=o;}return "/html/body"+e.join("")}var q="data-feedback-anchor";function Pe(t){let e=ft(t,{className:u=>!/^(css|sc|emotion|styled)-/.test(u)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(u),attr:u=>["data-testid","data-id","role","aria-label"].includes(u),idName:u=>!u.startsWith("radix-")&&!/^:r[0-9]+:$/.test(u),seedMinLength:3,optimizedMinLength:2}),n=vt(t),o=(t.textContent?.trim()??"").slice(0,120),r=B(t,"before"),s=B(t,"after"),a=Me(t),l=oe(t),d=t.closest(`[${q}]`)?.getAttribute(q)??null;return {cssSelector:e,xpath:n,textSnippet:o,textPrefix:r,textSuffix:s,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:d}}function xt(t,e){let n=t.getBoundingClientRect();return n.left<=e.x&&n.top<=e.y&&n.right>=e.x+e.width&&n.bottom>=e.y+e.height}function wt(t,e=document.documentElement){let n=t.x+t.width/2,i=t.y+t.height/2,o=document.elementFromPoint(n,i);if(!o||o===e)return document.body;let r=o;for(;r&&r!==document.body;){if(r.hasAttribute(q)&&xt(r,t))return r;r=r.parentElement;}for(r=o;r&&r!==document.body;){if(xt(r,t))return r;r=r.parentElement;}return document.body}function Et(t,e){return e.width<=0||e.height<=0?{xPct:0,yPct:0,wPct:1,hPct:1}:{xPct:(t.x-e.x)/e.width,yPct:(t.y-e.y)/e.height,wPct:t.width/e.width,hPct:t.height/e.height}}var sn={question:"type.question",change:"type.change",bug:"type.bug",other:"type.other"};function rn(){let t=navigator.userAgentData;return t?t.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent)}var se=class{constructor(e,n$1){this.colors=e;this.t=n$1;this.root=b("div",{style:`
1
+ import {L,M,w,K,_,Z as Z$1,R,P,ca,T,B,b,x,A,N,c,e,J as J$1,u,v,h,g,a,f,i,D,F,E,C,l,m,n,o,G as G$1}from'./chunk-BC2J5J47.js';var Vt=new Set(["role","name","aria-label","rel","href"]);function Jt(t,e){let n=Vt.has(t);n||=t.startsWith("data-")&&q(t);let i=q(e)&&e.length<100;return i||=e.startsWith("#")&&q(e.slice(1)),n&&i}function Zt(t){return q(t)}function Qt(t){return q(t)}function en(t){return true}function yt(t,e){if(t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return "html";let n={root:document.body,idName:Zt,className:Qt,tagName:en,attr:Jt,timeoutMs:1e3,seedMinLength:3,optimizedMinLength:2,maxNumberOfPathChecks:1/0},i=new Date,o={...n,...e},r=rn(o.root,n),s,a=0;for(let c of tn(t,o,r)){if(new Date().getTime()-i.getTime()>o.timeoutMs||a>=o.maxNumberOfPathChecks){let u=on(t,r);if(!u)throw new Error(`Timeout: Can't find a unique selector after ${o.timeoutMs}ms`);return W(u)}if(a++,Fe(c,r)){s=c;break}}if(!s)throw new Error("Selector was not found.");let l=[...wt(s,t,o,r,i)];return l.sort(Me),l.length>0?W(l[0]):W(s)}function*tn(t,e,n){let i=[],o=[],r=t,s=0;for(;r&&r!==n;){let a=nn(r,e);for(let l of a)l.level=s;if(i.push(a),r=r.parentElement,s++,o.push(...xt(i)),s>=e.seedMinLength){o.sort(Me);for(let l of o)yield l;o=[];}}o.sort(Me);for(let a of o)yield a;}function q(t){if(/^[a-z\-]{3,}$/i.test(t)){let e=t.split(/-|[A-Z]/);for(let n of e)if(n.length<=2||/[^aeiou]{4,}/i.test(n))return false;return true}return false}function nn(t,e){let n=[],i=t.getAttribute("id");i&&e.idName(i)&&n.push({name:"#"+CSS.escape(i),penalty:0});for(let s=0;s<t.classList.length;s++){let a=t.classList[s];e.className(a)&&n.push({name:"."+CSS.escape(a),penalty:1});}for(let s=0;s<t.attributes.length;s++){let a=t.attributes[s];e.attr(a.name,a.value)&&n.push({name:`[${CSS.escape(a.name)}="${CSS.escape(a.value)}"]`,penalty:2});}let o=t.tagName.toLowerCase();if(e.tagName(o)){n.push({name:o,penalty:5});let s=Pe(t,o);s!==void 0&&n.push({name:vt(o,s),penalty:10});}let r=Pe(t);return r!==void 0&&n.push({name:sn(o,r),penalty:50}),n}function W(t){let e=t[0],n=e.name;for(let i=1;i<t.length;i++){let o=t[i].level||0;e.level===o-1?n=`${t[i].name} > ${n}`:n=`${t[i].name} ${n}`,e=t[i];}return n}function gt(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Me(t,e){return gt(t)-gt(e)}function Pe(t,e){let n=t.parentNode;if(!n)return;let i=n.firstChild;if(!i)return;let o=0;for(;i&&(i.nodeType===Node.ELEMENT_NODE&&(e===void 0||i.tagName.toLowerCase()===e)&&o++,i!==t);)i=i.nextSibling;return o}function on(t,e){let n=0,i=t,o=[];for(;i&&i!==e;){let r=i.tagName.toLowerCase(),s=Pe(i,r);if(s===void 0)return;o.push({name:vt(r,s),penalty:NaN,level:n}),i=i.parentElement,n++;}if(Fe(o,e))return o}function sn(t,e){return t==="html"?"html":`${t}:nth-child(${e})`}function vt(t,e){return t==="html"?"html":`${t}:nth-of-type(${e})`}function*xt(t,e=[]){if(t.length>0)for(let n of t[0])yield*xt(t.slice(1,t.length),e.concat(n));else yield e;}function rn(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Fe(t,e){let n=W(t);switch(e.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return true;default:return false}}function*wt(t,e,n,i,o){if(t.length>2&&t.length>n.optimizedMinLength)for(let r=1;r<t.length-1;r++){if(new Date().getTime()-o.getTime()>n.timeoutMs)return;let a=[...t];a.splice(r,1),Fe(a,i)&&i.querySelector(W(a))===e&&(yield a,yield*wt(a,e,n,i,o));}}var an=["role","aria-label","type","name","href","src","data-testid","data-id"];function ln(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return (e>>>0).toString(36)}function Ie(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let s of i.children){if(s===t)break;s.tagName===t.tagName&&n++;}let o=[];for(let s of an){let a=t.getAttribute(s);a&&o.push(`${s}=${a}`);}let r=o.length>0?ln(o.join(",")):"0";return `${e}:${n}:${r}`}function Et(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,o,r]=n,s=Number(i),a=Number(o);if(Number.isNaN(s)||Number.isNaN(a))return 0;let l=Ie(t),[c,d,u]=l.split(":"),p=0,f=Math.abs(Number(c)-s);f===0?p+=.2:f<=2?p+=.1:f<=5&&(p+=.03);let y=Math.abs(Number(d)-a);return y===0?p+=.4:y===1?p+=.2:y<=3&&(p+=.08),u===r&&(p+=.4),p}function z(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],o=3;for(;i&&o>0;){let r=i.textContent?.trim();if(r)return e==="before"?r.slice(-32):r.slice(0,32);i=i[n],o--;}return ""}function re(t){let e=t.previousElementSibling?.textContent?.trim().slice(0,40)??"",n=t.nextElementSibling?.textContent?.trim().slice(0,40)??"";return [e,n].filter(Boolean).join(" | ")}function kt(t){if(t.id){let i=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return `//${t.localName}[@id=${i}]`}let e=[],n=t;for(;n&&n!==document.body&&e.length<6;){let i=n.localName,o=n.parentElement;if(n.id){let s=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${i}[@id=${s}]`),"/"+e.join("")}let r=1;if(o)for(let s of o.children){if(s===n)break;s.localName===i&&r++;}e.unshift(`/${i}[${r}]`),n=o;}return "/html/body"+e.join("")}var U="data-feedback-anchor";function Ne(t){let e=yt(t,{className:u=>!/^(css|sc|emotion|styled)-/.test(u)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(u),attr:u=>["data-testid","data-id","role","aria-label"].includes(u),idName:u=>!u.startsWith("radix-")&&!/^:r[0-9]+:$/.test(u),seedMinLength:3,optimizedMinLength:2}),n=kt(t),o=(t.textContent?.trim()??"").slice(0,120),r=z(t,"before"),s=z(t,"after"),a=Ie(t),l=re(t),d=t.closest(`[${U}]`)?.getAttribute(U)??null;return {cssSelector:e,xpath:n,textSnippet:o,textPrefix:r,textSuffix:s,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:d}}function St(t,e){let n=t.getBoundingClientRect();return n.left<=e.x&&n.top<=e.y&&n.right>=e.x+e.width&&n.bottom>=e.y+e.height}function Tt(t,e=document.documentElement){let n=t.x+t.width/2,i=t.y+t.height/2,o=document.elementFromPoint(n,i);if(!o||o===e)return document.body;let r=o;for(;r&&r!==document.body;){if(r.hasAttribute(U)&&St(r,t))return r;r=r.parentElement;}for(r=o;r&&r!==document.body;){if(St(r,t))return r;r=r.parentElement;}return document.body}function Ct(t,e){return e.width<=0||e.height<=0?{xPct:0,yPct:0,wPct:1,hPct:1}:{xPct:(t.x-e.x)/e.width,yPct:(t.y-e.y)/e.height,wPct:t.width/e.width,hPct:t.height/e.height}}var cn={question:"type.question",change:"type.change",bug:"type.bug",other:"type.other"};function pn(){let t=navigator.userAgentData;return t?t.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent)}var ae=class{constructor(e,n$1){this.colors=e;this.t=n$1;this.root=b("div",{style:`
2
2
  position:fixed;
3
3
  z-index:${2147483647};
4
4
  width:300px;
@@ -24,7 +24,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
24
24
  font-size:13px;font-weight:500;color:${this.colors.textTertiary};
25
25
  transition:all 0.2s ease;
26
26
  padding:0 12px;
27
- `;let a$1=a(r.icon);a$1.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),s.appendChild(a$1),s.appendChild(document.createElement("span")),s.dataset.type=r.type,s.setAttribute("aria-pressed","false"),s.addEventListener("click",()=>{this.submittingState||this.selectType(r.type,this.typeRow);}),s.addEventListener("mouseenter",()=>{if(!this.submittingState&&s.dataset.type!==this.selectedType){let l=y(s.dataset.type??"",this.colors);s.style.background=l,s.style.borderColor=x(s.dataset.type??"",this.colors)+"40";}}),s.addEventListener("mouseleave",()=>{this.submittingState||s.dataset.type!==this.selectedType&&(s.style.background=this.colors.glassBg,s.style.borderColor=this.colors.border);}),this.typeRow.appendChild(s);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
27
+ `;let a$1=a(r.icon);a$1.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),s.appendChild(a$1),s.appendChild(document.createElement("span")),s.dataset.type=r.type,s.setAttribute("aria-pressed","false"),s.addEventListener("click",()=>{this.submittingState||this.selectType(r.type,this.typeRow);}),s.addEventListener("mouseenter",()=>{if(!this.submittingState&&s.dataset.type!==this.selectedType){let l=A(s.dataset.type??"",this.colors);s.style.background=l,s.style.borderColor=x(s.dataset.type??"",this.colors)+"40";}}),s.addEventListener("mouseleave",()=>{this.submittingState||s.dataset.type!==this.selectedType&&(s.style.background=this.colors.glassBg,s.style.borderColor=this.colors.border);}),this.typeRow.appendChild(s);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
28
28
  width:100%;min-height:72px;max-height:152px;
29
29
  padding:10px 12px;border-radius:12px;
30
30
  border:1px solid ${this.colors.border};
@@ -54,13 +54,13 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
54
54
  transition:all 0.2s ease;
55
55
  box-shadow:0 2px 8px ${this.colors.accentGlow};
56
56
  display:inline-flex;align-items:center;justify-content:center;min-width:64px;
57
- `,this.submitLabel=document.createElement("span"),this.submitBtn.appendChild(this.submitLabel),this.submitBtn.addEventListener("click",()=>this.submit()),o$1.appendChild(this.cancelBtn),o$1.appendChild(this.submitBtn),this.root.appendChild(this.typeRow),this.root.appendChild(this.textarea),this.root.appendChild(this.hint),this.root.appendChild(o$1),document.body.appendChild(this.root),this.applyLabels();}colors;t;root;selectedType=null;textarea;submitBtn;cancelBtn;typeRow;submitLabel;hint;resolve=null;previouslyFocused=null;onKeydownTrap=null;onSubmit=null;submittingState=false;spinnerAnimation=null;refreshLabels(){this.applyLabels();}applyLabels(){this.root.setAttribute("aria-label",this.t("popup.ariaLabel"));let e=this.root.querySelectorAll("button[data-type]");for(let n of e){let i=n.dataset.type;if(!i)continue;let o=sn[i];if(!o)continue;let r=n.querySelector("span");r&&c(r,this.t(o));}this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria")),c(this.hint,rn()?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),c(this.cancelBtn,this.t("popup.cancel")),c(this.submitLabel,this.t("popup.submit"));}show(e,n){return new Promise(i=>{this.resolve=i,this.onSubmit=n??null,this.selectedType=null,this.textarea.value="",this.submittingState=false,this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let o=220,r=300,s=e.bottom+8,a=e.left;if(s+o>window.innerHeight){let p=e.top-o-8;p>=8?s=p:s=window.innerHeight-o-8;}a+r>window.innerWidth&&(a=e.right-r),a=Math.max(8,a),s=Math.max(8,s),this.root.style.top=`${s}px`,this.root.style.left=`${a}px`,this.root.style.display="block",this.onKeydownTrap=p=>{if(p.key==="Tab"){let d=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(d.length===0)return;let u=d[0],c=d[d.length-1];if(!u||!c)return;p.shiftKey?(document.activeElement===u||!this.root.contains(document.activeElement))&&(p.preventDefault(),c.focus()):(document.activeElement===c||!this.root.contains(document.activeElement))&&(p.preventDefault(),u.focus());}},this.root.addEventListener("keydown",this.onKeydownTrap);let l=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=l?"none":"",requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus();});})}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let o of i){let r=o.dataset.type===e,s=x(o.dataset.type??"",this.colors),a=y(o.dataset.type??"",this.colors);o.style.background=r?a:this.colors.glassBg,o.style.borderColor=r?s+"60":this.colors.border,o.style.color=r?s:this.colors.textTertiary,o.style.fontWeight=r?"600":"500",o.setAttribute("aria-pressed",String(r));}this.updateSubmitState();}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let n of e)n.setAttribute("aria-pressed","false"),n.disabled=false,n.style.background=this.colors.glassBg,n.style.borderColor=this.colors.border,n.style.color=this.colors.textTertiary,n.style.fontWeight="500",n.style.cursor="pointer";}updateSubmitState(){if(this.submittingState)return;let e=this.selectedType!==null&&this.textarea.value.trim().length>0;this.submitBtn.disabled=!e,this.submitBtn.style.opacity=e?"1":"0.35",this.submitBtn.style.pointerEvents=e?"auto":"none";}submit(){if(this.submittingState||!this.selectedType||!this.textarea.value.trim())return;let e={type:this.selectedType,message:this.textarea.value.trim()};if(!this.onSubmit){this.resolve?.(e),this.resolve=null,this.hideElement();return}this.enterSubmittingState();let n=this.onSubmit;n(e).then(()=>{this.resolve?.(e),this.resolve=null,this.hideElement();}).catch(()=>{this.exitSubmittingState();});}cancel(){this.submittingState||(this.resolve?.(null),this.resolve=null,this.hideElement());}enterSubmittingState(){this.submittingState=true,this.submitLabel.style.display="none",this.submitBtn.disabled=true,this.submitBtn.style.cursor="wait",this.submitBtn.style.opacity="0.85",this.submitBtn.setAttribute("aria-busy","true"),this.submitBtn.appendChild(this.buildSpinner()),this.cancelBtn.disabled=true,this.cancelBtn.style.opacity="0.5",this.cancelBtn.style.cursor="not-allowed",this.cancelBtn.style.pointerEvents="none",this.textarea.disabled=true,this.textarea.style.opacity="0.6";let e=this.typeRow.querySelectorAll("button");for(let n of e)n.disabled=true,n.style.cursor="not-allowed",n.style.opacity="0.6";}exitSubmittingState(){this.submittingState=false,this.spinnerAnimation?.cancel(),this.spinnerAnimation=null,this.submitBtn.querySelector('[data-role="sp-popup-spinner"]')?.remove(),this.submitLabel.style.display="",this.submitBtn.removeAttribute("aria-busy"),this.submitBtn.style.cursor="pointer",this.cancelBtn.disabled=false,this.cancelBtn.style.opacity="1",this.cancelBtn.style.cursor="pointer",this.cancelBtn.style.pointerEvents="auto",this.textarea.disabled=false,this.textarea.style.opacity="1";let n=this.typeRow.querySelectorAll("button");for(let i of n)i.disabled=false,i.style.cursor="pointer",i.style.opacity="1";this.updateSubmitState();}buildSpinner(){let e=document.createElement("div");return e.dataset.role="sp-popup-spinner",e.style.cssText=`
57
+ `,this.submitLabel=document.createElement("span"),this.submitBtn.appendChild(this.submitLabel),this.submitBtn.addEventListener("click",()=>this.submit()),o$1.appendChild(this.cancelBtn),o$1.appendChild(this.submitBtn),this.root.appendChild(this.typeRow),this.root.appendChild(this.textarea),this.root.appendChild(this.hint),this.root.appendChild(o$1),document.body.appendChild(this.root),this.applyLabels();}colors;t;root;selectedType=null;textarea;submitBtn;cancelBtn;typeRow;submitLabel;hint;resolve=null;previouslyFocused=null;onKeydownTrap=null;onSubmit=null;submittingState=false;spinnerAnimation=null;refreshLabels(){this.applyLabels();}applyLabels(){this.root.setAttribute("aria-label",this.t("popup.ariaLabel"));let e=this.root.querySelectorAll("button[data-type]");for(let n of e){let i=n.dataset.type;if(!i)continue;let o=cn[i];if(!o)continue;let r=n.querySelector("span");r&&c(r,this.t(o));}this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria")),c(this.hint,pn()?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),c(this.cancelBtn,this.t("popup.cancel")),c(this.submitLabel,this.t("popup.submit"));}show(e,n){return new Promise(i=>{this.resolve=i,this.onSubmit=n??null,this.selectedType=null,this.textarea.value="",this.submittingState=false,this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let o=220,r=300,s=e.bottom+8,a=e.left;if(s+o>window.innerHeight){let c=e.top-o-8;c>=8?s=c:s=window.innerHeight-o-8;}a+r>window.innerWidth&&(a=e.right-r),a=Math.max(8,a),s=Math.max(8,s),this.root.style.top=`${s}px`,this.root.style.left=`${a}px`,this.root.style.display="block",this.onKeydownTrap=c=>{if(c.key==="Tab"){let d=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(d.length===0)return;let u=d[0],p=d[d.length-1];if(!u||!p)return;c.shiftKey?(document.activeElement===u||!this.root.contains(document.activeElement))&&(c.preventDefault(),p.focus()):(document.activeElement===p||!this.root.contains(document.activeElement))&&(c.preventDefault(),u.focus());}},this.root.addEventListener("keydown",this.onKeydownTrap);let l=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=l?"none":"",requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus();});})}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let o of i){let r=o.dataset.type===e,s=x(o.dataset.type??"",this.colors),a=A(o.dataset.type??"",this.colors);o.style.background=r?a:this.colors.glassBg,o.style.borderColor=r?s+"60":this.colors.border,o.style.color=r?s:this.colors.textTertiary,o.style.fontWeight=r?"600":"500",o.setAttribute("aria-pressed",String(r));}this.updateSubmitState();}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let n of e)n.setAttribute("aria-pressed","false"),n.disabled=false,n.style.background=this.colors.glassBg,n.style.borderColor=this.colors.border,n.style.color=this.colors.textTertiary,n.style.fontWeight="500",n.style.cursor="pointer";}updateSubmitState(){if(this.submittingState)return;let e=this.selectedType!==null&&this.textarea.value.trim().length>0;this.submitBtn.disabled=!e,this.submitBtn.style.opacity=e?"1":"0.35",this.submitBtn.style.pointerEvents=e?"auto":"none";}submit(){if(this.submittingState||!this.selectedType||!this.textarea.value.trim())return;let e={type:this.selectedType,message:this.textarea.value.trim()};if(!this.onSubmit){this.resolve?.(e),this.resolve=null,this.hideElement();return}this.enterSubmittingState();let n=this.onSubmit;n(e).then(()=>{this.resolve?.(e),this.resolve=null,this.hideElement();}).catch(()=>{this.exitSubmittingState();});}cancel(){this.submittingState||(this.resolve?.(null),this.resolve=null,this.hideElement());}enterSubmittingState(){this.submittingState=true,this.submitLabel.style.display="none",this.submitBtn.disabled=true,this.submitBtn.style.cursor="wait",this.submitBtn.style.opacity="0.85",this.submitBtn.setAttribute("aria-busy","true"),this.submitBtn.appendChild(this.buildSpinner()),this.cancelBtn.disabled=true,this.cancelBtn.style.opacity="0.5",this.cancelBtn.style.cursor="not-allowed",this.cancelBtn.style.pointerEvents="none",this.textarea.disabled=true,this.textarea.style.opacity="0.6";let e=this.typeRow.querySelectorAll("button");for(let n of e)n.disabled=true,n.style.cursor="not-allowed",n.style.opacity="0.6";}exitSubmittingState(){this.submittingState=false,this.spinnerAnimation?.cancel(),this.spinnerAnimation=null,this.submitBtn.querySelector('[data-role="sp-popup-spinner"]')?.remove(),this.submitLabel.style.display="",this.submitBtn.removeAttribute("aria-busy"),this.submitBtn.style.cursor="pointer",this.cancelBtn.disabled=false,this.cancelBtn.style.opacity="1",this.cancelBtn.style.cursor="pointer",this.cancelBtn.style.pointerEvents="auto",this.textarea.disabled=false,this.textarea.style.opacity="1";let n=this.typeRow.querySelectorAll("button");for(let i of n)i.disabled=false,i.style.cursor="pointer",i.style.opacity="1";this.updateSubmitState();}buildSpinner(){let e=document.createElement("div");return e.dataset.role="sp-popup-spinner",e.style.cssText=`
58
58
  width:14px;height:14px;
59
59
  border:2px solid rgba(255,255,255,0.35);
60
60
  border-top-color:#fff;
61
61
  border-radius:50%;
62
62
  box-sizing:border-box;
63
- `,!(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)&&typeof e.animate=="function"&&(this.spinnerAnimation=e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:600,iterations:1/0,easing:"linear"})),e}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.submittingState&&this.exitSubmittingState(),this.onSubmit=null,this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none";},250);}destroy(){this.submittingState&&this.exitSubmittingState(),this.resolve?.(null),this.resolve=null,this.onSubmit=null,this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.remove();}};var Y,kt=false;async function an(){if(Y!==void 0)return Y;try{let t=await import('html2canvas');return Y=t.default??t,Y}catch(t){return Y=null,kt||(kt=true,console.warn("[siteping] html2canvas import failed unexpectedly. Capture is disabled for this session \u2014 feedbacks are still submitted, just without screenshots. Underlying error:",t)),null}}async function St(t,e){let n=await an();if(!n)return null;let i=.85,o=1200;try{let r=await n(document.body,{x:window.scrollX+t.x,y:window.scrollY+t.y,width:t.width,height:t.height,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,ignoreElements:u=>u.tagName==="SITEPING-WIDGET"||u.closest?.("siteping-widget")!==null||u.getAttribute?.("data-siteping-ignore")==="true"});if(r.width<=o)return r.toDataURL("image/jpeg",i);let s=o/r.width,a=o,l=Math.round(r.height*s),p=document.createElement("canvas");p.width=a,p.height=l;let d=p.getContext("2d");return d?(d.drawImage(r,0,0,a,l),p.toDataURL("image/jpeg",i)):null}catch(r){return console.warn("[siteping] Screenshot capture failed:",r),null}}var re=class{constructor(e,n,i,o=false){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.popup=new se(e,i),this.bus.on("annotation:start",()=>this.activate());}colors;bus;t;enableScreenshot;overlay=null;toolbar=null;drawingRect=null;startX=0;startY=0;isDrawing=false;isActive=false;popup;savedOverflow="";preActiveFocusElement=null;rafId=null;pendingMoveEvent=null;rejectPendingSubmission=null;refreshLabels(){this.popup.refreshLabels();}get submissionInFlight(){return this.rejectPendingSubmission!==null}async maybeCapture(e){return this.enableScreenshot?St(e):null}activate(){if(this.isActive)return;this.isActive=true,this.preActiveFocusElement=document.activeElement,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=b("div",{style:`
63
+ `,!(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)&&typeof e.animate=="function"&&(this.spinnerAnimation=e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:600,iterations:1/0,easing:"linear"})),e}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.submittingState&&this.exitSubmittingState(),this.onSubmit=null,this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none";},250);}destroy(){this.submittingState&&this.exitSubmittingState(),this.resolve?.(null),this.resolve=null,this.onSubmit=null,this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.remove();}};var G,At=false;async function dn(){if(G!==void 0)return G;try{let t=await import('html2canvas');return G=t.default??t,G}catch(t){return G=null,At||(At=true,console.warn("[siteping] html2canvas import failed unexpectedly. Capture is disabled for this session \u2014 feedbacks are still submitted, just without screenshots. Underlying error:",t)),null}}function He(t,e,n){return Math.min(n,Math.max(t,e))}function le(t){return He(0,Math.round(t*1e4)/1e4,1)}async function Lt(t,e){let n=await dn();if(!n)return null;let i=.85,o=1200,r=He(48,t.width*.6,280),s=He(48,t.height*.6,220),a=window.scrollX+t.x,l=window.scrollY+t.y,c=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),d=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),u=Math.max(0,a-r),p=Math.max(0,l-s),f=Math.min(c,a+t.width+r)-u,y=Math.min(d,l+t.height+s)-p;if(f<=0||y<=0)return null;let A={xPct:le((a-u)/f),yPct:le((l-p)/y),wPct:le(t.width/f),hPct:le(t.height/y)};try{let k=await n(document.body,{x:u,y:p,width:f,height:y,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,ignoreElements:g=>g.tagName==="SITEPING-WIDGET"||g.closest?.("siteping-widget")!==null||g.getAttribute?.("data-siteping-ignore")==="true"});if(k.width<=o)return {dataUrl:k.toDataURL("image/jpeg",i),region:A};let F=o/k.width,T=o,X=Math.round(k.height*F),w=document.createElement("canvas");w.width=T,w.height=X;let S=w.getContext("2d");return S?(S.drawImage(k,0,0,T,X),{dataUrl:w.toDataURL("image/jpeg",i),region:A}):null}catch(k){return console.warn("[siteping] Screenshot capture failed:",k),null}}var ce=class{constructor(e,n,i,o=false){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.popup=new ae(e,i),this.bus.on("annotation:start",()=>this.activate());}colors;bus;t;enableScreenshot;overlay=null;toolbar=null;drawingRect=null;startX=0;startY=0;isDrawing=false;isActive=false;popup;savedOverflow="";preActiveFocusElement=null;rafId=null;pendingMoveEvent=null;rejectPendingSubmission=null;refreshLabels(){this.popup.refreshLabels();}get submissionInFlight(){return this.rejectPendingSubmission!==null}async maybeCapture(e){return this.enableScreenshot?Lt(e):null}activate(){if(this.isActive)return;this.isActive=true,this.preActiveFocusElement=document.activeElement,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=b("div",{style:`
64
64
  position:fixed;inset:0;
65
65
  z-index:${2147483646};
66
66
  background:rgba(15, 23, 42, 0.04);
@@ -90,7 +90,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
90
90
  color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
91
91
  font-size:13px;font-weight:500;cursor:pointer;
92
92
  transition:all 0.2s ease;
93
- `,c(o,this.t("annotator.cancel")),o.addEventListener("click",()=>this.deactivate()),o.addEventListener("mouseenter",()=>{o.style.borderColor=this.colors.typeBug,o.style.color=this.colors.typeBug,o.style.background=this.colors.typeBugBg;}),o.addEventListener("mouseleave",()=>{o.style.borderColor=this.colors.border,o.style.color=this.colors.textTertiary,o.style.background=this.colors.glassBg;}),this.toolbar.appendChild(e),this.toolbar.appendChild(i),this.toolbar.appendChild(o),this.overlay.addEventListener("mousedown",this.onMouseDown),this.overlay.addEventListener("mousemove",this.onMouseMove),this.overlay.addEventListener("mouseup",this.onMouseUp),this.overlay.addEventListener("touchstart",this.onTouchStart,{passive:false}),this.overlay.addEventListener("touchmove",this.onTouchMove,{passive:false}),this.overlay.addEventListener("touchend",this.onTouchEnd),this.overlay.addEventListener("keydown",this.onOverlayKeyDown),this.overlay.setAttribute("tabindex","0"),document.addEventListener("keydown",this.onKeyDown),document.body.appendChild(this.overlay),document.body.appendChild(this.toolbar),this.overlay.focus({preventScroll:true});}deactivate(){if(!this.isActive)return;this.isActive=false,this.isDrawing=false;let e=this.preActiveFocusElement;this.preActiveFocusElement=null,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingMoveEvent=null,document.body.style.overflow=this.savedOverflow,document.removeEventListener("keydown",this.onKeyDown),this.overlay?.remove(),this.toolbar?.remove(),this.drawingRect?.remove(),this.overlay=null,this.toolbar=null,this.drawingRect=null,e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:true}),this.bus.emit("annotation:end");}onKeyDown=e=>{e.key==="Escape"&&this.deactivate();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"||(e.preventDefault(),this.submissionInFlight))return;let n=this.preActiveFocusElement;if(!n||!(n instanceof HTMLElement))return;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let o=new DOMRect(i.x,i.y,i.width,i.height),s={anchor:Pe(n),rect:{xPct:0,yPct:0,wPct:1,hPct:1},scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},a={};await this.popup.show(o,p=>this.runSubmission(s,p,o,a))&&this.deactivate();};onMouseDown=e=>{this.startDrawing(e.clientX,e.clientY);};onTouchStart=e=>{e.preventDefault();let n=e.touches[0];n&&this.startDrawing(n.clientX,n.clientY);};startDrawing(e,n){this.submissionInFlight||(this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
93
+ `,c(o,this.t("annotator.cancel")),o.addEventListener("click",()=>this.deactivate()),o.addEventListener("mouseenter",()=>{o.style.borderColor=this.colors.typeBug,o.style.color=this.colors.typeBug,o.style.background=this.colors.typeBugBg;}),o.addEventListener("mouseleave",()=>{o.style.borderColor=this.colors.border,o.style.color=this.colors.textTertiary,o.style.background=this.colors.glassBg;}),this.toolbar.appendChild(e),this.toolbar.appendChild(i),this.toolbar.appendChild(o),this.overlay.addEventListener("mousedown",this.onMouseDown),this.overlay.addEventListener("mousemove",this.onMouseMove),this.overlay.addEventListener("mouseup",this.onMouseUp),this.overlay.addEventListener("touchstart",this.onTouchStart,{passive:false}),this.overlay.addEventListener("touchmove",this.onTouchMove,{passive:false}),this.overlay.addEventListener("touchend",this.onTouchEnd),this.overlay.addEventListener("keydown",this.onOverlayKeyDown),this.overlay.setAttribute("tabindex","0"),document.addEventListener("keydown",this.onKeyDown),document.body.appendChild(this.overlay),document.body.appendChild(this.toolbar),this.overlay.focus({preventScroll:true});}deactivate(){if(!this.isActive)return;this.isActive=false,this.isDrawing=false;let e=this.preActiveFocusElement;this.preActiveFocusElement=null,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingMoveEvent=null,document.body.style.overflow=this.savedOverflow,document.removeEventListener("keydown",this.onKeyDown),this.overlay?.remove(),this.toolbar?.remove(),this.drawingRect?.remove(),this.overlay=null,this.toolbar=null,this.drawingRect=null,e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:true}),this.bus.emit("annotation:end");}onKeyDown=e=>{e.key==="Escape"&&this.deactivate();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"||(e.preventDefault(),this.submissionInFlight))return;let n=this.preActiveFocusElement;if(!n||!(n instanceof HTMLElement))return;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let o=new DOMRect(i.x,i.y,i.width,i.height),s={anchor:Ne(n),rect:{xPct:0,yPct:0,wPct:1,hPct:1},scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},a={};await this.popup.show(o,c=>this.runSubmission(s,c,o,a))&&this.deactivate();};onMouseDown=e=>{this.startDrawing(e.clientX,e.clientY);};onTouchStart=e=>{e.preventDefault();let n=e.touches[0];n&&this.startDrawing(n.clientX,n.clientY);};startDrawing(e,n){this.submissionInFlight||(this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
94
94
  position:fixed;
95
95
  border:2px solid ${this.colors.accent};
96
96
  background:${this.colors.accent}12;
@@ -98,8 +98,8 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
98
98
  border-radius:8px;
99
99
  box-shadow:0 0 16px ${this.colors.accentGlow};
100
100
  transition:box-shadow 0.15s ease;
101
- `}),this.drawingRect.setAttribute("data-siteping-ignore","true"),this.overlay?.appendChild(this.drawingRect));}onMouseMove=e=>{this.scheduleRectUpdate(e);};onTouchMove=e=>{e.preventDefault(),e.touches[0]&&this.scheduleRectUpdate(e.touches[0]);};scheduleRectUpdate(e){!this.isDrawing||!this.drawingRect||(this.pendingMoveEvent=e,this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;let n=this.pendingMoveEvent;if(!n||!this.drawingRect)return;let i=Math.min(n.clientX,this.startX),o=Math.min(n.clientY,this.startY),r=Math.abs(n.clientX-this.startX),s=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${o}px`,this.drawingRect.style.width=`${r}px`,this.drawingRect.style.height=`${s}px`;})));}onTouchEnd=async e=>{let n=e.changedTouches[0];n&&await this.finishDrawing(n.clientX,n.clientY);};onMouseUp=async e=>{await this.finishDrawing(e.clientX,e.clientY);};finishDrawing=async(e,n)=>{if(!this.isDrawing||!this.drawingRect)return;this.isDrawing=false;let i=Math.min(e,this.startX),o=Math.min(n,this.startY),r=Math.abs(e-this.startX),s=Math.abs(n-this.startY);if(r<10||s<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(i,o,r,s),l=this.buildAnnotation(a),p={},d=await this.popup.show(a,u=>this.runSubmission(l,u,a,p));this.drawingRect?.remove(),this.drawingRect=null,d&&this.deactivate();};async runSubmission(e,n,i,o){o.value===void 0&&(o.value=await this.maybeCapture(i));let r=o.value;await new Promise((s,a)=>{let l=()=>{p(),d(),u(),this.rejectPendingSubmission=null;},p=this.bus.on("feedback:sent",()=>{l(),s();}),d=this.bus.on("feedback:error",c=>{l(),a(c);}),u=this.bus.on("submission:cancelled",()=>{l(),a(new Error("Feedback submission cancelled"));});this.rejectPendingSubmission=c=>{l(),a(c);},this.bus.emit("annotation:complete",{annotation:e,type:n.type,message:n.message,screenshotDataUrl:r});});}buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=wt(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Pe(n),o=n.getBoundingClientRect(),r=Et(e,o);return {anchor:i,rect:r,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.rejectPendingSubmission?.(new Error("Annotator destroyed during submission")),this.popup.destroy();}};async function W(t,e){let n=await t.text().catch(()=>"Unknown error"),i=n?`${t.status} ${n}`:`${t.status}`,o=`${e}: ${i}`;return t.status===401||t.status===403?new D(o):t.status>=400&&t.status<500?new C(o):new A(o,"SERVER",false)}function U(t,e){if(t instanceof B$1)return t;let n=t instanceof Error?t.message:String(t);return new B$1(`${e}: ${n}`)}var ln=3,pn=1e4,ae="siteping_retry_queue",cn=20;async function G(t,e,n=ln){for(let i=0;i<=n;i++){let o=new AbortController,r=setTimeout(()=>o.abort(),pn);try{let l=await fetch(t,{...e,signal:o.signal});if(clearTimeout(r),l.ok||l.status>=400&&l.status<500||i===n)return l}catch(l){if(clearTimeout(r),i===n)throw l}let s=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,s+a));}throw new Error("Max retries exceeded")}var dn="siteping_retry_queue";async function At(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(dn,()=>t()):t()}function Lt(){let t=localStorage.getItem(ae);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}function un(t,e){At(()=>{try{let n=Lt();n.length>=cn&&n.shift(),n.push({endpoint:t,payload:e}),localStorage.setItem(ae,JSON.stringify(n));}catch{}});}function Tt(t){return t.trim()}function Ct(t){return t.trim().toLowerCase()}async function Rt(t,e){await At(async()=>{try{let n=Lt();if(n.length===0)return;let i=[],o=[],r=0;for(let l of n){if(l.endpoint!==t){o.push(l);continue}!e||Tt(l.payload.authorName)===Tt(e.name)&&Ct(l.payload.authorEmail)===Ct(e.email)?i.push(l):r+=1;}if(i.length===0&&r===0)return;r>0;let s=[];for(let l of i)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l.payload)})).ok||s.push(l);}catch{s.push(l);}let a=o.concat(s);a.length>0?localStorage.setItem(ae,JSON.stringify(a)):localStorage.removeItem(ae);}catch{}});}async function Fe(t){return await t.json()}var le=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){try{let n;try{n=await G(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(i){throw U(i,"Failed to send feedback")}if(!n.ok)throw await W(n,"Failed to send feedback");return Fe(n)}catch(n){throw un(this.endpoint,e),n}}async getFeedbacks(e,n){let i=new URLSearchParams({projectName:e});n?.page&&i.set("page",String(n.page)),n?.limit&&i.set("limit",String(n.limit)),n?.type&&i.set("type",n.type),n?.status&&i.set("status",n.status),n?.search&&i.set("search",n.search),n?.url&&i.set("url",n.url),n?.urlPattern&&i.set("urlPattern",n.urlPattern);let o;try{o=await G(`${this.endpoint}?${i.toString()}`,{method:"GET",cache:"no-store"});}catch(r){throw U(r,"Failed to fetch feedbacks")}if(!o.ok)throw await W(o,"Failed to fetch feedbacks");return Fe(o)}async resolveFeedback(e,n){let i;try{i=await G(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(o){throw U(o,"Failed to update feedback")}if(!i.ok)throw await W(i,"Failed to update feedback");return Fe(i)}async deleteFeedback(e){let n;try{n=await G(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(i){throw U(i,"Failed to delete feedback")}if(!n.ok)throw await W(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await G(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(i){throw U(i,"Failed to delete all feedbacks")}if(!n.ok)throw await W(n,"Failed to delete all feedbacks")}};var hn=["log","info","warn","error"];function fn(t){if(t===null)return "null";if(t===void 0)return "undefined";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);if(t instanceof Error)return `${t.name}: ${t.message}${t.stack?`
102
- ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof i=="function")return "[Function]";if(typeof i=="symbol")return i.toString();if(typeof i=="object"&&i!==null){if(e.has(i))return "[Circular]";e.add(i);}return i})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function mn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=fn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var pe=class{maxEntries;entries=[];originals=new Map;disposed=false;constructor(e=50){if(this.maxEntries=Math.min(Math.max(Math.floor(e),0),1e3),!(typeof console>"u"))for(let n of hn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,r=function(...s){try{o.push(n,s);}catch{}i.apply(this??console,s);};try{Object.defineProperty(r,"name",{value:n});}catch{}console[n]=r;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:mn(n)}));}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed&&(this.disposed=true,!(typeof console>"u"))){for(let[e,n]of this.originals)try{console[e]=n;}catch{}this.originals.clear();}}};function Mt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Pt(t){if(typeof t=="string")return t;if(t instanceof URL)return t.href;if(typeof t=="object"&&t!==null&&"url"in t){let e=t.url;if(typeof e=="string")return e}try{return String(t)}catch{return "(unknown)"}}var ce=class{maxEntries;entries=[];originalFetch=null;originalXhrOpen=null;originalXhrSend=null;disposed=false;constructor(e=20){this.maxEntries=Math.min(Math.max(Math.floor(e),0),500),this.installFetch(),this.installXhr();}push(e){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push(e));}installFetch(){if(typeof globalThis.fetch!="function")return;let e=globalThis.fetch;this.originalFetch=e;let n=async(i,o)=>{let r=new Date,s=typeof performance<"u"?performance.now():Date.now(),a=Mt(Pt(i)),l=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let p=await e(i,o);if(!p.ok){let d=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:p.status,durationMs:Math.round(d-s),timestamp:r.toISOString()});}return p}catch(p){let d=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(d-s),timestamp:r.toISOString()}),p}};globalThis.fetch=n;}installXhr(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype,n=e.open,i=e.send;this.originalXhrOpen=n,this.originalXhrSend=i;let o=this,r=new WeakMap;e.open=function(s,a,...l){try{r.set(this,{method:s.toUpperCase(),url:Mt(Pt(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,s,a,...l)},e.send=function(s){let a=r.get(this);if(a){let l=()=>{try{let p=typeof performance<"u"?performance.now():Date.now(),d=this.status;(d===0||d>=400)&&o.push({url:a.url,method:a.method,status:d,durationMs:Math.round(p-a.t0),timestamp:a.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",l,{once:!0});}catch{try{this.addEventListener("loadend",l);}catch{}}}return i.call(this,s??null)};}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&typeof globalThis.fetch=="function")try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend);}catch{}}}};var V=class{listeners=new Map;on(e,n){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(n),()=>{i?.delete(n);}}off(e,n){this.listeners.get(e)?.delete(n);}emit(e,...n){let i=this.listeners.get(e);if(i)for(let o of i)try{o(...n);}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var bn=54,gn={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},de=class{constructor(e,n,i,o){this.bus=i;this.t=o;let r=n.position??"bottom-right",s=r==="bottom-right";this.items=[{id:"chat",icon:u},{id:"annotate",icon:v}],n.showAnnotationsToggle!==false&&this.items.push({id:"toggle-annotations",icon:g,iconAlt:h}),this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${r} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${r}`,this.radialContainer.setAttribute("role","menu");for(let p=0;p<this.items.length;p++){let d=this.items[p];if(!d)continue;let u=document.createElement("button");u.className="sp-radial-item",u.style.setProperty("--sp-i",String(p)),u.appendChild(a(d.icon)),u.setAttribute("role","menuitem"),u.dataset.itemId=d.id,u.addEventListener("click",b=>{b.stopPropagation(),this.handleItemClick(d.id);});let c=document.createElement("span");c.className="sp-radial-label",c.style.cssText=s?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",u.appendChild(c),this.radialContainer.appendChild(u);}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root),this.applyLabels();let a$1=e.host;this.onDocumentClick=p=>{this.isOpen&&!p.composedPath().includes(a$1)&&this.close();},document.addEventListener("click",this.onDocumentClick);let l=p=>{p.key==="Escape"&&this.isOpen&&(p.stopPropagation(),this.close());};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",p=>{let d=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(d.length===0||!this.isOpen)return;let u=e.activeElement??document.activeElement,c=d.indexOf(u);switch(p.key){case "ArrowUp":{p.preventDefault();let b=c<=0?d.length-1:c-1;d[b]?.focus();break}case "ArrowDown":{p.preventDefault();let b=c>=d.length-1?0:c+1;d[b]?.focus();break}case "Home":{p.preventDefault(),d[0]?.focus();break}case "End":{p.preventDefault(),d[d.length-1]?.focus();break}}});}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;refreshLabels(){this.applyLabels();}applyLabels(){this.fab.setAttribute("aria-label",this.t("fab.aria"));let e=this.radialContainer.querySelectorAll(".sp-radial-item");for(let n of e){let i=n.dataset.itemId;if(!i)continue;let o=gn[i];if(!o)continue;let r=this.t(o);n.setAttribute("aria-label",r);let s=n.querySelector(".sp-radial-label");s&&c(s,r);}}updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null;return}this.badgeEl||(this.badgeEl=document.createElement("span"),this.badgeEl.className="sp-fab-badge",this.badgeEl.setAttribute("role","status"),this.badgeEl.setAttribute("aria-live","polite"),this.fab.appendChild(this.badgeEl));let n=e>99?"99+":String(e);c(this.badgeEl,n),this.badgeEl.setAttribute("aria-label",this.t("fab.badge").replace("{count}",String(e)));}toggle(){this.isOpen?this.close():this.open();}open(){this.isOpen=true,this.setFabIcon(i),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+bn*(i+1));n.style.transform=`translate(0px, ${o}px) scale(1)`,n.classList.add("sp-radial-item--open");}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus();});}close(){this.isOpen=false,this.setFabIcon(f),this.fab.setAttribute("aria-expanded","false"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach(n=>{n.style.transform="translate(0, 0) scale(0.8)",n.classList.remove("sp-radial-item--open");}),this.fab.focus();}setFabIcon(e){let n=this.badgeEl;this.fab.replaceChildren(a(e)),n&&this.fab.appendChild(n);}handleItemClick(e){switch(this.close(),e){case "chat":this.bus.emit("panel:toggle",true);break;case "annotate":{let n=this.bus.on("annotation:end",()=>{n(),this.fab.focus();});this.bus.emit("annotation:start");break}case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let i=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]')?.querySelector("svg");if(i){let o=a(this.annotationsVisible?g:h);i.replaceWith(o);}break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var Ft="siteping_identity";function yn(t){if(!E(t,"name")||!E(t,"email"))return false;let e=t.name,n=t.email;return typeof e=="string"&&typeof n=="string"&&e.length>0&&n.length>0}function Ie(){try{let t=localStorage.getItem(Ft);if(!t)return null;let e=JSON.parse(t);return yn(e)?e:null}catch{return null}}function It(t){try{localStorage.setItem(Ft,JSON.stringify(t));}catch{}}function vn(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let s=t;t=e,e=s;}let n=t.length,i=e.length,o=new Array(n+1);for(let s=0;s<=n;s++)o[s]=s;let r=new Array(n+1);for(let s=1;s<=i;s++){r[0]=s;for(let l=1;l<=n;l++){let p=o[l-1]??0;r[l]=t[l-1]===e[s-1]?p:1+Math.min(p,o[l]??0,r[l-1]??0);}let a=o;o=r,r=a;}return o[n]??0}function z(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-vn(t,e)/n}function Ne(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let a=z(t,e);return a>=n?a:0}let o=0,r=t.length>500?t.slice(0,500):t,s=r.length-i;for(let a=0;a<=s;a++){let l=r.slice(a,a+i),p=z(l,e);if(p>o&&(o=p),o>=.95)break}return o>=n?o:0}var xn=300,wn=.3;function ue(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Ne(n,e.textSnippet,.5)>wn}function En(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${q}="${e}"]`);if(n&&ue(n,t))return {element:n,confidence:1,strategy:"anchorKey"}}catch{}}if(t.elementId){let e=document.getElementById(t.elementId);if(e&&e.tagName===t.elementTag&&ue(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&ue(e,t))return {element:e,confidence:.95,strategy:"css"}}catch{}try{let n=document.evaluate(t.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(n instanceof Element&&n.tagName===t.elementTag&&ue(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return kn(t)}function kn(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,r=Math.min(n.length,xn);for(let s=0;s<r;s++){let a=n[s];if(!a)continue;let l=Sn(a,t);if(l>o&&(o=l,i=a,o>=.85))break}return !i||o<.4?null:{element:i,confidence:Math.min(o,.85),strategy:"scan"}}function Sn(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=Ne(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=yt(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let r=0,s=0;if(e.textPrefix){let a=B(t,"before");r+=a?z(a,e.textPrefix):0,s++;}if(e.textSuffix){let a=B(t,"after");r+=a?z(a,e.textSuffix):0,s++;}s>0&&(n+=r/s*20);}if(e.neighborText){i+=20;let r=oe(t);n+=r?z(r,e.neighborText)*20:0;}return i>0?n/i:0}function he(t,e){let n=En(t);if(!n)return null;let i=n.element.getBoundingClientRect(),o=new DOMRect(i.x+e.xPct*i.width,i.y+e.yPct*i.height,e.wPct*i.width,e.hPct*i.height);return {element:n.element,rect:o,confidence:n.confidence,strategy:n.strategy}}function _e(t){return {cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId??void 0,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null}}function fe(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var Nt=13;function _t(t){return {top:t.top+window.scrollY-Nt,left:t.right+window.scrollX-Nt}}function J(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Dt=300,Ht=200,Tn=.7,Cn=28,$t=32,me=class{constructor(e,n,i,o,r=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;this.liveRegion=r;this.container=b("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",s=>{this.container.style.display=s?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),this.mutationObserver=new MutationObserver(s=>{let a=false;for(let l of s)if(!(this.container.contains(l.target)||this.tooltip.contains(l.target))){a=true;break}a&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=s=>{this.container.contains(s.target)||this.collapseAllClusters();},document.addEventListener("click",this.onDocumentClickForClusters);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;lastOpenCount=-1;get count(){return this.entries.length}get openCount(){let e=0;for(let n of this.entries)n.feedback.status==="open"&&e++;return e}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:Ht+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},Ht));}repositionAll(){let e=new Set;for(let n of this.entries)for(let i=0;i<n.feedback.annotations.length;i++){let o=n.elements[i];if(!o)continue;let r=n.feedback.annotations[i];if(!r)continue;let s=`${n.feedback.id}:${i}`;e.add(s);let l=this.anchorCache.get(s)?.deref(),p;if(l?.isConnected){let u=l.getBoundingClientRect(),c=fe(r);p={element:l,rect:new DOMRect(u.left+c.xPct*u.width,u.top+c.yPct*u.height,c.wPct*u.width,c.hPct*u.height),confidence:1,strategy:"css"};}else p=he(_e(r),fe(r)),p?.element&&this.anchorCache.set(s,new WeakRef(p.element));if(!p){o.style.display="none";continue}let d=_t(p.rect);n.baseTop=d.top,n.baseLeft=d.left,o.style.display="flex",this.applyConfidenceStyle(o,p.confidence,n.feedback);}for(let n of this.anchorCache.keys())e.has(n)||this.anchorCache.delete(n);this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback);}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e);}emitMarkersChanged(){let e=this.openCount;e!==this.lastOpenCount&&(this.lastOpenCount=e,this.bus.emit("markers:changed",e));}render(e){this.clear(),e.forEach((n,i)=>{let o=this.buildEntry(n,i+1);this.entries.push(o);}),this.buildClusters(),this.liveRegion&&this.entries.length>0&&(this.liveRegion.textContent=this.t("marker.count").replace("{count}",String(this.entries.length))),this.emitMarkersChanged();}addFeedback(e,n){let i=this.buildEntry(e,n);for(let o of i.elements)o.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters(),this.emitMarkersChanged();}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let o of e.annotations){let r=he(_e(o),fe(o));if(!r)continue;let s=_t(r.rect);i.baseTop=s.top,i.baseLeft=s.left;let a=this.createMarker(n,e,s);this.applyConfidenceStyle(a,r.confidence,e),this.container.appendChild(a),i.elements.push(a);}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let o=0;o<i.elements.length;o++)e.push({entry:i,elIdx:o});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let o=e[i];if(!o)continue;let r={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let s=i+1;s<e.length;s++){if(n.has(s))continue;let a=o.entry,l=e[s];if(!l)continue;let p=l.entry;Math.sqrt((a.baseLeft-p.baseLeft)**2+(a.baseTop-p.baseTop)**2)<Cn&&(r.entries.push(p),r.elementIndices.push(l.elIdx),n.add(s));}this.clusters.push(r);}for(let i of this.clusters)i.entries.length<=1||(this.applyStackPositions(i),this.addClusterBadge(i));}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=J(e,s);a&&(a.style.top=`${i+(r?0:s*3)}px`,a.style.left=`${o+(r?0:s*3)}px`,a.style.zIndex=String(s+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,r=e.entries.length,s=(r-1)*$t,a=o-s/2;for(let l=0;l<r;l++){let p=J(e,l);p&&(p.style.top=`${i}px`,p.style.left=`${a+l*$t}px`,p.style.zIndex=String(10+l));}}addClusterBadge(e){let n=J(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
101
+ `}),this.drawingRect.setAttribute("data-siteping-ignore","true"),this.overlay?.appendChild(this.drawingRect));}onMouseMove=e=>{this.scheduleRectUpdate(e);};onTouchMove=e=>{e.preventDefault(),e.touches[0]&&this.scheduleRectUpdate(e.touches[0]);};scheduleRectUpdate(e){!this.isDrawing||!this.drawingRect||(this.pendingMoveEvent=e,this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;let n=this.pendingMoveEvent;if(!n||!this.drawingRect)return;let i=Math.min(n.clientX,this.startX),o=Math.min(n.clientY,this.startY),r=Math.abs(n.clientX-this.startX),s=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${o}px`,this.drawingRect.style.width=`${r}px`,this.drawingRect.style.height=`${s}px`;})));}onTouchEnd=async e=>{let n=e.changedTouches[0];n&&await this.finishDrawing(n.clientX,n.clientY);};onMouseUp=async e=>{await this.finishDrawing(e.clientX,e.clientY);};finishDrawing=async(e,n)=>{if(!this.isDrawing||!this.drawingRect)return;this.isDrawing=false;let i=Math.min(e,this.startX),o=Math.min(n,this.startY),r=Math.abs(e-this.startX),s=Math.abs(n-this.startY);if(r<10||s<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(i,o,r,s),l=this.buildAnnotation(a),c={},d=await this.popup.show(a,u=>this.runSubmission(l,u,a,c));this.drawingRect?.remove(),this.drawingRect=null,d&&this.deactivate();};async runSubmission(e,n,i,o){o.value===void 0&&(o.value=await this.maybeCapture(i));let r=o.value;await new Promise((s,a)=>{let l=()=>{c(),d(),u(),this.rejectPendingSubmission=null;},c=this.bus.on("feedback:sent",()=>{l(),s();}),d=this.bus.on("feedback:error",p=>{l(),a(p);}),u=this.bus.on("submission:cancelled",()=>{l(),a(new Error("Feedback submission cancelled"));});this.rejectPendingSubmission=p=>{l(),a(p);},this.bus.emit("annotation:complete",{annotation:e,type:n.type,message:n.message,screenshotDataUrl:r?.dataUrl??null,screenshotRegion:r?.region??null});});}buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=Tt(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Ne(n),o=n.getBoundingClientRect(),r=Ct(e,o);return {anchor:i,rect:r,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.rejectPendingSubmission?.(new Error("Annotator destroyed during submission")),this.popup.destroy();}};async function V(t,e){let n=await t.text().catch(()=>"Unknown error"),i=n?`${t.status} ${n}`:`${t.status}`,o=`${e}: ${i}`;return t.status===401||t.status===403?new F(o):t.status>=400&&t.status<500?new E(o):new C(o,"SERVER",false)}function J(t,e){if(t instanceof D)return t;let n=t instanceof Error?t.message:String(t);return new D(`${e}: ${n}`)}var un=3,hn=1e4,pe="siteping_retry_queue",fn=20;async function Z(t,e,n=un){for(let i=0;i<=n;i++){let o=new AbortController,r=setTimeout(()=>o.abort(),hn);try{let l=await fetch(t,{...e,signal:o.signal});if(clearTimeout(r),l.ok||l.status>=400&&l.status<500||i===n)return l}catch(l){if(clearTimeout(r),i===n)throw l}let s=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,s+a));}throw new Error("Max retries exceeded")}var mn="siteping_retry_queue";async function Pt(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(mn,()=>t()):t()}function Ft(){let t=localStorage.getItem(pe);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}function bn(t,e){Pt(()=>{try{let n=Ft();n.length>=fn&&n.shift(),n.push({endpoint:t,payload:e}),localStorage.setItem(pe,JSON.stringify(n));}catch{}});}function Rt(t){return t.trim()}function Mt(t){return t.trim().toLowerCase()}async function It(t,e){await Pt(async()=>{try{let n=Ft();if(n.length===0)return;let i=[],o=[],r=0;for(let l of n){if(l.endpoint!==t){o.push(l);continue}!e||Rt(l.payload.authorName)===Rt(e.name)&&Mt(l.payload.authorEmail)===Mt(e.email)?i.push(l):r+=1;}if(i.length===0&&r===0)return;r>0;let s=[];for(let l of i)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l.payload)})).ok||s.push(l);}catch{s.push(l);}let a=o.concat(s);a.length>0?localStorage.setItem(pe,JSON.stringify(a)):localStorage.removeItem(pe);}catch{}});}async function _e(t){return await t.json()}var de=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){let{screenshotRegion:n,...i}=e,o=n?{...i,screenshotRegion:n}:i;try{let r;try{r=await Z(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});}catch(s){throw J(s,"Failed to send feedback")}if(!r.ok)throw await V(r,"Failed to send feedback");return _e(r)}catch(r){throw bn(this.endpoint,o),r}}async getFeedbacks(e,n){let i=new URLSearchParams({projectName:e});n?.page&&i.set("page",String(n.page)),n?.limit&&i.set("limit",String(n.limit)),n?.type&&i.set("type",n.type),n?.status&&i.set("status",n.status),n?.statuses?.length&&i.set("statuses",n.statuses.join(",")),n?.search&&i.set("search",n.search),n?.url&&i.set("url",n.url),n?.urlPattern&&i.set("urlPattern",n.urlPattern);let o;try{o=await Z(`${this.endpoint}?${i.toString()}`,{method:"GET",cache:"no-store"});}catch(r){throw J(r,"Failed to fetch feedbacks")}if(!o.ok)throw await V(o,"Failed to fetch feedbacks");return _e(o)}async resolveFeedback(e,n){let i;try{i=await Z(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(o){throw J(o,"Failed to update feedback")}if(!i.ok)throw await V(i,"Failed to update feedback");return _e(i)}async deleteFeedback(e){let n;try{n=await Z(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(i){throw J(i,"Failed to delete feedback")}if(!n.ok)throw await V(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await Z(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(i){throw J(i,"Failed to delete all feedbacks")}if(!n.ok)throw await V(n,"Failed to delete all feedbacks")}};var gn=["log","info","warn","error"];function yn(t){if(t===null)return "null";if(t===void 0)return "undefined";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);if(t instanceof Error)return `${t.name}: ${t.message}${t.stack?`
102
+ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof i=="function")return "[Function]";if(typeof i=="symbol")return i.toString();if(typeof i=="object"&&i!==null){if(e.has(i))return "[Circular]";e.add(i);}return i})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function vn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=yn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var ue=class{maxEntries;entries=[];originals=new Map;disposed=false;constructor(e=50){if(this.maxEntries=Math.min(Math.max(Math.floor(e),0),1e3),!(typeof console>"u"))for(let n of gn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,r=function(...s){try{o.push(n,s);}catch{}i.apply(this??console,s);};try{Object.defineProperty(r,"name",{value:n});}catch{}console[n]=r;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:vn(n)}));}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed&&(this.disposed=true,!(typeof console>"u"))){for(let[e,n]of this.originals)try{console[e]=n;}catch{}this.originals.clear();}}};function Nt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Ht(t){if(typeof t=="string")return t;if(t instanceof URL)return t.href;if(typeof t=="object"&&t!==null&&"url"in t){let e=t.url;if(typeof e=="string")return e}try{return String(t)}catch{return "(unknown)"}}var he=class{maxEntries;entries=[];originalFetch=null;originalXhrOpen=null;originalXhrSend=null;disposed=false;constructor(e=20){this.maxEntries=Math.min(Math.max(Math.floor(e),0),500),this.installFetch(),this.installXhr();}push(e){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push(e));}installFetch(){if(typeof globalThis.fetch!="function")return;let e=globalThis.fetch;this.originalFetch=e;let n=async(i,o)=>{let r=new Date,s=typeof performance<"u"?performance.now():Date.now(),a=Nt(Ht(i)),l=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,o);if(!c.ok){let d=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:c.status,durationMs:Math.round(d-s),timestamp:r.toISOString()});}return c}catch(c){let d=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(d-s),timestamp:r.toISOString()}),c}};globalThis.fetch=n;}installXhr(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype,n=e.open,i=e.send;this.originalXhrOpen=n,this.originalXhrSend=i;let o=this,r=new WeakMap;e.open=function(s,a,...l){try{r.set(this,{method:s.toUpperCase(),url:Nt(Ht(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,s,a,...l)},e.send=function(s){let a=r.get(this);if(a){let l=()=>{try{let c=typeof performance<"u"?performance.now():Date.now(),d=this.status;(d===0||d>=400)&&o.push({url:a.url,method:a.method,status:d,durationMs:Math.round(c-a.t0),timestamp:a.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",l,{once:!0});}catch{try{this.addEventListener("loadend",l);}catch{}}}return i.call(this,s??null)};}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&typeof globalThis.fetch=="function")try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend);}catch{}}}};var Q=class{listeners=new Map;on(e,n){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(n),()=>{i?.delete(n);}}off(e,n){this.listeners.get(e)?.delete(n);}emit(e,...n){let i=this.listeners.get(e);if(i)for(let o of i)try{o(...n);}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var xn=54,wn={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},fe=class{constructor(e,n,i,o){this.bus=i;this.t=o;let r=n.position??"bottom-right",s=r==="bottom-right";this.items=[{id:"chat",icon:u},{id:"annotate",icon:v}],n.showAnnotationsToggle!==false&&this.items.push({id:"toggle-annotations",icon:g,iconAlt:h}),this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${r} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${r}`,this.radialContainer.setAttribute("role","menu");for(let c=0;c<this.items.length;c++){let d=this.items[c];if(!d)continue;let u=document.createElement("button");u.className="sp-radial-item",u.style.setProperty("--sp-i",String(c)),u.appendChild(a(d.icon)),u.setAttribute("role","menuitem"),u.dataset.itemId=d.id,u.addEventListener("click",f=>{f.stopPropagation(),this.handleItemClick(d.id);});let p=document.createElement("span");p.className="sp-radial-label",p.style.cssText=s?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",u.appendChild(p),this.radialContainer.appendChild(u);}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root),this.applyLabels();let a$1=e.host;this.onDocumentClick=c=>{this.isOpen&&!c.composedPath().includes(a$1)&&this.close();},document.addEventListener("click",this.onDocumentClick);let l=c=>{c.key==="Escape"&&this.isOpen&&(c.stopPropagation(),this.close());};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",c=>{let d=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(d.length===0||!this.isOpen)return;let u=e.activeElement??document.activeElement,p=d.indexOf(u);switch(c.key){case "ArrowUp":{c.preventDefault();let f=p<=0?d.length-1:p-1;d[f]?.focus();break}case "ArrowDown":{c.preventDefault();let f=p>=d.length-1?0:p+1;d[f]?.focus();break}case "Home":{c.preventDefault(),d[0]?.focus();break}case "End":{c.preventDefault(),d[d.length-1]?.focus();break}}});}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;refreshLabels(){this.applyLabels();}applyLabels(){this.fab.setAttribute("aria-label",this.t("fab.aria"));let e=this.radialContainer.querySelectorAll(".sp-radial-item");for(let n of e){let i=n.dataset.itemId;if(!i)continue;let o=wn[i];if(!o)continue;let r=this.t(o);n.setAttribute("aria-label",r);let s=n.querySelector(".sp-radial-label");s&&c(s,r);}}updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null;return}this.badgeEl||(this.badgeEl=document.createElement("span"),this.badgeEl.className="sp-fab-badge",this.badgeEl.setAttribute("role","status"),this.badgeEl.setAttribute("aria-live","polite"),this.fab.appendChild(this.badgeEl));let n=e>99?"99+":String(e);c(this.badgeEl,n),this.badgeEl.setAttribute("aria-label",this.t("fab.badge").replace("{count}",String(e)));}toggle(){this.isOpen?this.close():this.open();}open(){this.isOpen=true,this.setFabIcon(i),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+xn*(i+1));n.style.transform=`translate(0px, ${o}px) scale(1)`,n.classList.add("sp-radial-item--open");}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus();});}close(){this.isOpen=false,this.setFabIcon(f),this.fab.setAttribute("aria-expanded","false"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach(n=>{n.style.transform="translate(0, 0) scale(0.8)",n.classList.remove("sp-radial-item--open");}),this.fab.focus();}setFabIcon(e){let n=this.badgeEl;this.fab.replaceChildren(a(e)),n&&this.fab.appendChild(n);}handleItemClick(e){switch(this.close(),e){case "chat":this.bus.emit("panel:toggle",true);break;case "annotate":{let n=this.bus.on("annotation:end",()=>{n(),this.fab.focus();});this.bus.emit("annotation:start");break}case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let i=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]')?.querySelector("svg");if(i){let o=a(this.annotationsVisible?g:h);i.replaceWith(o);}break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var _t="siteping_identity";function En(t){if(!G$1(t,"name")||!G$1(t,"email"))return false;let e=t.name,n=t.email;return typeof e=="string"&&typeof n=="string"&&e.length>0&&n.length>0}function De(){try{let t=localStorage.getItem(_t);if(!t)return null;let e=JSON.parse(t);return En(e)?e:null}catch{return null}}function Dt(t){try{localStorage.setItem(_t,JSON.stringify(t));}catch{}}function kn(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let s=t;t=e,e=s;}let n=t.length,i=e.length,o=new Array(n+1);for(let s=0;s<=n;s++)o[s]=s;let r=new Array(n+1);for(let s=1;s<=i;s++){r[0]=s;for(let l=1;l<=n;l++){let c=o[l-1]??0;r[l]=t[l-1]===e[s-1]?c:1+Math.min(c,o[l]??0,r[l-1]??0);}let a=o;o=r,r=a;}return o[n]??0}function j(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-kn(t,e)/n}function $e(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let a=j(t,e);return a>=n?a:0}let o=0,r=t.length>500?t.slice(0,500):t,s=r.length-i;for(let a=0;a<=s;a++){let l=r.slice(a,a+i),c=j(l,e);if(c>o&&(o=c),o>=.95)break}return o>=n?o:0}var Sn=300,Tn=.3;function me(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return $e(n,e.textSnippet,.5)>Tn}function Cn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${U}="${e}"]`);if(n&&me(n,t))return {element:n,confidence:1,strategy:"anchorKey"}}catch{}}if(t.elementId){let e=document.getElementById(t.elementId);if(e&&e.tagName===t.elementTag&&me(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&me(e,t))return {element:e,confidence:.95,strategy:"css"}}catch{}try{let n=document.evaluate(t.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(n instanceof Element&&n.tagName===t.elementTag&&me(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return An(t)}function An(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,r=Math.min(n.length,Sn);for(let s=0;s<r;s++){let a=n[s];if(!a)continue;let l=Ln(a,t);if(l>o&&(o=l,i=a,o>=.85))break}return !i||o<.4?null:{element:i,confidence:Math.min(o,.85),strategy:"scan"}}function Ln(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=$e(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=Et(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let r=0,s=0;if(e.textPrefix){let a=z(t,"before");r+=a?j(a,e.textPrefix):0,s++;}if(e.textSuffix){let a=z(t,"after");r+=a?j(a,e.textSuffix):0,s++;}s>0&&(n+=r/s*20);}if(e.neighborText){i+=20;let r=re(t);n+=r?j(r,e.neighborText)*20:0;}return i>0?n/i:0}function be(t,e){let n=Cn(t);if(!n)return null;let i=n.element.getBoundingClientRect(),o=new DOMRect(i.x+e.xPct*i.width,i.y+e.yPct*i.height,e.wPct*i.width,e.hPct*i.height);return {element:n.element,rect:o,confidence:n.confidence,strategy:n.strategy}}function Oe(t){return {cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId??void 0,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null}}function ge(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var $t=13;function Ot(t){return {top:t.top+window.scrollY-$t,left:t.right+window.scrollX-$t}}function ee(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Bt=300,zt=200,Rn=.7,Mn=28,jt=32,ye=class{constructor(e,n,i,o,r=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;this.liveRegion=r;this.container=b("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",s=>{this.container.style.display=s?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),this.mutationObserver=new MutationObserver(s=>{let a=false;for(let l of s)if(!(this.container.contains(l.target)||this.tooltip.contains(l.target))){a=true;break}a&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=s=>{this.container.contains(s.target)||this.collapseAllClusters();},document.addEventListener("click",this.onDocumentClickForClusters);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;lastOpenCount=-1;get count(){return this.entries.length}get openCount(){let e=0;for(let n of this.entries)J$1(n.feedback.status)||e++;return e}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:zt+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},zt));}repositionAll(){let e=new Set;for(let n of this.entries)for(let i=0;i<n.feedback.annotations.length;i++){let o=n.elements[i];if(!o)continue;let r=n.feedback.annotations[i];if(!r)continue;let s=`${n.feedback.id}:${i}`;e.add(s);let l=this.anchorCache.get(s)?.deref(),c;if(l?.isConnected){let u=l.getBoundingClientRect(),p=ge(r);c={element:l,rect:new DOMRect(u.left+p.xPct*u.width,u.top+p.yPct*u.height,p.wPct*u.width,p.hPct*u.height),confidence:1,strategy:"css"};}else c=be(Oe(r),ge(r)),c?.element&&this.anchorCache.set(s,new WeakRef(c.element));if(!c){o.style.display="none";continue}let d=Ot(c.rect);n.baseTop=d.top,n.baseLeft=d.left,o.style.display="flex",this.applyConfidenceStyle(o,c.confidence,n.feedback);}for(let n of this.anchorCache.keys())e.has(n)||this.anchorCache.delete(n);this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback);}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e);}emitMarkersChanged(){let e=this.openCount;e!==this.lastOpenCount&&(this.lastOpenCount=e,this.bus.emit("markers:changed",e));}render(e){this.clear(),e.forEach((n,i)=>{let o=this.buildEntry(n,i+1);this.entries.push(o);}),this.buildClusters(),this.liveRegion&&this.entries.length>0&&(this.liveRegion.textContent=this.t("marker.count").replace("{count}",String(this.entries.length))),this.emitMarkersChanged();}addFeedback(e,n){let i=this.buildEntry(e,n);for(let o of i.elements)o.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters(),this.emitMarkersChanged();}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let o of e.annotations){let r=be(Oe(o),ge(o));if(!r)continue;let s=Ot(r.rect);i.baseTop=s.top,i.baseLeft=s.left;let a=this.createMarker(n,e,s);this.applyConfidenceStyle(a,r.confidence,e),this.container.appendChild(a),i.elements.push(a);}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let o=0;o<i.elements.length;o++)e.push({entry:i,elIdx:o});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let o=e[i];if(!o)continue;let r={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let s=i+1;s<e.length;s++){if(n.has(s))continue;let a=o.entry,l=e[s];if(!l)continue;let c=l.entry;Math.sqrt((a.baseLeft-c.baseLeft)**2+(a.baseTop-c.baseTop)**2)<Mn&&(r.entries.push(c),r.elementIndices.push(l.elIdx),n.add(s));}this.clusters.push(r);}for(let i of this.clusters)i.entries.length<=1||(this.applyStackPositions(i),this.addClusterBadge(i));}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=ee(e,s);a&&(a.style.top=`${i+(r?0:s*3)}px`,a.style.left=`${o+(r?0:s*3)}px`,a.style.zIndex=String(s+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,r=e.entries.length,s=(r-1)*jt,a=o-s/2;for(let l=0;l<r;l++){let c=ee(e,l);c&&(c.style.top=`${i}px`,c.style.left=`${a+l*jt}px`,c.style.zIndex=String(10+l));}}addClusterBadge(e){let n=ee(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
103
103
  position:absolute;top:-6px;right:-6px;
104
104
  min-width:16px;height:16px;padding:0 4px;
105
105
  border-radius:9999px;
@@ -110,7 +110,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
110
110
  pointer-events:none;
111
111
  font-family:"Inter",system-ui,-apple-system,sans-serif;
112
112
  line-height:1;
113
- `});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=J(e,i)?.querySelector(".sp-cluster-badge");o&&(o.style.display=n?"flex":"none");}}findCluster(e){for(let n of this.clusters)if(!(n.entries.length<=1)){for(let i=0;i<n.entries.length;i++)if(J(n,i)===e)return n}return null}handleClusterClick(e,n){let i=this.findCluster(e);return i?i.expanded?false:(n.stopPropagation(),this.collapseAllClusters(),i.expanded=true,this.applyFanPositions(i),this.setBadgesVisible(i,false),true):false}collapseCluster(e){e.expanded&&(e.expanded=false,this.applyStackPositions(e),this.setBadgesVisible(e,true));}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e);}applyConfidenceStyle(e,n,i){let o=i.status==="resolved";n<Tn&&!o?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=this.t("marker.approximate").replace("{confidence}",String(Math.round(n*100)))):(e.style.borderStyle="solid",e.style.opacity="1",e.title="");}createMarker(e,n,i){let o=x(n.type,this.colors),r=n.status==="resolved",s=b("div",{style:`
113
+ `});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=ee(e,i)?.querySelector(".sp-cluster-badge");o&&(o.style.display=n?"flex":"none");}}findCluster(e){for(let n of this.clusters)if(!(n.entries.length<=1)){for(let i=0;i<n.entries.length;i++)if(ee(n,i)===e)return n}return null}handleClusterClick(e,n){let i=this.findCluster(e);return i?i.expanded?false:(n.stopPropagation(),this.collapseAllClusters(),i.expanded=true,this.applyFanPositions(i),this.setBadgesVisible(i,false),true):false}collapseCluster(e){e.expanded&&(e.expanded=false,this.applyStackPositions(e),this.setBadgesVisible(e,true));}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e);}applyConfidenceStyle(e,n,i){let o=J$1(i.status);n<Rn&&!o?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=this.t("marker.approximate").replace("{confidence}",String(Math.round(n*100)))):(e.style.borderStyle="solid",e.style.opacity="1",e.title="");}createMarker(e,n,i){let o=x(n.type,this.colors),r=J$1(n.status),s=b("div",{style:`
114
114
  position:absolute;
115
115
  top:${i.top}px;
116
116
  left:${i.left}px;
@@ -127,7 +127,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
127
127
  transition:top 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.15s ease, box-shadow 0.15s ease;
128
128
  user-select:none;
129
129
  -webkit-font-smoothing:antialiased;
130
- `});s.dataset.feedbackId=n.id,s.setAttribute("tabindex","0"),s.setAttribute("role","button");let a=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,l=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",I(n.type,this.t)).replace("{message}",a);s.setAttribute("aria-label",l),s.setAttribute("aria-describedby",this.tooltip.tooltipId),c(s,r?"\u2713":String(e)),s.addEventListener("mouseenter",()=>{s.style.transform="scale(1.2)",s.style.boxShadow=r?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${o}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("mouseleave",()=>{s.style.transform="scale(1)",s.style.boxShadow=r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${o}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),s.addEventListener("focus",()=>{this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let p=d=>{d instanceof MouseEvent&&this.handleClusterClick(s,d)||(this.pinHighlight(n),this.bus.emit("panel:toggle",true),s.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:true})));};return s.addEventListener("click",d=>p(d)),s.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),p(d));}),s}focusFeedback(e){let n=this.entries.find(o=>o.feedback.id===e);if(!n)return false;let i=n.elements[0];return i&&i.scrollIntoView({behavior:"smooth",block:"center"}),this.pinHighlight(n.feedback),this.highlight(e),true}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)i.style.animation="sp-pulse-ring 0.7s ease-out",i.addEventListener("animationend",()=>{i.style.animation="";},{once:true});}showHighlight(e){this.removeHighlightElements();for(let n of e.annotations){let i=he(_e(n),fe(n));if(!i)continue;let o=x(e.type,this.colors),r=i.rect,s=b("div",{style:`
130
+ `});s.dataset.feedbackId=n.id,s.setAttribute("tabindex","0"),s.setAttribute("role","button");let a=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,l=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",N(n.type,this.t)).replace("{message}",a);s.setAttribute("aria-label",l),s.setAttribute("aria-describedby",this.tooltip.tooltipId),c(s,r?"\u2713":String(e)),s.addEventListener("mouseenter",()=>{s.style.transform="scale(1.2)",s.style.boxShadow=r?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${o}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("mouseleave",()=>{s.style.transform="scale(1)",s.style.boxShadow=r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${o}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),s.addEventListener("focus",()=>{this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let c$1=d=>{d instanceof MouseEvent&&this.handleClusterClick(s,d)||(this.pinHighlight(n),this.bus.emit("panel:toggle",true),s.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:true})));};return s.addEventListener("click",d=>c$1(d)),s.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c$1(d));}),s}focusFeedback(e){let n=this.entries.find(o=>o.feedback.id===e);if(!n)return false;let i=n.elements[0];return i&&i.scrollIntoView({behavior:"smooth",block:"center"}),this.pinHighlight(n.feedback),this.highlight(e),true}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)i.style.animation="sp-pulse-ring 0.7s ease-out",i.addEventListener("animationend",()=>{i.style.animation="";},{once:true});}showHighlight(e){this.removeHighlightElements();for(let n of e.annotations){let i=be(Oe(n),ge(n));if(!i)continue;let o=x(e.type,this.colors),r=i.rect,s=b("div",{style:`
131
131
  position:absolute;
132
132
  top:${r.top+window.scrollY}px;
133
133
  left:${r.left+window.scrollX}px;
@@ -138,8 +138,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
138
138
  pointer-events:none;z-index:-1;
139
139
  opacity:0;
140
140
  box-shadow:0 0 16px ${o}20;
141
- transition:opacity ${Dt}ms ease;
142
- `});this.container.appendChild(s),this.highlightElements.push(s),s.offsetHeight,s.style.opacity="1";}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=n=>{this.container.contains(n.target)||this.unpinHighlight();},document.addEventListener("click",this.onDocumentClick,{capture:true});}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:true}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight();}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),Dt);this.highlightElements=[];}removeHighlightElements(){for(let e of this.highlightElements)e.remove();this.highlightElements=[];}clear(){this.unpinHighlight(),this.container.replaceChildren(),this.entries=[],this.clusters=[],this.anchorCache.clear();}destroy(){this.unpinHighlight(),this.repositionTimer&&("cancelIdleCallback"in window&&window.cancelIdleCallback(this.repositionTimer),clearTimeout(this.repositionTimer)),this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.scrollHandler&&window.removeEventListener("scroll",this.scrollHandler,{capture:true}),this.onDocumentClickForClusters&&document.removeEventListener("click",this.onDocumentClickForClusters),this.mutationObserver?.disconnect(),this.container.remove();}};var be=class{constructor(e,n){this.store=e;this.projectName=n;}store;projectName;async sendFeedback(e){let n=await this.store.createFeedback({projectName:e.projectName,type:e.type,message:e.message,status:"open",url:e.url,urlPattern:e.urlPattern??null,viewport:e.viewport,userAgent:e.userAgent,authorName:e.authorName,authorEmail:e.authorEmail,clientId:e.clientId,annotations:e.annotations.map(F),screenshotDataUrl:e.screenshotDataUrl??null});return De(n)}async getFeedbacks(e,n){let{feedbacks:i,total:o}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,search:n?.search,url:n?.url,urlPattern:n?.urlPattern});return {feedbacks:i.map(De),total:o}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return De(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function De(t){return {id:t.id,projectName:t.projectName,type:t.type,message:t.message,status:t.status,url:t.url,urlPattern:t.urlPattern??null,viewport:t.viewport,userAgent:t.userAgent,authorName:t.authorName,authorEmail:t.authorEmail,resolvedAt:t.resolvedAt?.toISOString()??null,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),annotations:t.annotations.map(An),screenshotUrl:t.screenshotUrl??null,diagnostics:t.diagnostics??null}}function An(t){return {id:t.id,feedbackId:t.feedbackId,cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null,xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct,scrollX:t.scrollX,scrollY:t.scrollY,viewportW:t.viewportW,viewportH:t.viewportH,devicePixelRatio:t.devicePixelRatio,createdAt:t.createdAt.toISOString()}}var Ln="linear(0, 0.006, 0.025, 0.06, 0.11, 0.17, 0.25, 0.34, 0.45, 0.56, 0.67, 0.78, 0.88, 0.95, 1.01, 1.04, 1.05, 1.04, 1.02, 1, 0.99, 1)",He="cubic-bezier(0.16, 1, 0.3, 1)",$e="cubic-bezier(0.34, 1.56, 0.64, 1)",Rn="cubic-bezier(0.25, 1, 0.5, 1)",Ot=`
141
+ transition:opacity ${Bt}ms ease;
142
+ `});this.container.appendChild(s),this.highlightElements.push(s),s.offsetHeight,s.style.opacity="1";}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=n=>{this.container.contains(n.target)||this.unpinHighlight();},document.addEventListener("click",this.onDocumentClick,{capture:true});}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:true}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight();}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),Bt);this.highlightElements=[];}removeHighlightElements(){for(let e of this.highlightElements)e.remove();this.highlightElements=[];}clear(){this.unpinHighlight(),this.container.replaceChildren(),this.entries=[],this.clusters=[],this.anchorCache.clear();}destroy(){this.unpinHighlight(),this.repositionTimer&&("cancelIdleCallback"in window&&window.cancelIdleCallback(this.repositionTimer),clearTimeout(this.repositionTimer)),this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.scrollHandler&&window.removeEventListener("scroll",this.scrollHandler,{capture:true}),this.onDocumentClickForClusters&&document.removeEventListener("click",this.onDocumentClickForClusters),this.mutationObserver?.disconnect(),this.container.remove();}};var ve=class{constructor(e,n){this.store=e;this.projectName=n;}store;projectName;async sendFeedback(e){let n=await this.store.createFeedback({projectName:e.projectName,type:e.type,message:e.message,status:"open",url:e.url,urlPattern:e.urlPattern??null,viewport:e.viewport,userAgent:e.userAgent,authorName:e.authorName,authorEmail:e.authorEmail,clientId:e.clientId,annotations:e.annotations.map(K),screenshotDataUrl:e.screenshotDataUrl??null,screenshotRegion:e.screenshotRegion??null,diagnostics:e.diagnostics??null});return Be(n)}async getFeedbacks(e,n){let{feedbacks:i,total:o}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,statuses:n?.statuses,search:n?.search,url:n?.url,urlPattern:n?.urlPattern});return {feedbacks:i.map(Be),total:o}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return Be(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function Be(t){return {id:t.id,projectName:t.projectName,type:t.type,message:t.message,status:t.status,url:t.url,urlPattern:t.urlPattern??null,viewport:t.viewport,userAgent:t.userAgent,authorName:t.authorName,authorEmail:t.authorEmail,resolvedAt:t.resolvedAt?.toISOString()??null,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),annotations:t.annotations.map(Pn),screenshotUrl:t.screenshotUrl??null,screenshotRegion:t.screenshotRegion??null,diagnostics:t.diagnostics??null}}function Pn(t){return {id:t.id,feedbackId:t.feedbackId,cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null,xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct,scrollX:t.scrollX,scrollY:t.scrollY,viewportW:t.viewportW,viewportH:t.viewportH,devicePixelRatio:t.devicePixelRatio,createdAt:t.createdAt.toISOString()}}var Fn="linear(0, 0.006, 0.025, 0.06, 0.11, 0.17, 0.25, 0.34, 0.45, 0.56, 0.67, 0.78, 0.88, 0.95, 1.01, 1.04, 1.05, 1.04, 1.02, 1, 0.99, 1)",ze="cubic-bezier(0.16, 1, 0.3, 1)",je="cubic-bezier(0.34, 1.56, 0.64, 1)",In="cubic-bezier(0.25, 1, 0.5, 1)",Xt=`
143
143
  /* ---- Keyframes ---- */
144
144
 
145
145
  @keyframes sp-fab-in {
@@ -213,11 +213,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
213
213
  /* ---- Animation classes ---- */
214
214
 
215
215
  .sp-anim-fab-in {
216
- animation: sp-fab-in 0.5s ${Ln} both;
216
+ animation: sp-fab-in 0.5s ${Fn} both;
217
217
  }
218
218
 
219
219
  .sp-anim-marker-in {
220
- animation: sp-marker-in 0.35s ${$e} both;
220
+ animation: sp-marker-in 0.35s ${je} both;
221
221
  }
222
222
 
223
223
  .sp-anim-pulse {
@@ -225,11 +225,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
225
225
  }
226
226
 
227
227
  .sp-anim-flash {
228
- animation: sp-flash-bg 0.5s ${Rn};
228
+ animation: sp-flash-bg 0.5s ${In};
229
229
  }
230
230
 
231
231
  .sp-anim-slide-up {
232
- animation: sp-slide-up 0.3s ${He} both;
232
+ animation: sp-slide-up 0.3s ${ze} both;
233
233
  }
234
234
 
235
235
  .sp-anim-fade-in {
@@ -240,7 +240,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
240
240
 
241
241
  .sp-panel {
242
242
  transform: translateX(110%);
243
- transition: transform 0.4s ${He};
243
+ transition: transform 0.4s ${ze};
244
244
  }
245
245
 
246
246
  .sp-panel.sp-panel--open {
@@ -252,7 +252,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
252
252
  pointer-events: none;
253
253
  transform: translate(0, 0) scale(0.8);
254
254
  transition:
255
- transform 0.35s ${$e},
255
+ transform 0.35s ${je},
256
256
  opacity 0.2s ease,
257
257
  background 0.2s ease,
258
258
  border-color 0.2s ease,
@@ -283,7 +283,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
283
283
  }
284
284
 
285
285
  .sp-card {
286
- animation: sp-card-in 0.35s ${He} both;
286
+ animation: sp-card-in 0.35s ${ze} both;
287
287
  animation-delay: calc(var(--sp-card-i, 0) * 40ms);
288
288
  }
289
289
 
@@ -311,7 +311,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
311
311
  }
312
312
 
313
313
  .sp-fab-badge {
314
- animation: sp-badge-in 0.4s ${$e} both;
314
+ animation: sp-badge-in 0.4s ${je} both;
315
315
  }
316
316
 
317
317
  /* ---- Reduced motion ---- */
@@ -324,7 +324,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
324
324
  }
325
325
  }
326
326
 
327
- `;function Oe(t){return `
327
+ `;function Xe(t){return `
328
328
  :host {
329
329
  all: initial;
330
330
  position: fixed;
@@ -337,7 +337,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
337
337
  color-scheme: ${t.bg==="#ffffff"?"light":"dark"};
338
338
  -webkit-font-smoothing: antialiased;
339
339
  -moz-osx-font-smoothing: grayscale;
340
- ${z$1(t)}
340
+ ${B(t)}
341
341
 
342
342
  /* Identity modal \u2014 theme-aware backdrop + panel */
343
343
  --sp-identity-bg: ${t.glassBgHeavy};
@@ -1495,14 +1495,14 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1495
1495
  }
1496
1496
  }
1497
1497
 
1498
- ${Ot}
1499
- ${U$1}
1498
+ ${Xt}
1499
+ ${_}
1500
+ ${Z$1}
1501
+ ${R}
1502
+ ${P}
1503
+ ${ca}
1500
1504
  ${T}
1501
- ${L}
1502
- ${J$1}
1503
- ${Y$1}
1504
- ${N}
1505
- `}var Mn=120,Pn=80,ge=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
1505
+ `}var Nn=120,Hn=80,xe=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
1506
1506
  position: fixed;
1507
1507
  z-index: ${2147483647};
1508
1508
  max-width: 280px;
@@ -1528,12 +1528,12 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1528
1528
  border: 1px solid ${this.colors.glassBorder};
1529
1529
  transform: rotate(45deg);
1530
1530
  pointer-events: none;
1531
- `}),this.root.appendChild(this.arrow),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),document.body.appendChild(this.root);}colors;locale;root;arrow;showTimer=null;hideTimer=null;currentFeedbackId=null;tooltipId="sp-tooltip";show(e,n){this.currentFeedbackId!==e.id&&(this.cancelHide(),this.cancelShow(),this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(n);let i=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=i?"none":"",this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)";},Mn));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Pn);}hide(){this.cancelShow(),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform="translateY(6px) scale(0.97)",setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden");},200);}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null);}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null);}render(e$1){let n=Array.from(this.root.children);for(let u of n)u!==this.arrow&&u.remove();let i=x(e$1.type,this.colors),o=y(e$1.type,this.colors),r=H(this.locale),s=I(e$1.type,r),a=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=b("span",{style:`
1531
+ `}),this.root.appendChild(this.arrow),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),document.body.appendChild(this.root);}colors;locale;root;arrow;showTimer=null;hideTimer=null;currentFeedbackId=null;tooltipId="sp-tooltip";show(e,n){this.currentFeedbackId!==e.id&&(this.cancelHide(),this.cancelShow(),this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(n);let i=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=i?"none":"",this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)";},Nn));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Hn);}hide(){this.cancelShow(),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform="translateY(6px) scale(0.97)",setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden");},200);}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null);}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null);}render(e$1){let n=Array.from(this.root.children);for(let u of n)u!==this.arrow&&u.remove();let i=x(e$1.type,this.colors),o=A(e$1.type,this.colors),r=M(this.locale),s=N(e$1.type,r),a=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=b("span",{style:`
1532
1532
  padding:3px 10px;border-radius:9999px;
1533
1533
  font-size:11px;font-weight:600;
1534
1534
  color:${i};background:${o};
1535
1535
  letter-spacing:0.02em;
1536
- `});c(l,s);let p=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(p,e(e$1.createdAt,this.locale)),a.appendChild(l),a.appendChild(p);let d=b("div",{style:`font-size:13px;line-height:1.55;color:${this.colors.text};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;`});c(d,e$1.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(d,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),i=10,o=e.top-n.height-i,r=e.left+e.width/2-n.width/2,s=true;o<8&&(o=e.bottom+i,s=false),r=Math.max(8,Math.min(r,window.innerWidth-n.width-8)),this.root.style.top=`${o}px`,this.root.style.left=`${r}px`;let a=Math.max(16,Math.min(e.left+e.width/2-r-6,n.width-22));s?this.arrow.style.cssText=`
1536
+ `});c(l,s);let c$1=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(c$1,e(e$1.createdAt,this.locale)),a.appendChild(l),a.appendChild(c$1);let d=b("div",{style:`font-size:13px;line-height:1.55;color:${this.colors.text};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;`});c(d,e$1.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(d,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),i=10,o=e.top-n.height-i,r=e.left+e.width/2-n.width/2,s=true;o<8&&(o=e.bottom+i,s=false),r=Math.max(8,Math.min(r,window.innerWidth-n.width-8)),this.root.style.top=`${o}px`,this.root.style.left=`${r}px`;let a=Math.max(16,Math.min(e.left+e.width/2-r-6,n.width-22));s?this.arrow.style.cssText=`
1537
1537
  position:absolute;
1538
1538
  width:12px;height:12px;
1539
1539
  background:${this.colors.glassBgHeavy};
@@ -1553,8 +1553,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1553
1553
  pointer-events:none;
1554
1554
  top:-6px;
1555
1555
  left:${a}px;
1556
- `;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var Z=null;function Fn(t){return t===void 0||t===false?{console:false,network:false,maxConsoleEntries:50,maxNetworkEntries:20}:t===true?{console:true,network:true,maxConsoleEntries:50,maxNetworkEntries:20}:{console:t.console!==false,network:t.network!==false,maxConsoleEntries:typeof t.maxConsoleEntries=="number"?t.maxConsoleEntries:50,maxNetworkEntries:typeof t.maxNetworkEntries=="number"?t.maxNetworkEntries:20}}function ye(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:t,focusFeedback:()=>false,on:()=>t,off:t}}function In(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function Bt(t){let e=t.debug?(...h)=>console.debug("[siteping]",...h):()=>{};if(Z)return e("initSiteping() called more than once \u2014 returning existing instance"),Z;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),ye()}catch{}let n=typeof t.minViewportWidth=="number"&&Number.isFinite(t.minViewportWidth)?t.minViewportWidth:768;if(!t.forceShow&&window.innerWidth<n){let h="mobile";return t.onSkip?.(h),ye()}if(!t.store&&(!t.endpoint||typeof t.endpoint!="string"))return console.error("[siteping] Missing 'endpoint' or 'store' in config. Provide an endpoint like '/api/siteping' or a SitepingStore instance."),ye();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),ye();let i=t.locale??"en",o=i==="en"?Promise.resolve():G$1(i).catch(()=>{}),r=H(i),s=t.scopeAnnotationsByUrl??true,a=()=>{try{let h=t.getPageScope?.();if(h)return h}catch(h){e("getPageScope() threw, falling back to pathname:",h);}return {url:window.location.pathname,urlPattern:null}};e("Initializing widget",{projectName:t.projectName,theme:t.theme??"light",locale:i,scopeAnnotationsByUrl:s});let l=Fn(t.captureDiagnostics),p=l.console?new pe(l.maxConsoleEntries):null,d=l.network?new ce(l.maxNetworkEntries):null,u=w(t.accentColor,t.theme),c=new V,b=new V,w$1=(()=>{if(t.store)return new be(t.store,t.projectName);let h=t.endpoint;if(typeof h!="string"||h.length===0)throw new Error("[siteping] internal invariant: endpoint must be a non-empty string in HTTP mode");return new le(h,t.projectName)})();t.onOpen&&c.on("open",t.onOpen),t.onClose&&c.on("close",t.onClose),t.onFeedbackSent&&c.on("feedback:sent",t.onFeedbackSent),t.onError&&c.on("feedback:error",t.onError),t.onAnnotationStart&&c.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&c.on("annotation:end",t.onAnnotationEnd),c.on("feedback:sent",h=>b.emit("feedback:sent",h)),c.on("feedback:deleted",h=>b.emit("feedback:deleted",h)),c.on("open",()=>b.emit("panel:open")),c.on("close",()=>b.emit("panel:close")),c.on("open",()=>e("Panel opened")),c.on("close",()=>e("Panel closed")),c.on("feedback:sent",h=>e("Feedback sent",h.id)),c.on("feedback:error",h=>e("Feedback failed",h.message)),c.on("annotation:start",()=>e("Annotation started")),c.on("annotation:end",()=>e("Annotation ended"));let L=document.createElement("siteping-widget");L.style.cssText=`position:fixed;z-index:${2147483647};`;let I=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(I=!0);}catch{}let H$1=I?"open":"closed",A=L.attachShadow({mode:H$1});if("adoptedStyleSheets"in ShadowRoot.prototype){let h=new CSSStyleSheet;h.replaceSync(Oe(u)),A.adoptedStyleSheets=[h];}else {let h=document.createElement("style");h.textContent=Oe(u),A.appendChild(h);}document.body.appendChild(L);let S=document.createElement("div");S.setAttribute("role","status"),S.setAttribute("aria-live","polite"),S.setAttribute("aria-atomic","true"),S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(S);let T=new ge(u,i),g=new me(u,T,c,r,S),R=new de(A,t,c,r);c.on("markers:changed",h=>R.updateBadge(h));let x=null,N=null,k=false,Q=0;async function je(){return k?null:x||(N||(N=import('./panel-66LNZR5L.js').then(h=>k?null:(x=new h.Panel(A,u,c,w$1,t.projectName,g,r,i,{getScope:a,scopeAnnotationsByUrl:s}),x))),N)}if(typeof window<"u"){let h=()=>{k||je();},f=window.requestIdleCallback;typeof f=="function"?f(h):setTimeout(h,200);}let $=false,zt=c.on("panel:toggle",h=>{x||(h?($=true,je().then(f=>{f&&$&&f.open(),$=false;}).catch(f=>e("Failed to lazy-load panel:",f))):$=false);}),Xe=new re(u,c,r,t.enableScreenshot??false);i!=="en"&&o.then(()=>{k||(R.refreshLabels(),Xe.refreshLabels());});let ve=false,jt=c.on("annotation:complete",async h=>{if(ve){c.emit("submission:cancelled");return}ve=true;try{let{annotation:f,type:y,message:M,screenshotDataUrl:O}=h,C=t.identity??Ie();if(!C){if(C=await Nn(A,r),!C){c.emit("submission:cancelled");return}It(C);}let ee=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),E=a(),te=null;(p||d)&&(te={console:p?.getEntries()??[],network:d?.getEntries()??[]});let qt={projectName:t.projectName,type:y,message:M,url:E.url,urlPattern:E.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:C.name,authorEmail:C.email,annotations:[f],clientId:ee,screenshotDataUrl:O??null,diagnostics:te};try{let _=await w$1.sendFeedback(qt);c.emit("feedback:sent",_),(!s||_.url===E.url)&&g.addFeedback(_,g.count+1),S.textContent=r("feedback.sent.confirmation"),x&&await x.refresh();}catch(_){c.emit("feedback:error",_ instanceof Error?_:new Error(String(_))),S.textContent=r("feedback.error.message");}}finally{ve=false;}}),xe=a(),Xt=s?{limit:20,url:xe.url}:{limit:20},we=In(t.deepLink),Kt=++Q;Promise.all([w$1.getFeedbacks(t.projectName,Xt),o]).then(([{feedbacks:h}])=>{if(k||Q!==Kt)return;let f=s?h.filter(y=>y.url===xe.url):h;if(g.render(f),we.enabled)try{let y=new URLSearchParams(window.location.search).get(we.param);if(y){let M=g.focusFeedback(y);e(`deepLink ?${we.param}=${y} ${M?"focused":"did not match a visible feedback"}`);}}catch(y){e("deepLink parsing failed:",y);}}).catch(h=>{e("Failed to load initial markers:",h);}),t.endpoint&&Rt(t.endpoint,t.identity??Ie()).then(()=>e("Retry queue flushed")).catch(()=>{});let Ke=()=>{let h=++Q;if(x?.isCurrentlyOpen)return x.refresh();let f=a(),y=s?{limit:20,url:f.url}:{limit:20};return w$1.getFeedbacks(t.projectName,y).then(({feedbacks:M})=>{if(k||h!==Q||x?.isCurrentlyOpen)return;let O=s?M.filter(C=>C.url===f.url):M;g.render(O);})},qe=null;if(t.watchNavigation!==false&&typeof window<"u"&&typeof history<"u"){let h=E=>`${E.url}
1557
- ${E.urlPattern??""}`,f=h(xe),y=()=>{if(k)return;let E=h(a());if(E===f)return;let te=f;f=E,e("SPA navigation detected \u2014 refreshing feedbacks for new scope"),Ke().catch(()=>{f===E&&(f=te);});},M=history.pushState,O=history.replaceState,C=function(...E){M.apply(this,E),y();},ee=function(...E){O.apply(this,E),y();};history.pushState=C,history.replaceState=ee,window.addEventListener("popstate",y),window.addEventListener("hashchange",y),qe=()=>{window.removeEventListener("popstate",y),window.removeEventListener("hashchange",y),history.pushState===C&&(history.pushState=M),history.replaceState===ee&&(history.replaceState=O);};}return Z={destroy:()=>{e("Destroying widget"),k=true,$=false,qe?.(),jt(),zt(),R.destroy(),x?.destroy(),Xe.destroy(),g.destroy(),T.destroy(),p?.dispose(),d?.dispose(),c.removeAll(),b.removeAll(),S.remove(),L.remove(),Z=null;},open:()=>{c.emit("panel:toggle",true);},close:()=>{x?x.close():$=false;},focusFeedback:h=>g.focusFeedback(h),refresh:()=>{Ke().catch(()=>{});},on:(h,f)=>b.on(h,f),off:(h,f)=>{b.off(h,f);}},Z}function Nn(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,o=t.host;o.parentNode&&o.parentNode.appendChild(o);let r=document.createElement("div");r.style.cssText=`
1556
+ `;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var te=null;function _n(t){return t===void 0||t===false?{console:false,network:false,maxConsoleEntries:50,maxNetworkEntries:20}:t===true?{console:true,network:true,maxConsoleEntries:50,maxNetworkEntries:20}:{console:t.console!==false,network:t.network!==false,maxConsoleEntries:typeof t.maxConsoleEntries=="number"?t.maxConsoleEntries:50,maxNetworkEntries:typeof t.maxNetworkEntries=="number"?t.maxNetworkEntries:20}}function we(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:t,focusFeedback:()=>false,on:()=>t,off:t}}function Dn(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function Kt(t){let e=t.debug?(...h)=>console.debug("[siteping]",...h):()=>{};if(te)return e("initSiteping() called more than once \u2014 returning existing instance"),te;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),we()}catch{}let n=typeof t.minViewportWidth=="number"&&Number.isFinite(t.minViewportWidth)?t.minViewportWidth:768;if(!t.forceShow&&window.innerWidth<n){let h="mobile";return t.onSkip?.(h),we()}if(!t.store&&(!t.endpoint||typeof t.endpoint!="string"))return console.error("[siteping] Missing 'endpoint' or 'store' in config. Provide an endpoint like '/api/siteping' or a SitepingStore instance."),we();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),we();let i=t.locale??"en",o=i==="en"?Promise.resolve():L(i).catch(()=>{}),r=M(i),s=t.scopeAnnotationsByUrl??true,a=()=>{try{let h=t.getPageScope?.();if(h)return h}catch(h){e("getPageScope() threw, falling back to pathname:",h);}return {url:window.location.pathname,urlPattern:null}};e("Initializing widget",{projectName:t.projectName,theme:t.theme??"light",locale:i,scopeAnnotationsByUrl:s});let l=_n(t.captureDiagnostics),c=l.console?new ue(l.maxConsoleEntries):null,d=l.network?new he(l.maxNetworkEntries):null,u=w(t.accentColor,t.theme),p=new Q,f=new Q,y=(()=>{if(t.store)return new ve(t.store,t.projectName);let h=t.endpoint;if(typeof h!="string"||h.length===0)throw new Error("[siteping] internal invariant: endpoint must be a non-empty string in HTTP mode");return new de(h,t.projectName)})();t.onOpen&&p.on("open",t.onOpen),t.onClose&&p.on("close",t.onClose),t.onFeedbackSent&&p.on("feedback:sent",t.onFeedbackSent),t.onError&&p.on("feedback:error",t.onError),t.onAnnotationStart&&p.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&p.on("annotation:end",t.onAnnotationEnd),p.on("feedback:sent",h=>f.emit("feedback:sent",h)),p.on("feedback:deleted",h=>f.emit("feedback:deleted",h)),p.on("open",()=>f.emit("panel:open")),p.on("close",()=>f.emit("panel:close")),p.on("open",()=>e("Panel opened")),p.on("close",()=>e("Panel closed")),p.on("feedback:sent",h=>e("Feedback sent",h.id)),p.on("feedback:error",h=>e("Feedback failed",h.message)),p.on("annotation:start",()=>e("Annotation started")),p.on("annotation:end",()=>e("Annotation ended"));let A=document.createElement("siteping-widget");A.style.cssText=`position:fixed;z-index:${2147483647};`;let k=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(k=!0);}catch{}let F=k?"open":"closed",T=A.attachShadow({mode:F});if("adoptedStyleSheets"in ShadowRoot.prototype){let h=new CSSStyleSheet;h.replaceSync(Xe(u)),T.adoptedStyleSheets=[h];}else {let h=document.createElement("style");h.textContent=Xe(u),T.appendChild(h);}document.body.appendChild(A);let w$1=document.createElement("div");w$1.setAttribute("role","status"),w$1.setAttribute("aria-live","polite"),w$1.setAttribute("aria-atomic","true"),w$1.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(w$1);let S=new xe(u,i),g=new ye(u,S,p,r,w$1),R=new fe(T,t,p,r);p.on("markers:changed",h=>R.updateBadge(h));let E=null,H=null,C=false,ne=0;async function Ye(){return C?null:E||(H||(H=import('./panel-YIFL7JMG.js').then(h=>C?null:(E=new h.Panel(T,u,p,y,t.projectName,g,r,i,{getScope:a,scopeAnnotationsByUrl:s}),E))),H)}if(typeof window<"u"){let h=()=>{C||Ye();},m=window.requestIdleCallback;typeof m=="function"?m(h):setTimeout(h,200);}let $=false,Yt=p.on("panel:toggle",h=>{E||(h?($=true,Ye().then(m=>{m&&$&&m.open(),$=false;}).catch(m=>e("Failed to lazy-load panel:",m))):$=false);}),qe=new ce(u,p,r,t.enableScreenshot??false);i!=="en"&&o.then(()=>{C||(R.refreshLabels(),qe.refreshLabels());});let Ee=false,qt=p.on("annotation:complete",async h=>{if(Ee){p.emit("submission:cancelled");return}Ee=true;try{let{annotation:m,type:v,message:M,screenshotDataUrl:O,screenshotRegion:B}=h,P=t.identity??De();if(!P){if(P=await $n(T,r),!P){p.emit("submission:cancelled");return}Dt(P);}let L=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),K=a(),Ge=null;(c||d)&&(Ge={console:c?.getEntries()??[],network:d?.getEntries()??[]});let Gt={projectName:t.projectName,type:v,message:M,url:K.url,urlPattern:K.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:P.name,authorEmail:P.email,annotations:[m],clientId:L,screenshotDataUrl:O??null,screenshotRegion:B??null,diagnostics:Ge};try{let _=await y.sendFeedback(Gt);p.emit("feedback:sent",_),(!s||_.url===K.url)&&g.addFeedback(_,g.count+1),w$1.textContent=r("feedback.sent.confirmation"),E&&await E.refresh();}catch(_){p.emit("feedback:error",_ instanceof Error?_:new Error(String(_))),w$1.textContent=r("feedback.error.message");}}finally{Ee=false;}}),ke=a(),Wt=s?{limit:20,url:ke.url}:{limit:20},Se=Dn(t.deepLink),Ut=++ne;Promise.all([y.getFeedbacks(t.projectName,Wt),o]).then(([{feedbacks:h}])=>{if(C||ne!==Ut)return;let m=s?h.filter(v=>v.url===ke.url):h;if(g.render(m),Se.enabled)try{let v=new URLSearchParams(window.location.search).get(Se.param);if(v){let M=g.focusFeedback(v);e(`deepLink ?${Se.param}=${v} ${M?"focused":"did not match a visible feedback"}`);}}catch(v){e("deepLink parsing failed:",v);}}).catch(h=>{e("Failed to load initial markers:",h);}),t.endpoint&&It(t.endpoint,t.identity??De()).then(()=>e("Retry queue flushed")).catch(()=>{});let We=()=>{let h=++ne;if(E?.isCurrentlyOpen)return E.refresh();let m=a(),v=s?{limit:20,url:m.url}:{limit:20};return y.getFeedbacks(t.projectName,v).then(({feedbacks:M})=>{if(C||h!==ne||E?.isCurrentlyOpen)return;let O=s?M.filter(B=>B.url===m.url):M;g.render(O);})},Ue=null;if(t.watchNavigation!==false&&typeof window<"u"&&typeof history<"u"){let h=L=>`${L.url}
1557
+ ${L.urlPattern??""}`,m=h(ke),v=()=>{if(C)return;let L=h(a());if(L===m)return;let K=m;m=L,e("SPA navigation detected \u2014 refreshing feedbacks for new scope"),We().catch(()=>{m===L&&(m=K);});},M=history.pushState,O=history.replaceState,B=function(...L){M.apply(this,L),v();},P=function(...L){O.apply(this,L),v();};history.pushState=B,history.replaceState=P,window.addEventListener("popstate",v),window.addEventListener("hashchange",v),Ue=()=>{window.removeEventListener("popstate",v),window.removeEventListener("hashchange",v),history.pushState===B&&(history.pushState=M),history.replaceState===P&&(history.replaceState=O);};}return te={destroy:()=>{e("Destroying widget"),C=true,$=false,Ue?.(),qt(),Yt(),R.destroy(),E?.destroy(),qe.destroy(),g.destroy(),S.destroy(),c?.dispose(),d?.dispose(),p.removeAll(),f.removeAll(),w$1.remove(),A.remove(),te=null;},open:()=>{p.emit("panel:toggle",true);},close:()=>{E?E.close():$=false;},focusFeedback:h=>g.focusFeedback(h),refresh:()=>{We().catch(()=>{});},on:(h,m)=>f.on(h,m),off:(h,m)=>{f.off(h,m);}},te}function $n(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,o=t.host;o.parentNode&&o.parentNode.appendChild(o);let r=document.createElement("div");r.style.cssText=`
1558
1558
  position:fixed;inset:0;
1559
1559
  background:var(--sp-identity-overlay);
1560
1560
  backdrop-filter:blur(8px);
@@ -1574,5 +1574,5 @@ ${E.urlPattern??""}`,f=h(xe),y=()=>{if(k)return;let E=h(a());if(E===f)return;let
1574
1574
  transform:translateY(12px) scale(0.97);
1575
1575
  transition:transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
1576
1576
  -webkit-font-smoothing:antialiased;
1577
- `;let a=`sp-identity-title-${Date.now()}`;s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",a);let l=document.createElement("div");l.className="sp-identity-title",l.id=a,l.textContent=e("identity.title"),l.style.marginBottom="20px";let p=`sp-identity-name-${Date.now()}`,d=`sp-identity-email-${Date.now()}`,u=document.createElement("label");u.className="sp-input-label",u.textContent=e("identity.nameLabel"),u.setAttribute("for",p);let c=document.createElement("input");c.className="sp-input",c.id=p,c.type="text",c.placeholder=e("identity.namePlaceholder"),c.style.marginBottom="14px";let b=document.createElement("label");b.className="sp-input-label",b.textContent=e("identity.emailLabel"),b.setAttribute("for",d);let w=document.createElement("input");w.className="sp-input",w.id=d,w.type="email",w.placeholder=e("identity.emailPlaceholder");let L=document.createElement("div");L.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let I=T=>{r.removeEventListener("keydown",S),r.style.opacity="0",s.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{r.remove(),i?.focus(),n(T);},250);},H=document.createElement("button");H.className="sp-btn-ghost",H.textContent=e("identity.cancel"),H.addEventListener("click",()=>I(null));let A=document.createElement("button");A.className="sp-btn-primary",A.textContent=e("identity.submit"),A.addEventListener("click",()=>{let T=c.value.trim(),g=w.value.trim();if(!T||!g)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(g)){w.style.borderColor="var(--sp-type-bug, #ef4444)";return}I({name:T,email:g});});let ze='input, button, [tabindex]:not([tabindex="-1"])',S=T=>{let g=T;if(g.key==="Escape"){I(null);return}if(g.key==="Tab"){let R=Array.from(s.querySelectorAll(ze));if(R.length===0)return;let x=R[0],N=R[R.length-1];if(!x||!N)return;let k=t.activeElement;g.shiftKey?(k===x||!s.contains(k))&&(g.preventDefault(),N.focus()):(k===N||!s.contains(k))&&(g.preventDefault(),x.focus());}};r.addEventListener("keydown",S),r.addEventListener("click",T=>{T.target===r&&I(null);}),L.appendChild(H),L.appendChild(A),s.appendChild(l),s.appendChild(u),s.appendChild(c),s.appendChild(b),s.appendChild(w),s.appendChild(L),r.appendChild(s),t.appendChild(r),requestAnimationFrame(()=>{r.style.opacity="1",s.style.transform="translateY(0) scale(1)",c.focus();});})}function Qi(t){return Bt(t)}export{Qi as initSiteping};//# sourceMappingURL=index.js.map
1577
+ `;let a=`sp-identity-title-${Date.now()}`;s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",a);let l=document.createElement("div");l.className="sp-identity-title",l.id=a,l.textContent=e("identity.title"),l.style.marginBottom="20px";let c=`sp-identity-name-${Date.now()}`,d=`sp-identity-email-${Date.now()}`,u=document.createElement("label");u.className="sp-input-label",u.textContent=e("identity.nameLabel"),u.setAttribute("for",c);let p=document.createElement("input");p.className="sp-input",p.id=c,p.type="text",p.placeholder=e("identity.namePlaceholder"),p.style.marginBottom="14px";let f=document.createElement("label");f.className="sp-input-label",f.textContent=e("identity.emailLabel"),f.setAttribute("for",d);let y=document.createElement("input");y.className="sp-input",y.id=d,y.type="email",y.placeholder=e("identity.emailPlaceholder");let A=document.createElement("div");A.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let k=S=>{r.removeEventListener("keydown",w),r.style.opacity="0",s.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{r.remove(),i?.focus(),n(S);},250);},F=document.createElement("button");F.className="sp-btn-ghost",F.textContent=e("identity.cancel"),F.addEventListener("click",()=>k(null));let T=document.createElement("button");T.className="sp-btn-primary",T.textContent=e("identity.submit"),T.addEventListener("click",()=>{let S=p.value.trim(),g=y.value.trim();if(!S||!g)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(g)){y.style.borderColor="var(--sp-type-bug, #ef4444)";return}k({name:S,email:g});});let X='input, button, [tabindex]:not([tabindex="-1"])',w=S=>{let g=S;if(g.key==="Escape"){k(null);return}if(g.key==="Tab"){let R=Array.from(s.querySelectorAll(X));if(R.length===0)return;let E=R[0],H=R[R.length-1];if(!E||!H)return;let C=t.activeElement;g.shiftKey?(C===E||!s.contains(C))&&(g.preventDefault(),H.focus()):(C===H||!s.contains(C))&&(g.preventDefault(),E.focus());}};r.addEventListener("keydown",w),r.addEventListener("click",S=>{S.target===r&&k(null);}),A.appendChild(F),A.appendChild(T),s.appendChild(l),s.appendChild(u),s.appendChild(p),s.appendChild(f),s.appendChild(y),s.appendChild(A),r.appendChild(s),t.appendChild(r),requestAnimationFrame(()=>{r.style.opacity="1",s.style.transform="translateY(0) scale(1)",p.focus();});})}function oo(t){return Kt(t)}export{oo as initSiteping};//# sourceMappingURL=index.js.map
1578
1578
  //# sourceMappingURL=index.js.map