@siteping/widget 0.12.2 → 0.12.3
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.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +2 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {g,ya,za,la,O,S,C,ka,o,n,l,c,x,s,u,e,E,qa,z,F,L,ma,Ba as Ba$1,na,Ca,k,Aa,va,N,ta,ua,ia,ja,V,U,D,T,I,Q,W,A,B,M,t,v,d,sa,_,$,aa,ba,K,P,R,wa,q,p,r,h,a,b,Pa,Oa,Fa,Da,Ta,Ia,y,ra}from'./chunk-HFZPYBZG.js';export{f as isSitepingError,ya as loadLocale,xa as registerLocale}from'./chunk-HFZPYBZG.js';var uo=new Set(["role","name","aria-label","rel","href"]);function ho(t,e){let n=uo.has(t);n||=t.startsWith("data-")&&ve(t);let i=ve(e)&&e.length<100;return i||=e.startsWith("#")&&ve(e.slice(1)),n&&i}function fo(t){return ve(t)}function mo(t){return ve(t)}function go(t){return true}function At(t,e){if(t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return "html";let n={root:document.body,idName:fo,className:mo,tagName:go,attr:ho,timeoutMs:1e3,seedMinLength:3,optimizedMinLength:2,maxNumberOfPathChecks:1/0},i=new Date,o={...n,...e},r=wo(o.root,n),s,a=0;for(let c of bo(t,o,r)){if(new Date().getTime()-i.getTime()>o.timeoutMs||a>=o.maxNumberOfPathChecks){let f=vo(t,r);if(!f)throw new Error(`Timeout: Can't find a unique selector after ${o.timeoutMs}ms`);return xe(f)}if(a++,Pt(c,r)){s=c;break}}if(!s)throw new Error("Selector was not found.");let l=[...Gn(s,t,o,r,i)];return l.sort(Ct),l.length>0?xe(l[0]):xe(s)}function*bo(t,e,n){let i=[],o=[],r=t,s=0;for(;r&&r!==n;){let a=yo(r,e);for(let l of a)l.level=s;if(i.push(a),r=r.parentElement,s++,o.push(...Vn(i)),s>=e.seedMinLength){o.sort(Ct);for(let l of o)yield l;o=[];}}o.sort(Ct);for(let a of o)yield a;}function ve(t){if(/^[a-z\-]{3,}$/i.test(t)){let e=t.split(/-|[A-Z]/);for(let n of e)if(n.length<=2||/[^aeiou]{4,}/i.test(n))return false;return true}return false}function yo(t,e){let n=[],i=t.getAttribute("id");i&&e.idName(i)&&n.push({name:"#"+CSS.escape(i),penalty:0});for(let s=0;s<t.classList.length;s++){let a=t.classList[s];e.className(a)&&n.push({name:"."+CSS.escape(a),penalty:1});}for(let s=0;s<t.attributes.length;s++){let a=t.attributes[s];e.attr(a.name,a.value)&&n.push({name:`[${CSS.escape(a.name)}="${CSS.escape(a.value)}"]`,penalty:2});}let o=t.tagName.toLowerCase();if(e.tagName(o)){n.push({name:o,penalty:5});let s=Rt(t,o);s!==void 0&&n.push({name:Yn(o,s),penalty:10});}let r=Rt(t);return r!==void 0&&n.push({name:xo(o,r),penalty:50}),n}function xe(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 Un(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ct(t,e){return Un(t)-Un(e)}function Rt(t,e){let n=t.parentNode;if(!n)return;let i=n.firstChild;if(!i)return;let o=0;for(;i&&(i.nodeType===Node.ELEMENT_NODE&&(e===void 0||i.tagName.toLowerCase()===e)&&o++,i!==t);)i=i.nextSibling;return o}function vo(t,e){let n=0,i=t,o=[];for(;i&&i!==e;){let r=i.tagName.toLowerCase(),s=Rt(i,r);if(s===void 0)return;o.push({name:Yn(r,s),penalty:NaN,level:n}),i=i.parentElement,n++;}if(Pt(o,e))return o}function xo(t,e){return t==="html"?"html":`${t}:nth-child(${e})`}function Yn(t,e){return t==="html"?"html":`${t}:nth-of-type(${e})`}function*Vn(t,e=[]){if(t.length>0)for(let n of t[0])yield*Vn(t.slice(1,t.length),e.concat(n));else yield e;}function wo(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Pt(t,e){let n=xe(t);switch(e.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return true;default:return false}}function*Gn(t,e,n,i,o){if(t.length>2&&t.length>n.optimizedMinLength)for(let r=1;r<t.length-1;r++){if(new Date().getTime()-o.getTime()>n.timeoutMs)return;let a=[...t];a.splice(r,1),Pt(a,i)&&i.querySelector(xe(a))===e&&(yield a,yield*Gn(a,e,n,i,o));}}var Eo=["role","aria-label","type","name","href","src","data-testid","data-id"];function ko(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 Mt(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let o of i.children){if(o===t)break;o.tagName===t.tagName&&n++;}return `${e}:${n}:${It(t)}`}function It(t){let e=[];for(let n of Eo){let i=t.getAttribute(n);i&&e.push(`${n}=${i}`);}return e.length>0?ko(e.join(",")):"0"}function Qn(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=Mt(t),[c,p,f]=l.split(":"),h=0,d=Math.abs(Number(c)-s);d===0?h+=.2:d<=2?h+=.1:d<=5&&(h+=.03);let g=Math.abs(Number(p)-a);return g===0?h+=.4:g===1?h+=.2:g<=3&&(h+=.08),f===r&&(h+=.4),h}var Xe=256;function je(t,e){let n=t;for(;n&&A(n);)n=n[e];return n}function Jn(t){return t.nodeType===1&&t.getAttribute("data-siteping-ignore")==="true"}function So(t){return t.nodeType===3?NodeFilter.FILTER_ACCEPT:Jn(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP}function ce(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=je(t[n],n),o=3;for(;i&&o>0;){let r=e==="before"?To(i,Xe,true).trim():j(i,Xe,true).trim();if(r)return e==="before"?r.slice(-32):r.slice(0,32);i=je(i[n],n),o--;}return ""}function qe(t){let e=je(t.previousElementSibling,"previousElementSibling"),n=je(t.nextElementSibling,"nextElementSibling"),i=e?j(e,Xe,true).trim().slice(0,40):"",o=n?j(n,Xe,true).trim().slice(0,40):"";return [i,o].filter(Boolean).join(" | ")}function j(t,e,n=false){let i="";if(t.firstElementChild===null){for(let r of t.childNodes)if(r.nodeType===3&&(i+=r.data,i.length>=e))break;return i.length>e?i.slice(0,e):i}let o=n?t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,So):t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;i.length<e;){let r=o.nextNode();if(!r)break;i+=r.data;}return i.length>e?i.slice(0,e):i}function To(t,e,n=false){let i="",o=r=>{for(let s=r.lastChild;s;s=s.previousSibling)if(s.nodeType===3){if(i=s.data+i,i.length>=e)return true}else if(s.nodeType===1&&!(n&&Jn(s))&&o(s))return true;return false};return o(t),i.length>e?i.slice(-e):i}function Zn(t){if(t.getRootNode()instanceof ShadowRoot)return Co(t);let e=Lt(t);if(e)return `//${t.localName}[@id=${_t(e)}]`;let n=[],i=t;for(;i&&i!==document.body&&n.length<6;){let o=i.localName,r=i.parentElement,s=Lt(i);if(s)return n.unshift(`/${o}[@id=${_t(s)}]`),"/"+n.join("");let a=1;if(r)for(let l of r.children){if(l===i)break;l.localName===o&&a++;}n.unshift(`/${o}[${a}]`),i=r;}return i!==document.body?"/"+n.join(""):"/html/body"+n.join("")}function Co(t){let e="";for(let n=t;n;n=n.parentElement){let i=n.localName,o=Lt(n);if(o){e=`/${i}[@id=${_t(o)}]${e}`;continue}let r=1;for(let s=n.previousElementSibling;s;s=s.previousElementSibling)s.localName===i&&r++;e=`/${i}[${r}]${e}`;}return `.${e}`}function Lt(t){return t.id&&t.id.length<=q?t.id:void 0}function _t(t){return t.includes("'")?`concat('${t.replace(/'/g,`',"'",'`)}')`:`'${t}'`}var we="data-feedback-anchor",Nt=" >>> ",ei={className:t=>!/^(css|sc|emotion|styled)-/.test(t)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(t),attr:t=>["data-testid","data-id","role","aria-label"].includes(t),idName:t=>!t.startsWith("radix-")&&!/^:r[0-9]+:$/.test(t),seedMinLength:3,optimizedMinLength:2};function ti(t,e){let n=t;for(;n;){let i=n.closest(e);if(i)return i;let o=n.getRootNode();n=o instanceof ShadowRoot?o.host:null;}return null}function ni(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return e instanceof ShadowRoot?e.host:null}function Ft(t){let e=[],n=t;for(;n;){let d=n.getRootNode();d instanceof ShadowRoot?(e.unshift(At(n,{...ei,root:d})),n=d.host):(e.unshift(At(n,ei)),n=null);}let i=e.join(Nt),o=Zn(t),r=ti(t,'[data-siteping-ignore="true"]')!==null,s=r?"":j(t,256,true).trim().slice(0,120),a=r?"":ce(t,"before"),l=r?"":ce(t,"after"),c=Mt(t),p$1=r?"":qe(t),h=ti(t,`[${we}]`)?.getAttribute(we)??null;return {cssSelector:i,xpath:o,textSnippet:s,textPrefix:a,textSuffix:l,fingerprint:c,neighborText:p$1,elementTag:t.tagName.slice(0,p),elementId:t.id&&t.id.length<=q?t.id:void 0,anchorKey:h}}function ii(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 oi(t,e=document.documentElement){let n=Ot(t.x+t.width/2,t.y+t.height/2);if(!n||n===e)return document.body;let i=n;for(;i&&i!==document.body;){if(i.hasAttribute(we)&&ii(i,t))return i;i=ni(i);}for(i=n;i&&i!==document.body;){if(ii(i,t))return i;i=ni(i);}return document.body}function Ot(t,e){let n=document.elementFromPoint(t,e),i=n?.shadowRoot;for(;i&&typeof i.elementFromPoint=="function";){let o=i.elementFromPoint(t,e);if(!o||o.getRootNode()!==i)break;n=o,i=o.shadowRoot;}return n}function si(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 ri={width:334,height:280},pe={top:0,bottom:0};function ai(t,e,n,i=pe){let o=i.top+8,r=n.height-i.bottom-8,s=Math.max(0,r-o),a=t.bottom+8,l=t.top-8-e.height,c=d=>d>=o&&d+e.height<=r,p,f=null;c(a)?p=a:c(l)?p=l:e.height<=s?p=Math.min(Math.max(a,o),r-e.height):(p=o,f=s);let h=t.left;return h+e.width>n.width-8&&(h=t.right-e.width),h=Math.max(8,Math.min(h,n.width-8-e.width)),{top:p,left:h,maxHeight:f}}var Ro={question:"type.question",change:"type.change",bug:"type.bug",other:"type.other"},Ht=`opacity ${200}ms ease,transform ${200}ms ${z}`,Ao="opacity 300ms ease,transform 300ms cubic-bezier(0.32, 0.72, 0, 1)",Ue=`background-color 0.15s ease,border-color 0.15s ease,color 0.15s ease,box-shadow 0.15s ease,opacity 0.15s ease,scale 0.16s ${z}`,li="blur(30px) saturate(180%)",Ee=class{constructor(e,n){this.colors=e;this.t=n;this.root=E("div",{style:`position:fixed;z-index:${2147483647};pointer-events:auto;width:300px;padding:16px;border:none;border-radius:18px;color:${this.colors.text};font-family:${qa};opacity:0;transform:scale(0.96);transition:${Ht};display:none;-webkit-font-smoothing:antialiased;`}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("data-siteping-ignore","true");let i=[{type:"question",icon:_},{type:"change",icon:$},{type:"bug",icon:aa},{type:"other",icon:ba}];this.typeRow=E("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:12px;"});for(let r of i){let s=document.createElement("button");s.style.cssText=`height:50px;padding:0 12px;border:none;border-radius:12px;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-family:${qa};font-size:13px;font-weight:500;letter-spacing:-0.005em;transition:${Ue};`;let a=D(r.icon);a.style.cssText=`width:17px;height:17px;flex-shrink:0;color:${ma(r.type,this.colors)};`,s.appendChild(a),s.appendChild(document.createElement("span")),s.dataset.type=r.type,s.setAttribute("aria-pressed","false"),this.paintType(s),s.addEventListener("click",()=>{this.submittingState||this.selectType(r.type,this.typeRow);}),s.addEventListener("mouseenter",()=>{this.submittingState||!ua()||this.paintType(s,true);}),s.addEventListener("mouseleave",()=>{this.submittingState||this.paintType(s);}),M(s),N(s,this.colors.accent),this.typeRow.appendChild(s);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`width:100%;min-height:80px;max-height:152px;padding:9px 12px;border:none;border-radius:12px;color:${this.colors.text};font-family:${qa};font-size:15px;line-height:1.35;letter-spacing:-0.01em;resize:vertical;outline:none;box-shadow:none;transition:${Ue};box-sizing:border-box;`,this.textarea.maxLength=5e3,this.paintField(false),this.hint=E("div",{style:`font-size:11px;color:${this.colors.textSecondary};text-align:right;margin-top:6px;font-family:${qa};letter-spacing:0.01em;`}),this.textarea.addEventListener("focus",()=>{this.submittingState||this.paintField(true);}),this.textarea.addEventListener("blur",()=>{this.submittingState||this.paintField(false);}),this.textarea.addEventListener("input",()=>{this.updateSubmitState();}),this.textarea.addEventListener("keydown",r=>{this.submittingState||r.key==="Enter"&&(r.ctrlKey||r.metaKey)&&(r.preventDefault(),this.submit());});let o=E("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"});this.cancelBtn=document.createElement("button"),this.cancelBtn.style.cssText=`height:34px;padding:0 18px;border:none;border-radius:9999px;color:${this.colors.text};font-family:${qa};font-size:15px;font-weight:500;letter-spacing:-0.01em;cursor:pointer;transition:${Ue};`,this.paintCancel(false),this.cancelBtn.addEventListener("click",()=>this.dismiss()),this.cancelBtn.addEventListener("mouseenter",()=>{this.submittingState||!ua()||this.paintCancel(true);}),this.cancelBtn.addEventListener("mouseleave",()=>{this.submittingState||this.paintCancel(false);}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`position:relative;height:34px;padding:0 20px;border:none;border-radius:9999px;background:${this.colors.accent};color:#fff;font-family:${qa};font-size:15px;font-weight:600;letter-spacing:-0.01em;cursor:pointer;opacity:0.35;pointer-events:none;transition:${Ue};display:inline-flex;align-items:center;justify-content:center;min-width:64px;`,this.submitLabel=document.createElement("span"),this.submitBtn.appendChild(this.submitLabel),this.submitBtn.addEventListener("click",()=>this.submit()),this.submitBtn.addEventListener("mouseenter",()=>{this.submittingState||!ua()||(this.submitBtn.style.background=this.colors.accentDark);}),this.submitBtn.addEventListener("mouseleave",()=>{this.submitBtn.style.background=this.colors.accent;}),M(this.cancelBtn),M(this.submitBtn),N(this.cancelBtn,this.colors.accent),N(this.submitBtn,this.colors.accent),o.appendChild(this.cancelBtn),o.appendChild(this.submitBtn),this.root.appendChild(this.typeRow),this.root.appendChild(this.textarea),this.root.appendChild(this.hint),this.root.appendChild(o),O(this.root),document.body.appendChild(this.root),this.applyLabels();}colors;t;root;selectedType=null;textarea;submitBtn;cancelBtn;typeRow;submitLabel;hint;resolve=null;previouslyFocused=null;removeKeydownTrap=null;onSubmit=null;submittingState=false;showFrame=null;hideTimeoutId=null;spinnerAnimation=null;sheet=false;stopKeyboardTracking=null;get isOpen(){return this.resolve!==null}get sheetTop(){return this.sheet&&this.isOpen?window.innerHeight-this.root.offsetHeight: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=Ro[i];if(!o)continue;let r=n.querySelector("span");r&&F(r,this.t(o));}this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria")),F(this.hint,K()?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),F(this.cancelBtn,this.t("popup.cancel")),F(this.submitLabel,this.t("popup.submit"));}show(e,n,i=pe){return new Promise(o=>{this.cancelPendingTransition(),this.resolve=o,this.onSubmit=n??null,this.selectedType=null,this.textarea.value="",this.submittingState=false;let r=ta();this.sheet=sa(),this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let s=this.sheet?"48px":r?"44px":"34px";this.cancelBtn.style.height=s,this.submitBtn.style.height=s,this.cancelBtn.style.flex=this.sheet?"1":"",this.submitBtn.style.flex=this.sheet?"2":"",this.textarea.style.fontSize=r?"16px":"15px",this.textarea.style.minHeight=this.sheet?"104px":"80px",this.paintField(false),this.paintCancel(false),this.submitBtn.style.background=this.colors.accent,this.hint.style.display=r?"none":"",this.root.style.transform=this.hiddenTransform(),P(this.root,false),this.root.style.display="block",this.layout(e,i),this.removeKeydownTrap?.(),this.removeKeydownTrap=R(this.root,a=>{if(a.key==="Escape"&&this.dismiss(),a.key==="Tab"){let l=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(l.length===0)return;let c=l[0],p=l[l.length-1];if(!c||!p)return;a.shiftKey?(document.activeElement===c||!this.root.contains(document.activeElement))&&(a.preventDefault(),p.focus()):(document.activeElement===p||!this.root.contains(document.activeElement))&&(a.preventDefault(),c.focus());}}),this.root.style.transition=va()?"none":this.sheet?Ao:Ht,this.showFrame=requestAnimationFrame(()=>{this.showFrame=null,this.root.style.opacity="1",this.root.style.transform="none",(r?this.typeRow.querySelector("button"):this.textarea)?.focus();});})}layout(e,n){let i=this.root.style,{surface:o}=this.colors;if(i.width=this.sheet?"auto":"300px",i.borderRadius=this.sheet?"16px 16px 0 0":"18px",i.background=this.sheet?o.grouped:o.material,i.backdropFilter=this.sheet?"none":li,i.setProperty("-webkit-backdrop-filter",this.sheet?"none":li),i.boxShadow=this.sheet?`0 -0.5px 0 ${o.hairline}, 0 -10px 40px rgba(0, 0, 0, 0.16)`:`inset 0 0.5px 0 ${o.edge}, ${o.shadowCard}`,i.overscrollBehavior=this.sheet?"contain":"",this.stopKeyboardTracking?.(),this.stopKeyboardTracking=null,this.sheet){i.top="auto",i.left="0",i.right="0",i.overflowY="auto";let f=(h,d=window.innerHeight)=>{i.bottom=`${h}px`,i.maxHeight=`${d-8}px`,i.padding=`16px 16px ${h>0?"16px":"calc(16px + env(safe-area-inset-bottom, 0px))"}`;};f(0),this.stopKeyboardTracking=wa(f);return}i.right="",i.bottom="",i.padding="16px",i.maxHeight="",i.overflowY="";let{top:r,left:s,maxHeight:a}=ai(e,this.measure(),{width:window.innerWidth,height:window.innerHeight},n);i.top=`${r}px`,i.left=`${s}px`;let{width:l,height:c}=this.measure(),p=Math.min(Math.max(e.left+e.width/2-s,0),l);i.transformOrigin=`${Math.round(p)}px ${r>=e.top+e.height/2?0:c}px`,a!==null&&(i.maxHeight=`${Math.max(0,a-this.verticalChromeHeight())}px`,i.overflowY="auto",this.root.scrollTop=0);}hiddenTransform(){return this.sheet?"translateY(100%)":"scale(0.96)"}measure(){let e=this.root.offsetWidth,n=this.root.offsetHeight;return e>0&&n>0?{width:e,height:n}:ri}verticalChromeHeight(){let e=window.getComputedStyle(this.root);return e.boxSizing==="border-box"?0:[e.paddingTop,e.paddingBottom,e.borderTopWidth,e.borderBottomWidth].reduce((n,i)=>n+(Number.parseFloat(i)||0),0)}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let o of i)o.setAttribute("aria-pressed",String(o.dataset.type===e)),this.paintType(o);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.cursor="pointer",this.paintType(n);}paintType(e,n=false){let{surface:i}=this.colors,o=e.style;if(e.getAttribute("aria-pressed")==="true"){let r=ma(e.dataset.type??"",this.colors);o.background=`color-mix(in srgb, ${r} 15%, ${i.row})`,o.color=`color-mix(in srgb, ${r} 78%, ${i.inkMix})`,o.fontWeight="600",o.boxShadow=`inset 0 0 0 1.5px ${r}`;return}o.background=n?i.fillStrong:this.sheet?i.row:i.fill,o.color=this.colors.text,o.fontWeight="500",o.boxShadow="none";}paintField(e){let{surface:n}=this.colors;this.textarea.style.background=e||this.sheet?n.row:n.fill,this.textarea.style.boxShadow=e?`0 0 0 3px color-mix(in srgb, ${this.colors.accent} 30%, transparent)`:"none";}paintCancel(e){let{surface:n}=this.colors;this.cancelBtn.style.background=e||this.sheet?n.fillStrong:n.fill;}updateSubmitState(){if(this.submittingState)return;let e=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.textarea.value.trim())return;let e={type:this.selectedType??"other",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();});}dismiss(){this.submittingState||!this.isOpen||(this.resolve?.(null),this.resolve=null,this.hideElement());}enterSubmittingState(){this.submittingState=true,this.submitLabel.style.opacity="0",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.opacity="",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="position:absolute;inset:0;margin:auto;width:14px;height:14px;border:2px solid rgba(255,255,255,0.35);border-top-color:#fff;border-radius:50%;box-sizing:border-box;",!va()&&typeof e.animate=="function"&&(this.spinnerAnimation=e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:600,iterations:1/0,easing:"linear"})),e}hideElement(){if(this.cancelPendingTransition(),this.removeKeydownTrap?.(),this.removeKeydownTrap=null,this.submittingState&&this.exitSubmittingState(),this.onSubmit=null,this.stopKeyboardTracking?.(),this.stopKeyboardTracking=null,va()||(this.root.style.transition=Ht),this.root.style.opacity="0",this.root.style.transform=this.hiddenTransform(),this.previouslyFocused?.focus(),this.previouslyFocused=null,P(this.root,true),va()){this.root.style.display="none";return}this.hideTimeoutId=setTimeout(()=>{this.hideTimeoutId=null,this.root.style.display="none";},200);}cancelPendingTransition(){this.showFrame!==null&&cancelAnimationFrame(this.showFrame),this.hideTimeoutId!==null&&clearTimeout(this.hideTimeoutId),this.showFrame=null,this.hideTimeoutId=null;}destroy(){this.submittingState&&this.exitSubmittingState(),this.cancelPendingTransition(),this.resolve?.(null),this.resolve=null,this.onSubmit=null,this.removeKeydownTrap?.(),this.removeKeydownTrap=null,this.stopKeyboardTracking?.(),this.stopKeyboardTracking=null,this.root.remove();}};var ke,ci=false;async function Po(){if(ke!==void 0)return ke;try{let t=await import('html2canvas-pro');return ke=t.default??t,ke}catch(t){return ke=null,ci||(ci=true,console.warn("[siteping] html2canvas-pro import failed unexpectedly. Capture is disabled for this session \u2014 feedbacks are still submitted, just without screenshots. Underlying error:",t)),null}}function $t(t,e,n){return Math.min(n,Math.max(t,e))}function Ye(t){return $t(0,Math.round(t*1e4)/1e4,1)}async function pi(t,e){let n=await Po();if(!n)return null;let i=.85,o=1200,r=$t(48,t.width*.6,280),s=$t(48,t.height*.6,220),a=window.scrollX+t.x,l=window.scrollY+t.y,c=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),p=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),f=Math.max(0,a-r),h=Math.max(0,l-s),d=Math.min(c,a+t.width+r)-f,g=Math.min(p,l+t.height+s)-h;if(d<=0||g<=0)return null;let v={xPct:Ye((a-f)/d),yPct:Ye((l-h)/g),wPct:Ye(t.width/d),hPct:Ye(t.height/g)};try{let k=await n(document.body,{x:f,y:h,width:d,height:g,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,ignoreElements:$=>$.tagName==="SITEPING-WIDGET"||$.closest?.("siteping-widget")!==null||$.getAttribute?.("data-siteping-ignore")==="true"});if(k.width<=o)return {dataUrl:k.toDataURL("image/jpeg",i),region:v};let H=o/k.width,S=o,w=Math.round(k.height*H),D=document.createElement("canvas");D.width=S,D.height=w;let P=D.getContext("2d");return P?(P.drawImage(k,0,0,S,w),{dataUrl:D.toDataURL("image/jpeg",i),region:v}):null}catch(k){return console.warn("[siteping] Screenshot capture failed:",k),null}}var di=10;function Mo(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-transparency: reduce), (prefers-contrast: more)").matches}var ne={bg:"rgba(0, 0, 0, 0.86)",bgSolid:"#000000",text:"#f5f5f7",instruction:"rgba(255, 255, 255, 0.94)",cancelBg:"rgba(255, 255, 255, 0.16)",cancelHoverBg:"rgba(255, 69, 58, 0.26)",cancelHoverText:"#ff8a80"};function ui(t){let e=Math.max(0,t.left),n=Math.max(0,t.top);return new DOMRect(e,n,Math.max(0,Math.min(t.right,window.innerWidth)-e),Math.max(0,Math.min(t.bottom,window.innerHeight)-n))}function Io(){return {clientId:r()}}var Ve=class{constructor(e,n,i,o=false,r){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.getFallbackTarget=r;this.popup=new Ee(e,i),this.bus.on("annotation:start",()=>this.activate());}colors;bus;t;enableScreenshot;getFallbackTarget;overlay=null;toolbar=null;toolbarCancel=null;cancelFrozen=false;drawingRect=null;startX=0;startY=0;isDrawing=false;isActive=false;instantMode=false;popup;stalePopup=false;savedOverflow="";preActiveFocusElement=null;keyboardTarget=null;rafId=null;pendingMoveEvent=null;rejectPendingSubmission=null;unregisterEscapeLayer=Q(document,()=>this.isActive);get isBusy(){return this.isActive}refreshLabels(){this.popup.refreshLabels();}restyle(){this.stalePopup=this.isActive||this.popup.isOpen,!this.stalePopup&&(this.popup.destroy(),this.popup=new Ee(this.colors,this.t));}async maybeCapture(e){return this.enableScreenshot?pi(e):null}activate(){if(this.isActive)return;this.isActive=true;let e=!this.instantMode,n=ta(),i=this.t("annotator.instruction");this.preActiveFocusElement=document.activeElement;let o=document.activeElement;if(this.keyboardTarget=o instanceof HTMLElement&&o!==document.body&&o!==document.documentElement&&!A(o)?B(o):this.getFallbackTarget?.()??null,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=E("div",{style:`position:fixed;inset:0;z-index:${2147483646};pointer-events:auto;background:${this.colors.surface.overlayTint};cursor:${e?"crosshair":"default"};touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;`}),this.overlay.setAttribute("role","application"),this.overlay.setAttribute("aria-label",e?i:this.t("annotator.instantInstruction")),this.overlay.setAttribute("data-siteping-ignore","true"),e){let r=Mo()?`background:${ne.bgSolid};`:`background:${ne.bg};backdrop-filter:blur(24px) saturate(180%);-webkit-backdrop-filter:blur(24px) saturate(180%);`;this.toolbar=E("div",{style:`position:fixed;top:calc(env(safe-area-inset-top,0px) + 10px);left:0;right:0;width:max-content;max-width:calc(100vw - 24px);margin:0 auto;z-index:${2147483647};pointer-events:auto;min-height:44px;box-sizing:border-box;padding:5px 5px 5px 16px;border:none;border-radius:22px;${r} box-shadow:inset 0 0 0 0.5px rgba(255,255,255,0.14),0 12px 32px rgba(0,0,0,0.28);display:flex;align-items:center;justify-content:center;gap:12px;font-family:${qa};font-size:13px;line-height:1.35;color:${ne.text};-webkit-font-smoothing:antialiased;`}),this.toolbar.setAttribute("data-siteping-ignore","true");let s=`color-mix(in srgb, ${this.colors.accent} 50%, #ffffff)`,a=E("span",{style:`width:8px;height:8px;border-radius:50%;flex-shrink:0;background:${s};box-shadow:0 0 10px color-mix(in srgb,${this.colors.accent} 60%,#ffffff);`});!va()&&typeof a.animate=="function"&&a.animate([{opacity:1},{opacity:.4},{opacity:1}],{duration:1500,easing:"ease-in-out",iterations:1/0});let l=E("span",{style:`font-weight:500;letter-spacing:-0.005em;min-width:0;color:${ne.instruction};`});F(l,n?this.t("annotator.touchInstruction"):i);let c=document.createElement("button");c.style.cssText=`height:${n?40:34}px;padding:0 14px;border:none;border-radius:9999px;flex-shrink:0;color:#ffffff;font-family:${qa};font-size:13px;font-weight:600;cursor:pointer;touch-action:manipulation;transition:background-color 0.15s ease,color 0.15s ease,opacity 0.15s ease,scale 0.16s ${z};`,F(c,this.t("annotator.cancel")),c.addEventListener("click",()=>this.cancelSession()),M(c),N(c,s),c.addEventListener("mouseenter",()=>{!this.cancelFrozen&&ua()&&this.paintCancel(true);}),c.addEventListener("mouseleave",()=>this.paintCancel(false)),this.toolbarCancel=c,this.paintCancel(false),this.toolbar.appendChild(a),this.toolbar.appendChild(l),this.toolbar.appendChild(c);}e&&(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),O(this.overlay),this.toolbar&&O(this.toolbar),document.body.appendChild(this.overlay),this.toolbar&&(document.body.appendChild(this.toolbar),!va()&&typeof this.toolbar.animate=="function"&&this.toolbar.animate([{transform:"translateY(-100%)"},{transform:"none"}],{duration:250,easing:z})),this.overlay.focus({preventScroll:true});}toolbarInsets(){if(!this.toolbar)return pe;if(typeof this.toolbar.getAnimations=="function")for(let o of this.toolbar.getAnimations())o.finish();let e=this.toolbar.getBoundingClientRect();if(e.height===0)return pe;let n=window.innerHeight;return e.top+e.height/2<n/2?{top:Math.max(0,e.bottom),bottom:0}:{top:0,bottom:Math.max(0,n-e.top)}}cancelSession(){this.isActive&&(this.popup.dismiss(),!this.popup.isOpen&&this.deactivate());}paintCancel(e){let n=this.toolbarCancel;n&&(n.style.color=e?ne.cancelHoverText:"#ffffff",n.style.background=e?ne.cancelHoverBg:ne.cancelBg);}freezeCancel(e){this.cancelFrozen=e;let n=this.toolbarCancel;n&&(e&&this.paintCancel(false),n.style.opacity=e?"0.5":"1",n.style.cursor=e?"not-allowed":"pointer",e?n.setAttribute("aria-disabled","true"):n.removeAttribute("aria-disabled"));}deactivate(){if(!this.isActive)return;this.isActive=false,this.isDrawing=false,this.instantMode=false;let e=this.preActiveFocusElement;this.preActiveFocusElement=null,this.keyboardTarget=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.toolbarCancel=null,this.cancelFrozen=false,this.drawingRect=null,e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:true}),this.bus.emit("annotation:end"),this.stalePopup&&this.restyle();}onKeyDown=e=>{e.key==="Escape"&&this.cancelSession();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"||(e.preventDefault(),this.popup.isOpen)||this.isDrawing)return;let n=this.keyboardTarget;!n||!(n instanceof HTMLElement)||await this.annotateElement(n);};async annotateElement(e,n=false){let i=e.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let o=new DOMRect(i.x,i.y,i.width,i.height);this.drawingRect?.remove();let r=this.createDrawingRect();r.style.left=`${i.x}px`,r.style.top=`${i.y}px`,r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,this.drawingRect=r,this.overlay?.appendChild(r);let a={anchor:Ft(e),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.openForm(a,o,n?ui(o):o);this.drawingRect?.remove(),this.drawingRect=null,l&&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.popup.isOpen||(this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=this.createDrawingRect(),this.overlay?.appendChild(this.drawingRect));}createDrawingRect(){let{accent:e}=this.colors,n=E("div",{style:`position:fixed;border:2px solid ${e};background:color-mix(in srgb,${e} 10%,transparent);pointer-events:none;border-radius:12px;box-shadow:0 0 0 4px color-mix(in srgb,${e} 16%,transparent),0 8px 24px rgba(0,0,0,0.08);transition:box-shadow 0.15s ease;`});return n.setAttribute("data-siteping-ignore","true"),n}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);};elementAt(e,n){this.overlay&&(this.overlay.style.pointerEvents="none");let i=Ot(e,n);this.overlay&&(this.overlay.style.pointerEvents="auto");let o=i instanceof SVGElement?(i.ownerSVGElement??i).parentElement:i;return o instanceof HTMLElement&&o!==document.body&&o!==document.documentElement&&!A(o)?o:null}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<di||s<di){this.drawingRect.remove(),this.drawingRect=null;let p=this.elementAt(e,n);p&&await this.annotateElement(p,true);return}let a=new DOMRect(i,o,r,s),{annotation:l}=this.buildAnnotation(a),c=await this.openForm(l,a);this.drawingRect?.remove(),this.drawingRect=null,c&&this.deactivate();};async startInstantAnnotation(e,n){if(this.isActive)return;this.instantMode=true,this.bus.emit("annotation:start");let i=Math.max(0,Math.min(e-20/2,window.innerWidth-20)),o=Math.max(0,Math.min(n-20/2,window.innerHeight-20)),r=new DOMRect(i,o,20,20),{annotation:s,anchorBounds:a}=this.buildAnnotation(r),l=ui(a);this.drawingRect?.remove(),this.drawingRect=this.createDrawingRect(),Object.assign(this.drawingRect.style,{left:`${i}px`,top:`${o}px`,width:`${20}px`,height:`${20}px`}),this.overlay?.appendChild(this.drawingRect),await this.openForm(s,r,l),this.drawingRect?.remove(),this.drawingRect=null,this.deactivate();}openForm(e,n,i=n){let o=Io(),r=this.popup.show(n,s=>(this.freezeCancel(true),this.runSubmission(e,s,i,o).finally(()=>this.freezeCancel(false))),this.toolbarInsets());return this.revealSelection(n),r}revealSelection(e){let n=this.popup.sheetTop;if(n===null||!this.drawingRect)return;let i=Math.min(e.bottom+16-n,e.top-72);if(i<=0)return;let o=window.scrollY;window.scrollBy({top:i,behavior:"instant"}),this.drawingRect.style.top=`${e.top-(window.scrollY-o)}px`;}async runSubmission(e,n,i,o){o.screenshot===void 0&&(o.screenshot=await this.maybeCapture(new DOMRect(i.x+e.scrollX-window.scrollX,i.y+e.scrollY-window.scrollY,i.width,i.height)));let r=o.screenshot;await new Promise((s,a)=>{let l=()=>{c(),p(),f(),h(),this.rejectPendingSubmission=null;},c=this.bus.on("feedback:sent",()=>{l(),s();}),p=this.bus.on("feedback:queued",()=>{l(),s();}),f=this.bus.on("feedback:error",d=>{l(),a(d);}),h=this.bus.on("submission:cancelled",()=>{l(),a(new Error("Feedback submission cancelled"));});this.rejectPendingSubmission=d=>{l(),a(d);},this.bus.emit("annotation:complete",{annotation:e,type:n.type,message:n.message,clientId:o.clientId,screenshotDataUrl:r?.dataUrl??null,screenshotRegion:r?.region??null});});}buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=oi(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Ft(n),o=n.getBoundingClientRect(),r=si(e,o);return {annotation:{anchor:i,rect:r,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},anchorBounds:o}}destroy(){this.deactivate(),this.unregisterEscapeLayer(),this.rejectPendingSubmission?.(new Error("Annotator destroyed during submission")),this.popup.destroy();}};function Ge(t,e){let n=`siteping_own_feedback:${JSON.stringify([t,e??null])}`,i=()=>{try{let r=JSON.parse(localStorage.getItem(n)??"[]");return new Set(Array.isArray(r)?r.filter(s=>typeof s=="string"):[])}catch{return new Set}},o=r=>{try{r.size>0?localStorage.setItem(n,JSON.stringify([...r].slice(-500))):localStorage.removeItem(n);}catch{}};return {ids:i,add(r){let s=i();s.delete(r),o(s.add(r));},remove(...r){let s=i(),a=s.size;for(let l of r)s.delete(l);s.size<a&&o(s);},clear:()=>o(new Set)}}var hi=3,Se=1e4,Lo=1e4,_o=6e4,ie="siteping_retry_queue",No=20;function zt(t,e,n){let i,o=new Promise((r,s)=>{i=setTimeout(()=>s(n()),e);});return Promise.race([t,o]).finally(()=>clearTimeout(i))}async function vi(t$1,e){let n={};e&&(n["Content-Type"]="application/json"),t$1.apiKey&&(n.Authorization=`Bearer ${t$1.apiKey}`);let i=typeof t$1.headers=="function"?await zt(Promise.resolve(t$1.headers()),Se,()=>new Error(`headers factory did not settle within ${Se/1e3} s`)):t$1.headers;return t(n,i)}async function de(t,e,n,i,{boundBody:o=false,timeoutMs:r=Se,resendOnTimeout:s=true}={}){for(let a=0;;a++){let l=new AbortController,c=setTimeout(()=>l.abort(),r),p;try{let f=await fetch(t,{...e,signal:l.signal}).catch(h=>{if(a===hi||!s&&l.signal.aborted)throw x(h,n);return null});if(p=Fo(f,a),f&&(!xi(f.status)||a===hi||p>Lo)){if(clearTimeout(c),o&&(c=setTimeout(()=>l.abort(),Se)),!f.ok)throw await v(f,n);return await i(f).catch(h=>{throw x(h,n)})}}finally{clearTimeout(c);}await new Promise(f=>setTimeout(f,p));}}function Fo(t,e){let n=t?.headers.get("Retry-After"),i=n?/^\d+$/.test(n)?Number(n)*1e3:Date.parse(n)-Date.now():Number.NaN;return Number.isNaN(i)?1e3*2**e+Math.random()*1e3-500:Math.max(0,i)}function Oo(t){return t instanceof d||t instanceof c&&t.code==="SERVER"}function xi(t){return t>=500||t===408||t===429}var Ho="siteping_retry_queue";async function Kt(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(Ho,()=>t()):t()}function Do(t){if(!b(t,"endpoint")||typeof t.endpoint!="string"||!b(t,"payload"))return false;let{payload:e}=t;return b(e,"authorName")&&typeof e.authorName=="string"&&b(e,"authorEmail")&&typeof e.authorEmail=="string"}function Wt(){let t=localStorage.getItem(ie);if(!t)return [];let e;try{e=JSON.parse(t);}catch{return localStorage.removeItem(ie),console.warn(`[siteping] discarded an unreadable retry queue from localStorage (${t.length} chars)`),[]}return Array.isArray(e)?e.filter(Do):[]}var wi=new WeakMap;function Ei(t){return typeof t=="object"&&t!==null?wi.get(t):void 0}function $o(t,e){return Kt(()=>{try{let n=Wt().filter(r=>r.payload.clientId!==e.clientId);if(n.length>=No&&n.shift(),n.push({endpoint:t,payload:e}),Bt(n))return !0;let i=n.slice(),o=0;for(let[r,s]of i.entries())if(fi(s)&&(i[r]=zo(s),o+=1,Bt(i)))return console.warn(`[siteping] retry queue exceeded the localStorage quota \u2014 dropped the screenshot of ${o} of ${n.length} queued feedback(s)`),!0;for(;i.length>1;)if(i.shift(),Bt(i)){let r=n.length-i.length,s=n.slice(r).filter(fi).length;return console.warn(`[siteping] retry queue exceeded the localStorage quota \u2014 dropped the ${r} oldest of ${n.length} queued feedback(s)${s>0?`, and the screenshot of ${s} of the rest`:""}`),!0}console.warn("[siteping] feedback could not be queued for retry \u2014 localStorage is full or unavailable");}catch{}return false}).catch(()=>false)}function Bo(t){Kt(()=>{try{let e=Wt(),n=e.filter(i=>i.payload.clientId!==t);if(n.length===e.length)return;n.length>0?localStorage.setItem(ie,JSON.stringify(n)):localStorage.removeItem(ie);}catch{}});}function Bt(t){try{return localStorage.setItem(ie,JSON.stringify(t)),!0}catch{return false}}function fi(t){return t.payload.screenshotDataUrl!=null}function zo(t){let{screenshotDataUrl:e,screenshotRegion:n,...i}=t.payload;return {endpoint:t.endpoint,payload:i}}function mi(t){return t.trim()}function gi(t){return t.trim().toLowerCase()}async function ki(t,e,n={}){await Kt(async()=>{try{let i=Wt();if(i.length===0)return;let o=[],r=[],s=0;for(let p of i){if(p.endpoint!==t){r.push(p);continue}!e||mi(p.payload.authorName)===mi(e.name)&&gi(p.payload.authorEmail)===gi(e.email)?o.push(p):s+=1;}if(o.length===0&&s===0)return;s>0;let a=[],l=0;if(o.length>0){let p=await vi(n,!0);for(let f of o){let h=new AbortController,d=setTimeout(()=>h.abort(),Se);try{let g=await fetch(t,{method:"POST",headers:p,body:JSON.stringify(f.payload),signal:h.signal});if(g.ok){let v=await g.json().catch(()=>null);b(v,"id")&&typeof v.id=="string"&&Ge(f.payload.projectName,t).add(v.id);continue}xi(g.status)?a.push(f):l+=1;}catch{a.push(f);}finally{clearTimeout(d);}}}l>0&&console.warn(`[siteping] flushRetryQueue: dropped ${l} queued feedback(s) the server rejected (4xx) \u2014 they would fail identically on every replay`);let c=r.concat(a);c.length>0?localStorage.setItem(ie,JSON.stringify(c)):localStorage.removeItem(ie);}catch{}});}function bi(t,e){let n=Math.min(1,Math.max(0,t)),i=e-(n-t);return [n,Math.max(0,n+i<=1?i:1-n)]}function Ko(t){let[e,n]=bi(t.rect.xPct,t.rect.wPct),[i,o]=bi(t.rect.yPct,t.rect.hPct);return {...t,rect:{xPct:e,yPct:i,wPct:n,hPct:o}}}async function Qe(t){return await t.json()}async function yi(){}var Je=class{constructor(e,n,i={}){this.endpoint=e;this.projectName=n;this.auth=i;}endpoint;projectName;auth;listRefusalExplained=false;async headers(e,n){try{return await vi(this.auth,e)}catch(i){throw x(i,n)}}async sendFeedback(e){let n="Failed to send feedback",{screenshotRegion:i,...o}=e,r={...o,annotations:o.annotations.map(Ko)},s=i?{...r,screenshotRegion:i}:r;try{let a=await de(this.endpoint,{method:"POST",headers:await this.headers(!0,n),body:JSON.stringify(s)},n,Qe,{boundBody:!0});return Bo(s.clientId),a}catch(a){throw Oo(a)&&wi.set(a,await $o(this.endpoint,s)),a}}async getFeedbacks(e$1,n){let i="Failed to fetch feedbacks",o=s({projectName:e$1,...n}),r=await this.headers(false,i);return de(u(this.endpoint,o),{method:"GET",cache:"no-store",...Object.keys(r).length>0?{headers:r}:{}},i,Qe).catch(s=>{throw s instanceof e&&!this.listRefusalExplained&&(this.listRefusalExplained=true,console.warn(`[siteping] Feedback list refused (${s.status}): with an apiKey, GET needs it unless publicEndpoints includes "GET"; pins and panel stay empty. https://siteping.dev/docs/server#the-security-model-honestly`)),s})}async addComment(e,n){let i="Failed to post comment";return de(this.endpoint,{method:"POST",headers:await this.headers(true,i),body:JSON.stringify({...n,projectName:this.projectName,feedbackId:e})},i,Qe,{boundBody:true})}async resolveFeedback(e,n){let i="Failed to update feedback";return de(this.endpoint,{method:"PATCH",headers:await this.headers(true,i),body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})},i,Qe)}async deleteFeedback(e){let n="Failed to delete feedback";await de(this.endpoint,{method:"DELETE",headers:await this.headers(true,n),body:JSON.stringify({id:e,projectName:this.projectName})},n,yi);}async deleteAllFeedbacks(e){let n="Failed to delete all feedbacks";await de(this.endpoint,{method:"DELETE",headers:await this.headers(true,n),body:JSON.stringify({projectName:e,deleteAll:true})},n,yi,{timeoutMs:_o,resendOnTimeout:false});}};function Ze(t,e){if(t.length<=e)return t;let n=e-1,i=t.charCodeAt(n-1);return i>=55296&&i<=56319&&(n-=1),`${t.slice(0,n)}\u2026`}var Xt=50,jt=500,Wo=["log","info","warn","error"];function Xo(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?`
|
|
2
|
-
${t.stack}`:""}`;try{let e=[],n=jt;return JSON.stringify(t,function(i,o){if(!(--n<0)){if(typeof o=="function")return "[Function]";if(typeof o=="symbol")return o.toString();if(typeof o!="object"||o===null)return o;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(o)?"[Circular]":(e.push(o),o)}})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function jo(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=Xo(t[n]),!(e.length>=jt));n++);return Ze(e,jt)}var et=class{maxEntries;entries=[];originals=new Map;wrappers=new Map;disposed=false;constructor(e=Xt){if(this.maxEntries=Number.isFinite(e)&&e>=0?Math.min(Math.floor(e),Xt):Xt,!(typeof console>"u"))for(let n of Wo){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{}this.wrappers.set(n,r),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:jo(n)}));}getEntries(){return this.entries.slice()}dispose(){if(this.disposed||(this.disposed=true,typeof console>"u"))return;let e=console;for(let[n,i]of this.originals)if(e[n]===this.wrappers.get(n))try{e[n]=i;}catch{}this.originals.clear(),this.wrappers.clear();}};var qt=20,qo=2e3,Uo=20,Yo=6e5,Vo=599;function Si(t){let e=Go(Qo(t)),n=e.search(/[?#]/);return Ze(n===-1?e:e.slice(0,n),qo)}function Go(t){try{let e=new URL(t,typeof location>"u"?void 0:location.href);return !e.username&&!e.password?t:(e.username="",e.password="",e.href)}catch{return t}}function Qo(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 tt=class{maxEntries;entries=[];originalFetch=null;originalXhrOpen=null;originalXhrSend=null;wrappedFetch=null;wrappedXhrOpen=null;wrappedXhrSend=null;disposed=false;constructor(e=qt){this.maxEntries=Number.isFinite(e)&&e>=0?Math.min(Math.floor(e),qt):qt,this.installFetch(),this.installXhr();}push(e){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({...e,method:e.method.slice(0,Uo),status:e.status<=Vo?e.status:0,durationMs:Math.min(Math.max(e.durationMs,0),Yo)}));}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=Si(i),l=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,o);if(!c.ok){let p=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:c.status,durationMs:Math.round(p-s),timestamp:r.toISOString()});}return c}catch(c){let p=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(p-s),timestamp:r.toISOString()}),c}};this.wrappedFetch=n,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,s=function(l,c,...p){try{r.set(this,{method:l.toUpperCase(),url:Si(c),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,l,c,...p)},a=function(l){let c=r.get(this);if(c){let p=()=>{try{let f=typeof performance<"u"?performance.now():Date.now(),h=this.status;(h===0||h>=400)&&o.push({url:c.url,method:c.method,status:h,durationMs:Math.round(f-c.t0),timestamp:c.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",p,{once:!0});}catch{try{this.addEventListener("loadend",p);}catch{}}}return i.call(this,l??null)};this.wrappedXhrOpen=s,this.wrappedXhrSend=a,e.open=s,e.send=a;}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&globalThis.fetch===this.wrappedFetch)try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{let e=XMLHttpRequest.prototype;this.originalXhrOpen&&e.open===this.wrappedXhrOpen&&(e.open=this.originalXhrOpen),this.originalXhrSend&&e.send===this.wrappedXhrSend&&(e.send=this.originalXhrSend);}catch{}}}};var Te=class{listeners=new Map;on(e,n){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(n),()=>{i?.delete(n);}}off(e,n){this.listeners.get(e)?.delete(n);}emit(e,...n){let i=this.listeners.get(e);if(i)for(let o of i)try{o(...n);}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var Jo=54,Zo=60,es={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},nt=class{constructor(e,n,i,o){this.bus=i;this.t=o;let r=n.position??"bottom-right";this.items=[{id:"chat",icon:ia},{id:"annotate",icon:ja}],n.showAnnotationsToggle!==false&&this.items.push({id:"toggle-annotations",icon:U,iconAlt:V}),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(D(T)),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"),I(this.radialContainer,true);for(let l=0;l<this.items.length;l++){let c=this.items[l];if(!c)continue;let p=document.createElement("button");p.className="sp-radial-item",p.style.setProperty("--sp-i",String(l)),p.appendChild(D(c.icon)),p.setAttribute("role","menuitem"),p.dataset.itemId=c.id,p.addEventListener("click",h=>{h.stopPropagation(),this.handleItemClick(c.id);});let f=document.createElement("span");f.className="sp-radial-label",p.appendChild(f),this.radialContainer.appendChild(p);}this.scrim=document.createElement("div"),this.scrim.className="sp-scrim",this.scrim.addEventListener("click",()=>this.close()),this.root=document.createElement("div"),this.root.appendChild(this.scrim),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root),this.applyLabels();let s=e.host;this.onDocumentClick=l=>{this.isOpen&&!l.composedPath().includes(s)&&this.close();},document.addEventListener("click",this.onDocumentClick,true);let a=l=>{l.key==="Escape"&&this.isOpen&&(l.stopPropagation(),this.close());};this.fab.addEventListener("keydown",a),this.radialContainer.addEventListener("keydown",a),Q(this.root,()=>this.isOpen),this.radialContainer.addEventListener("keydown",l=>{let c=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(c.length===0||!this.isOpen)return;let p=e.activeElement??document.activeElement,f=c.indexOf(p);switch(l.key){case "ArrowUp":{l.preventDefault();let h=f<=0?c.length-1:f-1;c[h]?.focus();break}case "ArrowDown":{l.preventDefault();let h=f>=c.length-1?0:f+1;c[h]?.focus();break}case "Home":{l.preventDefault(),c[0]?.focus();break}case "End":{l.preventDefault(),c[c.length-1]?.focus();break}}});}bus;t;root;scrim;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;refreshLabels(){this.applyLabels();}applyLabels(){this.applyFabLabel();let e=this.radialContainer.querySelectorAll(".sp-radial-item");for(let n of e){let i=n.dataset.itemId;if(!i)continue;let o=es[i];if(!o)continue;let r=this.t(o);n.setAttribute("aria-label",r);let s=n.querySelector(".sp-radial-label");s&&F(s,r);}}applyFabLabel(){let e=this.t("fab.aria"),n=this.badgeEl?.textContent;this.fab.setAttribute("aria-label",n?`${e}, ${Aa(this.t,"fab.badge",{count:n})}`:e);}updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null,this.applyFabLabel();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);F(this.badgeEl,n),this.badgeEl.setAttribute("aria-label",Aa(this.t,"fab.badge",{count:e})),this.applyFabLabel();}toggle(){this.isOpen?this.close():this.open();}open(){this.isOpen=true,this.setFabIcon(W),this.fab.setAttribute("aria-expanded","true"),this.scrim.classList.add("sp-scrim--open"),I(this.radialContainer,false);let e=ta()?Zo:Jo;this.radialContainer.querySelectorAll(".sp-radial-item").forEach((i,o)=>{let r=-(16+e*(o+1));i.style.transform=`translate(0px, ${r}px) scale(1)`,i.classList.add("sp-radial-item--open");}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus();});}close(){this.isOpen=false,this.setFabIcon(T),this.fab.setAttribute("aria-expanded","false"),this.scrim.classList.remove("sp-scrim--open"),I(this.radialContainer,true),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){this.fab.querySelector("svg")?.replaceWith(D(e));}handleItemClick(e){switch(this.close(),e){case "chat":this.bus.emit("panel:toggle",true);break;case "annotate":{let n=this.bus.on("annotation:end",()=>{n(),this.fab.focus();});this.bus.emit("annotation:start");break}case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let i=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]')?.querySelector("svg");if(i){let o=D(this.annotationsVisible?U:V);i.replaceWith(o);}break}}}destroy(){document.removeEventListener("click",this.onDocumentClick,true),this.root.remove();}};var Ti="siteping_identity";function ts(t){if(!b(t,"name")||!b(t,"email"))return false;let{name:e,email:n}=t;return typeof e=="string"&&typeof n=="string"&&e.length>0&&e.length<=h&&n.length<=h&&a(n)}function Ut(){try{let t=localStorage.getItem(Ti);if(!t)return null;let e=JSON.parse(t);return ts(e)?e:null}catch{return null}}function Ci(t){try{localStorage.setItem(Ti,JSON.stringify(t));}catch{}}function oe(t){return t.normalize("NFC").replace(/\s+/g," ").trim()}function Ri(t){return t.replace(/\s+/g," ").trim()}function ns(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let s=t;t=e,e=s;}let n=t.length,i=e.length,o=new Array(n+1);for(let s=0;s<=n;s++)o[s]=s;let r=new Array(n+1);for(let s=1;s<=i;s++){r[0]=s;for(let l=1;l<=n;l++){let c=o[l-1];r[l]=t[l-1]===e[s-1]?c:1+Math.min(c,o[l],r[l-1]);}let a=o;o=r,r=a;}return o[n]}function Ce(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-ns(t,e)/n}function is(t,e){let n=e.length,i=new Int32Array(n+1),o=new Int32Array(n+1);for(let s=0;s<=n;s++)i[s]=s;let r=n;for(let s=1;s<=t.length;s++){o[0]=0;let a=t.charCodeAt(s-1);for(let p=1;p<=n;p++){let f=i[p-1]+(e.charCodeAt(p-1)===a?0:1),h=i[p]+1,d=o[p-1]+1;o[p]=Math.min(f,h,d);}let l=o[n];l<r&&(r=l);let c=i;i=o,o=c;}return r}function Yt(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=t.length>500?t.slice(0,500):t;if(e.length>i.length){let r=Ce(i,e);return r>=n?r:0}if(e.length<8&&i.length>64)return 0;let o=1-is(i,e)/e.length;return o>=n?o:0}function Ai(t){let e=new Map;for(let n=0;n<t.length-1;n++){let i=t.charCodeAt(n)<<16|t.charCodeAt(n+1);e.set(i,(e.get(i)??0)+1);}return e}function Pi(t,e,n){let i=n.length-1;if(e<=0||i<=0)return 0;let o=0,r=new Map;for(let s=0;s<n.length-1;s++){let a=n.charCodeAt(s)<<16|n.charCodeAt(s+1),l=t.get(a);if(l===void 0)continue;let c=r.get(a)??0;c<l&&(r.set(a,c+1),o++);}return 2*o/(e+i)}function Mi(t){let e=new Map,n=t.split(" ");for(let i=0;i<n.length-1;i++){let o=`${n[i]} ${n[i+1]}`;e.set(o,(e.get(o)??0)+1);}return e}function Ii(t,e,n){if(e<=0)return 0;let i=n.split(" "),o=i.length-1;if(o<=0)return 0;let r=0,s=new Map;for(let a=0;a<i.length-1;a++){let l=`${i[a]} ${i[a+1]}`,c=t.get(l);if(c===void 0)continue;let p=s.get(l)??0;p<c&&(s.set(l,p+1),r++);}return 2*r/(e+o)}var os={checkOpacity:true,opacityProperty:true,checkVisibilityCSS:true,visibilityProperty:true};function Re(t){if(!t.isConnected)return "hidden";if(typeof t.checkVisibility=="function")return t.checkVisibility(os)?"visible":t.checkVisibility()?"soft-hidden":"hidden";if(t.getClientRects().length>0)try{return getComputedStyle(t).visibility==="visible"?"visible":"soft-hidden"}catch{return "visible"}let e=t.firstElementChild;return e&&e.getClientRects().length>0?"visible":t.ownerDocument.documentElement.getClientRects().length===0?"unknown":"hidden"}function Li(t){switch(t){case "hidden":return .3;case "soft-hidden":return .6;default:return 1}}var ue={anchorKey:1,id:1,css:.95,xpath:.9,scan:.85},Qt=16,ss=24,_i=1e4,st=500,rs=.5,Vt=.6,as=.4,ls=2e3,Jt=.8,Gt=.6,cs=.05;function it(t,e){return oe((t??"").slice(0,ls)).slice(0,e)}function ps(t){let e=it(t.textSnippet,st),n=Mi(e),i=0;for(let o of n.values())i+=o;return {snippet:e,snippetBigrams:Ai(e),snippetBigramTotal:Math.max(0,e.length-1),snippetWordPairs:n,snippetWordPairTotal:i,prefix:it(t.textPrefix,128),suffix:it(t.textSuffix,128),neighbor:it(t.neighborText,128),fingerprint:(t.fingerprint??"").slice(0,64),tag:typeof t.elementTag=="string"?t.elementTag:""}}function ds(t,e){let n=ps(t),{pool:i,treeRoots:o}=hs(t),r=[];for(let[h,d]of i){let g=Ni(h,d,n);g&&r.push(g);}let s=0,a=false;for(let h of r)h.final>s&&(s=h.final),(h.strategy==="id"||h.strategy==="anchorKey")&&h.visibility===1&&(h.signals?.text??0)>=Jt&&(h.signals?.fingerprint===void 0||h.signals.fingerprint>=Jt)&&(a=true);let l=!!(n.snippet||n.fingerprint||n.prefix||n.suffix||n.neighbor),c=e?.scanBudget;if(l&&o.length>0&&s<ue.scan&&!a)if(c&&c.remaining<=0)c.starved=true;else {c&&c.remaining--;for(let h of fs(n,i,o)){let d=Ni(h,"scan",n);d&&r.push(d);}}let p=r.filter(ms);if(p.length===0)return null;p.sort((h,d)=>d.final-h.final);let f=bs(p);return {element:f.element,confidence:ys(f),strategy:f.strategy}}function ot(t,e){let n=[];for(let i of t){let o=i.querySelectorAll(e);for(let r=0;r<o.length&&n.length<Qt;r++){let s=o[r];s&&n.push(s);}if(n.length===Qt)break}return n}function us(t){let e=[],n=[document];for(let i of t){let o;try{o=ot(n,i);}catch{return []}let r=[];for(let s of o)s.shadowRoot&&r.push(s.shadowRoot);if(r.length===0)return [];e.push(r),n=r;}return e}function hs(t){let e=new Map,n=(l,c,p)=>{!l||e.has(l)||p&&l.tagName!==t.elementTag||e.set(l,c);},i=typeof t.cssSelector=="string"?t.cssSelector.split(Nt):[],o=i[i.length-1]??t.cssSelector,r=i.length>1?us(i.slice(0,-1)):null,s=r?r[r.length-1]??[]:[document],a=r?[document,...r.flat()]:s;if(t.anchorKey){let l=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{for(let c of ot(a,`[${we}="${l}"]`))n(c,"anchorKey",!1);}catch{}}if(t.elementId){let l=t.elementId.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{for(let c of ot(s,`[id="${l}"]`))n(c,"id",!0);}catch{for(let c of s)n(c.getElementById(t.elementId),"id",true);}}try{for(let l of ot(s,o))n(l,"css",!0);}catch{}if(r)return {pool:e,treeRoots:s};try{let l=document.evaluate(t.xpath,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),c=Math.min(l.snapshotLength,Qt);for(let p=0;p<c;p++){let f=l.snapshotItem(p);f instanceof Element&&n(f,"xpath",!0);}}catch{}return {pool:e,treeRoots:s}}function fs(t,e,n){let i=t.tag.toLowerCase();if(!i)return [];let o=[];try{for(let c of n){let p=c.querySelectorAll(i);for(let f=0;f<p.length&&o.length<_i;f++){let h=p[f];h&&o.push(h);}if(o.length===_i)break}}catch{return []}let r=t.fingerprint.split(":"),s=r.length===3?Number(r[0]):Number.NaN,a=r.length===3?r[2]??"":"",l=[];for(let c of o){if(e.has(c))continue;let p=0;if(t.snippetBigramTotal>0){let f=Ri(j(c,st)),h=Pi(t.snippetBigrams,t.snippetBigramTotal,f);if(t.snippetWordPairTotal>0){let d=h>0?Ii(t.snippetWordPairs,t.snippetWordPairTotal,f):0;p+=.6*(.5*h+.5*d);}else p+=.6*h;}if(a&&It(c)===a&&(p+=.25),!Number.isNaN(s)){let f=Math.abs(c.children.length-s);f===0?p+=.15:f<=2&&(p+=.07);}l.push({element:c,cheap:p});}return l.sort((c,p)=>p.cheap-c.cheap),l.slice(0,ss).map(c=>c.element)}function Ni(t,e,n){let i=gs(t,n),o=Li(Re(t));return i===null?e==="scan"?null:{element:t,strategy:e,verification:Gt,strongest:Gt,visibility:o,final:ue[e]*Gt*o,unverified:true}:{element:t,strategy:e,verification:i.blend,strongest:i.strongest,signals:i,visibility:o,final:ue[e]*i.blend*o}}function ms(t){if(t.strategy==="scan")return t.verification>=as;if(t.unverified||!t.signals)return true;let e=t.signals;return e.text===void 0||e.text>=rs?true:(e.fingerprint??0)>=Vt||(e.context??0)>=Vt||(e.neighbor??0)>=Vt}function gs(t,e){let n=0,i=0,o={blend:0,strongest:0};if(e.snippet){i+=40;let r=j(t,st,true);if(o.text=Yt(oe(r),e.snippet,.5),o.text<1){let s=j(t,st);s!==r&&(o.text=Math.max(o.text,Yt(oe(s),e.snippet,.5)));}n+=o.text*40;}if(e.fingerprint&&(i+=20,o.fingerprint=Qn(t,e.fingerprint),n+=o.fingerprint*20),e.prefix||e.suffix){i+=20;let r=0,s=0;if(e.prefix){let a=oe(ce(t,"before"));r+=a?Ce(a,e.prefix):0,s++;}if(e.suffix){let a=oe(ce(t,"after"));r+=a?Ce(a,e.suffix):0,s++;}s>0&&(o.context=r/s,n+=o.context*20);}if(e.neighbor){i+=20;let r=oe(qe(t));o.neighbor=r?Ce(r,e.neighbor):0,n+=o.neighbor*20;}return i===0?null:(o.blend=n/i,o.strongest=Math.max(o.text??0,o.fingerprint??0,o.context??0,o.neighbor??0),o)}function bs(t){let e=t[0],n=t.filter(o=>e.final-o.final<=cs&&(o===e||e.element.contains(o.element))),i=e;for(let o of n)o!==i&&i.element.contains(o.element)&&(i=o);return i}function ys(t){return t.strategy==="scan"?Math.min(t.verification,ue.scan):t.unverified?ue[t.strategy]:ue[t.strategy]*Math.min(1,t.strongest/Jt)}function rt(t,e,n){let i=ds(t,n);if(!i)return null;let o=i.element.getBoundingClientRect(),r=new DOMRect(o.x+e.xPct*o.width,o.y+e.yPct*o.height,e.wPct*o.width,e.hPct*o.height);return {element:i.element,rect:r,confidence:i.confidence,strategy:i.strategy}}function Zt(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 at(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var Fi=13,vs=26,ji=9,Oi="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.22)",Hi="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.28)",Di={question:"#2563eb",change:"#b45309",bug:"#d01f1f",other:"#5b6778"},xs={light:{bg:"rgba(255, 255, 255, 0.94)",ring:"#ffffff",check:"#636366",slash:"#8e8e93"},dark:{bg:"rgba(44, 44, 46, 0.94)",ring:"#48484a",check:"#c7c7cc",slash:"#aeaeb2"}},ws="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.14)",Es="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.18)";function ks(t,e,n){let i=n.scheme==="dark";if(k(t)){let r=xs[n.scheme];return {bg:r.bg,ring:r.ring,color:t==="wont_fix"?r.slash:r.check,shadow:ws,hoverShadow:Es}}let o=ma(e,n);if(t==="in_progress"){let{row:r}=n.surface,s=`color-mix(in srgb, ${o} 35%, ${r})`;return {bg:`color-mix(in srgb, ${o} ${i?18:14}%, ${r})`,ring:`${o} ${o} ${s} ${s}`,color:i?o:`color-mix(in srgb, ${o} 80%, #000000)`,shadow:Oi,hoverShadow:Hi}}return {bg:i?Di[e]??Di.other??o:o,ring:"#ffffff",color:"#ffffff",shadow:Oi,hoverShadow:Hi}}function $i(t){let e=document.documentElement.clientWidth,n=vs+(ta()?ji:0),i=t.right-Fi;return t.right<=e&&(i=Math.min(i,e-n)),{top:Math.max(0,t.top+window.scrollY-Fi),left:Math.max(0,i)+window.scrollX}}var en=t=>t.width>0||t.height>0;function he(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}function Bi(t){let e=t.elementIndices[0];return e===void 0?void 0:t.entries[0]?.positions[e]}var zi=t=>t.style.display!=="none";function tn(t,e,n){!va()&&typeof t.animate=="function"&&t.animate(e,n);}var Ki=200,Wi=200,Ss=3e3,Ts=.7,Cs=28,Xi=32,lt=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=E("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",O(this.container),document.body.appendChild(this.container),this.bus.on("annotations:toggle",s=>{this.container.style.display=s?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition("resize"),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition("scroll"),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("mutation");}),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,true);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;pendingLayoutChange=false;pendingResize=false;hiddenRecheckAt=new Map;clusters=[];onDocumentClickForClusters=null;lastOpenCount=-1;get count(){return this.entries.length}get openCount(){let e=0;for(let n of this.entries)k(n.feedback.status)||e++;return e}scheduleReposition(e="mutation"){e!=="scroll"&&(this.pendingLayoutChange=true),e==="resize"&&(this.pendingResize=true),!this.repositionTimer&&("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:Wi+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},Wi));}repositionAll(){let e=this.pendingLayoutChange,n=this.pendingResize;this.pendingLayoutChange=false,this.pendingResize=false,n&&this.hiddenRecheckAt.clear();let i=Date.now(),o={remaining:2,starved:false},r=new Set,s=false;for(let a of this.entries)for(let l=0;l<a.feedback.annotations.length;l++){let c=a.elements[l];if(!c)continue;let p=a.feedback.annotations[l];if(!p)continue;let f=`${a.feedback.id}:${l}`;r.add(f);let h=this.anchorCache.get(f),d=h?.ref.deref(),g,v=(this.hiddenRecheckAt.get(f)??0)>i,k=d?.isConnected&&(v||!(e&&Re(d)==="hidden"));if(h&&d&&k){let S=d.getBoundingClientRect(),w=at(p);g={element:d,rect:new DOMRect(S.left+w.xPct*S.width,S.top+w.yPct*S.height,w.wPct*S.width,w.hPct*S.height),confidence:h.confidence,strategy:h.strategy};}else if(v)g=null;else if(o.starved=false,g=rt(Zt(p),at(p),{scanBudget:o}),!o.starved){if(g?.element){let{confidence:S,strategy:w}=g;this.anchorCache.set(f,{ref:new WeakRef(g.element),confidence:S,strategy:w});}!g||Re(g.element)==="hidden"?this.hiddenRecheckAt.set(f,i+Ss):this.hiddenRecheckAt.delete(f);}let H=c.style.display!=="none";if(!g||!en(g.rect)){H&&(s=true),c.style.display="none";continue}H||(s=true),a.positions[l]=$i(g.rect),c.style.display="flex",this.applyConfidenceStyle(c,g.confidence,a.feedback);}for(let a of this.anchorCache.keys())r.has(a)||this.anchorCache.delete(a);for(let a of this.hiddenRecheckAt.keys())r.has(a)||this.hiddenRecheckAt.delete(a);s&&(this.buildClusters(),this.bus.emit("markers:placed")),this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback,false);}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((i,o)=>{let r=this.buildEntry(i,o+1);this.entries.push(r);}),this.buildClusters();let n=this.entries.filter(i=>i.elements.some(zi)).length;this.liveRegion&&n>0&&(this.liveRegion.textContent=Aa(this.t,"marker.count",{count:n})),this.emitMarkersChanged(),this.bus.emit("markers:placed");}addFeedback(e,n){let i=this.buildEntry(e,n);for(let o of i.elements)tn(o,[{scale:.9,opacity:0},{scale:1,opacity:1}],{duration:250,easing:z});this.entries.push(i),this.buildClusters(),this.emitMarkersChanged(),this.bus.emit("markers:placed");}buildEntry(e,n){let i={feedback:e,elements:[],positions:[]};for(let o of e.annotations){let r=rt(Zt(o),at(o)),s=r&&en(r.rect)?r:null,a=s?$i(s.rect):{top:0,left:0},l=this.createMarker(n,e,a);s?this.applyConfidenceStyle(l,s.confidence,e):l.style.display="none",this.container.appendChild(l),i.elements.push(l),i.positions.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++){let r=i.positions[o];!r||i.elements[o]?.style.display==="none"||e.push({entry:i,elIdx:o,pos:r});}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.pos,l=e[s];if(!l)continue;let c=l.pos;Math.sqrt((a.left-c.left)**2+(a.top-c.top)**2)<Cs&&(r.entries.push(l.entry),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=Bi(e);if(!n)return;let{top:i,left:o}=n,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=he(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=Bi(e);if(!n)return;let{top:i,left:o}=n,r=e.entries.length,s=(r-1)*Xi,a=o-s/2;for(let l=0;l<r;l++){let c=he(e,l);c&&(c.style.top=`${i}px`,c.style.left=`${a+l*Xi}px`,c.style.zIndex=String(10+l));}}addClusterBadge(e){let n=he(e,e.entries.length-1);if(!n)return;let i=E("div",{class:"sp-cluster-badge",style:`position:absolute;top:-6px;right:-6px;min-width:16px;height:16px;padding:0 4px;border-radius:9999px;background:#1d1d1f;color:#fff;font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center;border:1.5px solid #fff;pointer-events:none;font-family:${qa};line-height:1;`});F(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=he(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(he(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.glide(i,()=>this.applyFanPositions(i)),this.setBadgesVisible(i,false),true):false}collapseCluster(e){e.expanded&&(e.expanded=false,this.glide(e,()=>this.applyStackPositions(e)),this.setBadgesVisible(e,true));}glide(e,n){let i=e.entries.map((r,s)=>he(e,s)),o=i.map(r=>r&&{top:parseFloat(r.style.top),left:parseFloat(r.style.left)});n(),i.forEach((r,s)=>{let a=o[s];if(!r||!a)return;let l=a.left-parseFloat(r.style.left),c=a.top-parseFloat(r.style.top);(l||c)&&tn(r,[{translate:`${l}px ${c}px`},{translate:"0 0"}],{duration:200,easing:z});});}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e);}applyConfidenceStyle(e,n,i){let o=k(i.status);n<Ts&&!o?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=Aa(this.t,"marker.approximate",{confidence:Math.round(n*100)})):(e.style.borderStyle="solid",e.style.opacity="1",e.title="");}createMarker(e,n,i){let{status:o}=n,r=ks(o,n.type,this.colors),s=E("div",{style:`position:absolute;top:${i.top}px;left:${i.left}px;width:26px;height:26px;border-radius:50%;background:${r.bg};border:2px solid;border-color:${r.ring};display:flex;align-items:center;justify-content:center;font-family:${qa};font-size:12px;font-weight:700;letter-spacing:-0.01em;color:${r.color};cursor:pointer;pointer-events:auto;box-shadow:${r.shadow};transition:${va()?"box-shadow 0.15s ease":`transform 0.15s ${z}, box-shadow 0.15s ease`};touch-action:manipulation;user-select:none;-webkit-font-smoothing:antialiased;`});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=Aa(this.t,"marker.aria",{number:e,type:Ba$1(n.type,this.t),status:Ca(o,this.t),message:a});s.setAttribute("aria-label",l),s.setAttribute("aria-describedby",this.tooltip.tooltipId),N(s,this.colors.accent),o==="wont_fix"?s.appendChild(E("span",{style:"width:2px;height:16px;border-radius:1px;background:currentColor;transform:rotate(45deg);"})):F(s,o==="resolved"?"\u2713":String(e)),ta()&&s.appendChild(E("span",{style:`position:absolute;inset:-${ji}px;border-radius:50%;`})),s.addEventListener("mouseenter",()=>{ua()&&(s.style.transform="scale(1.2)",s.style.boxShadow=r.hoverShadow),this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("mouseleave",()=>{s.style.transform="scale(1)",s.style.boxShadow=r.shadow,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),s.addEventListener("focus",()=>{this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let c=p=>{p instanceof MouseEvent&&this.handleClusterClick(s,p)||(sa()&&this.tooltip.hide(),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",p=>c(p)),s.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),c(p));}),s}focusFeedback(e){let n=this.entries.find(o=>o.feedback.id===e),i=n?.elements.find(zi);return !n||!i?false:(i.scrollIntoView({behavior:va()?"auto":"smooth",block:"center"}),this.pinHighlight(n.feedback),this.highlight(e),true)}revealPin(e){return this.container.style.display!=="none"&&this.focusFeedback(e)}isLost(e){let n=this.entries.filter(i=>i.feedback.id===e);return n.length>0&&n.every(i=>i.elements.every(o=>o.style.display==="none"))}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)tn(i,[{boxShadow:`0 0 0 0 ${this.colors.accentGlow}`},{boxShadow:"0 0 0 8px transparent",offset:.7},{boxShadow:"0 0 0 0 transparent"}],{duration:700,easing:"ease-out"});}showHighlight(e,n=true){this.removeHighlightElements();for(let i of e.annotations){let o=rt(Zt(i),at(i));if(!o||!en(o.rect))continue;let r=ma(e.type,this.colors),s=o.rect,a=E("div",{style:`position:absolute;top:${s.top+window.scrollY}px;left:${s.left+window.scrollX}px;width:${s.width}px;height:${s.height}px;border:2px solid ${r};background:${r}0c;border-radius:12px;pointer-events:none;z-index:-1;opacity:${n?0:1};box-shadow:0 0 16px ${r}20;transition:opacity ${Ki}ms ease;`});this.container.appendChild(a),this.highlightElements.push(a),n&&(a.offsetHeight,a.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(),Ki);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,true),this.mutationObserver?.disconnect(),this.container.remove();}};var qi=3e4,ct=class{constructor(e,n){this.store=e;this.projectName=n;}store;projectName;async sendFeedback(e){return nn(await Ui(this.write(e),"Failed to send feedback"))}async write(e){try{return 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(o),screenshotDataUrl:e.screenshotDataUrl??null,screenshotRegion:e.screenshotRegion??null,diagnostics:e.diagnostics??null})}catch(n$1){if(!n(n$1))throw n$1;let i=await this.store.findByClientId(e.clientId);if(!i||i.projectName!==e.projectName)throw n$1;return i}}async getFeedbacks(e,n){let{feedbacks:i,total:o}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,statuses:n?.statuses,search:n?.search,url:n?.url,urlPattern:n?.urlPattern});return {feedbacks:i.map(nn),total:o,capabilities:{comments:!!this.store.addComment}}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,l(n?"resolved":"open"));return nn(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}async addComment(e,n){let i="Failed to post comment";if(!this.store.addComment)throw new c(`${i}: this store keeps no comments`,"SERVER",false);return Yi(await Ui(this.store.addComment(e,n),i))}};function Ui(t,e){return zt(t,qi,()=>new c(`${e}: the store did not answer within ${qi/1e3} s`,"TIMEOUT",true))}function nn(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(Rs),comments:t.comments?.map(Yi),screenshotUrl:t.screenshotUrl??null,screenshotRegion:t.screenshotRegion??null,diagnostics:t.diagnostics??null}}function Yi({clientId:t,createdAt:e,...n}){return {...n,createdAt:e.toISOString()}}function Rs(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 Vi="@keyframes sp-fab-in{from{opacity:0;transform:scale(0.9);}}.sp-anim-fab-in{animation:sp-fab-in 0.2s var(--sp-ease-out) backwards;}@keyframes sp-flash-bg{from{background-color:var(--sp-accent-light);}}.sp-anim-flash{animation:sp-flash-bg 0.6s var(--sp-ease-out);}.sp-panel{transform:translateX(110%);transition:transform 0.2s var(--sp-ease-out);}.sp-panel.sp-panel--open{transform:translateX(0);transition:transform 0.3s var(--sp-ease-drawer);}.sp-radial-item{opacity:0;pointer-events:none;transform:translate(0,0) scale(0.9);transition:transform 0.2s var(--sp-ease-out),opacity 0.15s ease,background-color 0.15s ease,border-color 0.15s ease,box-shadow 0.15s ease,color 0.15s ease,scale 0.16s var(--sp-ease-out);}.sp-radial-item:active{scale:0.97;}.sp-radial-item.sp-radial-item--open{opacity:1;pointer-events:auto;transition-delay:calc(var(--sp-i, 0) * 30ms),calc(var(--sp-i, 0) * 30ms),0s,0s,0s,0s,0s;}@keyframes sp-spin{to{transform:rotate(360deg);}}.sp-spinner{width:20px;height:20px;border:2px solid var(--sp-fill-strong);border-top-color:var(--sp-text-secondary);border-radius:50%;animation:sp-spin 0.6s linear infinite;}@media (prefers-reduced-motion: reduce){*,*::before,*::after{animation-duration:0.01ms !important;animation-delay:0s !important;animation-iteration-count:1 !important;transition-property:opacity,color,background-color,border-color,box-shadow,outline-color !important;transition-delay:0s !important;}.sp-spinner{animation-duration:1.2s !important;animation-iteration-count:infinite !important;}}";var Gi=`:host{-webkit-tap-highlight-color:transparent;}.sp-list,.sp-detail-content{overscroll-behavior:contain;}.sp-scrim{display:none;}@media not all and (hover: hover) and (pointer: fine){.sp-radial-item--open .sp-radial-label{opacity:1;transform:translate(0,-50%);}.sp-bulk-checkbox{opacity:1;}.sp-bulk-checkbox::after{content:"";position:absolute;inset:-12px;}.sp-bulk-select-all{display:none;}.sp-list--has-selection .sp-bulk-select-all{display:flex;}.sp-shortcuts-hint{display:none;}}@media (pointer: coarse){.sp-radial-item{width:48px;height:48px;left:3px;bottom:3px;}.sp-radial-item svg{width:20px;height:20px;}.sp-radial-label{font-size:14px;padding:8px 14px;}.sp-search,.sp-input{font-size:16px;}.sp-search,.sp-filter-dropdown-btn,.sp-sort-btn,.sp-group-toggle,.sp-mine-toggle,.sp-segmented__btn,.sp-btn-resolve,.sp-btn-delete,.sp-bulk-btn-resolve,.sp-bulk-btn-delete,.sp-thread-foot .sp-btn-primary{height:40px;min-height:40px;}.sp-bulk-btn-deselect{width:40px;height:40px;}.sp-detail-back{width:44px;height:44px;}.sp-detail-actions button,.sp-detail-actions a,.sp-btn-primary,.sp-btn-ghost,.sp-btn-danger{height:44px;}.sp-export-option,.sp-filter-dropdown-option,.sp-sort-option,.sp-group-header{min-height:44px;}.sp-export-btn,.sp-btn-delete-all,.sp-bulk-select-all{min-height:40px;}.sp-panel-close::before{inset:5px;}.sp-card-expand{position:relative;}.sp-card-expand::after{content:"";position:absolute;inset:-8px -10px;}}@media (max-height: 600px){.sp-stats-bar{display:none;}}@media ${y}{.sp-fab--bottom-right,.sp-radial--bottom-right{right:calc(16px + env(safe-area-inset-right,0px));bottom:calc(16px + env(safe-area-inset-bottom,0px));}.sp-fab--bottom-left,.sp-radial--bottom-left{left:calc(16px + env(safe-area-inset-left,0px));bottom:calc(16px + env(safe-area-inset-bottom,0px));}.sp-scrim{display:block;position:fixed;inset:0;background:var(--sp-scrim);opacity:0;pointer-events:none;touch-action:none;transition:opacity 0.2s ease;}.sp-scrim--open{opacity:1;pointer-events:auto;}.sp-panel{top:auto;left:0;right:0;bottom:0;width:auto;max-width:none;height:calc(100vh - 48px);height:calc(100dvh - 40px - env(safe-area-inset-top,0px));border-radius:16px 16px 0 0;background:var(--sp-grouped);-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:var(--sp-shadow-sheet-up);transform:translateY(105%);}.sp-panel.sp-panel--open{transform:translateY(0);}.sp-panel-header,.sp-detail-header{position:relative;touch-action:none;}.sp-panel-header{padding:24px 8px 6px 20px;}.sp-detail-header{padding:22px 12px 4px 6px;}.sp-panel-header::before,.sp-detail-header::before{content:"";position:absolute;top:6px;left:50%;width:36px;height:5px;margin-left:-18px;border-radius:3px;background:var(--sp-grabber);}.sp-export-btn,.sp-btn-delete-all{width:40px;height:40px;padding:0;justify-content:center;border-radius:50%;background:transparent;}.sp-export-btn svg,.sp-btn-delete-all svg{width:19px;height:19px;}.sp-stats-bar{padding:2px 20px 10px;}.sp-filters{padding:2px 16px 8px;}.sp-stats-bar,.sp-filters{touch-action:pan-x;}.sp-search{height:40px;}.sp-filter-bar{flex-wrap:nowrap;overflow-x:auto;margin:0 -16px 8px;padding:0 16px 2px;scrollbar-width:none;}.sp-filter-bar::-webkit-scrollbar{display:none;}.sp-filter-dropdown{flex:0 0 auto;}.sp-filter-dropdown-btn{width:auto;}.sp-filter-dropdown-menu,.sp-sort-menu{position:fixed;top:auto;left:8px;right:8px;bottom:calc(8px + env(safe-area-inset-bottom,0px));min-width:0;padding:6px;border-radius:16px;background:var(--sp-row);-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:var(--sp-shadow-popover);z-index:30;transform-origin:bottom center;}.sp-filter-dropdown-option,.sp-sort-option{min-height:44px;font-size:16px;}.sp-list{padding:8px 16px calc(16px + env(safe-area-inset-bottom,0px));}.sp-bulk-bar{bottom:calc(12px + env(safe-area-inset-bottom,0px));}.sp-detail-section{padding:0 16px;}.sp-detail-content{padding-bottom:calc(20px + env(safe-area-inset-bottom,0px));}.sp-identity-backdrop{align-items:flex-end;}.sp-identity-modal{width:100%;max-width:none;margin-bottom:var(--sp-kb, 0px);padding:22px 20px calc(20px + env(safe-area-inset-bottom,0px));border-radius:16px 16px 0 0;background:var(--sp-grouped);-webkit-backdrop-filter:none;backdrop-filter:none;transform:translateY(100%);}.sp-identity-modal .sp-input{background:var(--sp-row);}.sp-identity-actions button{height:50px;}.sp-identity-actions .sp-btn-primary{flex:2;}}@media (prefers-reduced-transparency: reduce){*{-webkit-backdrop-filter:none !important;backdrop-filter:none !important;}}@media (prefers-contrast: more){.sp-card,.sp-detail-message,.sp-detail-meta,.sp-detail-annotation-info,.sp-detail-diag-toggle{box-shadow:inset 0 0 0 1px var(--sp-separator);}}`;function on(t){let e=t.scheme==="dark";return `:host{all:initial;position:fixed;z-index:${2147483647};font-family:var(--sp-font);font-size:14px;line-height:1.5;color:var(--sp-text);color-scheme:${t.scheme};-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;${ra(t)} --sp-ease-out: cubic-bezier(0.23, 1, 0.32, 1);--sp-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);--sp-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);--sp-tr: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.16s var(--sp-ease-out);--sp-backdrop: ${e?"rgba(0, 0, 0, 0.45)":"rgba(0, 0, 0, 0.2)"};--sp-identity-overlay: ${e?"rgba(0, 0, 0, 0.5)":"rgba(0, 0, 0, 0.2)"};--sp-scrim: ${e?"rgba(0, 0, 0, 0.55)":"rgba(0, 0, 0, 0.24)"};}*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}:focus-visible{outline:2px solid var(--sp-accent);outline-offset:2px;box-shadow:0 0 0 4px var(--sp-bg);}button,[role="button"],[role="tab"],[role="menuitem"],[role="option"]{touch-action:manipulation;-webkit-user-select:none;user-select:none;}:where(.sp-panel-close,.sp-filter-dropdown-btn,.sp-segmented__btn,.sp-btn-resolve,.sp-btn-delete,.sp-btn-delete-all,.sp-btn-danger,.sp-btn-primary,.sp-btn-ghost,.sp-sort-btn,.sp-group-toggle,.sp-mine-toggle,.sp-export-btn,.sp-bulk-btn-resolve,.sp-bulk-btn-delete,.sp-bulk-btn-deselect,.sp-detail-back,.sp-detail-btn-resolve,.sp-detail-btn-reopen,.sp-detail-btn-delete,.sp-detail-btn-custom,.sp-detail-btn-goto,.sp-shortcuts-close):not(:disabled):active{transform:scale(0.97);}.sp-fab{position:fixed;width:54px;height:54px;border-radius:var(--sp-radius-full);background:var(--sp-accent);color:#fff;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 1px 0 rgba(255,255,255,0.22),0 8px 24px color-mix(in srgb,var(--sp-accent) 36%,transparent),0 2px 6px rgba(0,0,0,0.12);transition:transform 0.16s var(--sp-ease-out),opacity 0.2s ease,box-shadow 0.2s ease;outline:none;touch-action:manipulation;-webkit-user-select:none;user-select:none;}.sp-fab:focus-visible{outline:2px solid var(--sp-accent);outline-offset:3px;}@media (hover: hover) and (pointer: fine){.sp-fab:hover{box-shadow:inset 0 1px 0 rgba(255,255,255,0.22),0 12px 32px color-mix(in srgb,var(--sp-accent) 46%,transparent),0 3px 8px rgba(0,0,0,0.14);}}.sp-fab:active{transform:scale(0.97);}div:has(> .sp-fab):has(~ .sp-panel.sp-panel--open) > .sp-fab{opacity:0;transform:scale(0.9);pointer-events:none;}.sp-fab--bottom-right{bottom:24px;right:24px;}.sp-fab--bottom-left{bottom:24px;left:24px;}.sp-fab svg{width:23px;height:23px;fill:currentColor;}.sp-fab-badge{position:absolute;top:-3px;right:-3px;min-width:20px;height:20px;padding:0 6px;border-radius:var(--sp-radius-full);background:var(--sp-danger);color:#fff;font:600 11px/1 var(--sp-font);display:flex;align-items:center;justify-content:center;border:2px solid var(--sp-bg);pointer-events:none;}.sp-toast{position:fixed;left:50%;bottom:96px;transform:translateX(-50%);max-width:min(360px,calc(100vw - 32px));padding:11px 18px;border-radius:20px;background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);color:var(--sp-text);font:500 14px/1.35 var(--sp-font);letter-spacing:-0.01em;box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);cursor:pointer;animation:sp-toast-in 0.2s var(--sp-ease-out);transition:opacity 0.15s ease;}.sp-toast--leaving{opacity:0;}.sp-toast[hidden]{display:none;}.sp-toast--error::before{content:"";display:inline-block;width:8px;height:8px;margin-right:8px;border-radius:50%;background:var(--sp-type-bug);vertical-align:1px;}@keyframes sp-toast-in{from{opacity:0;transform:translate(-50%,8px);}}.sp-radial{position:fixed;pointer-events:none;width:54px;height:54px;}.sp-radial--bottom-right{bottom:24px;right:24px;}.sp-radial--bottom-left{bottom:24px;left:24px;}.sp-radial-item{position:absolute;left:5px;bottom:5px;width:44px;height:44px;border-radius:var(--sp-radius-full);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);color:var(--sp-text);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);font-size:12px;font-weight:600;}.sp-radial-item:focus-visible{background:var(--sp-row);color:var(--sp-accent-ink);box-shadow:var(--sp-shadow-float),var(--sp-ring);outline:none;}@media (hover: hover) and (pointer: fine){.sp-radial-item:hover{background:var(--sp-row);color:var(--sp-accent-ink);}}.sp-radial-item svg{width:19px;height:19px;flex-shrink:0;stroke:currentColor;fill:none;}.sp-radial-label{position:absolute;top:50%;white-space:nowrap;font-size:13px;font-weight:500;letter-spacing:-0.01em;color:var(--sp-text);pointer-events:none;opacity:0;padding:6px 12px;border-radius:var(--sp-radius-full);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);transform:translate(4px,-50%);transition:opacity 0.18s ease,transform 0.2s var(--sp-ease-out);}.sp-radial--bottom-right .sp-radial-label{right:calc(100% + 12px);}.sp-radial--bottom-left .sp-radial-label{left:calc(100% + 12px);transform:translate(-4px,-50%);}.sp-radial-item:focus-visible .sp-radial-label{opacity:1;transform:translate(0,-50%);}@media (hover: hover) and (pointer: fine){.sp-radial-item:hover .sp-radial-label{opacity:1;transform:translate(0,-50%);}}.sp-panel{position:fixed;top:12px;right:12px;bottom:12px;width:380px;max-width:calc(100vw - 24px);border-radius:var(--sp-radius-xl);background:var(--sp-material);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),inset 0 0 0 0.5px var(--sp-sheen-soft),var(--sp-shadow-sheet);display:flex;flex-direction:column;overflow:clip;}.sp-panel-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:16px 12px 8px 20px;position:relative;z-index:2;}.sp-panel-title{font-family:var(--sp-font-display);font-size:28px;font-weight:700;line-height:1.15;color:var(--sp-text);letter-spacing:-0.022em;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.sp-panel-close{position:relative;width:44px;height:44px;border-radius:50%;border:none;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--sp-text-secondary);transition:var(--sp-tr);}.sp-panel-close::before{content:"";position:absolute;inset:7px;border-radius:50%;background:var(--sp-fill);transition:background-color 0.15s ease;}@media (hover: hover) and (pointer: fine){.sp-panel-close:hover{color:var(--sp-text);}.sp-panel-close:hover::before{background:var(--sp-fill-strong);}}.sp-panel-close svg{position:relative;width:13px;height:13px;stroke-width:2.6;}.sp-filters{padding:2px 16px 10px;position:sticky;top:0;z-index:1;}.sp-search-wrap{position:relative;margin-bottom:10px;}.sp-search{width:100%;height:36px;padding:0 12px 0 34px;border-radius:var(--sp-radius);border:none;background:var(--sp-fill);color:var(--sp-text);font-family:var(--sp-font);font-size:15px;letter-spacing:-0.01em;outline:none;transition:var(--sp-tr);}.sp-search::placeholder{color:var(--sp-text-secondary);}.sp-search:focus{box-shadow:var(--sp-ring);}.sp-search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--sp-text-secondary);width:16px;height:16px;}.sp-filter-bar{display:flex;align-items:center;gap:8px;margin-bottom:8px;flex-wrap:wrap;}.sp-filter-dropdown{position:relative;flex:1 1 auto;min-width:0;}.sp-filter-dropdown-btn{--sp-chip-color: var(--sp-text-secondary);display:inline-flex;align-items:center;gap:6px;width:100%;height:32px;padding:0 10px;border-radius:var(--sp-radius-full);border:none;background:var(--sp-fill);color:var(--sp-text);font-family:var(--sp-font);font-size:13px;font-weight:500;cursor:pointer;white-space:nowrap;transition:var(--sp-tr);}@media (hover: hover) and (pointer: fine){.sp-filter-dropdown-btn:hover{background:var(--sp-fill-strong);}}.sp-filter-dropdown-btn[aria-expanded="true"]{background:var(--sp-fill-strong);}.sp-filter-dropdown-btn--filtered,.sp-filter-dropdown-btn--filtered[aria-expanded="true"]{background:color-mix(in srgb,var(--sp-chip-color) 14%,transparent);}.sp-filter-dropdown-btn__icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0;color:var(--sp-chip-color);}.sp-filter-dropdown-btn__icon svg{width:14px;height:14px;}.sp-filter-dropdown-btn__label{display:inline-flex;align-items:baseline;gap:6px;flex:1;min-width:0;overflow:hidden;}.sp-filter-dropdown-btn__prefix{color:var(--sp-text-secondary);font-weight:500;font-size:11px;text-transform:uppercase;letter-spacing:0.04em;}.sp-filter-dropdown-btn__value{color:var(--sp-text);font-weight:600;overflow:hidden;text-overflow:ellipsis;}.sp-filter-dropdown-btn--filtered .sp-filter-dropdown-btn__value{color:color-mix(in srgb,var(--sp-chip-color) var(--sp-ink-pct),var(--sp-ink-mix));}.sp-filter-dropdown-btn__chevron{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex-shrink:0;color:var(--sp-text-secondary);transition:transform 0.2s var(--sp-ease-out);}.sp-filter-dropdown-btn__chevron svg{width:12px;height:12px;}.sp-filter-dropdown-btn[aria-expanded="true"] .sp-filter-dropdown-btn__chevron{transform:rotate(180deg);}.sp-filter-dropdown-menu{position:absolute;top:calc(100% + 6px);left:0;right:0;min-width:180px;padding:6px;border-radius:var(--sp-radius-lg);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);z-index:10;transform-origin:top left;animation:sp-menu-in 0.15s var(--sp-ease-out) backwards;}@keyframes sp-menu-in{from{opacity:0;transform:scale(0.96);}}.sp-filter-dropdown-option{--sp-chip-color: var(--sp-text-secondary);display:flex;align-items:center;gap:10px;width:100%;min-height:34px;padding:7px 10px;border:none;border-radius:8px;background:transparent;color:var(--sp-text);font-family:var(--sp-font);font-size:13px;font-weight:400;letter-spacing:-0.005em;cursor:pointer;text-align:left;transition:background-color 0.12s ease,color 0.12s ease;}.sp-filter-dropdown-option__icon{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;flex-shrink:0;border-radius:6px;background:color-mix(in srgb,var(--sp-chip-color) 14%,transparent);color:var(--sp-chip-color);}.sp-filter-dropdown-option__icon svg{width:13px;height:13px;}.sp-filter-dropdown-option__label{flex:1;min-width:0;}.sp-filter-dropdown-option__check{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex-shrink:0;color:var(--sp-accent-ink);}.sp-filter-dropdown-option__check svg{width:13px;height:13px;}@media (hover: hover) and (pointer: fine){.sp-filter-dropdown-option:hover{background:var(--sp-fill);}}.sp-filter-dropdown-option--active{font-weight:600;}.sp-segmented{display:inline-flex;align-items:stretch;padding:2px;border-radius:9px;background:var(--sp-fill);flex-shrink:0;}.sp-segmented__btn{--sp-chip-color: var(--sp-text-tertiary);display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 10px;border:none;border-radius:7px;background:transparent;color:var(--sp-text);font-family:var(--sp-font);font-size:13px;font-weight:500;letter-spacing:-0.01em;cursor:pointer;white-space:nowrap;transition:var(--sp-tr);}.sp-segmented__icon{display:inline-flex;align-items:center;justify-content:center;width:13px;height:13px;flex-shrink:0;color:var(--sp-chip-color);}.sp-segmented__icon svg{width:13px;height:13px;}@media (hover: hover) and (pointer: fine){.sp-segmented__btn:not(.sp-segmented__btn--active):hover{background:var(--sp-sheen);}}.sp-segmented__btn--active{background:var(--sp-thumb);font-weight:600;box-shadow:var(--sp-shadow-thumb);}.sp-list{flex:1;overflow-y:auto;padding:8px 16px 16px;-webkit-mask-image:linear-gradient(to bottom,transparent,#000 8px);mask-image:linear-gradient(to bottom,transparent,#000 8px);}.sp-list::-webkit-scrollbar{width:6px;}.sp-list::-webkit-scrollbar-track{background:transparent;}.sp-list::-webkit-scrollbar-thumb{background:var(--sp-fill-strong);border-radius:var(--sp-radius-full);}@media (hover: hover) and (pointer: fine){.sp-list::-webkit-scrollbar-thumb:hover{background:var(--sp-text-tertiary);}}.sp-card{position:relative;display:flex;padding:12px 14px 12px 12px;margin-bottom:8px;cursor:pointer;border-radius:var(--sp-radius-lg);background:var(--sp-row);box-shadow:var(--sp-shadow-row);transition:var(--sp-tr);}@media (hover: hover) and (pointer: fine){.sp-card:hover{background:var(--sp-row-hover);box-shadow:var(--sp-shadow-row-hover);}}.sp-card:active{transform:scale(0.985);}.sp-card-bar{align-self:flex-start;width:8px;height:8px;margin:6px 10px 0 2px;border-radius:50%;flex-shrink:0;transition:opacity 0.15s ease;}.sp-card-body{flex:1;min-width:0;}.sp-card-header{display:flex;flex-wrap:wrap;align-items:center;gap:4px 6px;margin-bottom:4px;}.sp-card-number{font-size:13px;font-weight:600;letter-spacing:-0.01em;color:var(--sp-text);font-variant-numeric:tabular-nums;}.sp-badge{white-space:nowrap;padding:2px 8px;border-radius:var(--sp-radius-full);font-size:11px;font-weight:600;line-height:16px;letter-spacing:0.01em;background:color-mix(in srgb,currentColor 13%,transparent) !important;-webkit-text-fill-color:color-mix(in srgb,currentColor var(--sp-ink-pct-badge),var(--sp-ink-mix));}.sp-card-date{font-size:12px;color:var(--sp-text-tertiary);margin-left:auto;white-space:nowrap;font-variant-numeric:tabular-nums;}.sp-lost{font-size:12px;color:var(--sp-text-tertiary);margin-top:4px;}.sp-card-message{font-size:14px;line-height:1.43;letter-spacing:-0.006em;color:var(--sp-text);overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;}.sp-card-message--expanded{-webkit-line-clamp:unset;}.sp-card-expand{font-size:13px;font-weight:500;color:var(--sp-accent-ink);cursor:pointer;background:none;border:none;padding:4px 0;font-family:var(--sp-font);transition:opacity 0.15s ease;}@media (hover: hover) and (pointer: fine){.sp-card-expand:hover{opacity:0.8;}}.sp-card-footer{display:flex;align-items:center;justify-content:flex-end;gap:2px;margin-top:6px;margin-right:-6px;}.sp-btn-resolve,.sp-btn-delete{height:30px;padding:0 10px;border-radius:8px;border:none;background:transparent;font-family:var(--sp-font);font-size:13px;font-weight:500;cursor:pointer;display:flex;align-items:center;gap:5px;transition:var(--sp-tr);}.sp-btn-resolve svg,.sp-btn-delete svg{width:14px;height:14px;}.sp-btn-resolve{color:var(--sp-ink-green);}.sp-card--resolved .sp-btn-resolve{color:var(--sp-accent-ink);}.sp-btn-delete{color:var(--sp-ink-red);}@media (hover: hover) and (pointer: fine){.sp-btn-resolve:hover{background:color-mix(in srgb,var(--sp-status-open) 10%,transparent);}.sp-card--resolved .sp-btn-resolve:hover{background:color-mix(in srgb,var(--sp-accent) 10%,transparent);}.sp-btn-delete:hover{background:color-mix(in srgb,var(--sp-type-bug) 10%,transparent);}}.sp-btn-resolve:disabled,.sp-btn-delete:disabled{opacity:0.5;cursor:not-allowed;pointer-events:none;}.sp-spinner--sm{width:14px;height:14px;}.sp-panel-header-right{display:flex;flex-shrink:0;align-items:center;gap:2px;}.sp-btn-delete-all{width:32px;height:32px;padding:0;justify-content:center;border-radius:50%;border:none;background:transparent;color:var(--sp-ink-red);font-family:var(--sp-font);font-size:13px;font-weight:500;white-space:nowrap;cursor:pointer;display:flex;align-items:center;transition:var(--sp-tr);}.sp-btn-delete-all svg{width:17px;height:17px;}.sp-btn-delete-all span,.sp-export-btn span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;}@media (hover: hover) and (pointer: fine){.sp-btn-delete-all:hover{background:color-mix(in srgb,var(--sp-type-bug) 10%,transparent);}}.sp-btn-delete-all:disabled{opacity:0.5;cursor:not-allowed;pointer-events:none;}.sp-confirm-backdrop{position:fixed;inset:0;background:var(--sp-backdrop);display:flex;align-items:center;justify-content:center;z-index:${2147483647};opacity:0;transition:opacity 0.2s ease;}.sp-confirm-dialog,.sp-identity-modal{border-radius:var(--sp-radius-xl);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-sheet);}.sp-confirm-dialog{width:min(300px,calc(100vw - 32px));padding:22px 16px 16px;text-align:center;transform:translateY(8px) scale(0.97);transition:transform 0.2s var(--sp-ease-out);}.sp-confirm-title{font-size:17px;font-weight:600;color:var(--sp-text);letter-spacing:-0.022em;margin-bottom:4px;}.sp-confirm-message{font-size:13px;color:var(--sp-text-secondary);line-height:1.4;margin-bottom:18px;}.sp-confirm-actions{display:flex;gap:8px;justify-content:flex-end;}.sp-confirm-actions > button,.sp-identity-actions > button{flex:1 1 0;height:44px;}.sp-card--resolved .sp-card-number,.sp-card--resolved .sp-card-message{color:var(--sp-text-secondary);}.sp-card--resolved .sp-card-message{text-decoration:line-through;text-decoration-color:color-mix(in srgb,var(--sp-text-secondary) 60%,transparent);}.sp-loading{display:flex;align-items:center;justify-content:center;padding:56px 24px;}.sp-identity-backdrop{position:fixed;inset:0;background:var(--sp-identity-overlay);display:flex;align-items:center;justify-content:center;z-index:${2147483647};opacity:0;transition:opacity 0.2s ease;}.sp-identity-modal{width:340px;max-width:calc(100vw - 32px);padding:24px 20px 18px;color:var(--sp-text);transform:translateY(12px) scale(0.97);transition:transform 0.2s var(--sp-ease-out);}.sp-identity--open{opacity:1;}.sp-identity--open .sp-identity-modal{transform:none;}.sp-identity-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:20px;}.sp-identity-title{font-family:var(--sp-font-display);font-size:20px;font-weight:700;color:var(--sp-text);letter-spacing:-0.022em;}.sp-input{width:100%;height:40px;padding:0 12px;border-radius:var(--sp-radius);border:none;background:var(--sp-fill);color:var(--sp-text);font-family:var(--sp-font);font-size:15px;letter-spacing:-0.01em;outline:none;transition:var(--sp-tr);}.sp-input::placeholder{color:var(--sp-text-secondary);}.sp-input:focus{background:var(--sp-row);box-shadow:var(--sp-ring);}.sp-input-label{font-size:12px;font-weight:500;letter-spacing:0.02em;color:var(--sp-text-secondary);margin:0 0 6px 4px;display:block;}.sp-btn-primary,.sp-btn-ghost,.sp-btn-danger{height:40px;padding:0 18px;border-radius:12px;border:none;color:#fff;font-family:var(--sp-font);font-size:15px;font-weight:600;letter-spacing:-0.01em;cursor:pointer;transition:var(--sp-tr);}.sp-btn-primary{background:var(--sp-accent);}.sp-btn-ghost{background:var(--sp-fill);color:var(--sp-text);font-weight:500;}.sp-btn-danger{background:var(--sp-danger);}@media (hover: hover) and (pointer: fine){.sp-btn-primary:hover{background:var(--sp-accent-dark);}.sp-btn-ghost:hover{background:var(--sp-fill-strong);}.sp-btn-danger:hover{background:var(--sp-danger-press);}}.sp-btn-primary:disabled{opacity:0.4;cursor:not-allowed;transform:none;}.sp-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:56px 24px;color:var(--sp-text-secondary);text-align:center;gap:8px;}.sp-empty-text{font-size:15px;font-weight:500;letter-spacing:-0.01em;}.sp-load-more-wrap{display:flex;justify-content:center;padding:4px 0 0;}.sp-btn-ghost.sp-btn-load-more{width:100%;height:44px;border-radius:var(--sp-radius-lg);background:var(--sp-row);color:var(--sp-accent-ink);box-shadow:var(--sp-shadow-row);}@media (hover: hover) and (pointer: fine){.sp-btn-ghost.sp-btn-load-more:hover{background:var(--sp-row-hover);}}@media (forced-colors: active){.sp-fab,.sp-radial-item,.sp-filter-dropdown-btn,.sp-segmented,.sp-segmented__btn,.sp-card,.sp-panel-close,.sp-search,.sp-btn-resolve,.sp-btn-delete,.sp-btn-delete-all,.sp-btn-primary,.sp-btn-ghost,.sp-btn-danger,.sp-card-expand,.sp-input,.sp-confirm-dialog{border:2px solid ButtonText !important;background:Canvas !important;color:ButtonText !important;}.sp-segmented__btn--active{background:Highlight !important;color:HighlightText !important;}.sp-filter-dropdown-menu{border:2px solid ButtonText !important;background:Canvas !important;}.sp-filter-dropdown-option--active{background:Highlight !important;color:HighlightText !important;}.sp-fab:focus-visible,.sp-radial-item:focus-visible,.sp-filter-dropdown-btn:focus-visible,.sp-segmented__btn:focus-visible,.sp-filter-dropdown-option:focus-visible,.sp-panel-close:focus-visible,.sp-btn-resolve:focus-visible,.sp-btn-delete:focus-visible,.sp-btn-delete-all:focus-visible,.sp-btn-primary:focus-visible,.sp-btn-ghost:focus-visible,.sp-btn-danger:focus-visible,.sp-card-expand:focus-visible,.sp-input:focus-visible,.sp-search:focus-visible{outline:3px solid Highlight !important;}.sp-panel{border:2px solid ButtonText !important;}.sp-fab-badge{border:2px solid ButtonText !important;background:Canvas !important;color:ButtonText !important;}.sp-card-bar{background:ButtonText !important;}}${Vi} ${Pa} ${Oa} ${Fa} ${Da} ${Ta} ${Ia} ${Gi}`}var As=120,Ps=80,sn=150,Ms=300,Qi=`opacity ${sn}ms ease, transform ${sn}ms ${z}`,Ji="scale(0.97)",Zi=10,eo="blur(30px) saturate(180%)",pt=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=E("div",{style:`position:fixed;z-index:${2147483647};max-width:280px;padding:10px 14px 12px;border:none;border-radius:14px;backdrop-filter:${eo};-webkit-backdrop-filter:${eo};font-family:${qa};pointer-events:auto;opacity:0;transform:${Ji};transition:${Qi};visibility:hidden;-webkit-font-smoothing:antialiased;`}),this.root.setAttribute("role","tooltip"),this.root.id=this.tooltipId,this.restyle(),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),O(this.root),document.body.appendChild(this.root);}colors;locale;root;showTimer=null;hideTimer=null;currentFeedbackId=null;closedAt=0;tooltipId="sp-tooltip";restyle(){let{surface:e}=this.colors,{style:n}=this.root;n.background=e.material,n.boxShadow=`inset 0 0.5px 0 ${e.edge}, ${e.shadowCard}`;}show(e,n){if(this.cancelHide(),this.currentFeedbackId===e.id)return;this.cancelShow();let i=this.root.style.visibility==="visible"||Date.now()-this.closedAt<Ms;this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(n);let o=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=o||i?"none":Qi,this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="none";},i?0:As);}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Ps);}hide(){this.cancelShow(),this.currentFeedbackId&&(this.closedAt=Date.now()),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform=Ji,setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden");},sn);}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null);}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null);}render(e){let n=za(this.locale),{inkMix:i}=this.colors.surface,o=E("div",{style:"display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;margin-bottom:8px;"}),r=(l,c)=>{let p=E("span",{style:`padding:2px 8px;border-radius:9999px;font-size:11px;font-weight:600;white-space:nowrap;color:color-mix(in srgb,${c} 74%,${i});background:color-mix(in srgb,${c} 13%,transparent);letter-spacing:0.01em;`});return F(p,l),p},s=E("span",{style:`font-size:12px;color:${this.colors.textSecondary};margin-left:auto;white-space:nowrap;font-variant-numeric:tabular-nums;`});F(s,L(e.createdAt,this.locale)),o.appendChild(r(Ba$1(e.type,n),ma(e.type,this.colors))),o.appendChild(r(Ca(e.status,n),na(e.status,this.colors))),o.appendChild(s);let a=E("div",{style:`font-size:14px;line-height:1.43;letter-spacing:-0.006em;color:${this.colors.text};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;`});F(a,e.message),this.root.replaceChildren(o,a);}position(e){let n=this.root.getBoundingClientRect(),i=e.top-n.height-Zi,o=e.left+e.width/2-n.width/2,r=true;i<8&&(i=e.bottom+Zi,r=false),o=Math.max(8,Math.min(o,window.innerWidth-n.width-8)),this.root.style.top=`${i}px`,this.root.style.left=`${o}px`;let s=Math.max(22,Math.min(e.left+e.width/2-o,n.width-16));this.root.style.transformOrigin=`${s}px ${r?"100%":"0"}`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var dt=null;function Is(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 Ae(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:()=>Promise.resolve(),focusFeedback:()=>false,on:()=>t,off:t}}function to(){try{return process.env.NODE_ENV}catch{return}}function Ls(){let t=location.hostname;return t===""||t==="localhost"||t.endsWith(".localhost")||t==="127.0.0.1"||t==="[::1]"}function _s(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function no(t){if(typeof window>"u"||typeof document>"u")return t.onSkip?.("ssr"),Ae();let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(dt)return e("initSiteping() called more than once \u2014 returning existing instance"),dt();let n=to();if(!t.forceShow&&(n==="production"||n===void 0&&!Ls()))return t.onSkip?.("production"),Ae();let i=typeof t.minViewportWidth=="number"&&Number.isFinite(t.minViewportWidth)?t.minViewportWidth:0;if(!t.forceShow&&window.innerWidth<i){let u="mobile";return t.onSkip?.(u),Ae()}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."),Ae();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),Ae();let o=g(t.locale??"en"),r=o==="en"?Promise.resolve():ya(o).catch(()=>{}),s=za(o),a=t.scopeAnnotationsByUrl??true,l=()=>{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:o,scopeAnnotationsByUrl:a});let c=Is(t.captureDiagnostics),p=c.console?new et(c.maxConsoleEntries):null,f=c.network?new tt(c.maxNetworkEntries):null,h=la(t.accentColor,t.theme),d=new Te,g$1=new Set,v=(u,...m)=>{for(let y of g$1)y.emit(u,...m);},k=(()=>{if(t.store)return new ct(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 Je(u,t.projectName,{apiKey:t.apiKey,headers:t.headers})})();t.onOpen&&d.on("open",t.onOpen),t.onClose&&d.on("close",t.onClose),t.onFeedbackSent&&d.on("feedback:sent",t.onFeedbackSent),t.onCommentAdded&&d.on("comment:added",t.onCommentAdded),t.onError&&d.on("feedback:error",t.onError),t.onError&&d.on("panel:action-error",t.onError),d.on("panel:action-error",u=>console.error("[siteping] Panel action failed:",u)),t.onAnnotationStart&&d.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&d.on("annotation:end",t.onAnnotationEnd);let H=Ge(t.projectName,t.endpoint);d.on("feedback:sent",u=>H.add(u.id)),d.on("feedback:deleted",u=>H.remove(u)),d.on("feedback:all-deleted",()=>H.clear());let S$1={"feedback:sent":()=>d.on("feedback:sent",u=>v("feedback:sent",u)),"feedback:deleted":()=>d.on("feedback:deleted",u=>v("feedback:deleted",u)),"comment:added":()=>d.on("comment:added",u=>v("comment:added",u)),"feedback:error":()=>d.on("feedback:error",u=>v("feedback:error",u)),"panel:open":()=>d.on("open",()=>v("panel:open")),"panel:close":()=>d.on("close",()=>v("panel:close")),"annotation:start":()=>d.on("annotation:start",()=>v("annotation:start")),"annotation:end":()=>d.on("annotation:end",()=>v("annotation:end"))};for(let u of Object.values(S$1))u();d.on("open",()=>e("Panel opened")),d.on("close",()=>e("Panel closed")),d.on("feedback:sent",u=>e("Feedback sent",u.id)),d.on("feedback:error",u=>e("Feedback failed",u.message)),d.on("annotation:start",()=>e("Annotation started")),d.on("annotation:end",()=>e("Annotation ended"));let w=document.createElement("siteping-widget");w.style.cssText=`position:fixed;z-index:${2147483647};pointer-events:auto;`;let D=to()==="test"?"open":"closed",P=w.attachShadow({mode:D}),$;if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;P.adoptedStyleSheets=[u],$=()=>u.replaceSync(on(h));}else {let u=document.createElement("style");P.appendChild(u),$=()=>{u.textContent=on(h);};}$(),O(w,P);let an=S();document.body.appendChild(w);let Pe=C(w),I=document.createElement("div");I.setAttribute("role","status"),I.setAttribute("aria-live","polite"),I.setAttribute("aria-atomic","true"),I.setAttribute("data-siteping-ignore","true"),I.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",O(I),document.body.appendChild(I);let b=document.createElement("div");b.className="sp-toast",b.setAttribute("aria-hidden","true"),b.hidden=true;let T,B=()=>{clearTimeout(T),!b.hidden&&(b.classList.add("sp-toast--leaving"),T=setTimeout(()=>{b.hidden=true,b.classList.remove("sp-toast--leaving");},150));};b.addEventListener("click",B),P.appendChild(b);let z=(u,m)=>{I.textContent=u,b.textContent=u,b.classList.toggle("sp-toast--error",m),b.classList.remove("sp-toast--leaving"),b.hidden=false,clearTimeout(T),T=setTimeout(B,m?8e3:4e3);},q=new pt(h,o),U=new lt(h,q,d,s,I),ut=new nt(P,t,d,s);d.on("markers:changed",u=>ut.updateBadge(u));let M=null,ht=null,K=false,Me=0;async function ln(u=false){let m=t.identity??Ut();if(m)return m;let y=await Ns(P,s,u);return y&&Ci(y),y}async function ft(){return K?null:M||(ht||(ht=import('./panel-TDZWSRVV.js').then(u=>K?null:(M=new u.Panel(P,h,d,k,t.projectName,U,s,o,{getScope:l,scopeAnnotationsByUrl:a,panelActions:t.panelActions,ownFeedback:H,resolveIdentity:ln,readOnly:t.readOnly}),M))),ht)}if(typeof window<"u"){let u=()=>{K||ft();},m=window.requestIdleCallback;typeof m=="function"?m(u):setTimeout(u,200);}let se=false,io=d.on("panel:toggle",u=>{M||(u?(se=true,ft().then(m=>{m&&se&&m.open(),se=false;}).catch(m=>e("Failed to lazy-load panel:",m))):se=false);}),fe=new Ve(h,d,s,t.enableScreenshot??false,()=>Pe.getLastPageFocus()),Ie=null;t.enableRightClickComment&&(Ie=u=>{if(u.defaultPrevented)return;let m=u.pointerType;m===""||m===void 0&&u.button!==2||u.shiftKey||u.ctrlKey||u.altKey||u.metaKey||u.composedPath().some(E=>E===w||E instanceof Element&&(E.hasAttribute("data-siteping-ignore")||E.id==="siteping-markers"))||fe.isBusy||(u.preventDefault(),fe.startInstantAnnotation(u.clientX,u.clientY).catch(E=>e("right-click annotation failed",E)));},document.addEventListener("contextmenu",Ie)),o!=="en"&&r.then(()=>{K||(ut.refreshLabels(),fe.refreshLabels());});let mt=false,oo=d.on("annotation:complete",async u=>{if(mt){d.emit("submission:cancelled");return}mt=true;try{let{annotation:m,type:y,message:E,clientId:L,screenshotDataUrl:re,screenshotRegion:Le}=u,A=await ln(!0);if(!A){d.emit("submission:cancelled");return}let ge=l(),un=null;(p||f)&&(un={console:p?.getEntries()??[],network:f?.getEntries()??[]});let lo={projectName:t.projectName,type:y,message:E,url:ge.url,urlPattern:ge.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:A.name,authorEmail:A.email,annotations:[m],clientId:L,screenshotDataUrl:re??null,screenshotRegion:Le??null,diagnostics:un};try{let Y=await k.sendFeedback(lo);d.emit("feedback:sent",Y),(!a||Y.url===ge.url)&&U.addFeedback(Y,U.count+1),z(s("feedback.sent.confirmation"),!1),M&&await M.refresh();}catch(Y){let vt=Ei(Y);vt&&d.emit("feedback:queued"),d.emit("feedback:error",Y instanceof Error?Y:new Error(String(Y))),z(s(vt?"feedback.queued":"feedback.error.message"),!vt);}}finally{mt=false;}}),gt=l(),so=a?{limit:20,url:gt.url}:{limit:20},bt=_s(t.deepLink),ro=++Me;Promise.all([k.getFeedbacks(t.projectName,so),r]).then(([{feedbacks:u}])=>{if(K||Me!==ro)return;let m=a?u.filter(y=>y.url===gt.url):u;if(U.render(m),bt.enabled)try{let y=new URLSearchParams(window.location.search).get(bt.param);if(y){let E=U.focusFeedback(y);e(`deepLink ?${bt.param}=${y} ${E?"focused":"did not match a visible feedback"}`),E&&ft().then(async L=>{!L||K||(await L.open(),L.showFeedback(y));}).catch(L=>e("deepLink could not open the feedback:",L));}}catch(y){e("deepLink parsing failed:",y);}}).catch(u=>{e("Failed to load initial markers:",u);}),t.endpoint&&ki(t.endpoint,t.identity??Ut(),{apiKey:t.apiKey,headers:t.headers}).then(()=>e("Retry queue flushed")).catch(()=>{});let yt=()=>{let u=++Me;if(M?.isCurrentlyOpen)return M.refresh();let m=l(),y=a?{limit:20,url:m.url}:{limit:20};return k.getFeedbacks(t.projectName,y).then(({feedbacks:E})=>{if(K||u!==Me||M?.isCurrentlyOpen)return;let L=a?E.filter(re=>re.url===m.url):E;U.render(L);})},ao=t.theme==="auto"?ka(()=>{Object.assign(h,la(t.accentColor,"auto")),$(),q.restyle(),fe.restyle(),yt().catch(()=>{});}):void 0,cn=null;if(t.watchNavigation!==false&&typeof window<"u"&&typeof history<"u"){let u=A=>`${A.url}
|
|
3
|
-
${A.urlPattern??""}`,m=u(gt),y=()=>{if(K)return;let A=u(l());if(A===m)return;let ge=m;m=A,e("SPA navigation detected \u2014 refreshing feedbacks for new scope"),yt().catch(()=>{m===A&&(m=ge);});},E=history.pushState,L=history.replaceState,re=function(...A){E.apply(this,A),y();},Le=function(...A){L.apply(this,A),y();};history.pushState=re,history.replaceState=Le,window.addEventListener("popstate",y),window.addEventListener("hashchange",y),cn=()=>{window.removeEventListener("popstate",y),window.removeEventListener("hashchange",y),history.pushState===re&&(history.pushState=E),history.replaceState===Le&&(history.replaceState=L);};}let me={destroy:()=>{e("Destroying widget"),Ie&&document.removeEventListener("contextmenu",Ie),K=true,se=false,cn?.(),ao?.(),Pe.destroy(),oo(),io(),ut.destroy(),M?.destroy(),fe.destroy(),U.destroy(),q.destroy(),p?.dispose(),f?.dispose(),d.removeAll(),clearTimeout(T),I.remove(),w.remove(),an(),dt=null;},open:()=>{d.emit("panel:toggle",true);},close:()=>{M?M.close():se=false;},focusFeedback:u=>U.focusFeedback(u),refresh:()=>yt().catch(()=>{})},pn=0,dn=()=>{let u=new Te,m=true;return pn++,g$1.add(u),{destroy:()=>{m&&(m=false,g$1.delete(u),--pn===0&&me.destroy());},open:()=>{m&&me.open();},close:()=>{m&&me.close();},refresh:()=>m?me.refresh():Promise.resolve(),focusFeedback:y=>m&&me.focusFeedback(y),on:(y,E)=>u.on(y,E),off:(y,E)=>{u.off(y,E);}}};return dt=dn,dn()}function
|
|
1
|
+
import {g,ya,za as za$1,la,O,S,C,ka,o,n,l,c,x,s,u,e,E,qa,z,F,L,ma,Ba,na,Ca,k,Aa,va,N,ta,ua,ia,ja,V,U,D,T,I,Q,W,A,B,M,t,v,d,sa,_,$,aa,ba,K,P,R,wa,q,p,r,h,a,b,Pa,Oa,Fa,Da,Ta,Ia,y,ra}from'./chunk-HFZPYBZG.js';export{f as isSitepingError,ya as loadLocale,xa as registerLocale}from'./chunk-HFZPYBZG.js';var uo=new Set(["role","name","aria-label","rel","href"]);function ho(t,e){let n=uo.has(t);n||=t.startsWith("data-")&&ve(t);let i=ve(e)&&e.length<100;return i||=e.startsWith("#")&&ve(e.slice(1)),n&&i}function fo(t){return ve(t)}function mo(t){return ve(t)}function go(t){return true}function At(t,e){if(t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return "html";let n={root:document.body,idName:fo,className:mo,tagName:go,attr:ho,timeoutMs:1e3,seedMinLength:3,optimizedMinLength:2,maxNumberOfPathChecks:1/0},i=new Date,o={...n,...e},r=wo(o.root,n),s,a=0;for(let c of bo(t,o,r)){if(new Date().getTime()-i.getTime()>o.timeoutMs||a>=o.maxNumberOfPathChecks){let f=vo(t,r);if(!f)throw new Error(`Timeout: Can't find a unique selector after ${o.timeoutMs}ms`);return xe(f)}if(a++,Pt(c,r)){s=c;break}}if(!s)throw new Error("Selector was not found.");let l=[...Gn(s,t,o,r,i)];return l.sort(Ct),l.length>0?xe(l[0]):xe(s)}function*bo(t,e,n){let i=[],o=[],r=t,s=0;for(;r&&r!==n;){let a=yo(r,e);for(let l of a)l.level=s;if(i.push(a),r=r.parentElement,s++,o.push(...Vn(i)),s>=e.seedMinLength){o.sort(Ct);for(let l of o)yield l;o=[];}}o.sort(Ct);for(let a of o)yield a;}function ve(t){if(/^[a-z\-]{3,}$/i.test(t)){let e=t.split(/-|[A-Z]/);for(let n of e)if(n.length<=2||/[^aeiou]{4,}/i.test(n))return false;return true}return false}function yo(t,e){let n=[],i=t.getAttribute("id");i&&e.idName(i)&&n.push({name:"#"+CSS.escape(i),penalty:0});for(let s=0;s<t.classList.length;s++){let a=t.classList[s];e.className(a)&&n.push({name:"."+CSS.escape(a),penalty:1});}for(let s=0;s<t.attributes.length;s++){let a=t.attributes[s];e.attr(a.name,a.value)&&n.push({name:`[${CSS.escape(a.name)}="${CSS.escape(a.value)}"]`,penalty:2});}let o=t.tagName.toLowerCase();if(e.tagName(o)){n.push({name:o,penalty:5});let s=Rt(t,o);s!==void 0&&n.push({name:Yn(o,s),penalty:10});}let r=Rt(t);return r!==void 0&&n.push({name:xo(o,r),penalty:50}),n}function xe(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 Un(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ct(t,e){return Un(t)-Un(e)}function Rt(t,e){let n=t.parentNode;if(!n)return;let i=n.firstChild;if(!i)return;let o=0;for(;i&&(i.nodeType===Node.ELEMENT_NODE&&(e===void 0||i.tagName.toLowerCase()===e)&&o++,i!==t);)i=i.nextSibling;return o}function vo(t,e){let n=0,i=t,o=[];for(;i&&i!==e;){let r=i.tagName.toLowerCase(),s=Rt(i,r);if(s===void 0)return;o.push({name:Yn(r,s),penalty:NaN,level:n}),i=i.parentElement,n++;}if(Pt(o,e))return o}function xo(t,e){return t==="html"?"html":`${t}:nth-child(${e})`}function Yn(t,e){return t==="html"?"html":`${t}:nth-of-type(${e})`}function*Vn(t,e=[]){if(t.length>0)for(let n of t[0])yield*Vn(t.slice(1,t.length),e.concat(n));else yield e;}function wo(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Pt(t,e){let n=xe(t);switch(e.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return true;default:return false}}function*Gn(t,e,n,i,o){if(t.length>2&&t.length>n.optimizedMinLength)for(let r=1;r<t.length-1;r++){if(new Date().getTime()-o.getTime()>n.timeoutMs)return;let a=[...t];a.splice(r,1),Pt(a,i)&&i.querySelector(xe(a))===e&&(yield a,yield*Gn(a,e,n,i,o));}}var Eo=["role","aria-label","type","name","href","src","data-testid","data-id"];function ko(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 Mt(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let o of i.children){if(o===t)break;o.tagName===t.tagName&&n++;}return `${e}:${n}:${It(t)}`}function It(t){let e=[];for(let n of Eo){let i=t.getAttribute(n);i&&e.push(`${n}=${i}`);}return e.length>0?ko(e.join(",")):"0"}function Qn(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=Mt(t),[c,p,f]=l.split(":"),h=0,d=Math.abs(Number(c)-s);d===0?h+=.2:d<=2?h+=.1:d<=5&&(h+=.03);let g=Math.abs(Number(p)-a);return g===0?h+=.4:g===1?h+=.2:g<=3&&(h+=.08),f===r&&(h+=.4),h}var Xe=256;function je(t,e){let n=t;for(;n&&A(n);)n=n[e];return n}function Jn(t){return t.nodeType===1&&t.getAttribute("data-siteping-ignore")==="true"}function So(t){return t.nodeType===3?NodeFilter.FILTER_ACCEPT:Jn(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP}function ce(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=je(t[n],n),o=3;for(;i&&o>0;){let r=e==="before"?To(i,Xe,true).trim():j(i,Xe,true).trim();if(r)return e==="before"?r.slice(-32):r.slice(0,32);i=je(i[n],n),o--;}return ""}function qe(t){let e=je(t.previousElementSibling,"previousElementSibling"),n=je(t.nextElementSibling,"nextElementSibling"),i=e?j(e,Xe,true).trim().slice(0,40):"",o=n?j(n,Xe,true).trim().slice(0,40):"";return [i,o].filter(Boolean).join(" | ")}function j(t,e,n=false){let i="";if(t.firstElementChild===null){for(let r of t.childNodes)if(r.nodeType===3&&(i+=r.data,i.length>=e))break;return i.length>e?i.slice(0,e):i}let o=n?t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,So):t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;i.length<e;){let r=o.nextNode();if(!r)break;i+=r.data;}return i.length>e?i.slice(0,e):i}function To(t,e,n=false){let i="",o=r=>{for(let s=r.lastChild;s;s=s.previousSibling)if(s.nodeType===3){if(i=s.data+i,i.length>=e)return true}else if(s.nodeType===1&&!(n&&Jn(s))&&o(s))return true;return false};return o(t),i.length>e?i.slice(-e):i}function Zn(t){if(t.getRootNode()instanceof ShadowRoot)return Co(t);let e=Lt(t);if(e)return `//${t.localName}[@id=${_t(e)}]`;let n=[],i=t;for(;i&&i!==document.body&&n.length<6;){let o=i.localName,r=i.parentElement,s=Lt(i);if(s)return n.unshift(`/${o}[@id=${_t(s)}]`),"/"+n.join("");let a=1;if(r)for(let l of r.children){if(l===i)break;l.localName===o&&a++;}n.unshift(`/${o}[${a}]`),i=r;}return i!==document.body?"/"+n.join(""):"/html/body"+n.join("")}function Co(t){let e="";for(let n=t;n;n=n.parentElement){let i=n.localName,o=Lt(n);if(o){e=`/${i}[@id=${_t(o)}]${e}`;continue}let r=1;for(let s=n.previousElementSibling;s;s=s.previousElementSibling)s.localName===i&&r++;e=`/${i}[${r}]${e}`;}return `.${e}`}function Lt(t){return t.id&&t.id.length<=q?t.id:void 0}function _t(t){return t.includes("'")?`concat('${t.replace(/'/g,`',"'",'`)}')`:`'${t}'`}var we="data-feedback-anchor",Nt=" >>> ",ei={className:t=>!/^(css|sc|emotion|styled)-/.test(t)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(t),attr:t=>["data-testid","data-id","role","aria-label"].includes(t),idName:t=>!t.startsWith("radix-")&&!/^:r[0-9]+:$/.test(t),seedMinLength:3,optimizedMinLength:2};function ti(t,e){let n=t;for(;n;){let i=n.closest(e);if(i)return i;let o=n.getRootNode();n=o instanceof ShadowRoot?o.host:null;}return null}function ni(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return e instanceof ShadowRoot?e.host:null}function Ft(t){let e=[],n=t;for(;n;){let d=n.getRootNode();d instanceof ShadowRoot?(e.unshift(At(n,{...ei,root:d})),n=d.host):(e.unshift(At(n,ei)),n=null);}let i=e.join(Nt),o=Zn(t),r=ti(t,'[data-siteping-ignore="true"]')!==null,s=r?"":j(t,256,true).trim().slice(0,120),a=r?"":ce(t,"before"),l=r?"":ce(t,"after"),c=Mt(t),p$1=r?"":qe(t),h=ti(t,`[${we}]`)?.getAttribute(we)??null;return {cssSelector:i,xpath:o,textSnippet:s,textPrefix:a,textSuffix:l,fingerprint:c,neighborText:p$1,elementTag:t.tagName.slice(0,p),elementId:t.id&&t.id.length<=q?t.id:void 0,anchorKey:h}}function ii(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 oi(t,e=document.documentElement){let n=Ot(t.x+t.width/2,t.y+t.height/2);if(!n||n===e)return document.body;let i=n;for(;i&&i!==document.body;){if(i.hasAttribute(we)&&ii(i,t))return i;i=ni(i);}for(i=n;i&&i!==document.body;){if(ii(i,t))return i;i=ni(i);}return document.body}function Ot(t,e){let n=document.elementFromPoint(t,e),i=n?.shadowRoot;for(;i&&typeof i.elementFromPoint=="function";){let o=i.elementFromPoint(t,e);if(!o||o.getRootNode()!==i)break;n=o,i=o.shadowRoot;}return n}function si(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 ri={width:334,height:280},pe={top:0,bottom:0};function ai(t,e,n,i=pe){let o=i.top+8,r=n.height-i.bottom-8,s=Math.max(0,r-o),a=t.bottom+8,l=t.top-8-e.height,c=d=>d>=o&&d+e.height<=r,p,f=null;c(a)?p=a:c(l)?p=l:e.height<=s?p=Math.min(Math.max(a,o),r-e.height):(p=o,f=s);let h=t.left;return h+e.width>n.width-8&&(h=t.right-e.width),h=Math.max(8,Math.min(h,n.width-8-e.width)),{top:p,left:h,maxHeight:f}}var Ro={question:"type.question",change:"type.change",bug:"type.bug",other:"type.other"},Ht=`opacity ${200}ms ease,transform ${200}ms ${z}`,Ao="opacity 300ms ease,transform 300ms cubic-bezier(0.32, 0.72, 0, 1)",Ue=`background-color 0.15s ease,border-color 0.15s ease,color 0.15s ease,box-shadow 0.15s ease,opacity 0.15s ease,scale 0.16s ${z}`,li="blur(30px) saturate(180%)",Ee=class{constructor(e,n){this.colors=e;this.t=n;this.root=E("div",{style:`position:fixed;z-index:${2147483647};pointer-events:auto;width:300px;padding:16px;border:none;border-radius:18px;color:${this.colors.text};font-family:${qa};opacity:0;transform:scale(0.96);transition:${Ht};display:none;-webkit-font-smoothing:antialiased;`}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("data-siteping-ignore","true");let i=[{type:"question",icon:_},{type:"change",icon:$},{type:"bug",icon:aa},{type:"other",icon:ba}];this.typeRow=E("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:12px;"});for(let r of i){let s=document.createElement("button");s.style.cssText=`height:50px;padding:0 12px;border:none;border-radius:12px;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-family:${qa};font-size:13px;font-weight:500;letter-spacing:-0.005em;transition:${Ue};`;let a=D(r.icon);a.style.cssText=`width:17px;height:17px;flex-shrink:0;color:${ma(r.type,this.colors)};`,s.appendChild(a),s.appendChild(document.createElement("span")),s.dataset.type=r.type,s.setAttribute("aria-pressed","false"),this.paintType(s),s.addEventListener("click",()=>{this.submittingState||this.selectType(r.type,this.typeRow);}),s.addEventListener("mouseenter",()=>{this.submittingState||!ua()||this.paintType(s,true);}),s.addEventListener("mouseleave",()=>{this.submittingState||this.paintType(s);}),M(s),N(s,this.colors.accent),this.typeRow.appendChild(s);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`width:100%;min-height:80px;max-height:152px;padding:9px 12px;border:none;border-radius:12px;color:${this.colors.text};font-family:${qa};font-size:15px;line-height:1.35;letter-spacing:-0.01em;resize:vertical;outline:none;box-shadow:none;transition:${Ue};box-sizing:border-box;`,this.textarea.maxLength=5e3,this.paintField(false),this.hint=E("div",{style:`font-size:11px;color:${this.colors.textSecondary};text-align:right;margin-top:6px;font-family:${qa};letter-spacing:0.01em;`}),this.textarea.addEventListener("focus",()=>{this.submittingState||this.paintField(true);}),this.textarea.addEventListener("blur",()=>{this.submittingState||this.paintField(false);}),this.textarea.addEventListener("input",()=>{this.updateSubmitState();}),this.textarea.addEventListener("keydown",r=>{this.submittingState||r.key==="Enter"&&(r.ctrlKey||r.metaKey)&&(r.preventDefault(),this.submit());});let o=E("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"});this.cancelBtn=document.createElement("button"),this.cancelBtn.style.cssText=`height:34px;padding:0 18px;border:none;border-radius:9999px;color:${this.colors.text};font-family:${qa};font-size:15px;font-weight:500;letter-spacing:-0.01em;cursor:pointer;transition:${Ue};`,this.paintCancel(false),this.cancelBtn.addEventListener("click",()=>this.dismiss()),this.cancelBtn.addEventListener("mouseenter",()=>{this.submittingState||!ua()||this.paintCancel(true);}),this.cancelBtn.addEventListener("mouseleave",()=>{this.submittingState||this.paintCancel(false);}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`position:relative;height:34px;padding:0 20px;border:none;border-radius:9999px;background:${this.colors.accent};color:#fff;font-family:${qa};font-size:15px;font-weight:600;letter-spacing:-0.01em;cursor:pointer;opacity:0.35;pointer-events:none;transition:${Ue};display:inline-flex;align-items:center;justify-content:center;min-width:64px;`,this.submitLabel=document.createElement("span"),this.submitBtn.appendChild(this.submitLabel),this.submitBtn.addEventListener("click",()=>this.submit()),this.submitBtn.addEventListener("mouseenter",()=>{this.submittingState||!ua()||(this.submitBtn.style.background=this.colors.accentDark);}),this.submitBtn.addEventListener("mouseleave",()=>{this.submitBtn.style.background=this.colors.accent;}),M(this.cancelBtn),M(this.submitBtn),N(this.cancelBtn,this.colors.accent),N(this.submitBtn,this.colors.accent),o.appendChild(this.cancelBtn),o.appendChild(this.submitBtn),this.root.appendChild(this.typeRow),this.root.appendChild(this.textarea),this.root.appendChild(this.hint),this.root.appendChild(o),O(this.root),document.body.appendChild(this.root),this.applyLabels();}colors;t;root;selectedType=null;textarea;submitBtn;cancelBtn;typeRow;submitLabel;hint;resolve=null;previouslyFocused=null;removeKeydownTrap=null;onSubmit=null;submittingState=false;showFrame=null;hideTimeoutId=null;spinnerAnimation=null;sheet=false;stopKeyboardTracking=null;get isOpen(){return this.resolve!==null}get sheetTop(){return this.sheet&&this.isOpen?window.innerHeight-this.root.offsetHeight: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=Ro[i];if(!o)continue;let r=n.querySelector("span");r&&F(r,this.t(o));}this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria")),F(this.hint,K()?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),F(this.cancelBtn,this.t("popup.cancel")),F(this.submitLabel,this.t("popup.submit"));}show(e,n,i=pe){return new Promise(o=>{this.cancelPendingTransition(),this.resolve=o,this.onSubmit=n??null,this.selectedType=null,this.textarea.value="",this.submittingState=false;let r=ta();this.sheet=sa(),this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let s=this.sheet?"48px":r?"44px":"34px";this.cancelBtn.style.height=s,this.submitBtn.style.height=s,this.cancelBtn.style.flex=this.sheet?"1":"",this.submitBtn.style.flex=this.sheet?"2":"",this.textarea.style.fontSize=r?"16px":"15px",this.textarea.style.minHeight=this.sheet?"104px":"80px",this.paintField(false),this.paintCancel(false),this.submitBtn.style.background=this.colors.accent,this.hint.style.display=r?"none":"",this.root.style.transform=this.hiddenTransform(),P(this.root,false),this.root.style.display="block",this.layout(e,i),this.removeKeydownTrap?.(),this.removeKeydownTrap=R(this.root,a=>{if(a.key==="Escape"&&this.dismiss(),a.key==="Tab"){let l=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(l.length===0)return;let c=l[0],p=l[l.length-1];if(!c||!p)return;a.shiftKey?(document.activeElement===c||!this.root.contains(document.activeElement))&&(a.preventDefault(),p.focus()):(document.activeElement===p||!this.root.contains(document.activeElement))&&(a.preventDefault(),c.focus());}}),this.root.style.transition=va()?"none":this.sheet?Ao:Ht,this.showFrame=requestAnimationFrame(()=>{this.showFrame=null,this.root.style.opacity="1",this.root.style.transform="none",(r?this.typeRow.querySelector("button"):this.textarea)?.focus();});})}layout(e,n){let i=this.root.style,{surface:o}=this.colors;if(i.width=this.sheet?"auto":"300px",i.borderRadius=this.sheet?"16px 16px 0 0":"18px",i.background=this.sheet?o.grouped:o.material,i.backdropFilter=this.sheet?"none":li,i.setProperty("-webkit-backdrop-filter",this.sheet?"none":li),i.boxShadow=this.sheet?`0 -0.5px 0 ${o.hairline}, 0 -10px 40px rgba(0, 0, 0, 0.16)`:`inset 0 0.5px 0 ${o.edge}, ${o.shadowCard}`,i.overscrollBehavior=this.sheet?"contain":"",this.stopKeyboardTracking?.(),this.stopKeyboardTracking=null,this.sheet){i.top="auto",i.left="0",i.right="0",i.overflowY="auto";let f=(h,d=window.innerHeight)=>{i.bottom=`${h}px`,i.maxHeight=`${d-8}px`,i.padding=`16px 16px ${h>0?"16px":"calc(16px + env(safe-area-inset-bottom, 0px))"}`;};f(0),this.stopKeyboardTracking=wa(f);return}i.right="",i.bottom="",i.padding="16px",i.maxHeight="",i.overflowY="";let{top:r,left:s,maxHeight:a}=ai(e,this.measure(),{width:window.innerWidth,height:window.innerHeight},n);i.top=`${r}px`,i.left=`${s}px`;let{width:l,height:c}=this.measure(),p=Math.min(Math.max(e.left+e.width/2-s,0),l);i.transformOrigin=`${Math.round(p)}px ${r>=e.top+e.height/2?0:c}px`,a!==null&&(i.maxHeight=`${Math.max(0,a-this.verticalChromeHeight())}px`,i.overflowY="auto",this.root.scrollTop=0);}hiddenTransform(){return this.sheet?"translateY(100%)":"scale(0.96)"}measure(){let e=this.root.offsetWidth,n=this.root.offsetHeight;return e>0&&n>0?{width:e,height:n}:ri}verticalChromeHeight(){let e=window.getComputedStyle(this.root);return e.boxSizing==="border-box"?0:[e.paddingTop,e.paddingBottom,e.borderTopWidth,e.borderBottomWidth].reduce((n,i)=>n+(Number.parseFloat(i)||0),0)}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let o of i)o.setAttribute("aria-pressed",String(o.dataset.type===e)),this.paintType(o);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.cursor="pointer",this.paintType(n);}paintType(e,n=false){let{surface:i}=this.colors,o=e.style;if(e.getAttribute("aria-pressed")==="true"){let r=ma(e.dataset.type??"",this.colors);o.background=`color-mix(in srgb, ${r} 15%, ${i.row})`,o.color=`color-mix(in srgb, ${r} 78%, ${i.inkMix})`,o.fontWeight="600",o.boxShadow=`inset 0 0 0 1.5px ${r}`;return}o.background=n?i.fillStrong:this.sheet?i.row:i.fill,o.color=this.colors.text,o.fontWeight="500",o.boxShadow="none";}paintField(e){let{surface:n}=this.colors;this.textarea.style.background=e||this.sheet?n.row:n.fill,this.textarea.style.boxShadow=e?`0 0 0 3px color-mix(in srgb, ${this.colors.accent} 30%, transparent)`:"none";}paintCancel(e){let{surface:n}=this.colors;this.cancelBtn.style.background=e||this.sheet?n.fillStrong:n.fill;}updateSubmitState(){if(this.submittingState)return;let e=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.textarea.value.trim())return;let e={type:this.selectedType??"other",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();});}dismiss(){this.submittingState||!this.isOpen||(this.resolve?.(null),this.resolve=null,this.hideElement());}enterSubmittingState(){this.submittingState=true,this.submitLabel.style.opacity="0",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.opacity="",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="position:absolute;inset:0;margin:auto;width:14px;height:14px;border:2px solid rgba(255,255,255,0.35);border-top-color:#fff;border-radius:50%;box-sizing:border-box;",!va()&&typeof e.animate=="function"&&(this.spinnerAnimation=e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:600,iterations:1/0,easing:"linear"})),e}hideElement(){if(this.cancelPendingTransition(),this.removeKeydownTrap?.(),this.removeKeydownTrap=null,this.submittingState&&this.exitSubmittingState(),this.onSubmit=null,this.stopKeyboardTracking?.(),this.stopKeyboardTracking=null,va()||(this.root.style.transition=Ht),this.root.style.opacity="0",this.root.style.transform=this.hiddenTransform(),this.previouslyFocused?.focus(),this.previouslyFocused=null,P(this.root,true),va()){this.root.style.display="none";return}this.hideTimeoutId=setTimeout(()=>{this.hideTimeoutId=null,this.root.style.display="none";},200);}cancelPendingTransition(){this.showFrame!==null&&cancelAnimationFrame(this.showFrame),this.hideTimeoutId!==null&&clearTimeout(this.hideTimeoutId),this.showFrame=null,this.hideTimeoutId=null;}destroy(){this.submittingState&&this.exitSubmittingState(),this.cancelPendingTransition(),this.resolve?.(null),this.resolve=null,this.onSubmit=null,this.removeKeydownTrap?.(),this.removeKeydownTrap=null,this.stopKeyboardTracking?.(),this.stopKeyboardTracking=null,this.root.remove();}};var ke,ci=false;async function Po(){if(ke!==void 0)return ke;try{let t=await import('html2canvas-pro');return ke=t.default??t,ke}catch(t){return ke=null,ci||(ci=true,console.warn("[siteping] html2canvas-pro import failed unexpectedly. Capture is disabled for this session \u2014 feedbacks are still submitted, just without screenshots. Underlying error:",t)),null}}function Mo(t){for(let e of [t.documentElement,t.body])e&&e.style.setProperty("scroll-behavior","auto","important");}function $t(t,e,n){return Math.min(n,Math.max(t,e))}function Ye(t){return $t(0,Math.round(t*1e4)/1e4,1)}async function pi(t,e){let n=await Po();if(!n)return null;let i=.85,o=1200,r=$t(48,t.width*.6,280),s=$t(48,t.height*.6,220),a=window.scrollX+t.x,l=window.scrollY+t.y,c=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),p=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),f=Math.max(0,a-r),h=Math.max(0,l-s),d=Math.min(c,a+t.width+r)-f,g=Math.min(p,l+t.height+s)-h;if(d<=0||g<=0)return null;let v={xPct:Ye((a-f)/d),yPct:Ye((l-h)/g),wPct:Ye(t.width/d),hPct:Ye(t.height/g)};try{let k=await n(document.body,{x:f,y:h,width:d,height:g,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,onclone:Mo,ignoreElements:$=>$.tagName==="SITEPING-WIDGET"||$.closest?.("siteping-widget")!==null||$.getAttribute?.("data-siteping-ignore")==="true"});if(k.width<=o)return {dataUrl:k.toDataURL("image/jpeg",i),region:v};let H=o/k.width,S=o,w=Math.round(k.height*H),D=document.createElement("canvas");D.width=S,D.height=w;let P=D.getContext("2d");return P?(P.drawImage(k,0,0,S,w),{dataUrl:D.toDataURL("image/jpeg",i),region:v}):null}catch(k){return console.warn("[siteping] Screenshot capture failed:",k),null}}var di=10;function Io(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-transparency: reduce), (prefers-contrast: more)").matches}var ne={bg:"rgba(0, 0, 0, 0.86)",bgSolid:"#000000",text:"#f5f5f7",instruction:"rgba(255, 255, 255, 0.94)",cancelBg:"rgba(255, 255, 255, 0.16)",cancelHoverBg:"rgba(255, 69, 58, 0.26)",cancelHoverText:"#ff8a80"};function ui(t){let e=Math.max(0,t.left),n=Math.max(0,t.top);return new DOMRect(e,n,Math.max(0,Math.min(t.right,window.innerWidth)-e),Math.max(0,Math.min(t.bottom,window.innerHeight)-n))}function Lo(){return {clientId:r()}}var Ve=class{constructor(e,n,i,o=false,r){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.getFallbackTarget=r;this.popup=new Ee(e,i),this.bus.on("annotation:start",()=>this.activate());}colors;bus;t;enableScreenshot;getFallbackTarget;overlay=null;toolbar=null;toolbarCancel=null;cancelFrozen=false;drawingRect=null;startX=0;startY=0;isDrawing=false;isActive=false;instantMode=false;popup;stalePopup=false;savedOverflow="";preActiveFocusElement=null;keyboardTarget=null;rafId=null;pendingMoveEvent=null;rejectPendingSubmission=null;unregisterEscapeLayer=Q(document,()=>this.isActive);get isBusy(){return this.isActive}refreshLabels(){this.popup.refreshLabels();}restyle(){this.stalePopup=this.isActive||this.popup.isOpen,!this.stalePopup&&(this.popup.destroy(),this.popup=new Ee(this.colors,this.t));}async maybeCapture(e){return this.enableScreenshot?pi(e):null}activate(){if(this.isActive)return;this.isActive=true;let e=!this.instantMode,n=ta(),i=this.t("annotator.instruction");this.preActiveFocusElement=document.activeElement;let o=document.activeElement;if(this.keyboardTarget=o instanceof HTMLElement&&o!==document.body&&o!==document.documentElement&&!A(o)?B(o):this.getFallbackTarget?.()??null,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=E("div",{style:`position:fixed;inset:0;z-index:${2147483646};pointer-events:auto;background:${this.colors.surface.overlayTint};cursor:${e?"crosshair":"default"};touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;`}),this.overlay.setAttribute("role","application"),this.overlay.setAttribute("aria-label",e?i:this.t("annotator.instantInstruction")),this.overlay.setAttribute("data-siteping-ignore","true"),e){let r=Io()?`background:${ne.bgSolid};`:`background:${ne.bg};backdrop-filter:blur(24px) saturate(180%);-webkit-backdrop-filter:blur(24px) saturate(180%);`;this.toolbar=E("div",{style:`position:fixed;top:calc(env(safe-area-inset-top,0px) + 10px);left:0;right:0;width:max-content;max-width:calc(100vw - 24px);margin:0 auto;z-index:${2147483647};pointer-events:auto;min-height:44px;box-sizing:border-box;padding:5px 5px 5px 16px;border:none;border-radius:22px;${r} box-shadow:inset 0 0 0 0.5px rgba(255,255,255,0.14),0 12px 32px rgba(0,0,0,0.28);display:flex;align-items:center;justify-content:center;gap:12px;font-family:${qa};font-size:13px;line-height:1.35;color:${ne.text};-webkit-font-smoothing:antialiased;`}),this.toolbar.setAttribute("data-siteping-ignore","true");let s=`color-mix(in srgb, ${this.colors.accent} 50%, #ffffff)`,a=E("span",{style:`width:8px;height:8px;border-radius:50%;flex-shrink:0;background:${s};box-shadow:0 0 10px color-mix(in srgb,${this.colors.accent} 60%,#ffffff);`});!va()&&typeof a.animate=="function"&&a.animate([{opacity:1},{opacity:.4},{opacity:1}],{duration:1500,easing:"ease-in-out",iterations:1/0});let l=E("span",{style:`font-weight:500;letter-spacing:-0.005em;min-width:0;color:${ne.instruction};`});F(l,n?this.t("annotator.touchInstruction"):i);let c=document.createElement("button");c.style.cssText=`height:${n?40:34}px;padding:0 14px;border:none;border-radius:9999px;flex-shrink:0;color:#ffffff;font-family:${qa};font-size:13px;font-weight:600;cursor:pointer;touch-action:manipulation;transition:background-color 0.15s ease,color 0.15s ease,opacity 0.15s ease,scale 0.16s ${z};`,F(c,this.t("annotator.cancel")),c.addEventListener("click",()=>this.cancelSession()),M(c),N(c,s),c.addEventListener("mouseenter",()=>{!this.cancelFrozen&&ua()&&this.paintCancel(true);}),c.addEventListener("mouseleave",()=>this.paintCancel(false)),this.toolbarCancel=c,this.paintCancel(false),this.toolbar.appendChild(a),this.toolbar.appendChild(l),this.toolbar.appendChild(c);}e&&(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),O(this.overlay),this.toolbar&&O(this.toolbar),document.body.appendChild(this.overlay),this.toolbar&&(document.body.appendChild(this.toolbar),!va()&&typeof this.toolbar.animate=="function"&&this.toolbar.animate([{transform:"translateY(-100%)"},{transform:"none"}],{duration:250,easing:z})),this.overlay.focus({preventScroll:true});}toolbarInsets(){if(!this.toolbar)return pe;if(typeof this.toolbar.getAnimations=="function")for(let o of this.toolbar.getAnimations())o.finish();let e=this.toolbar.getBoundingClientRect();if(e.height===0)return pe;let n=window.innerHeight;return e.top+e.height/2<n/2?{top:Math.max(0,e.bottom),bottom:0}:{top:0,bottom:Math.max(0,n-e.top)}}cancelSession(){this.isActive&&(this.popup.dismiss(),!this.popup.isOpen&&this.deactivate());}paintCancel(e){let n=this.toolbarCancel;n&&(n.style.color=e?ne.cancelHoverText:"#ffffff",n.style.background=e?ne.cancelHoverBg:ne.cancelBg);}freezeCancel(e){this.cancelFrozen=e;let n=this.toolbarCancel;n&&(e&&this.paintCancel(false),n.style.opacity=e?"0.5":"1",n.style.cursor=e?"not-allowed":"pointer",e?n.setAttribute("aria-disabled","true"):n.removeAttribute("aria-disabled"));}deactivate(){if(!this.isActive)return;this.isActive=false,this.isDrawing=false,this.instantMode=false;let e=this.preActiveFocusElement;this.preActiveFocusElement=null,this.keyboardTarget=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.toolbarCancel=null,this.cancelFrozen=false,this.drawingRect=null,e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:true}),this.bus.emit("annotation:end"),this.stalePopup&&this.restyle();}onKeyDown=e=>{e.key==="Escape"&&this.cancelSession();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"||(e.preventDefault(),this.popup.isOpen)||this.isDrawing)return;let n=this.keyboardTarget;!n||!(n instanceof HTMLElement)||await this.annotateElement(n);};async annotateElement(e,n=false){let i=e.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let o=new DOMRect(i.x,i.y,i.width,i.height);this.drawingRect?.remove();let r=this.createDrawingRect();r.style.left=`${i.x}px`,r.style.top=`${i.y}px`,r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,this.drawingRect=r,this.overlay?.appendChild(r);let a={anchor:Ft(e),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.openForm(a,o,n?ui(o):o);this.drawingRect?.remove(),this.drawingRect=null,l&&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.popup.isOpen||(this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=this.createDrawingRect(),this.overlay?.appendChild(this.drawingRect));}createDrawingRect(){let{accent:e}=this.colors,n=E("div",{style:`position:fixed;border:2px solid ${e};background:color-mix(in srgb,${e} 10%,transparent);pointer-events:none;border-radius:12px;box-shadow:0 0 0 4px color-mix(in srgb,${e} 16%,transparent),0 8px 24px rgba(0,0,0,0.08);transition:box-shadow 0.15s ease;`});return n.setAttribute("data-siteping-ignore","true"),n}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);};elementAt(e,n){this.overlay&&(this.overlay.style.pointerEvents="none");let i=Ot(e,n);this.overlay&&(this.overlay.style.pointerEvents="auto");let o=i instanceof SVGElement?(i.ownerSVGElement??i).parentElement:i;return o instanceof HTMLElement&&o!==document.body&&o!==document.documentElement&&!A(o)?o:null}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<di||s<di){this.drawingRect.remove(),this.drawingRect=null;let p=this.elementAt(e,n);p&&await this.annotateElement(p,true);return}let a=new DOMRect(i,o,r,s),{annotation:l}=this.buildAnnotation(a),c=await this.openForm(l,a);this.drawingRect?.remove(),this.drawingRect=null,c&&this.deactivate();};async startInstantAnnotation(e,n){if(this.isActive)return;this.instantMode=true,this.bus.emit("annotation:start");let i=Math.max(0,Math.min(e-20/2,window.innerWidth-20)),o=Math.max(0,Math.min(n-20/2,window.innerHeight-20)),r=new DOMRect(i,o,20,20),{annotation:s,anchorBounds:a}=this.buildAnnotation(r),l=ui(a);this.drawingRect?.remove(),this.drawingRect=this.createDrawingRect(),Object.assign(this.drawingRect.style,{left:`${i}px`,top:`${o}px`,width:`${20}px`,height:`${20}px`}),this.overlay?.appendChild(this.drawingRect),await this.openForm(s,r,l),this.drawingRect?.remove(),this.drawingRect=null,this.deactivate();}openForm(e,n,i=n){let o=Lo(),r=this.popup.show(n,s=>(this.freezeCancel(true),this.runSubmission(e,s,i,o).finally(()=>this.freezeCancel(false))),this.toolbarInsets());return this.revealSelection(n),r}revealSelection(e){let n=this.popup.sheetTop;if(n===null||!this.drawingRect)return;let i=Math.min(e.bottom+16-n,e.top-72);if(i<=0)return;let o=window.scrollY;window.scrollBy({top:i,behavior:"instant"}),this.drawingRect.style.top=`${e.top-(window.scrollY-o)}px`;}async runSubmission(e,n,i,o){o.screenshot===void 0&&(o.screenshot=await this.maybeCapture(new DOMRect(i.x+e.scrollX-window.scrollX,i.y+e.scrollY-window.scrollY,i.width,i.height)));let r=o.screenshot;await new Promise((s,a)=>{let l=()=>{c(),p(),f(),h(),this.rejectPendingSubmission=null;},c=this.bus.on("feedback:sent",()=>{l(),s();}),p=this.bus.on("feedback:queued",()=>{l(),s();}),f=this.bus.on("feedback:error",d=>{l(),a(d);}),h=this.bus.on("submission:cancelled",()=>{l(),a(new Error("Feedback submission cancelled"));});this.rejectPendingSubmission=d=>{l(),a(d);},this.bus.emit("annotation:complete",{annotation:e,type:n.type,message:n.message,clientId:o.clientId,screenshotDataUrl:r?.dataUrl??null,screenshotRegion:r?.region??null});});}buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=oi(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Ft(n),o=n.getBoundingClientRect(),r=si(e,o);return {annotation:{anchor:i,rect:r,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},anchorBounds:o}}destroy(){this.deactivate(),this.unregisterEscapeLayer(),this.rejectPendingSubmission?.(new Error("Annotator destroyed during submission")),this.popup.destroy();}};function Ge(t,e){let n=`siteping_own_feedback:${JSON.stringify([t,e??null])}`,i=()=>{try{let r=JSON.parse(localStorage.getItem(n)??"[]");return new Set(Array.isArray(r)?r.filter(s=>typeof s=="string"):[])}catch{return new Set}},o=r=>{try{r.size>0?localStorage.setItem(n,JSON.stringify([...r].slice(-500))):localStorage.removeItem(n);}catch{}};return {ids:i,add(r){let s=i();s.delete(r),o(s.add(r));},remove(...r){let s=i(),a=s.size;for(let l of r)s.delete(l);s.size<a&&o(s);},clear:()=>o(new Set)}}var hi=3,Se=1e4,_o=1e4,No=6e4,ie="siteping_retry_queue",Fo=20;function zt(t,e,n){let i,o=new Promise((r,s)=>{i=setTimeout(()=>s(n()),e);});return Promise.race([t,o]).finally(()=>clearTimeout(i))}async function vi(t$1,e){let n={};e&&(n["Content-Type"]="application/json"),t$1.apiKey&&(n.Authorization=`Bearer ${t$1.apiKey}`);let i=typeof t$1.headers=="function"?await zt(Promise.resolve(t$1.headers()),Se,()=>new Error(`headers factory did not settle within ${Se/1e3} s`)):t$1.headers;return t(n,i)}async function de(t,e,n,i,{boundBody:o=false,timeoutMs:r=Se,resendOnTimeout:s=true}={}){for(let a=0;;a++){let l=new AbortController,c=setTimeout(()=>l.abort(),r),p;try{let f=await fetch(t,{...e,signal:l.signal}).catch(h=>{if(a===hi||!s&&l.signal.aborted)throw x(h,n);return null});if(p=Oo(f,a),f&&(!xi(f.status)||a===hi||p>_o)){if(clearTimeout(c),o&&(c=setTimeout(()=>l.abort(),Se)),!f.ok)throw await v(f,n);return await i(f).catch(h=>{throw x(h,n)})}}finally{clearTimeout(c);}await new Promise(f=>setTimeout(f,p));}}function Oo(t,e){let n=t?.headers.get("Retry-After"),i=n?/^\d+$/.test(n)?Number(n)*1e3:Date.parse(n)-Date.now():Number.NaN;return Number.isNaN(i)?1e3*2**e+Math.random()*1e3-500:Math.max(0,i)}function Ho(t){return t instanceof d||t instanceof c&&t.code==="SERVER"}function xi(t){return t>=500||t===408||t===429}var Do="siteping_retry_queue";async function Kt(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(Do,()=>t()):t()}function $o(t){if(!b(t,"endpoint")||typeof t.endpoint!="string"||!b(t,"payload"))return false;let{payload:e}=t;return b(e,"authorName")&&typeof e.authorName=="string"&&b(e,"authorEmail")&&typeof e.authorEmail=="string"}function Wt(){let t=localStorage.getItem(ie);if(!t)return [];let e;try{e=JSON.parse(t);}catch{return localStorage.removeItem(ie),console.warn(`[siteping] discarded an unreadable retry queue from localStorage (${t.length} chars)`),[]}return Array.isArray(e)?e.filter($o):[]}var wi=new WeakMap;function Ei(t){return typeof t=="object"&&t!==null?wi.get(t):void 0}function Bo(t,e){return Kt(()=>{try{let n=Wt().filter(r=>r.payload.clientId!==e.clientId);if(n.length>=Fo&&n.shift(),n.push({endpoint:t,payload:e}),Bt(n))return !0;let i=n.slice(),o=0;for(let[r,s]of i.entries())if(fi(s)&&(i[r]=Ko(s),o+=1,Bt(i)))return console.warn(`[siteping] retry queue exceeded the localStorage quota \u2014 dropped the screenshot of ${o} of ${n.length} queued feedback(s)`),!0;for(;i.length>1;)if(i.shift(),Bt(i)){let r=n.length-i.length,s=n.slice(r).filter(fi).length;return console.warn(`[siteping] retry queue exceeded the localStorage quota \u2014 dropped the ${r} oldest of ${n.length} queued feedback(s)${s>0?`, and the screenshot of ${s} of the rest`:""}`),!0}console.warn("[siteping] feedback could not be queued for retry \u2014 localStorage is full or unavailable");}catch{}return false}).catch(()=>false)}function zo(t){Kt(()=>{try{let e=Wt(),n=e.filter(i=>i.payload.clientId!==t);if(n.length===e.length)return;n.length>0?localStorage.setItem(ie,JSON.stringify(n)):localStorage.removeItem(ie);}catch{}});}function Bt(t){try{return localStorage.setItem(ie,JSON.stringify(t)),!0}catch{return false}}function fi(t){return t.payload.screenshotDataUrl!=null}function Ko(t){let{screenshotDataUrl:e,screenshotRegion:n,...i}=t.payload;return {endpoint:t.endpoint,payload:i}}function mi(t){return t.trim()}function gi(t){return t.trim().toLowerCase()}async function ki(t,e,n={}){await Kt(async()=>{try{let i=Wt();if(i.length===0)return;let o=[],r=[],s=0;for(let p of i){if(p.endpoint!==t){r.push(p);continue}!e||mi(p.payload.authorName)===mi(e.name)&&gi(p.payload.authorEmail)===gi(e.email)?o.push(p):s+=1;}if(o.length===0&&s===0)return;s>0;let a=[],l=0;if(o.length>0){let p=await vi(n,!0);for(let f of o){let h=new AbortController,d=setTimeout(()=>h.abort(),Se);try{let g=await fetch(t,{method:"POST",headers:p,body:JSON.stringify(f.payload),signal:h.signal});if(g.ok){let v=await g.json().catch(()=>null);b(v,"id")&&typeof v.id=="string"&&Ge(f.payload.projectName,t).add(v.id);continue}xi(g.status)?a.push(f):l+=1;}catch{a.push(f);}finally{clearTimeout(d);}}}l>0&&console.warn(`[siteping] flushRetryQueue: dropped ${l} queued feedback(s) the server rejected (4xx) \u2014 they would fail identically on every replay`);let c=r.concat(a);c.length>0?localStorage.setItem(ie,JSON.stringify(c)):localStorage.removeItem(ie);}catch{}});}function bi(t,e){let n=Math.min(1,Math.max(0,t)),i=e-(n-t);return [n,Math.max(0,n+i<=1?i:1-n)]}function Wo(t){let[e,n]=bi(t.rect.xPct,t.rect.wPct),[i,o]=bi(t.rect.yPct,t.rect.hPct);return {...t,rect:{xPct:e,yPct:i,wPct:n,hPct:o}}}async function Qe(t){return await t.json()}async function yi(){}var Je=class{constructor(e,n,i={}){this.endpoint=e;this.projectName=n;this.auth=i;}endpoint;projectName;auth;listRefusalExplained=false;async headers(e,n){try{return await vi(this.auth,e)}catch(i){throw x(i,n)}}async sendFeedback(e){let n="Failed to send feedback",{screenshotRegion:i,...o}=e,r={...o,annotations:o.annotations.map(Wo)},s=i?{...r,screenshotRegion:i}:r;try{let a=await de(this.endpoint,{method:"POST",headers:await this.headers(!0,n),body:JSON.stringify(s)},n,Qe,{boundBody:!0});return zo(s.clientId),a}catch(a){throw Ho(a)&&wi.set(a,await Bo(this.endpoint,s)),a}}async getFeedbacks(e$1,n){let i="Failed to fetch feedbacks",o=s({projectName:e$1,...n}),r=await this.headers(false,i);return de(u(this.endpoint,o),{method:"GET",cache:"no-store",...Object.keys(r).length>0?{headers:r}:{}},i,Qe).catch(s=>{throw s instanceof e&&!this.listRefusalExplained&&(this.listRefusalExplained=true,console.warn(`[siteping] Feedback list refused (${s.status}): with an apiKey, GET needs it unless publicEndpoints includes "GET"; pins and panel stay empty. https://siteping.dev/docs/server#the-security-model-honestly`)),s})}async addComment(e,n){let i="Failed to post comment";return de(this.endpoint,{method:"POST",headers:await this.headers(true,i),body:JSON.stringify({...n,projectName:this.projectName,feedbackId:e})},i,Qe,{boundBody:true})}async resolveFeedback(e,n){let i="Failed to update feedback";return de(this.endpoint,{method:"PATCH",headers:await this.headers(true,i),body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})},i,Qe)}async deleteFeedback(e){let n="Failed to delete feedback";await de(this.endpoint,{method:"DELETE",headers:await this.headers(true,n),body:JSON.stringify({id:e,projectName:this.projectName})},n,yi);}async deleteAllFeedbacks(e){let n="Failed to delete all feedbacks";await de(this.endpoint,{method:"DELETE",headers:await this.headers(true,n),body:JSON.stringify({projectName:e,deleteAll:true})},n,yi,{timeoutMs:No,resendOnTimeout:false});}};function Ze(t,e){if(t.length<=e)return t;let n=e-1,i=t.charCodeAt(n-1);return i>=55296&&i<=56319&&(n-=1),`${t.slice(0,n)}\u2026`}var Xt=50,jt=500,Xo=["log","info","warn","error"];function jo(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?`
|
|
2
|
+
${t.stack}`:""}`;try{let e=[],n=jt;return JSON.stringify(t,function(i,o){if(!(--n<0)){if(typeof o=="function")return "[Function]";if(typeof o=="symbol")return o.toString();if(typeof o!="object"||o===null)return o;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(o)?"[Circular]":(e.push(o),o)}})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function qo(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=jo(t[n]),!(e.length>=jt));n++);return Ze(e,jt)}var et=class{maxEntries;entries=[];originals=new Map;wrappers=new Map;disposed=false;constructor(e=Xt){if(this.maxEntries=Number.isFinite(e)&&e>=0?Math.min(Math.floor(e),Xt):Xt,!(typeof console>"u"))for(let n of Xo){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{}this.wrappers.set(n,r),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:qo(n)}));}getEntries(){return this.entries.slice()}dispose(){if(this.disposed||(this.disposed=true,typeof console>"u"))return;let e=console;for(let[n,i]of this.originals)if(e[n]===this.wrappers.get(n))try{e[n]=i;}catch{}this.originals.clear(),this.wrappers.clear();}};var qt=20,Uo=2e3,Yo=20,Vo=6e5,Go=599;function Si(t){let e=Qo(Jo(t)),n=e.search(/[?#]/);return Ze(n===-1?e:e.slice(0,n),Uo)}function Qo(t){try{let e=new URL(t,typeof location>"u"?void 0:location.href);return !e.username&&!e.password?t:(e.username="",e.password="",e.href)}catch{return t}}function Jo(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 tt=class{maxEntries;entries=[];originalFetch=null;originalXhrOpen=null;originalXhrSend=null;wrappedFetch=null;wrappedXhrOpen=null;wrappedXhrSend=null;disposed=false;constructor(e=qt){this.maxEntries=Number.isFinite(e)&&e>=0?Math.min(Math.floor(e),qt):qt,this.installFetch(),this.installXhr();}push(e){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({...e,method:e.method.slice(0,Yo),status:e.status<=Go?e.status:0,durationMs:Math.min(Math.max(e.durationMs,0),Vo)}));}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=Si(i),l=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,o);if(!c.ok){let p=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:c.status,durationMs:Math.round(p-s),timestamp:r.toISOString()});}return c}catch(c){let p=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(p-s),timestamp:r.toISOString()}),c}};this.wrappedFetch=n,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,s=function(l,c,...p){try{r.set(this,{method:l.toUpperCase(),url:Si(c),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,l,c,...p)},a=function(l){let c=r.get(this);if(c){let p=()=>{try{let f=typeof performance<"u"?performance.now():Date.now(),h=this.status;(h===0||h>=400)&&o.push({url:c.url,method:c.method,status:h,durationMs:Math.round(f-c.t0),timestamp:c.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",p,{once:!0});}catch{try{this.addEventListener("loadend",p);}catch{}}}return i.call(this,l??null)};this.wrappedXhrOpen=s,this.wrappedXhrSend=a,e.open=s,e.send=a;}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&globalThis.fetch===this.wrappedFetch)try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{let e=XMLHttpRequest.prototype;this.originalXhrOpen&&e.open===this.wrappedXhrOpen&&(e.open=this.originalXhrOpen),this.originalXhrSend&&e.send===this.wrappedXhrSend&&(e.send=this.originalXhrSend);}catch{}}}};var Te=class{listeners=new Map;on(e,n){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(n),()=>{i?.delete(n);}}off(e,n){this.listeners.get(e)?.delete(n);}emit(e,...n){let i=this.listeners.get(e);if(i)for(let o of i)try{o(...n);}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var Zo=54,es=60,ts={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},nt=class{constructor(e,n,i,o){this.bus=i;this.t=o;let r=n.position??"bottom-right";this.items=[{id:"chat",icon:ia},{id:"annotate",icon:ja}],n.showAnnotationsToggle!==false&&this.items.push({id:"toggle-annotations",icon:U,iconAlt:V}),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(D(T)),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"),I(this.radialContainer,true);for(let l=0;l<this.items.length;l++){let c=this.items[l];if(!c)continue;let p=document.createElement("button");p.className="sp-radial-item",p.style.setProperty("--sp-i",String(l)),p.appendChild(D(c.icon)),p.setAttribute("role","menuitem"),p.dataset.itemId=c.id,p.addEventListener("click",h=>{h.stopPropagation(),this.handleItemClick(c.id);});let f=document.createElement("span");f.className="sp-radial-label",p.appendChild(f),this.radialContainer.appendChild(p);}this.scrim=document.createElement("div"),this.scrim.className="sp-scrim",this.scrim.addEventListener("click",()=>this.close()),this.root=document.createElement("div"),this.root.appendChild(this.scrim),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root),this.applyLabels();let s=e.host;this.onDocumentClick=l=>{this.isOpen&&!l.composedPath().includes(s)&&this.close();},document.addEventListener("click",this.onDocumentClick,true);let a=l=>{l.key==="Escape"&&this.isOpen&&(l.stopPropagation(),this.close());};this.fab.addEventListener("keydown",a),this.radialContainer.addEventListener("keydown",a),Q(this.root,()=>this.isOpen),this.radialContainer.addEventListener("keydown",l=>{let c=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(c.length===0||!this.isOpen)return;let p=e.activeElement??document.activeElement,f=c.indexOf(p);switch(l.key){case "ArrowUp":{l.preventDefault();let h=f<=0?c.length-1:f-1;c[h]?.focus();break}case "ArrowDown":{l.preventDefault();let h=f>=c.length-1?0:f+1;c[h]?.focus();break}case "Home":{l.preventDefault(),c[0]?.focus();break}case "End":{l.preventDefault(),c[c.length-1]?.focus();break}}});}bus;t;root;scrim;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;refreshLabels(){this.applyLabels();}applyLabels(){this.applyFabLabel();let e=this.radialContainer.querySelectorAll(".sp-radial-item");for(let n of e){let i=n.dataset.itemId;if(!i)continue;let o=ts[i];if(!o)continue;let r=this.t(o);n.setAttribute("aria-label",r);let s=n.querySelector(".sp-radial-label");s&&F(s,r);}}applyFabLabel(){let e=this.t("fab.aria"),n=this.badgeEl?.textContent;this.fab.setAttribute("aria-label",n?`${e}, ${Aa(this.t,"fab.badge",{count:n})}`:e);}updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null,this.applyFabLabel();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);F(this.badgeEl,n),this.badgeEl.setAttribute("aria-label",Aa(this.t,"fab.badge",{count:e})),this.applyFabLabel();}toggle(){this.isOpen?this.close():this.open();}open(){this.isOpen=true,this.setFabIcon(W),this.fab.setAttribute("aria-expanded","true"),this.scrim.classList.add("sp-scrim--open"),I(this.radialContainer,false);let e=ta()?es:Zo;this.radialContainer.querySelectorAll(".sp-radial-item").forEach((i,o)=>{let r=-(16+e*(o+1));i.style.transform=`translate(0px, ${r}px) scale(1)`,i.classList.add("sp-radial-item--open");}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus();});}close(){this.isOpen=false,this.setFabIcon(T),this.fab.setAttribute("aria-expanded","false"),this.scrim.classList.remove("sp-scrim--open"),I(this.radialContainer,true),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){this.fab.querySelector("svg")?.replaceWith(D(e));}handleItemClick(e){switch(this.close(),e){case "chat":this.bus.emit("panel:toggle",true);break;case "annotate":{let n=this.bus.on("annotation:end",()=>{n(),this.fab.focus();});this.bus.emit("annotation:start");break}case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let i=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]')?.querySelector("svg");if(i){let o=D(this.annotationsVisible?U:V);i.replaceWith(o);}break}}}destroy(){document.removeEventListener("click",this.onDocumentClick,true),this.root.remove();}};var Ti="siteping_identity";function ns(t){if(!b(t,"name")||!b(t,"email"))return false;let{name:e,email:n}=t;return typeof e=="string"&&typeof n=="string"&&e.length>0&&e.length<=h&&n.length<=h&&a(n)}function Ut(){try{let t=localStorage.getItem(Ti);if(!t)return null;let e=JSON.parse(t);return ns(e)?e:null}catch{return null}}function Ci(t){try{localStorage.setItem(Ti,JSON.stringify(t));}catch{}}function oe(t){return t.normalize("NFC").replace(/\s+/g," ").trim()}function Ri(t){return t.replace(/\s+/g," ").trim()}function is(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let s=t;t=e,e=s;}let n=t.length,i=e.length,o=new Array(n+1);for(let s=0;s<=n;s++)o[s]=s;let r=new Array(n+1);for(let s=1;s<=i;s++){r[0]=s;for(let l=1;l<=n;l++){let c=o[l-1];r[l]=t[l-1]===e[s-1]?c:1+Math.min(c,o[l],r[l-1]);}let a=o;o=r,r=a;}return o[n]}function Ce(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-is(t,e)/n}function os(t,e){let n=e.length,i=new Int32Array(n+1),o=new Int32Array(n+1);for(let s=0;s<=n;s++)i[s]=s;let r=n;for(let s=1;s<=t.length;s++){o[0]=0;let a=t.charCodeAt(s-1);for(let p=1;p<=n;p++){let f=i[p-1]+(e.charCodeAt(p-1)===a?0:1),h=i[p]+1,d=o[p-1]+1;o[p]=Math.min(f,h,d);}let l=o[n];l<r&&(r=l);let c=i;i=o,o=c;}return r}function Yt(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=t.length>500?t.slice(0,500):t;if(e.length>i.length){let r=Ce(i,e);return r>=n?r:0}if(e.length<8&&i.length>64)return 0;let o=1-os(i,e)/e.length;return o>=n?o:0}function Ai(t){let e=new Map;for(let n=0;n<t.length-1;n++){let i=t.charCodeAt(n)<<16|t.charCodeAt(n+1);e.set(i,(e.get(i)??0)+1);}return e}function Pi(t,e,n){let i=n.length-1;if(e<=0||i<=0)return 0;let o=0,r=new Map;for(let s=0;s<n.length-1;s++){let a=n.charCodeAt(s)<<16|n.charCodeAt(s+1),l=t.get(a);if(l===void 0)continue;let c=r.get(a)??0;c<l&&(r.set(a,c+1),o++);}return 2*o/(e+i)}function Mi(t){let e=new Map,n=t.split(" ");for(let i=0;i<n.length-1;i++){let o=`${n[i]} ${n[i+1]}`;e.set(o,(e.get(o)??0)+1);}return e}function Ii(t,e,n){if(e<=0)return 0;let i=n.split(" "),o=i.length-1;if(o<=0)return 0;let r=0,s=new Map;for(let a=0;a<i.length-1;a++){let l=`${i[a]} ${i[a+1]}`,c=t.get(l);if(c===void 0)continue;let p=s.get(l)??0;p<c&&(s.set(l,p+1),r++);}return 2*r/(e+o)}var ss={checkOpacity:true,opacityProperty:true,checkVisibilityCSS:true,visibilityProperty:true};function Re(t){if(!t.isConnected)return "hidden";if(typeof t.checkVisibility=="function")return t.checkVisibility(ss)?"visible":t.checkVisibility()?"soft-hidden":"hidden";if(t.getClientRects().length>0)try{return getComputedStyle(t).visibility==="visible"?"visible":"soft-hidden"}catch{return "visible"}let e=t.firstElementChild;return e&&e.getClientRects().length>0?"visible":t.ownerDocument.documentElement.getClientRects().length===0?"unknown":"hidden"}function Li(t){switch(t){case "hidden":return .3;case "soft-hidden":return .6;default:return 1}}var ue={anchorKey:1,id:1,css:.95,xpath:.9,scan:.85},Qt=16,rs=24,_i=1e4,st=500,as=.5,Vt=.6,ls=.4,cs=2e3,Jt=.8,Gt=.6,ps=.05;function it(t,e){return oe((t??"").slice(0,cs)).slice(0,e)}function ds(t){let e=it(t.textSnippet,st),n=Mi(e),i=0;for(let o of n.values())i+=o;return {snippet:e,snippetBigrams:Ai(e),snippetBigramTotal:Math.max(0,e.length-1),snippetWordPairs:n,snippetWordPairTotal:i,prefix:it(t.textPrefix,128),suffix:it(t.textSuffix,128),neighbor:it(t.neighborText,128),fingerprint:(t.fingerprint??"").slice(0,64),tag:typeof t.elementTag=="string"?t.elementTag:""}}function us(t,e){let n=ds(t),{pool:i,treeRoots:o}=fs(t),r=[];for(let[h,d]of i){let g=Ni(h,d,n);g&&r.push(g);}let s=0,a=false;for(let h of r)h.final>s&&(s=h.final),(h.strategy==="id"||h.strategy==="anchorKey")&&h.visibility===1&&(h.signals?.text??0)>=Jt&&(h.signals?.fingerprint===void 0||h.signals.fingerprint>=Jt)&&(a=true);let l=!!(n.snippet||n.fingerprint||n.prefix||n.suffix||n.neighbor),c=e?.scanBudget;if(l&&o.length>0&&s<ue.scan&&!a)if(c&&c.remaining<=0)c.starved=true;else {c&&c.remaining--;for(let h of ms(n,i,o)){let d=Ni(h,"scan",n);d&&r.push(d);}}let p=r.filter(gs);if(p.length===0)return null;p.sort((h,d)=>d.final-h.final);let f=ys(p);return {element:f.element,confidence:vs(f),strategy:f.strategy}}function ot(t,e){let n=[];for(let i of t){let o=i.querySelectorAll(e);for(let r=0;r<o.length&&n.length<Qt;r++){let s=o[r];s&&n.push(s);}if(n.length===Qt)break}return n}function hs(t){let e=[],n=[document];for(let i of t){let o;try{o=ot(n,i);}catch{return []}let r=[];for(let s of o)s.shadowRoot&&r.push(s.shadowRoot);if(r.length===0)return [];e.push(r),n=r;}return e}function fs(t){let e=new Map,n=(l,c,p)=>{!l||e.has(l)||p&&l.tagName!==t.elementTag||e.set(l,c);},i=typeof t.cssSelector=="string"?t.cssSelector.split(Nt):[],o=i[i.length-1]??t.cssSelector,r=i.length>1?hs(i.slice(0,-1)):null,s=r?r[r.length-1]??[]:[document],a=r?[document,...r.flat()]:s;if(t.anchorKey){let l=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{for(let c of ot(a,`[${we}="${l}"]`))n(c,"anchorKey",!1);}catch{}}if(t.elementId){let l=t.elementId.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{for(let c of ot(s,`[id="${l}"]`))n(c,"id",!0);}catch{for(let c of s)n(c.getElementById(t.elementId),"id",true);}}try{for(let l of ot(s,o))n(l,"css",!0);}catch{}if(r)return {pool:e,treeRoots:s};try{let l=document.evaluate(t.xpath,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),c=Math.min(l.snapshotLength,Qt);for(let p=0;p<c;p++){let f=l.snapshotItem(p);f instanceof Element&&n(f,"xpath",!0);}}catch{}return {pool:e,treeRoots:s}}function ms(t,e,n){let i=t.tag.toLowerCase();if(!i)return [];let o=[];try{for(let c of n){let p=c.querySelectorAll(i);for(let f=0;f<p.length&&o.length<_i;f++){let h=p[f];h&&o.push(h);}if(o.length===_i)break}}catch{return []}let r=t.fingerprint.split(":"),s=r.length===3?Number(r[0]):Number.NaN,a=r.length===3?r[2]??"":"",l=[];for(let c of o){if(e.has(c))continue;let p=0;if(t.snippetBigramTotal>0){let f=Ri(j(c,st)),h=Pi(t.snippetBigrams,t.snippetBigramTotal,f);if(t.snippetWordPairTotal>0){let d=h>0?Ii(t.snippetWordPairs,t.snippetWordPairTotal,f):0;p+=.6*(.5*h+.5*d);}else p+=.6*h;}if(a&&It(c)===a&&(p+=.25),!Number.isNaN(s)){let f=Math.abs(c.children.length-s);f===0?p+=.15:f<=2&&(p+=.07);}l.push({element:c,cheap:p});}return l.sort((c,p)=>p.cheap-c.cheap),l.slice(0,rs).map(c=>c.element)}function Ni(t,e,n){let i=bs(t,n),o=Li(Re(t));return i===null?e==="scan"?null:{element:t,strategy:e,verification:Gt,strongest:Gt,visibility:o,final:ue[e]*Gt*o,unverified:true}:{element:t,strategy:e,verification:i.blend,strongest:i.strongest,signals:i,visibility:o,final:ue[e]*i.blend*o}}function gs(t){if(t.strategy==="scan")return t.verification>=ls;if(t.unverified||!t.signals)return true;let e=t.signals;return e.text===void 0||e.text>=as?true:(e.fingerprint??0)>=Vt||(e.context??0)>=Vt||(e.neighbor??0)>=Vt}function bs(t,e){let n=0,i=0,o={blend:0,strongest:0};if(e.snippet){i+=40;let r=j(t,st,true);if(o.text=Yt(oe(r),e.snippet,.5),o.text<1){let s=j(t,st);s!==r&&(o.text=Math.max(o.text,Yt(oe(s),e.snippet,.5)));}n+=o.text*40;}if(e.fingerprint&&(i+=20,o.fingerprint=Qn(t,e.fingerprint),n+=o.fingerprint*20),e.prefix||e.suffix){i+=20;let r=0,s=0;if(e.prefix){let a=oe(ce(t,"before"));r+=a?Ce(a,e.prefix):0,s++;}if(e.suffix){let a=oe(ce(t,"after"));r+=a?Ce(a,e.suffix):0,s++;}s>0&&(o.context=r/s,n+=o.context*20);}if(e.neighbor){i+=20;let r=oe(qe(t));o.neighbor=r?Ce(r,e.neighbor):0,n+=o.neighbor*20;}return i===0?null:(o.blend=n/i,o.strongest=Math.max(o.text??0,o.fingerprint??0,o.context??0,o.neighbor??0),o)}function ys(t){let e=t[0],n=t.filter(o=>e.final-o.final<=ps&&(o===e||e.element.contains(o.element))),i=e;for(let o of n)o!==i&&i.element.contains(o.element)&&(i=o);return i}function vs(t){return t.strategy==="scan"?Math.min(t.verification,ue.scan):t.unverified?ue[t.strategy]:ue[t.strategy]*Math.min(1,t.strongest/Jt)}function rt(t,e,n){let i=us(t,n);if(!i)return null;let o=i.element.getBoundingClientRect(),r=new DOMRect(o.x+e.xPct*o.width,o.y+e.yPct*o.height,e.wPct*o.width,e.hPct*o.height);return {element:i.element,rect:r,confidence:i.confidence,strategy:i.strategy}}function Zt(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 at(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var Fi=13,xs=26,ji=9,Oi="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.22)",Hi="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.28)",Di={question:"#2563eb",change:"#b45309",bug:"#d01f1f",other:"#5b6778"},ws={light:{bg:"rgba(255, 255, 255, 0.94)",ring:"#ffffff",check:"#636366",slash:"#8e8e93"},dark:{bg:"rgba(44, 44, 46, 0.94)",ring:"#48484a",check:"#c7c7cc",slash:"#aeaeb2"}},Es="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.14)",ks="0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.18)";function Ss(t,e,n){let i=n.scheme==="dark";if(k(t)){let r=ws[n.scheme];return {bg:r.bg,ring:r.ring,color:t==="wont_fix"?r.slash:r.check,shadow:Es,hoverShadow:ks}}let o=ma(e,n);if(t==="in_progress"){let{row:r}=n.surface,s=`color-mix(in srgb, ${o} 35%, ${r})`;return {bg:`color-mix(in srgb, ${o} ${i?18:14}%, ${r})`,ring:`${o} ${o} ${s} ${s}`,color:i?o:`color-mix(in srgb, ${o} 80%, #000000)`,shadow:Oi,hoverShadow:Hi}}return {bg:i?Di[e]??Di.other??o:o,ring:"#ffffff",color:"#ffffff",shadow:Oi,hoverShadow:Hi}}function $i(t){let e=document.documentElement.clientWidth,n=xs+(ta()?ji:0),i=t.right-Fi;return t.right<=e&&(i=Math.min(i,e-n)),{top:Math.max(0,t.top+window.scrollY-Fi),left:Math.max(0,i)+window.scrollX}}var en=t=>t.width>0||t.height>0;function he(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}function Bi(t){let e=t.elementIndices[0];return e===void 0?void 0:t.entries[0]?.positions[e]}var zi=t=>t.style.display!=="none";function tn(t,e,n){!va()&&typeof t.animate=="function"&&t.animate(e,n);}var Ki=200,Wi=200,Ts=3e3,Cs=.7,Rs=28,Xi=32,lt=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=E("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",O(this.container),document.body.appendChild(this.container),this.bus.on("annotations:toggle",s=>{this.container.style.display=s?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition("resize"),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition("scroll"),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("mutation");}),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,true);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;pendingLayoutChange=false;pendingResize=false;hiddenRecheckAt=new Map;clusters=[];onDocumentClickForClusters=null;lastOpenCount=-1;get count(){return this.entries.length}get openCount(){let e=0;for(let n of this.entries)k(n.feedback.status)||e++;return e}scheduleReposition(e="mutation"){e!=="scroll"&&(this.pendingLayoutChange=true),e==="resize"&&(this.pendingResize=true),!this.repositionTimer&&("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:Wi+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},Wi));}repositionAll(){let e=this.pendingLayoutChange,n=this.pendingResize;this.pendingLayoutChange=false,this.pendingResize=false,n&&this.hiddenRecheckAt.clear();let i=Date.now(),o={remaining:2,starved:false},r=new Set,s=false;for(let a of this.entries)for(let l=0;l<a.feedback.annotations.length;l++){let c=a.elements[l];if(!c)continue;let p=a.feedback.annotations[l];if(!p)continue;let f=`${a.feedback.id}:${l}`;r.add(f);let h=this.anchorCache.get(f),d=h?.ref.deref(),g,v=(this.hiddenRecheckAt.get(f)??0)>i,k=d?.isConnected&&(v||!(e&&Re(d)==="hidden"));if(h&&d&&k){let S=d.getBoundingClientRect(),w=at(p);g={element:d,rect:new DOMRect(S.left+w.xPct*S.width,S.top+w.yPct*S.height,w.wPct*S.width,w.hPct*S.height),confidence:h.confidence,strategy:h.strategy};}else if(v)g=null;else if(o.starved=false,g=rt(Zt(p),at(p),{scanBudget:o}),!o.starved){if(g?.element){let{confidence:S,strategy:w}=g;this.anchorCache.set(f,{ref:new WeakRef(g.element),confidence:S,strategy:w});}!g||Re(g.element)==="hidden"?this.hiddenRecheckAt.set(f,i+Ts):this.hiddenRecheckAt.delete(f);}let H=c.style.display!=="none";if(!g||!en(g.rect)){H&&(s=true),c.style.display="none";continue}H||(s=true),a.positions[l]=$i(g.rect),c.style.display="flex",this.applyConfidenceStyle(c,g.confidence,a.feedback);}for(let a of this.anchorCache.keys())r.has(a)||this.anchorCache.delete(a);for(let a of this.hiddenRecheckAt.keys())r.has(a)||this.hiddenRecheckAt.delete(a);s&&(this.buildClusters(),this.bus.emit("markers:placed")),this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback,false);}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((i,o)=>{let r=this.buildEntry(i,o+1);this.entries.push(r);}),this.buildClusters();let n=this.entries.filter(i=>i.elements.some(zi)).length;this.liveRegion&&n>0&&(this.liveRegion.textContent=Aa(this.t,"marker.count",{count:n})),this.emitMarkersChanged(),this.bus.emit("markers:placed");}addFeedback(e,n){let i=this.buildEntry(e,n);for(let o of i.elements)tn(o,[{scale:.9,opacity:0},{scale:1,opacity:1}],{duration:250,easing:z});this.entries.push(i),this.buildClusters(),this.emitMarkersChanged(),this.bus.emit("markers:placed");}buildEntry(e,n){let i={feedback:e,elements:[],positions:[]};for(let o of e.annotations){let r=rt(Zt(o),at(o)),s=r&&en(r.rect)?r:null,a=s?$i(s.rect):{top:0,left:0},l=this.createMarker(n,e,a);s?this.applyConfidenceStyle(l,s.confidence,e):l.style.display="none",this.container.appendChild(l),i.elements.push(l),i.positions.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++){let r=i.positions[o];!r||i.elements[o]?.style.display==="none"||e.push({entry:i,elIdx:o,pos:r});}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.pos,l=e[s];if(!l)continue;let c=l.pos;Math.sqrt((a.left-c.left)**2+(a.top-c.top)**2)<Rs&&(r.entries.push(l.entry),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=Bi(e);if(!n)return;let{top:i,left:o}=n,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=he(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=Bi(e);if(!n)return;let{top:i,left:o}=n,r=e.entries.length,s=(r-1)*Xi,a=o-s/2;for(let l=0;l<r;l++){let c=he(e,l);c&&(c.style.top=`${i}px`,c.style.left=`${a+l*Xi}px`,c.style.zIndex=String(10+l));}}addClusterBadge(e){let n=he(e,e.entries.length-1);if(!n)return;let i=E("div",{class:"sp-cluster-badge",style:`position:absolute;top:-6px;right:-6px;min-width:16px;height:16px;padding:0 4px;border-radius:9999px;background:#1d1d1f;color:#fff;font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center;border:1.5px solid #fff;pointer-events:none;font-family:${qa};line-height:1;`});F(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=he(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(he(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.glide(i,()=>this.applyFanPositions(i)),this.setBadgesVisible(i,false),true):false}collapseCluster(e){e.expanded&&(e.expanded=false,this.glide(e,()=>this.applyStackPositions(e)),this.setBadgesVisible(e,true));}glide(e,n){let i=e.entries.map((r,s)=>he(e,s)),o=i.map(r=>r&&{top:parseFloat(r.style.top),left:parseFloat(r.style.left)});n(),i.forEach((r,s)=>{let a=o[s];if(!r||!a)return;let l=a.left-parseFloat(r.style.left),c=a.top-parseFloat(r.style.top);(l||c)&&tn(r,[{translate:`${l}px ${c}px`},{translate:"0 0"}],{duration:200,easing:z});});}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e);}applyConfidenceStyle(e,n,i){let o=k(i.status);n<Cs&&!o?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=Aa(this.t,"marker.approximate",{confidence:Math.round(n*100)})):(e.style.borderStyle="solid",e.style.opacity="1",e.title="");}createMarker(e,n,i){let{status:o}=n,r=Ss(o,n.type,this.colors),s=E("div",{style:`position:absolute;top:${i.top}px;left:${i.left}px;width:26px;height:26px;border-radius:50%;background:${r.bg};border:2px solid;border-color:${r.ring};display:flex;align-items:center;justify-content:center;font-family:${qa};font-size:12px;font-weight:700;letter-spacing:-0.01em;color:${r.color};cursor:pointer;pointer-events:auto;box-shadow:${r.shadow};transition:${va()?"box-shadow 0.15s ease":`transform 0.15s ${z}, box-shadow 0.15s ease`};touch-action:manipulation;user-select:none;-webkit-font-smoothing:antialiased;`});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=Aa(this.t,"marker.aria",{number:e,type:Ba(n.type,this.t),status:Ca(o,this.t),message:a});s.setAttribute("aria-label",l),s.setAttribute("aria-describedby",this.tooltip.tooltipId),N(s,this.colors.accent),o==="wont_fix"?s.appendChild(E("span",{style:"width:2px;height:16px;border-radius:1px;background:currentColor;transform:rotate(45deg);"})):F(s,o==="resolved"?"\u2713":String(e)),ta()&&s.appendChild(E("span",{style:`position:absolute;inset:-${ji}px;border-radius:50%;`})),s.addEventListener("mouseenter",()=>{ua()&&(s.style.transform="scale(1.2)",s.style.boxShadow=r.hoverShadow),this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("mouseleave",()=>{s.style.transform="scale(1)",s.style.boxShadow=r.shadow,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),s.addEventListener("focus",()=>{this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let c=p=>{p instanceof MouseEvent&&this.handleClusterClick(s,p)||(sa()&&this.tooltip.hide(),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",p=>c(p)),s.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),c(p));}),s}focusFeedback(e){let n=this.entries.find(o=>o.feedback.id===e),i=n?.elements.find(zi);return !n||!i?false:(i.scrollIntoView({behavior:va()?"auto":"smooth",block:"center"}),this.pinHighlight(n.feedback),this.highlight(e),true)}revealPin(e){return this.container.style.display!=="none"&&this.focusFeedback(e)}isLost(e){let n=this.entries.filter(i=>i.feedback.id===e);return n.length>0&&n.every(i=>i.elements.every(o=>o.style.display==="none"))}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)tn(i,[{boxShadow:`0 0 0 0 ${this.colors.accentGlow}`},{boxShadow:"0 0 0 8px transparent",offset:.7},{boxShadow:"0 0 0 0 transparent"}],{duration:700,easing:"ease-out"});}showHighlight(e,n=true){this.removeHighlightElements();for(let i of e.annotations){let o=rt(Zt(i),at(i));if(!o||!en(o.rect))continue;let r=ma(e.type,this.colors),s=o.rect,a=E("div",{style:`position:absolute;top:${s.top+window.scrollY}px;left:${s.left+window.scrollX}px;width:${s.width}px;height:${s.height}px;border:2px solid ${r};background:${r}0c;border-radius:12px;pointer-events:none;z-index:-1;opacity:${n?0:1};box-shadow:0 0 16px ${r}20;transition:opacity ${Ki}ms ease;`});this.container.appendChild(a),this.highlightElements.push(a),n&&(a.offsetHeight,a.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(),Ki);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,true),this.mutationObserver?.disconnect(),this.container.remove();}};var qi=3e4,ct=class{constructor(e,n){this.store=e;this.projectName=n;}store;projectName;async sendFeedback(e){return nn(await Ui(this.write(e),"Failed to send feedback"))}async write(e){try{return 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(o),screenshotDataUrl:e.screenshotDataUrl??null,screenshotRegion:e.screenshotRegion??null,diagnostics:e.diagnostics??null})}catch(n$1){if(!n(n$1))throw n$1;let i=await this.store.findByClientId(e.clientId);if(!i||i.projectName!==e.projectName)throw n$1;return i}}async getFeedbacks(e,n){let{feedbacks:i,total:o}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,statuses:n?.statuses,search:n?.search,url:n?.url,urlPattern:n?.urlPattern});return {feedbacks:i.map(nn),total:o,capabilities:{comments:!!this.store.addComment}}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,l(n?"resolved":"open"));return nn(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}async addComment(e,n){let i="Failed to post comment";if(!this.store.addComment)throw new c(`${i}: this store keeps no comments`,"SERVER",false);return Yi(await Ui(this.store.addComment(e,n),i))}};function Ui(t,e){return zt(t,qi,()=>new c(`${e}: the store did not answer within ${qi/1e3} s`,"TIMEOUT",true))}function nn(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(As),comments:t.comments?.map(Yi),screenshotUrl:t.screenshotUrl??null,screenshotRegion:t.screenshotRegion??null,diagnostics:t.diagnostics??null}}function Yi({clientId:t,createdAt:e,...n}){return {...n,createdAt:e.toISOString()}}function As(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 Vi="@keyframes sp-fab-in{from{opacity:0;transform:scale(0.9);}}.sp-anim-fab-in{animation:sp-fab-in 0.2s var(--sp-ease-out) backwards;}@keyframes sp-flash-bg{from{background-color:var(--sp-accent-light);}}.sp-anim-flash{animation:sp-flash-bg 0.6s var(--sp-ease-out);}.sp-panel{transform:translateX(110%);transition:transform 0.2s var(--sp-ease-out);}.sp-panel.sp-panel--open{transform:translateX(0);transition:transform 0.3s var(--sp-ease-drawer);}.sp-radial-item{opacity:0;pointer-events:none;transform:translate(0,0) scale(0.9);transition:transform 0.2s var(--sp-ease-out),opacity 0.15s ease,background-color 0.15s ease,border-color 0.15s ease,box-shadow 0.15s ease,color 0.15s ease,scale 0.16s var(--sp-ease-out);}.sp-radial-item:active{scale:0.97;}.sp-radial-item.sp-radial-item--open{opacity:1;pointer-events:auto;transition-delay:calc(var(--sp-i, 0) * 30ms),calc(var(--sp-i, 0) * 30ms),0s,0s,0s,0s,0s;}@keyframes sp-spin{to{transform:rotate(360deg);}}.sp-spinner{width:20px;height:20px;border:2px solid var(--sp-fill-strong);border-top-color:var(--sp-text-secondary);border-radius:50%;animation:sp-spin 0.6s linear infinite;}@media (prefers-reduced-motion: reduce){*,*::before,*::after{animation-duration:0.01ms !important;animation-delay:0s !important;animation-iteration-count:1 !important;transition-property:opacity,color,background-color,border-color,box-shadow,outline-color !important;transition-delay:0s !important;}.sp-spinner{animation-duration:1.2s !important;animation-iteration-count:infinite !important;}}";var Gi=`:host{-webkit-tap-highlight-color:transparent;}.sp-list,.sp-detail-content{overscroll-behavior:contain;}.sp-scrim{display:none;}@media not all and (hover: hover) and (pointer: fine){.sp-radial-item--open .sp-radial-label{opacity:1;transform:translate(0,-50%);}.sp-bulk-checkbox{opacity:1;}.sp-bulk-checkbox::after{content:"";position:absolute;inset:-12px;}.sp-bulk-select-all{display:none;}.sp-list--has-selection .sp-bulk-select-all{display:flex;}.sp-shortcuts-hint{display:none;}}@media (pointer: coarse){.sp-radial-item{width:48px;height:48px;left:3px;bottom:3px;}.sp-radial-item svg{width:20px;height:20px;}.sp-radial-label{font-size:14px;padding:8px 14px;}.sp-search,.sp-input{font-size:16px;}.sp-search,.sp-filter-dropdown-btn,.sp-sort-btn,.sp-group-toggle,.sp-mine-toggle,.sp-segmented__btn,.sp-btn-resolve,.sp-btn-delete,.sp-bulk-btn-resolve,.sp-bulk-btn-delete,.sp-thread-foot .sp-btn-primary{height:40px;min-height:40px;}.sp-bulk-btn-deselect{width:40px;height:40px;}.sp-detail-back{width:44px;height:44px;}.sp-detail-actions button,.sp-detail-actions a,.sp-btn-primary,.sp-btn-ghost,.sp-btn-danger{height:44px;}.sp-export-option,.sp-filter-dropdown-option,.sp-sort-option,.sp-group-header{min-height:44px;}.sp-export-btn,.sp-btn-delete-all,.sp-bulk-select-all{min-height:40px;}.sp-panel-close::before{inset:5px;}.sp-card-expand{position:relative;}.sp-card-expand::after{content:"";position:absolute;inset:-8px -10px;}}@media (max-height: 600px){.sp-stats-bar{display:none;}}@media ${y}{.sp-fab--bottom-right,.sp-radial--bottom-right{right:calc(16px + env(safe-area-inset-right,0px));bottom:calc(16px + env(safe-area-inset-bottom,0px));}.sp-fab--bottom-left,.sp-radial--bottom-left{left:calc(16px + env(safe-area-inset-left,0px));bottom:calc(16px + env(safe-area-inset-bottom,0px));}.sp-scrim{display:block;position:fixed;inset:0;background:var(--sp-scrim);opacity:0;pointer-events:none;touch-action:none;transition:opacity 0.2s ease;}.sp-scrim--open{opacity:1;pointer-events:auto;}.sp-panel{top:auto;left:0;right:0;bottom:0;width:auto;max-width:none;height:calc(100vh - 48px);height:calc(100dvh - 40px - env(safe-area-inset-top,0px));border-radius:16px 16px 0 0;background:var(--sp-grouped);-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:var(--sp-shadow-sheet-up);transform:translateY(105%);}.sp-panel.sp-panel--open{transform:translateY(0);}.sp-panel-header,.sp-detail-header{position:relative;touch-action:none;}.sp-panel-header{padding:24px 8px 6px 20px;}.sp-detail-header{padding:22px 12px 4px 6px;}.sp-panel-header::before,.sp-detail-header::before{content:"";position:absolute;top:6px;left:50%;width:36px;height:5px;margin-left:-18px;border-radius:3px;background:var(--sp-grabber);}.sp-export-btn,.sp-btn-delete-all{width:40px;height:40px;padding:0;justify-content:center;border-radius:50%;background:transparent;}.sp-export-btn svg,.sp-btn-delete-all svg{width:19px;height:19px;}.sp-stats-bar{padding:2px 20px 10px;}.sp-filters{padding:2px 16px 8px;}.sp-stats-bar,.sp-filters{touch-action:pan-x;}.sp-search{height:40px;}.sp-filter-bar{flex-wrap:nowrap;overflow-x:auto;margin:0 -16px 8px;padding:0 16px 2px;scrollbar-width:none;}.sp-filter-bar::-webkit-scrollbar{display:none;}.sp-filter-dropdown{flex:0 0 auto;}.sp-filter-dropdown-btn{width:auto;}.sp-filter-dropdown-menu,.sp-sort-menu{position:fixed;top:auto;left:8px;right:8px;bottom:calc(8px + env(safe-area-inset-bottom,0px));min-width:0;padding:6px;border-radius:16px;background:var(--sp-row);-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:var(--sp-shadow-popover);z-index:30;transform-origin:bottom center;}.sp-filter-dropdown-option,.sp-sort-option{min-height:44px;font-size:16px;}.sp-list{padding:8px 16px calc(16px + env(safe-area-inset-bottom,0px));}.sp-bulk-bar{bottom:calc(12px + env(safe-area-inset-bottom,0px));}.sp-detail-section{padding:0 16px;}.sp-detail-content{padding-bottom:calc(20px + env(safe-area-inset-bottom,0px));}.sp-identity-backdrop{align-items:flex-end;}.sp-identity-modal{width:100%;max-width:none;margin-bottom:var(--sp-kb, 0px);padding:22px 20px calc(20px + env(safe-area-inset-bottom,0px));border-radius:16px 16px 0 0;background:var(--sp-grouped);-webkit-backdrop-filter:none;backdrop-filter:none;transform:translateY(100%);}.sp-identity-modal .sp-input{background:var(--sp-row);}.sp-identity-actions button{height:50px;}.sp-identity-actions .sp-btn-primary{flex:2;}}@media (prefers-reduced-transparency: reduce){*{-webkit-backdrop-filter:none !important;backdrop-filter:none !important;}}@media (prefers-contrast: more){.sp-card,.sp-detail-message,.sp-detail-meta,.sp-detail-annotation-info,.sp-detail-diag-toggle{box-shadow:inset 0 0 0 1px var(--sp-separator);}}`;function on(t){let e=t.scheme==="dark";return `:host{all:initial;position:fixed;z-index:${2147483647};font-family:var(--sp-font);font-size:14px;line-height:1.5;color:var(--sp-text);color-scheme:${t.scheme};-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;${ra(t)} --sp-ease-out: cubic-bezier(0.23, 1, 0.32, 1);--sp-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);--sp-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);--sp-tr: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.16s var(--sp-ease-out);--sp-backdrop: ${e?"rgba(0, 0, 0, 0.45)":"rgba(0, 0, 0, 0.2)"};--sp-identity-overlay: ${e?"rgba(0, 0, 0, 0.5)":"rgba(0, 0, 0, 0.2)"};--sp-scrim: ${e?"rgba(0, 0, 0, 0.55)":"rgba(0, 0, 0, 0.24)"};}*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}:focus-visible{outline:2px solid var(--sp-accent);outline-offset:2px;box-shadow:0 0 0 4px var(--sp-bg);}button,[role="button"],[role="tab"],[role="menuitem"],[role="option"]{touch-action:manipulation;-webkit-user-select:none;user-select:none;}:where(.sp-panel-close,.sp-filter-dropdown-btn,.sp-segmented__btn,.sp-btn-resolve,.sp-btn-delete,.sp-btn-delete-all,.sp-btn-danger,.sp-btn-primary,.sp-btn-ghost,.sp-sort-btn,.sp-group-toggle,.sp-mine-toggle,.sp-export-btn,.sp-bulk-btn-resolve,.sp-bulk-btn-delete,.sp-bulk-btn-deselect,.sp-detail-back,.sp-detail-btn-resolve,.sp-detail-btn-reopen,.sp-detail-btn-delete,.sp-detail-btn-custom,.sp-detail-btn-goto,.sp-shortcuts-close):not(:disabled):active{transform:scale(0.97);}.sp-fab{position:fixed;width:54px;height:54px;border-radius:var(--sp-radius-full);background:var(--sp-accent);color:#fff;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 1px 0 rgba(255,255,255,0.22),0 8px 24px color-mix(in srgb,var(--sp-accent) 36%,transparent),0 2px 6px rgba(0,0,0,0.12);transition:transform 0.16s var(--sp-ease-out),opacity 0.2s ease,box-shadow 0.2s ease;outline:none;touch-action:manipulation;-webkit-user-select:none;user-select:none;}.sp-fab:focus-visible{outline:2px solid var(--sp-accent);outline-offset:3px;}@media (hover: hover) and (pointer: fine){.sp-fab:hover{box-shadow:inset 0 1px 0 rgba(255,255,255,0.22),0 12px 32px color-mix(in srgb,var(--sp-accent) 46%,transparent),0 3px 8px rgba(0,0,0,0.14);}}.sp-fab:active{transform:scale(0.97);}div:has(> .sp-fab):has(~ .sp-panel.sp-panel--open) > .sp-fab{opacity:0;transform:scale(0.9);pointer-events:none;}.sp-fab--bottom-right{bottom:24px;right:24px;}.sp-fab--bottom-left{bottom:24px;left:24px;}.sp-fab svg{width:23px;height:23px;fill:currentColor;}.sp-fab-badge{position:absolute;top:-3px;right:-3px;min-width:20px;height:20px;padding:0 6px;border-radius:var(--sp-radius-full);background:var(--sp-danger);color:#fff;font:600 11px/1 var(--sp-font);display:flex;align-items:center;justify-content:center;border:2px solid var(--sp-bg);pointer-events:none;}.sp-toast{position:fixed;left:50%;bottom:96px;transform:translateX(-50%);max-width:min(360px,calc(100vw - 32px));padding:11px 18px;border-radius:20px;background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);color:var(--sp-text);font:500 14px/1.35 var(--sp-font);letter-spacing:-0.01em;box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);cursor:pointer;animation:sp-toast-in 0.2s var(--sp-ease-out);transition:opacity 0.15s ease;}.sp-toast--leaving{opacity:0;}.sp-toast[hidden]{display:none;}.sp-toast--error::before{content:"";display:inline-block;width:8px;height:8px;margin-right:8px;border-radius:50%;background:var(--sp-type-bug);vertical-align:1px;}@keyframes sp-toast-in{from{opacity:0;transform:translate(-50%,8px);}}.sp-radial{position:fixed;pointer-events:none;width:54px;height:54px;}.sp-radial--bottom-right{bottom:24px;right:24px;}.sp-radial--bottom-left{bottom:24px;left:24px;}.sp-radial-item{position:absolute;left:5px;bottom:5px;width:44px;height:44px;border-radius:var(--sp-radius-full);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);color:var(--sp-text);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);font-size:12px;font-weight:600;}.sp-radial-item:focus-visible{background:var(--sp-row);color:var(--sp-accent-ink);box-shadow:var(--sp-shadow-float),var(--sp-ring);outline:none;}@media (hover: hover) and (pointer: fine){.sp-radial-item:hover{background:var(--sp-row);color:var(--sp-accent-ink);}}.sp-radial-item svg{width:19px;height:19px;flex-shrink:0;stroke:currentColor;fill:none;}.sp-radial-label{position:absolute;top:50%;white-space:nowrap;font-size:13px;font-weight:500;letter-spacing:-0.01em;color:var(--sp-text);pointer-events:none;opacity:0;padding:6px 12px;border-radius:var(--sp-radius-full);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);transform:translate(4px,-50%);transition:opacity 0.18s ease,transform 0.2s var(--sp-ease-out);}.sp-radial--bottom-right .sp-radial-label{right:calc(100% + 12px);}.sp-radial--bottom-left .sp-radial-label{left:calc(100% + 12px);transform:translate(-4px,-50%);}.sp-radial-item:focus-visible .sp-radial-label{opacity:1;transform:translate(0,-50%);}@media (hover: hover) and (pointer: fine){.sp-radial-item:hover .sp-radial-label{opacity:1;transform:translate(0,-50%);}}.sp-panel{position:fixed;top:12px;right:12px;bottom:12px;width:380px;max-width:calc(100vw - 24px);border-radius:var(--sp-radius-xl);background:var(--sp-material);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),inset 0 0 0 0.5px var(--sp-sheen-soft),var(--sp-shadow-sheet);display:flex;flex-direction:column;overflow:clip;}.sp-panel-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:16px 12px 8px 20px;position:relative;z-index:2;}.sp-panel-title{font-family:var(--sp-font-display);font-size:28px;font-weight:700;line-height:1.15;color:var(--sp-text);letter-spacing:-0.022em;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.sp-panel-close{position:relative;width:44px;height:44px;border-radius:50%;border:none;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--sp-text-secondary);transition:var(--sp-tr);}.sp-panel-close::before{content:"";position:absolute;inset:7px;border-radius:50%;background:var(--sp-fill);transition:background-color 0.15s ease;}@media (hover: hover) and (pointer: fine){.sp-panel-close:hover{color:var(--sp-text);}.sp-panel-close:hover::before{background:var(--sp-fill-strong);}}.sp-panel-close svg{position:relative;width:13px;height:13px;stroke-width:2.6;}.sp-filters{padding:2px 16px 10px;position:sticky;top:0;z-index:1;}.sp-search-wrap{position:relative;margin-bottom:10px;}.sp-search{width:100%;height:36px;padding:0 12px 0 34px;border-radius:var(--sp-radius);border:none;background:var(--sp-fill);color:var(--sp-text);font-family:var(--sp-font);font-size:15px;letter-spacing:-0.01em;outline:none;transition:var(--sp-tr);}.sp-search::placeholder{color:var(--sp-text-secondary);}.sp-search:focus{box-shadow:var(--sp-ring);}.sp-search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--sp-text-secondary);width:16px;height:16px;}.sp-filter-bar{display:flex;align-items:center;gap:8px;margin-bottom:8px;flex-wrap:wrap;}.sp-filter-dropdown{position:relative;flex:1 1 auto;min-width:0;}.sp-filter-dropdown-btn{--sp-chip-color: var(--sp-text-secondary);display:inline-flex;align-items:center;gap:6px;width:100%;height:32px;padding:0 10px;border-radius:var(--sp-radius-full);border:none;background:var(--sp-fill);color:var(--sp-text);font-family:var(--sp-font);font-size:13px;font-weight:500;cursor:pointer;white-space:nowrap;transition:var(--sp-tr);}@media (hover: hover) and (pointer: fine){.sp-filter-dropdown-btn:hover{background:var(--sp-fill-strong);}}.sp-filter-dropdown-btn[aria-expanded="true"]{background:var(--sp-fill-strong);}.sp-filter-dropdown-btn--filtered,.sp-filter-dropdown-btn--filtered[aria-expanded="true"]{background:color-mix(in srgb,var(--sp-chip-color) 14%,transparent);}.sp-filter-dropdown-btn__icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0;color:var(--sp-chip-color);}.sp-filter-dropdown-btn__icon svg{width:14px;height:14px;}.sp-filter-dropdown-btn__label{display:inline-flex;align-items:baseline;gap:6px;flex:1;min-width:0;overflow:hidden;}.sp-filter-dropdown-btn__prefix{color:var(--sp-text-secondary);font-weight:500;font-size:11px;text-transform:uppercase;letter-spacing:0.04em;}.sp-filter-dropdown-btn__value{color:var(--sp-text);font-weight:600;overflow:hidden;text-overflow:ellipsis;}.sp-filter-dropdown-btn--filtered .sp-filter-dropdown-btn__value{color:color-mix(in srgb,var(--sp-chip-color) var(--sp-ink-pct),var(--sp-ink-mix));}.sp-filter-dropdown-btn__chevron{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex-shrink:0;color:var(--sp-text-secondary);transition:transform 0.2s var(--sp-ease-out);}.sp-filter-dropdown-btn__chevron svg{width:12px;height:12px;}.sp-filter-dropdown-btn[aria-expanded="true"] .sp-filter-dropdown-btn__chevron{transform:rotate(180deg);}.sp-filter-dropdown-menu{position:absolute;top:calc(100% + 6px);left:0;right:0;min-width:180px;padding:6px;border-radius:var(--sp-radius-lg);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-float);z-index:10;transform-origin:top left;animation:sp-menu-in 0.15s var(--sp-ease-out) backwards;}@keyframes sp-menu-in{from{opacity:0;transform:scale(0.96);}}.sp-filter-dropdown-option{--sp-chip-color: var(--sp-text-secondary);display:flex;align-items:center;gap:10px;width:100%;min-height:34px;padding:7px 10px;border:none;border-radius:8px;background:transparent;color:var(--sp-text);font-family:var(--sp-font);font-size:13px;font-weight:400;letter-spacing:-0.005em;cursor:pointer;text-align:left;transition:background-color 0.12s ease,color 0.12s ease;}.sp-filter-dropdown-option__icon{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;flex-shrink:0;border-radius:6px;background:color-mix(in srgb,var(--sp-chip-color) 14%,transparent);color:var(--sp-chip-color);}.sp-filter-dropdown-option__icon svg{width:13px;height:13px;}.sp-filter-dropdown-option__label{flex:1;min-width:0;}.sp-filter-dropdown-option__check{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex-shrink:0;color:var(--sp-accent-ink);}.sp-filter-dropdown-option__check svg{width:13px;height:13px;}@media (hover: hover) and (pointer: fine){.sp-filter-dropdown-option:hover{background:var(--sp-fill);}}.sp-filter-dropdown-option--active{font-weight:600;}.sp-segmented{display:inline-flex;align-items:stretch;padding:2px;border-radius:9px;background:var(--sp-fill);flex-shrink:0;}.sp-segmented__btn{--sp-chip-color: var(--sp-text-tertiary);display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 10px;border:none;border-radius:7px;background:transparent;color:var(--sp-text);font-family:var(--sp-font);font-size:13px;font-weight:500;letter-spacing:-0.01em;cursor:pointer;white-space:nowrap;transition:var(--sp-tr);}.sp-segmented__icon{display:inline-flex;align-items:center;justify-content:center;width:13px;height:13px;flex-shrink:0;color:var(--sp-chip-color);}.sp-segmented__icon svg{width:13px;height:13px;}@media (hover: hover) and (pointer: fine){.sp-segmented__btn:not(.sp-segmented__btn--active):hover{background:var(--sp-sheen);}}.sp-segmented__btn--active{background:var(--sp-thumb);font-weight:600;box-shadow:var(--sp-shadow-thumb);}.sp-list{flex:1;overflow-y:auto;padding:8px 16px 16px;-webkit-mask-image:linear-gradient(to bottom,transparent,#000 8px);mask-image:linear-gradient(to bottom,transparent,#000 8px);}.sp-list::-webkit-scrollbar{width:6px;}.sp-list::-webkit-scrollbar-track{background:transparent;}.sp-list::-webkit-scrollbar-thumb{background:var(--sp-fill-strong);border-radius:var(--sp-radius-full);}@media (hover: hover) and (pointer: fine){.sp-list::-webkit-scrollbar-thumb:hover{background:var(--sp-text-tertiary);}}.sp-card{position:relative;display:flex;padding:12px 14px 12px 12px;margin-bottom:8px;cursor:pointer;border-radius:var(--sp-radius-lg);background:var(--sp-row);box-shadow:var(--sp-shadow-row);transition:var(--sp-tr);}@media (hover: hover) and (pointer: fine){.sp-card:hover{background:var(--sp-row-hover);box-shadow:var(--sp-shadow-row-hover);}}.sp-card:active{transform:scale(0.985);}.sp-card-bar{align-self:flex-start;width:8px;height:8px;margin:6px 10px 0 2px;border-radius:50%;flex-shrink:0;transition:opacity 0.15s ease;}.sp-card-body{flex:1;min-width:0;}.sp-card-header{display:flex;flex-wrap:wrap;align-items:center;gap:4px 6px;margin-bottom:4px;}.sp-card-number{font-size:13px;font-weight:600;letter-spacing:-0.01em;color:var(--sp-text);font-variant-numeric:tabular-nums;}.sp-badge{white-space:nowrap;padding:2px 8px;border-radius:var(--sp-radius-full);font-size:11px;font-weight:600;line-height:16px;letter-spacing:0.01em;background:color-mix(in srgb,currentColor 13%,transparent) !important;-webkit-text-fill-color:color-mix(in srgb,currentColor var(--sp-ink-pct-badge),var(--sp-ink-mix));}.sp-card-date{font-size:12px;color:var(--sp-text-tertiary);margin-left:auto;white-space:nowrap;font-variant-numeric:tabular-nums;}.sp-lost{font-size:12px;color:var(--sp-text-tertiary);margin-top:4px;}.sp-card-message{font-size:14px;line-height:1.43;letter-spacing:-0.006em;color:var(--sp-text);overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;}.sp-card-message--expanded{-webkit-line-clamp:unset;}.sp-card-expand{font-size:13px;font-weight:500;color:var(--sp-accent-ink);cursor:pointer;background:none;border:none;padding:4px 0;font-family:var(--sp-font);transition:opacity 0.15s ease;}@media (hover: hover) and (pointer: fine){.sp-card-expand:hover{opacity:0.8;}}.sp-card-footer{display:flex;align-items:center;justify-content:flex-end;gap:2px;margin-top:6px;margin-right:-6px;}.sp-btn-resolve,.sp-btn-delete{height:30px;padding:0 10px;border-radius:8px;border:none;background:transparent;font-family:var(--sp-font);font-size:13px;font-weight:500;cursor:pointer;display:flex;align-items:center;gap:5px;transition:var(--sp-tr);}.sp-btn-resolve svg,.sp-btn-delete svg{width:14px;height:14px;}.sp-btn-resolve{color:var(--sp-ink-green);}.sp-card--resolved .sp-btn-resolve{color:var(--sp-accent-ink);}.sp-btn-delete{color:var(--sp-ink-red);}@media (hover: hover) and (pointer: fine){.sp-btn-resolve:hover{background:color-mix(in srgb,var(--sp-status-open) 10%,transparent);}.sp-card--resolved .sp-btn-resolve:hover{background:color-mix(in srgb,var(--sp-accent) 10%,transparent);}.sp-btn-delete:hover{background:color-mix(in srgb,var(--sp-type-bug) 10%,transparent);}}.sp-btn-resolve:disabled,.sp-btn-delete:disabled{opacity:0.5;cursor:not-allowed;pointer-events:none;}.sp-spinner--sm{width:14px;height:14px;}.sp-panel-header-right{display:flex;flex-shrink:0;align-items:center;gap:2px;}.sp-btn-delete-all{width:32px;height:32px;padding:0;justify-content:center;border-radius:50%;border:none;background:transparent;color:var(--sp-ink-red);font-family:var(--sp-font);font-size:13px;font-weight:500;white-space:nowrap;cursor:pointer;display:flex;align-items:center;transition:var(--sp-tr);}.sp-btn-delete-all svg{width:17px;height:17px;}.sp-btn-delete-all span,.sp-export-btn span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;}@media (hover: hover) and (pointer: fine){.sp-btn-delete-all:hover{background:color-mix(in srgb,var(--sp-type-bug) 10%,transparent);}}.sp-btn-delete-all:disabled{opacity:0.5;cursor:not-allowed;pointer-events:none;}.sp-confirm-backdrop{position:fixed;inset:0;background:var(--sp-backdrop);display:flex;align-items:center;justify-content:center;z-index:${2147483647};opacity:0;transition:opacity 0.2s ease;}.sp-confirm-dialog,.sp-identity-modal{border-radius:var(--sp-radius-xl);background:var(--sp-material-thick);-webkit-backdrop-filter:var(--sp-material-blur);backdrop-filter:var(--sp-material-blur);box-shadow:inset 0 0.5px 0 var(--sp-edge),var(--sp-shadow-sheet);}.sp-confirm-dialog{width:min(300px,calc(100vw - 32px));padding:22px 16px 16px;text-align:center;transform:translateY(8px) scale(0.97);transition:transform 0.2s var(--sp-ease-out);}.sp-confirm-title{font-size:17px;font-weight:600;color:var(--sp-text);letter-spacing:-0.022em;margin-bottom:4px;}.sp-confirm-message{font-size:13px;color:var(--sp-text-secondary);line-height:1.4;margin-bottom:18px;}.sp-confirm-actions{display:flex;gap:8px;justify-content:flex-end;}.sp-confirm-actions > button,.sp-identity-actions > button{flex:1 1 0;height:44px;}.sp-card--resolved .sp-card-number,.sp-card--resolved .sp-card-message{color:var(--sp-text-secondary);}.sp-card--resolved .sp-card-message{text-decoration:line-through;text-decoration-color:color-mix(in srgb,var(--sp-text-secondary) 60%,transparent);}.sp-loading{display:flex;align-items:center;justify-content:center;padding:56px 24px;}.sp-identity-backdrop{position:fixed;inset:0;background:var(--sp-identity-overlay);display:flex;align-items:center;justify-content:center;z-index:${2147483647};opacity:0;transition:opacity 0.2s ease;}.sp-identity-modal{width:340px;max-width:calc(100vw - 32px);padding:24px 20px 18px;color:var(--sp-text);transform:translateY(12px) scale(0.97);transition:transform 0.2s var(--sp-ease-out);}.sp-identity--open{opacity:1;}.sp-identity--open .sp-identity-modal{transform:none;}.sp-identity-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:20px;}.sp-identity-title{font-family:var(--sp-font-display);font-size:20px;font-weight:700;color:var(--sp-text);letter-spacing:-0.022em;}.sp-input{width:100%;height:40px;padding:0 12px;border-radius:var(--sp-radius);border:none;background:var(--sp-fill);color:var(--sp-text);font-family:var(--sp-font);font-size:15px;letter-spacing:-0.01em;outline:none;transition:var(--sp-tr);}.sp-input::placeholder{color:var(--sp-text-secondary);}.sp-input:focus{background:var(--sp-row);box-shadow:var(--sp-ring);}.sp-input-label{font-size:12px;font-weight:500;letter-spacing:0.02em;color:var(--sp-text-secondary);margin:0 0 6px 4px;display:block;}.sp-btn-primary,.sp-btn-ghost,.sp-btn-danger{height:40px;padding:0 18px;border-radius:12px;border:none;color:#fff;font-family:var(--sp-font);font-size:15px;font-weight:600;letter-spacing:-0.01em;cursor:pointer;transition:var(--sp-tr);}.sp-btn-primary{background:var(--sp-accent);}.sp-btn-ghost{background:var(--sp-fill);color:var(--sp-text);font-weight:500;}.sp-btn-danger{background:var(--sp-danger);}@media (hover: hover) and (pointer: fine){.sp-btn-primary:hover{background:var(--sp-accent-dark);}.sp-btn-ghost:hover{background:var(--sp-fill-strong);}.sp-btn-danger:hover{background:var(--sp-danger-press);}}.sp-btn-primary:disabled{opacity:0.4;cursor:not-allowed;transform:none;}.sp-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:56px 24px;color:var(--sp-text-secondary);text-align:center;gap:8px;}.sp-empty-text{font-size:15px;font-weight:500;letter-spacing:-0.01em;}.sp-load-more-wrap{display:flex;justify-content:center;padding:4px 0 0;}.sp-btn-ghost.sp-btn-load-more{width:100%;height:44px;border-radius:var(--sp-radius-lg);background:var(--sp-row);color:var(--sp-accent-ink);box-shadow:var(--sp-shadow-row);}@media (hover: hover) and (pointer: fine){.sp-btn-ghost.sp-btn-load-more:hover{background:var(--sp-row-hover);}}@media (forced-colors: active){.sp-fab,.sp-radial-item,.sp-filter-dropdown-btn,.sp-segmented,.sp-segmented__btn,.sp-card,.sp-panel-close,.sp-search,.sp-btn-resolve,.sp-btn-delete,.sp-btn-delete-all,.sp-btn-primary,.sp-btn-ghost,.sp-btn-danger,.sp-card-expand,.sp-input,.sp-confirm-dialog{border:2px solid ButtonText !important;background:Canvas !important;color:ButtonText !important;}.sp-segmented__btn--active{background:Highlight !important;color:HighlightText !important;}.sp-filter-dropdown-menu{border:2px solid ButtonText !important;background:Canvas !important;}.sp-filter-dropdown-option--active{background:Highlight !important;color:HighlightText !important;}.sp-fab:focus-visible,.sp-radial-item:focus-visible,.sp-filter-dropdown-btn:focus-visible,.sp-segmented__btn:focus-visible,.sp-filter-dropdown-option:focus-visible,.sp-panel-close:focus-visible,.sp-btn-resolve:focus-visible,.sp-btn-delete:focus-visible,.sp-btn-delete-all:focus-visible,.sp-btn-primary:focus-visible,.sp-btn-ghost:focus-visible,.sp-btn-danger:focus-visible,.sp-card-expand:focus-visible,.sp-input:focus-visible,.sp-search:focus-visible{outline:3px solid Highlight !important;}.sp-panel{border:2px solid ButtonText !important;}.sp-fab-badge{border:2px solid ButtonText !important;background:Canvas !important;color:ButtonText !important;}.sp-card-bar{background:ButtonText !important;}}${Vi} ${Pa} ${Oa} ${Fa} ${Da} ${Ta} ${Ia} ${Gi}`}var Ps=120,Ms=80,sn=150,Is=300,Qi=`opacity ${sn}ms ease, transform ${sn}ms ${z}`,Ji="scale(0.97)",Zi=10,eo="blur(30px) saturate(180%)",pt=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=E("div",{style:`position:fixed;z-index:${2147483647};max-width:280px;padding:10px 14px 12px;border:none;border-radius:14px;backdrop-filter:${eo};-webkit-backdrop-filter:${eo};font-family:${qa};pointer-events:auto;opacity:0;transform:${Ji};transition:${Qi};visibility:hidden;-webkit-font-smoothing:antialiased;`}),this.root.setAttribute("role","tooltip"),this.root.id=this.tooltipId,this.restyle(),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),O(this.root),document.body.appendChild(this.root);}colors;locale;root;showTimer=null;hideTimer=null;currentFeedbackId=null;closedAt=0;tooltipId="sp-tooltip";restyle(){let{surface:e}=this.colors,{style:n}=this.root;n.background=e.material,n.boxShadow=`inset 0 0.5px 0 ${e.edge}, ${e.shadowCard}`;}show(e,n){if(this.cancelHide(),this.currentFeedbackId===e.id)return;this.cancelShow();let i=this.root.style.visibility==="visible"||Date.now()-this.closedAt<Is;this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(n);let o=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=o||i?"none":Qi,this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="none";},i?0:Ps);}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Ms);}hide(){this.cancelShow(),this.currentFeedbackId&&(this.closedAt=Date.now()),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform=Ji,setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden");},sn);}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null);}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null);}render(e){let n=za$1(this.locale),{inkMix:i}=this.colors.surface,o=E("div",{style:"display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;margin-bottom:8px;"}),r=(l,c)=>{let p=E("span",{style:`padding:2px 8px;border-radius:9999px;font-size:11px;font-weight:600;white-space:nowrap;color:color-mix(in srgb,${c} 74%,${i});background:color-mix(in srgb,${c} 13%,transparent);letter-spacing:0.01em;`});return F(p,l),p},s=E("span",{style:`font-size:12px;color:${this.colors.textSecondary};margin-left:auto;white-space:nowrap;font-variant-numeric:tabular-nums;`});F(s,L(e.createdAt,this.locale)),o.appendChild(r(Ba(e.type,n),ma(e.type,this.colors))),o.appendChild(r(Ca(e.status,n),na(e.status,this.colors))),o.appendChild(s);let a=E("div",{style:`font-size:14px;line-height:1.43;letter-spacing:-0.006em;color:${this.colors.text};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;`});F(a,e.message),this.root.replaceChildren(o,a);}position(e){let n=this.root.getBoundingClientRect(),i=e.top-n.height-Zi,o=e.left+e.width/2-n.width/2,r=true;i<8&&(i=e.bottom+Zi,r=false),o=Math.max(8,Math.min(o,window.innerWidth-n.width-8)),this.root.style.top=`${i}px`,this.root.style.left=`${o}px`;let s=Math.max(22,Math.min(e.left+e.width/2-o,n.width-16));this.root.style.transformOrigin=`${s}px ${r?"100%":"0"}`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var dt=null;function Ls(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 Ae(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:()=>Promise.resolve(),focusFeedback:()=>false,on:()=>t,off:t}}function to(){try{return process.env.NODE_ENV}catch{return}}function _s(){let t=location.hostname;return t===""||t==="localhost"||t.endsWith(".localhost")||t==="127.0.0.1"||t==="[::1]"}function Ns(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function no(t){if(typeof window>"u"||typeof document>"u")return t.onSkip?.("ssr"),Ae();let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(dt)return e("initSiteping() called more than once \u2014 returning existing instance"),dt();let n=to();if(!t.forceShow&&(n==="production"||n===void 0&&!_s()))return t.onSkip?.("production"),Ae();let i=typeof t.minViewportWidth=="number"&&Number.isFinite(t.minViewportWidth)?t.minViewportWidth:0;if(!t.forceShow&&window.innerWidth<i){let u="mobile";return t.onSkip?.(u),Ae()}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."),Ae();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),Ae();let o=g(t.locale??"en"),r=o==="en"?Promise.resolve():ya(o).catch(()=>{}),s=za$1(o),a=t.scopeAnnotationsByUrl??true,l=()=>{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:o,scopeAnnotationsByUrl:a});let c=Ls(t.captureDiagnostics),p=c.console?new et(c.maxConsoleEntries):null,f=c.network?new tt(c.maxNetworkEntries):null,h=la(t.accentColor,t.theme),d=new Te,g$1=new Set,v=(u,...m)=>{for(let y of g$1)y.emit(u,...m);},k=(()=>{if(t.store)return new ct(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 Je(u,t.projectName,{apiKey:t.apiKey,headers:t.headers})})();t.onOpen&&d.on("open",t.onOpen),t.onClose&&d.on("close",t.onClose),t.onFeedbackSent&&d.on("feedback:sent",t.onFeedbackSent),t.onCommentAdded&&d.on("comment:added",t.onCommentAdded),t.onError&&d.on("feedback:error",t.onError),t.onError&&d.on("panel:action-error",t.onError),d.on("panel:action-error",u=>console.error("[siteping] Panel action failed:",u)),t.onAnnotationStart&&d.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&d.on("annotation:end",t.onAnnotationEnd);let H=Ge(t.projectName,t.endpoint);d.on("feedback:sent",u=>H.add(u.id)),d.on("feedback:deleted",u=>H.remove(u)),d.on("feedback:all-deleted",()=>H.clear());let S$1={"feedback:sent":()=>d.on("feedback:sent",u=>v("feedback:sent",u)),"feedback:deleted":()=>d.on("feedback:deleted",u=>v("feedback:deleted",u)),"comment:added":()=>d.on("comment:added",u=>v("comment:added",u)),"feedback:error":()=>d.on("feedback:error",u=>v("feedback:error",u)),"panel:open":()=>d.on("open",()=>v("panel:open")),"panel:close":()=>d.on("close",()=>v("panel:close")),"annotation:start":()=>d.on("annotation:start",()=>v("annotation:start")),"annotation:end":()=>d.on("annotation:end",()=>v("annotation:end"))};for(let u of Object.values(S$1))u();d.on("open",()=>e("Panel opened")),d.on("close",()=>e("Panel closed")),d.on("feedback:sent",u=>e("Feedback sent",u.id)),d.on("feedback:error",u=>e("Feedback failed",u.message)),d.on("annotation:start",()=>e("Annotation started")),d.on("annotation:end",()=>e("Annotation ended"));let w=document.createElement("siteping-widget");w.style.cssText=`position:fixed;z-index:${2147483647};pointer-events:auto;`;let D=to()==="test"?"open":"closed",P=w.attachShadow({mode:D}),$;if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;P.adoptedStyleSheets=[u],$=()=>u.replaceSync(on(h));}else {let u=document.createElement("style");P.appendChild(u),$=()=>{u.textContent=on(h);};}$(),O(w,P);let an=S();document.body.appendChild(w);let Pe=C(w),I=document.createElement("div");I.setAttribute("role","status"),I.setAttribute("aria-live","polite"),I.setAttribute("aria-atomic","true"),I.setAttribute("data-siteping-ignore","true"),I.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",O(I),document.body.appendChild(I);let b=document.createElement("div");b.className="sp-toast",b.setAttribute("aria-hidden","true"),b.hidden=true;let T,B=()=>{clearTimeout(T),!b.hidden&&(b.classList.add("sp-toast--leaving"),T=setTimeout(()=>{b.hidden=true,b.classList.remove("sp-toast--leaving");},150));};b.addEventListener("click",B),P.appendChild(b);let z=(u,m)=>{I.textContent=u,b.textContent=u,b.classList.toggle("sp-toast--error",m),b.classList.remove("sp-toast--leaving"),b.hidden=false,clearTimeout(T),T=setTimeout(B,m?8e3:4e3);},q=new pt(h,o),U=new lt(h,q,d,s,I),ut=new nt(P,t,d,s);d.on("markers:changed",u=>ut.updateBadge(u));let M=null,ht=null,K=false,Me=0;async function ln(u=false){let m=t.identity??Ut();if(m)return m;let y=await Fs(P,s,u);return y&&Ci(y),y}async function ft(){return K?null:M||(ht||(ht=import('./panel-TDZWSRVV.js').then(u=>K?null:(M=new u.Panel(P,h,d,k,t.projectName,U,s,o,{getScope:l,scopeAnnotationsByUrl:a,panelActions:t.panelActions,ownFeedback:H,resolveIdentity:ln,readOnly:t.readOnly}),M))),ht)}if(typeof window<"u"){let u=()=>{K||ft();},m=window.requestIdleCallback;typeof m=="function"?m(u):setTimeout(u,200);}let se=false,io=d.on("panel:toggle",u=>{M||(u?(se=true,ft().then(m=>{m&&se&&m.open(),se=false;}).catch(m=>e("Failed to lazy-load panel:",m))):se=false);}),fe=new Ve(h,d,s,t.enableScreenshot??false,()=>Pe.getLastPageFocus()),Ie=null;t.enableRightClickComment&&(Ie=u=>{if(u.defaultPrevented)return;let m=u.pointerType;m===""||m===void 0&&u.button!==2||u.shiftKey||u.ctrlKey||u.altKey||u.metaKey||u.composedPath().some(E=>E===w||E instanceof Element&&(E.hasAttribute("data-siteping-ignore")||E.id==="siteping-markers"))||fe.isBusy||(u.preventDefault(),fe.startInstantAnnotation(u.clientX,u.clientY).catch(E=>e("right-click annotation failed",E)));},document.addEventListener("contextmenu",Ie)),o!=="en"&&r.then(()=>{K||(ut.refreshLabels(),fe.refreshLabels());});let mt=false,oo=d.on("annotation:complete",async u=>{if(mt){d.emit("submission:cancelled");return}mt=true;try{let{annotation:m,type:y,message:E,clientId:L,screenshotDataUrl:re,screenshotRegion:Le}=u,A=await ln(!0);if(!A){d.emit("submission:cancelled");return}let ge=l(),un=null;(p||f)&&(un={console:p?.getEntries()??[],network:f?.getEntries()??[]});let lo={projectName:t.projectName,type:y,message:E,url:ge.url,urlPattern:ge.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:A.name,authorEmail:A.email,annotations:[m],clientId:L,screenshotDataUrl:re??null,screenshotRegion:Le??null,diagnostics:un};try{let Y=await k.sendFeedback(lo);d.emit("feedback:sent",Y),(!a||Y.url===ge.url)&&U.addFeedback(Y,U.count+1),z(s("feedback.sent.confirmation"),!1),M&&await M.refresh();}catch(Y){let vt=Ei(Y);vt&&d.emit("feedback:queued"),d.emit("feedback:error",Y instanceof Error?Y:new Error(String(Y))),z(s(vt?"feedback.queued":"feedback.error.message"),!vt);}}finally{mt=false;}}),gt=l(),so=a?{limit:20,url:gt.url}:{limit:20},bt=Ns(t.deepLink),ro=++Me;Promise.all([k.getFeedbacks(t.projectName,so),r]).then(([{feedbacks:u}])=>{if(K||Me!==ro)return;let m=a?u.filter(y=>y.url===gt.url):u;if(U.render(m),bt.enabled)try{let y=new URLSearchParams(window.location.search).get(bt.param);if(y){let E=U.focusFeedback(y);e(`deepLink ?${bt.param}=${y} ${E?"focused":"did not match a visible feedback"}`),E&&ft().then(async L=>{!L||K||(await L.open(),L.showFeedback(y));}).catch(L=>e("deepLink could not open the feedback:",L));}}catch(y){e("deepLink parsing failed:",y);}}).catch(u=>{e("Failed to load initial markers:",u);}),t.endpoint&&ki(t.endpoint,t.identity??Ut(),{apiKey:t.apiKey,headers:t.headers}).then(()=>e("Retry queue flushed")).catch(()=>{});let yt=()=>{let u=++Me;if(M?.isCurrentlyOpen)return M.refresh();let m=l(),y=a?{limit:20,url:m.url}:{limit:20};return k.getFeedbacks(t.projectName,y).then(({feedbacks:E})=>{if(K||u!==Me||M?.isCurrentlyOpen)return;let L=a?E.filter(re=>re.url===m.url):E;U.render(L);})},ao=t.theme==="auto"?ka(()=>{Object.assign(h,la(t.accentColor,"auto")),$(),q.restyle(),fe.restyle(),yt().catch(()=>{});}):void 0,cn=null;if(t.watchNavigation!==false&&typeof window<"u"&&typeof history<"u"){let u=A=>`${A.url}
|
|
3
|
+
${A.urlPattern??""}`,m=u(gt),y=()=>{if(K)return;let A=u(l());if(A===m)return;let ge=m;m=A,e("SPA navigation detected \u2014 refreshing feedbacks for new scope"),yt().catch(()=>{m===A&&(m=ge);});},E=history.pushState,L=history.replaceState,re=function(...A){E.apply(this,A),y();},Le=function(...A){L.apply(this,A),y();};history.pushState=re,history.replaceState=Le,window.addEventListener("popstate",y),window.addEventListener("hashchange",y),cn=()=>{window.removeEventListener("popstate",y),window.removeEventListener("hashchange",y),history.pushState===re&&(history.pushState=E),history.replaceState===Le&&(history.replaceState=L);};}let me={destroy:()=>{e("Destroying widget"),Ie&&document.removeEventListener("contextmenu",Ie),K=true,se=false,cn?.(),ao?.(),Pe.destroy(),oo(),io(),ut.destroy(),M?.destroy(),fe.destroy(),U.destroy(),q.destroy(),p?.dispose(),f?.dispose(),d.removeAll(),clearTimeout(T),I.remove(),w.remove(),an(),dt=null;},open:()=>{d.emit("panel:toggle",true);},close:()=>{M?M.close():se=false;},focusFeedback:u=>U.focusFeedback(u),refresh:()=>yt().catch(()=>{})},pn=0,dn=()=>{let u=new Te,m=true;return pn++,g$1.add(u),{destroy:()=>{m&&(m=false,g$1.delete(u),--pn===0&&me.destroy());},open:()=>{m&&me.open();},close:()=>{m&&me.close();},refresh:()=>m?me.refresh():Promise.resolve(),focusFeedback:y=>m&&me.focusFeedback(y),on:(y,E)=>u.on(y,E),off:(y,E)=>{u.off(y,E);}}};return dt=dn,dn()}function Fs(t,e,n){return new Promise(i=>{let o=t.activeElement??document.activeElement,r=t.host;n&&r.parentNode&&r.parentNode.appendChild(r);let s=document.createElement("div");s.className="sp-identity-backdrop";let a$1=document.createElement("div");a$1.className="sp-identity-modal";let l=`sp-identity-title-${Date.now()}`;a$1.setAttribute("role","dialog"),a$1.setAttribute("aria-modal","true"),a$1.setAttribute("aria-labelledby",l);let c=document.createElement("div");c.className="sp-identity-title",c.id=l,c.textContent=e("identity.title"),c.style.marginBottom="20px";let p=`sp-identity-name-${Date.now()}`,f=`sp-identity-email-${Date.now()}`,h$1=document.createElement("label");h$1.className="sp-input-label",h$1.textContent=e("identity.nameLabel"),h$1.setAttribute("for",p);let d=document.createElement("input");d.className="sp-input",d.id=p,d.type="text",d.maxLength=h,d.placeholder=e("identity.namePlaceholder"),d.style.marginBottom="14px";let g=document.createElement("label");g.className="sp-input-label",g.textContent=e("identity.emailLabel"),g.setAttribute("for",f);let v=document.createElement("input");v.className="sp-input",v.id=f,v.type="email",v.maxLength=h,v.placeholder=e("identity.emailPlaceholder");let k=document.createElement("div");k.className="sp-identity-actions";let H=wa(b=>a$1.style.setProperty("--sp-kb",`${b}px`)),S=b=>{Pe(),I(),H(),s.classList.remove("sp-identity--open"),setTimeout(()=>{s.remove(),o?.focus(),i(b);},200);},w=document.createElement("button");w.className="sp-btn-ghost",w.textContent=e("identity.cancel"),w.addEventListener("click",()=>S(null));let D=document.createElement("button");D.className="sp-btn-primary",D.textContent=e("identity.submit");let P=(b,T)=>{b.style.borderColor=T?"var(--sp-type-bug, #ef4444)":"",T?b.setAttribute("aria-invalid","true"):b.removeAttribute("aria-invalid");};D.addEventListener("click",()=>{let b=d.value.trim(),T=v.value.trim();if(!b||!T)return;let B=b.length>h,z=T.length>h||!a(T);P(d,B),P(v,z),!(B||z)&&S({name:b,email:T});});let $='input, button, [tabindex]:not([tabindex="-1"])',Pe=R(s,b=>{if(b.key==="Escape"){b.stopPropagation(),S(null);return}if(b.key==="Tab"){let T=Array.from(a$1.querySelectorAll($));if(T.length===0)return;let B=T[0],z=T[T.length-1];if(!B||!z)return;let q=t.activeElement;b.shiftKey?(q===B||!a$1.contains(q))&&(b.preventDefault(),z.focus()):(q===z||!a$1.contains(q))&&(b.preventDefault(),B.focus());}}),I=Q(s,()=>true);s.addEventListener("click",b=>{b.target===s&&S(null);}),k.appendChild(w),k.appendChild(D),a$1.appendChild(c),a$1.appendChild(h$1),a$1.appendChild(d),a$1.appendChild(g),a$1.appendChild(v),a$1.appendChild(k),s.appendChild(a$1),t.appendChild(s),s.offsetHeight,s.classList.add("sp-identity--open"),d.focus();})}function za(t){return no(t)}export{za as initSiteping};//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|