@siteping/widget 0.9.2 → 0.9.4

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.js CHANGED
@@ -1,28 +1,28 @@
1
- var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(n.tagName.toLowerCase()==="html")return"html";let t={root:document.body,idName:s=>!0,className:s=>!0,tagName:s=>!0,attr:(s,r)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};T={...t,...e},ne=nt(T.root,t);let i=P(n,"all",()=>P(n,"two",()=>P(n,"one",()=>P(n,"none"))));if(i){let s=we(ke(i,n));return s.length>0&&(i=s[0]),_(i)}else throw new Error("Selector was not found.")}function nt(n,e){return n.nodeType===Node.DOCUMENT_NODE?n:n===e.root?n.ownerDocument:n}function P(n,e,t){let i=null,s=[],r=n,o=0;for(;r;){let a=new Date().getTime()-ge.getTime();if(T.timeoutMs!==void 0&&a>T.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${a}ms`);let l=j(it(r))||j(...st(r))||j(...rt(r))||j(ot(r))||[be()],p=at(r);if(e=="all")p&&(l=l.concat(l.filter(te).map(d=>z(d,p))));else if(e=="two")l=l.slice(0,1),p&&(l=l.concat(l.filter(te).map(d=>z(d,p))));else if(e=="one"){let[d]=l=l.slice(0,1);p&&te(d)&&(l=[z(d,p)])}else e=="none"&&(l=[be()],p&&(l=[z(l[0],p)]));for(let d of l)d.level=o;if(s.push(l),s.length>=T.seedMinLength&&(i=fe(s,t),i))break;r=r.parentElement,o++}return i||(i=fe(s,t)),!i&&t?t():i}function fe(n,e){let t=we(xe(n));if(t.length>T.threshold)return e?e():null;for(let i of t)if(ve(i))return i;return null}function _(n){let e=n[0],t=e.name;for(let i=1;i<n.length;i++){let s=n[i].level||0;e.level===s-1?t=`${n[i].name} > ${t}`:t=`${n[i].name} ${t}`,e=n[i]}return t}function me(n){return n.map(e=>e.penalty).reduce((e,t)=>e+t,0)}function ve(n){let e=_(n);switch(ne.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return!0;default:return!1}}function it(n){let e=n.getAttribute("id");return e&&T.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function st(n){return Array.from(n.attributes).filter(t=>T.attr(t.name,t.value)).map(t=>({name:`[${CSS.escape(t.name)}="${CSS.escape(t.value)}"]`,penalty:.5}))}function rt(n){return Array.from(n.classList).filter(T.className).map(t=>({name:"."+CSS.escape(t),penalty:1}))}function ot(n){let e=n.tagName.toLowerCase();return T.tagName(e)?{name:e,penalty:2}:null}function be(){return{name:"*",penalty:3}}function at(n){let e=n.parentNode;if(!e)return null;let t=e.firstChild;if(!t)return null;let i=0;for(;t&&(t.nodeType===Node.ELEMENT_NODE&&i++,t!==n);)t=t.nextSibling;return i}function z(n,e){return{name:n.name+`:nth-child(${e})`,penalty:n.penalty+1}}function te(n){return n.name!=="html"&&!n.name.startsWith("#")}function j(...n){let e=n.filter(lt);return e.length>0?e:null}function lt(n){return n!=null}function*xe(n,e=[]){if(n.length>0)for(let t of n[0])yield*xe(n.slice(1,n.length),e.concat(t));else yield e}function we(n){return[...n].sort((e,t)=>me(e)-me(t))}function*ke(n,e,t={counter:0,visited:new Map}){if(n.length>2&&n.length>T.optimizedMinLength)for(let i=1;i<n.length-1;i++){if(t.counter>T.maxNumberOfTries)return;t.counter+=1;let s=[...n];s.splice(i,1);let r=_(s);if(t.visited.has(r))return;ve(s)&&pt(s,e)&&(yield s,t.visited.set(r,!0),yield*ke(s,e,t))}}function pt(n,e){return ne.querySelector(_(n))===e}var ct=["role","aria-label","type","name","href","src","data-testid","data-id"];function dt(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t)|0;return(e>>>0).toString(36)}function ie(n){let e=n.children.length,t=0,i=n.parentElement;if(i)for(let o of i.children){if(o===n)break;o.tagName===n.tagName&&t++}let s=[];for(let o of ct){let a=n.getAttribute(o);a&&s.push(`${o}=${a}`)}let r=s.length>0?dt(s.join(",")):"0";return`${e}:${t}:${r}`}function Ee(n,e){let t=e.split(":");if(t.length!==3)return 0;let[i,s,r]=t,o=Number(i),a=Number(s);if(Number.isNaN(o)||Number.isNaN(a))return 0;let l=ie(n),[p,d,c]=l.split(":"),h=0,b=Math.abs(Number(p)-o);b===0?h+=.2:b<=2?h+=.1:b<=5&&(h+=.03);let g=Math.abs(Number(d)-a);return g===0?h+=.4:g===1?h+=.2:g<=3&&(h+=.08),c===r&&(h+=.4),h}function I(n,e){let t=e==="before"?"previousElementSibling":"nextElementSibling",i=n[t],s=3;for(;i&&s>0;){let r=i.textContent?.trim();if(r)return e==="before"?r.slice(-32):r.slice(0,32);i=i[t],s--}return""}function Y(n){let e=n.previousElementSibling?.textContent?.trim().slice(0,40)??"",t=n.nextElementSibling?.textContent?.trim().slice(0,40)??"";return[e,t].filter(Boolean).join(" | ")}function Ce(n){if(n.id){let i=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return`//${n.localName}[@id=${i}]`}let e=[],t=n;for(;t&&t!==document.body&&e.length<6;){let i=t.localName,s=t.parentElement;if(t.id){let o=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return e.unshift(`/${i}[@id=${o}]`),"/"+e.join("")}let r=1;if(s)for(let o of s.children){if(o===t)break;o.localName===i&&r++}e.unshift(`/${i}[${r}]`),t=s}return"/html/body"+e.join("")}function Te(n){let e=ye(n,{className:p=>!/^(css|sc|emotion|styled)-/.test(p)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(p),attr:p=>["data-testid","data-id","role","aria-label"].includes(p),idName:p=>!p.startsWith("radix-")&&!/^:r[0-9]+:$/.test(p),seedMinLength:3,optimizedMinLength:2}),t=Ce(n),s=(n.textContent?.trim()??"").slice(0,120),r=I(n,"before"),o=I(n,"after"),a=ie(n),l=Y(n);return{cssSelector:e,xpath:t,textSnippet:s,textPrefix:r,textSuffix:o,fingerprint:a,neighborText:l,elementTag:n.tagName,elementId:n.id||void 0}}function Se(n,e=document.documentElement){let t=n.x+n.width/2,i=n.y+n.height/2,s=document.elementFromPoint(t,i);if(!s||s===e)return document.body;let r=s,o=s;for(;o&&o!==document.body;){let a=o.getBoundingClientRect();if(a.left<=n.x&&a.top<=n.y&&a.right>=n.x+n.width&&a.bottom>=n.y+n.height){r=o;break}o=o.parentElement}return r}function Ae(n,e){return e.width<=0||e.height<=0?{xPct:0,yPct:0,wPct:1,hPct:1}:{xPct:(n.x-e.x)/e.width,yPct:(n.y-e.y)/e.height,wPct:n.width/e.width,hPct:n.height/e.height}}function C(n){let i=document.createRange().createContextualFragment(n).firstElementChild;if(!i||i.nodeName.toLowerCase()!=="svg")throw new Error("[siteping] Invalid SVG string");return i}function u(n,e){let t=document.createElement(n);if(e)for(let[i,s]of Object.entries(e))i==="class"?t.className=s:i==="style"?t.style.cssText=s:t.setAttribute(i,s);return t}function m(n,e){n.textContent=e}function q(n,e="fr"){let t=Date.now()-new Date(n).getTime(),i=Math.floor(t/1e3);if(i<60)return new Intl.RelativeTimeFormat(e,{numeric:"auto"}).format(0,"second");let s=new Intl.RelativeTimeFormat(e,{numeric:"always",style:"narrow"}),r=Math.floor(i/60);if(r<60)return s.format(-r,"minute");let o=Math.floor(r/60);if(o<24)return s.format(-o,"hour");let a=Math.floor(o/24);return a<7?s.format(-a,"day"):new Date(n).toLocaleDateString(e)}var se='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><circle cx="12" cy="10" r="1" fill="currentColor" stroke="none"/><circle cx="8" cy="10" r="1" fill="currentColor" stroke="none"/><circle cx="16" cy="10" r="1" fill="currentColor" stroke="none"/></svg>',Le='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>',Me='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 3v18"/></svg>',re='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',oe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"/><path d="M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"/><line x1="1" y1="1" x2="23" y2="23"/></svg>',K='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',Fe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>',Ie='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>',Re='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',Ne='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',$e='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="8" y="6" width="8" height="14" rx="4"/><path d="M19 9h2"/><path d="M3 9h2"/><path d="M19 13h2"/><path d="M3 13h2"/><path d="M19 17h2"/><path d="M3 17h2"/><path d="M10 2h4"/></svg>',De='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>',Be='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',ae='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>';var He="#0066ff",ut=/^#[0-9a-fA-F]{6}$/,Oe=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/,ht=/^#[0-9a-fA-F]{8}$/;function ft(n){if(ut.test(n))return n;let e=Oe.test(n)?n.match(Oe):null;return e?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:ht.test(n)?n.slice(0,7):He}function mt(n,e){let t=Math.max(0,Math.round(parseInt(n.slice(1,3),16)*(1-e))),i=Math.max(0,Math.round(parseInt(n.slice(3,5),16)*(1-e))),s=Math.max(0,Math.round(parseInt(n.slice(5,7),16)*(1-e)));return`#${t.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function bt(){return typeof window>"u"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function gt(n){return n==="dark"||n==="auto"&&bt()?"dark":"light"}function Pe(n=He,e){let t=ft(n),i=mt(t,.15);return gt(e)==="dark"?{accent:t,accentLight:t+"22",accentDark:i,accentGlow:t+"44",accentGradient:`linear-gradient(135deg, ${t}, ${i})`,bg:"#0f172a",bgHover:"#1e293b",text:"#f1f5f9",textSecondary:"#94a3b8",textTertiary:"#64748b",border:"#334155",shadow:"rgba(0, 0, 0, 0.3)",glassBg:"rgba(15, 23, 42, 0.78)",glassBgHeavy:"rgba(15, 23, 42, 0.88)",glassBorder:"rgba(51, 65, 85, 0.5)",glassBorderSubtle:"rgba(51, 65, 85, 0.3)",typeQuestion:"#60a5fa",typeChange:"#fbbf24",typeBug:"#f87171",typeOther:"#94a3b8",typeQuestionBg:"rgba(59, 130, 246, 0.15)",typeChangeBg:"rgba(245, 158, 11, 0.15)",typeBugBg:"rgba(239, 68, 68, 0.15)",typeOtherBg:"rgba(100, 116, 139, 0.15)"}:{accent:t,accentLight:t+"14",accentDark:i,accentGlow:t+"33",accentGradient:`linear-gradient(135deg, ${t}, ${i})`,bg:"#ffffff",bgHover:"#f8f9fb",text:"#0f172a",textSecondary:"#475569",textTertiary:"#64748b",border:"#e2e8f0",shadow:"rgba(0, 0, 0, 0.06)",glassBg:"rgba(255, 255, 255, 0.72)",glassBgHeavy:"rgba(255, 255, 255, 0.85)",glassBorder:"rgba(255, 255, 255, 0.35)",glassBorderSubtle:"rgba(255, 255, 255, 0.18)",typeQuestion:"#3b82f6",typeChange:"#b45309",typeBug:"#ef4444",typeOther:"#64748b",typeQuestionBg:"#eff6ff",typeChangeBg:"#fffbeb",typeBugBg:"#fef2f2",typeOtherBg:"#f8fafc"}}function A(n,e){switch(n){case"question":return e.typeQuestion;case"change":return e.typeChange;case"bug":return e.typeBug;default:return e.typeOther}}function F(n,e){switch(n){case"question":return e.typeQuestionBg;case"change":return e.typeChangeBg;case"bug":return e.typeBugBg;default:return e.typeOtherBg}}function ze(n){return`
2
- --sp-accent: ${n.accent};
3
- --sp-accent-light: ${n.accentLight};
4
- --sp-accent-dark: ${n.accentDark};
5
- --sp-accent-glow: ${n.accentGlow};
6
- --sp-accent-gradient: ${n.accentGradient};
7
- --sp-bg: ${n.bg};
8
- --sp-bg-hover: ${n.bgHover};
9
- --sp-text: ${n.text};
10
- --sp-text-secondary: ${n.textSecondary};
11
- --sp-text-tertiary: ${n.textTertiary};
12
- --sp-border: ${n.border};
13
- --sp-shadow: ${n.shadow};
14
- --sp-glass-bg: ${n.glassBg};
15
- --sp-glass-bg-heavy: ${n.glassBgHeavy};
16
- --sp-glass-border: ${n.glassBorder};
17
- --sp-glass-border-subtle: ${n.glassBorderSubtle};
18
- --sp-type-question: ${n.typeQuestion};
19
- --sp-type-change: ${n.typeChange};
20
- --sp-type-bug: ${n.typeBug};
21
- --sp-type-other: ${n.typeOther};
22
- --sp-type-question-bg: ${n.typeQuestionBg};
23
- --sp-type-change-bg: ${n.typeChangeBg};
24
- --sp-type-bug-bg: ${n.typeBugBg};
25
- --sp-type-other-bg: ${n.typeOtherBg};
1
+ var M,ce,Fe;function Le(t,e){if(Fe=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return"html";let n={root:document.body,idName:s=>!0,className:s=>!0,tagName:s=>!0,attr:(s,o)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};M={...n,...e},ce=ut(M.root,n);let i=K(t,"all",()=>K(t,"two",()=>K(t,"one",()=>K(t,"none"))));if(i){let s=Re(Pe(i,t));return s.length>0&&(i=s[0]),q(i)}else throw new Error("Selector was not found.")}function ut(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function K(t,e,n){let i=null,s=[],o=t,r=0;for(;o;){let a=new Date().getTime()-Fe.getTime();if(M.timeoutMs!==void 0&&a>M.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${a}ms`);let l=W(ht(o))||W(...ft(o))||W(...mt(o))||W(gt(o))||[Ae()],c=bt(o);if(e=="all")c&&(l=l.concat(l.filter(le).map(d=>Y(d,c))));else if(e=="two")l=l.slice(0,1),c&&(l=l.concat(l.filter(le).map(d=>Y(d,c))));else if(e=="one"){let[d]=l=l.slice(0,1);c&&le(d)&&(l=[Y(d,c)])}else e=="none"&&(l=[Ae()],c&&(l=[Y(l[0],c)]));for(let d of l)d.level=r;if(s.push(l),s.length>=M.seedMinLength&&(i=Te(s,n),i))break;o=o.parentElement,r++}return i||(i=Te(s,n)),!i&&n?n():i}function Te(t,e){let n=Re(Ie(t));if(n.length>M.threshold)return e?e():null;for(let i of n)if(Me(i))return i;return null}function q(t){let e=t[0],n=e.name;for(let i=1;i<t.length;i++){let s=t[i].level||0;e.level===s-1?n=`${t[i].name} > ${n}`:n=`${t[i].name} ${n}`,e=t[i]}return n}function Se(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Me(t){let e=q(t);switch(ce.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return!0;default:return!1}}function ht(t){let e=t.getAttribute("id");return e&&M.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function ft(t){return Array.from(t.attributes).filter(n=>M.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function mt(t){return Array.from(t.classList).filter(M.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function gt(t){let e=t.tagName.toLowerCase();return M.tagName(e)?{name:e,penalty:2}:null}function Ae(){return{name:"*",penalty:3}}function bt(t){let e=t.parentNode;if(!e)return null;let n=e.firstChild;if(!n)return null;let i=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&i++,n!==t);)n=n.nextSibling;return i}function Y(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function le(t){return t.name!=="html"&&!t.name.startsWith("#")}function W(...t){let e=t.filter(yt);return e.length>0?e:null}function yt(t){return t!=null}function*Ie(t,e=[]){if(t.length>0)for(let n of t[0])yield*Ie(t.slice(1,t.length),e.concat(n));else yield e}function Re(t){return[...t].sort((e,n)=>Se(e)-Se(n))}function*Pe(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>M.optimizedMinLength)for(let i=1;i<t.length-1;i++){if(n.counter>M.maxNumberOfTries)return;n.counter+=1;let s=[...t];s.splice(i,1);let o=q(s);if(n.visited.has(o))return;Me(s)&&vt(s,e)&&(yield s,n.visited.set(o,!0),yield*Pe(s,e,n))}}function vt(t,e){return ce.querySelector(q(t))===e}var xt=["role","aria-label","type","name","href","src","data-testid","data-id"];function kt(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 de(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let r of i.children){if(r===t)break;r.tagName===t.tagName&&n++}let s=[];for(let r of xt){let a=t.getAttribute(r);a&&s.push(`${r}=${a}`)}let o=s.length>0?kt(s.join(",")):"0";return`${e}:${n}:${o}`}function Be(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,s,o]=n,r=Number(i),a=Number(s);if(Number.isNaN(r)||Number.isNaN(a))return 0;let l=de(t),[c,d,p]=l.split(":"),f=0,m=Math.abs(Number(c)-r);m===0?f+=.2:m<=2?f+=.1:m<=5&&(f+=.03);let y=Math.abs(Number(d)-a);return y===0?f+=.4:y===1?f+=.2:y<=3&&(f+=.08),p===o&&(f+=.4),f}function N(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],s=3;for(;i&&s>0;){let o=i.textContent?.trim();if(o)return e==="before"?o.slice(-32):o.slice(0,32);i=i[n],s--}return""}function U(t){let e=t.previousElementSibling?.textContent?.trim().slice(0,40)??"",n=t.nextElementSibling?.textContent?.trim().slice(0,40)??"";return[e,n].filter(Boolean).join(" | ")}function Ne(t){if(t.id){let i=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return`//${t.localName}[@id=${i}]`}let e=[],n=t;for(;n&&n!==document.body&&e.length<6;){let i=n.localName,s=n.parentElement;if(n.id){let r=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${i}[@id=${r}]`),"/"+e.join("")}let o=1;if(s)for(let r of s.children){if(r===n)break;r.localName===i&&o++}e.unshift(`/${i}[${o}]`),n=s}return"/html/body"+e.join("")}function pe(t){let e=Le(t,{className:c=>!/^(css|sc|emotion|styled)-/.test(c)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(c),attr:c=>["data-testid","data-id","role","aria-label"].includes(c),idName:c=>!c.startsWith("radix-")&&!/^:r[0-9]+:$/.test(c),seedMinLength:3,optimizedMinLength:2}),n=Ne(t),s=(t.textContent?.trim()??"").slice(0,120),o=N(t,"before"),r=N(t,"after"),a=de(t),l=U(t);return{cssSelector:e,xpath:n,textSnippet:s,textPrefix:o,textSuffix:r,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0}}function $e(t,e=document.documentElement){let n=t.x+t.width/2,i=t.y+t.height/2,s=document.elementFromPoint(n,i);if(!s||s===e)return document.body;let o=s,r=s;for(;r&&r!==document.body;){let a=r.getBoundingClientRect();if(a.left<=t.x&&a.top<=t.y&&a.right>=t.x+t.width&&a.bottom>=t.y+t.height){o=r;break}r=r.parentElement}return o}function De(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}}function F(t){let i=document.createRange().createContextualFragment(t).firstElementChild;if(!i||i.nodeName.toLowerCase()!=="svg")throw new Error("[siteping] Invalid SVG string");for(let s of[...i.attributes])s.name.startsWith("on")&&i.removeAttribute(s.name);for(let s of i.querySelectorAll("*"))for(let o of[...s.attributes])o.name.startsWith("on")&&s.removeAttribute(o.name);return i}function h(t,e){let n=document.createElement(t);if(e)for(let[i,s]of Object.entries(e))i==="class"?n.className=s:i==="style"?n.style.cssText=s:n.setAttribute(i,s);return n}function b(t,e){t.textContent=e}function X(t,e="fr"){let n=Date.now()-new Date(t).getTime(),i=Math.floor(n/1e3);if(i<60)return new Intl.RelativeTimeFormat(e,{numeric:"auto"}).format(0,"second");let s=new Intl.RelativeTimeFormat(e,{numeric:"always",style:"narrow"}),o=Math.floor(i/60);if(o<60)return s.format(-o,"minute");let r=Math.floor(o/60);if(r<24)return s.format(-r,"hour");let a=Math.floor(r/24);return a<7?s.format(-a,"day"):new Date(t).toLocaleDateString(e)}var ue='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><circle cx="12" cy="10" r="1" fill="currentColor" stroke="none"/><circle cx="8" cy="10" r="1" fill="currentColor" stroke="none"/><circle cx="16" cy="10" r="1" fill="currentColor" stroke="none"/></svg>',He='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>',Oe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 3v18"/></svg>',he='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',fe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"/><path d="M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"/><line x1="1" y1="1" x2="23" y2="23"/></svg>',G='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',je='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>',ze='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>',_e='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',Ke='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',Ye='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="8" y="6" width="8" height="14" rx="4"/><path d="M19 9h2"/><path d="M3 9h2"/><path d="M19 13h2"/><path d="M3 13h2"/><path d="M19 17h2"/><path d="M3 17h2"/><path d="M10 2h4"/></svg>',We='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>',qe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',me='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>';var Xe="#0066ff",wt=/^#[0-9a-fA-F]{6}$/,Ue=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/,Et=/^#[0-9a-fA-F]{8}$/;function Ct(t){if(wt.test(t))return t;let e=Ue.test(t)?t.match(Ue):null;return e?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:Et.test(t)?t.slice(0,7):(console.warn(`[siteping] Invalid accentColor "${t}" \u2014 only hex colors (#RGB, #RRGGBB, #RRGGBBAA) are supported. Using default.`),Xe)}function Tt(t,e){let n=Math.max(0,Math.round(parseInt(t.slice(1,3),16)*(1-e))),i=Math.max(0,Math.round(parseInt(t.slice(3,5),16)*(1-e))),s=Math.max(0,Math.round(parseInt(t.slice(5,7),16)*(1-e)));return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function St(){return typeof window>"u"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function At(t){return t==="dark"||t==="auto"&&St()?"dark":"light"}function Ge(t=Xe,e){let n=Ct(t),i=Tt(n,.15);return At(e)==="dark"?{accent:n,accentLight:n+"22",accentDark:i,accentGlow:n+"44",accentGradient:`linear-gradient(135deg, ${n}, ${i})`,bg:"#0f172a",bgHover:"#1e293b",text:"#f1f5f9",textSecondary:"#94a3b8",textTertiary:"#64748b",border:"#334155",shadow:"rgba(0, 0, 0, 0.3)",glassBg:"rgba(15, 23, 42, 0.78)",glassBgHeavy:"rgba(15, 23, 42, 0.88)",glassBorder:"rgba(51, 65, 85, 0.5)",glassBorderSubtle:"rgba(51, 65, 85, 0.3)",typeQuestion:"#60a5fa",typeChange:"#fbbf24",typeBug:"#f87171",typeOther:"#94a3b8",typeQuestionBg:"rgba(59, 130, 246, 0.15)",typeChangeBg:"rgba(245, 158, 11, 0.15)",typeBugBg:"rgba(239, 68, 68, 0.15)",typeOtherBg:"rgba(100, 116, 139, 0.15)"}:{accent:n,accentLight:n+"14",accentDark:i,accentGlow:n+"33",accentGradient:`linear-gradient(135deg, ${n}, ${i})`,bg:"#ffffff",bgHover:"#f8f9fb",text:"#0f172a",textSecondary:"#475569",textTertiary:"#64748b",border:"#e2e8f0",shadow:"rgba(0, 0, 0, 0.06)",glassBg:"rgba(255, 255, 255, 0.72)",glassBgHeavy:"rgba(255, 255, 255, 0.85)",glassBorder:"rgba(255, 255, 255, 0.35)",glassBorderSubtle:"rgba(255, 255, 255, 0.18)",typeQuestion:"#3b82f6",typeChange:"#b45309",typeBug:"#ef4444",typeOther:"#64748b",typeQuestionBg:"#eff6ff",typeChangeBg:"#fffbeb",typeBugBg:"#fef2f2",typeOtherBg:"#f8fafc"}}function I(t,e){switch(t){case"question":return e.typeQuestion;case"change":return e.typeChange;case"bug":return e.typeBug;default:return e.typeOther}}function P(t,e){switch(t){case"question":return e.typeQuestionBg;case"change":return e.typeChangeBg;case"bug":return e.typeBugBg;default:return e.typeOtherBg}}function Ve(t){return`
2
+ --sp-accent: ${t.accent};
3
+ --sp-accent-light: ${t.accentLight};
4
+ --sp-accent-dark: ${t.accentDark};
5
+ --sp-accent-glow: ${t.accentGlow};
6
+ --sp-accent-gradient: ${t.accentGradient};
7
+ --sp-bg: ${t.bg};
8
+ --sp-bg-hover: ${t.bgHover};
9
+ --sp-text: ${t.text};
10
+ --sp-text-secondary: ${t.textSecondary};
11
+ --sp-text-tertiary: ${t.textTertiary};
12
+ --sp-border: ${t.border};
13
+ --sp-shadow: ${t.shadow};
14
+ --sp-glass-bg: ${t.glassBg};
15
+ --sp-glass-bg-heavy: ${t.glassBgHeavy};
16
+ --sp-glass-border: ${t.glassBorder};
17
+ --sp-glass-border-subtle: ${t.glassBorderSubtle};
18
+ --sp-type-question: ${t.typeQuestion};
19
+ --sp-type-change: ${t.typeChange};
20
+ --sp-type-bug: ${t.typeBug};
21
+ --sp-type-other: ${t.typeOther};
22
+ --sp-type-question-bg: ${t.typeQuestionBg};
23
+ --sp-type-change-bg: ${t.typeChangeBg};
24
+ --sp-type-bug-bg: ${t.typeBugBg};
25
+ --sp-type-other-bg: ${t.typeOtherBg};
26
26
  --sp-radius: 12px;
27
27
  --sp-radius-lg: 16px;
28
28
  --sp-radius-xl: 20px;
@@ -35,54 +35,54 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
35
35
  --sp-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.04);
36
36
  --sp-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.06);
37
37
  --sp-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
38
- `}var W=class{constructor(e,t){this.colors=e;this.t=t;this.root=u("div",{style:`
38
+ `}var V=class{constructor(e,n){this.colors=e;this.t=n;this.root=h("div",{style:`
39
39
  position:fixed;
40
40
  z-index:2147483647;
41
41
  width:300px;
42
42
  padding:16px;
43
43
  border-radius:16px;
44
- background:rgba(255, 255, 255, 0.82);
44
+ background:${this.colors.glassBg};
45
45
  backdrop-filter:blur(24px);
46
46
  -webkit-backdrop-filter:blur(24px);
47
- border:1px solid rgba(255, 255, 255, 0.35);
48
- box-shadow:0 8px 32px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.04);
47
+ border:1px solid ${this.colors.glassBorder};
48
+ box-shadow:0 8px 32px ${this.colors.shadow}, 0 2px 8px ${this.colors.shadow};
49
49
  font-family:"Inter",system-ui,-apple-system,sans-serif;
50
50
  opacity:0;
51
51
  transform:translateY(8px) scale(0.98);
52
52
  transition:opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
53
53
  display:none;
54
54
  -webkit-font-smoothing:antialiased;
55
- `}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("aria-label","Formulaire de feedback");let i=[{type:"question",label:this.t("type.question"),icon:Re},{type:"change",label:this.t("type.change"),icon:Ne},{type:"bug",label:this.t("type.bug"),icon:$e},{type:"other",label:this.t("type.other"),icon:De}],s=u("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let d of i){let c=document.createElement("button");c.style.cssText=`
56
- height:34px;
57
- border-radius:9999px;border:1px solid #e2e8f0;
58
- background:rgba(255,255,255,0.8);cursor:pointer;
55
+ `}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("aria-label",this.t("popup.ariaLabel"));let i=[{type:"question",label:this.t("type.question"),icon:_e},{type:"change",label:this.t("type.change"),icon:Ke},{type:"bug",label:this.t("type.bug"),icon:Ye},{type:"other",label:this.t("type.other"),icon:We}],s=h("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let d of i){let p=document.createElement("button");p.style.cssText=`
56
+ height:44px;
57
+ border-radius:9999px;border:1px solid ${this.colors.border};
58
+ background:${this.colors.glassBg};cursor:pointer;
59
59
  display:flex;align-items:center;justify-content:center;gap:5px;
60
60
  font-family:"Inter",system-ui,-apple-system,sans-serif;
61
- font-size:12px;font-weight:500;color:#64748b;
61
+ font-size:13px;font-weight:500;color:${this.colors.textTertiary};
62
62
  transition:all 0.2s ease;
63
- padding:0 10px;
64
- `;let h=C(d.icon);h.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),c.appendChild(h);let b=document.createElement("span");m(b,d.label),c.appendChild(b),c.dataset.type=d.type,c.setAttribute("aria-pressed","false"),c.addEventListener("click",()=>{this.selectType(d.type,s)}),c.addEventListener("mouseenter",()=>{if(c.dataset.type!==this.selectedType){let g=F(c.dataset.type??"",this.colors);c.style.background=g,c.style.borderColor=A(c.dataset.type??"",this.colors)+"40"}}),c.addEventListener("mouseleave",()=>{c.dataset.type!==this.selectedType&&(c.style.background="rgba(255,255,255,0.8)",c.style.borderColor="#e2e8f0")}),s.appendChild(c)}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
63
+ padding:0 12px;
64
+ `;let f=F(d.icon);f.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),p.appendChild(f);let m=document.createElement("span");b(m,d.label),p.appendChild(m),p.dataset.type=d.type,p.setAttribute("aria-pressed","false"),p.addEventListener("click",()=>{this.selectType(d.type,s)}),p.addEventListener("mouseenter",()=>{if(p.dataset.type!==this.selectedType){let y=P(p.dataset.type??"",this.colors);p.style.background=y,p.style.borderColor=I(p.dataset.type??"",this.colors)+"40"}}),p.addEventListener("mouseleave",()=>{p.dataset.type!==this.selectedType&&(p.style.background=this.colors.glassBg,p.style.borderColor=this.colors.border)}),s.appendChild(p)}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
65
65
  width:100%;min-height:72px;max-height:152px;
66
66
  padding:10px 12px;border-radius:12px;
67
- border:1px solid #e2e8f0;
68
- background:rgba(255,255,255,0.85);
69
- color:#0f172a;font-family:"Inter",system-ui,-apple-system,sans-serif;
67
+ border:1px solid ${this.colors.border};
68
+ background:${this.colors.glassBgHeavy};
69
+ color:${this.colors.text};font-family:"Inter",system-ui,-apple-system,sans-serif;
70
70
  font-size:13px;line-height:1.5;resize:vertical;
71
71
  outline:none;transition:all 0.2s ease;
72
72
  box-sizing:border-box;
73
- `,this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria"));let r=u("div",{style:`
74
- font-size:11px;color:#94a3b8;
73
+ `,this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.maxLength=5e3,this.textarea.setAttribute("aria-label",this.t("popup.textareaAria"));let o=h("div",{style:`
74
+ font-size:11px;color:${this.colors.textTertiary};
75
75
  text-align:right;margin-top:4px;
76
76
  font-family:"Inter",system-ui,-apple-system,sans-serif;
77
77
  letter-spacing:0.01em;
78
- `}),o=navigator.userAgentData,a=o?o.platform==="macOS":navigator.platform?.includes("Mac")??!1;m(r,a?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),this.textarea.addEventListener("focus",()=>{this.textarea.style.borderColor=this.colors.accent,this.textarea.style.boxShadow=`0 0 0 3px ${this.colors.accent}14`,this.textarea.style.background="#fff"}),this.textarea.addEventListener("blur",()=>{this.textarea.style.borderColor="#e2e8f0",this.textarea.style.boxShadow="none",this.textarea.style.background="rgba(255,255,255,0.85)"}),this.textarea.addEventListener("input",()=>{this.updateSubmitState()}),this.textarea.addEventListener("keydown",d=>{d.key==="Enter"&&(d.ctrlKey||d.metaKey)&&(d.preventDefault(),this.submit()),d.key==="Escape"&&this.cancel()});let l=u("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"}),p=document.createElement("button");p.style.cssText=`
78
+ `}),r=navigator.userAgentData,a=r?r.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent);b(o,a?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),this.textarea.addEventListener("focus",()=>{this.textarea.style.borderColor=this.colors.accent,this.textarea.style.boxShadow=`0 0 0 3px ${this.colors.accent}14`,this.textarea.style.background=this.colors.bg}),this.textarea.addEventListener("blur",()=>{this.textarea.style.borderColor=this.colors.border,this.textarea.style.boxShadow="none",this.textarea.style.background=this.colors.glassBgHeavy}),this.textarea.addEventListener("input",()=>{this.updateSubmitState()}),this.textarea.addEventListener("keydown",d=>{d.key==="Enter"&&(d.ctrlKey||d.metaKey)&&(d.preventDefault(),this.submit()),d.key==="Escape"&&this.cancel()});let l=h("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"}),c=document.createElement("button");c.style.cssText=`
79
79
  height:34px;padding:0 16px;border-radius:9999px;
80
- border:1px solid #e2e8f0;
81
- background:rgba(255,255,255,0.8);
82
- color:#64748b;font-family:"Inter",system-ui,-apple-system,sans-serif;
80
+ border:1px solid ${this.colors.border};
81
+ background:${this.colors.glassBg};
82
+ color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
83
83
  font-size:13px;font-weight:500;cursor:pointer;
84
84
  transition:all 0.2s ease;
85
- `,m(p,this.t("popup.cancel")),p.addEventListener("click",()=>this.cancel()),p.addEventListener("mouseenter",()=>{p.style.borderColor=this.colors.accent,p.style.color=this.colors.accent}),p.addEventListener("mouseleave",()=>{p.style.borderColor="#e2e8f0",p.style.color="#64748b"}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`
85
+ `,b(c,this.t("popup.cancel")),c.addEventListener("click",()=>this.cancel()),c.addEventListener("mouseenter",()=>{c.style.borderColor=this.colors.accent,c.style.color=this.colors.accent}),c.addEventListener("mouseleave",()=>{c.style.borderColor=this.colors.border,c.style.color=this.colors.textTertiary}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`
86
86
  height:34px;padding:0 18px;border-radius:9999px;
87
87
  border:none;background:${this.colors.accentGradient};
88
88
  color:#fff;font-family:"Inter",system-ui,-apple-system,sans-serif;
@@ -90,37 +90,37 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
90
90
  opacity:0.35;pointer-events:none;
91
91
  transition:all 0.2s ease;
92
92
  box-shadow:0 2px 8px ${this.colors.accentGlow};
93
- `,m(this.submitBtn,this.t("popup.submit")),this.submitBtn.addEventListener("click",()=>this.submit()),l.appendChild(p),l.appendChild(this.submitBtn),this.root.appendChild(s),this.root.appendChild(this.textarea),this.root.appendChild(r),this.root.appendChild(l),document.body.appendChild(this.root)}colors;t;root;selectedType=null;textarea;submitBtn;resolve=null;previouslyFocused=null;onKeydownTrap=null;show(e){return new Promise(t=>{this.resolve=t,this.selectedType=null,this.textarea.value="",this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let i=e.bottom+8,s=e.left;i+220>window.innerHeight&&(i=e.top-220-8),s+300>window.innerWidth&&(s=e.right-300),s=Math.max(8,s),i=Math.max(8,i),this.root.style.top=`${i}px`,this.root.style.left=`${s}px`,this.root.style.display="block",this.onKeydownTrap=r=>{if(r.key==="Tab"){let o=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea, input, [tabindex]:not([tabindex="-1"])'));if(o.length===0)return;let a=o[0],l=o[o.length-1];r.shiftKey?(document.activeElement===a||!this.root.contains(document.activeElement))&&(r.preventDefault(),l.focus()):(document.activeElement===l||!this.root.contains(document.activeElement))&&(r.preventDefault(),a.focus())}},this.root.addEventListener("keydown",this.onKeydownTrap),requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus()})})}selectType(e,t){this.selectedType=e;let i=t.querySelectorAll("button");for(let s of i){let r=s.dataset.type===e,o=A(s.dataset.type??"",this.colors),a=F(s.dataset.type??"",this.colors);s.style.background=r?a:"rgba(255,255,255,0.8)",s.style.borderColor=r?o+"60":"#e2e8f0",s.style.color=r?o:"#64748b",s.style.fontWeight=r?"600":"500",s.setAttribute("aria-pressed",String(r))}this.updateSubmitState()}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let t of e)t.style.background="rgba(255,255,255,0.8)",t.style.borderColor="#e2e8f0",t.style.color="#64748b",t.style.fontWeight="500"}updateSubmitState(){let e=this.selectedType!==null&&this.textarea.value.trim().length>0;this.submitBtn.disabled=!e,this.submitBtn.style.opacity=e?"1":"0.35",this.submitBtn.style.pointerEvents=e?"auto":"none"}submit(){!this.selectedType||!this.textarea.value.trim()||(this.resolve?.({type:this.selectedType,message:this.textarea.value.trim()}),this.resolve=null,this.hideElement())}cancel(){this.resolve?.(null),this.resolve=null,this.hideElement()}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none"},250)}destroy(){this.root.remove()}};var G=class{constructor(e,t,i){this.colors=e;this.bus=t;this.t=i;this.popup=new W(e,i),this.bus.on("annotation:start",()=>this.activate())}colors;bus;t;overlay=null;toolbar=null;drawingRect=null;startX=0;startY=0;isDrawing=!1;isActive=!1;popup;savedOverflow="";activate(){if(this.isActive)return;this.isActive=!0,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=u("div",{style:`
93
+ `,b(this.submitBtn,this.t("popup.submit")),this.submitBtn.addEventListener("click",()=>this.submit()),l.appendChild(c),l.appendChild(this.submitBtn),this.root.appendChild(s),this.root.appendChild(this.textarea),this.root.appendChild(o),this.root.appendChild(l),document.body.appendChild(this.root)}colors;t;root;selectedType=null;textarea;submitBtn;resolve=null;previouslyFocused=null;onKeydownTrap=null;show(e){return new Promise(n=>{this.resolve=n,this.selectedType=null,this.textarea.value="",this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let i=e.bottom+8,s=e.left;i+220>window.innerHeight&&(i=e.top-220-8),s+300>window.innerWidth&&(s=e.right-300),s=Math.max(8,s),i=Math.max(8,i),this.root.style.top=`${i}px`,this.root.style.left=`${s}px`,this.root.style.display="block",this.onKeydownTrap=r=>{if(r.key==="Tab"){let a=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea, input, [tabindex]:not([tabindex="-1"])'));if(a.length===0)return;let l=a[0],c=a[a.length-1];if(!l||!c)return;r.shiftKey?(document.activeElement===l||!this.root.contains(document.activeElement))&&(r.preventDefault(),c.focus()):(document.activeElement===c||!this.root.contains(document.activeElement))&&(r.preventDefault(),l.focus())}},this.root.addEventListener("keydown",this.onKeydownTrap);let o=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=o?"none":"",requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus()})})}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let s of i){let o=s.dataset.type===e,r=I(s.dataset.type??"",this.colors),a=P(s.dataset.type??"",this.colors);s.style.background=o?a:this.colors.glassBg,s.style.borderColor=o?r+"60":this.colors.border,s.style.color=o?r:this.colors.textTertiary,s.style.fontWeight=o?"600":"500",s.setAttribute("aria-pressed",String(o))}this.updateSubmitState()}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let n of e)n.setAttribute("aria-pressed","false"),n.style.background=this.colors.glassBg,n.style.borderColor=this.colors.border,n.style.color=this.colors.textTertiary,n.style.fontWeight="500"}updateSubmitState(){let e=this.selectedType!==null&&this.textarea.value.trim().length>0;this.submitBtn.disabled=!e,this.submitBtn.style.opacity=e?"1":"0.35",this.submitBtn.style.pointerEvents=e?"auto":"none"}submit(){!this.selectedType||!this.textarea.value.trim()||(this.resolve?.({type:this.selectedType,message:this.textarea.value.trim()}),this.resolve=null,this.hideElement())}cancel(){this.resolve?.(null),this.resolve=null,this.hideElement()}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none"},250)}destroy(){this.root.remove()}};var Q=class{constructor(e,n,i){this.colors=e;this.bus=n;this.t=i;this.popup=new V(e,i),this.bus.on("annotation:start",()=>this.activate())}colors;bus;t;overlay=null;toolbar=null;drawingRect=null;startX=0;startY=0;isDrawing=!1;isActive=!1;popup;savedOverflow="";preActiveFocusElement=null;rafId=null;pendingMoveEvent=null;activate(){if(this.isActive)return;this.isActive=!0,this.preActiveFocusElement=document.activeElement,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=h("div",{style:`
94
94
  position:fixed;inset:0;
95
95
  z-index:2147483646;
96
96
  background:rgba(15, 23, 42, 0.04);
97
97
  cursor:crosshair;
98
- `}),this.overlay.setAttribute("aria-hidden","true"),this.toolbar=u("div",{style:`
98
+ `}),this.overlay.setAttribute("aria-hidden","true"),this.toolbar=h("div",{style:`
99
99
  position:fixed;top:0;left:0;right:0;
100
100
  z-index:2147483647;
101
101
  height:52px;
102
- background:rgba(255, 255, 255, 0.82);
102
+ background:${this.colors.glassBg};
103
103
  backdrop-filter:blur(24px);
104
104
  -webkit-backdrop-filter:blur(24px);
105
- border-bottom:1px solid rgba(255, 255, 255, 0.35);
105
+ border-bottom:1px solid ${this.colors.glassBorder};
106
106
  display:flex;align-items:center;justify-content:center;gap:16px;
107
107
  font-family:"Inter",system-ui,-apple-system,sans-serif;
108
- font-size:14px;color:#0f172a;
109
- box-shadow:0 4px 16px rgba(0,0,0,0.06);
108
+ font-size:14px;color:${this.colors.text};
109
+ box-shadow:0 4px 16px ${this.colors.shadow};
110
110
  -webkit-font-smoothing:antialiased;
111
- `});let e=u("span",{style:`
111
+ `});let e=h("span",{style:`
112
112
  width:8px;height:8px;border-radius:50%;
113
113
  background:${this.colors.accent};
114
114
  box-shadow:0 0 8px ${this.colors.accentGlow};
115
115
  animation:pulse 1.5s ease-in-out infinite;
116
- `}),t=document.createElement("style");t.textContent="@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}",this.toolbar.appendChild(t);let i=u("span",{style:"font-weight:500;letter-spacing:-0.01em;"});m(i,this.t("annotator.instruction"));let s=document.createElement("button");s.style.cssText=`
116
+ `}),n=document.createElement("style");n.textContent=["@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}","@media(prefers-reduced-motion:reduce){@keyframes pulse{from,to{opacity:1}}}"].join(""),this.toolbar.appendChild(n);let i=h("span",{style:"font-weight:500;letter-spacing:-0.01em;"});b(i,this.t("annotator.instruction"));let s=document.createElement("button");s.style.cssText=`
117
117
  height:34px;padding:0 18px;border-radius:9999px;
118
- border:1px solid #e2e8f0;
119
- background:rgba(255,255,255,0.8);
120
- color:#64748b;font-family:"Inter",system-ui,-apple-system,sans-serif;
118
+ border:1px solid ${this.colors.border};
119
+ background:${this.colors.glassBg};
120
+ color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
121
121
  font-size:13px;font-weight:500;cursor:pointer;
122
122
  transition:all 0.2s ease;
123
- `,m(s,this.t("annotator.cancel")),s.addEventListener("click",()=>this.deactivate()),s.addEventListener("mouseenter",()=>{s.style.borderColor="#ef4444",s.style.color="#ef4444",s.style.background="rgba(239,68,68,0.06)"}),s.addEventListener("mouseleave",()=>{s.style.borderColor="#e2e8f0",s.style.color="#64748b",s.style.background="rgba(255,255,255,0.8)"}),this.toolbar.appendChild(e),this.toolbar.appendChild(i),this.toolbar.appendChild(s),this.overlay.addEventListener("mousedown",this.onMouseDown),this.overlay.addEventListener("mousemove",this.onMouseMove),this.overlay.addEventListener("mouseup",this.onMouseUp),document.addEventListener("keydown",this.onKeyDown),document.body.appendChild(this.overlay),document.body.appendChild(this.toolbar)}deactivate(){this.isActive&&(this.isActive=!1,this.isDrawing=!1,document.body.style.overflow=this.savedOverflow,document.removeEventListener("keydown",this.onKeyDown),this.overlay?.remove(),this.toolbar?.remove(),this.drawingRect?.remove(),this.overlay=null,this.toolbar=null,this.drawingRect=null,this.bus.emit("annotation:end"))}onKeyDown=e=>{e.key==="Escape"&&this.deactivate()};onMouseDown=e=>{this.isDrawing=!0,this.startX=e.clientX,this.startY=e.clientY,this.drawingRect?.remove(),this.drawingRect=u("div",{style:`
123
+ `,b(s,this.t("annotator.cancel")),s.addEventListener("click",()=>this.deactivate()),s.addEventListener("mouseenter",()=>{s.style.borderColor=this.colors.typeBug,s.style.color=this.colors.typeBug,s.style.background=this.colors.typeBugBg}),s.addEventListener("mouseleave",()=>{s.style.borderColor=this.colors.border,s.style.color=this.colors.textTertiary,s.style.background=this.colors.glassBg}),this.toolbar.appendChild(e),this.toolbar.appendChild(i),this.toolbar.appendChild(s),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:!1}),this.overlay.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.overlay.addEventListener("touchend",this.onTouchEnd),this.overlay.addEventListener("keydown",this.onOverlayKeyDown),this.overlay.setAttribute("tabindex","0"),document.addEventListener("keydown",this.onKeyDown),document.body.appendChild(this.overlay),document.body.appendChild(this.toolbar)}deactivate(){this.isActive&&(this.isActive=!1,this.isDrawing=!1,this.preActiveFocusElement=null,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingMoveEvent=null,document.body.style.overflow=this.savedOverflow,document.removeEventListener("keydown",this.onKeyDown),this.overlay?.remove(),this.toolbar?.remove(),this.drawingRect?.remove(),this.overlay=null,this.toolbar=null,this.drawingRect=null,this.bus.emit("annotation:end"))}onKeyDown=e=>{e.key==="Escape"&&this.deactivate()};onOverlayKeyDown=async e=>{if(e.key!=="Enter")return;e.preventDefault();let n=this.preActiveFocusElement;if(!n||!(n instanceof HTMLElement))return;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let s=new DOMRect(i.x,i.y,i.width,i.height),o=await this.popup.show(s);if(!o)return;let a={anchor:pe(n),rect:{xPct:0,yPct:0,wPct:1,hPct:1},scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio};this.deactivate(),this.bus.emit("annotation:complete",{annotation:a,type:o.type,message:o.message})};onMouseDown=e=>{this.startDrawing(e.clientX,e.clientY)};onTouchStart=e=>{e.preventDefault();let n=e.touches[0];n&&this.startDrawing(n.clientX,n.clientY)};startDrawing(e,n){this.isDrawing=!0,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=h("div",{style:`
124
124
  position:fixed;
125
125
  border:2px solid ${this.colors.accent};
126
126
  background:${this.colors.accent}12;
@@ -128,7 +128,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
128
128
  border-radius:8px;
129
129
  box-shadow:0 0 16px ${this.colors.accentGlow};
130
130
  transition:box-shadow 0.15s ease;
131
- `}),this.overlay?.appendChild(this.drawingRect)};onMouseMove=e=>{if(!this.isDrawing||!this.drawingRect)return;let t=Math.min(e.clientX,this.startX),i=Math.min(e.clientY,this.startY),s=Math.abs(e.clientX-this.startX),r=Math.abs(e.clientY-this.startY);this.drawingRect.style.left=`${t}px`,this.drawingRect.style.top=`${i}px`,this.drawingRect.style.width=`${s}px`,this.drawingRect.style.height=`${r}px`};onMouseUp=async e=>{if(!this.isDrawing||!this.drawingRect)return;this.isDrawing=!1;let t=Math.min(e.clientX,this.startX),i=Math.min(e.clientY,this.startY),s=Math.abs(e.clientX-this.startX),r=Math.abs(e.clientY-this.startY);if(s<10||r<10){this.drawingRect.remove(),this.drawingRect=null;return}let o=new DOMRect(t,i,s,r),a=await this.popup.show(o);if(!a){this.drawingRect?.remove(),this.drawingRect=null;return}let l=this.buildAnnotation(o);this.drawingRect?.remove(),this.drawingRect=null,this.deactivate(),this.bus.emit("annotation:complete",{annotation:l,type:a.type,message:a.message})};buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let t=Se(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Te(t),s=t.getBoundingClientRect(),r=Ae(e,s);return{anchor:i,rect:r,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.popup.destroy()}};var $="siteping_retry_queue";async function N(n,e,t=3){for(let i=0;i<=t;i++){let s=new AbortController,r=setTimeout(()=>s.abort(),1e4);try{let l=await fetch(n,{...e,signal:s.signal});if(clearTimeout(r),l.ok||l.status>=400&&l.status<500||i===t)return l}catch(l){if(clearTimeout(r),i===t)throw l}let o=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,o+a))}throw new Error("Max retries exceeded")}function yt(n,e){try{let t=localStorage.getItem($),i=t?JSON.parse(t):[];i.push({endpoint:n,payload:e}),localStorage.setItem($,JSON.stringify(i))}catch{}}async function je(n){try{let e=localStorage.getItem($);if(!e)return;let t=JSON.parse(e),i=t.filter(a=>a.endpoint===n);if(i.length===0)return;let r=(await Promise.allSettled(i.map(a=>fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.payload)}).then(l=>({entry:a,ok:l.ok}))))).map((a,l)=>a.status==="rejected"||!a.value.ok?i[l]:null).filter(a=>a!==null),o=t.filter(a=>a.endpoint!==n).concat(r);o.length>0?localStorage.setItem($,JSON.stringify(o)):localStorage.removeItem($)}catch{}}var X=class{constructor(e){this.endpoint=e}endpoint;async sendFeedback(e){try{let t=await N(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let i=await t.text().catch(()=>"Unknown error");throw new Error(`Failed to send feedback: ${t.status} ${i}`)}return await t.json()}catch(t){throw yt(this.endpoint,e),t}}async getFeedbacks(e,t){let i=new URLSearchParams({projectName:e});t?.page&&i.set("page",String(t.page)),t?.limit&&i.set("limit",String(t.limit)),t?.type&&i.set("type",t.type),t?.status&&i.set("status",t.status),t?.search&&i.set("search",t.search);let s=await N(`${this.endpoint}?${i.toString()}`,{method:"GET"});if(!s.ok)throw new Error(`Failed to fetch feedbacks: ${s.status}`);return await s.json()}async resolveFeedback(e,t){let i=await N(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,status:t?"resolved":"open"})});if(!i.ok)throw new Error(`Failed to update feedback: ${i.status}`);return await i.json()}async deleteFeedback(e){let t=await N(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})});if(!t.ok)throw new Error(`Failed to delete feedback: ${t.status}`)}async deleteAllFeedbacks(e){let t=await N(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});if(!t.ok)throw new Error(`Failed to delete all feedbacks: ${t.status}`)}};var D=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set);let i=this.listeners.get(e);return i.add(t),()=>{i.delete(t)}}off(e,t){let i=this.listeners.get(e);i&&i.delete(t)}emit(e,...t){let i=this.listeners.get(e);if(i)for(let s of i)try{s(...t)}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r)}}removeAll(){this.listeners.clear()}};var vt=54,V=class{constructor(e,t,i,s){this.bus=i;let r=t.position??"bottom-right",o=r==="bottom-right";this.items=[{id:"chat",icon:Le,label:s("fab.messages")},{id:"annotate",icon:Me,label:s("fab.annotate")},{id:"toggle-annotations",icon:re,iconAlt:oe,label:s("fab.annotations")}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${r} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(C(se)),this.fab.setAttribute("aria-label",s("fab.aria")),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${r}`,this.radialContainer.setAttribute("role","menu");for(let p=0;p<this.items.length;p++){let d=this.items[p],c=document.createElement("button");c.className="sp-radial-item",c.style.setProperty("--sp-i",String(p)),c.appendChild(C(d.icon)),c.setAttribute("role","menuitem"),c.setAttribute("aria-label",d.label),c.dataset.itemId=d.id,c.addEventListener("click",b=>{b.stopPropagation(),this.handleItemClick(d.id)});let h=document.createElement("span");h.className="sp-radial-label",h.textContent=d.label,h.style.cssText=o?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",c.appendChild(h),this.radialContainer.appendChild(c)}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root);let a=e.host;this.onDocumentClick=p=>{this.isOpen&&!p.composedPath().includes(a)&&this.close()},document.addEventListener("click",this.onDocumentClick);let l=p=>{p.key==="Escape"&&this.isOpen&&(p.stopPropagation(),this.close())};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",p=>{let d=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(d.length===0||!this.isOpen)return;let c=e.activeElement??document.activeElement,h=d.indexOf(c);switch(p.key){case"ArrowUp":{p.preventDefault();let b=h<=0?d.length-1:h-1;d[b].focus();break}case"ArrowDown":{p.preventDefault();let b=h>=d.length-1?0:h+1;d[b].focus();break}case"Home":{p.preventDefault(),d[0].focus();break}case"End":{p.preventDefault(),d[d.length-1].focus();break}}})}bus;root;fab;radialContainer;badgeEl=null;isOpen=!1;annotationsVisible=!0;items;onDocumentClick;updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null;return}this.badgeEl||(this.badgeEl=document.createElement("span"),this.badgeEl.className="sp-fab-badge",this.fab.appendChild(this.badgeEl)),m(this.badgeEl,e>99?"99+":String(e))}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.setFabIcon(K),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((t,i)=>{let s=-(16+vt*(i+1));t.style.transform=`translate(0px, ${s}px) scale(1)`,t.classList.add("sp-radial-item--open")}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus()})}close(){this.isOpen=!1,this.setFabIcon(se),this.fab.setAttribute("aria-expanded","false"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach(t=>{t.style.transform="translate(0, 0) scale(0.8)",t.classList.remove("sp-radial-item--open")}),this.fab.focus()}setFabIcon(e){let t=this.badgeEl;this.fab.replaceChildren(C(e)),t&&this.fab.appendChild(t)}handleItemClick(e){switch(this.close(),e){case"chat":this.bus.emit("panel:toggle",!0);break;case"annotate":this.bus.emit("annotation:start");break;case"toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let t=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]');t&&t.replaceChildren(C(this.annotationsVisible?re:oe));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove()}};var _e={"panel.title":"Feedbacks","panel.close":"Close panel","panel.deleteAll":"Delete all","panel.deleteAllConfirmTitle":"Delete all","panel.deleteAllConfirmMessage":"Delete all feedbacks for this project? This action cannot be undone.","panel.search":"Search...","panel.searchAria":"Search feedbacks","panel.filterAll":"All","panel.loadError":"Failed to load","panel.retry":"Retry","panel.empty":"No feedback yet","panel.showMore":"Show more","panel.showLess":"Show less","panel.resolve":"Resolve","panel.reopen":"Reopen","panel.delete":"Delete","panel.cancel":"Cancel","panel.confirmDelete":"Delete","type.question":"Question","type.change":"Change","type.bug":"Bug","type.other":"Other","fab.aria":"Siteping \u2014 Feedback menu","fab.messages":"Messages","fab.annotate":"Annotate","fab.annotations":"Annotations","annotator.instruction":"Draw a rectangle on the area to comment","annotator.cancel":"Cancel","popup.placeholder":"Describe your feedback...","popup.textareaAria":"Feedback message","popup.submitHintMac":"\u2318+Enter to send","popup.submitHintOther":"Ctrl+Enter to send","popup.cancel":"Cancel","popup.submit":"Send","identity.title":"Identify yourself","identity.nameLabel":"Name","identity.namePlaceholder":"Your name","identity.emailLabel":"Email","identity.emailPlaceholder":"your@email.com","identity.cancel":"Cancel","identity.submit":"Continue","marker.approximate":"Approximate position (confidence: {confidence}%)"};var Ye={"panel.title":"Feedbacks","panel.close":"Fermer le panneau","panel.deleteAll":"Tout supprimer","panel.deleteAllConfirmTitle":"Tout supprimer","panel.deleteAllConfirmMessage":"Supprimer tous les feedbacks de ce projet ? Cette action est irr\xE9versible.","panel.search":"Rechercher...","panel.searchAria":"Rechercher dans les feedbacks","panel.filterAll":"Tous","panel.loadError":"Erreur de chargement","panel.retry":"R\xE9essayer","panel.empty":"Aucun feedback pour le moment","panel.showMore":"Voir plus","panel.showLess":"Voir moins","panel.resolve":"R\xE9soudre","panel.reopen":"Rouvrir","panel.delete":"Supprimer","panel.cancel":"Annuler","panel.confirmDelete":"Supprimer","type.question":"Question","type.change":"Changement","type.bug":"Bug","type.other":"Autre","fab.aria":"Siteping \u2014 Menu feedback","fab.messages":"Messages","fab.annotate":"Annoter","fab.annotations":"Annotations","annotator.instruction":"Tracez un rectangle sur la zone \xE0 commenter","annotator.cancel":"Annuler","popup.placeholder":"D\xE9crivez votre retour...","popup.textareaAria":"Message de feedback","popup.submitHintMac":"\u2318+Entr\xE9e pour envoyer","popup.submitHintOther":"Ctrl+Entr\xE9e pour envoyer","popup.cancel":"Annuler","popup.submit":"Envoyer","identity.title":"Identifiez-vous","identity.nameLabel":"Nom","identity.namePlaceholder":"Votre nom","identity.emailLabel":"Email","identity.emailPlaceholder":"votre@email.com","identity.cancel":"Annuler","identity.submit":"Continuer","marker.approximate":"Position approximative (confiance : {confidence}%)"};var qe={fr:Ye,en:_e};function U(n){let e=n.split("-")[0].toLowerCase(),t=qe[e]??qe.fr;return i=>t[i]??i}function B(n,e){switch(n){case"question":return e("type.question");case"change":return e("type.change");case"bug":return e("type.bug");case"other":return e("type.other");default:return n}}var Ke="siteping_identity";function We(){try{let n=localStorage.getItem(Ke);if(!n)return null;let e=JSON.parse(n);return e.name&&e.email?e:null}catch{return null}}function Ge(n){try{localStorage.setItem(Ke,JSON.stringify(n))}catch{}}function xt(n,e){if(n===e)return 0;if(n.length===0)return e.length;if(e.length===0)return n.length;if(n.length>e.length){let o=n;n=e,e=o}let t=n.length,i=e.length,s=new Array(t+1);for(let o=0;o<=t;o++)s[o]=o;let r=new Array(t+1);for(let o=1;o<=i;o++){r[0]=o;for(let l=1;l<=t;l++)r[l]=n[l-1]===e[o-1]?s[l-1]:1+Math.min(s[l-1],s[l],r[l-1]);let a=s;s=r,r=a}return s[t]}function R(n,e){if(n===e)return 1;let t=Math.max(n.length,e.length);return t===0?1:1-xt(n,e)/t}function le(n,e,t=.6){if(!e||!n)return 0;if(n.includes(e))return 1;let i=e.length;if(i>n.length){let a=R(n,e);return a>=t?a:0}let s=0,r=n.length>500?n.slice(0,500):n,o=r.length-i;for(let a=0;a<=o;a++){let l=r.slice(a,a+i),p=R(l,e);if(p>s&&(s=p),s>=.95)break}return s>=t?s:0}var wt=300,kt=.3;function pe(n,e){if(!e.textSnippet)return!0;let t=(n.textContent?.trim()??"").slice(0,500);return le(t,e.textSnippet,.5)>kt}function Et(n){if(n.elementId){let e=document.getElementById(n.elementId);if(e&&e.tagName===n.elementTag&&pe(e,n))return{element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(n.cssSelector);if(e&&e.tagName===n.elementTag&&pe(e,n))return{element:e,confidence:.95,strategy:"css"}}catch{}try{let t=document.evaluate(n.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(t instanceof Element&&t.tagName===n.elementTag&&pe(t,n))return{element:t,confidence:.9,strategy:"xpath"}}catch{}return Ct(n)}function Ct(n){let e=n.elementTag.toLowerCase(),t=document.querySelectorAll(e);if(t.length===0)return null;let i=null,s=0,r=Math.min(t.length,wt);for(let o=0;o<r;o++){let a=t[o],l=Tt(a,n);if(l>s&&(s=l,i=a,s>=.85))break}return!i||s<.4?null:{element:i,confidence:Math.min(s,.85),strategy:"scan"}}function Tt(n,e){let t=0,i=0,s=(n.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,t+=le(s,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,t+=Ee(n,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let r=0,o=0;if(e.textPrefix){let a=I(n,"before");r+=a?R(a,e.textPrefix):0,o++}if(e.textSuffix){let a=I(n,"after");r+=a?R(a,e.textSuffix):0,o++}o>0&&(t+=r/o*20)}if(e.neighborText){i+=20;let r=Y(n);t+=r?R(r,e.neighborText)*20:0}return i>0?t/i:0}function Q(n,e){let t=Et(n);if(!t)return null;let i=t.element.getBoundingClientRect(),s=new DOMRect(i.x+e.xPct*i.width,i.y+e.yPct*i.height,e.wPct*i.width,e.hPct*i.height);return{element:t.element,rect:s,confidence:t.confidence,strategy:t.strategy}}function ce(n){return{cssSelector:n.cssSelector,xpath:n.xpath,textSnippet:n.textSnippet,elementTag:n.elementTag,elementId:n.elementId??void 0,textPrefix:n.textPrefix,textSuffix:n.textSuffix,fingerprint:n.fingerprint,neighborText:n.neighborText}}function de(n){return{xPct:n.xPct,yPct:n.yPct,wPct:n.wPct,hPct:n.hPct}}var Xe=13;function Ve(n){return{top:n.top+window.scrollY-Xe,left:n.right+window.scrollX-Xe}}function O(n,e){return n.entries[e].elements[n.elementIndices[e]]}var Ue=300,St=200,At=.7,Lt=28,Qe=32,J=class{constructor(e,t,i,s){this.colors=e;this.tooltip=t;this.bus=i;this.t=s;this.container=u("div",{style:"position:absolute;top:0;left:0;pointer-events:none;z-index:2147483646;"}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",r=>{this.container.style.display=r?"block":"none"}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:!0}),this.mutationObserver=new MutationObserver(r=>{r.every(a=>this.container.contains(a.target)||this.tooltip.contains(a.target))||this.scheduleReposition()}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1}),this.onDocumentClickForClusters=r=>{this.container.contains(r.target)||this.collapseAllClusters()},document.addEventListener("click",this.onDocumentClickForClusters)}colors;tooltip;bus;t;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;resizeHandler=null;clusters=[];onDocumentClickForClusters=null;get count(){return this.entries.length}scheduleReposition(){this.repositionTimer||(this.repositionTimer=setTimeout(()=>{this.repositionTimer=null,this.repositionAll()},St))}repositionAll(){for(let e of this.entries)for(let t=0;t<e.feedback.annotations.length;t++){let i=e.elements[t];if(!i)continue;let s=e.feedback.annotations[t],r=Q(ce(s),de(s));if(!r){i.style.display="none";continue}let o=Ve(r.rect);e.baseTop=o.top,e.baseLeft=o.left,i.style.display="flex",this.applyConfidenceStyle(i,r.confidence,e.feedback)}this.applyClusterPositions()}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e)}render(e){this.clear(),e.forEach((t,i)=>{let s=this.buildEntry(t,i+1);this.entries.push(s)}),this.buildClusters()}addFeedback(e,t){let i=this.buildEntry(e,t);for(let s of i.elements)s.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters()}buildEntry(e,t){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let s of e.annotations){let r=Q(ce(s),de(s));if(!r)continue;let o=Ve(r.rect);i.baseTop=o.top,i.baseLeft=o.left;let a=this.createMarker(t,e,o);this.applyConfidenceStyle(a,r.confidence,e),this.container.appendChild(a),i.elements.push(a)}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let s=0;s<i.elements.length;s++)e.push({entry:i,elIdx:s});let t=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(t.has(i))continue;let s={entries:[e[i].entry],elementIndices:[e[i].elIdx],expanded:!1};t.add(i);for(let r=i+1;r<e.length;r++){if(t.has(r))continue;let o=e[i].entry,a=e[r].entry;Math.sqrt((o.baseLeft-a.baseLeft)**2+(o.baseTop-a.baseTop)**2)<Lt&&(s.entries.push(a),s.elementIndices.push(e[r].elIdx),t.add(r))}this.clusters.push(s)}for(let i of this.clusters)i.entries.length<=1||(this.applyStackPositions(i),this.addClusterBadge(i))}applyStackPositions(e){let{baseTop:t,baseLeft:i}=e.entries[0],s=e.entries.length<=1;for(let r=0;r<e.entries.length;r++){let o=O(e,r);o&&(o.style.top=`${t+(s?0:r*3)}px`,o.style.left=`${i+(s?0:r*3)}px`,o.style.zIndex=String(r+1))}}applyFanPositions(e){let{baseTop:t,baseLeft:i}=e.entries[0],s=e.entries.length,r=(s-1)*Qe,o=i-r/2;for(let a=0;a<s;a++){let l=O(e,a);l&&(l.style.top=`${t}px`,l.style.left=`${o+a*Qe}px`,l.style.zIndex=String(10+a))}}addClusterBadge(e){let t=O(e,e.entries.length-1);if(!t)return;let i=u("div",{class:"sp-cluster-badge",style:`
131
+ `}),this.overlay?.appendChild(this.drawingRect)}onMouseMove=e=>{this.scheduleRectUpdate(e)};onTouchMove=e=>{e.preventDefault(),e.touches[0]&&this.scheduleRectUpdate(e.touches[0])};scheduleRectUpdate(e){!this.isDrawing||!this.drawingRect||(this.pendingMoveEvent=e,this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;let n=this.pendingMoveEvent;if(!n||!this.drawingRect)return;let i=Math.min(n.clientX,this.startX),s=Math.min(n.clientY,this.startY),o=Math.abs(n.clientX-this.startX),r=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${s}px`,this.drawingRect.style.width=`${o}px`,this.drawingRect.style.height=`${r}px`})))}onTouchEnd=async e=>{let n=e.changedTouches[0];n&&await this.finishDrawing(n.clientX,n.clientY)};onMouseUp=async e=>{await this.finishDrawing(e.clientX,e.clientY)};finishDrawing=async(e,n)=>{if(!this.isDrawing||!this.drawingRect)return;this.isDrawing=!1;let i=Math.min(e,this.startX),s=Math.min(n,this.startY),o=Math.abs(e-this.startX),r=Math.abs(n-this.startY);if(o<10||r<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(i,s,o,r),l=await this.popup.show(a);if(!l){this.drawingRect?.remove(),this.drawingRect=null;return}let c=this.buildAnnotation(a);this.drawingRect?.remove(),this.drawingRect=null,this.deactivate(),this.bus.emit("annotation:complete",{annotation:c,type:l.type,message:l.message})};buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=$e(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=pe(n),s=n.getBoundingClientRect(),o=De(e,s);return{anchor:i,rect:o,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.popup.destroy()}};var H="siteping_retry_queue";async function D(t,e,n=3){for(let i=0;i<=n;i++){let s=new AbortController,o=setTimeout(()=>s.abort(),1e4);try{let l=await fetch(t,{...e,signal:s.signal});if(clearTimeout(o),l.ok||l.status>=400&&l.status<500||i===n)return l}catch(l){if(clearTimeout(o),i===n)throw l}let r=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,r+a))}throw new Error("Max retries exceeded")}function Ft(t,e){try{let n=localStorage.getItem(H),i=n?JSON.parse(n):[],s=Array.isArray(i)?i:[];s.length>=20&&s.shift(),s.push({endpoint:t,payload:e}),localStorage.setItem(H,JSON.stringify(s))}catch{}}async function Qe(t){try{let e=localStorage.getItem(H);if(!e)return;let n=JSON.parse(e),i=Array.isArray(n)?n:[],s=i.filter(a=>a.endpoint===t);if(s.length===0)return;let o=[];for(let a of s)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.payload)})).ok||o.push(a)}catch{o.push(a)}let r=i.filter(a=>a.endpoint!==t).concat(o);r.length>0?localStorage.setItem(H,JSON.stringify(r)):localStorage.removeItem(H)}catch{}}var J=class{constructor(e,n){this.endpoint=e;this.projectName=n}endpoint;projectName;async sendFeedback(e){try{let n=await D(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){let i=await n.text().catch(()=>"Unknown error");throw new Error(`Failed to send feedback: ${n.status} ${i}`)}return await n.json()}catch(n){throw Ft(this.endpoint,e),n}}async getFeedbacks(e,n){let i=new URLSearchParams({projectName:e});n?.page&&i.set("page",String(n.page)),n?.limit&&i.set("limit",String(n.limit)),n?.type&&i.set("type",n.type),n?.status&&i.set("status",n.status),n?.search&&i.set("search",n.search);let s=await D(`${this.endpoint}?${i.toString()}`,{method:"GET"});if(!s.ok)throw new Error(`Failed to fetch feedbacks: ${s.status}`);return await s.json()}async resolveFeedback(e,n){let i=await D(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});if(!i.ok)throw new Error(`Failed to update feedback: ${i.status}`);return await i.json()}async deleteFeedback(e){let n=await D(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});if(!n.ok)throw new Error(`Failed to delete feedback: ${n.status}`)}async deleteAllFeedbacks(e){let n=await D(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});if(!n.ok)throw new Error(`Failed to delete all feedbacks: ${n.status}`)}};var O=class{listeners=new Map;on(e,n){this.listeners.has(e)||this.listeners.set(e,new Set);let i=this.listeners.get(e);return i.add(n),()=>{i.delete(n)}}off(e,n){let i=this.listeners.get(e);i&&i.delete(n)}emit(e,...n){let i=this.listeners.get(e);if(i)for(let s of i)try{s(...n)}catch(o){console.error(`[siteping] Error in event listener for "${String(e)}":`,o)}}removeAll(){this.listeners.clear()}};var Lt=54,Z=class{constructor(e,n,i,s){this.bus=i;this.t=s;let o=n.position??"bottom-right",r=o==="bottom-right";this.items=[{id:"chat",icon:He,label:s("fab.messages")},{id:"annotate",icon:Oe,label:s("fab.annotate")},{id:"toggle-annotations",icon:he,iconAlt:fe,label:s("fab.annotations")}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${o} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(F(ue)),this.fab.setAttribute("aria-label",s("fab.aria")),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${o}`,this.radialContainer.setAttribute("role","menu");for(let c=0;c<this.items.length;c++){let d=this.items[c];if(!d)continue;let p=document.createElement("button");p.className="sp-radial-item",p.style.setProperty("--sp-i",String(c)),p.appendChild(F(d.icon)),p.setAttribute("role","menuitem"),p.setAttribute("aria-label",d.label),p.dataset.itemId=d.id,p.addEventListener("click",m=>{m.stopPropagation(),this.handleItemClick(d.id)});let f=document.createElement("span");f.className="sp-radial-label",f.textContent=d.label,f.style.cssText=r?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",p.appendChild(f),this.radialContainer.appendChild(p)}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root);let a=e.host;this.onDocumentClick=c=>{this.isOpen&&!c.composedPath().includes(a)&&this.close()},document.addEventListener("click",this.onDocumentClick);let l=c=>{c.key==="Escape"&&this.isOpen&&(c.stopPropagation(),this.close())};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",c=>{let d=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(d.length===0||!this.isOpen)return;let p=e.activeElement??document.activeElement,f=d.indexOf(p);switch(c.key){case"ArrowUp":{c.preventDefault();let m=f<=0?d.length-1:f-1;d[m]?.focus();break}case"ArrowDown":{c.preventDefault();let m=f>=d.length-1?0:f+1;d[m]?.focus();break}case"Home":{c.preventDefault(),d[0]?.focus();break}case"End":{c.preventDefault(),d[d.length-1]?.focus();break}}})}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=!1;annotationsVisible=!0;items;onDocumentClick;updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null;return}this.badgeEl||(this.badgeEl=document.createElement("span"),this.badgeEl.className="sp-fab-badge",this.badgeEl.setAttribute("role","status"),this.badgeEl.setAttribute("aria-live","polite"),this.fab.appendChild(this.badgeEl));let n=e>99?"99+":String(e);b(this.badgeEl,n),this.badgeEl.setAttribute("aria-label",this.t("fab.badge").replace("{count}",String(e)))}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.setFabIcon(G),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let s=-(16+Lt*(i+1));n.style.transform=`translate(0px, ${s}px) scale(1)`,n.classList.add("sp-radial-item--open")}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus()})}close(){this.isOpen=!1,this.setFabIcon(ue),this.fab.setAttribute("aria-expanded","false"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach(n=>{n.style.transform="translate(0, 0) scale(0.8)",n.classList.remove("sp-radial-item--open")}),this.fab.focus()}setFabIcon(e){let n=this.badgeEl;this.fab.replaceChildren(F(e)),n&&this.fab.appendChild(n)}handleItemClick(e){switch(this.close(),e){case"chat":this.bus.emit("panel:toggle",!0);break;case"annotate":this.bus.emit("annotation:start");break;case"toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let n=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]');n&&n.replaceChildren(F(this.annotationsVisible?he:fe));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove()}};var Je={"panel.title":"Feedbacks","panel.ariaLabel":"Siteping feedback panel","panel.feedbackList":"Feedback list","panel.loading":"Loading feedbacks","panel.close":"Close panel","panel.deleteAll":"Delete all","panel.deleteAllConfirmTitle":"Delete all","panel.deleteAllConfirmMessage":"Delete all feedbacks for this project? This action cannot be undone.","panel.search":"Search...","panel.searchAria":"Search feedbacks","panel.filterAll":"All","panel.loadError":"Failed to load","panel.retry":"Retry","panel.empty":"No feedback yet","panel.showMore":"Show more","panel.showLess":"Show less","panel.resolve":"Resolve","panel.reopen":"Reopen","panel.delete":"Delete","panel.cancel":"Cancel","panel.confirmDelete":"Delete","type.question":"Question","type.change":"Change","type.bug":"Bug","type.other":"Other","fab.aria":"Siteping \u2014 Feedback menu","fab.messages":"Messages","fab.annotate":"Annotate","fab.annotations":"Annotations","annotator.instruction":"Draw a rectangle on the area to comment","annotator.cancel":"Cancel","popup.ariaLabel":"Feedback form","popup.placeholder":"Describe your feedback...","popup.textareaAria":"Feedback message","popup.submitHintMac":"\u2318+Enter to send","popup.submitHintOther":"Ctrl+Enter to send","popup.cancel":"Cancel","popup.submit":"Send","identity.title":"Identify yourself","identity.nameLabel":"Name","identity.namePlaceholder":"Your name","identity.emailLabel":"Email","identity.emailPlaceholder":"your@email.com","identity.cancel":"Cancel","identity.submit":"Continue","marker.approximate":"Approximate position (confidence: {confidence}%)","marker.aria":"Feedback #{number}: {type} \u2014 {message}","fab.badge":"{count} unresolved feedbacks","feedback.sent.confirmation":"Feedback sent successfully","feedback.error.message":"Failed to send feedback","feedback.deleted.confirmation":"Feedback deleted","badge.count":"{count} unresolved feedbacks"};var Ze={"panel.title":"Feedbacks","panel.ariaLabel":"Panneau de feedback Siteping","panel.feedbackList":"Liste des feedbacks","panel.loading":"Chargement des feedbacks","panel.close":"Fermer le panneau","panel.deleteAll":"Tout supprimer","panel.deleteAllConfirmTitle":"Tout supprimer","panel.deleteAllConfirmMessage":"Supprimer tous les feedbacks de ce projet ? Cette action est irr\xE9versible.","panel.search":"Rechercher...","panel.searchAria":"Rechercher dans les feedbacks","panel.filterAll":"Tous","panel.loadError":"Erreur de chargement","panel.retry":"R\xE9essayer","panel.empty":"Aucun feedback pour le moment","panel.showMore":"Voir plus","panel.showLess":"Voir moins","panel.resolve":"R\xE9soudre","panel.reopen":"Rouvrir","panel.delete":"Supprimer","panel.cancel":"Annuler","panel.confirmDelete":"Supprimer","type.question":"Question","type.change":"Changement","type.bug":"Bug","type.other":"Autre","fab.aria":"Siteping \u2014 Menu feedback","fab.messages":"Messages","fab.annotate":"Annoter","fab.annotations":"Annotations","annotator.instruction":"Tracez un rectangle sur la zone \xE0 commenter","annotator.cancel":"Annuler","popup.ariaLabel":"Formulaire de feedback","popup.placeholder":"D\xE9crivez votre retour...","popup.textareaAria":"Message de feedback","popup.submitHintMac":"\u2318+Entr\xE9e pour envoyer","popup.submitHintOther":"Ctrl+Entr\xE9e pour envoyer","popup.cancel":"Annuler","popup.submit":"Envoyer","identity.title":"Identifiez-vous","identity.nameLabel":"Nom","identity.namePlaceholder":"Votre nom","identity.emailLabel":"Email","identity.emailPlaceholder":"votre@email.com","identity.cancel":"Annuler","identity.submit":"Continuer","marker.approximate":"Position approximative (confiance : {confidence}%)","marker.aria":"Feedback n\xB0{number} : {type} \u2014 {message}","fab.badge":"{count} feedbacks non r\xE9solus","feedback.sent.confirmation":"Feedback envoy\xE9 avec succ\xE8s","feedback.error.message":"\xC9chec de l'envoi du feedback","feedback.deleted.confirmation":"Feedback supprim\xE9","badge.count":"{count} feedbacks non r\xE9solus"};var ge={fr:Ze,en:Je};function ee(t){let e=(t.split("-")[0]??t).toLowerCase();ge[e]||console.warn(`[siteping] Unknown locale "${t}", falling back to "en"`);let n=ge[e]??ge.en??{};return i=>n[i]??i}function B(t,e){switch(t){case"question":return e("type.question");case"change":return e("type.change");case"bug":return e("type.bug");case"other":return e("type.other");default:return t}}var et="siteping_identity";function tt(){try{let t=localStorage.getItem(et);if(!t)return null;let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"name"in e&&typeof e.name=="string"&&"email"in e&&typeof e.email=="string"){let n=e;if(n.name&&n.email)return n}return null}catch{return null}}function nt(t){try{localStorage.setItem(et,JSON.stringify(t))}catch{}}function Mt(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let r=t;t=e,e=r}let n=t.length,i=e.length,s=new Array(n+1);for(let r=0;r<=n;r++)s[r]=r;let o=new Array(n+1);for(let r=1;r<=i;r++){o[0]=r;for(let l=1;l<=n;l++){let c=s[l-1]??0;o[l]=t[l-1]===e[r-1]?c:1+Math.min(c,s[l]??0,o[l-1]??0)}let a=s;s=o,o=a}return s[n]??0}function $(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-Mt(t,e)/n}function be(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let a=$(t,e);return a>=n?a:0}let s=0,o=t.length>500?t.slice(0,500):t,r=o.length-i;for(let a=0;a<=r;a++){let l=o.slice(a,a+i),c=$(l,e);if(c>s&&(s=c),s>=.95)break}return s>=n?s:0}var It=300,Rt=.3;function ye(t,e){if(!e.textSnippet)return!0;let n=(t.textContent?.trim()??"").slice(0,500);return be(n,e.textSnippet,.5)>Rt}function Pt(t){if(t.elementId){let e=document.getElementById(t.elementId);if(e&&e.tagName===t.elementTag&&ye(e,t))return{element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&ye(e,t))return{element:e,confidence:.95,strategy:"css"}}catch{}try{let n=document.evaluate(t.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(n instanceof Element&&n.tagName===t.elementTag&&ye(n,t))return{element:n,confidence:.9,strategy:"xpath"}}catch{}return Bt(t)}function Bt(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,s=0,o=Math.min(n.length,It);for(let r=0;r<o;r++){let a=n[r];if(!a)continue;let l=Nt(a,t);if(l>s&&(s=l,i=a,s>=.85))break}return!i||s<.4?null:{element:i,confidence:Math.min(s,.85),strategy:"scan"}}function Nt(t,e){let n=0,i=0,s=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=be(s,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=Be(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let o=0,r=0;if(e.textPrefix){let a=N(t,"before");o+=a?$(a,e.textPrefix):0,r++}if(e.textSuffix){let a=N(t,"after");o+=a?$(a,e.textSuffix):0,r++}r>0&&(n+=o/r*20)}if(e.neighborText){i+=20;let o=U(t);n+=o?$(o,e.neighborText)*20:0}return i>0?n/i:0}function te(t,e){let n=Pt(t);if(!n)return null;let i=n.element.getBoundingClientRect(),s=new DOMRect(i.x+e.xPct*i.width,i.y+e.yPct*i.height,e.wPct*i.width,e.hPct*i.height);return{element:n.element,rect:s,confidence:n.confidence,strategy:n.strategy}}function ve(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}}function ne(t){return{xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var it=13;function st(t){return{top:t.top+window.scrollY-it,left:t.right+window.scrollX-it}}function j(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var ot=300,rt=200,$t=.7,Dt=28,at=32,ie=class{constructor(e,n,i,s){this.colors=e;this.tooltip=n;this.bus=i;this.t=s;this.container=h("div",{style:"position:absolute;top:0;left:0;pointer-events:none;z-index:2147483646;"}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",o=>{this.container.style.display=o?"block":"none"}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:!0}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:!0,capture:!0}),this.mutationObserver=new MutationObserver(o=>{if(o.length>20){this.scheduleReposition();return}let r=!1;for(let a of o)if(!(this.container.contains(a.target)||this.tooltip.contains(a.target))){r=!0;break}r&&this.scheduleReposition()}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1}),this.onDocumentClickForClusters=o=>{this.container.contains(o.target)||this.collapseAllClusters()},document.addEventListener("click",this.onDocumentClickForClusters)}colors;tooltip;bus;t;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;get count(){return this.entries.length}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll()},{timeout:rt+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll()},rt))}repositionAll(){for(let e of this.entries)for(let n=0;n<e.feedback.annotations.length;n++){let i=e.elements[n];if(!i)continue;let s=e.feedback.annotations[n];if(!s)continue;let o=`${e.feedback.id}:${n}`,a=this.anchorCache.get(o)?.deref(),l;if(a?.isConnected){let d=a.getBoundingClientRect(),p=ne(s);l={element:a,rect:new DOMRect(d.left+p.xPct*d.width,d.top+p.yPct*d.height,p.wPct*d.width,p.hPct*d.height),confidence:1,strategy:"css"}}else l=te(ve(s),ne(s)),l?.element&&this.anchorCache.set(o,new WeakRef(l.element));if(!l){i.style.display="none";continue}let c=st(l.rect);e.baseTop=c.top,e.baseLeft=c.left,i.style.display="flex",this.applyConfidenceStyle(i,l.confidence,e.feedback)}this.applyClusterPositions()}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e)}render(e){this.clear(),e.forEach((n,i)=>{let s=this.buildEntry(n,i+1);this.entries.push(s)}),this.buildClusters()}addFeedback(e,n){let i=this.buildEntry(e,n);for(let s of i.elements)s.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters()}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let s of e.annotations){let o=te(ve(s),ne(s));if(!o)continue;let r=st(o.rect);i.baseTop=r.top,i.baseLeft=r.left;let a=this.createMarker(n,e,r);this.applyConfidenceStyle(a,o.confidence,e),this.container.appendChild(a),i.elements.push(a)}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let s=0;s<i.elements.length;s++)e.push({entry:i,elIdx:s});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let s=e[i];if(!s)continue;let o={entries:[s.entry],elementIndices:[s.elIdx],expanded:!1};n.add(i);for(let r=i+1;r<e.length;r++){if(n.has(r))continue;let a=s.entry,l=e[r];if(!l)continue;let c=l.entry;Math.sqrt((a.baseLeft-c.baseLeft)**2+(a.baseTop-c.baseTop)**2)<Dt&&(o.entries.push(c),o.elementIndices.push(l.elIdx),n.add(r))}this.clusters.push(o)}for(let i of this.clusters)i.entries.length<=1||(this.applyStackPositions(i),this.addClusterBadge(i))}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:s}=n,o=e.entries.length<=1;for(let r=0;r<e.entries.length;r++){let a=j(e,r);a&&(a.style.top=`${i+(o?0:r*3)}px`,a.style.left=`${s+(o?0:r*3)}px`,a.style.zIndex=String(r+1))}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:s}=n,o=e.entries.length,r=(o-1)*at,a=s-r/2;for(let l=0;l<o;l++){let c=j(e,l);c&&(c.style.top=`${i}px`,c.style.left=`${a+l*at}px`,c.style.zIndex=String(10+l))}}addClusterBadge(e){let n=j(e,e.entries.length-1);if(!n)return;let i=h("div",{class:"sp-cluster-badge",style:`
132
132
  position:absolute;top:-6px;right:-6px;
133
133
  min-width:16px;height:16px;padding:0 4px;
134
134
  border-radius:9999px;
@@ -139,38 +139,36 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
139
139
  pointer-events:none;
140
140
  font-family:"Inter",system-ui,-apple-system,sans-serif;
141
141
  line-height:1;
142
- `});m(i,String(e.entries.length)),t.appendChild(i)}setBadgesVisible(e,t){for(let i=0;i<e.entries.length;i++){let s=O(e,i)?.querySelector(".sp-cluster-badge");s&&(s.style.display=t?"flex":"none")}}findCluster(e){for(let t of this.clusters)if(!(t.entries.length<=1)){for(let i=0;i<t.entries.length;i++)if(O(t,i)===e)return t}return null}handleClusterClick(e,t){let i=this.findCluster(e);return i?i.expanded?!1:(t.stopPropagation(),this.collapseAllClusters(),i.expanded=!0,this.applyFanPositions(i),this.setBadgesVisible(i,!1),!0):!1}collapseCluster(e){e.expanded&&(e.expanded=!1,this.applyStackPositions(e),this.setBadgesVisible(e,!0))}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e)}applyConfidenceStyle(e,t,i){let s=i.status==="resolved";t<At&&!s?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=this.t("marker.approximate").replace("{confidence}",String(Math.round(t*100)))):(e.style.borderStyle="solid",e.style.opacity="1",e.title="")}createMarker(e,t,i){let s=A(t.type,this.colors),r=t.status==="resolved",o=u("div",{style:`
142
+ `});b(i,String(e.entries.length)),n.appendChild(i)}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let s=j(e,i)?.querySelector(".sp-cluster-badge");s&&(s.style.display=n?"flex":"none")}}findCluster(e){for(let n of this.clusters)if(!(n.entries.length<=1)){for(let i=0;i<n.entries.length;i++)if(j(n,i)===e)return n}return null}handleClusterClick(e,n){let i=this.findCluster(e);return i?i.expanded?!1:(n.stopPropagation(),this.collapseAllClusters(),i.expanded=!0,this.applyFanPositions(i),this.setBadgesVisible(i,!1),!0):!1}collapseCluster(e){e.expanded&&(e.expanded=!1,this.applyStackPositions(e),this.setBadgesVisible(e,!0))}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e)}applyConfidenceStyle(e,n,i){let s=i.status==="resolved";n<$t&&!s?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=this.t("marker.approximate").replace("{confidence}",String(Math.round(n*100)))):(e.style.borderStyle="solid",e.style.opacity="1",e.title="")}createMarker(e,n,i){let s=I(n.type,this.colors),o=n.status==="resolved",r=h("div",{style:`
143
143
  position:absolute;
144
144
  top:${i.top}px;
145
145
  left:${i.left}px;
146
146
  width:26px;height:26px;
147
147
  border-radius:50%;
148
- background:${r?"rgba(241,245,249,0.9)":"rgba(255,255,255,0.92)"};
149
- backdrop-filter:blur(12px);
150
- -webkit-backdrop-filter:blur(12px);
151
- border:2px solid ${r?"#cbd5e1":s};
148
+ background:${o?"rgba(241,245,249,0.9)":"rgba(255,255,255,0.92)"};
149
+ border:2px solid ${o?"#cbd5e1":s};
152
150
  display:flex;align-items:center;justify-content:center;
153
151
  font-family:"Inter",system-ui,-apple-system,sans-serif;
154
152
  font-size:11px;font-weight:700;
155
- color:${r?"#94a3b8":s};
153
+ color:${o?"#94a3b8":s};
156
154
  cursor:pointer;pointer-events:auto;
157
- box-shadow:${r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${s}25, 0 2px 6px rgba(0,0,0,0.06)`};
155
+ box-shadow:${o?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${s}25, 0 2px 6px rgba(0,0,0,0.06)`};
158
156
  transition:top 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.15s ease, box-shadow 0.15s ease;
159
157
  user-select:none;
160
158
  -webkit-font-smoothing:antialiased;
161
- `});o.dataset.feedbackId=t.id,o.setAttribute("tabindex","0"),o.setAttribute("role","button"),o.setAttribute("aria-label",`Feedback #${e}: ${t.type} \u2014 ${t.message.slice(0,60)}${t.message.length>60?"...":""}`),o.setAttribute("aria-describedby",this.tooltip.tooltipId),m(o,r?"\u2713":String(e)),o.addEventListener("mouseenter",()=>{o.style.transform="scale(1.2)",o.style.boxShadow=r?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${s}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(t,o.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(t)}),o.addEventListener("mouseleave",()=>{o.style.transform="scale(1)",o.style.boxShadow=r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${s}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight()});let a=l=>{l instanceof MouseEvent&&this.handleClusterClick(o,l)||(this.pinHighlight(t),this.bus.emit("panel:toggle",!0),o.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:t.id},bubbles:!0})))};return o.addEventListener("click",l=>a(l)),o.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a(l))}),o}highlight(e){for(let t of this.entries)if(t.feedback.id===e)for(let i of t.elements)i.style.animation="sp-pulse-ring 0.7s ease-out",i.addEventListener("animationend",()=>{i.style.animation=""},{once:!0})}showHighlight(e){this.removeHighlightElements();for(let t of e.annotations){let i=Q(ce(t),de(t));if(!i)continue;let s=A(e.type,this.colors),r=i.rect,o=u("div",{style:`
159
+ `});r.dataset.feedbackId=n.id,r.setAttribute("tabindex","0"),r.setAttribute("role","button");let a=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,l=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",B(n.type,this.t)).replace("{message}",a);r.setAttribute("aria-label",l),r.setAttribute("aria-describedby",this.tooltip.tooltipId),b(r,o?"\u2713":String(e)),r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.2)",r.style.boxShadow=o?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${s}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(n,r.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n)}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow=o?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${s}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight()});let c=d=>{d instanceof MouseEvent&&this.handleClusterClick(r,d)||(this.pinHighlight(n),this.bus.emit("panel:toggle",!0),r.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:!0})))};return r.addEventListener("click",d=>c(d)),r.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c(d))}),r}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)i.style.animation="sp-pulse-ring 0.7s ease-out",i.addEventListener("animationend",()=>{i.style.animation=""},{once:!0})}showHighlight(e){this.removeHighlightElements();for(let n of e.annotations){let i=te(ve(n),ne(n));if(!i)continue;let s=I(e.type,this.colors),o=i.rect,r=h("div",{style:`
162
160
  position:absolute;
163
- top:${r.top+window.scrollY}px;
164
- left:${r.left+window.scrollX}px;
165
- width:${r.width}px;height:${r.height}px;
161
+ top:${o.top+window.scrollY}px;
162
+ left:${o.left+window.scrollX}px;
163
+ width:${o.width}px;height:${o.height}px;
166
164
  border:2px solid ${s};
167
165
  background:${s}0c;
168
166
  border-radius:8px;
169
167
  pointer-events:none;z-index:-1;
170
168
  opacity:0;
171
169
  box-shadow:0 0 16px ${s}20;
172
- transition:opacity ${Ue}ms ease;
173
- `});this.container.appendChild(o),this.highlightElements.push(o),o.offsetHeight,o.style.opacity="1"}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=t=>{this.container.contains(t.target)||this.unpinHighlight()},document.addEventListener("click",this.onDocumentClick,{capture:!0})}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:!0}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight()}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),Ue);this.highlightElements=[]}removeHighlightElements(){for(let e of this.highlightElements)e.remove();this.highlightElements=[]}clear(){this.unpinHighlight(),this.container.replaceChildren(),this.entries=[],this.clusters=[]}destroy(){this.unpinHighlight(),this.repositionTimer&&clearTimeout(this.repositionTimer),this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.onDocumentClickForClusters&&document.removeEventListener("click",this.onDocumentClickForClusters),this.mutationObserver?.disconnect(),this.container.remove()}};var Z=class{constructor(e,t,i,s,r,o,a,l){this.colors=t;this.bus=i;this.apiClient=s;this.projectName=r;this.markers=o;this.t=a;this.locale=l;this.root=u("div",{class:"sp-panel"}),this.root.setAttribute("role","complementary"),this.root.setAttribute("aria-label","Siteping feedback panel"),this.root.setAttribute("aria-hidden","true");let p=u("div",{class:"sp-panel-header"}),d=u("span",{class:"sp-panel-title"});m(d,this.t("panel.title")),this.closeBtn=document.createElement("button"),this.closeBtn.className="sp-panel-close",this.closeBtn.setAttribute("aria-label",this.t("panel.close")),this.closeBtn.appendChild(C(K)),this.closeBtn.addEventListener("click",()=>this.close()),this.deleteAllBtn=document.createElement("button"),this.deleteAllBtn.className="sp-btn-delete-all",this.deleteAllBtn.setAttribute("aria-label",this.t("panel.deleteAll")),this.deleteAllBtn.appendChild(C(ae));let c=document.createElement("span");m(c,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(c),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll());let h=u("div",{class:"sp-panel-header-right"});h.appendChild(this.deleteAllBtn),h.appendChild(this.closeBtn),p.appendChild(d),p.appendChild(h);let b=u("div",{class:"sp-filters"}),g=u("div",{class:"sp-search-wrap"}),k=C(Fe);k.setAttribute("class","sp-search-icon"),this.searchInput=document.createElement("input"),this.searchInput.type="text",this.searchInput.className="sp-search",this.searchInput.placeholder=this.t("panel.search"),this.searchInput.setAttribute("aria-label",this.t("panel.searchAria")),this.searchInput.addEventListener("input",()=>{this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>this.loadFeedbacks().catch(()=>{}),200)}),g.appendChild(k),g.appendChild(this.searchInput);let v=u("div",{class:"sp-chips"}),w=[{value:"all",label:this.t("panel.filterAll")},{value:"question",label:this.t("type.question")},{value:"change",label:this.t("type.change")},{value:"bug",label:this.t("type.bug")},{value:"other",label:this.t("type.other")}];for(let x of w){let f=document.createElement("button");f.className=`sp-chip ${x.value==="all"?"sp-chip--active":""}`,x.value!=="all"&&(f.style.borderColor=A(x.value,this.colors)),m(f,x.label),f.dataset.filter=x.value,f.setAttribute("aria-pressed",x.value==="all"?"true":"false"),f.addEventListener("click",()=>this.toggleFilter(x.value,v)),v.appendChild(f)}b.appendChild(g),b.appendChild(v),this.listContainer=u("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label","Liste des feedbacks"),this.root.appendChild(p),this.root.appendChild(b),this.root.appendChild(this.listContainer),e.appendChild(this.root),this.bus.on("panel:toggle",x=>{x?this.open():this.close()}),e.addEventListener("keydown",x=>{x.key==="Escape"&&this.isOpen&&this.close()}),this.onMarkerClick=(x=>{this.scrollToFeedback(x.detail.feedbackId)}),document.addEventListener("sp-marker-click",this.onMarkerClick)}colors;bus;apiClient;projectName;markers;t;locale;root;listContainer;searchInput;closeBtn;deleteAllBtn;activeFilters=new Set(["all"]);feedbacks=[];isOpen=!1;searchTimeout=null;onMarkerClick;async open(){this.isOpen||(this.isOpen=!0,this.root.classList.add("sp-panel--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),await this.loadFeedbacks(),requestAnimationFrame(()=>{this.searchInput?this.searchInput.focus():this.closeBtn.focus()}))}close(){if(!this.isOpen)return;this.isOpen=!1,this.root.classList.remove("sp-panel--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.root.getRootNode().querySelector(".sp-fab")?.focus()}showLoading(){this.listContainer.replaceChildren();let e=u("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","Chargement des feedbacks");let t=u("div",{class:"sp-spinner"});e.appendChild(t),this.listContainer.appendChild(e)}showError(){this.listContainer.replaceChildren();let e=u("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=u("div",{class:"sp-empty-text"});m(t,this.t("panel.loadError"));let i=document.createElement("button");i.className="sp-btn-ghost",i.style.marginTop="8px",m(i,this.t("panel.retry")),i.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(t),e.appendChild(i),this.listContainer.appendChild(e)}async loadFeedbacks(){let e=this.searchInput.value.trim()||void 0,t=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],i={limit:50};t&&(i.type=t),e&&(i.search=e);let s=this.feedbacks.length>0;s||this.showLoading();try{let{feedbacks:r}=await this.apiClient.getFeedbacks(this.projectName,i);this.feedbacks=r,this.renderList(),this.markers.render(r)}catch(r){s||this.showError(),this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r)))}}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let e=u("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=u("div",{class:"sp-empty-text"});m(t,this.t("panel.empty")),e.appendChild(t),this.listContainer.appendChild(e);return}this.feedbacks.forEach((e,t)=>{let i=this.createCard(e,t+1);i.style.setProperty("--sp-card-i",String(t)),this.listContainer.appendChild(i)})}createCard(e,t){let i=e.status==="resolved",s=A(e.type,this.colors),r=u("div",{class:`sp-card ${i?"sp-card--resolved":""}`});r.setAttribute("role","listitem"),r.setAttribute("tabindex","0"),r.setAttribute("aria-label",`Feedback #${t}: ${B(e.type,this.t)} \u2014 ${e.message.slice(0,80)}`),r.dataset.feedbackId=e.id;let o=u("div",{class:"sp-card-bar"});o.style.background=i?"#9ca3af":s;let a=u("div",{class:"sp-card-body"}),l=u("div",{class:"sp-card-header"}),p=u("span",{class:"sp-card-number"});m(p,`#${t}`);let d=u("span",{class:"sp-badge"}),c=F(e.type,this.colors);d.style.background=c,d.style.color=s,m(d,B(e.type,this.t));let h=u("span",{class:"sp-card-date"});m(h,q(e.createdAt,this.locale)),l.appendChild(p),l.appendChild(d),l.appendChild(h);let b=u("div",{class:"sp-card-message"});m(b,e.message);let g=document.createElement("button");g.className="sp-card-expand",m(g,this.t("panel.showMore")),g.style.display="none",g.setAttribute("aria-expanded","false"),g.addEventListener("click",y=>{y.stopPropagation();let E=b.classList.toggle("sp-card-message--expanded");m(g,E?this.t("panel.showLess"):this.t("panel.showMore")),g.setAttribute("aria-expanded",String(E))}),requestAnimationFrame(()=>{b.scrollHeight>b.clientHeight&&(g.style.display="block")});let k=u("div",{class:"sp-card-footer"}),v=document.createElement("button");if(v.className="sp-btn-resolve",i){v.appendChild(C(Be));let y=document.createElement("span");m(y,` ${this.t("panel.reopen")}`),v.appendChild(y)}else{v.appendChild(C(Ie));let y=document.createElement("span");m(y,` ${this.t("panel.resolve")}`),v.appendChild(y)}v.addEventListener("click",async y=>{y.stopPropagation(),await this.toggleResolve(e,v)});let w=document.createElement("button");w.className="sp-btn-delete",w.appendChild(C(ae));let x=document.createElement("span");m(x,` ${this.t("panel.delete")}`),w.appendChild(x),w.addEventListener("click",async y=>{y.stopPropagation(),await this.deleteFeedback(e,w)}),k.appendChild(v),k.appendChild(w),a.appendChild(l),a.appendChild(b),a.appendChild(g),a.appendChild(k),r.appendChild(o),r.appendChild(a),r.addEventListener("mouseenter",()=>{this.markers.highlight(e.id)});let f=()=>{if(e.annotations.length>0){let y=e.annotations[0];window.scrollTo({left:y.scrollX,top:y.scrollY,behavior:"smooth"}),this.markers.pinHighlight(e)}};return r.addEventListener("click",f),r.addEventListener("keydown",y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),f())}),r}async deleteFeedback(e,t){t.disabled=!0;try{await this.apiClient.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks()}catch(i){t.disabled=!1,this.bus.emit("feedback:error",i instanceof Error?i:new Error(String(i)))}}async confirmDeleteAll(){if(await this.showConfirmDialog(this.t("panel.deleteAllConfirmTitle"),this.t("panel.deleteAllConfirmMessage"))){this.deleteAllBtn.disabled=!0;try{await this.apiClient.deleteAllFeedbacks(this.projectName),this.bus.emit("feedback:all-deleted"),await this.loadFeedbacks()}catch(t){this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t)))}finally{this.deleteAllBtn.disabled=!1}}}showConfirmDialog(e,t){return new Promise(i=>{let s=u("div",{class:"sp-confirm-backdrop"}),r=`sp-confirm-title-${Date.now()}`,o=`sp-confirm-msg-${Date.now()}`,a=u("div",{class:"sp-confirm-dialog"});a.setAttribute("role","alertdialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-labelledby",r),a.setAttribute("aria-describedby",o);let l=u("div",{class:"sp-confirm-title"});l.id=r,m(l,e);let p=u("div",{class:"sp-confirm-message"});p.id=o,m(p,t);let d=u("div",{class:"sp-confirm-actions"}),c=document.createElement("button");c.type="button",c.className="sp-btn-ghost",m(c,this.t("panel.cancel"));let h=document.createElement("button");h.type="button",h.className="sp-btn-danger",m(h,this.t("panel.confirmDelete"));let b=!1,g=v=>{b||(b=!0,s.removeEventListener("keydown",k),s.style.opacity="0",a.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{s.remove(),i(v)},200))},k=v=>{let w=v;if(w.key==="Escape"){g(!1);return}w.key==="Tab"&&(w.preventDefault(),s.getRootNode().activeElement===c?h.focus():c.focus())};s.addEventListener("keydown",k),c.addEventListener("click",()=>g(!1)),h.addEventListener("click",()=>g(!0)),s.addEventListener("click",v=>{v.target===s&&g(!1)}),d.appendChild(c),d.appendChild(h),a.appendChild(l),a.appendChild(p),a.appendChild(d),s.appendChild(a),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(s):this.root.appendChild(s),requestAnimationFrame(()=>{s.style.opacity="1",a.style.transform="translateY(0) scale(1)",c.focus()})})}async toggleResolve(e,t){t.disabled=!0;try{let i=e.status!=="resolved";await this.apiClient.resolveFeedback(e.id,i),await this.loadFeedbacks()}catch(i){t.disabled=!1,this.bus.emit("feedback:error",i instanceof Error?i:new Error(String(i)))}}toggleFilter(e,t){this.activeFilters.clear(),this.activeFilters.add(e);let i=t.querySelectorAll(".sp-chip");for(let s of i){let r=this.activeFilters.has(s.dataset.filter??"");s.classList.toggle("sp-chip--active",r),s.setAttribute("aria-pressed",String(r))}this.loadFeedbacks().catch(()=>{})}scrollToFeedback(e){let t=CSS.escape(e),i=this.listContainer.querySelector(`[data-feedback-id="${t}"]`);i&&(i.scrollIntoView({behavior:"smooth",block:"center"}),i.classList.add("sp-anim-flash"),i.addEventListener("animationend",()=>{i.classList.remove("sp-anim-flash")},{once:!0}))}async refresh(){this.isOpen&&await this.loadFeedbacks()}destroy(){this.searchTimeout&&clearTimeout(this.searchTimeout),document.removeEventListener("sp-marker-click",this.onMarkerClick),this.root.remove()}};var Mt="linear(0, 0.006, 0.025, 0.06, 0.11, 0.17, 0.25, 0.34, 0.45, 0.56, 0.67, 0.78, 0.88, 0.95, 1.01, 1.04, 1.05, 1.04, 1.02, 1, 0.99, 1)",ue="cubic-bezier(0.16, 1, 0.3, 1)",he="cubic-bezier(0.34, 1.56, 0.64, 1)",Ft="cubic-bezier(0.25, 1, 0.5, 1)",Je=`
170
+ transition:opacity ${ot}ms ease;
171
+ `});this.container.appendChild(r),this.highlightElements.push(r),r.offsetHeight,r.style.opacity="1"}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=n=>{this.container.contains(n.target)||this.unpinHighlight()},document.addEventListener("click",this.onDocumentClick,{capture:!0})}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:!0}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight()}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),ot);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:!0}),this.onDocumentClickForClusters&&document.removeEventListener("click",this.onDocumentClickForClusters),this.mutationObserver?.disconnect(),this.container.remove()}};var se=class{constructor(e,n,i,s,o,r,a,l){this.colors=n;this.bus=i;this.client=s;this.projectName=o;this.markers=r;this.t=a;this.locale=l;this.root=h("div",{class:"sp-panel"}),this.root.setAttribute("role","complementary"),this.root.setAttribute("aria-label",this.t("panel.ariaLabel")),this.root.setAttribute("aria-hidden","true");let c=h("div",{class:"sp-panel-header"}),d=h("span",{class:"sp-panel-title"});b(d,this.t("panel.title")),this.closeBtn=document.createElement("button"),this.closeBtn.className="sp-panel-close",this.closeBtn.setAttribute("aria-label",this.t("panel.close")),this.closeBtn.appendChild(F(G)),this.closeBtn.addEventListener("click",()=>this.close()),this.deleteAllBtn=document.createElement("button"),this.deleteAllBtn.className="sp-btn-delete-all",this.deleteAllBtn.setAttribute("aria-label",this.t("panel.deleteAll")),this.deleteAllBtn.appendChild(F(me));let p=document.createElement("span");b(p,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(p),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll());let f=h("div",{class:"sp-panel-header-right"});f.appendChild(this.deleteAllBtn),f.appendChild(this.closeBtn),c.appendChild(d),c.appendChild(f);let m=h("div",{class:"sp-filters"}),y=h("div",{class:"sp-search-wrap"}),T=F(je);T.setAttribute("class","sp-search-icon"),this.searchInput=document.createElement("input"),this.searchInput.type="text",this.searchInput.className="sp-search",this.searchInput.placeholder=this.t("panel.search"),this.searchInput.setAttribute("aria-label",this.t("panel.searchAria")),this.searchInput.addEventListener("input",()=>{this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>this.loadFeedbacks().catch(()=>{}),200)}),y.appendChild(T),y.appendChild(this.searchInput);let k=h("div",{class:"sp-chips"}),C=[{value:"all",label:this.t("panel.filterAll")},{value:"question",label:this.t("type.question")},{value:"change",label:this.t("type.change")},{value:"bug",label:this.t("type.bug")},{value:"other",label:this.t("type.other")}];for(let v of C){let g=document.createElement("button");g.className=`sp-chip ${v.value==="all"?"sp-chip--active":""}`,v.value!=="all"&&(g.style.borderColor=I(v.value,this.colors)),b(g,v.label),g.dataset.filter=v.value,g.setAttribute("aria-pressed",v.value==="all"?"true":"false"),g.addEventListener("click",()=>this.toggleFilter(v.value,k)),k.appendChild(g)}m.appendChild(y),m.appendChild(k),this.listContainer=h("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label",this.t("panel.feedbackList")),this.root.appendChild(c),this.root.appendChild(m),this.root.appendChild(this.listContainer),e.appendChild(this.root),this.onListClick=v=>{let g=v.target,x=g.closest("[data-action]");if(x){v.stopPropagation();let w=x.closest(".sp-card");if(!w)return;let S=w.dataset.feedbackId,E=this.feedbacks.find(L=>L.id===S);if(!E)return;let A=x.dataset.action;if(A==="expand"){let L=w.querySelector(".sp-card-message");if(!L)return;let _=L.classList.toggle("sp-card-message--expanded");b(x,_?this.t("panel.showLess"):this.t("panel.showMore")),x.setAttribute("aria-expanded",String(_))}else if(A==="resolve"){if(this.pendingMutations.has(E.id))return;let L=x;this.toggleResolve(E,L).catch(()=>{})}else if(A==="delete"){if(this.pendingMutations.has(E.id))return;let L=x;this.deleteFeedback(E,L).catch(()=>{})}return}let u=g.closest(".sp-card");if(u){let w=u.dataset.feedbackId,S=this.feedbacks.find(E=>E.id===w);if(S&&S.annotations.length>0){let E=S.annotations[0];if(!E)return;window.scrollTo({left:E.scrollX,top:E.scrollY,behavior:"smooth"}),this.markers.pinHighlight(S)}}},this.listContainer.addEventListener("click",this.onListClick),this.onListKeydown=v=>{let g=v;if(g.key!=="Enter"&&g.key!==" ")return;let x=g.target,u=x.closest(".sp-card");if(!u||x!==u)return;g.preventDefault();let w=u.dataset.feedbackId,S=this.feedbacks.find(E=>E.id===w);if(S&&S.annotations.length>0){let E=S.annotations[0];if(!E)return;window.scrollTo({left:E.scrollX,top:E.scrollY,behavior:"smooth"}),this.markers.pinHighlight(S)}},this.listContainer.addEventListener("keydown",this.onListKeydown),this.onListMouseover=v=>{let x=v.target.closest(".sp-card");if(!x)return;let u=x.dataset.feedbackId;u&&this.markers.highlight(u)},this.listContainer.addEventListener("mouseover",this.onListMouseover),this.onListMouseout=v=>{let g=v.relatedTarget;g&&this.listContainer.contains(g)||this.markers.highlight("")},this.listContainer.addEventListener("mouseout",this.onListMouseout),this.bus.on("panel:toggle",v=>{v?this.open():this.close()}),e.addEventListener("keydown",v=>{let g=v;if(g.key==="Escape"&&this.isOpen){this.close();return}if(g.key==="Tab"&&this.isOpen){let x=this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(x.length===0)return;let u=x[0],w=x[x.length-1];if(!u||!w)return;let S=e.activeElement;g.shiftKey&&S===u?(g.preventDefault(),w.focus()):!g.shiftKey&&S===w&&(g.preventDefault(),u.focus())}}),this.onMarkerClick=(v=>{this.scrollToFeedback(v.detail.feedbackId)}),document.addEventListener("sp-marker-click",this.onMarkerClick)}colors;bus;client;projectName;markers;t;locale;root;listContainer;searchInput;closeBtn;deleteAllBtn;activeFilters=new Set(["all"]);feedbacks=[];isOpen=!1;searchTimeout=null;loadController=null;pendingMutations=new Set;onMarkerClick;onListClick;onListKeydown;onListMouseover;onListMouseout;async open(){this.isOpen||(this.isOpen=!0,this.root.classList.add("sp-panel--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),await this.loadFeedbacks(),requestAnimationFrame(()=>{this.searchInput?this.searchInput.focus():this.closeBtn.focus()}))}close(){if(!this.isOpen)return;this.isOpen=!1,this.root.classList.remove("sp-panel--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.root.getRootNode().querySelector(".sp-fab")?.focus()}showLoading(){this.listContainer.replaceChildren();let e=h("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label",this.t("panel.loading"));let n=h("div",{class:"sp-spinner"});e.appendChild(n),this.listContainer.appendChild(e)}showError(){this.listContainer.replaceChildren();let e=h("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let n=h("div",{class:"sp-empty-text"});b(n,this.t("panel.loadError"));let i=document.createElement("button");i.className="sp-btn-ghost",i.style.marginTop="8px",b(i,this.t("panel.retry")),i.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(n),e.appendChild(i),this.listContainer.appendChild(e)}async loadFeedbacks(){this.loadController?.abort(),this.loadController=new AbortController;let{signal:e}=this.loadController,n=this.searchInput.value.trim()||void 0,i=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],s={limit:50};i&&(s.type=i),n&&(s.search=n);let o=this.feedbacks.length>0;o||this.showLoading();try{let{feedbacks:r}=await this.client.getFeedbacks(this.projectName,s);if(e.aborted)return;this.feedbacks=r,this.renderList(),this.markers.render(r)}catch(r){if(e.aborted)return;o||this.showError(),this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r)))}}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let e=h("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let n=h("div",{class:"sp-empty-text"});b(n,this.t("panel.empty")),e.appendChild(n),this.listContainer.appendChild(e);return}this.feedbacks.forEach((e,n)=>{let i=this.createCard(e,n+1);i.style.setProperty("--sp-card-i",String(n)),this.listContainer.appendChild(i)})}createCard(e,n){let i=e.status==="resolved",s=I(e.type,this.colors),o=h("div",{class:`sp-card ${i?"sp-card--resolved":""}`});o.setAttribute("role","listitem"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Feedback #${n}: ${B(e.type,this.t)} \u2014 ${e.message.slice(0,80)}`),o.dataset.feedbackId=e.id;let r=h("div",{class:"sp-card-bar"});r.style.background=i?"#9ca3af":s;let a=h("div",{class:"sp-card-body"}),l=h("div",{class:"sp-card-header"}),c=h("span",{class:"sp-card-number"});b(c,`#${n}`);let d=h("span",{class:"sp-badge"}),p=P(e.type,this.colors);d.style.background=p,d.style.color=s,b(d,B(e.type,this.t));let f=h("span",{class:"sp-card-date"});b(f,X(e.createdAt,this.locale)),l.appendChild(c),l.appendChild(d),l.appendChild(f);let m=h("div",{class:"sp-card-message"});b(m,e.message);let y=document.createElement("button");y.className="sp-card-expand",y.dataset.action="expand",b(y,this.t("panel.showMore")),y.style.display="none",y.setAttribute("aria-expanded","false"),requestAnimationFrame(()=>{m.scrollHeight>m.clientHeight&&(y.style.display="block")});let T=h("div",{class:"sp-card-footer"}),k=document.createElement("button");if(k.className="sp-btn-resolve",k.dataset.action="resolve",i){k.appendChild(F(qe));let g=document.createElement("span");b(g,` ${this.t("panel.reopen")}`),k.appendChild(g)}else{k.appendChild(F(ze));let g=document.createElement("span");b(g,` ${this.t("panel.resolve")}`),k.appendChild(g)}let C=document.createElement("button");C.className="sp-btn-delete",C.dataset.action="delete",C.appendChild(F(me));let v=document.createElement("span");return b(v,` ${this.t("panel.delete")}`),C.appendChild(v),T.appendChild(k),T.appendChild(C),a.appendChild(l),a.appendChild(m),a.appendChild(y),a.appendChild(T),o.appendChild(r),o.appendChild(a),o}async deleteFeedback(e,n){this.pendingMutations.add(e.id),n.disabled=!0;try{await this.client.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks()}catch(i){this.pendingMutations.delete(e.id),n.disabled=!1,this.bus.emit("feedback:error",i instanceof Error?i:new Error(String(i)))}finally{this.pendingMutations.has(e.id)&&setTimeout(()=>this.pendingMutations.delete(e.id),300)}}async confirmDeleteAll(){if(await this.showConfirmDialog(this.t("panel.deleteAllConfirmTitle"),this.t("panel.deleteAllConfirmMessage"))){this.deleteAllBtn.disabled=!0;try{await this.client.deleteAllFeedbacks(this.projectName),this.bus.emit("feedback:all-deleted"),await this.loadFeedbacks()}catch(n){this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)))}finally{this.deleteAllBtn.disabled=!1}}}showConfirmDialog(e,n){return new Promise(i=>{let s=h("div",{class:"sp-confirm-backdrop"}),o=`sp-confirm-title-${Date.now()}`,r=`sp-confirm-msg-${Date.now()}`,a=h("div",{class:"sp-confirm-dialog"});a.setAttribute("role","alertdialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-labelledby",o),a.setAttribute("aria-describedby",r);let l=h("div",{class:"sp-confirm-title"});l.id=o,b(l,e);let c=h("div",{class:"sp-confirm-message"});c.id=r,b(c,n);let d=h("div",{class:"sp-confirm-actions"}),p=document.createElement("button");p.type="button",p.className="sp-btn-ghost",b(p,this.t("panel.cancel"));let f=document.createElement("button");f.type="button",f.className="sp-btn-danger",b(f,this.t("panel.confirmDelete"));let m=!1,y=k=>{m||(m=!0,s.removeEventListener("keydown",T),s.style.opacity="0",a.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{s.remove(),i(k)},200))},T=k=>{let C=k;if(C.key==="Escape"){y(!1);return}C.key==="Tab"&&(C.preventDefault(),s.getRootNode().activeElement===p?f.focus():p.focus())};s.addEventListener("keydown",T),p.addEventListener("click",()=>y(!1)),f.addEventListener("click",()=>y(!0)),s.addEventListener("click",k=>{k.target===s&&y(!1)}),d.appendChild(p),d.appendChild(f),a.appendChild(l),a.appendChild(c),a.appendChild(d),s.appendChild(a),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(s):this.root.appendChild(s),requestAnimationFrame(()=>{s.style.opacity="1",a.style.transform="translateY(0) scale(1)",p.focus()})})}async toggleResolve(e,n){this.pendingMutations.add(e.id),n.disabled=!0;try{let i=e.status!=="resolved";await this.client.resolveFeedback(e.id,i),await this.loadFeedbacks()}catch(i){this.pendingMutations.delete(e.id),n.disabled=!1,this.bus.emit("feedback:error",i instanceof Error?i:new Error(String(i)))}finally{this.pendingMutations.has(e.id)&&setTimeout(()=>this.pendingMutations.delete(e.id),300)}}toggleFilter(e,n){this.activeFilters.clear(),this.activeFilters.add(e);let i=n.querySelectorAll(".sp-chip");for(let s of i){let o=this.activeFilters.has(s.dataset.filter??"");s.classList.toggle("sp-chip--active",o),s.setAttribute("aria-pressed",String(o))}this.loadFeedbacks().catch(()=>{})}scrollToFeedback(e){let n=CSS.escape(e),i=this.listContainer.querySelector(`[data-feedback-id="${n}"]`);i&&(i.scrollIntoView({behavior:"smooth",block:"center"}),i.classList.add("sp-anim-flash"),i.addEventListener("animationend",()=>{i.classList.remove("sp-anim-flash")},{once:!0}))}async refresh(){this.isOpen&&await this.loadFeedbacks()}destroy(){this.loadController?.abort(),this.searchTimeout&&clearTimeout(this.searchTimeout),this.listContainer.removeEventListener("click",this.onListClick),this.listContainer.removeEventListener("keydown",this.onListKeydown),this.listContainer.removeEventListener("mouseover",this.onListMouseover),this.listContainer.removeEventListener("mouseout",this.onListMouseout),document.removeEventListener("sp-marker-click",this.onMarkerClick),this.root.remove()}};function xe(t){return{cssSelector:t.anchor.cssSelector,xpath:t.anchor.xpath,textSnippet:t.anchor.textSnippet,elementTag:t.anchor.elementTag,elementId:t.anchor.elementId,textPrefix:t.anchor.textPrefix,textSuffix:t.anchor.textSuffix,fingerprint:t.anchor.fingerprint,neighborText:t.anchor.neighborText,xPct:t.rect.xPct,yPct:t.rect.yPct,wPct:t.rect.wPct,hPct:t.rect.hPct,scrollX:t.scrollX,scrollY:t.scrollY,viewportW:t.viewportW,viewportH:t.viewportH,devicePixelRatio:t.devicePixelRatio}}var oe=class{constructor(e,n){this.store=e;this.projectName=n}store;projectName;async sendFeedback(e){let n=await this.store.createFeedback({projectName:e.projectName,type:e.type,message:e.message,status:"open",url:e.url,viewport:e.viewport,userAgent:e.userAgent,authorName:e.authorName,authorEmail:e.authorEmail,clientId:e.clientId,annotations:e.annotations.map(xe)});return ke(n)}async getFeedbacks(e,n){let{feedbacks:i,total:s}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,search:n?.search});return{feedbacks:i.map(ke),total:s}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return ke(i)}async deleteFeedback(e){await this.store.deleteFeedback(e)}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e)}};function ke(t){return{id:t.id,projectName:t.projectName,type:t.type,message:t.message,status:t.status,url:t.url,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(Ht)}}function Ht(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,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 Ot="linear(0, 0.006, 0.025, 0.06, 0.11, 0.17, 0.25, 0.34, 0.45, 0.56, 0.67, 0.78, 0.88, 0.95, 1.01, 1.04, 1.05, 1.04, 1.02, 1, 0.99, 1)",we="cubic-bezier(0.16, 1, 0.3, 1)",Ee="cubic-bezier(0.34, 1.56, 0.64, 1)",jt="cubic-bezier(0.25, 1, 0.5, 1)",lt=`
174
172
  /* ---- Keyframes ---- */
175
173
 
176
174
  @keyframes sp-fab-in {
@@ -244,11 +242,11 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
244
242
  /* ---- Animation classes ---- */
245
243
 
246
244
  .sp-anim-fab-in {
247
- animation: sp-fab-in 0.5s ${Mt} both;
245
+ animation: sp-fab-in 0.5s ${Ot} both;
248
246
  }
249
247
 
250
248
  .sp-anim-marker-in {
251
- animation: sp-marker-in 0.35s ${he} both;
249
+ animation: sp-marker-in 0.35s ${Ee} both;
252
250
  }
253
251
 
254
252
  .sp-anim-pulse {
@@ -256,11 +254,11 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
256
254
  }
257
255
 
258
256
  .sp-anim-flash {
259
- animation: sp-flash-bg 0.5s ${Ft};
257
+ animation: sp-flash-bg 0.5s ${jt};
260
258
  }
261
259
 
262
260
  .sp-anim-slide-up {
263
- animation: sp-slide-up 0.3s ${ue} both;
261
+ animation: sp-slide-up 0.3s ${we} both;
264
262
  }
265
263
 
266
264
  .sp-anim-fade-in {
@@ -271,7 +269,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
271
269
 
272
270
  .sp-panel {
273
271
  transform: translateX(110%);
274
- transition: transform 0.4s ${ue};
272
+ transition: transform 0.4s ${we};
275
273
  }
276
274
 
277
275
  .sp-panel.sp-panel--open {
@@ -283,7 +281,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
283
281
  pointer-events: none;
284
282
  transform: translate(0, 0) scale(0.8);
285
283
  transition:
286
- transform 0.35s ${he},
284
+ transform 0.35s ${Ee},
287
285
  opacity 0.2s ease,
288
286
  background 0.2s ease,
289
287
  border-color 0.2s ease,
@@ -314,7 +312,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
314
312
  }
315
313
 
316
314
  .sp-card {
317
- animation: sp-card-in 0.35s ${ue} both;
315
+ animation: sp-card-in 0.35s ${we} both;
318
316
  animation-delay: calc(var(--sp-card-i, 0) * 40ms);
319
317
  }
320
318
 
@@ -342,7 +340,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
342
340
  }
343
341
 
344
342
  .sp-fab-badge {
345
- animation: sp-badge-in 0.4s ${he} both;
343
+ animation: sp-badge-in 0.4s ${Ee} both;
346
344
  }
347
345
 
348
346
  /* ---- Reduced motion ---- */
@@ -355,7 +353,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
355
353
  }
356
354
  }
357
355
 
358
- `;function Ze(n){return`
356
+ `;function Ce(t){return`
359
357
  :host {
360
358
  all: initial;
361
359
  position: fixed;
@@ -366,7 +364,11 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
366
364
  color: var(--sp-text);
367
365
  -webkit-font-smoothing: antialiased;
368
366
  -moz-osx-font-smoothing: grayscale;
369
- ${ze(n)}
367
+ ${Ve(t)}
368
+
369
+ /* Identity modal \u2014 theme-aware backdrop + panel */
370
+ --sp-identity-bg: ${t.glassBgHeavy};
371
+ --sp-identity-overlay: ${t.bg==="#ffffff"?"rgba(15, 23, 42, 0.2)":"rgba(0, 0, 0, 0.4)"};
370
372
  }
371
373
 
372
374
  *, *::before, *::after {
@@ -562,6 +564,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
562
564
  width: 400px;
563
565
  max-width: 100vw;
564
566
  height: 100vh;
567
+ height: 100dvh;
565
568
  background: var(--sp-glass-bg);
566
569
  backdrop-filter: blur(var(--sp-blur-heavy));
567
570
  -webkit-backdrop-filter: blur(var(--sp-blur-heavy));
@@ -598,8 +601,8 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
598
601
  }
599
602
 
600
603
  .sp-panel-close {
601
- width: 32px;
602
- height: 32px;
604
+ width: 44px;
605
+ height: 44px;
603
606
  border-radius: var(--sp-radius);
604
607
  border: none;
605
608
  background: transparent;
@@ -851,7 +854,7 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
851
854
 
852
855
  .sp-btn-resolve,
853
856
  .sp-btn-delete {
854
- padding: 5px 14px;
857
+ padding: 8px 14px;
855
858
  border-radius: var(--sp-radius-full);
856
859
  border: 1px solid var(--sp-border);
857
860
  background: transparent;
@@ -1149,18 +1152,74 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
1149
1152
  font-weight: 500;
1150
1153
  }
1151
1154
 
1152
- ${Je}
1153
- `}var It=120,Rt=80,ee=class{constructor(e,t="fr"){this.colors=e;this.locale=t;this.root=u("div",{style:`
1155
+ /* ============================
1156
+ Forced Colors / High Contrast
1157
+ ============================ */
1158
+
1159
+ @media (forced-colors: active) {
1160
+ .sp-fab,
1161
+ .sp-radial-item,
1162
+ .sp-chip,
1163
+ .sp-card,
1164
+ .sp-panel-close,
1165
+ .sp-search,
1166
+ .sp-btn-resolve,
1167
+ .sp-btn-delete,
1168
+ .sp-btn-delete-all,
1169
+ .sp-btn-primary,
1170
+ .sp-btn-ghost,
1171
+ .sp-btn-danger,
1172
+ .sp-card-expand,
1173
+ .sp-input,
1174
+ .sp-confirm-dialog {
1175
+ border: 2px solid ButtonText !important;
1176
+ background: Canvas !important;
1177
+ color: ButtonText !important;
1178
+ }
1179
+
1180
+ .sp-fab:focus-visible,
1181
+ .sp-radial-item:focus-visible,
1182
+ .sp-chip:focus-visible,
1183
+ .sp-panel-close:focus-visible,
1184
+ .sp-btn-resolve:focus-visible,
1185
+ .sp-btn-delete:focus-visible,
1186
+ .sp-btn-delete-all:focus-visible,
1187
+ .sp-btn-primary:focus-visible,
1188
+ .sp-btn-ghost:focus-visible,
1189
+ .sp-btn-danger:focus-visible,
1190
+ .sp-card-expand:focus-visible,
1191
+ .sp-input:focus-visible,
1192
+ .sp-search:focus-visible {
1193
+ outline: 3px solid Highlight !important;
1194
+ }
1195
+
1196
+ .sp-panel {
1197
+ border: 2px solid ButtonText !important;
1198
+ }
1199
+
1200
+ .sp-fab-badge {
1201
+ border: 2px solid ButtonText !important;
1202
+ background: Canvas !important;
1203
+ color: ButtonText !important;
1204
+ }
1205
+
1206
+ .sp-card-bar {
1207
+ background: ButtonText !important;
1208
+ }
1209
+ }
1210
+
1211
+ ${lt}
1212
+ `}var zt=120,_t=80,re=class{constructor(e,n="fr"){this.colors=e;this.locale=n;this.root=h("div",{style:`
1154
1213
  position: fixed;
1155
1214
  z-index: 2147483647;
1156
1215
  max-width: 280px;
1157
1216
  padding: 12px 14px;
1158
1217
  border-radius: 14px;
1159
- background: rgba(255, 255, 255, 0.88);
1218
+ background: ${this.colors.glassBgHeavy};
1160
1219
  backdrop-filter: blur(24px);
1161
1220
  -webkit-backdrop-filter: blur(24px);
1162
- border: 1px solid rgba(255, 255, 255, 0.35);
1163
- box-shadow: 0 8px 32px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.04);
1221
+ border: 1px solid ${this.colors.glassBorder};
1222
+ box-shadow: 0 8px 32px ${this.colors.shadow}, 0 2px 8px ${this.colors.shadow};
1164
1223
  font-family: "Inter", system-ui, -apple-system, sans-serif;
1165
1224
  pointer-events: auto;
1166
1225
  opacity: 0;
@@ -1168,25 +1227,25 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
1168
1227
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
1169
1228
  visibility: hidden;
1170
1229
  -webkit-font-smoothing: antialiased;
1171
- `}),this.root.setAttribute("role","tooltip"),this.root.id=this.tooltipId,this.arrow=u("div",{style:`
1230
+ `}),this.root.setAttribute("role","tooltip"),this.root.id=this.tooltipId,this.arrow=h("div",{style:`
1172
1231
  position: absolute;
1173
1232
  width: 12px;
1174
1233
  height: 12px;
1175
- background: rgba(255, 255, 255, 0.88);
1176
- border: 1px solid rgba(255, 255, 255, 0.35);
1234
+ background: ${this.colors.glassBgHeavy};
1235
+ border: 1px solid ${this.colors.glassBorder};
1177
1236
  transform: rotate(45deg);
1178
1237
  pointer-events: none;
1179
- `}),this.root.appendChild(this.arrow),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),document.body.appendChild(this.root)}colors;locale;root;arrow;showTimer=null;hideTimer=null;currentFeedbackId=null;tooltipId="sp-tooltip";show(e,t){this.currentFeedbackId!==e.id&&(this.cancelHide(),this.cancelShow(),this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(t),this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)"},It))}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Rt)}hide(){this.cancelShow(),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform="translateY(6px) scale(0.97)",setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden")},200)}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null)}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)}render(e){let t=Array.from(this.root.children);for(let c of t)c!==this.arrow&&c.remove();let i=A(e.type,this.colors),s=F(e.type,this.colors),r=U(this.locale),o=B(e.type,r),a=u("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=u("span",{style:`
1238
+ `}),this.root.appendChild(this.arrow),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),document.body.appendChild(this.root)}colors;locale;root;arrow;showTimer=null;hideTimer=null;currentFeedbackId=null;tooltipId="sp-tooltip";show(e,n){this.currentFeedbackId!==e.id&&(this.cancelHide(),this.cancelShow(),this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(n);let i=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=i?"none":"",this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)"},zt))}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),_t)}hide(){this.cancelShow(),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform="translateY(6px) scale(0.97)",setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden")},200)}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null)}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)}render(e){let n=Array.from(this.root.children);for(let p of n)p!==this.arrow&&p.remove();let i=I(e.type,this.colors),s=P(e.type,this.colors),o=ee(this.locale),r=B(e.type,o),a=h("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=h("span",{style:`
1180
1239
  padding:3px 10px;border-radius:9999px;
1181
1240
  font-size:11px;font-weight:600;
1182
1241
  color:${i};background:${s};
1183
1242
  letter-spacing:0.02em;
1184
- `});m(l,o);let p=u("span",{style:"font-size:11px;color:#64748b;margin-left:auto;"});m(p,q(e.createdAt,this.locale)),a.appendChild(l),a.appendChild(p);let d=u("div",{style:"font-size:13px;line-height:1.55;color:#0f172a;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;"});m(d,e.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(d,this.arrow)}position(e){let t=this.root.getBoundingClientRect(),i=10,s=e.top-t.height-i,r=e.left+e.width/2-t.width/2,o=!0;s<8&&(s=e.bottom+i,o=!1),r=Math.max(8,Math.min(r,window.innerWidth-t.width-8)),this.root.style.top=`${s}px`,this.root.style.left=`${r}px`;let a=Math.max(16,Math.min(e.left+e.width/2-r-6,t.width-22));o?this.arrow.style.cssText=`
1243
+ `});b(l,r);let c=h("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});b(c,X(e.createdAt,this.locale)),a.appendChild(l),a.appendChild(c);let d=h("div",{style:`font-size:13px;line-height:1.55;color:${this.colors.text};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;`});b(d,e.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(d,this.arrow)}position(e){let n=this.root.getBoundingClientRect(),i=10,s=e.top-n.height-i,o=e.left+e.width/2-n.width/2,r=!0;s<8&&(s=e.bottom+i,r=!1),o=Math.max(8,Math.min(o,window.innerWidth-n.width-8)),this.root.style.top=`${s}px`,this.root.style.left=`${o}px`;let a=Math.max(16,Math.min(e.left+e.width/2-o-6,n.width-22));r?this.arrow.style.cssText=`
1185
1244
  position:absolute;
1186
1245
  width:12px;height:12px;
1187
- background:rgba(255, 255, 255, 0.88);
1188
- border-right:1px solid rgba(255, 255, 255, 0.35);
1189
- border-bottom:1px solid rgba(255, 255, 255, 0.35);
1246
+ background:${this.colors.glassBgHeavy};
1247
+ border-right:1px solid ${this.colors.glassBorder};
1248
+ border-bottom:1px solid ${this.colors.glassBorder};
1190
1249
  transform:rotate(45deg);
1191
1250
  pointer-events:none;
1192
1251
  bottom:-6px;
@@ -1194,30 +1253,32 @@ var T,ne,ge;function ye(n,e){if(ge=new Date,n.nodeType!==Node.ELEMENT_NODE)throw
1194
1253
  `:this.arrow.style.cssText=`
1195
1254
  position:absolute;
1196
1255
  width:12px;height:12px;
1197
- background:rgba(255, 255, 255, 0.88);
1198
- border-left:1px solid rgba(255, 255, 255, 0.35);
1199
- border-top:1px solid rgba(255, 255, 255, 0.35);
1256
+ background:${this.colors.glassBgHeavy};
1257
+ border-left:1px solid ${this.colors.glassBorder};
1258
+ border-top:1px solid ${this.colors.glassBorder};
1200
1259
  transform:rotate(45deg);
1201
1260
  pointer-events:none;
1202
1261
  top:-6px;
1203
1262
  left:${a}px;
1204
- `}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove()}};function et(){let n=()=>{};return{destroy:n,open:n,close:n,refresh:n,on:()=>n,off:n}}function tt(n){let e=n.debug?(...f)=>console.debug("[siteping]",...f):()=>{};if(!n.forceShow)try{let f=import.meta,y=globalThis.process;if((f.env?.MODE??y?.env?.NODE_ENV)==="production"){let L="production";return console.info("[siteping] Widget not loaded: production mode detected. Use forceShow: true to override."),n.onSkip?.(L),et()}}catch{}if(window.innerWidth<768){let f="mobile";return console.info("[siteping] Widget not loaded: viewport width < 768px (mobile not supported)."),n.onSkip?.(f),et()}let t=n.locale??"fr",i=U(t);e("Initializing widget",{projectName:n.projectName,theme:n.theme??"light",locale:t});let s=Pe(n.accentColor,n.theme),r=new D,o=new D,a=new X(n.endpoint);n.onOpen&&r.on("open",n.onOpen),n.onClose&&r.on("close",n.onClose),n.onFeedbackSent&&r.on("feedback:sent",n.onFeedbackSent),n.onError&&r.on("feedback:error",n.onError),n.onAnnotationStart&&r.on("annotation:start",n.onAnnotationStart),n.onAnnotationEnd&&r.on("annotation:end",n.onAnnotationEnd),r.on("feedback:sent",f=>o.emit("feedback:sent",f)),r.on("feedback:deleted",f=>o.emit("feedback:deleted",f)),r.on("open",()=>o.emit("panel:open")),r.on("close",()=>o.emit("panel:close")),r.on("open",()=>e("Panel opened")),r.on("close",()=>e("Panel closed")),r.on("feedback:sent",f=>e("Feedback sent",f.id)),r.on("feedback:error",f=>e("Feedback failed",f.message)),r.on("annotation:start",()=>e("Annotation started")),r.on("annotation:end",()=>e("Annotation ended"));let l=document.createElement("siteping-widget");l.style.cssText="position:fixed;z-index:2147483647;";let d=(()=>{try{if(import.meta.env?.MODE==="test")return!0}catch{}try{if(globalThis.process?.env?.NODE_ENV==="test")return!0}catch{}return!1})()?"open":"closed",c=l.attachShadow({mode:d}),h=new CSSStyleSheet;h.replaceSync(Ze(s)),c.adoptedStyleSheets=[h],document.body.appendChild(l);let b=new ee(s,t),g=new J(s,b,r,i),k=new V(c,n,r,i),v=new Z(c,s,r,a,n.projectName,g,i,t),w=new G(s,r,i),x=r.on("annotation:complete",async f=>{let{annotation:y,type:E,message:L}=f,M=We();if(!M){if(M=await Nt(c,i),!M)return;Ge(M)}let H={projectName:n.projectName,type:E,message:L,url:window.location.href,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:M.name,authorEmail:M.email,annotations:[y],clientId:crypto.randomUUID()};try{let S=await a.sendFeedback(H);r.emit("feedback:sent",S),g.addFeedback(S,g.count+1),await v.refresh()}catch(S){r.emit("feedback:error",S instanceof Error?S:new Error(String(S)))}});return a.getFeedbacks(n.projectName,{limit:50}).then(({feedbacks:f})=>{g.render(f)}).catch(()=>{}),je(n.endpoint).then(()=>e("Retry queue flushed")).catch(()=>{}),{destroy:()=>{e("Destroying widget"),x(),k.destroy(),v.destroy(),w.destroy(),g.destroy(),b.destroy(),r.removeAll(),o.removeAll(),l.remove()},open:()=>{v.open()},close:()=>{v.close()},refresh:()=>{v.refresh()},on:(f,y)=>o.on(f,y),off:(f,y)=>{o.off(f,y)}}}function Nt(n,e){return new Promise(t=>{let i=n.activeElement??document.activeElement,s=document.createElement("div");s.style.cssText=`
1263
+ `}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove()}};var z=null;function ae(){let t=()=>{};return{destroy:t,open:t,close:t,refresh:t,on:()=>t,off:t}}function ct(t){let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(z)return e("initSiteping() called more than once \u2014 returning existing instance"),z;if(!t.forceShow)try{if(typeof process<"u"){let u="production";return console.info("[siteping] Widget not loaded: production mode detected. Use forceShow: true to override."),t.onSkip?.(u),ae()}}catch{}if(window.innerWidth<768){let u="mobile";return console.info("[siteping] Widget not loaded: viewport width < 768px (mobile not supported)."),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 n=t.locale??"en",i=ee(n);e("Initializing widget",{projectName:t.projectName,theme:t.theme??"light",locale:n});let s=Ge(t.accentColor,t.theme),o=new O,r=new O,a=t.store?new oe(t.store,t.projectName):new J(t.endpoint,t.projectName);t.onOpen&&o.on("open",t.onOpen),t.onClose&&o.on("close",t.onClose),t.onFeedbackSent&&o.on("feedback:sent",t.onFeedbackSent),t.onError&&o.on("feedback:error",t.onError),t.onAnnotationStart&&o.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&o.on("annotation:end",t.onAnnotationEnd),o.on("feedback:sent",u=>r.emit("feedback:sent",u)),o.on("feedback:deleted",u=>r.emit("feedback:deleted",u)),o.on("open",()=>r.emit("panel:open")),o.on("close",()=>r.emit("panel:close")),o.on("open",()=>e("Panel opened")),o.on("close",()=>e("Panel closed")),o.on("feedback:sent",u=>e("Feedback sent",u.id)),o.on("feedback:error",u=>e("Feedback failed",u.message)),o.on("annotation:start",()=>e("Annotation started")),o.on("annotation:end",()=>e("Annotation ended"));let l=document.createElement("siteping-widget");l.style.cssText="position:fixed;z-index:2147483647;";let c=!1;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(c=!0)}catch{}let d=c?"open":"closed",p=l.attachShadow({mode:d});if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;u.replaceSync(Ce(s)),p.adoptedStyleSheets=[u]}else{let u=document.createElement("style");u.textContent=Ce(s),p.appendChild(u)}document.body.appendChild(l);let m=document.createElement("div");m.setAttribute("role","status"),m.setAttribute("aria-live","polite"),m.setAttribute("aria-atomic","true"),m.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(m);let y=new re(s,n),T=new ie(s,y,o,i),k=new Z(p,t,o,i),C=new se(p,s,o,a,t.projectName,T,i,n),v=new Q(s,o,i),g=!1,x=o.on("annotation:complete",async u=>{if(!g){g=!0;try{let{annotation:w,type:S,message:E}=u,A=tt();if(!A){if(A=await Kt(p,i),!A)return;nt(A)}let L=new URL(window.location.href);for(let R of[...L.searchParams.keys()])/token|key|secret|auth|session|password|code/i.test(R)&&L.searchParams.delete(R);let _=L.toString(),dt=(()=>{try{return crypto.randomUUID()}catch{return`${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),pt={projectName:t.projectName,type:S,message:E,url:_,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:A.name,authorEmail:A.email,annotations:[w],clientId:dt};try{let R=await a.sendFeedback(pt);o.emit("feedback:sent",R),T.addFeedback(R,T.count+1),m.textContent=i("feedback.sent.confirmation"),await C.refresh()}catch(R){o.emit("feedback:error",R instanceof Error?R:new Error(String(R))),m.textContent=i("feedback.error.message")}}finally{g=!1}}});return a.getFeedbacks(t.projectName,{limit:50}).then(({feedbacks:u})=>{T.render(u)}).catch(u=>{e("Failed to load initial markers:",u)}),t.endpoint&&Qe(t.endpoint).then(()=>e("Retry queue flushed")).catch(()=>{}),z={destroy:()=>{e("Destroying widget"),x(),k.destroy(),C.destroy(),v.destroy(),T.destroy(),y.destroy(),o.removeAll(),r.removeAll(),m.remove(),l.remove(),z=null},open:()=>{C.open()},close:()=>{C.close()},refresh:()=>{C.refresh()},on:(u,w)=>r.on(u,w),off:(u,w)=>{r.off(u,w)}},z}function Kt(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,s=document.createElement("div");s.style.cssText=`
1205
1264
  position:fixed;inset:0;
1206
- background:rgba(15, 23, 42, 0.2);
1265
+ background:var(--sp-identity-overlay);
1207
1266
  backdrop-filter:blur(8px);
1208
1267
  -webkit-backdrop-filter:blur(8px);
1209
1268
  display:flex;align-items:center;justify-content:center;
1210
1269
  z-index:2147483647;
1211
1270
  opacity:0;transition:opacity 0.25s ease;
1212
- `;let r=document.createElement("div");r.style.cssText=`
1213
- width:340px;padding:28px;border-radius:20px;
1214
- background:rgba(255, 255, 255, 0.85);
1215
- backdrop-filter:blur(32px);
1216
- -webkit-backdrop-filter:blur(32px);
1217
- border:1px solid rgba(255, 255, 255, 0.35);
1218
- box-shadow:0 16px 48px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);
1219
- font-family:"Inter",system-ui,-apple-system,sans-serif;
1271
+ `;let o=document.createElement("div");o.style.cssText=`
1272
+ width:340px;padding:28px;border-radius:var(--sp-radius-xl);
1273
+ background:var(--sp-identity-bg);
1274
+ backdrop-filter:blur(var(--sp-blur-heavy));
1275
+ -webkit-backdrop-filter:blur(var(--sp-blur-heavy));
1276
+ border:1px solid var(--sp-glass-border);
1277
+ box-shadow:0 16px 48px var(--sp-shadow), 0 8px 16px var(--sp-shadow);
1278
+ font-family:var(--sp-font, "Inter",system-ui,-apple-system,sans-serif);
1279
+ color:var(--sp-text);
1220
1280
  transform:translateY(12px) scale(0.97);
1221
1281
  transition:transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
1222
1282
  -webkit-font-smoothing:antialiased;
1223
- `;let o=`sp-identity-title-${Date.now()}`;r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby",o);let a=document.createElement("div");a.className="sp-identity-title",a.id=o,a.textContent=e("identity.title"),a.style.marginBottom="20px";let l=`sp-identity-name-${Date.now()}`,p=`sp-identity-email-${Date.now()}`,d=document.createElement("label");d.className="sp-input-label",d.textContent=e("identity.nameLabel"),d.setAttribute("for",l);let c=document.createElement("input");c.className="sp-input",c.id=l,c.type="text",c.placeholder=e("identity.namePlaceholder"),c.style.marginBottom="14px";let h=document.createElement("label");h.className="sp-input-label",h.textContent=e("identity.emailLabel"),h.setAttribute("for",p);let b=document.createElement("input");b.className="sp-input",b.id=p,b.type="email",b.placeholder=e("identity.emailPlaceholder");let g=document.createElement("div");g.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let k=y=>{s.removeEventListener("keydown",f),s.style.opacity="0",r.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{s.remove(),i?.focus(),t(y)},250)},v=document.createElement("button");v.className="sp-btn-ghost",v.textContent=e("identity.cancel"),v.addEventListener("click",()=>k(null));let w=document.createElement("button");w.className="sp-btn-primary",w.textContent=e("identity.submit"),w.addEventListener("click",()=>{let y=c.value.trim(),E=b.value.trim();if(!y||!E)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E)){b.style.borderColor="#ef4444";return}k({name:y,email:E})});let x='input, button, [tabindex]:not([tabindex="-1"])',f=y=>{let E=y;if(E.key==="Escape"){k(null);return}if(E.key==="Tab"){let L=Array.from(r.querySelectorAll(x));if(L.length===0)return;let M=L[0],H=L[L.length-1],S=n.activeElement;E.shiftKey?(S===M||!r.contains(S))&&(E.preventDefault(),H.focus()):(S===H||!r.contains(S))&&(E.preventDefault(),M.focus())}};s.addEventListener("keydown",f),s.addEventListener("click",y=>{y.target===s&&k(null)}),g.appendChild(v),g.appendChild(w),r.appendChild(a),r.appendChild(d),r.appendChild(c),r.appendChild(h),r.appendChild(b),r.appendChild(g),s.appendChild(r),n.appendChild(s),requestAnimationFrame(()=>{s.style.opacity="1",r.style.transform="translateY(0) scale(1)",c.focus()})})}function Gn(n){return tt(n)}export{Gn as initSiteping};
1283
+ `;let r=`sp-identity-title-${Date.now()}`;o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-labelledby",r);let a=document.createElement("div");a.className="sp-identity-title",a.id=r,a.textContent=e("identity.title"),a.style.marginBottom="20px";let l=`sp-identity-name-${Date.now()}`,c=`sp-identity-email-${Date.now()}`,d=document.createElement("label");d.className="sp-input-label",d.textContent=e("identity.nameLabel"),d.setAttribute("for",l);let p=document.createElement("input");p.className="sp-input",p.id=l,p.type="text",p.placeholder=e("identity.namePlaceholder"),p.style.marginBottom="14px";let f=document.createElement("label");f.className="sp-input-label",f.textContent=e("identity.emailLabel"),f.setAttribute("for",c);let m=document.createElement("input");m.className="sp-input",m.id=c,m.type="email",m.placeholder=e("identity.emailPlaceholder");let y=document.createElement("div");y.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let T=x=>{s.removeEventListener("keydown",g),s.style.opacity="0",o.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{s.remove(),i?.focus(),n(x)},250)},k=document.createElement("button");k.className="sp-btn-ghost",k.textContent=e("identity.cancel"),k.addEventListener("click",()=>T(null));let C=document.createElement("button");C.className="sp-btn-primary",C.textContent=e("identity.submit"),C.addEventListener("click",()=>{let x=p.value.trim(),u=m.value.trim();if(!x||!u)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)){m.style.borderColor="var(--sp-type-bug, #ef4444)";return}T({name:x,email:u})});let v='input, button, [tabindex]:not([tabindex="-1"])',g=x=>{let u=x;if(u.key==="Escape"){T(null);return}if(u.key==="Tab"){let w=Array.from(o.querySelectorAll(v));if(w.length===0)return;let S=w[0],E=w[w.length-1];if(!S||!E)return;let A=t.activeElement;u.shiftKey?(A===S||!o.contains(A))&&(u.preventDefault(),E.focus()):(A===E||!o.contains(A))&&(u.preventDefault(),S.focus())}};s.addEventListener("keydown",g),s.addEventListener("click",x=>{x.target===s&&T(null)}),y.appendChild(k),y.appendChild(C),o.appendChild(a),o.appendChild(d),o.appendChild(p),o.appendChild(f),o.appendChild(m),o.appendChild(y),s.appendChild(o),t.appendChild(s),requestAnimationFrame(()=>{s.style.opacity="1",o.style.transform="translateY(0) scale(1)",p.focus()})})}function gi(t){return ct(t)}export{gi as initSiteping};
1284
+ //# sourceMappingURL=index.js.map