@siteping/widget 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +50 -43
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +37 -30
- package/dist/index.js.map +1 -1
- package/dist/react.js +37 -30
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {G as
|
|
1
|
+
import {G,H as H$1,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,g,h,j as j$1,i,a,f,k as k$1,B,D,C,A,n,o,p,q as q$1,E}from'./chunk-EF2HNCBX.js';var k,Ce,ht;function ft(t,e){if(ht=new Date,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:o=>true,className:o=>true,tagName:o=>true,attr:(o,s)=>false,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};k={...n,...e},Ce=Ut(k.root,n);let i=J(t,"all",()=>J(t,"two",()=>J(t,"one",()=>J(t,"none"))));if(i){let o=gt(yt(i,t));return o.length>0&&(i=o[0]),ee(i)}else throw new Error("Selector was not found.")}function Ut(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function J(t,e,n){let i=null,o=[],s=t,r=0;for(;s;){let a=new Date().getTime()-ht.getTime();if(k.timeoutMs!==void 0&&a>k.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${a}ms`);let l=Q(Wt(s))||Q(...Gt(s))||Q(...Vt(s))||Q(Jt(s))||[ut()],p=Zt(s);if(e=="all")p&&(l=l.concat(l.filter(Te).map(d=>Z(d,p))));else if(e=="two")l=l.slice(0,1),p&&(l=l.concat(l.filter(Te).map(d=>Z(d,p))));else if(e=="one"){let[d]=l=l.slice(0,1);p&&Te(d)&&(l=[Z(d,p)]);}else e=="none"&&(l=[ut()],p&&(l=[Z(l[0],p)]));for(let d of l)d.level=r;if(o.push(l),o.length>=k.seedMinLength&&(i=ct(o,n),i))break;s=s.parentElement,r++;}return i||(i=ct(o,n)),!i&&n?n():i}function ct(t,e){let n=gt(bt(t));if(n.length>k.threshold)return e?e():null;for(let i of n)if(mt(i))return i;return null}function ee(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 dt(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function mt(t){let e=ee(t);switch(Ce.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return true;default:return false}}function Wt(t){let e=t.getAttribute("id");return e&&k.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Gt(t){return Array.from(t.attributes).filter(n=>k.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Vt(t){return Array.from(t.classList).filter(k.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Jt(t){let e=t.tagName.toLowerCase();return k.tagName(e)?{name:e,penalty:2}:null}function ut(){return {name:"*",penalty:3}}function Zt(t){let e=t.parentNode;if(!e)return null;let n=e.firstChild;if(!n)return null;let i=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&i++,n!==t);)n=n.nextSibling;return i}function Z(t,e){return {name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function Te(t){return t.name!=="html"&&!t.name.startsWith("#")}function Q(...t){let e=t.filter(Qt);return e.length>0?e:null}function Qt(t){return t!=null}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 gt(t){return [...t].sort((e,n)=>dt(e)-dt(n))}function*yt(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>k.optimizedMinLength)for(let i=1;i<t.length-1;i++){if(n.counter>k.maxNumberOfTries)return;n.counter+=1;let o=[...t];o.splice(i,1);let s=ee(o);if(n.visited.has(s))return;mt(o)&&en(o,e)&&(yield o,n.visited.set(s,true),yield*yt(o,e,n));}}function en(t,e){return Ce.querySelector(ee(t))===e}var tn=["role","aria-label","type","name","href","src","data-testid","data-id"];function nn(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 Ae(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let r of i.children){if(r===t)break;r.tagName===t.tagName&&n++;}let o=[];for(let r of tn){let a=t.getAttribute(r);a&&o.push(`${r}=${a}`);}let s=o.length>0?nn(o.join(",")):"0";return `${e}:${n}:${s}`}function vt(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,o,s]=n,r=Number(i),a=Number(o);if(Number.isNaN(r)||Number.isNaN(a))return 0;let l=Ae(t),[p,d,c]=l.split(":"),h=0,m=Math.abs(Number(p)-r);m===0?h+=.2:m<=2?h+=.1:m<=5&&(h+=.03);let x=Math.abs(Number(d)-a);return x===0?h+=.4:x===1?h+=.2:x<=3&&(h+=.08),c===s&&(h+=.4),h}function H(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],o=3;for(;i&&o>0;){let s=i.textContent?.trim();if(s)return e==="before"?s.slice(-32):s.slice(0,32);i=i[n],o--;}return ""}function te(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 xt(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 r=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${i}[@id=${r}]`),"/"+e.join("")}let s=1;if(o)for(let r of o.children){if(r===n)break;r.localName===i&&s++;}e.unshift(`/${i}[${s}]`),n=o;}return "/html/body"+e.join("")}var z="data-feedback-anchor";function Le(t){let e=ft(t,{className:c=>!/^(css|sc|emotion|styled)-/.test(c)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(c),attr:c=>["data-testid","data-id","role","aria-label"].includes(c),idName:c=>!c.startsWith("radix-")&&!/^:r[0-9]+:$/.test(c),seedMinLength:3,optimizedMinLength:2}),n=xt(t),o=(t.textContent?.trim()??"").slice(0,120),s=H(t,"before"),r=H(t,"after"),a=Ae(t),l=te(t),d=t.closest(`[${z}]`)?.getAttribute(z)??null;return {cssSelector:e,xpath:n,textSnippet:o,textPrefix:s,textSuffix:r,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:d}}function wt(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 Et(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 s=o;for(;s&&s!==document.body;){if(s.hasAttribute(z)&&wt(s,t))return s;s=s.parentElement;}for(s=o;s&&s!==document.body;){if(wt(s,t))return s;s=s.parentElement;}return document.body}function kt(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 on={question:"type.question",change:"type.change",bug:"type.bug",other:"type.other"};function sn(){let t=navigator.userAgentData;return t?t.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent)}var ne=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;
|
|
@@ -15,7 +15,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
|
|
|
15
15
|
transition:opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
|
16
16
|
display:none;
|
|
17
17
|
-webkit-font-smoothing:antialiased;
|
|
18
|
-
`}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("
|
|
18
|
+
`}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("data-siteping-ignore","true");let i=[{type:"question",icon:n},{type:"change",icon:o},{type:"bug",icon:p},{type:"other",icon:q$1}];this.typeRow=b("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let s of i){let r=document.createElement("button");r.style.cssText=`
|
|
19
19
|
height:44px;
|
|
20
20
|
border-radius:9999px;border:1px solid ${this.colors.border};
|
|
21
21
|
background:${this.colors.glassBg};cursor:pointer;
|
|
@@ -24,7 +24,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
|
|
|
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
|
|
27
|
+
`;let a$1=a(s.icon);a$1.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),r.appendChild(a$1),r.appendChild(document.createElement("span")),r.dataset.type=s.type,r.setAttribute("aria-pressed","false"),r.addEventListener("click",()=>{this.submittingState||this.selectType(s.type,this.typeRow);}),r.addEventListener("mouseenter",()=>{if(!this.submittingState&&r.dataset.type!==this.selectedType){let l=y(r.dataset.type??"",this.colors);r.style.background=l,r.style.borderColor=x(r.dataset.type??"",this.colors)+"40";}}),r.addEventListener("mouseleave",()=>{this.submittingState||r.dataset.type!==this.selectedType&&(r.style.background=this.colors.glassBg,r.style.borderColor=this.colors.border);}),this.typeRow.appendChild(r);}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};
|
|
@@ -33,19 +33,19 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
|
|
|
33
33
|
font-size:13px;line-height:1.5;resize:vertical;
|
|
34
34
|
outline:none;transition:all 0.2s ease;
|
|
35
35
|
box-sizing:border-box;
|
|
36
|
-
`,this.textarea.
|
|
36
|
+
`,this.textarea.maxLength=5e3,this.hint=b("div",{style:`
|
|
37
37
|
font-size:11px;color:${this.colors.textTertiary};
|
|
38
38
|
text-align:right;margin-top:4px;
|
|
39
39
|
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
40
40
|
letter-spacing:0.01em;
|
|
41
|
-
`}),
|
|
41
|
+
`}),this.textarea.addEventListener("focus",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.accent,this.textarea.style.boxShadow=`0 0 0 3px ${this.colors.accent}14`,this.textarea.style.background=this.colors.bg);}),this.textarea.addEventListener("blur",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.border,this.textarea.style.boxShadow="none",this.textarea.style.background=this.colors.glassBgHeavy);}),this.textarea.addEventListener("input",()=>{this.updateSubmitState();}),this.textarea.addEventListener("keydown",s=>{this.submittingState||(s.key==="Enter"&&(s.ctrlKey||s.metaKey)&&(s.preventDefault(),this.submit()),s.key==="Escape"&&this.cancel());});let o$1=b("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"});this.cancelBtn=document.createElement("button"),this.cancelBtn.style.cssText=`
|
|
42
42
|
height:34px;padding:0 16px;border-radius:9999px;
|
|
43
43
|
border:1px solid ${this.colors.border};
|
|
44
44
|
background:${this.colors.glassBg};
|
|
45
45
|
color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
46
46
|
font-size:13px;font-weight:500;cursor:pointer;
|
|
47
47
|
transition:all 0.2s ease;
|
|
48
|
-
`,
|
|
48
|
+
`,this.cancelBtn.addEventListener("click",()=>this.cancel()),this.cancelBtn.addEventListener("mouseenter",()=>{this.submittingState||(this.cancelBtn.style.borderColor=this.colors.accent,this.cancelBtn.style.color=this.colors.accent);}),this.cancelBtn.addEventListener("mouseleave",()=>{this.submittingState||(this.cancelBtn.style.borderColor=this.colors.border,this.cancelBtn.style.color=this.colors.textTertiary);}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`
|
|
49
49
|
height:34px;padding:0 18px;border-radius:9999px;
|
|
50
50
|
border:none;background:${this.colors.accentGradient};
|
|
51
51
|
color:#fff;font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
@@ -53,7 +53,14 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
|
|
|
53
53
|
opacity:0.35;pointer-events:none;
|
|
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=on[i];if(!o)continue;let s=n.querySelector("span");s&&c(s,this.t(o));}this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria")),c(this.hint,sn()?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,s=300,r=e.bottom+8,a=e.left;if(r+o>window.innerHeight){let p=e.top-o-8;p>=8?r=p:r=window.innerHeight-o-8;}a+s>window.innerWidth&&(a=e.right-s),a=Math.max(8,a),r=Math.max(8,r),this.root.style.top=`${r}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 c=d[0],h=d[d.length-1];if(!c||!h)return;p.shiftKey?(document.activeElement===c||!this.root.contains(document.activeElement))&&(p.preventDefault(),h.focus()):(document.activeElement===h||!this.root.contains(document.activeElement))&&(p.preventDefault(),c.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 s=o.dataset.type===e,r=x(o.dataset.type??"",this.colors),a=y(o.dataset.type??"",this.colors);o.style.background=s?a:this.colors.glassBg,o.style.borderColor=s?r+"60":this.colors.border,o.style.color=s?r:this.colors.textTertiary,o.style.fontWeight=s?"600":"500",o.setAttribute("aria-pressed",String(s));}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
|
+
width:14px;height:14px;
|
|
59
|
+
border:2px solid rgba(255,255,255,0.35);
|
|
60
|
+
border-top-color:#fff;
|
|
61
|
+
border-radius:50%;
|
|
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 j,St=false;async function rn(){if(j!==void 0)return j;try{let t=await import('html2canvas');return j=t.default??t,j}catch(t){return j=null,St||(St=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 Tt(t,e){let n=await rn();if(!n)return null;let i=.85,o=1200;try{let s=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:c=>c.tagName==="SITEPING-WIDGET"||c.closest?.("siteping-widget")!==null||c.getAttribute?.("data-siteping-ignore")==="true"});if(s.width<=o)return s.toDataURL("image/jpeg",i);let r=o/s.width,a=o,l=Math.round(s.height*r),p=document.createElement("canvas");p.width=a,p.height=l;let d=p.getContext("2d");return d?(d.drawImage(s,0,0,a,l),p.toDataURL("image/jpeg",i)):null}catch(s){return console.warn("[siteping] Screenshot capture failed:",s),null}}var ie=class{constructor(e,n,i,o=false){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.popup=new ne(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?Tt(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:`
|
|
57
64
|
position:fixed;inset:0;
|
|
58
65
|
z-index:${2147483646};
|
|
59
66
|
background:rgba(15, 23, 42, 0.04);
|
|
@@ -83,7 +90,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
|
|
|
83
90
|
color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
84
91
|
font-size:13px;font-weight:500;cursor:pointer;
|
|
85
92
|
transition:all 0.2s ease;
|
|
86
|
-
`,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);}deactivate(){this.isActive&&(this.isActive=false,this.isDrawing=false,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,this.bus.emit("annotation:end"));}onKeyDown=e=>{e.key==="Escape"&&this.deactivate();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"
|
|
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);}deactivate(){this.isActive&&(this.isActive=false,this.isDrawing=false,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,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),r={anchor:Le(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(r,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:`
|
|
87
94
|
position:fixed;
|
|
88
95
|
border:2px solid ${this.colors.accent};
|
|
89
96
|
background:${this.colors.accent}12;
|
|
@@ -91,8 +98,8 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
|
|
|
91
98
|
border-radius:8px;
|
|
92
99
|
box-shadow:0 0 16px ${this.colors.accentGlow};
|
|
93
100
|
transition:box-shadow 0.15s ease;
|
|
94
|
-
`}),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),s=Math.abs(n.clientX-this.startX),r=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${o}px`,this.drawingRect.style.width=`${s}px`,this.drawingRect.style.height=`${r}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),s=Math.abs(e-this.startX),r=Math.abs(n-this.startY);if(s<10||r<10){this.drawingRect.remove(),this.drawingRect=null;return}let
|
|
95
|
-
${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 dn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=cn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var ae=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 pn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,s=function(...r){try{o.push(n,r);}catch{}i.apply(this??console,r);};try{Object.defineProperty(s,"name",{value:n});}catch{}console[n]=s;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:dn(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 Lt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Mt(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 le=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 s=new Date,r=typeof performance<"u"?performance.now():Date.now(),p=Lt(Mt(i)),a=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,o);if(!c.ok){let l=typeof performance<"u"?performance.now():Date.now();this.push({url:p,method:a,status:c.status,durationMs:Math.round(l-r),timestamp:s.toISOString()});}return c}catch(c){let l=typeof performance<"u"?performance.now():Date.now();throw this.push({url:p,method:a,status:0,durationMs:Math.round(l-r),timestamp:s.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,s=new WeakMap;e.open=function(r,p,...a){try{s.set(this,{method:r.toUpperCase(),url:Lt(Mt(p)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,r,p,...a)},e.send=function(r){let p=s.get(this);if(p){let a=()=>{try{let c=typeof performance<"u"?performance.now():Date.now(),l=this.status;(l===0||l>=400)&&o.push({url:p.url,method:p.method,status:l,durationMs:Math.round(c-p.t0),timestamp:p.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",a,{once:!0});}catch{try{this.addEventListener("loadend",a);}catch{}}}return i.call(this,r??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(s){console.error(`[siteping] Error in event listener for "${String(e)}":`,s);}}removeAll(){this.listeners.clear();}};var un=54,pe=class{constructor(e,n,i$1,o){this.bus=i$1;this.t=o;let s=n.position??"bottom-right",r=s==="bottom-right";this.items=[{id:"chat",icon:g,label:o("fab.messages")},{id:"annotate",icon:h,label:o("fab.annotate")},{id:"toggle-annotations",icon:i,iconAlt:j$1,label:o("fab.annotations")}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${s} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-label",o("fab.aria")),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${s}`,this.radialContainer.setAttribute("role","menu");for(let c=0;c<this.items.length;c++){let l=this.items[c];if(!l)continue;let d=document.createElement("button");d.className="sp-radial-item",d.style.setProperty("--sp-i",String(c)),d.appendChild(a(l.icon)),d.setAttribute("role","menuitem"),d.setAttribute("aria-label",l.label),d.dataset.itemId=l.id,d.addEventListener("click",f=>{f.stopPropagation(),this.handleItemClick(l.id);});let h=document.createElement("span");h.className="sp-radial-label",h.textContent=l.label,h.style.cssText=r?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",d.appendChild(h),this.radialContainer.appendChild(d);}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root);let p=e.host;this.onDocumentClick=c=>{this.isOpen&&!c.composedPath().includes(p)&&this.close();},document.addEventListener("click",this.onDocumentClick);let a$1=c=>{c.key==="Escape"&&this.isOpen&&(c.stopPropagation(),this.close());};this.fab.addEventListener("keydown",a$1),this.radialContainer.addEventListener("keydown",a$1),this.radialContainer.addEventListener("keydown",c=>{let l=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(l.length===0||!this.isOpen)return;let d=e.activeElement??document.activeElement,h=l.indexOf(d);switch(c.key){case "ArrowUp":{c.preventDefault();let f=h<=0?l.length-1:h-1;l[f]?.focus();break}case "ArrowDown":{c.preventDefault();let f=h>=l.length-1?0:h+1;l[f]?.focus();break}case "Home":{c.preventDefault(),l[0]?.focus();break}case "End":{c.preventDefault(),l[l.length-1]?.focus();break}}});}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;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(k),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+un*(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":this.bus.emit("annotation:start");break;case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let n=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]');n&&n.replaceChildren(a(this.annotationsVisible?i:j$1));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var Ft="siteping_identity";function hn(t){if(!E$1(t,"name")||!E$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 Fe(){try{let t=localStorage.getItem(Ft);if(!t)return null;let e=JSON.parse(t);return hn(e)?e:null}catch{return null}}function Pt(t){try{localStorage.setItem(Ft,JSON.stringify(t));}catch{}}function fn(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 r=t;t=e,e=r;}let n=t.length,i=e.length,o=new Array(n+1);for(let r=0;r<=n;r++)o[r]=r;let s=new Array(n+1);for(let r=1;r<=i;r++){s[0]=r;for(let a=1;a<=n;a++){let c=o[a-1]??0;s[a]=t[a-1]===e[r-1]?c:1+Math.min(c,o[a]??0,s[a-1]??0);}let p=o;o=s,s=p;}return o[n]??0}function $(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-fn(t,e)/n}function Pe(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let p=$(t,e);return p>=n?p:0}let o=0,s=t.length>500?t.slice(0,500):t,r=s.length-i;for(let p=0;p<=r;p++){let a=s.slice(p,p+i),c=$(a,e);if(c>o&&(o=c),o>=.95)break}return o>=n?o:0}var mn=300,bn=.3;function ce(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Pe(n,e.textSnippet,.5)>bn}function gn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${j}="${e}"]`);if(n&&ce(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&&ce(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&ce(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&&ce(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return yn(t)}function yn(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,s=Math.min(n.length,mn);for(let r=0;r<s;r++){let p=n[r];if(!p)continue;let a=vn(p,t);if(a>o&&(o=a,i=p,o>=.85))break}return !i||o<.4?null:{element:i,confidence:Math.min(o,.85),strategy:"scan"}}function vn(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=Pe(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=gt(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let s=0,r=0;if(e.textPrefix){let p=_(t,"before");s+=p?$(p,e.textPrefix):0,r++;}if(e.textSuffix){let p=_(t,"after");s+=p?$(p,e.textSuffix):0,r++;}r>0&&(n+=s/r*20);}if(e.neighborText){i+=20;let s=ne(t);n+=s?$(s,e.neighborText)*20:0;}return i>0?n/i:0}function de(t,e){let n=gn(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 Ie(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 ue(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var It=13;function Nt(t){return {top:t.top+window.scrollY-It,left:t.right+window.scrollX-It}}function W(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Dt=300,_t=200,xn=.7,wn=28,$t=32,he=class{constructor(e,n,i,o,s=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;this.liveRegion=s;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",r=>{this.container.style.display=r?"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(r=>{let p=false;for(let a of r)if(!(this.container.contains(a.target)||this.tooltip.contains(a.target))){p=true;break}p&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=r=>{this.container.contains(r.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;get count(){return this.entries.length}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:_t+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},_t));}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 s=n.feedback.annotations[i];if(!s)continue;let r=`${n.feedback.id}:${i}`;e.add(r);let a=this.anchorCache.get(r)?.deref(),c;if(a?.isConnected){let d=a.getBoundingClientRect(),h=ue(s);c={element:a,rect:new DOMRect(d.left+h.xPct*d.width,d.top+h.yPct*d.height,h.wPct*d.width,h.hPct*d.height),confidence:1,strategy:"css"};}else c=de(Ie(s),ue(s)),c?.element&&this.anchorCache.set(r,new WeakRef(c.element));if(!c){o.style.display="none";continue}let l=Nt(c.rect);n.baseTop=l.top,n.baseLeft=l.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);}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)));}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();}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let o of e.annotations){let s=de(Ie(o),ue(o));if(!s)continue;let r=Nt(s.rect);i.baseTop=r.top,i.baseLeft=r.left;let p=this.createMarker(n,e,r);this.applyConfidenceStyle(p,s.confidence,e),this.container.appendChild(p),i.elements.push(p);}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 s={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let r=i+1;r<e.length;r++){if(n.has(r))continue;let p=o.entry,a=e[r];if(!a)continue;let c=a.entry;Math.sqrt((p.baseLeft-c.baseLeft)**2+(p.baseTop-c.baseTop)**2)<wn&&(s.entries.push(c),s.elementIndices.push(a.elIdx),n.add(r));}this.clusters.push(s);}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,s=e.entries.length<=1;for(let r=0;r<e.entries.length;r++){let p=W(e,r);p&&(p.style.top=`${i+(s?0:r*3)}px`,p.style.left=`${o+(s?0:r*3)}px`,p.style.zIndex=String(r+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,s=e.entries.length,r=(s-1)*$t,p=o-r/2;for(let a=0;a<s;a++){let c=W(e,a);c&&(c.style.top=`${i}px`,c.style.left=`${p+a*$t}px`,c.style.zIndex=String(10+a));}}addClusterBadge(e){let n=W(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
|
|
101
|
+
`}),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),s=Math.abs(n.clientX-this.startX),r=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${o}px`,this.drawingRect.style.width=`${s}px`,this.drawingRect.style.height=`${r}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),s=Math.abs(e-this.startX),r=Math.abs(n-this.startY);if(s<10||r<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(i,o,s,r),l=this.buildAnnotation(a),p={},d=await this.popup.show(a,c=>this.runSubmission(l,c,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 s=o.value;await new Promise((r,a)=>{let l=()=>{p(),d(),c(),this.rejectPendingSubmission=null;},p=this.bus.on("feedback:sent",()=>{l(),r();}),d=this.bus.on("feedback:error",h=>{l(),a(h);}),c=this.bus.on("submission:cancelled",()=>{l(),a(new Error("Feedback submission cancelled"));});this.rejectPendingSubmission=h=>{l(),a(h);},this.bus.emit("annotation:complete",{annotation:e,type:n.type,message:n.message,screenshotDataUrl:s});});}buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=Et(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Le(n),o=n.getBoundingClientRect(),s=kt(e,o);return {anchor:i,rect:s,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 X(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 K(t,e){if(t instanceof B)return t;let n=t instanceof Error?t.message:String(t);return new B(`${e}: ${n}`)}var an=3,ln=1e4,oe="siteping_retry_queue",pn=20;async function q(t,e,n=an){for(let i=0;i<=n;i++){let o=new AbortController,s=setTimeout(()=>o.abort(),ln);try{let l=await fetch(t,{...e,signal:o.signal});if(clearTimeout(s),l.ok||l.status>=400&&l.status<500||i===n)return l}catch(l){if(clearTimeout(s),i===n)throw l}let r=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,r+a));}throw new Error("Max retries exceeded")}var cn="siteping_retry_queue";async function Lt(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(cn,()=>t()):t()}function Rt(){let t=localStorage.getItem(oe);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}function dn(t,e){Lt(()=>{try{let n=Rt();n.length>=pn&&n.shift(),n.push({endpoint:t,payload:e}),localStorage.setItem(oe,JSON.stringify(n));}catch{}});}function Ct(t){return t.trim()}function At(t){return t.trim().toLowerCase()}async function Mt(t,e){await Lt(async()=>{try{let n=Rt();if(n.length===0)return;let i=[],o=[],s=0;for(let l of n){if(l.endpoint!==t){o.push(l);continue}!e||Ct(l.payload.authorName)===Ct(e.name)&&At(l.payload.authorEmail)===At(e.email)?i.push(l):s+=1;}if(i.length===0&&s===0)return;s>0;let r=[];for(let l of i)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l.payload)})).ok||r.push(l);}catch{r.push(l);}let a=o.concat(r);a.length>0?localStorage.setItem(oe,JSON.stringify(a)):localStorage.removeItem(oe);}catch{}});}async function Re(t){return await t.json()}var se=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){try{let n;try{n=await q(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(i){throw K(i,"Failed to send feedback")}if(!n.ok)throw await X(n,"Failed to send feedback");return Re(n)}catch(n){throw dn(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 q(`${this.endpoint}?${i.toString()}`,{method:"GET",cache:"no-store"});}catch(s){throw K(s,"Failed to fetch feedbacks")}if(!o.ok)throw await X(o,"Failed to fetch feedbacks");return Re(o)}async resolveFeedback(e,n){let i;try{i=await q(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(o){throw K(o,"Failed to update feedback")}if(!i.ok)throw await X(i,"Failed to update feedback");return Re(i)}async deleteFeedback(e){let n;try{n=await q(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(i){throw K(i,"Failed to delete feedback")}if(!n.ok)throw await X(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await q(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(i){throw K(i,"Failed to delete all feedbacks")}if(!n.ok)throw await X(n,"Failed to delete all feedbacks")}};var un=["log","info","warn","error"];function hn(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 fn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=hn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var re=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 un){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,s=function(...r){try{o.push(n,r);}catch{}i.apply(this??console,r);};try{Object.defineProperty(s,"name",{value:n});}catch{}console[n]=s;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:fn(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 Pt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Ft(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 ae=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 s=new Date,r=typeof performance<"u"?performance.now():Date.now(),a=Pt(Ft(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-r),timestamp:s.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-r),timestamp:s.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,s=new WeakMap;e.open=function(r,a,...l){try{s.set(this,{method:r.toUpperCase(),url:Pt(Ft(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,r,a,...l)},e.send=function(r){let a=s.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,r??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 Y=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(s){console.error(`[siteping] Error in event listener for "${String(e)}":`,s);}}removeAll(){this.listeners.clear();}};var mn=54,bn={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},le=class{constructor(e,n,i$1,o){this.bus=i$1;this.t=o;let s=n.position??"bottom-right",r=s==="bottom-right";this.items=[{id:"chat",icon:g},{id:"annotate",icon:h},{id:"toggle-annotations",icon:i,iconAlt:j$1}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${s} 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--${s}`,this.radialContainer.setAttribute("role","menu");for(let p=0;p<this.items.length;p++){let d=this.items[p];if(!d)continue;let c=document.createElement("button");c.className="sp-radial-item",c.style.setProperty("--sp-i",String(p)),c.appendChild(a(d.icon)),c.setAttribute("role","menuitem"),c.dataset.itemId=d.id,c.addEventListener("click",m=>{m.stopPropagation(),this.handleItemClick(d.id);});let h=document.createElement("span");h.className="sp-radial-label",h.style.cssText=r?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",c.appendChild(h),this.radialContainer.appendChild(c);}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 c=e.activeElement??document.activeElement,h=d.indexOf(c);switch(p.key){case "ArrowUp":{p.preventDefault();let m=h<=0?d.length-1:h-1;d[m]?.focus();break}case "ArrowDown":{p.preventDefault();let m=h>=d.length-1?0:h+1;d[m]?.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=bn[i];if(!o)continue;let s=this.t(o);n.setAttribute("aria-label",s);let r=n.querySelector(".sp-radial-label");r&&c(r,s);}}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(k$1),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+mn*(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":this.bus.emit("annotation:start");break;case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let n=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]');n&&n.replaceChildren(a(this.annotationsVisible?i:j$1));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var It="siteping_identity";function gn(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 Me(){try{let t=localStorage.getItem(It);if(!t)return null;let e=JSON.parse(t);return gn(e)?e:null}catch{return null}}function Dt(t){try{localStorage.setItem(It,JSON.stringify(t));}catch{}}function yn(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 r=t;t=e,e=r;}let n=t.length,i=e.length,o=new Array(n+1);for(let r=0;r<=n;r++)o[r]=r;let s=new Array(n+1);for(let r=1;r<=i;r++){s[0]=r;for(let l=1;l<=n;l++){let p=o[l-1]??0;s[l]=t[l-1]===e[r-1]?p:1+Math.min(p,o[l]??0,s[l-1]??0);}let a=o;o=s,s=a;}return o[n]??0}function $(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-yn(t,e)/n}function Pe(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=$(t,e);return a>=n?a:0}let o=0,s=t.length>500?t.slice(0,500):t,r=s.length-i;for(let a=0;a<=r;a++){let l=s.slice(a,a+i),p=$(l,e);if(p>o&&(o=p),o>=.95)break}return o>=n?o:0}var vn=300,xn=.3;function pe(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Pe(n,e.textSnippet,.5)>xn}function wn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${z}="${e}"]`);if(n&&pe(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&&pe(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&pe(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&&pe(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return En(t)}function En(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,s=Math.min(n.length,vn);for(let r=0;r<s;r++){let a=n[r];if(!a)continue;let l=kn(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 kn(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=Pe(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=vt(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let s=0,r=0;if(e.textPrefix){let a=H(t,"before");s+=a?$(a,e.textPrefix):0,r++;}if(e.textSuffix){let a=H(t,"after");s+=a?$(a,e.textSuffix):0,r++;}r>0&&(n+=s/r*20);}if(e.neighborText){i+=20;let s=te(t);n+=s?$(s,e.neighborText)*20:0;}return i>0?n/i:0}function ce(t,e){let n=wn(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 Fe(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 de(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 U(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Ht=300,$t=200,Sn=.7,Tn=28,Ot=32,ue=class{constructor(e,n,i,o,s=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;this.liveRegion=s;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",r=>{this.container.style.display=r?"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(r=>{let a=false;for(let l of r)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=r=>{this.container.contains(r.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:$t+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},$t));}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 s=n.feedback.annotations[i];if(!s)continue;let r=`${n.feedback.id}:${i}`;e.add(r);let l=this.anchorCache.get(r)?.deref(),p;if(l?.isConnected){let c=l.getBoundingClientRect(),h=de(s);p={element:l,rect:new DOMRect(c.left+h.xPct*c.width,c.top+h.yPct*c.height,h.wPct*c.width,h.hPct*c.height),confidence:1,strategy:"css"};}else p=ce(Fe(s),de(s)),p?.element&&this.anchorCache.set(r,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 s=ce(Fe(o),de(o));if(!s)continue;let r=_t(s.rect);i.baseTop=r.top,i.baseLeft=r.left;let a=this.createMarker(n,e,r);this.applyConfidenceStyle(a,s.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 s={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let r=i+1;r<e.length;r++){if(n.has(r))continue;let a=o.entry,l=e[r];if(!l)continue;let p=l.entry;Math.sqrt((a.baseLeft-p.baseLeft)**2+(a.baseTop-p.baseTop)**2)<Tn&&(s.entries.push(p),s.elementIndices.push(l.elIdx),n.add(r));}this.clusters.push(s);}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,s=e.entries.length<=1;for(let r=0;r<e.entries.length;r++){let a=U(e,r);a&&(a.style.top=`${i+(s?0:r*3)}px`,a.style.left=`${o+(s?0:r*3)}px`,a.style.zIndex=String(r+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,s=e.entries.length,r=(s-1)*Ot,a=o-r/2;for(let l=0;l<s;l++){let p=U(e,l);p&&(p.style.top=`${i}px`,p.style.left=`${a+l*Ot}px`,p.style.zIndex=String(10+l));}}addClusterBadge(e){let n=U(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
|
|
96
103
|
position:absolute;top:-6px;right:-6px;
|
|
97
104
|
min-width:16px;height:16px;padding:0 4px;
|
|
98
105
|
border-radius:9999px;
|
|
@@ -103,7 +110,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
103
110
|
pointer-events:none;
|
|
104
111
|
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
105
112
|
line-height:1;
|
|
106
|
-
`});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=
|
|
113
|
+
`});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=U(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(U(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<Sn&&!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),s=n.status==="resolved",r=b("div",{style:`
|
|
107
114
|
position:absolute;
|
|
108
115
|
top:${i.top}px;
|
|
109
116
|
left:${i.left}px;
|
|
@@ -120,7 +127,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
120
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;
|
|
121
128
|
user-select:none;
|
|
122
129
|
-webkit-font-smoothing:antialiased;
|
|
123
|
-
`});r.dataset.feedbackId=n.id,r.setAttribute("tabindex","0"),r.setAttribute("role","button");let
|
|
130
|
+
`});r.dataset.feedbackId=n.id,r.setAttribute("tabindex","0"),r.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);r.setAttribute("aria-label",l),r.setAttribute("aria-describedby",this.tooltip.tooltipId),c(r,s?"\u2713":String(e)),r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.2)",r.style.boxShadow=s?"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,r.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow=s?"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();}),r.addEventListener("focus",()=>{this.tooltip.show(n,r.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),r.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let p=d=>{d instanceof MouseEvent&&this.handleClusterClick(r,d)||(this.pinHighlight(n),this.bus.emit("panel:toggle",true),r.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:true})));};return r.addEventListener("click",d=>p(d)),r.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),p(d));}),r}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=ce(Fe(n),de(n));if(!i)continue;let o=x(e.type,this.colors),s=i.rect,r=b("div",{style:`
|
|
124
131
|
position:absolute;
|
|
125
132
|
top:${s.top+window.scrollY}px;
|
|
126
133
|
left:${s.left+window.scrollX}px;
|
|
@@ -131,8 +138,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
131
138
|
pointer-events:none;z-index:-1;
|
|
132
139
|
opacity:0;
|
|
133
140
|
box-shadow:0 0 16px ${o}20;
|
|
134
|
-
transition:opacity ${
|
|
135
|
-
`});this.container.appendChild(r),this.highlightElements.push(r),r.offsetHeight,r.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(),
|
|
141
|
+
transition:opacity ${Ht}ms ease;
|
|
142
|
+
`});this.container.appendChild(r),this.highlightElements.push(r),r.offsetHeight,r.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(),Ht);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 he=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 Ie(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(Ie),total:o}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return Ie(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function Ie(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(Cn),screenshotUrl:t.screenshotUrl??null,diagnostics:t.diagnostics??null}}function Cn(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 An="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)",De="cubic-bezier(0.16, 1, 0.3, 1)",Ne="cubic-bezier(0.34, 1.56, 0.64, 1)",Ln="cubic-bezier(0.25, 1, 0.5, 1)",Bt=`
|
|
136
143
|
/* ---- Keyframes ---- */
|
|
137
144
|
|
|
138
145
|
@keyframes sp-fab-in {
|
|
@@ -206,11 +213,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
206
213
|
/* ---- Animation classes ---- */
|
|
207
214
|
|
|
208
215
|
.sp-anim-fab-in {
|
|
209
|
-
animation: sp-fab-in 0.5s ${
|
|
216
|
+
animation: sp-fab-in 0.5s ${An} both;
|
|
210
217
|
}
|
|
211
218
|
|
|
212
219
|
.sp-anim-marker-in {
|
|
213
|
-
animation: sp-marker-in 0.35s ${
|
|
220
|
+
animation: sp-marker-in 0.35s ${Ne} both;
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
.sp-anim-pulse {
|
|
@@ -218,7 +225,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
218
225
|
}
|
|
219
226
|
|
|
220
227
|
.sp-anim-flash {
|
|
221
|
-
animation: sp-flash-bg 0.5s ${
|
|
228
|
+
animation: sp-flash-bg 0.5s ${Ln};
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
.sp-anim-slide-up {
|
|
@@ -245,7 +252,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
245
252
|
pointer-events: none;
|
|
246
253
|
transform: translate(0, 0) scale(0.8);
|
|
247
254
|
transition:
|
|
248
|
-
transform 0.35s ${
|
|
255
|
+
transform 0.35s ${Ne},
|
|
249
256
|
opacity 0.2s ease,
|
|
250
257
|
background 0.2s ease,
|
|
251
258
|
border-color 0.2s ease,
|
|
@@ -304,7 +311,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
304
311
|
}
|
|
305
312
|
|
|
306
313
|
.sp-fab-badge {
|
|
307
|
-
animation: sp-badge-in 0.4s ${
|
|
314
|
+
animation: sp-badge-in 0.4s ${Ne} both;
|
|
308
315
|
}
|
|
309
316
|
|
|
310
317
|
/* ---- Reduced motion ---- */
|
|
@@ -317,7 +324,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
317
324
|
}
|
|
318
325
|
}
|
|
319
326
|
|
|
320
|
-
`;function
|
|
327
|
+
`;function _e(t){return `
|
|
321
328
|
:host {
|
|
322
329
|
all: initial;
|
|
323
330
|
position: fixed;
|
|
@@ -328,7 +335,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
328
335
|
color: var(--sp-text);
|
|
329
336
|
-webkit-font-smoothing: antialiased;
|
|
330
337
|
-moz-osx-font-smoothing: grayscale;
|
|
331
|
-
${z(t)}
|
|
338
|
+
${z$1(t)}
|
|
332
339
|
|
|
333
340
|
/* Identity modal \u2014 theme-aware backdrop + panel */
|
|
334
341
|
--sp-identity-bg: ${t.glassBgHeavy};
|
|
@@ -1486,14 +1493,14 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1486
1493
|
}
|
|
1487
1494
|
}
|
|
1488
1495
|
|
|
1489
|
-
${
|
|
1496
|
+
${Bt}
|
|
1490
1497
|
${U$1}
|
|
1491
1498
|
${T}
|
|
1492
1499
|
${L}
|
|
1493
|
-
${J}
|
|
1500
|
+
${J$1}
|
|
1494
1501
|
${Y$1}
|
|
1495
1502
|
${N}
|
|
1496
|
-
`}var
|
|
1503
|
+
`}var Rn=120,Mn=80,fe=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
|
|
1497
1504
|
position: fixed;
|
|
1498
1505
|
z-index: ${2147483647};
|
|
1499
1506
|
max-width: 280px;
|
|
@@ -1519,12 +1526,12 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1519
1526
|
border: 1px solid ${this.colors.glassBorder};
|
|
1520
1527
|
transform: rotate(45deg);
|
|
1521
1528
|
pointer-events: none;
|
|
1522
|
-
`}),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)";},
|
|
1529
|
+
`}),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)";},Rn));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Mn);}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 c of n)c!==this.arrow&&c.remove();let i=x(e$1.type,this.colors),o=y(e$1.type,this.colors),s=H$1(this.locale),r=I(e$1.type,s),a=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=b("span",{style:`
|
|
1523
1530
|
padding:3px 10px;border-radius:9999px;
|
|
1524
1531
|
font-size:11px;font-weight:600;
|
|
1525
1532
|
color:${i};background:${o};
|
|
1526
1533
|
letter-spacing:0.02em;
|
|
1527
|
-
`});c(
|
|
1534
|
+
`});c(l,r);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,s=e.left+e.width/2-n.width/2,r=true;o<8&&(o=e.bottom+i,r=false),s=Math.max(8,Math.min(s,window.innerWidth-n.width-8)),this.root.style.top=`${o}px`,this.root.style.left=`${s}px`;let a=Math.max(16,Math.min(e.left+e.width/2-s-6,n.width-22));r?this.arrow.style.cssText=`
|
|
1528
1535
|
position:absolute;
|
|
1529
1536
|
width:12px;height:12px;
|
|
1530
1537
|
background:${this.colors.glassBgHeavy};
|
|
@@ -1533,7 +1540,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1533
1540
|
transform:rotate(45deg);
|
|
1534
1541
|
pointer-events:none;
|
|
1535
1542
|
bottom:-6px;
|
|
1536
|
-
left:${
|
|
1543
|
+
left:${a}px;
|
|
1537
1544
|
`:this.arrow.style.cssText=`
|
|
1538
1545
|
position:absolute;
|
|
1539
1546
|
width:12px;height:12px;
|
|
@@ -1543,8 +1550,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1543
1550
|
transform:rotate(45deg);
|
|
1544
1551
|
pointer-events:none;
|
|
1545
1552
|
top:-6px;
|
|
1546
|
-
left:${
|
|
1547
|
-
`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var
|
|
1553
|
+
left:${a}px;
|
|
1554
|
+
`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var W=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 me(){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 zt(t){let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(W)return e("initSiteping() called more than once \u2014 returning existing instance"),W;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),me()}catch{}if(window.innerWidth<768){let u="mobile";return t.onSkip?.(u),me()}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."),me();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),me();let n=t.locale??"en",i=n==="en"?Promise.resolve():G(n).catch(()=>{}),o=H$1(n),s=t.scopeAnnotationsByUrl??true,r=()=>{try{let u=t.getPageScope?.();if(u)return u}catch(u){e("getPageScope() threw, falling back to pathname:",u);}return {url:window.location.pathname,urlPattern:null}};e("Initializing widget",{projectName:t.projectName,theme:t.theme??"light",locale:n,scopeAnnotationsByUrl:s});let a=Fn(t.captureDiagnostics),l=a.console?new re(a.maxConsoleEntries):null,p=a.network?new ae(a.maxNetworkEntries):null,d=w(t.accentColor,t.theme),c=new Y,h=new Y,m=(()=>{if(t.store)return new he(t.store,t.projectName);let u=t.endpoint;if(typeof u!="string"||u.length===0)throw new Error("[siteping] internal invariant: endpoint must be a non-empty string in HTTP mode");return new se(u,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",u=>h.emit("feedback:sent",u)),c.on("feedback:deleted",u=>h.emit("feedback:deleted",u)),c.on("open",()=>h.emit("panel:open")),c.on("close",()=>h.emit("panel:close")),c.on("open",()=>e("Panel opened")),c.on("close",()=>e("Panel closed")),c.on("feedback:sent",u=>e("Feedback sent",u.id)),c.on("feedback:error",u=>e("Feedback failed",u.message)),c.on("annotation:start",()=>e("Annotation started")),c.on("annotation:end",()=>e("Annotation ended"));let x=document.createElement("siteping-widget");x.style.cssText=`position:fixed;z-index:${2147483647};`;let M=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(M=!0);}catch{}let D=M?"open":"closed",C=x.attachShadow({mode:D});if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;u.replaceSync(_e(d)),C.adoptedStyleSheets=[u];}else {let u=document.createElement("style");u.textContent=_e(d),C.appendChild(u);}document.body.appendChild(x);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 fe(d,n),b=new ue(d,S,c,o,w$1),A=new le(C,t,c,o);c.on("markers:changed",u=>A.updateBadge(u));let v=null,P=null,T=false;async function Oe(){return T?null:v||(P||(P=import('./panel-47WTS3KH.js').then(u=>T?null:(v=new u.Panel(C,d,c,m,t.projectName,b,o,n,{getScope:r,scopeAnnotationsByUrl:s}),v))),P)}if(typeof window<"u"){let u=()=>{T||Oe();},y=window.requestIdleCallback;typeof y=="function"?y(u):setTimeout(u,200);}let N=false,jt=c.on("panel:toggle",u=>{v||(u?(N=true,Oe().then(y=>{y&&N&&y.open(),N=false;}).catch(y=>e("Failed to lazy-load panel:",y))):N=false);}),Be=new ie(d,c,o,t.enableScreenshot??false);n!=="en"&&i.then(()=>{T||(A.refreshLabels(),Be.refreshLabels());});let be=false,Xt=c.on("annotation:complete",async u=>{if(be){c.emit("submission:cancelled");return}be=true;try{let{annotation:y,type:E,message:O,screenshotDataUrl:ye}=u,_=t.identity??Me();if(!_){if(_=await Dn(C,o),!_){c.emit("submission:cancelled");return}Dt(_);}let qt=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),ve=r(),je=null;(l||p)&&(je={console:l?.getEntries()??[],network:p?.getEntries()??[]});let Yt={projectName:t.projectName,type:E,message:O,url:ve.url,urlPattern:ve.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:_.name,authorEmail:_.email,annotations:[y],clientId:qt,screenshotDataUrl:ye??null,diagnostics:je};try{let F=await m.sendFeedback(Yt);c.emit("feedback:sent",F),(!s||F.url===ve.url)&&b.addFeedback(F,b.count+1),w$1.textContent=o("feedback.sent.confirmation"),v&&await v.refresh();}catch(F){c.emit("feedback:error",F instanceof Error?F:new Error(String(F))),w$1.textContent=o("feedback.error.message");}}finally{be=false;}}),ze=r(),Kt=s?{limit:20,url:ze.url}:{limit:20},ge=In(t.deepLink);return Promise.all([m.getFeedbacks(t.projectName,Kt),i]).then(([{feedbacks:u}])=>{if(T)return;let y=s?u.filter(E=>E.url===ze.url):u;if(b.render(y),ge.enabled)try{let E=new URLSearchParams(window.location.search).get(ge.param);if(E){let O=b.focusFeedback(E);e(`deepLink ?${ge.param}=${E} ${O?"focused":"did not match a visible feedback"}`);}}catch(E){e("deepLink parsing failed:",E);}}).catch(u=>{e("Failed to load initial markers:",u);}),t.endpoint&&Mt(t.endpoint,t.identity??Me()).then(()=>e("Retry queue flushed")).catch(()=>{}),W={destroy:()=>{e("Destroying widget"),T=true,N=false,Xt(),jt(),A.destroy(),v?.destroy(),Be.destroy(),b.destroy(),S.destroy(),l?.dispose(),p?.dispose(),c.removeAll(),h.removeAll(),w$1.remove(),x.remove(),W=null;},open:()=>{c.emit("panel:toggle",true);},close:()=>{v?v.close():N=false;},focusFeedback:u=>b.focusFeedback(u),refresh:()=>{if(v?.isCurrentlyOpen){v.refresh();return}let u=r(),y=s?{limit:20,url:u.url}:{limit:20};m.getFeedbacks(t.projectName,y).then(({feedbacks:E})=>{let O=s?E.filter(ye=>ye.url===u.url):E;b.render(O);}).catch(()=>{});},on:(u,y)=>h.on(u,y),off:(u,y)=>{h.off(u,y);}},W}function Dn(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,o=document.createElement("div");o.style.cssText=`
|
|
1548
1555
|
position:fixed;inset:0;
|
|
1549
1556
|
background:var(--sp-identity-overlay);
|
|
1550
1557
|
backdrop-filter:blur(8px);
|
|
@@ -1564,5 +1571,5 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1564
1571
|
transform:translateY(12px) scale(0.97);
|
|
1565
1572
|
transition:transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1566
1573
|
-webkit-font-smoothing:antialiased;
|
|
1567
|
-
`;let r=`sp-identity-title-${Date.now()}`;s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",r);let
|
|
1574
|
+
`;let r=`sp-identity-title-${Date.now()}`;s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",r);let a=document.createElement("div");a.className="sp-identity-title",a.id=r,a.textContent=e("identity.title"),a.style.marginBottom="20px";let l=`sp-identity-name-${Date.now()}`,p=`sp-identity-email-${Date.now()}`,d=document.createElement("label");d.className="sp-input-label",d.textContent=e("identity.nameLabel"),d.setAttribute("for",l);let c=document.createElement("input");c.className="sp-input",c.id=l,c.type="text",c.placeholder=e("identity.namePlaceholder"),c.style.marginBottom="14px";let h=document.createElement("label");h.className="sp-input-label",h.textContent=e("identity.emailLabel"),h.setAttribute("for",p);let m=document.createElement("input");m.className="sp-input",m.id=p,m.type="email",m.placeholder=e("identity.emailPlaceholder");let x=document.createElement("div");x.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let M=S=>{o.removeEventListener("keydown",w),o.style.opacity="0",s.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{o.remove(),i?.focus(),n(S);},250);},D=document.createElement("button");D.className="sp-btn-ghost",D.textContent=e("identity.cancel"),D.addEventListener("click",()=>M(null));let C=document.createElement("button");C.className="sp-btn-primary",C.textContent=e("identity.submit"),C.addEventListener("click",()=>{let S=c.value.trim(),b=m.value.trim();if(!S||!b)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b)){m.style.borderColor="var(--sp-type-bug, #ef4444)";return}M({name:S,email:b});});let $e='input, button, [tabindex]:not([tabindex="-1"])',w=S=>{let b=S;if(b.key==="Escape"){M(null);return}if(b.key==="Tab"){let A=Array.from(s.querySelectorAll($e));if(A.length===0)return;let v=A[0],P=A[A.length-1];if(!v||!P)return;let T=t.activeElement;b.shiftKey?(T===v||!s.contains(T))&&(b.preventDefault(),P.focus()):(T===P||!s.contains(T))&&(b.preventDefault(),v.focus());}};o.addEventListener("keydown",w),o.addEventListener("click",S=>{S.target===o&&M(null);}),x.appendChild(D),x.appendChild(C),s.appendChild(a),s.appendChild(d),s.appendChild(c),s.appendChild(h),s.appendChild(m),s.appendChild(x),o.appendChild(s),t.appendChild(o),requestAnimationFrame(()=>{o.style.opacity="1",s.style.transform="translateY(0) scale(1)",c.focus();});})}function Zi(t){return zt(t)}export{Zi as initSiteping};//# sourceMappingURL=index.js.map
|
|
1568
1575
|
//# sourceMappingURL=index.js.map
|