@siteping/widget 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-CX5YE4V3.js → chunk-26577FDQ.js} +3 -3
  3. package/dist/chunk-26577FDQ.js.map +1 -0
  4. package/dist/{chunk-CVWZCWBQ.js → chunk-3EHIWTJH.js} +3 -3
  5. package/dist/chunk-3EHIWTJH.js.map +1 -0
  6. package/dist/{chunk-QW2L5ARZ.cjs → chunk-6MCFOKVG.cjs} +3 -3
  7. package/dist/chunk-6MCFOKVG.cjs.map +1 -0
  8. package/dist/{chunk-KCOX2NRI.cjs → chunk-Q34GDCKE.cjs} +3 -3
  9. package/dist/chunk-Q34GDCKE.cjs.map +1 -0
  10. package/dist/index.cjs +3 -3
  11. package/dist/index.global.js +2 -2
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/ko-U2CS6XQ4.js +2 -0
  15. package/dist/ko-U2CS6XQ4.js.map +1 -0
  16. package/dist/ko-ZUL567LW.cjs +2 -0
  17. package/dist/ko-ZUL567LW.cjs.map +1 -0
  18. package/dist/{panel-HGYK7HVK.cjs → panel-3BEMZFIR.cjs} +2 -2
  19. package/dist/{panel-HGYK7HVK.cjs.map → panel-3BEMZFIR.cjs.map} +1 -1
  20. package/dist/{panel-RE2IHZ4S.js → panel-HPDIAYLQ.js} +2 -2
  21. package/dist/{panel-RE2IHZ4S.js.map → panel-HPDIAYLQ.js.map} +1 -1
  22. package/dist/{panel-RHSIY6KS.cjs → panel-MIWFGD7X.cjs} +2 -2
  23. package/dist/{panel-RHSIY6KS.cjs.map → panel-MIWFGD7X.cjs.map} +1 -1
  24. package/dist/{panel-XVIF2WMU.js → panel-XTNU6XHV.js} +2 -2
  25. package/dist/{panel-XVIF2WMU.js.map → panel-XTNU6XHV.js.map} +1 -1
  26. package/dist/react.cjs +3 -3
  27. package/dist/react.js +2 -2
  28. package/dist/types.d.cts +2 -2
  29. package/dist/types.d.ts +2 -2
  30. package/package.json +3 -3
  31. package/dist/chunk-CVWZCWBQ.js.map +0 -1
  32. package/dist/chunk-CX5YE4V3.js.map +0 -1
  33. package/dist/chunk-KCOX2NRI.cjs.map +0 -1
  34. package/dist/chunk-QW2L5ARZ.cjs.map +0 -1
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkQW2L5ARZ_cjs=require('./chunk-QW2L5ARZ.cjs');var P=class{element;current;opts;onChange;datasetKey;constructor(e){this.opts=e.options,this.current=e.value,this.onChange=e.onChange,this.datasetKey=e.datasetKey,this.element=chunkQW2L5ARZ_cjs.y("div",{class:`sp-segmented${e.extraClass?` ${e.extraClass}`:""}`,role:"radiogroup"}),this.element.setAttribute("aria-label",e.ariaLabel);for(let t of this.opts){let i=document.createElement("button");i.type="button",i.className=e.modifierPrefix!==void 0?`sp-segmented__btn ${e.modifierPrefix}${t.value}`:"sp-segmented__btn",i.dataset[this.datasetKey]=t.value,i.setAttribute("role","radio");let s=this.current===t.value;if(i.setAttribute("aria-checked",String(s)),i.tabIndex=s?0:-1,s&&i.classList.add("sp-segmented__btn--active"),t.color&&i.style.setProperty("--sp-chip-color",t.color),t.bg&&i.style.setProperty("--sp-chip-bg",t.bg),t.icon){let o=chunkQW2L5ARZ_cjs.y("span",{class:"sp-segmented__icon"});o.appendChild(chunkQW2L5ARZ_cjs.x(t.icon)),i.appendChild(o);}let n=chunkQW2L5ARZ_cjs.y("span",{class:"sp-segmented__label"});chunkQW2L5ARZ_cjs.z(n,t.label),i.appendChild(n),i.addEventListener("click",()=>this.select(t.value)),i.addEventListener("keydown",o=>this.handleKey(o,t.value)),this.element.appendChild(i);}}select(e){this.current=e,this.syncSelection(),this.onChange(e);}syncSelection(){let e=this.element.querySelectorAll(".sp-segmented__btn");for(let t of e){let i=t.dataset[this.datasetKey]===this.current;t.classList.toggle("sp-segmented__btn--active",i),t.setAttribute("aria-checked",String(i)),t.tabIndex=i?0:-1;}}setOptionVisible(e,t){let i=this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`);return i?(i.style.display=t?"":"none",true):false}get value(){return this.current}focusOption(e){this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`)?.focus();}handleKey(e,t){let i=this.opts.map(d=>d.value).filter(d=>{let p=this.element.querySelector(`[data-${this.kebabKey()}="${d}"]`);return p!==null&&p.style.display!=="none"}),s=i.indexOf(t);if(s<0)return;let n;switch(e.key){case "ArrowLeft":n=(s-1+i.length)%i.length;break;case "ArrowRight":n=(s+1)%i.length;break;case "Home":n=0;break;case "End":n=i.length-1;break;default:return}e.preventDefault();let o=i[n];o!==void 0&&(this.select(o),this.focusOption(o));}kebabKey(){return this.datasetKey.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}};function j({input:M,send:e},t){M.readOnly=t,e.setAttribute("aria-busy",String(t)),e.setAttribute("aria-disabled",String(t));}var Fe=0;function Le(M,{t:e,locale:t,canPost:i,draft:s,post:n}){let o=M.comments??[];if(!i&&o.length===0)return null;let d=chunkQW2L5ARZ_cjs.y("div"),p=chunkQW2L5ARZ_cjs.y("ol",{class:"sp-thread-list",role:"list","aria-label":e("comments.title"),"aria-live":"polite"}),f=new Set,v=a=>{if(f.has(a.id))return;f.add(a.id);let l=chunkQW2L5ARZ_cjs.y("li",{class:"sp-detail-message sp-comment","data-role":a.authorRole}),m=chunkQW2L5ARZ_cjs.y("div",{class:"sp-comment-head"}),k=chunkQW2L5ARZ_cjs.y("span");if(chunkQW2L5ARZ_cjs.z(k,a.authorName),m.appendChild(k),a.authorRole==="team"){let T=chunkQW2L5ARZ_cjs.y("span",{class:"sp-badge"});chunkQW2L5ARZ_cjs.z(T,e("comments.team")),m.appendChild(T);}let E=chunkQW2L5ARZ_cjs.y("time",{datetime:a.createdAt});chunkQW2L5ARZ_cjs.z(E,chunkQW2L5ARZ_cjs.E(a.createdAt,t)),m.appendChild(E);let S=chunkQW2L5ARZ_cjs.y("div");chunkQW2L5ARZ_cjs.z(S,a.body),l.append(m,S),p.appendChild(l);};for(let a of o)v(a);if(d.appendChild(p),!i)return d;let c=document.createElement("textarea");c.className="sp-input sp-thread-input",c.rows=3,c.maxLength=chunkQW2L5ARZ_cjs.j,c.placeholder=e("comments.placeholder"),c.setAttribute("aria-label",c.placeholder),c.value=s.text,c.addEventListener("input",()=>{s.text=c.value;});let u=chunkQW2L5ARZ_cjs.y("div",{class:"sp-thread-foot"}),C=chunkQW2L5ARZ_cjs.y("span",{id:`sp-thread-hint-${++Fe}`});chunkQW2L5ARZ_cjs.ga()||(chunkQW2L5ARZ_cjs.z(C,e(chunkQW2L5ARZ_cjs.D()?"popup.submitHintMac":"popup.submitHintOther")),c.setAttribute("aria-describedby",C.id),c.setAttribute("aria-keyshortcuts","Control+Enter Meta+Enter"));let b=document.createElement("button");b.type="button",b.className="sp-btn-primary",chunkQW2L5ARZ_cjs.z(b,e("popup.submit")),u.append(C,b);let g=chunkQW2L5ARZ_cjs.y("div",{class:"sp-thread-error",role:"alert"});d.append(c,u,g);let y={add:v,input:c,send:b,error:g};s.view=y,j(y,s.sending===true);let w=async()=>{s.text=c.value;let a=s.text.trim();if(s.sending||!a)return;s.sent?.body!==a&&(s.sent={body:a,clientId:chunkQW2L5ARZ_cjs.p()});let{clientId:l}=s.sent;s.sending=true,chunkQW2L5ARZ_cjs.z(g,""),j(y,true);let m="",k=null;try{k=await n(a,l);}catch(S){m=e(chunkQW2L5ARZ_cjs.u(S)?"comments.full":"comments.error");}s.sending=false;let E=s.view??y;j(E,false),chunkQW2L5ARZ_cjs.z(E.error,m),k&&(E.add(k),E.input.value=s.text="",s.sent=void 0);};return b.addEventListener("click",()=>{w();}),c.addEventListener("keydown",a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),w());}),d}var Be=chunkQW2L5ARZ_cjs.f.filter(M=>!chunkQW2L5ARZ_cjs.h(M)),Ae=class{constructor(e,t,i,s,n,o,d,p,f){this.colors=t;this.bus=i;this.client=s;this.projectName=n;this.markers=o;this.t=d;this.locale=p;this.shadowRoot=e,this.readOnly=!!f?.readOnly,this.resolveIdentity=f?.resolveIdentity??(async()=>null),this.getScope=f?.getScope??(()=>({url:window.location.pathname,urlPattern:null})),this.scopeAnnotationsByUrl=f?.scopeAnnotationsByUrl??true,this.ownFeedback=f?.ownFeedback??{ids:()=>new Set,remove:()=>{}},this.scrim=chunkQW2L5ARZ_cjs.y("div",{class:"sp-scrim"}),this.scrim.addEventListener("click",()=>this.close()),this.root=chunkQW2L5ARZ_cjs.y("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 v=chunkQW2L5ARZ_cjs.y("div",{class:"sp-panel-header"}),c=chunkQW2L5ARZ_cjs.y("span",{class:"sp-panel-title"});chunkQW2L5ARZ_cjs.z(c,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(chunkQW2L5ARZ_cjs.x(chunkQW2L5ARZ_cjs.M)),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(chunkQW2L5ARZ_cjs.x(chunkQW2L5ARZ_cjs.X));let u=document.createElement("span");chunkQW2L5ARZ_cjs.z(u,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(u),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll()),chunkQW2L5ARZ_cjs.B(this.deleteAllBtn,true),this.exportBtn=new chunkQW2L5ARZ_cjs.pa(t,()=>this.feedbacks,this.t);let C=chunkQW2L5ARZ_cjs.y("div",{class:"sp-panel-header-right"});C.appendChild(this.exportBtn.element),C.appendChild(this.deleteAllBtn),C.appendChild(this.closeBtn),v.appendChild(c),v.appendChild(C),this.stats=new chunkQW2L5ARZ_cjs.Ba(t,this.t);let b=chunkQW2L5ARZ_cjs.y("div",{class:"sp-filters"}),g=chunkQW2L5ARZ_cjs.y("div",{class:"sp-search-wrap"}),y=chunkQW2L5ARZ_cjs.x(chunkQW2L5ARZ_cjs.N);y.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(y),g.appendChild(this.searchInput);let w=chunkQW2L5ARZ_cjs.y("div",{class:"sp-filter-bar"});w.appendChild(this.buildTypeDropdown()),w.appendChild(this.buildStatusSegmented()),w.appendChild(this.buildScopeSegmented()),w.appendChild(this.buildMineToggle()),this.sortControls=new chunkQW2L5ARZ_cjs.ya(t,()=>this.renderList(),this.t),b.appendChild(g),b.appendChild(w),b.appendChild(this.sortControls.element),this.listContainer=chunkQW2L5ARZ_cjs.y("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label",this.t("panel.feedbackList")),this.bulk=new chunkQW2L5ARZ_cjs.ra(t,{onResolve:a=>this.bulkResolve(a),onDelete:a=>this.bulkDelete(a),permits:(a,l)=>this.feedbacks.every(m=>!a.includes(m.id)||this.can(m,l))},this.t),this.bulk.setListContainer(this.listContainer),this.detail=new chunkQW2L5ARZ_cjs.ua(t,{onBack:()=>this.detail.hide(),onResolve:async a=>{try{let l=!chunkQW2L5ARZ_cjs.h(a.status);await this.client.resolveFeedback(a.id,l),await this.loadFeedbacks(),this.detail.hide();}catch(l){throw this.bus.emit("feedback:error",l instanceof Error?l:new Error(String(l))),l}},onDelete:async a=>{try{await this.client.deleteFeedback(a.id),this.bus.emit("feedback:deleted",a.id),await this.loadFeedbacks(),this.detail.hide();}catch(l){throw this.bus.emit("feedback:error",l instanceof Error?l:new Error(String(l))),l}},canGoToAnnotation:a=>!this.scopeAnnotationsByUrl||a.url===this.getScope().url,onGoToAnnotation:a=>{if(a.annotations.length>0){let l=a.annotations[0];if(!l)return;this.markers.revealPin(a.id)||(window.scrollTo({left:l.scrollX,top:l.scrollY,behavior:"smooth"}),this.markers.pinHighlight(a)),chunkQW2L5ARZ_cjs.fa()&&this.close();}},onCustomAction:async(a,l)=>{try{await a.onAction(l,{refresh:()=>this.refreshDetail(l.id),close:()=>this.close()});}catch(m){this.reportActionError(m);}},onCustomActionError:a=>this.reportActionError(a),permits:(a,l)=>this.can(a,l),buildThread:a=>Le(a,{t:this.t,locale:p,canPost:this.canComment&&a.permissions?.canComment!==false,draft:this.draftOf(a.id),post:(l,m)=>this.postComment(a,l,m)})},this.t,p,chunkQW2L5ARZ_cjs.sa(f?.panelActions)),this.shortcuts=new chunkQW2L5ARZ_cjs.Fa(t,{onNavigate:a=>{let l=chunkQW2L5ARZ_cjs.Ca(this.listContainer);chunkQW2L5ARZ_cjs.Da(this.listContainer,a==="down"?l+1:l-1);},onResolve:()=>this.pressInFocusedCard('[data-action="resolve"]'),onDelete:()=>this.pressInFocusedCard('[data-action="delete"]'),onFocusSearch:()=>this.searchInput.focus(),onToggleSelect:()=>this.pressInFocusedCard(".sp-bulk-checkbox"),isSuspended:()=>this.detail.isVisible},this.t),this.root.appendChild(v),this.root.appendChild(this.stats.element),this.root.appendChild(b),this.root.appendChild(this.listContainer),this.root.appendChild(this.bulk.barElement),this.root.appendChild(this.detail.element),this.root.appendChild(this.shortcuts.helpOverlay),this.root.appendChild(this.shortcuts.hintButton),e.appendChild(this.scrim),e.appendChild(this.root),this.attachSheetDrag(),this.onListClick=a=>{let l=a.target;if(l.closest(".sp-bulk-checkbox"))return;let m=l.closest("[data-action]");if(m){a.stopPropagation();let E=m.closest(".sp-card");if(!E)return;let S=E.dataset.feedbackId,T=this.feedbacks.find(L=>L.id===S);if(!T)return;let F=m.dataset.action;if(F==="expand"){let L=E.querySelector(".sp-card-message");if(!L)return;let U=L.classList.toggle("sp-card-message--expanded");chunkQW2L5ARZ_cjs.z(m,U?this.t("panel.showLess"):this.t("panel.showMore")),m.setAttribute("aria-expanded",String(U));}else if(F==="resolve"){if(this.pendingMutations.has(T.id))return;let L=m;this.toggleResolve(T,L).catch(()=>{});}else if(F==="delete"){if(this.pendingMutations.has(T.id))return;let L=m;this.deleteFeedback(T,L).catch(()=>{});}return}let k=l.closest(".sp-card");if(k){let E=k.dataset.feedbackId,S=this.feedbacks.find(T=>T.id===E);S&&this.detail.show(S,Number(k.dataset.number));}},this.listContainer.addEventListener("click",this.onListClick),this.onListKeydown=a=>{let l=a;if(l.key!=="Enter"&&l.key!==" ")return;let m=l.target,k=m.closest(".sp-card");if(!k||m!==k)return;l.preventDefault();let E=k.dataset.feedbackId,S=this.feedbacks.find(T=>T.id===E);S&&this.detail.show(S,Number(k.dataset.number));},this.listContainer.addEventListener("keydown",this.onListKeydown),this.onListMouseover=a=>{let m=a.target.closest(".sp-card");if(!m)return;let k=m.dataset.feedbackId;k&&this.markers.highlight(k);},this.listContainer.addEventListener("mouseover",this.onListMouseover),this.onListMouseout=a=>{let l=a.relatedTarget;l&&this.listContainer.contains(l)||this.markers.highlight("");},this.listContainer.addEventListener("mouseout",this.onListMouseout),this.bus.on("panel:toggle",a=>{a?this.open():this.close();}),chunkQW2L5ARZ_cjs.H(e,()=>this.isOpen),e.addEventListener("keydown",a=>{let l=a;if(l.key==="Escape"&&this.isOpen){if(this.shortcuts.isHelpVisible)return;if(this.detail.isVisible){this.detail.hide();return}this.close();return}if(l.key==="Tab"&&this.isOpen){let m=F=>{let L=F;for(;L&&L!==this.root;){if(getComputedStyle(L).display==="none")return false;L=L.parentElement;}return true},k=Array.from(this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(F=>m(F)&&!F.hasAttribute("disabled"));if(k.length===0)return;let E=k[0],S=k[k.length-1];if(!E||!S)return;let T=e.activeElement;l.shiftKey&&T===E?(l.preventDefault(),S.focus()):!l.shiftKey&&T===S&&(l.preventDefault(),E.focus());}}),this.onMarkerClick=(a=>{this.scrollToFeedback(a.detail.feedbackId);}),document.addEventListener("sp-marker-click",this.onMarkerClick);}colors;bus;client;projectName;markers;t;locale;root;scrim;listContainer;searchInput;closeBtn;deleteAllBtn;activeFilters=new Set(["all"]);typeDropdownBtn;typeDropdownContainer;typeDropdownMenu=null;removeTypeDropdownOutsideClick=null;statusSegmented;typeOptions;feedbacks=[];currentPage=1;totalFeedbacks=0;isLoadingMore=false;isOpen=false;searchTimeout=null;loadController=null;isLoading=false;pendingScrollId=null;pendingMutations=new Set;canComment=false;threadDrafts=new Map;readOnly;resolveIdentity;stats;sortControls;bulk;exportBtn;shortcuts;detail;shadowRoot;getScope;scopeAnnotationsByUrl;scopeSegmented;initialScopeFilter="this";mineOnly=false;ownFeedback;onMarkerClick;onListClick;onListKeydown;onListMouseover;onListMouseout;async open(){if(this.isOpen)return;this.isOpen=true;let e=chunkQW2L5ARZ_cjs.fa();this.root.setAttribute("role",e?"dialog":"complementary"),e?this.root.setAttribute("aria-modal","true"):this.root.removeAttribute("aria-modal"),this.root.classList.add("sp-panel--open"),this.scrim.classList.add("sp-scrim--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),this.shortcuts.enable(this.shadowRoot),await this.loadFeedbacks(),requestAnimationFrame(()=>{(chunkQW2L5ARZ_cjs.ga()?this.closeBtn:this.searchInput).focus();});}close(){if(!this.isOpen)return;this.isOpen=false,this.root.classList.remove("sp-panel--open"),this.scrim.classList.remove("sp-scrim--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.shortcuts.disable(),this.detail.hide(),this.pendingScrollId=null,this.root.getRootNode().querySelector(".sp-fab")?.focus();}attachSheetDrag(){let e=0,t=0,i=0,s=false;this.root.addEventListener("pointerdown",o=>{let d=o.target;o.pointerType==="mouse"||!chunkQW2L5ARZ_cjs.fa()||d.closest("button")||!d.closest(".sp-panel-header, .sp-detail-header")||(s=true,e=o.clientY,t=o.timeStamp,i=0,this.root.style.transition="none",this.root.setPointerCapture?.(o.pointerId));}),this.root.addEventListener("pointermove",o=>{s&&(i=Math.max(0,o.clientY-e),this.root.style.transform=`translateY(${i}px)`);});let n=o=>{if(!s)return;s=false,this.root.style.transition="",this.root.style.transform="",(i>40&&i/Math.max(1,o.timeStamp-t)>.5||i>this.root.offsetHeight/4)&&this.close();};this.root.addEventListener("pointerup",n),this.root.addEventListener("pointercancel",n);}showLoading(){this.listContainer.replaceChildren();let e=chunkQW2L5ARZ_cjs.y("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label",this.t("panel.loading"));let t=chunkQW2L5ARZ_cjs.y("div",{class:"sp-spinner"});e.appendChild(t),this.listContainer.appendChild(e);}showError(){this.listContainer.replaceChildren();let e=chunkQW2L5ARZ_cjs.y("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=chunkQW2L5ARZ_cjs.y("div",{class:"sp-empty-text"});chunkQW2L5ARZ_cjs.z(t,this.t("panel.loadError"));let i=document.createElement("button");i.className="sp-btn-ghost",i.style.marginTop="8px",chunkQW2L5ARZ_cjs.z(i,this.t("panel.retry")),i.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(t),e.appendChild(i),this.listContainer.appendChild(e);}statusBucket(e){if(e!=="all")return chunkQW2L5ARZ_cjs.h(e)?chunkQW2L5ARZ_cjs.g:Be}async loadFeedbacks(e=1){this.loadController?.abort(),this.loadController=new AbortController;let{signal:t}=this.loadController;this.currentPage=1;let i=this.searchInput.value.trim()||void 0,s=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],n=this.statusBucket(this.statusSegmented.value),o=this.getScope();this.syncScopeAvailability();let d=this.scopeSegmented.value,p={page:1,limit:20};s&&(p.type=s),n&&(p.statuses=n),i&&(p.search=i),d==="this"?p.url=o.url:d==="template"&&o.urlPattern&&(p.urlPattern=o.urlPattern);let f=this.feedbacks.length>0;f||this.showLoading();let v=!this.mineOnly&&this.isMarkerQuery(p,o);this.isLoading=true;try{let c=this.mineOnly?this.fetchOwnFeedbacks(p,t):this.client.getFeedbacks(this.projectName,p);v||this.loadPageMarkers(o,t);let u=await c,{feedbacks:C,total:b}=u,g=1;for(;g<e&&C.length<b&&!t.aborted;){g++;let y=await this.client.getFeedbacks(this.projectName,{...p,page:g});C=[...C,...y.feedbacks],b=y.total;}if(t.aborted)return;this.currentPage=g,this.feedbacks=C,this.totalFeedbacks=b,this.canComment=u.capabilities?.comments===!0,chunkQW2L5ARZ_cjs.B(this.deleteAllBtn,this.readOnly||u.permissions?.canDeleteAll===!1),this.stats.update(C,b),this.bulk.reset(),this.renderList(),this.pendingScrollId&&this.flashCard(this.pendingScrollId),v&&this.renderPageMarkers(C,o);}catch(c){if(t.aborted)return;f||this.showError(),this.bus.emit("feedback:error",c instanceof Error?c:new Error(String(c)));}finally{t.aborted||(this.isLoading=false,this.pendingScrollId=null);}}async loadMoreFeedbacks(){if(this.isLoadingMore)return;this.isLoadingMore=true;let e=this.loadController,t=this.currentPage+1,i=this.searchInput.value.trim()||void 0,s=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],n=this.statusBucket(this.statusSegmented.value),o=this.getScope(),d=this.scopeSegmented.value,p={page:t,limit:20};s&&(p.type=s),n&&(p.statuses=n),i&&(p.search=i),d==="this"?p.url=o.url:d==="template"&&o.urlPattern&&(p.urlPattern=o.urlPattern);let f=this.listContainer.querySelector(".sp-btn-load-more"),v;f&&(v=chunkQW2L5ARZ_cjs.C(f));try{let{feedbacks:c,total:u}=await this.client.getFeedbacks(this.projectName,p);if(e!==this.loadController)return;this.currentPage=t,this.totalFeedbacks=u,this.feedbacks=[...this.feedbacks,...c],this.stats.update(this.feedbacks,u),this.renderList(),this.isMarkerQuery(p,o)&&this.renderPageMarkers(this.feedbacks,o);}catch(c){v&&v(),this.bus.emit("feedback:error",c instanceof Error?c:new Error(String(c)));}finally{this.isLoadingMore=false;}}isMarkerQuery(e,t){let i=this.scopeAnnotationsByUrl?t.url:void 0;return !e.type&&!e.statuses&&!e.search&&!e.urlPattern&&e.url===i}async fetchOwnFeedbacks(e,t){let i=this.ownFeedback.ids(),s=new Map,n=new Set,o=0,d,p=true,f,v;for(let u=1;s.size<i.size&&!t.aborted;u++){let C=await this.client.getFeedbacks(this.projectName,{...e,page:u,limit:100}),{feedbacks:b,total:g}=C;f=C.capabilities,v=C.permissions,d??=g,p&&=g===d;for(let y of b)n.add(y.id),i.has(y.id)&&s.set(y.id,y);if(o+=b.length,b.length===0||o>=g)break}return Object.keys(e).every(u=>u==="page"||u==="limit")&&p&&n.size===d&&this.ownFeedback.remove(...[...i].filter(u=>!s.has(u))),{feedbacks:[...s.values()],total:s.size,capabilities:f,permissions:v}}async loadPageMarkers(e,t){let i=this.scopeAnnotationsByUrl?{limit:20,url:e.url}:{limit:20};try{let{feedbacks:s}=await this.client.getFeedbacks(this.projectName,i);t.aborted||this.renderPageMarkers(s,e);}catch{}}renderPageMarkers(e,t){this.markers.render(this.scopeAnnotationsByUrl?e.filter(i=>i.url===t.url):e);}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let s=chunkQW2L5ARZ_cjs.y("div",{class:"sp-empty"});s.setAttribute("role","status"),s.setAttribute("aria-live","polite");let n=chunkQW2L5ARZ_cjs.y("div",{class:"sp-empty-text"});chunkQW2L5ARZ_cjs.z(n,this.t("panel.empty")),s.appendChild(n),this.listContainer.appendChild(s);return}let e=chunkQW2L5ARZ_cjs.va(this.feedbacks,this.sortControls.sortMode),t=e.filter(s=>this.selectable(s)).map(s=>s.id);if(t.length>0&&this.listContainer.appendChild(this.bulk.createSelectAllBar(t,this.t("bulk.selectAll"))),this.sortControls.groupByPage){let s=chunkQW2L5ARZ_cjs.wa(e),n=0;for(let[o,d]of s){let p=chunkQW2L5ARZ_cjs.xa(o,d.length,this.colors);this.listContainer.appendChild(p);let f=chunkQW2L5ARZ_cjs.y("div",{class:"sp-group-content"});for(let v of d){let c=this.createCard(v,n+1);c.style.setProperty("--sp-card-i",String(n)),f.appendChild(c),n++;}this.listContainer.appendChild(f);}}else e.forEach((s,n)=>{let o=this.createCard(s,n+1);o.style.setProperty("--sp-card-i",String(n)),this.listContainer.appendChild(o);});let i=this.totalFeedbacks-this.feedbacks.length;if(i>0){let s=chunkQW2L5ARZ_cjs.y("div",{class:"sp-load-more-wrap"}),n=document.createElement("button");n.className="sp-btn-ghost sp-btn-load-more",chunkQW2L5ARZ_cjs.z(n,chunkQW2L5ARZ_cjs.la(this.t,"panel.loadMore",{remaining:i})),n.addEventListener("click",()=>this.loadMoreFeedbacks().catch(()=>{})),s.appendChild(n),this.listContainer.appendChild(s);}}createCard(e,t){let i=chunkQW2L5ARZ_cjs.h(e.status),s=chunkQW2L5ARZ_cjs.aa(e.type,this.colors),n=chunkQW2L5ARZ_cjs.y("div",{class:`sp-card ${i?"sp-card--resolved":""}`});n.classList.toggle("sp-card--selected",this.bulk.isSelected(e.id)),n.setAttribute("role","listitem"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label",`Feedback #${t}: ${chunkQW2L5ARZ_cjs.ma(e.type,this.t)} \u2014 ${e.message.slice(0,80)}`),n.dataset.feedbackId=e.id,n.dataset.number=String(t);let o=chunkQW2L5ARZ_cjs.y("div",{class:"sp-card-bar"});o.style.background=i?"#9ca3af":s;let d=chunkQW2L5ARZ_cjs.y("div",{class:"sp-card-body"}),p=chunkQW2L5ARZ_cjs.y("div",{class:"sp-card-header"});this.selectable(e)&&p.appendChild(this.bulk.createCheckbox(e.id));let f=chunkQW2L5ARZ_cjs.y("span",{class:"sp-card-number"});chunkQW2L5ARZ_cjs.z(f,`#${t}`);let v=chunkQW2L5ARZ_cjs.y("span",{class:"sp-badge"}),c=chunkQW2L5ARZ_cjs.da(e.type,this.colors);v.style.background=c,v.style.color=s,chunkQW2L5ARZ_cjs.z(v,chunkQW2L5ARZ_cjs.ma(e.type,this.t));let u=chunkQW2L5ARZ_cjs.y("span",{class:"sp-badge sp-badge--status"});u.dataset.status=e.status,u.style.background=chunkQW2L5ARZ_cjs.ca(e.status,this.colors),u.style.color=chunkQW2L5ARZ_cjs.ba(e.status,this.colors),chunkQW2L5ARZ_cjs.z(u,chunkQW2L5ARZ_cjs.na(e.status,this.t));let C=chunkQW2L5ARZ_cjs.y("span",{class:"sp-card-date"});chunkQW2L5ARZ_cjs.z(C,chunkQW2L5ARZ_cjs.E(e.createdAt,this.locale)),p.appendChild(f),p.appendChild(v),p.appendChild(u),p.appendChild(C);let b=chunkQW2L5ARZ_cjs.y("div",{class:"sp-card-message"});chunkQW2L5ARZ_cjs.z(b,e.message);let g=document.createElement("button");g.className="sp-card-expand",g.dataset.action="expand",chunkQW2L5ARZ_cjs.z(g,this.t("panel.showMore")),g.style.display="none",g.setAttribute("aria-expanded","false"),requestAnimationFrame(()=>{b.scrollHeight>b.clientHeight&&(g.style.display="block");});let y=chunkQW2L5ARZ_cjs.y("div",{class:"sp-card-footer"}),w=document.createElement("button");w.className="sp-btn-resolve",w.dataset.action="resolve",w.appendChild(chunkQW2L5ARZ_cjs.x(i?chunkQW2L5ARZ_cjs.W:chunkQW2L5ARZ_cjs.O));let a=document.createElement("span");chunkQW2L5ARZ_cjs.z(a,` ${this.t(i?"panel.reopen":"panel.resolve")}`),w.appendChild(a);let l=document.createElement("button");l.className="sp-btn-delete",l.dataset.action="delete",l.appendChild(chunkQW2L5ARZ_cjs.x(chunkQW2L5ARZ_cjs.X));let m=document.createElement("span");return chunkQW2L5ARZ_cjs.z(m,` ${this.t("panel.delete")}`),l.appendChild(m),this.can(e,"canChangeStatus")&&y.appendChild(w),this.can(e,"canDelete")&&y.appendChild(l),d.appendChild(p),d.appendChild(b),d.appendChild(g),y.hasChildNodes()&&d.appendChild(y),n.appendChild(o),n.appendChild(d),n}can(e,t){return !this.readOnly&&e.permissions?.[t]!==false}selectable(e){return this.can(e,"canChangeStatus")||this.can(e,"canDelete")}async bulkResolve(e){let t=new Set(this.feedbacks.filter(n=>chunkQW2L5ARZ_cjs.h(n.status)).map(n=>n.id)),i=e.filter(n=>!t.has(n)),s=await Promise.allSettled(i.map(n=>this.client.resolveFeedback(n,true)));await this.settleBulk(i,s);}async bulkDelete(e){let t=await Promise.allSettled(e.map(i=>this.client.deleteFeedback(i)));e.forEach((i,s)=>{t[s]?.status==="fulfilled"&&this.bus.emit("feedback:deleted",i);}),await this.settleBulk(e,t);}async settleBulk(e,t){let i=e.filter((d,p)=>t[p]?.status==="rejected");i.length<e.length&&await this.loadFeedbacks();let s=t.find(d=>d.status==="rejected");if(!s)return;let n=new Set(this.feedbacks.map(d=>d.id));this.bulk.selectAll(i.filter(d=>n.has(d)));let o=s.reason instanceof Error?s.reason:new Error(String(s.reason));throw this.bus.emit("feedback:error",o),o}async confirmDeleteAll(){if(await this.showConfirmDialog(this.t("panel.deleteAllConfirmTitle"),this.t("panel.deleteAllConfirmMessage"))){this.deleteAllBtn.disabled=true;try{await this.client.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=false;}}}showConfirmDialog(e,t){return new Promise(i=>{let s=chunkQW2L5ARZ_cjs.y("div",{class:"sp-confirm-backdrop"}),n=`sp-confirm-title-${Date.now()}`,o=`sp-confirm-msg-${Date.now()}`,d=chunkQW2L5ARZ_cjs.y("div",{class:"sp-confirm-dialog"});d.setAttribute("role","alertdialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby",n),d.setAttribute("aria-describedby",o);let p=chunkQW2L5ARZ_cjs.y("div",{class:"sp-confirm-title"});p.id=n,chunkQW2L5ARZ_cjs.z(p,e);let f=chunkQW2L5ARZ_cjs.y("div",{class:"sp-confirm-message"});f.id=o,chunkQW2L5ARZ_cjs.z(f,t);let v=chunkQW2L5ARZ_cjs.y("div",{class:"sp-confirm-actions"}),c=document.createElement("button");c.type="button",c.className="sp-btn-ghost",chunkQW2L5ARZ_cjs.z(c,this.t("panel.cancel"));let u=document.createElement("button");u.type="button",u.className="sp-btn-danger",chunkQW2L5ARZ_cjs.z(u,this.t("panel.confirmDelete"));let C=false,b=y=>{C||(C=true,s.removeEventListener("keydown",g),s.style.opacity="0",d.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{s.remove(),i(y);},200));},g=y=>{let w=y;if(w.key==="Escape"){w.stopPropagation(),b(false);return}w.key==="Tab"&&(w.preventDefault(),s.getRootNode().activeElement===c?u.focus():c.focus());};s.addEventListener("keydown",g),c.addEventListener("click",()=>b(false)),u.addEventListener("click",()=>b(true)),s.addEventListener("click",y=>{y.target===s&&b(false);}),v.appendChild(c),v.appendChild(u),d.appendChild(p),d.appendChild(f),d.appendChild(v),s.appendChild(d),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(s):this.root.appendChild(s),requestAnimationFrame(()=>{s.style.opacity="1",d.style.transform="translateY(0) scale(1)",c.focus();});})}async deleteFeedback(e,t){this.pendingMutations.add(e.id);let i=chunkQW2L5ARZ_cjs.C(t);try{await this.client.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks();}catch(s){i(),this.bus.emit("feedback:error",s instanceof Error?s:new Error(String(s)));}finally{this.pendingMutations.delete(e.id);}}async toggleResolve(e,t){this.pendingMutations.add(e.id);let i=chunkQW2L5ARZ_cjs.C(t);try{let s=!chunkQW2L5ARZ_cjs.h(e.status);await this.client.resolveFeedback(e.id,s),await this.loadFeedbacks();}catch(s){i(),this.bus.emit("feedback:error",s instanceof Error?s:new Error(String(s)));}finally{this.pendingMutations.delete(e.id);}}buildTypeDropdown(){return this.typeOptions=[{value:"all",label:this.t("panel.filterAll"),icon:chunkQW2L5ARZ_cjs.T,color:this.colors.accent,bg:this.colors.accentLight},{value:"question",label:this.t("type.question"),icon:chunkQW2L5ARZ_cjs.P,color:this.colors.typeQuestion,bg:this.colors.typeQuestionBg},{value:"change",label:this.t("type.change"),icon:chunkQW2L5ARZ_cjs.Q,color:this.colors.typeChange,bg:this.colors.typeChangeBg},{value:"bug",label:this.t("type.bug"),icon:chunkQW2L5ARZ_cjs.R,color:this.colors.typeBug,bg:this.colors.typeBugBg},{value:"other",label:this.t("type.other"),icon:chunkQW2L5ARZ_cjs.S,color:this.colors.typeOther,bg:this.colors.typeOtherBg}],this.typeDropdownContainer=chunkQW2L5ARZ_cjs.y("div",{class:"sp-filter-dropdown"}),this.typeDropdownBtn=document.createElement("button"),this.typeDropdownBtn.type="button",this.typeDropdownBtn.className="sp-filter-dropdown-btn",this.typeDropdownBtn.setAttribute("aria-haspopup","listbox"),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.renderTypeDropdownTrigger(),this.typeDropdownBtn.addEventListener("click",e=>{e.stopPropagation(),this.typeDropdownMenu?this.closeTypeDropdown():this.openTypeDropdown();}),this.typeDropdownContainer.addEventListener("keydown",e=>{e.key!=="Escape"||!this.typeDropdownMenu||(e.stopPropagation(),this.closeTypeDropdown(),this.typeDropdownBtn.focus());}),this.typeDropdownContainer.appendChild(this.typeDropdownBtn),this.typeDropdownContainer}renderTypeDropdownTrigger(){let e=this.typeOptions.find(d=>this.activeFilters.has(d.value))??this.typeOptions[0];if(!e)return;this.typeDropdownBtn.replaceChildren(),this.typeDropdownBtn.style.setProperty("--sp-chip-color",e.color),this.typeDropdownBtn.style.setProperty("--sp-chip-bg",e.bg),this.typeDropdownBtn.dataset.filter=e.value,this.typeDropdownBtn.classList.toggle("sp-filter-dropdown-btn--filtered",e.value!=="all"),this.typeDropdownBtn.setAttribute("aria-label",`${this.t("type.label")}: ${e.label}`);let t=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-btn__icon"});t.appendChild(chunkQW2L5ARZ_cjs.x(e.icon)),this.typeDropdownBtn.appendChild(t);let i=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-btn__label"}),s=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-btn__prefix"});chunkQW2L5ARZ_cjs.z(s,this.t("type.label"));let n=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-btn__value"});chunkQW2L5ARZ_cjs.z(n,e.label),i.appendChild(s),i.appendChild(n),this.typeDropdownBtn.appendChild(i);let o=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-btn__chevron"});o.appendChild(chunkQW2L5ARZ_cjs.x(chunkQW2L5ARZ_cjs.V)),this.typeDropdownBtn.appendChild(o);}openTypeDropdown(){this.typeDropdownMenu=chunkQW2L5ARZ_cjs.y("div",{class:"sp-filter-dropdown-menu"}),this.typeDropdownMenu.setAttribute("role","listbox"),this.typeDropdownMenu.setAttribute("aria-label",this.t("type.label")),this.typeDropdownBtn.setAttribute("aria-expanded","true");for(let e of this.typeOptions){let t=document.createElement("button");t.type="button";let i=this.activeFilters.has(e.value);t.className=`sp-filter-dropdown-option${i?" sp-filter-dropdown-option--active":""}`,t.style.setProperty("--sp-chip-color",e.color),t.style.setProperty("--sp-chip-bg",e.bg),t.dataset.filter=e.value,t.setAttribute("role","option"),t.setAttribute("aria-selected",String(i));let s=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-option__icon"});s.appendChild(chunkQW2L5ARZ_cjs.x(e.icon)),t.appendChild(s);let n=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-option__label"});if(chunkQW2L5ARZ_cjs.z(n,e.label),t.appendChild(n),i){let o=chunkQW2L5ARZ_cjs.y("span",{class:"sp-filter-dropdown-option__check"});o.appendChild(chunkQW2L5ARZ_cjs.x(chunkQW2L5ARZ_cjs.O)),t.appendChild(o);}t.addEventListener("click",o=>{o.stopPropagation(),this.selectTypeFilter(e.value);}),this.typeDropdownMenu.appendChild(t);}this.typeDropdownContainer.appendChild(this.typeDropdownMenu),this.removeTypeDropdownOutsideClick=chunkQW2L5ARZ_cjs.A(this.typeDropdownContainer,()=>this.closeTypeDropdown());}closeTypeDropdown(){this.typeDropdownMenu&&(this.typeDropdownMenu.remove(),this.typeDropdownMenu=null),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.removeTypeDropdownOutsideClick?.(),this.removeTypeDropdownOutsideClick=null;}selectTypeFilter(e){this.activeFilters.clear(),this.activeFilters.add(e),this.renderTypeDropdownTrigger(),this.closeTypeDropdown(),this.loadFeedbacks().catch(()=>{});}buildStatusSegmented(){return this.statusSegmented=new P({options:[{value:"all",label:this.t("panel.statusAll"),icon:chunkQW2L5ARZ_cjs.T,color:this.colors.accent,bg:this.colors.accentLight},{value:"open",label:this.t("panel.statusOpen"),icon:chunkQW2L5ARZ_cjs.U,color:this.colors.statusOpen,bg:this.colors.statusOpenBg},{value:"resolved",label:this.t("panel.statusResolved"),icon:chunkQW2L5ARZ_cjs.O,color:this.colors.statusResolved,bg:this.colors.statusResolvedBg}],value:"all",onChange:()=>{this.loadFeedbacks().catch(()=>{});},ariaLabel:this.t("status.label"),datasetKey:"statusFilter",modifierPrefix:"sp-segmented__btn--"}),this.statusSegmented.element}buildScopeSegmented(){return this.scopeSegmented=new P({options:[{value:"this",label:this.t("scope.thisPage")},{value:"template",label:this.t("scope.thisType")},{value:"all",label:this.t("scope.all")}],value:this.initialScopeFilter,onChange:()=>{this.loadFeedbacks().catch(()=>{});},ariaLabel:this.t("scope.label"),datasetKey:"scopeFilter",modifierPrefix:"sp-segmented__btn--scope-",extraClass:"sp-segmented--scope"}),this.syncScopeAvailability(),this.scopeSegmented.element}syncScopeAvailability(){if(!this.scopeSegmented)return;let t=!!this.getScope().urlPattern;this.scopeSegmented.setOptionVisible("template",t),!t&&this.scopeSegmented.value==="template"&&this.scopeSegmented.select("this");}buildMineToggle(){let e=document.createElement("button");return e.type="button",e.className="sp-mine-toggle",e.title=this.t("panel.filterMineHint"),e.setAttribute("aria-pressed","false"),e.append(chunkQW2L5ARZ_cjs.x(chunkQW2L5ARZ_cjs.Y),this.t("panel.filterMine")),e.addEventListener("click",()=>{this.mineOnly=!this.mineOnly,e.classList.toggle("sp-mine-toggle--active",this.mineOnly),e.setAttribute("aria-pressed",String(this.mineOnly)),this.loadFeedbacks().catch(()=>{});}),e}pressInFocusedCard(e){this.listContainer.querySelectorAll(".sp-card")[chunkQW2L5ARZ_cjs.Ca(this.listContainer)]?.querySelector(e)?.click();}scrollToFeedback(e){if(this.isLoading){this.pendingScrollId=e;return}this.flashCard(e);}flashCard(e){let t=CSS.escape(e),i=this.listContainer.querySelector(`[data-feedback-id="${t}"]`);if(i){i.scrollIntoView({behavior:"smooth",block:"center"}),i.classList.add("sp-anim-flash"),i.addEventListener("animationend",()=>{i.classList.remove("sp-anim-flash");},{once:true});let s=this.feedbacks.find(n=>n.id===e);s&&chunkQW2L5ARZ_cjs.fa()&&this.detail.show(s,Number(i.dataset.number));}}draftOf(e){let t=this.threadDrafts.get(e)??{text:""};return this.threadDrafts.set(e,t),t}async postComment(e,t,i){let s=await this.resolveIdentity();if(!s)return null;try{let n=await this.client.addComment(e.id,{body:t,clientId:i,authorName:s.name,authorEmail:s.email,authorRole:"client"});for(let o of new Set([e,this.feedbacks.find(d=>d.id===e.id)]))o&&!o.comments?.some(d=>d.id===n.id)&&(o.comments=[...o.comments??[],n]);return this.bus.emit("comment:added",n),n}catch(n){throw this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n))),n}}reportActionError(e){this.bus.emit("panel:action-error",e instanceof Error?e:new Error(String(e)));}async refreshDetail(e){if(this.isOpen&&await this.loadFeedbacks(this.currentPage),this.detail.feedbackId!==e)return;let t=this.feedbacks.findIndex(s=>s.id===e),i=this.feedbacks[t];i?this.detail.show(i,t+1):this.detail.hide();}async refresh(){this.isOpen&&await this.loadFeedbacks();}get isCurrentlyOpen(){return this.isOpen}destroy(){this.isOpen=false,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.closeTypeDropdown(),this.sortControls.destroy(),this.bulk.destroy(),this.exportBtn.destroy(),this.shortcuts.destroy(),this.detail.destroy(),this.scrim.remove(),this.root.remove();}};exports.Panel=Ae;//# sourceMappingURL=panel-RHSIY6KS.cjs.map
2
- //# sourceMappingURL=panel-RHSIY6KS.cjs.map
1
+ 'use strict';var chunkQ34GDCKE_cjs=require('./chunk-Q34GDCKE.cjs');var P=class{element;current;opts;onChange;datasetKey;constructor(e){this.opts=e.options,this.current=e.value,this.onChange=e.onChange,this.datasetKey=e.datasetKey,this.element=chunkQ34GDCKE_cjs.y("div",{class:`sp-segmented${e.extraClass?` ${e.extraClass}`:""}`,role:"radiogroup"}),this.element.setAttribute("aria-label",e.ariaLabel);for(let t of this.opts){let i=document.createElement("button");i.type="button",i.className=e.modifierPrefix!==void 0?`sp-segmented__btn ${e.modifierPrefix}${t.value}`:"sp-segmented__btn",i.dataset[this.datasetKey]=t.value,i.setAttribute("role","radio");let s=this.current===t.value;if(i.setAttribute("aria-checked",String(s)),i.tabIndex=s?0:-1,s&&i.classList.add("sp-segmented__btn--active"),t.color&&i.style.setProperty("--sp-chip-color",t.color),t.bg&&i.style.setProperty("--sp-chip-bg",t.bg),t.icon){let o=chunkQ34GDCKE_cjs.y("span",{class:"sp-segmented__icon"});o.appendChild(chunkQ34GDCKE_cjs.x(t.icon)),i.appendChild(o);}let n=chunkQ34GDCKE_cjs.y("span",{class:"sp-segmented__label"});chunkQ34GDCKE_cjs.z(n,t.label),i.appendChild(n),i.addEventListener("click",()=>this.select(t.value)),i.addEventListener("keydown",o=>this.handleKey(o,t.value)),this.element.appendChild(i);}}select(e){this.current=e,this.syncSelection(),this.onChange(e);}syncSelection(){let e=this.element.querySelectorAll(".sp-segmented__btn");for(let t of e){let i=t.dataset[this.datasetKey]===this.current;t.classList.toggle("sp-segmented__btn--active",i),t.setAttribute("aria-checked",String(i)),t.tabIndex=i?0:-1;}}setOptionVisible(e,t){let i=this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`);return i?(i.style.display=t?"":"none",true):false}get value(){return this.current}focusOption(e){this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`)?.focus();}handleKey(e,t){let i=this.opts.map(d=>d.value).filter(d=>{let p=this.element.querySelector(`[data-${this.kebabKey()}="${d}"]`);return p!==null&&p.style.display!=="none"}),s=i.indexOf(t);if(s<0)return;let n;switch(e.key){case "ArrowLeft":n=(s-1+i.length)%i.length;break;case "ArrowRight":n=(s+1)%i.length;break;case "Home":n=0;break;case "End":n=i.length-1;break;default:return}e.preventDefault();let o=i[n];o!==void 0&&(this.select(o),this.focusOption(o));}kebabKey(){return this.datasetKey.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}};function j({input:M,send:e},t){M.readOnly=t,e.setAttribute("aria-busy",String(t)),e.setAttribute("aria-disabled",String(t));}var Fe=0;function Le(M,{t:e,locale:t,canPost:i,draft:s,post:n}){let o=M.comments??[];if(!i&&o.length===0)return null;let d=chunkQ34GDCKE_cjs.y("div"),p=chunkQ34GDCKE_cjs.y("ol",{class:"sp-thread-list",role:"list","aria-label":e("comments.title"),"aria-live":"polite"}),f=new Set,v=a=>{if(f.has(a.id))return;f.add(a.id);let l=chunkQ34GDCKE_cjs.y("li",{class:"sp-detail-message sp-comment","data-role":a.authorRole}),m=chunkQ34GDCKE_cjs.y("div",{class:"sp-comment-head"}),k=chunkQ34GDCKE_cjs.y("span");if(chunkQ34GDCKE_cjs.z(k,a.authorName),m.appendChild(k),a.authorRole==="team"){let T=chunkQ34GDCKE_cjs.y("span",{class:"sp-badge"});chunkQ34GDCKE_cjs.z(T,e("comments.team")),m.appendChild(T);}let E=chunkQ34GDCKE_cjs.y("time",{datetime:a.createdAt});chunkQ34GDCKE_cjs.z(E,chunkQ34GDCKE_cjs.E(a.createdAt,t)),m.appendChild(E);let S=chunkQ34GDCKE_cjs.y("div");chunkQ34GDCKE_cjs.z(S,a.body),l.append(m,S),p.appendChild(l);};for(let a of o)v(a);if(d.appendChild(p),!i)return d;let c=document.createElement("textarea");c.className="sp-input sp-thread-input",c.rows=3,c.maxLength=chunkQ34GDCKE_cjs.j,c.placeholder=e("comments.placeholder"),c.setAttribute("aria-label",c.placeholder),c.value=s.text,c.addEventListener("input",()=>{s.text=c.value;});let u=chunkQ34GDCKE_cjs.y("div",{class:"sp-thread-foot"}),C=chunkQ34GDCKE_cjs.y("span",{id:`sp-thread-hint-${++Fe}`});chunkQ34GDCKE_cjs.ga()||(chunkQ34GDCKE_cjs.z(C,e(chunkQ34GDCKE_cjs.D()?"popup.submitHintMac":"popup.submitHintOther")),c.setAttribute("aria-describedby",C.id),c.setAttribute("aria-keyshortcuts","Control+Enter Meta+Enter"));let b=document.createElement("button");b.type="button",b.className="sp-btn-primary",chunkQ34GDCKE_cjs.z(b,e("popup.submit")),u.append(C,b);let g=chunkQ34GDCKE_cjs.y("div",{class:"sp-thread-error",role:"alert"});d.append(c,u,g);let y={add:v,input:c,send:b,error:g};s.view=y,j(y,s.sending===true);let w=async()=>{s.text=c.value;let a=s.text.trim();if(s.sending||!a)return;s.sent?.body!==a&&(s.sent={body:a,clientId:chunkQ34GDCKE_cjs.p()});let{clientId:l}=s.sent;s.sending=true,chunkQ34GDCKE_cjs.z(g,""),j(y,true);let m="",k=null;try{k=await n(a,l);}catch(S){m=e(chunkQ34GDCKE_cjs.u(S)?"comments.full":"comments.error");}s.sending=false;let E=s.view??y;j(E,false),chunkQ34GDCKE_cjs.z(E.error,m),k&&(E.add(k),E.input.value=s.text="",s.sent=void 0);};return b.addEventListener("click",()=>{w();}),c.addEventListener("keydown",a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),w());}),d}var Be=chunkQ34GDCKE_cjs.f.filter(M=>!chunkQ34GDCKE_cjs.h(M)),Ae=class{constructor(e,t,i,s,n,o,d,p,f){this.colors=t;this.bus=i;this.client=s;this.projectName=n;this.markers=o;this.t=d;this.locale=p;this.shadowRoot=e,this.readOnly=!!f?.readOnly,this.resolveIdentity=f?.resolveIdentity??(async()=>null),this.getScope=f?.getScope??(()=>({url:window.location.pathname,urlPattern:null})),this.scopeAnnotationsByUrl=f?.scopeAnnotationsByUrl??true,this.ownFeedback=f?.ownFeedback??{ids:()=>new Set,remove:()=>{}},this.scrim=chunkQ34GDCKE_cjs.y("div",{class:"sp-scrim"}),this.scrim.addEventListener("click",()=>this.close()),this.root=chunkQ34GDCKE_cjs.y("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 v=chunkQ34GDCKE_cjs.y("div",{class:"sp-panel-header"}),c=chunkQ34GDCKE_cjs.y("span",{class:"sp-panel-title"});chunkQ34GDCKE_cjs.z(c,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(chunkQ34GDCKE_cjs.x(chunkQ34GDCKE_cjs.M)),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(chunkQ34GDCKE_cjs.x(chunkQ34GDCKE_cjs.X));let u=document.createElement("span");chunkQ34GDCKE_cjs.z(u,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(u),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll()),chunkQ34GDCKE_cjs.B(this.deleteAllBtn,true),this.exportBtn=new chunkQ34GDCKE_cjs.oa(t,()=>this.feedbacks,this.t);let C=chunkQ34GDCKE_cjs.y("div",{class:"sp-panel-header-right"});C.appendChild(this.exportBtn.element),C.appendChild(this.deleteAllBtn),C.appendChild(this.closeBtn),v.appendChild(c),v.appendChild(C),this.stats=new chunkQ34GDCKE_cjs.Aa(t,this.t);let b=chunkQ34GDCKE_cjs.y("div",{class:"sp-filters"}),g=chunkQ34GDCKE_cjs.y("div",{class:"sp-search-wrap"}),y=chunkQ34GDCKE_cjs.x(chunkQ34GDCKE_cjs.N);y.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(y),g.appendChild(this.searchInput);let w=chunkQ34GDCKE_cjs.y("div",{class:"sp-filter-bar"});w.appendChild(this.buildTypeDropdown()),w.appendChild(this.buildStatusSegmented()),w.appendChild(this.buildScopeSegmented()),w.appendChild(this.buildMineToggle()),this.sortControls=new chunkQ34GDCKE_cjs.xa(t,()=>this.renderList(),this.t),b.appendChild(g),b.appendChild(w),b.appendChild(this.sortControls.element),this.listContainer=chunkQ34GDCKE_cjs.y("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label",this.t("panel.feedbackList")),this.bulk=new chunkQ34GDCKE_cjs.qa(t,{onResolve:a=>this.bulkResolve(a),onDelete:a=>this.bulkDelete(a),permits:(a,l)=>this.feedbacks.every(m=>!a.includes(m.id)||this.can(m,l))},this.t),this.bulk.setListContainer(this.listContainer),this.detail=new chunkQ34GDCKE_cjs.ta(t,{onBack:()=>this.detail.hide(),onResolve:async a=>{try{let l=!chunkQ34GDCKE_cjs.h(a.status);await this.client.resolveFeedback(a.id,l),await this.loadFeedbacks(),this.detail.hide();}catch(l){throw this.bus.emit("feedback:error",l instanceof Error?l:new Error(String(l))),l}},onDelete:async a=>{try{await this.client.deleteFeedback(a.id),this.bus.emit("feedback:deleted",a.id),await this.loadFeedbacks(),this.detail.hide();}catch(l){throw this.bus.emit("feedback:error",l instanceof Error?l:new Error(String(l))),l}},canGoToAnnotation:a=>!this.scopeAnnotationsByUrl||a.url===this.getScope().url,onGoToAnnotation:a=>{if(a.annotations.length>0){let l=a.annotations[0];if(!l)return;this.markers.revealPin(a.id)||(window.scrollTo({left:l.scrollX,top:l.scrollY,behavior:"smooth"}),this.markers.pinHighlight(a)),chunkQ34GDCKE_cjs.fa()&&this.close();}},onCustomAction:async(a,l)=>{try{await a.onAction(l,{refresh:()=>this.refreshDetail(l.id),close:()=>this.close()});}catch(m){this.reportActionError(m);}},onCustomActionError:a=>this.reportActionError(a),permits:(a,l)=>this.can(a,l),buildThread:a=>Le(a,{t:this.t,locale:p,canPost:this.canComment&&a.permissions?.canComment!==false,draft:this.draftOf(a.id),post:(l,m)=>this.postComment(a,l,m)})},this.t,p,chunkQ34GDCKE_cjs.ra(f?.panelActions)),this.shortcuts=new chunkQ34GDCKE_cjs.Ea(t,{onNavigate:a=>{let l=chunkQ34GDCKE_cjs.Ba(this.listContainer);chunkQ34GDCKE_cjs.Ca(this.listContainer,a==="down"?l+1:l-1);},onResolve:()=>this.pressInFocusedCard('[data-action="resolve"]'),onDelete:()=>this.pressInFocusedCard('[data-action="delete"]'),onFocusSearch:()=>this.searchInput.focus(),onToggleSelect:()=>this.pressInFocusedCard(".sp-bulk-checkbox"),isSuspended:()=>this.detail.isVisible},this.t),this.root.appendChild(v),this.root.appendChild(this.stats.element),this.root.appendChild(b),this.root.appendChild(this.listContainer),this.root.appendChild(this.bulk.barElement),this.root.appendChild(this.detail.element),this.root.appendChild(this.shortcuts.helpOverlay),this.root.appendChild(this.shortcuts.hintButton),e.appendChild(this.scrim),e.appendChild(this.root),this.attachSheetDrag(),this.onListClick=a=>{let l=a.target;if(l.closest(".sp-bulk-checkbox"))return;let m=l.closest("[data-action]");if(m){a.stopPropagation();let E=m.closest(".sp-card");if(!E)return;let S=E.dataset.feedbackId,T=this.feedbacks.find(L=>L.id===S);if(!T)return;let F=m.dataset.action;if(F==="expand"){let L=E.querySelector(".sp-card-message");if(!L)return;let U=L.classList.toggle("sp-card-message--expanded");chunkQ34GDCKE_cjs.z(m,U?this.t("panel.showLess"):this.t("panel.showMore")),m.setAttribute("aria-expanded",String(U));}else if(F==="resolve"){if(this.pendingMutations.has(T.id))return;let L=m;this.toggleResolve(T,L).catch(()=>{});}else if(F==="delete"){if(this.pendingMutations.has(T.id))return;let L=m;this.deleteFeedback(T,L).catch(()=>{});}return}let k=l.closest(".sp-card");if(k){let E=k.dataset.feedbackId,S=this.feedbacks.find(T=>T.id===E);S&&this.detail.show(S,Number(k.dataset.number));}},this.listContainer.addEventListener("click",this.onListClick),this.onListKeydown=a=>{let l=a;if(l.key!=="Enter"&&l.key!==" ")return;let m=l.target,k=m.closest(".sp-card");if(!k||m!==k)return;l.preventDefault();let E=k.dataset.feedbackId,S=this.feedbacks.find(T=>T.id===E);S&&this.detail.show(S,Number(k.dataset.number));},this.listContainer.addEventListener("keydown",this.onListKeydown),this.onListMouseover=a=>{let m=a.target.closest(".sp-card");if(!m)return;let k=m.dataset.feedbackId;k&&this.markers.highlight(k);},this.listContainer.addEventListener("mouseover",this.onListMouseover),this.onListMouseout=a=>{let l=a.relatedTarget;l&&this.listContainer.contains(l)||this.markers.highlight("");},this.listContainer.addEventListener("mouseout",this.onListMouseout),this.bus.on("panel:toggle",a=>{a?this.open():this.close();}),chunkQ34GDCKE_cjs.H(e,()=>this.isOpen),e.addEventListener("keydown",a=>{let l=a;if(l.key==="Escape"&&this.isOpen){if(this.shortcuts.isHelpVisible)return;if(this.detail.isVisible){this.detail.hide();return}this.close();return}if(l.key==="Tab"&&this.isOpen){let m=F=>{let L=F;for(;L&&L!==this.root;){if(getComputedStyle(L).display==="none")return false;L=L.parentElement;}return true},k=Array.from(this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(F=>m(F)&&!F.hasAttribute("disabled"));if(k.length===0)return;let E=k[0],S=k[k.length-1];if(!E||!S)return;let T=e.activeElement;l.shiftKey&&T===E?(l.preventDefault(),S.focus()):!l.shiftKey&&T===S&&(l.preventDefault(),E.focus());}}),this.onMarkerClick=(a=>{this.scrollToFeedback(a.detail.feedbackId);}),document.addEventListener("sp-marker-click",this.onMarkerClick);}colors;bus;client;projectName;markers;t;locale;root;scrim;listContainer;searchInput;closeBtn;deleteAllBtn;activeFilters=new Set(["all"]);typeDropdownBtn;typeDropdownContainer;typeDropdownMenu=null;removeTypeDropdownOutsideClick=null;statusSegmented;typeOptions;feedbacks=[];currentPage=1;totalFeedbacks=0;isLoadingMore=false;isOpen=false;searchTimeout=null;loadController=null;isLoading=false;pendingScrollId=null;pendingMutations=new Set;canComment=false;threadDrafts=new Map;readOnly;resolveIdentity;stats;sortControls;bulk;exportBtn;shortcuts;detail;shadowRoot;getScope;scopeAnnotationsByUrl;scopeSegmented;initialScopeFilter="this";mineOnly=false;ownFeedback;onMarkerClick;onListClick;onListKeydown;onListMouseover;onListMouseout;async open(){if(this.isOpen)return;this.isOpen=true;let e=chunkQ34GDCKE_cjs.fa();this.root.setAttribute("role",e?"dialog":"complementary"),e?this.root.setAttribute("aria-modal","true"):this.root.removeAttribute("aria-modal"),this.root.classList.add("sp-panel--open"),this.scrim.classList.add("sp-scrim--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),this.shortcuts.enable(this.shadowRoot),await this.loadFeedbacks(),requestAnimationFrame(()=>{(chunkQ34GDCKE_cjs.ga()?this.closeBtn:this.searchInput).focus();});}close(){if(!this.isOpen)return;this.isOpen=false,this.root.classList.remove("sp-panel--open"),this.scrim.classList.remove("sp-scrim--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.shortcuts.disable(),this.detail.hide(),this.pendingScrollId=null,this.root.getRootNode().querySelector(".sp-fab")?.focus();}attachSheetDrag(){let e=0,t=0,i=0,s=false;this.root.addEventListener("pointerdown",o=>{let d=o.target;o.pointerType==="mouse"||!chunkQ34GDCKE_cjs.fa()||d.closest("button")||!d.closest(".sp-panel-header, .sp-detail-header")||(s=true,e=o.clientY,t=o.timeStamp,i=0,this.root.style.transition="none",this.root.setPointerCapture?.(o.pointerId));}),this.root.addEventListener("pointermove",o=>{s&&(i=Math.max(0,o.clientY-e),this.root.style.transform=`translateY(${i}px)`);});let n=o=>{if(!s)return;s=false,this.root.style.transition="",this.root.style.transform="",(i>40&&i/Math.max(1,o.timeStamp-t)>.5||i>this.root.offsetHeight/4)&&this.close();};this.root.addEventListener("pointerup",n),this.root.addEventListener("pointercancel",n);}showLoading(){this.listContainer.replaceChildren();let e=chunkQ34GDCKE_cjs.y("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label",this.t("panel.loading"));let t=chunkQ34GDCKE_cjs.y("div",{class:"sp-spinner"});e.appendChild(t),this.listContainer.appendChild(e);}showError(){this.listContainer.replaceChildren();let e=chunkQ34GDCKE_cjs.y("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=chunkQ34GDCKE_cjs.y("div",{class:"sp-empty-text"});chunkQ34GDCKE_cjs.z(t,this.t("panel.loadError"));let i=document.createElement("button");i.className="sp-btn-ghost",i.style.marginTop="8px",chunkQ34GDCKE_cjs.z(i,this.t("panel.retry")),i.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(t),e.appendChild(i),this.listContainer.appendChild(e);}statusBucket(e){if(e!=="all")return chunkQ34GDCKE_cjs.h(e)?chunkQ34GDCKE_cjs.g:Be}async loadFeedbacks(e=1){this.loadController?.abort(),this.loadController=new AbortController;let{signal:t}=this.loadController;this.currentPage=1;let i=this.searchInput.value.trim()||void 0,s=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],n=this.statusBucket(this.statusSegmented.value),o=this.getScope();this.syncScopeAvailability();let d=this.scopeSegmented.value,p={page:1,limit:20};s&&(p.type=s),n&&(p.statuses=n),i&&(p.search=i),d==="this"?p.url=o.url:d==="template"&&o.urlPattern&&(p.urlPattern=o.urlPattern);let f=this.feedbacks.length>0;f||this.showLoading();let v=!this.mineOnly&&this.isMarkerQuery(p,o);this.isLoading=true;try{let c=this.mineOnly?this.fetchOwnFeedbacks(p,t):this.client.getFeedbacks(this.projectName,p);v||this.loadPageMarkers(o,t);let u=await c,{feedbacks:C,total:b}=u,g=1;for(;g<e&&C.length<b&&!t.aborted;){g++;let y=await this.client.getFeedbacks(this.projectName,{...p,page:g});C=[...C,...y.feedbacks],b=y.total;}if(t.aborted)return;this.currentPage=g,this.feedbacks=C,this.totalFeedbacks=b,this.canComment=u.capabilities?.comments===!0,chunkQ34GDCKE_cjs.B(this.deleteAllBtn,this.readOnly||u.permissions?.canDeleteAll===!1),this.stats.update(C,b),this.bulk.reset(),this.renderList(),this.pendingScrollId&&this.flashCard(this.pendingScrollId),v&&this.renderPageMarkers(C,o);}catch(c){if(t.aborted)return;f||this.showError(),this.bus.emit("feedback:error",c instanceof Error?c:new Error(String(c)));}finally{t.aborted||(this.isLoading=false,this.pendingScrollId=null);}}async loadMoreFeedbacks(){if(this.isLoadingMore)return;this.isLoadingMore=true;let e=this.loadController,t=this.currentPage+1,i=this.searchInput.value.trim()||void 0,s=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],n=this.statusBucket(this.statusSegmented.value),o=this.getScope(),d=this.scopeSegmented.value,p={page:t,limit:20};s&&(p.type=s),n&&(p.statuses=n),i&&(p.search=i),d==="this"?p.url=o.url:d==="template"&&o.urlPattern&&(p.urlPattern=o.urlPattern);let f=this.listContainer.querySelector(".sp-btn-load-more"),v;f&&(v=chunkQ34GDCKE_cjs.C(f));try{let{feedbacks:c,total:u}=await this.client.getFeedbacks(this.projectName,p);if(e!==this.loadController)return;this.currentPage=t,this.totalFeedbacks=u,this.feedbacks=[...this.feedbacks,...c],this.stats.update(this.feedbacks,u),this.renderList(),this.isMarkerQuery(p,o)&&this.renderPageMarkers(this.feedbacks,o);}catch(c){v&&v(),this.bus.emit("feedback:error",c instanceof Error?c:new Error(String(c)));}finally{this.isLoadingMore=false;}}isMarkerQuery(e,t){let i=this.scopeAnnotationsByUrl?t.url:void 0;return !e.type&&!e.statuses&&!e.search&&!e.urlPattern&&e.url===i}async fetchOwnFeedbacks(e,t){let i=this.ownFeedback.ids(),s=new Map,n=new Set,o=0,d,p=true,f,v;for(let u=1;s.size<i.size&&!t.aborted;u++){let C=await this.client.getFeedbacks(this.projectName,{...e,page:u,limit:100}),{feedbacks:b,total:g}=C;f=C.capabilities,v=C.permissions,d??=g,p&&=g===d;for(let y of b)n.add(y.id),i.has(y.id)&&s.set(y.id,y);if(o+=b.length,b.length===0||o>=g)break}return Object.keys(e).every(u=>u==="page"||u==="limit")&&p&&n.size===d&&this.ownFeedback.remove(...[...i].filter(u=>!s.has(u))),{feedbacks:[...s.values()],total:s.size,capabilities:f,permissions:v}}async loadPageMarkers(e,t){let i=this.scopeAnnotationsByUrl?{limit:20,url:e.url}:{limit:20};try{let{feedbacks:s}=await this.client.getFeedbacks(this.projectName,i);t.aborted||this.renderPageMarkers(s,e);}catch{}}renderPageMarkers(e,t){this.markers.render(this.scopeAnnotationsByUrl?e.filter(i=>i.url===t.url):e);}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let s=chunkQ34GDCKE_cjs.y("div",{class:"sp-empty"});s.setAttribute("role","status"),s.setAttribute("aria-live","polite");let n=chunkQ34GDCKE_cjs.y("div",{class:"sp-empty-text"});chunkQ34GDCKE_cjs.z(n,this.t("panel.empty")),s.appendChild(n),this.listContainer.appendChild(s);return}let e=chunkQ34GDCKE_cjs.ua(this.feedbacks,this.sortControls.sortMode),t=e.filter(s=>this.selectable(s)).map(s=>s.id);if(t.length>0&&this.listContainer.appendChild(this.bulk.createSelectAllBar(t,this.t("bulk.selectAll"))),this.sortControls.groupByPage){let s=chunkQ34GDCKE_cjs.va(e),n=0;for(let[o,d]of s){let p=chunkQ34GDCKE_cjs.wa(o,d.length,this.colors);this.listContainer.appendChild(p);let f=chunkQ34GDCKE_cjs.y("div",{class:"sp-group-content"});for(let v of d){let c=this.createCard(v,n+1);c.style.setProperty("--sp-card-i",String(n)),f.appendChild(c),n++;}this.listContainer.appendChild(f);}}else e.forEach((s,n)=>{let o=this.createCard(s,n+1);o.style.setProperty("--sp-card-i",String(n)),this.listContainer.appendChild(o);});let i=this.totalFeedbacks-this.feedbacks.length;if(i>0){let s=chunkQ34GDCKE_cjs.y("div",{class:"sp-load-more-wrap"}),n=document.createElement("button");n.className="sp-btn-ghost sp-btn-load-more",chunkQ34GDCKE_cjs.z(n,chunkQ34GDCKE_cjs.ka(this.t,"panel.loadMore",{remaining:i})),n.addEventListener("click",()=>this.loadMoreFeedbacks().catch(()=>{})),s.appendChild(n),this.listContainer.appendChild(s);}}createCard(e,t){let i=chunkQ34GDCKE_cjs.h(e.status),s=chunkQ34GDCKE_cjs.aa(e.type,this.colors),n=chunkQ34GDCKE_cjs.y("div",{class:`sp-card ${i?"sp-card--resolved":""}`});n.classList.toggle("sp-card--selected",this.bulk.isSelected(e.id)),n.setAttribute("role","listitem"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label",`Feedback #${t}: ${chunkQ34GDCKE_cjs.la(e.type,this.t)} \u2014 ${e.message.slice(0,80)}`),n.dataset.feedbackId=e.id,n.dataset.number=String(t);let o=chunkQ34GDCKE_cjs.y("div",{class:"sp-card-bar"});o.style.background=i?"#9ca3af":s;let d=chunkQ34GDCKE_cjs.y("div",{class:"sp-card-body"}),p=chunkQ34GDCKE_cjs.y("div",{class:"sp-card-header"});this.selectable(e)&&p.appendChild(this.bulk.createCheckbox(e.id));let f=chunkQ34GDCKE_cjs.y("span",{class:"sp-card-number"});chunkQ34GDCKE_cjs.z(f,`#${t}`);let v=chunkQ34GDCKE_cjs.y("span",{class:"sp-badge"}),c=chunkQ34GDCKE_cjs.da(e.type,this.colors);v.style.background=c,v.style.color=s,chunkQ34GDCKE_cjs.z(v,chunkQ34GDCKE_cjs.la(e.type,this.t));let u=chunkQ34GDCKE_cjs.y("span",{class:"sp-badge sp-badge--status"});u.dataset.status=e.status,u.style.background=chunkQ34GDCKE_cjs.ca(e.status,this.colors),u.style.color=chunkQ34GDCKE_cjs.ba(e.status,this.colors),chunkQ34GDCKE_cjs.z(u,chunkQ34GDCKE_cjs.ma(e.status,this.t));let C=chunkQ34GDCKE_cjs.y("span",{class:"sp-card-date"});chunkQ34GDCKE_cjs.z(C,chunkQ34GDCKE_cjs.E(e.createdAt,this.locale)),p.appendChild(f),p.appendChild(v),p.appendChild(u),p.appendChild(C);let b=chunkQ34GDCKE_cjs.y("div",{class:"sp-card-message"});chunkQ34GDCKE_cjs.z(b,e.message);let g=document.createElement("button");g.className="sp-card-expand",g.dataset.action="expand",chunkQ34GDCKE_cjs.z(g,this.t("panel.showMore")),g.style.display="none",g.setAttribute("aria-expanded","false"),requestAnimationFrame(()=>{b.scrollHeight>b.clientHeight&&(g.style.display="block");});let y=chunkQ34GDCKE_cjs.y("div",{class:"sp-card-footer"}),w=document.createElement("button");w.className="sp-btn-resolve",w.dataset.action="resolve",w.appendChild(chunkQ34GDCKE_cjs.x(i?chunkQ34GDCKE_cjs.W:chunkQ34GDCKE_cjs.O));let a=document.createElement("span");chunkQ34GDCKE_cjs.z(a,` ${this.t(i?"panel.reopen":"panel.resolve")}`),w.appendChild(a);let l=document.createElement("button");l.className="sp-btn-delete",l.dataset.action="delete",l.appendChild(chunkQ34GDCKE_cjs.x(chunkQ34GDCKE_cjs.X));let m=document.createElement("span");return chunkQ34GDCKE_cjs.z(m,` ${this.t("panel.delete")}`),l.appendChild(m),this.can(e,"canChangeStatus")&&y.appendChild(w),this.can(e,"canDelete")&&y.appendChild(l),d.appendChild(p),d.appendChild(b),d.appendChild(g),y.hasChildNodes()&&d.appendChild(y),n.appendChild(o),n.appendChild(d),n}can(e,t){return !this.readOnly&&e.permissions?.[t]!==false}selectable(e){return this.can(e,"canChangeStatus")||this.can(e,"canDelete")}async bulkResolve(e){let t=new Set(this.feedbacks.filter(n=>chunkQ34GDCKE_cjs.h(n.status)).map(n=>n.id)),i=e.filter(n=>!t.has(n)),s=await Promise.allSettled(i.map(n=>this.client.resolveFeedback(n,true)));await this.settleBulk(i,s);}async bulkDelete(e){let t=await Promise.allSettled(e.map(i=>this.client.deleteFeedback(i)));e.forEach((i,s)=>{t[s]?.status==="fulfilled"&&this.bus.emit("feedback:deleted",i);}),await this.settleBulk(e,t);}async settleBulk(e,t){let i=e.filter((d,p)=>t[p]?.status==="rejected");i.length<e.length&&await this.loadFeedbacks();let s=t.find(d=>d.status==="rejected");if(!s)return;let n=new Set(this.feedbacks.map(d=>d.id));this.bulk.selectAll(i.filter(d=>n.has(d)));let o=s.reason instanceof Error?s.reason:new Error(String(s.reason));throw this.bus.emit("feedback:error",o),o}async confirmDeleteAll(){if(await this.showConfirmDialog(this.t("panel.deleteAllConfirmTitle"),this.t("panel.deleteAllConfirmMessage"))){this.deleteAllBtn.disabled=true;try{await this.client.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=false;}}}showConfirmDialog(e,t){return new Promise(i=>{let s=chunkQ34GDCKE_cjs.y("div",{class:"sp-confirm-backdrop"}),n=`sp-confirm-title-${Date.now()}`,o=`sp-confirm-msg-${Date.now()}`,d=chunkQ34GDCKE_cjs.y("div",{class:"sp-confirm-dialog"});d.setAttribute("role","alertdialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby",n),d.setAttribute("aria-describedby",o);let p=chunkQ34GDCKE_cjs.y("div",{class:"sp-confirm-title"});p.id=n,chunkQ34GDCKE_cjs.z(p,e);let f=chunkQ34GDCKE_cjs.y("div",{class:"sp-confirm-message"});f.id=o,chunkQ34GDCKE_cjs.z(f,t);let v=chunkQ34GDCKE_cjs.y("div",{class:"sp-confirm-actions"}),c=document.createElement("button");c.type="button",c.className="sp-btn-ghost",chunkQ34GDCKE_cjs.z(c,this.t("panel.cancel"));let u=document.createElement("button");u.type="button",u.className="sp-btn-danger",chunkQ34GDCKE_cjs.z(u,this.t("panel.confirmDelete"));let C=false,b=y=>{C||(C=true,s.removeEventListener("keydown",g),s.style.opacity="0",d.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{s.remove(),i(y);},200));},g=y=>{let w=y;if(w.key==="Escape"){w.stopPropagation(),b(false);return}w.key==="Tab"&&(w.preventDefault(),s.getRootNode().activeElement===c?u.focus():c.focus());};s.addEventListener("keydown",g),c.addEventListener("click",()=>b(false)),u.addEventListener("click",()=>b(true)),s.addEventListener("click",y=>{y.target===s&&b(false);}),v.appendChild(c),v.appendChild(u),d.appendChild(p),d.appendChild(f),d.appendChild(v),s.appendChild(d),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(s):this.root.appendChild(s),requestAnimationFrame(()=>{s.style.opacity="1",d.style.transform="translateY(0) scale(1)",c.focus();});})}async deleteFeedback(e,t){this.pendingMutations.add(e.id);let i=chunkQ34GDCKE_cjs.C(t);try{await this.client.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks();}catch(s){i(),this.bus.emit("feedback:error",s instanceof Error?s:new Error(String(s)));}finally{this.pendingMutations.delete(e.id);}}async toggleResolve(e,t){this.pendingMutations.add(e.id);let i=chunkQ34GDCKE_cjs.C(t);try{let s=!chunkQ34GDCKE_cjs.h(e.status);await this.client.resolveFeedback(e.id,s),await this.loadFeedbacks();}catch(s){i(),this.bus.emit("feedback:error",s instanceof Error?s:new Error(String(s)));}finally{this.pendingMutations.delete(e.id);}}buildTypeDropdown(){return this.typeOptions=[{value:"all",label:this.t("panel.filterAll"),icon:chunkQ34GDCKE_cjs.T,color:this.colors.accent,bg:this.colors.accentLight},{value:"question",label:this.t("type.question"),icon:chunkQ34GDCKE_cjs.P,color:this.colors.typeQuestion,bg:this.colors.typeQuestionBg},{value:"change",label:this.t("type.change"),icon:chunkQ34GDCKE_cjs.Q,color:this.colors.typeChange,bg:this.colors.typeChangeBg},{value:"bug",label:this.t("type.bug"),icon:chunkQ34GDCKE_cjs.R,color:this.colors.typeBug,bg:this.colors.typeBugBg},{value:"other",label:this.t("type.other"),icon:chunkQ34GDCKE_cjs.S,color:this.colors.typeOther,bg:this.colors.typeOtherBg}],this.typeDropdownContainer=chunkQ34GDCKE_cjs.y("div",{class:"sp-filter-dropdown"}),this.typeDropdownBtn=document.createElement("button"),this.typeDropdownBtn.type="button",this.typeDropdownBtn.className="sp-filter-dropdown-btn",this.typeDropdownBtn.setAttribute("aria-haspopup","listbox"),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.renderTypeDropdownTrigger(),this.typeDropdownBtn.addEventListener("click",e=>{e.stopPropagation(),this.typeDropdownMenu?this.closeTypeDropdown():this.openTypeDropdown();}),this.typeDropdownContainer.addEventListener("keydown",e=>{e.key!=="Escape"||!this.typeDropdownMenu||(e.stopPropagation(),this.closeTypeDropdown(),this.typeDropdownBtn.focus());}),this.typeDropdownContainer.appendChild(this.typeDropdownBtn),this.typeDropdownContainer}renderTypeDropdownTrigger(){let e=this.typeOptions.find(d=>this.activeFilters.has(d.value))??this.typeOptions[0];if(!e)return;this.typeDropdownBtn.replaceChildren(),this.typeDropdownBtn.style.setProperty("--sp-chip-color",e.color),this.typeDropdownBtn.style.setProperty("--sp-chip-bg",e.bg),this.typeDropdownBtn.dataset.filter=e.value,this.typeDropdownBtn.classList.toggle("sp-filter-dropdown-btn--filtered",e.value!=="all"),this.typeDropdownBtn.setAttribute("aria-label",`${this.t("type.label")}: ${e.label}`);let t=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-btn__icon"});t.appendChild(chunkQ34GDCKE_cjs.x(e.icon)),this.typeDropdownBtn.appendChild(t);let i=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-btn__label"}),s=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-btn__prefix"});chunkQ34GDCKE_cjs.z(s,this.t("type.label"));let n=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-btn__value"});chunkQ34GDCKE_cjs.z(n,e.label),i.appendChild(s),i.appendChild(n),this.typeDropdownBtn.appendChild(i);let o=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-btn__chevron"});o.appendChild(chunkQ34GDCKE_cjs.x(chunkQ34GDCKE_cjs.V)),this.typeDropdownBtn.appendChild(o);}openTypeDropdown(){this.typeDropdownMenu=chunkQ34GDCKE_cjs.y("div",{class:"sp-filter-dropdown-menu"}),this.typeDropdownMenu.setAttribute("role","listbox"),this.typeDropdownMenu.setAttribute("aria-label",this.t("type.label")),this.typeDropdownBtn.setAttribute("aria-expanded","true");for(let e of this.typeOptions){let t=document.createElement("button");t.type="button";let i=this.activeFilters.has(e.value);t.className=`sp-filter-dropdown-option${i?" sp-filter-dropdown-option--active":""}`,t.style.setProperty("--sp-chip-color",e.color),t.style.setProperty("--sp-chip-bg",e.bg),t.dataset.filter=e.value,t.setAttribute("role","option"),t.setAttribute("aria-selected",String(i));let s=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-option__icon"});s.appendChild(chunkQ34GDCKE_cjs.x(e.icon)),t.appendChild(s);let n=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-option__label"});if(chunkQ34GDCKE_cjs.z(n,e.label),t.appendChild(n),i){let o=chunkQ34GDCKE_cjs.y("span",{class:"sp-filter-dropdown-option__check"});o.appendChild(chunkQ34GDCKE_cjs.x(chunkQ34GDCKE_cjs.O)),t.appendChild(o);}t.addEventListener("click",o=>{o.stopPropagation(),this.selectTypeFilter(e.value);}),this.typeDropdownMenu.appendChild(t);}this.typeDropdownContainer.appendChild(this.typeDropdownMenu),this.removeTypeDropdownOutsideClick=chunkQ34GDCKE_cjs.A(this.typeDropdownContainer,()=>this.closeTypeDropdown());}closeTypeDropdown(){this.typeDropdownMenu&&(this.typeDropdownMenu.remove(),this.typeDropdownMenu=null),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.removeTypeDropdownOutsideClick?.(),this.removeTypeDropdownOutsideClick=null;}selectTypeFilter(e){this.activeFilters.clear(),this.activeFilters.add(e),this.renderTypeDropdownTrigger(),this.closeTypeDropdown(),this.loadFeedbacks().catch(()=>{});}buildStatusSegmented(){return this.statusSegmented=new P({options:[{value:"all",label:this.t("panel.statusAll"),icon:chunkQ34GDCKE_cjs.T,color:this.colors.accent,bg:this.colors.accentLight},{value:"open",label:this.t("panel.statusOpen"),icon:chunkQ34GDCKE_cjs.U,color:this.colors.statusOpen,bg:this.colors.statusOpenBg},{value:"resolved",label:this.t("panel.statusResolved"),icon:chunkQ34GDCKE_cjs.O,color:this.colors.statusResolved,bg:this.colors.statusResolvedBg}],value:"all",onChange:()=>{this.loadFeedbacks().catch(()=>{});},ariaLabel:this.t("status.label"),datasetKey:"statusFilter",modifierPrefix:"sp-segmented__btn--"}),this.statusSegmented.element}buildScopeSegmented(){return this.scopeSegmented=new P({options:[{value:"this",label:this.t("scope.thisPage")},{value:"template",label:this.t("scope.thisType")},{value:"all",label:this.t("scope.all")}],value:this.initialScopeFilter,onChange:()=>{this.loadFeedbacks().catch(()=>{});},ariaLabel:this.t("scope.label"),datasetKey:"scopeFilter",modifierPrefix:"sp-segmented__btn--scope-",extraClass:"sp-segmented--scope"}),this.syncScopeAvailability(),this.scopeSegmented.element}syncScopeAvailability(){if(!this.scopeSegmented)return;let t=!!this.getScope().urlPattern;this.scopeSegmented.setOptionVisible("template",t),!t&&this.scopeSegmented.value==="template"&&this.scopeSegmented.select("this");}buildMineToggle(){let e=document.createElement("button");return e.type="button",e.className="sp-mine-toggle",e.title=this.t("panel.filterMineHint"),e.setAttribute("aria-pressed","false"),e.append(chunkQ34GDCKE_cjs.x(chunkQ34GDCKE_cjs.Y),this.t("panel.filterMine")),e.addEventListener("click",()=>{this.mineOnly=!this.mineOnly,e.classList.toggle("sp-mine-toggle--active",this.mineOnly),e.setAttribute("aria-pressed",String(this.mineOnly)),this.loadFeedbacks().catch(()=>{});}),e}pressInFocusedCard(e){this.listContainer.querySelectorAll(".sp-card")[chunkQ34GDCKE_cjs.Ba(this.listContainer)]?.querySelector(e)?.click();}scrollToFeedback(e){if(this.isLoading){this.pendingScrollId=e;return}this.flashCard(e);}flashCard(e){let t=CSS.escape(e),i=this.listContainer.querySelector(`[data-feedback-id="${t}"]`);if(i){i.scrollIntoView({behavior:"smooth",block:"center"}),i.classList.add("sp-anim-flash"),i.addEventListener("animationend",()=>{i.classList.remove("sp-anim-flash");},{once:true});let s=this.feedbacks.find(n=>n.id===e);s&&chunkQ34GDCKE_cjs.fa()&&this.detail.show(s,Number(i.dataset.number));}}draftOf(e){let t=this.threadDrafts.get(e)??{text:""};return this.threadDrafts.set(e,t),t}async postComment(e,t,i){let s=await this.resolveIdentity();if(!s)return null;try{let n=await this.client.addComment(e.id,{body:t,clientId:i,authorName:s.name,authorEmail:s.email,authorRole:"client"});for(let o of new Set([e,this.feedbacks.find(d=>d.id===e.id)]))o&&!o.comments?.some(d=>d.id===n.id)&&(o.comments=[...o.comments??[],n]);return this.bus.emit("comment:added",n),n}catch(n){throw this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n))),n}}reportActionError(e){this.bus.emit("panel:action-error",e instanceof Error?e:new Error(String(e)));}async refreshDetail(e){if(this.isOpen&&await this.loadFeedbacks(this.currentPage),this.detail.feedbackId!==e)return;let t=this.feedbacks.findIndex(s=>s.id===e),i=this.feedbacks[t];i?this.detail.show(i,t+1):this.detail.hide();}async refresh(){this.isOpen&&await this.loadFeedbacks();}get isCurrentlyOpen(){return this.isOpen}destroy(){this.isOpen=false,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.closeTypeDropdown(),this.sortControls.destroy(),this.bulk.destroy(),this.exportBtn.destroy(),this.shortcuts.destroy(),this.detail.destroy(),this.scrim.remove(),this.root.remove();}};exports.Panel=Ae;//# sourceMappingURL=panel-MIWFGD7X.cjs.map
2
+ //# sourceMappingURL=panel-MIWFGD7X.cjs.map