@siteping/widget 0.9.8 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/{chunk-OTJZRTBK.js → chunk-HHREBLKP.js} +43 -10
- package/dist/chunk-HHREBLKP.js.map +1 -0
- package/dist/index.global.js +74 -41
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +35 -35
- package/dist/index.js.map +1 -1
- package/dist/{panel-HDPPIATU.js → panel-OQ6MGCXK.js} +2 -2
- package/dist/{panel-HDPPIATU.js.map → panel-OQ6MGCXK.js.map} +1 -1
- package/dist/react.js +35 -35
- package/dist/react.js.map +1 -1
- package/dist/types.d.ts +60 -0
- package/package.json +1 -1
- package/dist/chunk-OTJZRTBK.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {A,B,w
|
|
1
|
+
import {A,B,w,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C as C$1,c,e,g,h,j,i,a,f,k as k$1,n,o,p,q as q$1}from'./chunk-HHREBLKP.js';import {useRef,useState,useEffect}from'react';var k,Fe,lt;function ct(t,e){if(lt=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,r)=>false,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};k={...n,...e},Fe=zt(k.root,n);let i=ie(t,"all",()=>ie(t,"two",()=>ie(t,"one",()=>ie(t,"none"))));if(i){let o=ut(ht(i,t));return o.length>0&&(i=o[0]),se(i)}else throw new Error("Selector was not found.")}function zt(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function ie(t,e,n){let i=null,o=[],r=t,s=0;for(;r;){let a=new Date().getTime()-lt.getTime();if(k.timeoutMs!==void 0&&a>k.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${a}ms`);let l=re(Kt(r))||re(...Xt(r))||re(...Ut(r))||re(Yt(r))||[at()],p=Wt(r);if(e=="all")p&&(l=l.concat(l.filter(Pe).map(c=>oe(c,p))));else if(e=="two")l=l.slice(0,1),p&&(l=l.concat(l.filter(Pe).map(c=>oe(c,p))));else if(e=="one"){let[c]=l=l.slice(0,1);p&&Pe(c)&&(l=[oe(c,p)]);}else e=="none"&&(l=[at()],p&&(l=[oe(l[0],p)]));for(let c of l)c.level=s;if(o.push(l),o.length>=k.seedMinLength&&(i=rt(o,n),i))break;r=r.parentElement,s++;}return i||(i=rt(o,n)),!i&&n?n():i}function rt(t,e){let n=ut(dt(t));if(n.length>k.threshold)return e?e():null;for(let i of n)if(pt(i))return i;return null}function se(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 st(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function pt(t){let e=se(t);switch(Fe.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 Kt(t){let e=t.getAttribute("id");return e&&k.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Xt(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 Ut(t){return Array.from(t.classList).filter(k.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Yt(t){let e=t.tagName.toLowerCase();return k.tagName(e)?{name:e,penalty:2}:null}function at(){return {name:"*",penalty:3}}function Wt(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 oe(t,e){return {name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function Pe(t){return t.name!=="html"&&!t.name.startsWith("#")}function re(...t){let e=t.filter(qt);return e.length>0?e:null}function qt(t){return t!=null}function*dt(t,e=[]){if(t.length>0)for(let n of t[0])yield*dt(t.slice(1,t.length),e.concat(n));else yield e;}function ut(t){return [...t].sort((e,n)=>st(e)-st(n))}function*ht(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 r=se(o);if(n.visited.has(r))return;pt(o)&&Gt(o,e)&&(yield o,n.visited.set(r,true),yield*ht(o,e,n));}}function Gt(t,e){return Fe.querySelector(se(t))===e}var Vt=["role","aria-label","type","name","href","src","data-testid","data-id"];function Jt(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 Re(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let s of i.children){if(s===t)break;s.tagName===t.tagName&&n++;}let o=[];for(let s of Vt){let a=t.getAttribute(s);a&&o.push(`${s}=${a}`);}let r=o.length>0?Jt(o.join(",")):"0";return `${e}:${n}:${r}`}function ft(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,o,r]=n,s=Number(i),a=Number(o);if(Number.isNaN(s)||Number.isNaN(a))return 0;let l=Re(t),[p,c,d]=l.split(":"),h=0,f=Math.abs(Number(p)-s);f===0?h+=.2:f<=2?h+=.1:f<=5&&(h+=.03);let v=Math.abs(Number(c)-a);return v===0?h+=.4:v===1?h+=.2:v<=3&&(h+=.08),d===r&&(h+=.4),h}function $(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],o=3;for(;i&&o>0;){let r=i.textContent?.trim();if(r)return e==="before"?r.slice(-32):r.slice(0,32);i=i[n],o--;}return ""}function ae(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 mt(t){if(t.id){let i=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return `//${t.localName}[@id=${i}]`}let e=[],n=t;for(;n&&n!==document.body&&e.length<6;){let i=n.localName,o=n.parentElement;if(n.id){let s=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${i}[@id=${s}]`),"/"+e.join("")}let r=1;if(o)for(let s of o.children){if(s===n)break;s.localName===i&&r++;}e.unshift(`/${i}[${r}]`),n=o;}return "/html/body"+e.join("")}var X="data-feedback-anchor";function Ie(t){let e=ct(t,{className:d=>!/^(css|sc|emotion|styled)-/.test(d)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(d),attr:d=>["data-testid","data-id","role","aria-label"].includes(d),idName:d=>!d.startsWith("radix-")&&!/^:r[0-9]+:$/.test(d),seedMinLength:3,optimizedMinLength:2}),n=mt(t),o=(t.textContent?.trim()??"").slice(0,120),r=$(t,"before"),s=$(t,"after"),a=Re(t),l=ae(t),c=t.closest(`[${X}]`)?.getAttribute(X)??null;return {cssSelector:e,xpath:n,textSnippet:o,textPrefix:r,textSuffix:s,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:c}}function gt(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 bt(t,e=document.documentElement){let n=t.x+t.width/2,i=t.y+t.height/2,o=document.elementFromPoint(n,i);if(!o||o===e)return document.body;let r=o;for(;r&&r!==document.body;){if(r.hasAttribute(X)&>(r,t))return r;r=r.parentElement;}for(r=o;r&&r!==document.body;){if(gt(r,t))return r;r=r.parentElement;}return document.body}function yt(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 le=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 {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
|
|
|
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("aria-label",this.t("popup.ariaLabel"));let
|
|
18
|
+
`}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("aria-label",this.t("popup.ariaLabel"));let i=[{type:"question",label:this.t("type.question"),icon:n},{type:"change",label:this.t("type.change"),icon:o},{type:"bug",label:this.t("type.bug"),icon:p},{type:"other",label:this.t("type.other"),icon:q$1}],o$1=b("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let c$1 of i){let d=document.createElement("button");d.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 {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
|
|
|
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 h=a(c$1.icon);h.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),d.appendChild(h);let f=document.createElement("span");c(f,c$1.label),d.appendChild(f),d.dataset.type=c$1.type,d.setAttribute("aria-pressed","false"),d.addEventListener("click",()=>{this.selectType(c$1.type,
|
|
27
|
+
`;let h=a(c$1.icon);h.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),d.appendChild(h);let f=document.createElement("span");c(f,c$1.label),d.appendChild(f),d.dataset.type=c$1.type,d.setAttribute("aria-pressed","false"),d.addEventListener("click",()=>{this.selectType(c$1.type,o$1);}),d.addEventListener("mouseenter",()=>{if(d.dataset.type!==this.selectedType){let v=y(d.dataset.type??"",this.colors);d.style.background=v,d.style.borderColor=x(d.dataset.type??"",this.colors)+"40";}}),d.addEventListener("mouseleave",()=>{d.dataset.type!==this.selectedType&&(d.style.background=this.colors.glassBg,d.style.borderColor=this.colors.border);}),o$1.appendChild(d);}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};
|
|
@@ -53,7 +53,7 @@ import {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
|
|
|
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
|
-
`,c(this.submitBtn,this.t("popup.submit")),this.submitBtn.addEventListener("click",()=>this.submit()),l.appendChild(p$1),l.appendChild(this.submitBtn),this.root.appendChild(
|
|
56
|
+
`,c(this.submitBtn,this.t("popup.submit")),this.submitBtn.addEventListener("click",()=>this.submit()),l.appendChild(p$1),l.appendChild(this.submitBtn),this.root.appendChild(o$1),this.root.appendChild(this.textarea),this.root.appendChild(r),this.root.appendChild(l),document.body.appendChild(this.root);}colors;t;root;selectedType=null;textarea;submitBtn;resolve=null;previouslyFocused=null;onKeydownTrap=null;show(e){return new Promise(n=>{this.resolve=n,this.selectedType=null,this.textarea.value="",this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let i=220,o=300,r=e.bottom+8,s=e.left;if(r+i>window.innerHeight){let l=e.top-i-8;l>=8?r=l:r=window.innerHeight-i-8;}s+o>window.innerWidth&&(s=e.right-o),s=Math.max(8,s),r=Math.max(8,r),this.root.style.top=`${r}px`,this.root.style.left=`${s}px`,this.root.style.display="block",this.onKeydownTrap=l=>{if(l.key==="Tab"){let p=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea, input, [tabindex]:not([tabindex="-1"])'));if(p.length===0)return;let c=p[0],d=p[p.length-1];if(!c||!d)return;l.shiftKey?(document.activeElement===c||!this.root.contains(document.activeElement))&&(l.preventDefault(),d.focus()):(document.activeElement===d||!this.root.contains(document.activeElement))&&(l.preventDefault(),c.focus());}},this.root.addEventListener("keydown",this.onKeydownTrap);let a=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=a?"none":"",requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus();});})}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let o of i){let r=o.dataset.type===e,s=x(o.dataset.type??"",this.colors),a=y(o.dataset.type??"",this.colors);o.style.background=r?a:this.colors.glassBg,o.style.borderColor=r?s+"60":this.colors.border,o.style.color=r?s:this.colors.textTertiary,o.style.fontWeight=r?"600":"500",o.setAttribute("aria-pressed",String(r));}this.updateSubmitState();}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let n of e)n.setAttribute("aria-pressed","false"),n.style.background=this.colors.glassBg,n.style.borderColor=this.colors.border,n.style.color=this.colors.textTertiary,n.style.fontWeight="500";}updateSubmitState(){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(){!this.selectedType||!this.textarea.value.trim()||(this.resolve?.({type:this.selectedType,message:this.textarea.value.trim()}),this.resolve=null,this.hideElement());}cancel(){this.resolve?.(null),this.resolve=null,this.hideElement();}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=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.root.remove();}};var U,xt=false;async function Qt(){if(U!==void 0)return U;try{let t=await import('html2canvas');return U=t.default??t,U}catch(t){return U=null,xt||(xt=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 vt(t,e){let n=await Qt();if(!n)return null;let i=.85,o=1200;try{let r=await n(document.body,{x:window.scrollX+t.x,y:window.scrollY+t.y,width:t.width,height:t.height,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,ignoreElements:d=>d.tagName==="SITEPING-WIDGET"||d.closest?.("siteping-widget")!==null||d.getAttribute?.("data-siteping-ignore")==="true"});if(r.width<=o)return r.toDataURL("image/jpeg",i);let s=o/r.width,a=o,l=Math.round(r.height*s),p=document.createElement("canvas");p.width=a,p.height=l;let c=p.getContext("2d");return c?(c.drawImage(r,0,0,a,l),p.toDataURL("image/jpeg",i)):null}catch(r){return console.warn("[siteping] Screenshot capture failed:",r),null}}var ce=class{constructor(e,n,i,o=false){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.popup=new le(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;async maybeCapture(e){return this.enableScreenshot?vt(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
57
|
position:fixed;inset:0;
|
|
58
58
|
z-index:${2147483646};
|
|
59
59
|
background:rgba(15, 23, 42, 0.04);
|
|
@@ -76,14 +76,14 @@ import {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
|
|
|
76
76
|
background:${this.colors.accent};
|
|
77
77
|
box-shadow:0 0 8px ${this.colors.accentGlow};
|
|
78
78
|
animation:pulse 1.5s ease-in-out infinite;
|
|
79
|
-
`}),n=document.createElement("style");n.textContent=["@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}","@media(prefers-reduced-motion:reduce){@keyframes pulse{from,to{opacity:1}}}"].join(""),this.toolbar.appendChild(n);let
|
|
79
|
+
`}),n=document.createElement("style");n.textContent=["@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}","@media(prefers-reduced-motion:reduce){@keyframes pulse{from,to{opacity:1}}}"].join(""),this.toolbar.appendChild(n);let i=b("span",{style:"font-weight:500;letter-spacing:-0.01em;"});c(i,this.t("annotator.instruction"));let o=document.createElement("button");o.style.cssText=`
|
|
80
80
|
height:34px;padding:0 18px;border-radius:9999px;
|
|
81
81
|
border:1px solid ${this.colors.border};
|
|
82
82
|
background:${this.colors.glassBg};
|
|
83
83
|
color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
84
84
|
font-size:13px;font-weight:500;cursor:pointer;
|
|
85
85
|
transition:all 0.2s ease;
|
|
86
|
-
`,c(
|
|
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")return;e.preventDefault();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=await this.popup.show(o);if(!r)return;let a={anchor:Ie(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},l=await this.maybeCapture(o);this.deactivate(),this.bus.emit("annotation:complete",{annotation:a,type:r.type,message:r.message,screenshotDataUrl:l});};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.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
|
|
87
87
|
position:fixed;
|
|
88
88
|
border:2px solid ${this.colors.accent};
|
|
89
89
|
background:${this.colors.accent}12;
|
|
@@ -91,8 +91,8 @@ import {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
|
|
|
91
91
|
border-radius:8px;
|
|
92
92
|
box-shadow:0 0 16px ${this.colors.accentGlow};
|
|
93
93
|
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
|
|
95
|
-
${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof o=="function")return "[Function]";if(typeof o=="symbol")return o.toString();if(typeof o=="object"&&o!==null){if(e.has(o))return "[Circular]";e.add(o);}return o})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function sn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=rn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var pe=class{maxEntries;entries=[];originals=new Map;disposed=false;constructor(e=50){if(this.maxEntries=Math.min(Math.max(Math.floor(e),0),1e3),!(typeof console>"u"))for(let n of on){let o=console[n];if(typeof o!="function")continue;this.originals.set(n,o);let i=this,r=function(...s){try{i.push(n,s);}catch{}o.apply(this??console,s);};try{Object.defineProperty(r,"name",{value:n});}catch{}console[n]=r;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:sn(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 kt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Et(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 de=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(o,i)=>{let r=new Date,s=typeof performance<"u"?performance.now():Date.now(),a=kt(Et(o)),l=(i?.method??(o instanceof Request?o.method:"GET")).toUpperCase();try{let p=await e(o,i);if(!p.ok){let c=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:p.status,durationMs:Math.round(c-s),timestamp:r.toISOString()});}return p}catch(p){let c=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(c-s),timestamp:r.toISOString()}),p}};globalThis.fetch=n;}installXhr(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype,n=e.open,o=e.send;this.originalXhrOpen=n,this.originalXhrSend=o;let i=this,r=new WeakMap;e.open=function(s,a,...l){try{r.set(this,{method:s.toUpperCase(),url:kt(Et(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,s,a,...l)},e.send=function(s){let a=r.get(this);if(a){let l=()=>{try{let p=typeof performance<"u"?performance.now():Date.now(),c=this.status;(c===0||c>=400)&&i.push({url:a.url,method:a.method,status:c,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 o.call(this,s??null)};}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&typeof globalThis.fetch=="function")try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend);}catch{}}}};var J=class{listeners=new Map;on(e,n){this.listeners.has(e)||this.listeners.set(e,new Set);let o=this.listeners.get(e);return o.add(n),()=>{o.delete(n);}}off(e,n){let o=this.listeners.get(e);o&&o.delete(n);}emit(e,...n){let o=this.listeners.get(e);if(o)for(let i of o)try{i(...n);}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var an=54,ue=class{constructor(e,n,o,i$1){this.bus=o;this.t=i$1;let r=n.position??"bottom-right",s=r==="bottom-right";this.items=[{id:"chat",icon:g,label:i$1("fab.messages")},{id:"annotate",icon:h,label:i$1("fab.annotate")},{id:"toggle-annotations",icon:i,iconAlt:j,label:i$1("fab.annotations")}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${r} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-label",i$1("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--${r}`,this.radialContainer.setAttribute("role","menu");for(let p=0;p<this.items.length;p++){let c=this.items[p];if(!c)continue;let d=document.createElement("button");d.className="sp-radial-item",d.style.setProperty("--sp-i",String(p)),d.appendChild(a(c.icon)),d.setAttribute("role","menuitem"),d.setAttribute("aria-label",c.label),d.dataset.itemId=c.id,d.addEventListener("click",f=>{f.stopPropagation(),this.handleItemClick(c.id);});let h=document.createElement("span");h.className="sp-radial-label",h.textContent=c.label,h.style.cssText=s?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",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 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 c=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(c.length===0||!this.isOpen)return;let d=e.activeElement??document.activeElement,h=c.indexOf(d);switch(p.key){case "ArrowUp":{p.preventDefault();let f=h<=0?c.length-1:h-1;c[f]?.focus();break}case "ArrowDown":{p.preventDefault();let f=h>=c.length-1?0:h+1;c[f]?.focus();break}case "Home":{p.preventDefault(),c[0]?.focus();break}case "End":{p.preventDefault(),c[c.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,o)=>{let i=-(16+an*(o+1));n.style.transform=`translate(0px, ${i}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));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var St="siteping_identity";function Tt(){try{let t=localStorage.getItem(St);if(!t)return null;let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"name"in e&&typeof e.name=="string"&&"email"in e&&typeof e.email=="string"){let n=e;if(n.name&&n.email)return n}return null}catch{return null}}function Ct(t){try{localStorage.setItem(St,JSON.stringify(t));}catch{}}function ln(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let s=t;t=e,e=s;}let n=t.length,o=e.length,i=new Array(n+1);for(let s=0;s<=n;s++)i[s]=s;let r=new Array(n+1);for(let s=1;s<=o;s++){r[0]=s;for(let l=1;l<=n;l++){let p=i[l-1]??0;r[l]=t[l-1]===e[s-1]?p:1+Math.min(p,i[l]??0,r[l-1]??0);}let a=i;i=r,r=a;}return i[n]??0}function O(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-ln(t,e)/n}function Ie(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let o=e.length;if(o>t.length){let a=O(t,e);return a>=n?a:0}let i=0,r=t.length>500?t.slice(0,500):t,s=r.length-o;for(let a=0;a<=s;a++){let l=r.slice(a,a+o),p=O(l,e);if(p>i&&(i=p),i>=.95)break}return i>=n?i:0}var cn=300,pn=.3;function he(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Ie(n,e.textSnippet,.5)>pn}function dn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${K}="${e}"]`);if(n&&he(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&&he(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&he(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&&he(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return un(t)}function un(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let o=null,i=0,r=Math.min(n.length,cn);for(let s=0;s<r;s++){let a=n[s];if(!a)continue;let l=hn(a,t);if(l>i&&(i=l,o=a,i>=.85))break}return !o||i<.4?null:{element:o,confidence:Math.min(i,.85),strategy:"scan"}}function hn(t,e){let n=0,o=0,i=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(o+=40,n+=Ie(i,e.textSnippet,.5)*40),e.fingerprint&&(o+=20,n+=ht(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){o+=20;let r=0,s=0;if(e.textPrefix){let a=$(t,"before");r+=a?O(a,e.textPrefix):0,s++;}if(e.textSuffix){let a=$(t,"after");r+=a?O(a,e.textSuffix):0,s++;}s>0&&(n+=r/s*20);}if(e.neighborText){o+=20;let r=se(t);n+=r?O(r,e.neighborText)*20:0;}return o>0?n/o:0}function fe(t,e){let n=dn(t);if(!n)return null;let o=n.element.getBoundingClientRect(),i=new DOMRect(o.x+e.xPct*o.width,o.y+e.yPct*o.height,e.wPct*o.width,e.hPct*o.height);return {element:n.element,rect:i,confidence:n.confidence,strategy:n.strategy}}function De(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 me(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var At=13;function Pt(t){return {top:t.top+window.scrollY-At,left:t.right+window.scrollX-At}}function Q(t,e){let n=t.entries[e],o=t.elementIndices[e];if(!(!n||o===void 0))return n.elements[o]}var Rt=300,Ft=200,fn=.7,mn=28,Mt=32,ge=class{constructor(e,n,o,i,r=null){this.colors=e;this.tooltip=n;this.bus=o;this.t=i;this.liveRegion=r;this.container=b("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",s=>{this.container.style.display=s?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),this.mutationObserver=new MutationObserver(s=>{let a=false;for(let l of s)if(!(this.container.contains(l.target)||this.tooltip.contains(l.target))){a=true;break}a&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=s=>{this.container.contains(s.target)||this.collapseAllClusters();},document.addEventListener("click",this.onDocumentClickForClusters);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;get count(){return this.entries.length}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:Ft+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},Ft));}repositionAll(){let e=new Set;for(let n of this.entries)for(let o=0;o<n.feedback.annotations.length;o++){let i=n.elements[o];if(!i)continue;let r=n.feedback.annotations[o];if(!r)continue;let s=`${n.feedback.id}:${o}`;e.add(s);let l=this.anchorCache.get(s)?.deref(),p;if(l?.isConnected){let d=l.getBoundingClientRect(),h=me(r);p={element:l,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 p=fe(De(r),me(r)),p?.element&&this.anchorCache.set(s,new WeakRef(p.element));if(!p){i.style.display="none";continue}let c=Pt(p.rect);n.baseTop=c.top,n.baseLeft=c.left,i.style.display="flex",this.applyConfidenceStyle(i,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);}render(e){this.clear(),e.forEach((n,o)=>{let i=this.buildEntry(n,o+1);this.entries.push(i);}),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 o=this.buildEntry(e,n);for(let i of o.elements)i.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(o),this.buildClusters();}buildEntry(e,n){let o={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let i of e.annotations){let r=fe(De(i),me(i));if(!r)continue;let s=Pt(r.rect);o.baseTop=s.top,o.baseLeft=s.left;let a=this.createMarker(n,e,s);this.applyConfidenceStyle(a,r.confidence,e),this.container.appendChild(a),o.elements.push(a);}return o}buildClusters(){for(let o of this.container.querySelectorAll(".sp-cluster-badge"))o.remove();let e=[];for(let o of this.entries)for(let i=0;i<o.elements.length;i++)e.push({entry:o,elIdx:i});let n=new Set;this.clusters=[];for(let o=0;o<e.length;o++){if(n.has(o))continue;let i=e[o];if(!i)continue;let r={entries:[i.entry],elementIndices:[i.elIdx],expanded:false};n.add(o);for(let s=o+1;s<e.length;s++){if(n.has(s))continue;let a=i.entry,l=e[s];if(!l)continue;let p=l.entry;Math.sqrt((a.baseLeft-p.baseLeft)**2+(a.baseTop-p.baseTop)**2)<mn&&(r.entries.push(p),r.elementIndices.push(l.elIdx),n.add(s));}this.clusters.push(r);}for(let o of this.clusters)o.entries.length<=1||(this.applyStackPositions(o),this.addClusterBadge(o));}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:o,baseLeft:i}=n,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=Q(e,s);a&&(a.style.top=`${o+(r?0:s*3)}px`,a.style.left=`${i+(r?0:s*3)}px`,a.style.zIndex=String(s+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:o,baseLeft:i}=n,r=e.entries.length,s=(r-1)*Mt,a=i-s/2;for(let l=0;l<r;l++){let p=Q(e,l);p&&(p.style.top=`${o}px`,p.style.left=`${a+l*Mt}px`,p.style.zIndex=String(10+l));}}addClusterBadge(e){let n=Q(e,e.entries.length-1);if(!n)return;let o=b("div",{class:"sp-cluster-badge",style:`
|
|
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),r=Math.abs(n.clientX-this.startX),s=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${o}px`,this.drawingRect.style.width=`${r}px`,this.drawingRect.style.height=`${s}px`;})));}onTouchEnd=async e=>{let n=e.changedTouches[0];n&&await this.finishDrawing(n.clientX,n.clientY);};onMouseUp=async e=>{await this.finishDrawing(e.clientX,e.clientY);};finishDrawing=async(e,n)=>{if(!this.isDrawing||!this.drawingRect)return;this.isDrawing=false;let i=Math.min(e,this.startX),o=Math.min(n,this.startY),r=Math.abs(e-this.startX),s=Math.abs(n-this.startY);if(r<10||s<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(i,o,r,s),l=await this.popup.show(a);if(!l){this.drawingRect?.remove(),this.drawingRect=null;return}let p=this.buildAnnotation(a);this.drawingRect?.remove(),this.drawingRect=null;let c=await this.maybeCapture(a);this.deactivate(),this.bus.emit("annotation:complete",{annotation:p,type:l.type,message:l.message,screenshotDataUrl:c});};buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=bt(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Ie(n),o=n.getBoundingClientRect(),r=yt(e,o);return {anchor:i,rect:r,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.popup.destroy();}};var C=class extends Error{code;retryable;constructor(e,n,i){super(e),this.code=n,this.retryable=i,this.name="SitepingError";}},H=class extends C{constructor(e){super(e,"NETWORK",true),this.name="SitepingNetworkError";}},Y=class extends C{constructor(e){super(e,"VALIDATION",false),this.name="SitepingValidationError";}},W=class extends C{constructor(e){super(e,"AUTH",false),this.name="SitepingAuthError";}};function Me(t){return {cssSelector:t.anchor.cssSelector,xpath:t.anchor.xpath,textSnippet:t.anchor.textSnippet,elementTag:t.anchor.elementTag,elementId:t.anchor.elementId,textPrefix:t.anchor.textPrefix,textSuffix:t.anchor.textSuffix,fingerprint:t.anchor.fingerprint,neighborText:t.anchor.neighborText,anchorKey:t.anchor.anchorKey??null,xPct:t.rect.xPct,yPct:t.rect.yPct,wPct:t.rect.wPct,hPct:t.rect.hPct,scrollX:t.scrollX,scrollY:t.scrollY,viewportW:t.viewportW,viewportH:t.viewportH,devicePixelRatio:t.devicePixelRatio}}async function q(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 W(o):t.status>=400&&t.status<500?new Y(o):new C(o,"SERVER",false)}function G(t,e){if(t instanceof C&&t instanceof H)return t;let n=t instanceof Error?t.message:String(t);return new H(`${e}: ${n}`)}var Zt=3,en=1e4,J="siteping_retry_queue",tn=20;async function V(t,e,n=Zt){for(let i=0;i<=n;i++){let o=new AbortController,r=setTimeout(()=>o.abort(),en);try{let l=await fetch(t,{...e,signal:o.signal});if(clearTimeout(r),l.ok||l.status>=400&&l.status<500||i===n)return l}catch(l){if(clearTimeout(r),i===n)throw l}let s=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,s+a));}throw new Error("Max retries exceeded")}var nn="siteping_retry_queue";async function wt(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(nn,()=>t()):t()}function on(t,e){wt(()=>{try{let n=localStorage.getItem(J),i=n?JSON.parse(n):[],o=Array.isArray(i)?i:[];o.length>=tn&&o.shift(),o.push({endpoint:t,payload:e}),localStorage.setItem(J,JSON.stringify(o));}catch{}});}async function kt(t){await wt(async()=>{try{let e=localStorage.getItem(J);if(!e)return;let n=JSON.parse(e),i=Array.isArray(n)?n:[],o=i.filter(a=>a.endpoint===t);if(o.length===0)return;let r=[];for(let a of o)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.payload)})).ok||r.push(a);}catch{r.push(a);}let s=i.filter(a=>a.endpoint!==t).concat(r);s.length>0?localStorage.setItem(J,JSON.stringify(s)):localStorage.removeItem(J);}catch{}});}var pe=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){try{let n;try{n=await V(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(i){throw G(i,"Failed to send feedback")}if(!n.ok)throw await q(n,"Failed to send feedback");return await n.json()}catch(n){throw on(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 V(`${this.endpoint}?${i.toString()}`,{method:"GET",cache:"no-store"});}catch(r){throw G(r,"Failed to fetch feedbacks")}if(!o.ok)throw await q(o,"Failed to fetch feedbacks");return await o.json()}async resolveFeedback(e,n){let i;try{i=await V(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(o){throw G(o,"Failed to update feedback")}if(!i.ok)throw await q(i,"Failed to update feedback");return await i.json()}async deleteFeedback(e){let n;try{n=await V(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(i){throw G(i,"Failed to delete feedback")}if(!n.ok)throw await q(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await V(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(i){throw G(i,"Failed to delete all feedbacks")}if(!n.ok)throw await q(n,"Failed to delete all feedbacks")}};var rn=["log","info","warn","error"];function sn(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?`
|
|
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 an(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=sn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var de=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 rn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,r=function(...s){try{o.push(n,s);}catch{}i.apply(this??console,s);};try{Object.defineProperty(r,"name",{value:n});}catch{}console[n]=r;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:an(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 Et(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function St(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 ue=class{maxEntries;entries=[];originalFetch=null;originalXhrOpen=null;originalXhrSend=null;disposed=false;constructor(e=20){this.maxEntries=Math.min(Math.max(Math.floor(e),0),500),this.installFetch(),this.installXhr();}push(e){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push(e));}installFetch(){if(typeof globalThis.fetch!="function")return;let e=globalThis.fetch;this.originalFetch=e;let n=async(i,o)=>{let r=new Date,s=typeof performance<"u"?performance.now():Date.now(),a=Et(St(i)),l=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let p=await e(i,o);if(!p.ok){let c=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:p.status,durationMs:Math.round(c-s),timestamp:r.toISOString()});}return p}catch(p){let c=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(c-s),timestamp:r.toISOString()}),p}};globalThis.fetch=n;}installXhr(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype,n=e.open,i=e.send;this.originalXhrOpen=n,this.originalXhrSend=i;let o=this,r=new WeakMap;e.open=function(s,a,...l){try{r.set(this,{method:s.toUpperCase(),url:Et(St(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,s,a,...l)},e.send=function(s){let a=r.get(this);if(a){let l=()=>{try{let p=typeof performance<"u"?performance.now():Date.now(),c=this.status;(c===0||c>=400)&&o.push({url:a.url,method:a.method,status:c,durationMs:Math.round(p-a.t0),timestamp:a.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",l,{once:!0});}catch{try{this.addEventListener("loadend",l);}catch{}}}return i.call(this,s??null)};}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&typeof globalThis.fetch=="function")try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend);}catch{}}}};var Q=class{listeners=new Map;on(e,n){this.listeners.has(e)||this.listeners.set(e,new Set);let i=this.listeners.get(e);return i.add(n),()=>{i.delete(n);}}off(e,n){let i=this.listeners.get(e);i&&i.delete(n);}emit(e,...n){let i=this.listeners.get(e);if(i)for(let o of i)try{o(...n);}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var ln=54,he=class{constructor(e,n,i$1,o){this.bus=i$1;this.t=o;let r=n.position??"bottom-right",s=r==="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,label:o("fab.annotations")}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${r} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-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--${r}`,this.radialContainer.setAttribute("role","menu");for(let p=0;p<this.items.length;p++){let c=this.items[p];if(!c)continue;let d=document.createElement("button");d.className="sp-radial-item",d.style.setProperty("--sp-i",String(p)),d.appendChild(a(c.icon)),d.setAttribute("role","menuitem"),d.setAttribute("aria-label",c.label),d.dataset.itemId=c.id,d.addEventListener("click",f=>{f.stopPropagation(),this.handleItemClick(c.id);});let h=document.createElement("span");h.className="sp-radial-label",h.textContent=c.label,h.style.cssText=s?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",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 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 c=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(c.length===0||!this.isOpen)return;let d=e.activeElement??document.activeElement,h=c.indexOf(d);switch(p.key){case "ArrowUp":{p.preventDefault();let f=h<=0?c.length-1:h-1;c[f]?.focus();break}case "ArrowDown":{p.preventDefault();let f=h>=c.length-1?0:h+1;c[f]?.focus();break}case "Home":{p.preventDefault(),c[0]?.focus();break}case "End":{p.preventDefault(),c[c.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$1),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+ln*(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));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var Tt="siteping_identity";function Ct(){try{let t=localStorage.getItem(Tt);if(!t)return null;let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"name"in e&&typeof e.name=="string"&&"email"in e&&typeof e.email=="string"){let n=e;if(n.name&&n.email)return n}return null}catch{return null}}function At(t){try{localStorage.setItem(Tt,JSON.stringify(t));}catch{}}function cn(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let s=t;t=e,e=s;}let n=t.length,i=e.length,o=new Array(n+1);for(let s=0;s<=n;s++)o[s]=s;let r=new Array(n+1);for(let s=1;s<=i;s++){r[0]=s;for(let l=1;l<=n;l++){let p=o[l-1]??0;r[l]=t[l-1]===e[s-1]?p:1+Math.min(p,o[l]??0,r[l-1]??0);}let a=o;o=r,r=a;}return o[n]??0}function O(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-cn(t,e)/n}function De(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=O(t,e);return a>=n?a:0}let o=0,r=t.length>500?t.slice(0,500):t,s=r.length-i;for(let a=0;a<=s;a++){let l=r.slice(a,a+i),p=O(l,e);if(p>o&&(o=p),o>=.95)break}return o>=n?o:0}var pn=300,dn=.3;function fe(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return De(n,e.textSnippet,.5)>dn}function un(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${X}="${e}"]`);if(n&&fe(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&&fe(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&fe(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&&fe(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return hn(t)}function hn(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,r=Math.min(n.length,pn);for(let s=0;s<r;s++){let a=n[s];if(!a)continue;let l=fn(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 fn(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=De(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=ft(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let r=0,s=0;if(e.textPrefix){let a=$(t,"before");r+=a?O(a,e.textPrefix):0,s++;}if(e.textSuffix){let a=$(t,"after");r+=a?O(a,e.textSuffix):0,s++;}s>0&&(n+=r/s*20);}if(e.neighborText){i+=20;let r=ae(t);n+=r?O(r,e.neighborText)*20:0;}return i>0?n/i:0}function me(t,e){let n=un(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 Le(t){return {cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId??void 0,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null}}function ge(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var Pt=13;function Ft(t){return {top:t.top+window.scrollY-Pt,left:t.right+window.scrollX-Pt}}function Z(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Rt=300,It=200,mn=.7,gn=28,Mt=32,be=class{constructor(e,n,i,o,r=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;this.liveRegion=r;this.container=b("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",s=>{this.container.style.display=s?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),this.mutationObserver=new MutationObserver(s=>{let a=false;for(let l of s)if(!(this.container.contains(l.target)||this.tooltip.contains(l.target))){a=true;break}a&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=s=>{this.container.contains(s.target)||this.collapseAllClusters();},document.addEventListener("click",this.onDocumentClickForClusters);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;get count(){return this.entries.length}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:It+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},It));}repositionAll(){let e=new Set;for(let n of this.entries)for(let i=0;i<n.feedback.annotations.length;i++){let o=n.elements[i];if(!o)continue;let r=n.feedback.annotations[i];if(!r)continue;let s=`${n.feedback.id}:${i}`;e.add(s);let l=this.anchorCache.get(s)?.deref(),p;if(l?.isConnected){let d=l.getBoundingClientRect(),h=ge(r);p={element:l,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 p=me(Le(r),ge(r)),p?.element&&this.anchorCache.set(s,new WeakRef(p.element));if(!p){o.style.display="none";continue}let c=Ft(p.rect);n.baseTop=c.top,n.baseLeft=c.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);}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 r=me(Le(o),ge(o));if(!r)continue;let s=Ft(r.rect);i.baseTop=s.top,i.baseLeft=s.left;let a=this.createMarker(n,e,s);this.applyConfidenceStyle(a,r.confidence,e),this.container.appendChild(a),i.elements.push(a);}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let o=0;o<i.elements.length;o++)e.push({entry:i,elIdx:o});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let o=e[i];if(!o)continue;let r={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let s=i+1;s<e.length;s++){if(n.has(s))continue;let a=o.entry,l=e[s];if(!l)continue;let p=l.entry;Math.sqrt((a.baseLeft-p.baseLeft)**2+(a.baseTop-p.baseTop)**2)<gn&&(r.entries.push(p),r.elementIndices.push(l.elIdx),n.add(s));}this.clusters.push(r);}for(let i of this.clusters)i.entries.length<=1||(this.applyStackPositions(i),this.addClusterBadge(i));}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=Z(e,s);a&&(a.style.top=`${i+(r?0:s*3)}px`,a.style.left=`${o+(r?0:s*3)}px`,a.style.zIndex=String(s+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,r=e.entries.length,s=(r-1)*Mt,a=o-s/2;for(let l=0;l<r;l++){let p=Z(e,l);p&&(p.style.top=`${i}px`,p.style.left=`${a+l*Mt}px`,p.style.zIndex=String(10+l));}}addClusterBadge(e){let n=Z(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
|
|
96
96
|
position:absolute;top:-6px;right:-6px;
|
|
97
97
|
min-width:16px;height:16px;padding:0 4px;
|
|
98
98
|
border-radius:9999px;
|
|
@@ -103,36 +103,36 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
103
103
|
pointer-events:none;
|
|
104
104
|
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
105
105
|
line-height:1;
|
|
106
|
-
`});c(
|
|
106
|
+
`});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=Z(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(Z(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<mn&&!o?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=this.t("marker.approximate").replace("{confidence}",String(Math.round(n*100)))):(e.style.borderStyle="solid",e.style.opacity="1",e.title="");}createMarker(e,n,i){let o=x(n.type,this.colors),r=n.status==="resolved",s=b("div",{style:`
|
|
107
107
|
position:absolute;
|
|
108
|
-
top:${
|
|
109
|
-
left:${
|
|
108
|
+
top:${i.top}px;
|
|
109
|
+
left:${i.left}px;
|
|
110
110
|
width:26px;height:26px;
|
|
111
111
|
border-radius:50%;
|
|
112
112
|
background:${r?"rgba(241,245,249,0.9)":"rgba(255,255,255,0.92)"};
|
|
113
|
-
border:2px solid ${r?"#cbd5e1":
|
|
113
|
+
border:2px solid ${r?"#cbd5e1":o};
|
|
114
114
|
display:flex;align-items:center;justify-content:center;
|
|
115
115
|
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
116
116
|
font-size:11px;font-weight:700;
|
|
117
|
-
color:${r?"#94a3b8":
|
|
117
|
+
color:${r?"#94a3b8":o};
|
|
118
118
|
cursor:pointer;pointer-events:auto;
|
|
119
|
-
box-shadow:${r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${
|
|
119
|
+
box-shadow:${r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${o}25, 0 2px 6px rgba(0,0,0,0.06)`};
|
|
120
120
|
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
121
|
user-select:none;
|
|
122
122
|
-webkit-font-smoothing:antialiased;
|
|
123
|
-
`});s.dataset.feedbackId=n.id,s.setAttribute("tabindex","0"),s.setAttribute("role","button");let a=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,l=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",C(n.type,this.t)).replace("{message}",a);s.setAttribute("aria-label",l),s.setAttribute("aria-describedby",this.tooltip.tooltipId),c(s,r?"\u2713":String(e)),s.addEventListener("mouseenter",()=>{s.style.transform="scale(1.2)",s.style.boxShadow=r?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${
|
|
123
|
+
`});s.dataset.feedbackId=n.id,s.setAttribute("tabindex","0"),s.setAttribute("role","button");let a=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,l=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",C$1(n.type,this.t)).replace("{message}",a);s.setAttribute("aria-label",l),s.setAttribute("aria-describedby",this.tooltip.tooltipId),c(s,r?"\u2713":String(e)),s.addEventListener("mouseenter",()=>{s.style.transform="scale(1.2)",s.style.boxShadow=r?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${o}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("mouseleave",()=>{s.style.transform="scale(1)",s.style.boxShadow=r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${o}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),s.addEventListener("focus",()=>{this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let p=c=>{c instanceof MouseEvent&&this.handleClusterClick(s,c)||(this.pinHighlight(n),this.bus.emit("panel:toggle",true),s.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:true})));};return s.addEventListener("click",c=>p(c)),s.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),p(c));}),s}focusFeedback(e){let n=this.entries.find(o=>o.feedback.id===e);if(!n)return false;let i=n.elements[0];return i&&i.scrollIntoView({behavior:"smooth",block:"center"}),this.pinHighlight(n.feedback),this.highlight(e),true}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)i.style.animation="sp-pulse-ring 0.7s ease-out",i.addEventListener("animationend",()=>{i.style.animation="";},{once:true});}showHighlight(e){this.removeHighlightElements();for(let n of e.annotations){let i=me(Le(n),ge(n));if(!i)continue;let o=x(e.type,this.colors),r=i.rect,s=b("div",{style:`
|
|
124
124
|
position:absolute;
|
|
125
125
|
top:${r.top+window.scrollY}px;
|
|
126
126
|
left:${r.left+window.scrollX}px;
|
|
127
127
|
width:${r.width}px;height:${r.height}px;
|
|
128
|
-
border:2px solid ${
|
|
129
|
-
background:${
|
|
128
|
+
border:2px solid ${o};
|
|
129
|
+
background:${o}0c;
|
|
130
130
|
border-radius:8px;
|
|
131
131
|
pointer-events:none;z-index:-1;
|
|
132
132
|
opacity:0;
|
|
133
|
-
box-shadow:0 0 16px ${
|
|
133
|
+
box-shadow:0 0 16px ${o}20;
|
|
134
134
|
transition:opacity ${Rt}ms ease;
|
|
135
|
-
`});this.container.appendChild(s),this.highlightElements.push(s),s.offsetHeight,s.style.opacity="1";}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=n=>{this.container.contains(n.target)||this.unpinHighlight();},document.addEventListener("click",this.onDocumentClick,{capture:true});}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:true}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight();}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),Rt);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
|
|
135
|
+
`});this.container.appendChild(s),this.highlightElements.push(s),s.offsetHeight,s.style.opacity="1";}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=n=>{this.container.contains(n.target)||this.unpinHighlight();},document.addEventListener("click",this.onDocumentClick,{capture:true});}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:true}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight();}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),Rt);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 ye=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(Me),screenshotDataUrl:e.screenshotDataUrl??null});return Ne(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(Ne),total:o}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return Ne(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function Ne(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(bn),screenshotUrl:t.screenshotUrl??null,diagnostics:t.diagnostics??null}}function bn(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 yn="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)",_e="cubic-bezier(0.16, 1, 0.3, 1)",$e="cubic-bezier(0.34, 1.56, 0.64, 1)",xn="cubic-bezier(0.25, 1, 0.5, 1)",Dt=`
|
|
136
136
|
/* ---- Keyframes ---- */
|
|
137
137
|
|
|
138
138
|
@keyframes sp-fab-in {
|
|
@@ -206,11 +206,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
206
206
|
/* ---- Animation classes ---- */
|
|
207
207
|
|
|
208
208
|
.sp-anim-fab-in {
|
|
209
|
-
animation: sp-fab-in 0.5s ${
|
|
209
|
+
animation: sp-fab-in 0.5s ${yn} both;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
.sp-anim-marker-in {
|
|
213
|
-
animation: sp-marker-in 0.35s ${
|
|
213
|
+
animation: sp-marker-in 0.35s ${$e} both;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
.sp-anim-pulse {
|
|
@@ -218,11 +218,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
.sp-anim-flash {
|
|
221
|
-
animation: sp-flash-bg 0.5s ${
|
|
221
|
+
animation: sp-flash-bg 0.5s ${xn};
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
.sp-anim-slide-up {
|
|
225
|
-
animation: sp-slide-up 0.3s ${
|
|
225
|
+
animation: sp-slide-up 0.3s ${_e} both;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
.sp-anim-fade-in {
|
|
@@ -233,7 +233,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
233
233
|
|
|
234
234
|
.sp-panel {
|
|
235
235
|
transform: translateX(110%);
|
|
236
|
-
transition: transform 0.4s ${
|
|
236
|
+
transition: transform 0.4s ${_e};
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
.sp-panel.sp-panel--open {
|
|
@@ -245,7 +245,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
245
245
|
pointer-events: none;
|
|
246
246
|
transform: translate(0, 0) scale(0.8);
|
|
247
247
|
transition:
|
|
248
|
-
transform 0.35s ${
|
|
248
|
+
transform 0.35s ${$e},
|
|
249
249
|
opacity 0.2s ease,
|
|
250
250
|
background 0.2s ease,
|
|
251
251
|
border-color 0.2s ease,
|
|
@@ -276,7 +276,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
.sp-card {
|
|
279
|
-
animation: sp-card-in 0.35s ${
|
|
279
|
+
animation: sp-card-in 0.35s ${_e} both;
|
|
280
280
|
animation-delay: calc(var(--sp-card-i, 0) * 40ms);
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -304,7 +304,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
.sp-fab-badge {
|
|
307
|
-
animation: sp-badge-in 0.4s ${
|
|
307
|
+
animation: sp-badge-in 0.4s ${$e} both;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
/* ---- Reduced motion ---- */
|
|
@@ -317,7 +317,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
`;function
|
|
320
|
+
`;function He(t){return `
|
|
321
321
|
:host {
|
|
322
322
|
all: initial;
|
|
323
323
|
position: fixed;
|
|
@@ -1486,14 +1486,14 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
1488
|
|
|
1489
|
-
${
|
|
1489
|
+
${Dt}
|
|
1490
1490
|
${O$1}
|
|
1491
1491
|
${N}
|
|
1492
1492
|
${F}
|
|
1493
1493
|
${D}
|
|
1494
1494
|
${S}
|
|
1495
1495
|
${H$1}
|
|
1496
|
-
`}var
|
|
1496
|
+
`}var vn=120,wn=80,xe=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
|
|
1497
1497
|
position: fixed;
|
|
1498
1498
|
z-index: ${2147483647};
|
|
1499
1499
|
max-width: 280px;
|
|
@@ -1519,12 +1519,12 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
1519
1519
|
border: 1px solid ${this.colors.glassBorder};
|
|
1520
1520
|
transform: rotate(45deg);
|
|
1521
1521
|
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
|
|
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)";},vn));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),wn);}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 d of n)d!==this.arrow&&d.remove();let i=x(e$1.type,this.colors),o=y(e$1.type,this.colors),r=B(this.locale),s=C$1(e$1.type,r),a=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=b("span",{style:`
|
|
1523
1523
|
padding:3px 10px;border-radius:9999px;
|
|
1524
1524
|
font-size:11px;font-weight:600;
|
|
1525
|
-
color:${
|
|
1525
|
+
color:${i};background:${o};
|
|
1526
1526
|
letter-spacing:0.02em;
|
|
1527
|
-
`});c(l,s);let p=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(p,e(e$1.createdAt,this.locale)),a.appendChild(l),a.appendChild(p);let c$1=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(c$1,e$1.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(c$1,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),
|
|
1527
|
+
`});c(l,s);let p=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(p,e(e$1.createdAt,this.locale)),a.appendChild(l),a.appendChild(p);let c$1=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(c$1,e$1.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(c$1,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),i=10,o=e.top-n.height-i,r=e.left+e.width/2-n.width/2,s=true;o<8&&(o=e.bottom+i,s=false),r=Math.max(8,Math.min(r,window.innerWidth-n.width-8)),this.root.style.top=`${o}px`,this.root.style.left=`${r}px`;let a=Math.max(16,Math.min(e.left+e.width/2-r-6,n.width-22));s?this.arrow.style.cssText=`
|
|
1528
1528
|
position:absolute;
|
|
1529
1529
|
width:12px;height:12px;
|
|
1530
1530
|
background:${this.colors.glassBgHeavy};
|
|
@@ -1544,7 +1544,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
1544
1544
|
pointer-events:none;
|
|
1545
1545
|
top:-6px;
|
|
1546
1546
|
left:${a}px;
|
|
1547
|
-
`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var
|
|
1547
|
+
`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var ee=null;function En(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 ve(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:t,focusFeedback:()=>false,on:()=>t,off:t}}function Sn(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function Lt(t){let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(ee)return e("initSiteping() called more than once \u2014 returning existing instance"),ee;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),ve()}catch{}if(window.innerWidth<768){let u="mobile";return t.onSkip?.(u),ve()}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."),ve();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),ve();let n=t.locale??"en";n!=="en"&&A(n).catch(()=>{});let i=B(n),o=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:o});let s=En(t.captureDiagnostics),a=s.console?new de(s.maxConsoleEntries):null,l=s.network?new ue(s.maxNetworkEntries):null,p=w(t.accentColor,t.theme),c=new Q,d=new Q,h=t.store?new ye(t.store,t.projectName):new pe(t.endpoint,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=>d.emit("feedback:sent",u)),c.on("feedback:deleted",u=>d.emit("feedback:deleted",u)),c.on("open",()=>d.emit("panel:open")),c.on("close",()=>d.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 f=document.createElement("siteping-widget");f.style.cssText=`position:fixed;z-index:${2147483647};`;let v=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(v=!0);}catch{}let L=v?"open":"closed",T=f.attachShadow({mode:L});if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;u.replaceSync(He(p)),T.adoptedStyleSheets=[u];}else {let u=document.createElement("style");u.textContent=He(p),T.appendChild(u);}document.body.appendChild(f);let E=document.createElement("div");E.setAttribute("role","status"),E.setAttribute("aria-live","polite"),E.setAttribute("aria-atomic","true"),E.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(E);let j=new xe(p,n),b=new be(p,j,c,i,E),S=new he(T,t,c,i),g=null,R=null,A$1=false;async function I(){return A$1?null:g||(R||(R=import('./panel-OQ6MGCXK.js').then(u=>A$1?null:(g=new u.Panel(T,p,c,h,t.projectName,b,i,n,{getScope:r,scopeAnnotationsByUrl:o}),g))),R)}if(typeof window<"u"){let u=()=>{A$1||I();},y=window.requestIdleCallback;typeof y=="function"?y(u):setTimeout(u,200);}let N=false,_t=c.on("panel:toggle",u=>{g||(u?(N=true,I().then(y=>{y&&N&&y.open(),N=false;}).catch(y=>e("Failed to lazy-load panel:",y))):N=false);}),$t=new ce(p,c,i,t.enableScreenshot??false),we=false,Ht=c.on("annotation:complete",async u=>{if(!we){we=true;try{let{annotation:y,type:w,message:z,screenshotDataUrl:Ee}=u,_=t.identity??Ct();if(!_){if(_=await Tn(T,i),!_)return;At(_);}let Bt=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),Se=r(),je=null;(a||l)&&(je={console:a?.getEntries()??[],network:l?.getEntries()??[]});let jt={projectName:t.projectName,type:w,message:z,url:Se.url,urlPattern:Se.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:_.name,authorEmail:_.email,annotations:[y],clientId:Bt,screenshotDataUrl:Ee??null,diagnostics:je};try{let M=await h.sendFeedback(jt);c.emit("feedback:sent",M),(!o||M.url===Se.url)&&b.addFeedback(M,b.count+1),E.textContent=i("feedback.sent.confirmation"),g&&await g.refresh();}catch(M){c.emit("feedback:error",M instanceof Error?M:new Error(String(M))),E.textContent=i("feedback.error.message");}}finally{we=false;}}}),Be=r(),Ot=o?{limit:20,url:Be.url}:{limit:20},ke=Sn(t.deepLink);return h.getFeedbacks(t.projectName,Ot).then(({feedbacks:u})=>{let y=o?u.filter(w=>w.url===Be.url):u;if(b.render(y),ke.enabled)try{let w=new URLSearchParams(window.location.search).get(ke.param);if(w){let z=b.focusFeedback(w);e(`deepLink ?${ke.param}=${w} ${z?"focused":"did not match a visible feedback"}`);}}catch(w){e("deepLink parsing failed:",w);}}).catch(u=>{e("Failed to load initial markers:",u);}),t.endpoint&&kt(t.endpoint).then(()=>e("Retry queue flushed")).catch(()=>{}),ee={destroy:()=>{e("Destroying widget"),A$1=true,N=false,Ht(),_t(),S.destroy(),g?.destroy(),$t.destroy(),b.destroy(),j.destroy(),a?.dispose(),l?.dispose(),c.removeAll(),d.removeAll(),E.remove(),f.remove(),ee=null;},open:()=>{c.emit("panel:toggle",true);},close:()=>{g?g.close():N=false;},focusFeedback:u=>b.focusFeedback(u),refresh:()=>{if(g?.isCurrentlyOpen){g.refresh();return}let u=r(),y=o?{limit:20,url:u.url}:{limit:20};h.getFeedbacks(t.projectName,y).then(({feedbacks:w})=>{let z=o?w.filter(Ee=>Ee.url===u.url):w;b.render(z);}).catch(()=>{});},on:(u,y)=>d.on(u,y),off:(u,y)=>{d.off(u,y);}},ee}function Tn(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,o=document.createElement("div");o.style.cssText=`
|
|
1548
1548
|
position:fixed;inset:0;
|
|
1549
1549
|
background:var(--sp-identity-overlay);
|
|
1550
1550
|
backdrop-filter:blur(8px);
|
|
@@ -1564,5 +1564,5 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
|
|
|
1564
1564
|
transform:translateY(12px) scale(0.97);
|
|
1565
1565
|
transition:transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1566
1566
|
-webkit-font-smoothing:antialiased;
|
|
1567
|
-
`;let s=`sp-identity-title-${Date.now()}`;r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby",s);let a=document.createElement("div");a.className="sp-identity-title",a.id=s,a.textContent=e("identity.title"),a.style.marginBottom="20px";let l=`sp-identity-name-${Date.now()}`,p=`sp-identity-email-${Date.now()}`,c=document.createElement("label");c.className="sp-input-label",c.textContent=e("identity.nameLabel"),c.setAttribute("for",l);let d=document.createElement("input");d.className="sp-input",d.id=l,d.type="text",d.placeholder=e("identity.namePlaceholder"),d.style.marginBottom="14px";let h=document.createElement("label");h.className="sp-input-label",h.textContent=e("identity.emailLabel"),h.setAttribute("for",p);let f=document.createElement("input");f.className="sp-input",f.id=p,f.type="email",f.placeholder=e("identity.emailPlaceholder");let v=document.createElement("div");v.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let
|
|
1567
|
+
`;let s=`sp-identity-title-${Date.now()}`;r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby",s);let a=document.createElement("div");a.className="sp-identity-title",a.id=s,a.textContent=e("identity.title"),a.style.marginBottom="20px";let l=`sp-identity-name-${Date.now()}`,p=`sp-identity-email-${Date.now()}`,c=document.createElement("label");c.className="sp-input-label",c.textContent=e("identity.nameLabel"),c.setAttribute("for",l);let d=document.createElement("input");d.className="sp-input",d.id=l,d.type="text",d.placeholder=e("identity.namePlaceholder"),d.style.marginBottom="14px";let h=document.createElement("label");h.className="sp-input-label",h.textContent=e("identity.emailLabel"),h.setAttribute("for",p);let f=document.createElement("input");f.className="sp-input",f.id=p,f.type="email",f.placeholder=e("identity.emailPlaceholder");let v=document.createElement("div");v.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let L=b=>{o.removeEventListener("keydown",j),o.style.opacity="0",r.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{o.remove(),i?.focus(),n(b);},250);},T=document.createElement("button");T.className="sp-btn-ghost",T.textContent=e("identity.cancel"),T.addEventListener("click",()=>L(null));let B=document.createElement("button");B.className="sp-btn-primary",B.textContent=e("identity.submit"),B.addEventListener("click",()=>{let b=d.value.trim(),S=f.value.trim();if(!b||!S)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(S)){f.style.borderColor="var(--sp-type-bug, #ef4444)";return}L({name:b,email:S});});let E='input, button, [tabindex]:not([tabindex="-1"])',j=b=>{let S=b;if(S.key==="Escape"){L(null);return}if(S.key==="Tab"){let g=Array.from(r.querySelectorAll(E));if(g.length===0)return;let R=g[0],A=g[g.length-1];if(!R||!A)return;let I=t.activeElement;S.shiftKey?(I===R||!r.contains(I))&&(S.preventDefault(),A.focus()):(I===A||!r.contains(I))&&(S.preventDefault(),R.focus());}};o.addEventListener("keydown",j),o.addEventListener("click",b=>{b.target===o&&L(null);}),v.appendChild(T),v.appendChild(B),r.appendChild(a),r.appendChild(c),r.appendChild(d),r.appendChild(h),r.appendChild(f),r.appendChild(v),o.appendChild(r),t.appendChild(o),requestAnimationFrame(()=>{o.style.opacity="1",r.style.transform="translateY(0) scale(1)",d.focus();});})}function Nt(t){return Lt(t)}function ro(t){let e=useRef(t);e.current=t;let[n,i]=useState(null);return useEffect(()=>{let o=true,r=Nt(e.current);if(!o){r.destroy();return}let s=r.on("feedback:sent",p=>{e.current.onFeedbackSent?.(p);}),a=r.on("panel:open",()=>{e.current.onOpen?.();}),l=r.on("panel:close",()=>{e.current.onClose?.();});return i(r),()=>{o=false,s(),a(),l(),r.destroy(),i(null);}},[]),n}export{ro as useSiteping};//# sourceMappingURL=react.js.map
|
|
1568
1568
|
//# sourceMappingURL=react.js.map
|