@siteping/widget 0.10.7 → 0.10.8

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 (45) hide show
  1. package/dist/{chunk-7ZBKJ6NW.js → chunk-4CK3N4YE.js} +11 -11
  2. package/dist/chunk-4CK3N4YE.js.map +1 -0
  3. package/dist/{chunk-GKRKCSID.cjs → chunk-BJFC7TVL.cjs} +11 -11
  4. package/dist/chunk-BJFC7TVL.cjs.map +1 -0
  5. package/dist/{chunk-NVNA5AI2.cjs → chunk-EYISG4OI.js} +11 -11
  6. package/dist/chunk-EYISG4OI.js.map +1 -0
  7. package/dist/{chunk-FDQWFGRR.js → chunk-OK2KX3KN.cjs} +11 -11
  8. package/dist/chunk-OK2KX3KN.cjs.map +1 -0
  9. package/dist/email.d.cts +19 -0
  10. package/dist/email.d.ts +19 -0
  11. package/dist/filters.d.cts +29 -4
  12. package/dist/filters.d.ts +29 -4
  13. package/dist/index.cjs +50 -50
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.global.js +46 -46
  16. package/dist/index.global.js.map +1 -1
  17. package/dist/index.js +51 -51
  18. package/dist/index.js.map +1 -1
  19. package/dist/panel-KCYUMYAI.cjs +2 -0
  20. package/dist/{panel-M2QKMFYO.cjs.map → panel-KCYUMYAI.cjs.map} +1 -1
  21. package/dist/panel-KV2AQHC2.js +2 -0
  22. package/dist/{panel-FUPBUN6F.js.map → panel-KV2AQHC2.js.map} +1 -1
  23. package/dist/panel-LYS3425X.cjs +2 -0
  24. package/dist/{panel-XUTDVTAR.cjs.map → panel-LYS3425X.cjs.map} +1 -1
  25. package/dist/panel-W2LHYGFS.js +2 -0
  26. package/dist/{panel-7URHNKQH.js.map → panel-W2LHYGFS.js.map} +1 -1
  27. package/dist/react.cjs +42 -42
  28. package/dist/react.cjs.map +1 -1
  29. package/dist/react.js +46 -46
  30. package/dist/react.js.map +1 -1
  31. package/dist/siteping-core.d.cts +3 -2
  32. package/dist/siteping-core.d.ts +3 -2
  33. package/dist/store-helpers.d.cts +13 -4
  34. package/dist/store-helpers.d.ts +13 -4
  35. package/dist/types.d.cts +2 -2
  36. package/dist/types.d.ts +2 -2
  37. package/package.json +4 -4
  38. package/dist/chunk-7ZBKJ6NW.js.map +0 -1
  39. package/dist/chunk-FDQWFGRR.js.map +0 -1
  40. package/dist/chunk-GKRKCSID.cjs.map +0 -1
  41. package/dist/chunk-NVNA5AI2.cjs.map +0 -1
  42. package/dist/panel-7URHNKQH.js +0 -2
  43. package/dist/panel-FUPBUN6F.js +0 -2
  44. package/dist/panel-M2QKMFYO.cjs +0 -2
  45. package/dist/panel-XUTDVTAR.cjs +0 -2
@@ -1,2 +0,0 @@
1
- import {D,F,b,c,a,i,t,S,ba,j,_,U,W,fa,ca,da,E,d,X,Y,Z,O,x,P,A,z,y,Q,e,s,k,p,l,m,n,o,r,q}from'./chunk-FDQWFGRR.js';var M=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=b("div",{class:`sp-segmented${e.extraClass?` ${e.extraClass}`:""}`,role:"radiogroup"}),this.element.setAttribute("aria-label",e.ariaLabel);for(let t of this.opts){let s=document.createElement("button");s.type="button",s.className=e.modifierPrefix!==void 0?`sp-segmented__btn ${e.modifierPrefix}${t.value}`:"sp-segmented__btn",s.dataset[this.datasetKey]=t.value,s.setAttribute("role","radio");let n=this.current===t.value;if(s.setAttribute("aria-checked",String(n)),s.tabIndex=n?0:-1,n&&s.classList.add("sp-segmented__btn--active"),t.color&&s.style.setProperty("--sp-chip-color",t.color),t.bg&&s.style.setProperty("--sp-chip-bg",t.bg),t.icon){let a$1=b("span",{class:"sp-segmented__icon"});a$1.appendChild(a(t.icon)),s.appendChild(a$1);}let o=b("span",{class:"sp-segmented__label"});c(o,t.label),s.appendChild(o),s.addEventListener("click",()=>this.select(t.value)),s.addEventListener("keydown",a=>this.handleKey(a,t.value)),this.element.appendChild(s);}}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 s=t.dataset[this.datasetKey]===this.current;t.classList.toggle("sp-segmented__btn--active",s),t.setAttribute("aria-checked",String(s)),t.tabIndex=s?0:-1;}}setOptionVisible(e,t){let s=this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`);return s?(s.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 s=this.opts.map(d=>d.value).filter(d=>{let c=this.element.querySelector(`[data-${this.kebabKey()}="${d}"]`);return c!==null&&c.style.display!=="none"}),n=s.indexOf(t);if(n<0)return;let o;switch(e.key){case "ArrowLeft":o=(n-1+s.length)%s.length;break;case "ArrowRight":o=(n+1)%s.length;break;case "Home":o=0;break;case "End":o=s.length-1;break;default:return}e.preventDefault();let a=s[o];a!==void 0&&(this.select(a),this.focusOption(a));}kebabKey(){return this.datasetKey.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}};var me=D.filter(O=>!F(O)),ue=class{constructor(e,t$1,s,n,o,a$1,d,c$1,b$1){this.colors=t$1;this.bus=s;this.client=n;this.projectName=o;this.markers=a$1;this.t=d;this.locale=c$1;this.shadowRoot=e,this.getScope=b$1?.getScope??(()=>({url:window.location.pathname,urlPattern:null})),this.scopeAnnotationsByUrl=b$1?.scopeAnnotationsByUrl??true,this.root=b("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 m=b("div",{class:"sp-panel-header"}),p=b("span",{class:"sp-panel-title"});c(p,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(a(i)),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(a(t));let y=document.createElement("span");c(y,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(y),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll()),this.exportBtn=new S(t$1,()=>this.feedbacks,this.t);let C=b("div",{class:"sp-panel-header-right"});C.appendChild(this.exportBtn.element),C.appendChild(this.deleteAllBtn),C.appendChild(this.closeBtn),m.appendChild(p),m.appendChild(C),this.stats=new ba(t$1,this.t);let k=b("div",{class:"sp-filters"}),T=b("div",{class:"sp-search-wrap"}),f=a(j);f.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);}),T.appendChild(f),T.appendChild(this.searchInput);let L=b("div",{class:"sp-filter-bar"});L.appendChild(this.buildTypeDropdown()),L.appendChild(this.buildStatusSegmented()),L.appendChild(this.buildScopeSegmented()),this.sortControls=new _(t$1,()=>this.renderList(),this.t),k.appendChild(T),k.appendChild(L),k.appendChild(this.sortControls.element),this.listContainer=b("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label",this.t("panel.feedbackList")),this.bulk=new U(t$1,{onResolve:i=>this.bulkResolve(i),onDelete:i=>this.bulkDelete(i)},this.t),this.bulk.setListContainer(this.listContainer),this.detail=new W(t$1,{onBack:()=>this.detail.hide(),onResolve:async i=>{try{let r=!F(i.status);await this.client.resolveFeedback(i.id,r),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onDelete:async i=>{try{await this.client.deleteFeedback(i.id),this.bus.emit("feedback:deleted",i.id),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onGoToAnnotation:i=>{if(i.annotations.length>0){let r=i.annotations[0];if(!r)return;window.scrollTo({left:r.scrollX,top:r.scrollY,behavior:"smooth"}),this.markers.pinHighlight(i);}}},this.t,c$1),this.shortcuts=new fa(t$1,{onNavigate:i=>{let r=ca(this.listContainer);da(this.listContainer,i==="down"?r+1:r-1);},onResolve:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="resolve"]');u&&this.toggleResolve(i,u).catch(()=>{});}},onDelete:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="delete"]');u&&this.deleteFeedback(i,u).catch(()=>{});}},onFocusSearch:()=>this.searchInput.focus(),onToggleSelect:()=>{let i=this.getFocusedFeedback();i&&this.bulk.toggle(i.id);}},this.t),this.root.appendChild(m),this.root.appendChild(this.stats.element),this.root.appendChild(k),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.root),this.onListClick=i=>{let r=i.target;if(r.closest(".sp-bulk-checkbox"))return;let u=r.closest("[data-action]");if(u){i.stopPropagation();let A=u.closest(".sp-card");if(!A)return;let w=A.dataset.feedbackId,g=this.feedbacks.find(E=>E.id===w);if(!g)return;let B=u.dataset.action;if(B==="expand"){let E=A.querySelector(".sp-card-message");if(!E)return;let R=E.classList.toggle("sp-card-message--expanded");c(u,R?this.t("panel.showLess"):this.t("panel.showMore")),u.setAttribute("aria-expanded",String(R));}else if(B==="resolve"){if(this.pendingMutations.has(g.id))return;let E=u;this.toggleResolve(g,E).catch(()=>{});}else if(B==="delete"){if(this.pendingMutations.has(g.id))return;let E=u;this.deleteFeedback(g,E).catch(()=>{});}return}let v=r.closest(".sp-card");if(v){let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}}},this.listContainer.addEventListener("click",this.onListClick),this.onListKeydown=i=>{let r=i;if(r.key!=="Enter"&&r.key!==" ")return;let u=r.target,v=u.closest(".sp-card");if(!v||u!==v)return;r.preventDefault();let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}},this.listContainer.addEventListener("keydown",this.onListKeydown),this.onListMouseover=i=>{let u=i.target.closest(".sp-card");if(!u)return;let v=u.dataset.feedbackId;v&&this.markers.highlight(v);},this.listContainer.addEventListener("mouseover",this.onListMouseover),this.onListMouseout=i=>{let r=i.relatedTarget;r&&this.listContainer.contains(r)||this.markers.highlight("");},this.listContainer.addEventListener("mouseout",this.onListMouseout),this.bus.on("panel:toggle",i=>{i?this.open():this.close();}),e.addEventListener("keydown",i=>{let r=i;if(r.key==="Escape"&&this.isOpen){if(this.detail.isVisible){this.detail.hide();return}this.close();return}if(r.key==="Tab"&&this.isOpen){let u=B=>{let E=B;for(;E&&E!==this.root;){if(E.style.display==="none")return false;E=E.parentElement;}return true},v=Array.from(this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(B=>u(B)&&!B.hasAttribute("disabled"));if(v.length===0)return;let A=v[0],w=v[v.length-1];if(!A||!w)return;let g=e.activeElement;r.shiftKey&&g===A?(r.preventDefault(),w.focus()):!r.shiftKey&&g===w&&(r.preventDefault(),A.focus());}}),this.onMarkerClick=(i=>{this.scrollToFeedback(i.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"]);typeDropdownBtn;typeDropdownContainer;typeDropdownMenu=null;typeDropdownOutsideHandler=null;statusSegmented;typeOptions;feedbacks=[];currentPage=1;totalFeedbacks=0;isLoadingMore=false;isOpen=false;searchTimeout=null;loadController=null;pendingMutations=new Set;stats;sortControls;bulk;exportBtn;shortcuts;detail;shadowRoot;getScope;scopeAnnotationsByUrl;scopeSegmented;initialScopeFilter="this";onMarkerClick;onListClick;onListKeydown;onListMouseover;onListMouseout;async open(){this.isOpen||(this.isOpen=true,this.root.classList.add("sp-panel--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),this.shortcuts.enable(this.shadowRoot),await this.loadFeedbacks(),requestAnimationFrame(()=>{this.searchInput?this.searchInput.focus():this.closeBtn.focus();}));}close(){if(!this.isOpen)return;this.isOpen=false,this.root.classList.remove("sp-panel--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.shortcuts.disable(),this.detail.hide(),this.root.getRootNode().querySelector(".sp-fab")?.focus();}showLoading(){this.listContainer.replaceChildren();let e=b("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label",this.t("panel.loading"));let t=b("div",{class:"sp-spinner"});e.appendChild(t),this.listContainer.appendChild(e);}showError(){this.listContainer.replaceChildren();let e=b("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=b("div",{class:"sp-empty-text"});c(t,this.t("panel.loadError"));let s=document.createElement("button");s.className="sp-btn-ghost",s.style.marginTop="8px",c(s,this.t("panel.retry")),s.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(t),e.appendChild(s),this.listContainer.appendChild(e);}statusBucket(e){if(e!=="all")return F(e)?E:me}async loadFeedbacks(){this.loadController?.abort(),this.loadController=new AbortController;let{signal:e}=this.loadController;this.currentPage=1;let t=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 a=this.scopeSegmented.value,d={page:1,limit:20};s&&(d.type=s),n&&(d.statuses=n),t&&(d.search=t),a==="this"?d.url=o.url:a==="template"&&o.urlPattern&&(d.urlPattern=o.urlPattern);let c=this.feedbacks.length>0;c||this.showLoading();try{let{feedbacks:b,total:m}=await this.client.getFeedbacks(this.projectName,d);if(e.aborted)return;this.feedbacks=b,this.totalFeedbacks=m,this.stats.update(b,m),this.bulk.reset(),this.renderList();let p=this.scopeAnnotationsByUrl?b.filter(y=>y.url===o.url):b;this.markers.render(p);}catch(b){if(e.aborted)return;c||this.showError(),this.bus.emit("feedback:error",b instanceof Error?b:new Error(String(b)));}}async loadMoreFeedbacks(){if(this.isLoadingMore)return;this.isLoadingMore=true;let e=this.loadController,t=this.currentPage+1,s=this.searchInput.value.trim()||void 0,n=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],o=this.statusBucket(this.statusSegmented.value),a=this.getScope(),d$1=this.scopeSegmented.value,c={page:t,limit:20};n&&(c.type=n),o&&(c.statuses=o),s&&(c.search=s),d$1==="this"?c.url=a.url:d$1==="template"&&a.urlPattern&&(c.urlPattern=a.urlPattern);let b=this.listContainer.querySelector(".sp-btn-load-more"),m;b&&(m=d(b));try{let{feedbacks:p,total:y}=await this.client.getFeedbacks(this.projectName,c);if(e!==this.loadController)return;this.currentPage=t,this.totalFeedbacks=y,this.feedbacks=[...this.feedbacks,...p],this.stats.update(this.feedbacks,y),this.renderList();let C=this.scopeAnnotationsByUrl?this.feedbacks.filter(k=>k.url===a.url):this.feedbacks;this.markers.render(C);}catch(p){m&&m(),this.bus.emit("feedback:error",p instanceof Error?p:new Error(String(p)));}finally{this.isLoadingMore=false;}}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let o=b("div",{class:"sp-empty"});o.setAttribute("role","status"),o.setAttribute("aria-live","polite");let a=b("div",{class:"sp-empty-text"});c(a,this.t("panel.empty")),o.appendChild(a),this.listContainer.appendChild(o);return}let e=X(this.feedbacks,this.sortControls.sortMode),t=e.map(o=>o.id),s=this.bulk.createSelectAllBar(t,this.t("bulk.selectAll"));if(this.listContainer.appendChild(s),this.sortControls.groupByPage){let o=Y(e),a=0;for(let[d,c]of o){let b$1=Z(d,c.length,this.colors);this.listContainer.appendChild(b$1);let m=b("div",{class:"sp-group-content"});for(let p of c){let y=this.createCard(p,a+1);y.style.setProperty("--sp-card-i",String(a)),m.appendChild(y),a++;}this.listContainer.appendChild(m);}}else e.forEach((o,a)=>{let d=this.createCard(o,a+1);d.style.setProperty("--sp-card-i",String(a)),this.listContainer.appendChild(d);});let n=this.totalFeedbacks-this.feedbacks.length;if(n>0){let o=b("div",{class:"sp-load-more-wrap"}),a=document.createElement("button");a.className="sp-btn-ghost sp-btn-load-more",c(a,O(this.t,"panel.loadMore",{remaining:n})),a.addEventListener("click",()=>this.loadMoreFeedbacks().catch(()=>{})),o.appendChild(a),this.listContainer.appendChild(o);}}createCard(e$1,t$1){let s$1=F(e$1.status),n=x(e$1.type,this.colors),o=b("div",{class:`sp-card ${s$1?"sp-card--resolved":""}`});o.setAttribute("role","listitem"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Feedback #${t$1}: ${P(e$1.type,this.t)} \u2014 ${e$1.message.slice(0,80)}`),o.dataset.feedbackId=e$1.id;let a$1=b("div",{class:"sp-card-bar"});a$1.style.background=s$1?"#9ca3af":n;let d=b("div",{class:"sp-card-body"}),c$1=b("div",{class:"sp-card-header"}),b$1=this.bulk.createCheckbox(e$1.id);c$1.appendChild(b$1);let m=b("span",{class:"sp-card-number"});c(m,`#${t$1}`);let p=b("span",{class:"sp-badge"}),y$1=A(e$1.type,this.colors);p.style.background=y$1,p.style.color=n,c(p,P(e$1.type,this.t));let C=b("span",{class:"sp-badge sp-badge--status"});C.dataset.status=e$1.status,C.style.background=z(e$1.status,this.colors),C.style.color=y(e$1.status,this.colors),c(C,Q(e$1.status,this.t));let k$1=b("span",{class:"sp-card-date"});c(k$1,e(e$1.createdAt,this.locale)),c$1.appendChild(m),c$1.appendChild(p),c$1.appendChild(C),c$1.appendChild(k$1);let T=b("div",{class:"sp-card-message"});c(T,e$1.message);let f=document.createElement("button");f.className="sp-card-expand",f.dataset.action="expand",c(f,this.t("panel.showMore")),f.style.display="none",f.setAttribute("aria-expanded","false"),requestAnimationFrame(()=>{T.scrollHeight>T.clientHeight&&(f.style.display="block");});let L=b("div",{class:"sp-card-footer"}),i=document.createElement("button");if(i.className="sp-btn-resolve",i.dataset.action="resolve",s$1){i.appendChild(a(s));let v=document.createElement("span");c(v,` ${this.t("panel.reopen")}`),i.appendChild(v);}else {i.appendChild(a(k));let v=document.createElement("span");c(v,` ${this.t("panel.resolve")}`),i.appendChild(v);}let r=document.createElement("button");r.className="sp-btn-delete",r.dataset.action="delete",r.appendChild(a(t));let u=document.createElement("span");return c(u,` ${this.t("panel.delete")}`),r.appendChild(u),L.appendChild(i),L.appendChild(r),d.appendChild(c$1),d.appendChild(T),d.appendChild(f),d.appendChild(L),o.appendChild(a$1),o.appendChild(d),o}async bulkResolve(e){try{await Promise.all(e.map(t=>this.client.resolveFeedback(t,!0))),await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}async bulkDelete(e){try{await Promise.all(e.map(t=>this.client.deleteFeedback(t)));for(let t of e)this.bus.emit("feedback:deleted",t);await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}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(s=>{let n=b("div",{class:"sp-confirm-backdrop"}),o=`sp-confirm-title-${Date.now()}`,a=`sp-confirm-msg-${Date.now()}`,d=b("div",{class:"sp-confirm-dialog"});d.setAttribute("role","alertdialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby",o),d.setAttribute("aria-describedby",a);let c$1=b("div",{class:"sp-confirm-title"});c$1.id=o,c(c$1,e);let b$1=b("div",{class:"sp-confirm-message"});b$1.id=a,c(b$1,t);let m=b("div",{class:"sp-confirm-actions"}),p=document.createElement("button");p.type="button",p.className="sp-btn-ghost",c(p,this.t("panel.cancel"));let y=document.createElement("button");y.type="button",y.className="sp-btn-danger",c(y,this.t("panel.confirmDelete"));let C=false,k=f=>{C||(C=true,n.removeEventListener("keydown",T),n.style.opacity="0",d.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{n.remove(),s(f);},200));},T=f=>{let L=f;if(L.key==="Escape"){k(false);return}L.key==="Tab"&&(L.preventDefault(),n.getRootNode().activeElement===p?y.focus():p.focus());};n.addEventListener("keydown",T),p.addEventListener("click",()=>k(false)),y.addEventListener("click",()=>k(true)),n.addEventListener("click",f=>{f.target===n&&k(false);}),m.appendChild(p),m.appendChild(y),d.appendChild(c$1),d.appendChild(b$1),d.appendChild(m),n.appendChild(d),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(n):this.root.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1",d.style.transform="translateY(0) scale(1)",p.focus();});})}async deleteFeedback(e,t){this.pendingMutations.add(e.id);let s=d(t);try{await this.client.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}async toggleResolve(e,t){this.pendingMutations.add(e.id);let s=d(t);try{let n=!F(e.status);await this.client.resolveFeedback(e.id,n),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}buildTypeDropdown(){return this.typeOptions=[{value:"all",label:this.t("panel.filterAll"),icon:p,color:this.colors.accent,bg:this.colors.accentLight},{value:"question",label:this.t("type.question"),icon:l,color:this.colors.typeQuestion,bg:this.colors.typeQuestionBg},{value:"change",label:this.t("type.change"),icon:m,color:this.colors.typeChange,bg:this.colors.typeChangeBg},{value:"bug",label:this.t("type.bug"),icon:n,color:this.colors.typeBug,bg:this.colors.typeBugBg},{value:"other",label:this.t("type.other"),icon:o,color:this.colors.typeOther,bg:this.colors.typeOtherBg}],this.typeDropdownContainer=b("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.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=b("span",{class:"sp-filter-dropdown-btn__icon"});t.appendChild(a(e.icon)),this.typeDropdownBtn.appendChild(t);let s=b("span",{class:"sp-filter-dropdown-btn__label"}),n=b("span",{class:"sp-filter-dropdown-btn__prefix"});c(n,this.t("type.label"));let o=b("span",{class:"sp-filter-dropdown-btn__value"});c(o,e.label),s.appendChild(n),s.appendChild(o),this.typeDropdownBtn.appendChild(s);let a$1=b("span",{class:"sp-filter-dropdown-btn__chevron"});a$1.appendChild(a(r)),this.typeDropdownBtn.appendChild(a$1);}openTypeDropdown(){this.typeDropdownMenu=b("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 s=this.activeFilters.has(e.value);t.className=`sp-filter-dropdown-option${s?" 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(s));let n=b("span",{class:"sp-filter-dropdown-option__icon"});n.appendChild(a(e.icon)),t.appendChild(n);let o=b("span",{class:"sp-filter-dropdown-option__label"});if(c(o,e.label),t.appendChild(o),s){let a$1=b("span",{class:"sp-filter-dropdown-option__check"});a$1.appendChild(a(k)),t.appendChild(a$1);}t.addEventListener("click",a=>{a.stopPropagation(),this.selectTypeFilter(e.value);}),this.typeDropdownMenu.appendChild(t);}this.typeDropdownContainer.appendChild(this.typeDropdownMenu),requestAnimationFrame(()=>{this.typeDropdownOutsideHandler=e=>{this.typeDropdownMenu&&!this.typeDropdownContainer.contains(e.target)&&this.closeTypeDropdown();},document.addEventListener("click",this.typeDropdownOutsideHandler,true);}),this.typeDropdownMenu.addEventListener("keydown",e=>{e.key==="Escape"&&(this.closeTypeDropdown(),this.typeDropdownBtn.focus());});}closeTypeDropdown(){this.typeDropdownMenu&&(this.typeDropdownMenu.remove(),this.typeDropdownMenu=null),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.typeDropdownOutsideHandler&&(document.removeEventListener("click",this.typeDropdownOutsideHandler,true),this.typeDropdownOutsideHandler=null);}selectTypeFilter(e){this.activeFilters.clear(),this.activeFilters.add(e),this.renderTypeDropdownTrigger(),this.closeTypeDropdown(),this.loadFeedbacks().catch(()=>{});}buildStatusSegmented(){return this.statusSegmented=new M({options:[{value:"all",label:this.t("panel.statusAll"),icon:p,color:this.colors.accent,bg:this.colors.accentLight},{value:"open",label:this.t("panel.statusOpen"),icon:q,color:this.colors.statusOpen,bg:this.colors.statusOpenBg},{value:"resolved",label:this.t("panel.statusResolved"),icon:k,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 M({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");}getFocusedFeedback(){let e=ca(this.listContainer);if(e<0)return;let t=this.listContainer.querySelectorAll(".sp-card")[e];if(t)return this.feedbacks.find(s=>s.id===t.dataset.feedbackId)}scrollToFeedback(e){let t=CSS.escape(e),s=this.listContainer.querySelector(`[data-feedback-id="${t}"]`);s&&(s.scrollIntoView({behavior:"smooth",block:"center"}),s.classList.add("sp-anim-flash"),s.addEventListener("animationend",()=>{s.classList.remove("sp-anim-flash");},{once:true}));}async refresh(){this.isOpen&&await this.loadFeedbacks();}get isCurrentlyOpen(){return this.isOpen}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.closeTypeDropdown(),this.sortControls.destroy(),this.bulk.destroy(),this.exportBtn.destroy(),this.shortcuts.destroy(),this.detail.destroy(),this.root.remove();}};export{ue as Panel};//# sourceMappingURL=panel-7URHNKQH.js.map
2
- //# sourceMappingURL=panel-7URHNKQH.js.map
@@ -1,2 +0,0 @@
1
- import {D,F,b,c,a,i,t,R,aa,j,Z,T,V,ea,ba,ca,E,d,W,X,Y,N,x,O,A,z,y,P,e,s,k,p,l,m,n,o,r,q}from'./chunk-7ZBKJ6NW.js';var M=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=b("div",{class:`sp-segmented${e.extraClass?` ${e.extraClass}`:""}`,role:"radiogroup"}),this.element.setAttribute("aria-label",e.ariaLabel);for(let t of this.opts){let s=document.createElement("button");s.type="button",s.className=e.modifierPrefix!==void 0?`sp-segmented__btn ${e.modifierPrefix}${t.value}`:"sp-segmented__btn",s.dataset[this.datasetKey]=t.value,s.setAttribute("role","radio");let n=this.current===t.value;if(s.setAttribute("aria-checked",String(n)),s.tabIndex=n?0:-1,n&&s.classList.add("sp-segmented__btn--active"),t.color&&s.style.setProperty("--sp-chip-color",t.color),t.bg&&s.style.setProperty("--sp-chip-bg",t.bg),t.icon){let a$1=b("span",{class:"sp-segmented__icon"});a$1.appendChild(a(t.icon)),s.appendChild(a$1);}let o=b("span",{class:"sp-segmented__label"});c(o,t.label),s.appendChild(o),s.addEventListener("click",()=>this.select(t.value)),s.addEventListener("keydown",a=>this.handleKey(a,t.value)),this.element.appendChild(s);}}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 s=t.dataset[this.datasetKey]===this.current;t.classList.toggle("sp-segmented__btn--active",s),t.setAttribute("aria-checked",String(s)),t.tabIndex=s?0:-1;}}setOptionVisible(e,t){let s=this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`);return s?(s.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 s=this.opts.map(d=>d.value).filter(d=>{let c=this.element.querySelector(`[data-${this.kebabKey()}="${d}"]`);return c!==null&&c.style.display!=="none"}),n=s.indexOf(t);if(n<0)return;let o;switch(e.key){case "ArrowLeft":o=(n-1+s.length)%s.length;break;case "ArrowRight":o=(n+1)%s.length;break;case "Home":o=0;break;case "End":o=s.length-1;break;default:return}e.preventDefault();let a=s[o];a!==void 0&&(this.select(a),this.focusOption(a));}kebabKey(){return this.datasetKey.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}};var me=D.filter(O=>!F(O)),ue=class{constructor(e,t$1,s,n,o,a$1,d,c$1,b$1){this.colors=t$1;this.bus=s;this.client=n;this.projectName=o;this.markers=a$1;this.t=d;this.locale=c$1;this.shadowRoot=e,this.getScope=b$1?.getScope??(()=>({url:window.location.pathname,urlPattern:null})),this.scopeAnnotationsByUrl=b$1?.scopeAnnotationsByUrl??true,this.root=b("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 m=b("div",{class:"sp-panel-header"}),p=b("span",{class:"sp-panel-title"});c(p,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(a(i)),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(a(t));let y=document.createElement("span");c(y,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(y),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll()),this.exportBtn=new R(t$1,()=>this.feedbacks,this.t);let C=b("div",{class:"sp-panel-header-right"});C.appendChild(this.exportBtn.element),C.appendChild(this.deleteAllBtn),C.appendChild(this.closeBtn),m.appendChild(p),m.appendChild(C),this.stats=new aa(t$1,this.t);let k=b("div",{class:"sp-filters"}),T$1=b("div",{class:"sp-search-wrap"}),f=a(j);f.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);}),T$1.appendChild(f),T$1.appendChild(this.searchInput);let L=b("div",{class:"sp-filter-bar"});L.appendChild(this.buildTypeDropdown()),L.appendChild(this.buildStatusSegmented()),L.appendChild(this.buildScopeSegmented()),this.sortControls=new Z(t$1,()=>this.renderList(),this.t),k.appendChild(T$1),k.appendChild(L),k.appendChild(this.sortControls.element),this.listContainer=b("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label",this.t("panel.feedbackList")),this.bulk=new T(t$1,{onResolve:i=>this.bulkResolve(i),onDelete:i=>this.bulkDelete(i)},this.t),this.bulk.setListContainer(this.listContainer),this.detail=new V(t$1,{onBack:()=>this.detail.hide(),onResolve:async i=>{try{let r=!F(i.status);await this.client.resolveFeedback(i.id,r),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onDelete:async i=>{try{await this.client.deleteFeedback(i.id),this.bus.emit("feedback:deleted",i.id),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onGoToAnnotation:i=>{if(i.annotations.length>0){let r=i.annotations[0];if(!r)return;window.scrollTo({left:r.scrollX,top:r.scrollY,behavior:"smooth"}),this.markers.pinHighlight(i);}}},this.t,c$1),this.shortcuts=new ea(t$1,{onNavigate:i=>{let r=ba(this.listContainer);ca(this.listContainer,i==="down"?r+1:r-1);},onResolve:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="resolve"]');u&&this.toggleResolve(i,u).catch(()=>{});}},onDelete:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="delete"]');u&&this.deleteFeedback(i,u).catch(()=>{});}},onFocusSearch:()=>this.searchInput.focus(),onToggleSelect:()=>{let i=this.getFocusedFeedback();i&&this.bulk.toggle(i.id);}},this.t),this.root.appendChild(m),this.root.appendChild(this.stats.element),this.root.appendChild(k),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.root),this.onListClick=i=>{let r=i.target;if(r.closest(".sp-bulk-checkbox"))return;let u=r.closest("[data-action]");if(u){i.stopPropagation();let A=u.closest(".sp-card");if(!A)return;let w=A.dataset.feedbackId,g=this.feedbacks.find(E=>E.id===w);if(!g)return;let B=u.dataset.action;if(B==="expand"){let E=A.querySelector(".sp-card-message");if(!E)return;let R=E.classList.toggle("sp-card-message--expanded");c(u,R?this.t("panel.showLess"):this.t("panel.showMore")),u.setAttribute("aria-expanded",String(R));}else if(B==="resolve"){if(this.pendingMutations.has(g.id))return;let E=u;this.toggleResolve(g,E).catch(()=>{});}else if(B==="delete"){if(this.pendingMutations.has(g.id))return;let E=u;this.deleteFeedback(g,E).catch(()=>{});}return}let v=r.closest(".sp-card");if(v){let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}}},this.listContainer.addEventListener("click",this.onListClick),this.onListKeydown=i=>{let r=i;if(r.key!=="Enter"&&r.key!==" ")return;let u=r.target,v=u.closest(".sp-card");if(!v||u!==v)return;r.preventDefault();let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}},this.listContainer.addEventListener("keydown",this.onListKeydown),this.onListMouseover=i=>{let u=i.target.closest(".sp-card");if(!u)return;let v=u.dataset.feedbackId;v&&this.markers.highlight(v);},this.listContainer.addEventListener("mouseover",this.onListMouseover),this.onListMouseout=i=>{let r=i.relatedTarget;r&&this.listContainer.contains(r)||this.markers.highlight("");},this.listContainer.addEventListener("mouseout",this.onListMouseout),this.bus.on("panel:toggle",i=>{i?this.open():this.close();}),e.addEventListener("keydown",i=>{let r=i;if(r.key==="Escape"&&this.isOpen){if(this.detail.isVisible){this.detail.hide();return}this.close();return}if(r.key==="Tab"&&this.isOpen){let u=B=>{let E=B;for(;E&&E!==this.root;){if(E.style.display==="none")return false;E=E.parentElement;}return true},v=Array.from(this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(B=>u(B)&&!B.hasAttribute("disabled"));if(v.length===0)return;let A=v[0],w=v[v.length-1];if(!A||!w)return;let g=e.activeElement;r.shiftKey&&g===A?(r.preventDefault(),w.focus()):!r.shiftKey&&g===w&&(r.preventDefault(),A.focus());}}),this.onMarkerClick=(i=>{this.scrollToFeedback(i.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"]);typeDropdownBtn;typeDropdownContainer;typeDropdownMenu=null;typeDropdownOutsideHandler=null;statusSegmented;typeOptions;feedbacks=[];currentPage=1;totalFeedbacks=0;isLoadingMore=false;isOpen=false;searchTimeout=null;loadController=null;pendingMutations=new Set;stats;sortControls;bulk;exportBtn;shortcuts;detail;shadowRoot;getScope;scopeAnnotationsByUrl;scopeSegmented;initialScopeFilter="this";onMarkerClick;onListClick;onListKeydown;onListMouseover;onListMouseout;async open(){this.isOpen||(this.isOpen=true,this.root.classList.add("sp-panel--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),this.shortcuts.enable(this.shadowRoot),await this.loadFeedbacks(),requestAnimationFrame(()=>{this.searchInput?this.searchInput.focus():this.closeBtn.focus();}));}close(){if(!this.isOpen)return;this.isOpen=false,this.root.classList.remove("sp-panel--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.shortcuts.disable(),this.detail.hide(),this.root.getRootNode().querySelector(".sp-fab")?.focus();}showLoading(){this.listContainer.replaceChildren();let e=b("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label",this.t("panel.loading"));let t=b("div",{class:"sp-spinner"});e.appendChild(t),this.listContainer.appendChild(e);}showError(){this.listContainer.replaceChildren();let e=b("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=b("div",{class:"sp-empty-text"});c(t,this.t("panel.loadError"));let s=document.createElement("button");s.className="sp-btn-ghost",s.style.marginTop="8px",c(s,this.t("panel.retry")),s.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(t),e.appendChild(s),this.listContainer.appendChild(e);}statusBucket(e){if(e!=="all")return F(e)?E:me}async loadFeedbacks(){this.loadController?.abort(),this.loadController=new AbortController;let{signal:e}=this.loadController;this.currentPage=1;let t=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 a=this.scopeSegmented.value,d={page:1,limit:20};s&&(d.type=s),n&&(d.statuses=n),t&&(d.search=t),a==="this"?d.url=o.url:a==="template"&&o.urlPattern&&(d.urlPattern=o.urlPattern);let c=this.feedbacks.length>0;c||this.showLoading();try{let{feedbacks:b,total:m}=await this.client.getFeedbacks(this.projectName,d);if(e.aborted)return;this.feedbacks=b,this.totalFeedbacks=m,this.stats.update(b,m),this.bulk.reset(),this.renderList();let p=this.scopeAnnotationsByUrl?b.filter(y=>y.url===o.url):b;this.markers.render(p);}catch(b){if(e.aborted)return;c||this.showError(),this.bus.emit("feedback:error",b instanceof Error?b:new Error(String(b)));}}async loadMoreFeedbacks(){if(this.isLoadingMore)return;this.isLoadingMore=true;let e=this.loadController,t=this.currentPage+1,s=this.searchInput.value.trim()||void 0,n=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],o=this.statusBucket(this.statusSegmented.value),a=this.getScope(),d$1=this.scopeSegmented.value,c={page:t,limit:20};n&&(c.type=n),o&&(c.statuses=o),s&&(c.search=s),d$1==="this"?c.url=a.url:d$1==="template"&&a.urlPattern&&(c.urlPattern=a.urlPattern);let b=this.listContainer.querySelector(".sp-btn-load-more"),m;b&&(m=d(b));try{let{feedbacks:p,total:y}=await this.client.getFeedbacks(this.projectName,c);if(e!==this.loadController)return;this.currentPage=t,this.totalFeedbacks=y,this.feedbacks=[...this.feedbacks,...p],this.stats.update(this.feedbacks,y),this.renderList();let C=this.scopeAnnotationsByUrl?this.feedbacks.filter(k=>k.url===a.url):this.feedbacks;this.markers.render(C);}catch(p){m&&m(),this.bus.emit("feedback:error",p instanceof Error?p:new Error(String(p)));}finally{this.isLoadingMore=false;}}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let o=b("div",{class:"sp-empty"});o.setAttribute("role","status"),o.setAttribute("aria-live","polite");let a=b("div",{class:"sp-empty-text"});c(a,this.t("panel.empty")),o.appendChild(a),this.listContainer.appendChild(o);return}let e=W(this.feedbacks,this.sortControls.sortMode),t=e.map(o=>o.id),s=this.bulk.createSelectAllBar(t,this.t("bulk.selectAll"));if(this.listContainer.appendChild(s),this.sortControls.groupByPage){let o=X(e),a=0;for(let[d,c]of o){let b$1=Y(d,c.length,this.colors);this.listContainer.appendChild(b$1);let m=b("div",{class:"sp-group-content"});for(let p of c){let y=this.createCard(p,a+1);y.style.setProperty("--sp-card-i",String(a)),m.appendChild(y),a++;}this.listContainer.appendChild(m);}}else e.forEach((o,a)=>{let d=this.createCard(o,a+1);d.style.setProperty("--sp-card-i",String(a)),this.listContainer.appendChild(d);});let n=this.totalFeedbacks-this.feedbacks.length;if(n>0){let o=b("div",{class:"sp-load-more-wrap"}),a=document.createElement("button");a.className="sp-btn-ghost sp-btn-load-more",c(a,N(this.t,"panel.loadMore",{remaining:n})),a.addEventListener("click",()=>this.loadMoreFeedbacks().catch(()=>{})),o.appendChild(a),this.listContainer.appendChild(o);}}createCard(e$1,t$1){let s$1=F(e$1.status),n=x(e$1.type,this.colors),o=b("div",{class:`sp-card ${s$1?"sp-card--resolved":""}`});o.setAttribute("role","listitem"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Feedback #${t$1}: ${O(e$1.type,this.t)} \u2014 ${e$1.message.slice(0,80)}`),o.dataset.feedbackId=e$1.id;let a$1=b("div",{class:"sp-card-bar"});a$1.style.background=s$1?"#9ca3af":n;let d=b("div",{class:"sp-card-body"}),c$1=b("div",{class:"sp-card-header"}),b$1=this.bulk.createCheckbox(e$1.id);c$1.appendChild(b$1);let m=b("span",{class:"sp-card-number"});c(m,`#${t$1}`);let p=b("span",{class:"sp-badge"}),y$1=A(e$1.type,this.colors);p.style.background=y$1,p.style.color=n,c(p,O(e$1.type,this.t));let C=b("span",{class:"sp-badge sp-badge--status"});C.dataset.status=e$1.status,C.style.background=z(e$1.status,this.colors),C.style.color=y(e$1.status,this.colors),c(C,P(e$1.status,this.t));let k$1=b("span",{class:"sp-card-date"});c(k$1,e(e$1.createdAt,this.locale)),c$1.appendChild(m),c$1.appendChild(p),c$1.appendChild(C),c$1.appendChild(k$1);let T=b("div",{class:"sp-card-message"});c(T,e$1.message);let f=document.createElement("button");f.className="sp-card-expand",f.dataset.action="expand",c(f,this.t("panel.showMore")),f.style.display="none",f.setAttribute("aria-expanded","false"),requestAnimationFrame(()=>{T.scrollHeight>T.clientHeight&&(f.style.display="block");});let L=b("div",{class:"sp-card-footer"}),i=document.createElement("button");if(i.className="sp-btn-resolve",i.dataset.action="resolve",s$1){i.appendChild(a(s));let v=document.createElement("span");c(v,` ${this.t("panel.reopen")}`),i.appendChild(v);}else {i.appendChild(a(k));let v=document.createElement("span");c(v,` ${this.t("panel.resolve")}`),i.appendChild(v);}let r=document.createElement("button");r.className="sp-btn-delete",r.dataset.action="delete",r.appendChild(a(t));let u=document.createElement("span");return c(u,` ${this.t("panel.delete")}`),r.appendChild(u),L.appendChild(i),L.appendChild(r),d.appendChild(c$1),d.appendChild(T),d.appendChild(f),d.appendChild(L),o.appendChild(a$1),o.appendChild(d),o}async bulkResolve(e){try{await Promise.all(e.map(t=>this.client.resolveFeedback(t,!0))),await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}async bulkDelete(e){try{await Promise.all(e.map(t=>this.client.deleteFeedback(t)));for(let t of e)this.bus.emit("feedback:deleted",t);await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}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(s=>{let n=b("div",{class:"sp-confirm-backdrop"}),o=`sp-confirm-title-${Date.now()}`,a=`sp-confirm-msg-${Date.now()}`,d=b("div",{class:"sp-confirm-dialog"});d.setAttribute("role","alertdialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby",o),d.setAttribute("aria-describedby",a);let c$1=b("div",{class:"sp-confirm-title"});c$1.id=o,c(c$1,e);let b$1=b("div",{class:"sp-confirm-message"});b$1.id=a,c(b$1,t);let m=b("div",{class:"sp-confirm-actions"}),p=document.createElement("button");p.type="button",p.className="sp-btn-ghost",c(p,this.t("panel.cancel"));let y=document.createElement("button");y.type="button",y.className="sp-btn-danger",c(y,this.t("panel.confirmDelete"));let C=false,k=f=>{C||(C=true,n.removeEventListener("keydown",T),n.style.opacity="0",d.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{n.remove(),s(f);},200));},T=f=>{let L=f;if(L.key==="Escape"){k(false);return}L.key==="Tab"&&(L.preventDefault(),n.getRootNode().activeElement===p?y.focus():p.focus());};n.addEventListener("keydown",T),p.addEventListener("click",()=>k(false)),y.addEventListener("click",()=>k(true)),n.addEventListener("click",f=>{f.target===n&&k(false);}),m.appendChild(p),m.appendChild(y),d.appendChild(c$1),d.appendChild(b$1),d.appendChild(m),n.appendChild(d),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(n):this.root.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1",d.style.transform="translateY(0) scale(1)",p.focus();});})}async deleteFeedback(e,t){this.pendingMutations.add(e.id);let s=d(t);try{await this.client.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}async toggleResolve(e,t){this.pendingMutations.add(e.id);let s=d(t);try{let n=!F(e.status);await this.client.resolveFeedback(e.id,n),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}buildTypeDropdown(){return this.typeOptions=[{value:"all",label:this.t("panel.filterAll"),icon:p,color:this.colors.accent,bg:this.colors.accentLight},{value:"question",label:this.t("type.question"),icon:l,color:this.colors.typeQuestion,bg:this.colors.typeQuestionBg},{value:"change",label:this.t("type.change"),icon:m,color:this.colors.typeChange,bg:this.colors.typeChangeBg},{value:"bug",label:this.t("type.bug"),icon:n,color:this.colors.typeBug,bg:this.colors.typeBugBg},{value:"other",label:this.t("type.other"),icon:o,color:this.colors.typeOther,bg:this.colors.typeOtherBg}],this.typeDropdownContainer=b("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.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=b("span",{class:"sp-filter-dropdown-btn__icon"});t.appendChild(a(e.icon)),this.typeDropdownBtn.appendChild(t);let s=b("span",{class:"sp-filter-dropdown-btn__label"}),n=b("span",{class:"sp-filter-dropdown-btn__prefix"});c(n,this.t("type.label"));let o=b("span",{class:"sp-filter-dropdown-btn__value"});c(o,e.label),s.appendChild(n),s.appendChild(o),this.typeDropdownBtn.appendChild(s);let a$1=b("span",{class:"sp-filter-dropdown-btn__chevron"});a$1.appendChild(a(r)),this.typeDropdownBtn.appendChild(a$1);}openTypeDropdown(){this.typeDropdownMenu=b("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 s=this.activeFilters.has(e.value);t.className=`sp-filter-dropdown-option${s?" 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(s));let n=b("span",{class:"sp-filter-dropdown-option__icon"});n.appendChild(a(e.icon)),t.appendChild(n);let o=b("span",{class:"sp-filter-dropdown-option__label"});if(c(o,e.label),t.appendChild(o),s){let a$1=b("span",{class:"sp-filter-dropdown-option__check"});a$1.appendChild(a(k)),t.appendChild(a$1);}t.addEventListener("click",a=>{a.stopPropagation(),this.selectTypeFilter(e.value);}),this.typeDropdownMenu.appendChild(t);}this.typeDropdownContainer.appendChild(this.typeDropdownMenu),requestAnimationFrame(()=>{this.typeDropdownOutsideHandler=e=>{this.typeDropdownMenu&&!this.typeDropdownContainer.contains(e.target)&&this.closeTypeDropdown();},document.addEventListener("click",this.typeDropdownOutsideHandler,true);}),this.typeDropdownMenu.addEventListener("keydown",e=>{e.key==="Escape"&&(this.closeTypeDropdown(),this.typeDropdownBtn.focus());});}closeTypeDropdown(){this.typeDropdownMenu&&(this.typeDropdownMenu.remove(),this.typeDropdownMenu=null),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.typeDropdownOutsideHandler&&(document.removeEventListener("click",this.typeDropdownOutsideHandler,true),this.typeDropdownOutsideHandler=null);}selectTypeFilter(e){this.activeFilters.clear(),this.activeFilters.add(e),this.renderTypeDropdownTrigger(),this.closeTypeDropdown(),this.loadFeedbacks().catch(()=>{});}buildStatusSegmented(){return this.statusSegmented=new M({options:[{value:"all",label:this.t("panel.statusAll"),icon:p,color:this.colors.accent,bg:this.colors.accentLight},{value:"open",label:this.t("panel.statusOpen"),icon:q,color:this.colors.statusOpen,bg:this.colors.statusOpenBg},{value:"resolved",label:this.t("panel.statusResolved"),icon:k,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 M({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");}getFocusedFeedback(){let e=ba(this.listContainer);if(e<0)return;let t=this.listContainer.querySelectorAll(".sp-card")[e];if(t)return this.feedbacks.find(s=>s.id===t.dataset.feedbackId)}scrollToFeedback(e){let t=CSS.escape(e),s=this.listContainer.querySelector(`[data-feedback-id="${t}"]`);s&&(s.scrollIntoView({behavior:"smooth",block:"center"}),s.classList.add("sp-anim-flash"),s.addEventListener("animationend",()=>{s.classList.remove("sp-anim-flash");},{once:true}));}async refresh(){this.isOpen&&await this.loadFeedbacks();}get isCurrentlyOpen(){return this.isOpen}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.closeTypeDropdown(),this.sortControls.destroy(),this.bulk.destroy(),this.exportBtn.destroy(),this.shortcuts.destroy(),this.detail.destroy(),this.root.remove();}};export{ue as Panel};//# sourceMappingURL=panel-FUPBUN6F.js.map
2
- //# sourceMappingURL=panel-FUPBUN6F.js.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkGKRKCSID_cjs=require('./chunk-GKRKCSID.cjs');var M=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=chunkGKRKCSID_cjs.b("div",{class:`sp-segmented${e.extraClass?` ${e.extraClass}`:""}`,role:"radiogroup"}),this.element.setAttribute("aria-label",e.ariaLabel);for(let t of this.opts){let s=document.createElement("button");s.type="button",s.className=e.modifierPrefix!==void 0?`sp-segmented__btn ${e.modifierPrefix}${t.value}`:"sp-segmented__btn",s.dataset[this.datasetKey]=t.value,s.setAttribute("role","radio");let n=this.current===t.value;if(s.setAttribute("aria-checked",String(n)),s.tabIndex=n?0:-1,n&&s.classList.add("sp-segmented__btn--active"),t.color&&s.style.setProperty("--sp-chip-color",t.color),t.bg&&s.style.setProperty("--sp-chip-bg",t.bg),t.icon){let a=chunkGKRKCSID_cjs.b("span",{class:"sp-segmented__icon"});a.appendChild(chunkGKRKCSID_cjs.a(t.icon)),s.appendChild(a);}let o=chunkGKRKCSID_cjs.b("span",{class:"sp-segmented__label"});chunkGKRKCSID_cjs.c(o,t.label),s.appendChild(o),s.addEventListener("click",()=>this.select(t.value)),s.addEventListener("keydown",a=>this.handleKey(a,t.value)),this.element.appendChild(s);}}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 s=t.dataset[this.datasetKey]===this.current;t.classList.toggle("sp-segmented__btn--active",s),t.setAttribute("aria-checked",String(s)),t.tabIndex=s?0:-1;}}setOptionVisible(e,t){let s=this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`);return s?(s.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 s=this.opts.map(d=>d.value).filter(d=>{let c=this.element.querySelector(`[data-${this.kebabKey()}="${d}"]`);return c!==null&&c.style.display!=="none"}),n=s.indexOf(t);if(n<0)return;let o;switch(e.key){case "ArrowLeft":o=(n-1+s.length)%s.length;break;case "ArrowRight":o=(n+1)%s.length;break;case "Home":o=0;break;case "End":o=s.length-1;break;default:return}e.preventDefault();let a=s[o];a!==void 0&&(this.select(a),this.focusOption(a));}kebabKey(){return this.datasetKey.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}};var me=chunkGKRKCSID_cjs.D.filter(O=>!chunkGKRKCSID_cjs.F(O)),ue=class{constructor(e,t,s,n,o,a,d,c,b){this.colors=t;this.bus=s;this.client=n;this.projectName=o;this.markers=a;this.t=d;this.locale=c;this.shadowRoot=e,this.getScope=b?.getScope??(()=>({url:window.location.pathname,urlPattern:null})),this.scopeAnnotationsByUrl=b?.scopeAnnotationsByUrl??true,this.root=chunkGKRKCSID_cjs.b("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 m=chunkGKRKCSID_cjs.b("div",{class:"sp-panel-header"}),p=chunkGKRKCSID_cjs.b("span",{class:"sp-panel-title"});chunkGKRKCSID_cjs.c(p,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(chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.i)),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(chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.t));let y=document.createElement("span");chunkGKRKCSID_cjs.c(y,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(y),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll()),this.exportBtn=new chunkGKRKCSID_cjs.R(t,()=>this.feedbacks,this.t);let C=chunkGKRKCSID_cjs.b("div",{class:"sp-panel-header-right"});C.appendChild(this.exportBtn.element),C.appendChild(this.deleteAllBtn),C.appendChild(this.closeBtn),m.appendChild(p),m.appendChild(C),this.stats=new chunkGKRKCSID_cjs.aa(t,this.t);let k=chunkGKRKCSID_cjs.b("div",{class:"sp-filters"}),T=chunkGKRKCSID_cjs.b("div",{class:"sp-search-wrap"}),f=chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.j);f.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);}),T.appendChild(f),T.appendChild(this.searchInput);let L=chunkGKRKCSID_cjs.b("div",{class:"sp-filter-bar"});L.appendChild(this.buildTypeDropdown()),L.appendChild(this.buildStatusSegmented()),L.appendChild(this.buildScopeSegmented()),this.sortControls=new chunkGKRKCSID_cjs.Z(t,()=>this.renderList(),this.t),k.appendChild(T),k.appendChild(L),k.appendChild(this.sortControls.element),this.listContainer=chunkGKRKCSID_cjs.b("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label",this.t("panel.feedbackList")),this.bulk=new chunkGKRKCSID_cjs.T(t,{onResolve:i=>this.bulkResolve(i),onDelete:i=>this.bulkDelete(i)},this.t),this.bulk.setListContainer(this.listContainer),this.detail=new chunkGKRKCSID_cjs.V(t,{onBack:()=>this.detail.hide(),onResolve:async i=>{try{let r=!chunkGKRKCSID_cjs.F(i.status);await this.client.resolveFeedback(i.id,r),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onDelete:async i=>{try{await this.client.deleteFeedback(i.id),this.bus.emit("feedback:deleted",i.id),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onGoToAnnotation:i=>{if(i.annotations.length>0){let r=i.annotations[0];if(!r)return;window.scrollTo({left:r.scrollX,top:r.scrollY,behavior:"smooth"}),this.markers.pinHighlight(i);}}},this.t,c),this.shortcuts=new chunkGKRKCSID_cjs.ea(t,{onNavigate:i=>{let r=chunkGKRKCSID_cjs.ba(this.listContainer);chunkGKRKCSID_cjs.ca(this.listContainer,i==="down"?r+1:r-1);},onResolve:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="resolve"]');u&&this.toggleResolve(i,u).catch(()=>{});}},onDelete:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="delete"]');u&&this.deleteFeedback(i,u).catch(()=>{});}},onFocusSearch:()=>this.searchInput.focus(),onToggleSelect:()=>{let i=this.getFocusedFeedback();i&&this.bulk.toggle(i.id);}},this.t),this.root.appendChild(m),this.root.appendChild(this.stats.element),this.root.appendChild(k),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.root),this.onListClick=i=>{let r=i.target;if(r.closest(".sp-bulk-checkbox"))return;let u=r.closest("[data-action]");if(u){i.stopPropagation();let A=u.closest(".sp-card");if(!A)return;let w=A.dataset.feedbackId,g=this.feedbacks.find(E=>E.id===w);if(!g)return;let B=u.dataset.action;if(B==="expand"){let E=A.querySelector(".sp-card-message");if(!E)return;let R=E.classList.toggle("sp-card-message--expanded");chunkGKRKCSID_cjs.c(u,R?this.t("panel.showLess"):this.t("panel.showMore")),u.setAttribute("aria-expanded",String(R));}else if(B==="resolve"){if(this.pendingMutations.has(g.id))return;let E=u;this.toggleResolve(g,E).catch(()=>{});}else if(B==="delete"){if(this.pendingMutations.has(g.id))return;let E=u;this.deleteFeedback(g,E).catch(()=>{});}return}let v=r.closest(".sp-card");if(v){let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}}},this.listContainer.addEventListener("click",this.onListClick),this.onListKeydown=i=>{let r=i;if(r.key!=="Enter"&&r.key!==" ")return;let u=r.target,v=u.closest(".sp-card");if(!v||u!==v)return;r.preventDefault();let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}},this.listContainer.addEventListener("keydown",this.onListKeydown),this.onListMouseover=i=>{let u=i.target.closest(".sp-card");if(!u)return;let v=u.dataset.feedbackId;v&&this.markers.highlight(v);},this.listContainer.addEventListener("mouseover",this.onListMouseover),this.onListMouseout=i=>{let r=i.relatedTarget;r&&this.listContainer.contains(r)||this.markers.highlight("");},this.listContainer.addEventListener("mouseout",this.onListMouseout),this.bus.on("panel:toggle",i=>{i?this.open():this.close();}),e.addEventListener("keydown",i=>{let r=i;if(r.key==="Escape"&&this.isOpen){if(this.detail.isVisible){this.detail.hide();return}this.close();return}if(r.key==="Tab"&&this.isOpen){let u=B=>{let E=B;for(;E&&E!==this.root;){if(E.style.display==="none")return false;E=E.parentElement;}return true},v=Array.from(this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(B=>u(B)&&!B.hasAttribute("disabled"));if(v.length===0)return;let A=v[0],w=v[v.length-1];if(!A||!w)return;let g=e.activeElement;r.shiftKey&&g===A?(r.preventDefault(),w.focus()):!r.shiftKey&&g===w&&(r.preventDefault(),A.focus());}}),this.onMarkerClick=(i=>{this.scrollToFeedback(i.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"]);typeDropdownBtn;typeDropdownContainer;typeDropdownMenu=null;typeDropdownOutsideHandler=null;statusSegmented;typeOptions;feedbacks=[];currentPage=1;totalFeedbacks=0;isLoadingMore=false;isOpen=false;searchTimeout=null;loadController=null;pendingMutations=new Set;stats;sortControls;bulk;exportBtn;shortcuts;detail;shadowRoot;getScope;scopeAnnotationsByUrl;scopeSegmented;initialScopeFilter="this";onMarkerClick;onListClick;onListKeydown;onListMouseover;onListMouseout;async open(){this.isOpen||(this.isOpen=true,this.root.classList.add("sp-panel--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),this.shortcuts.enable(this.shadowRoot),await this.loadFeedbacks(),requestAnimationFrame(()=>{this.searchInput?this.searchInput.focus():this.closeBtn.focus();}));}close(){if(!this.isOpen)return;this.isOpen=false,this.root.classList.remove("sp-panel--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.shortcuts.disable(),this.detail.hide(),this.root.getRootNode().querySelector(".sp-fab")?.focus();}showLoading(){this.listContainer.replaceChildren();let e=chunkGKRKCSID_cjs.b("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label",this.t("panel.loading"));let t=chunkGKRKCSID_cjs.b("div",{class:"sp-spinner"});e.appendChild(t),this.listContainer.appendChild(e);}showError(){this.listContainer.replaceChildren();let e=chunkGKRKCSID_cjs.b("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=chunkGKRKCSID_cjs.b("div",{class:"sp-empty-text"});chunkGKRKCSID_cjs.c(t,this.t("panel.loadError"));let s=document.createElement("button");s.className="sp-btn-ghost",s.style.marginTop="8px",chunkGKRKCSID_cjs.c(s,this.t("panel.retry")),s.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(t),e.appendChild(s),this.listContainer.appendChild(e);}statusBucket(e){if(e!=="all")return chunkGKRKCSID_cjs.F(e)?chunkGKRKCSID_cjs.E:me}async loadFeedbacks(){this.loadController?.abort(),this.loadController=new AbortController;let{signal:e}=this.loadController;this.currentPage=1;let t=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 a=this.scopeSegmented.value,d={page:1,limit:20};s&&(d.type=s),n&&(d.statuses=n),t&&(d.search=t),a==="this"?d.url=o.url:a==="template"&&o.urlPattern&&(d.urlPattern=o.urlPattern);let c=this.feedbacks.length>0;c||this.showLoading();try{let{feedbacks:b,total:m}=await this.client.getFeedbacks(this.projectName,d);if(e.aborted)return;this.feedbacks=b,this.totalFeedbacks=m,this.stats.update(b,m),this.bulk.reset(),this.renderList();let p=this.scopeAnnotationsByUrl?b.filter(y=>y.url===o.url):b;this.markers.render(p);}catch(b){if(e.aborted)return;c||this.showError(),this.bus.emit("feedback:error",b instanceof Error?b:new Error(String(b)));}}async loadMoreFeedbacks(){if(this.isLoadingMore)return;this.isLoadingMore=true;let e=this.loadController,t=this.currentPage+1,s=this.searchInput.value.trim()||void 0,n=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],o=this.statusBucket(this.statusSegmented.value),a=this.getScope(),d=this.scopeSegmented.value,c={page:t,limit:20};n&&(c.type=n),o&&(c.statuses=o),s&&(c.search=s),d==="this"?c.url=a.url:d==="template"&&a.urlPattern&&(c.urlPattern=a.urlPattern);let b=this.listContainer.querySelector(".sp-btn-load-more"),m;b&&(m=chunkGKRKCSID_cjs.d(b));try{let{feedbacks:p,total:y}=await this.client.getFeedbacks(this.projectName,c);if(e!==this.loadController)return;this.currentPage=t,this.totalFeedbacks=y,this.feedbacks=[...this.feedbacks,...p],this.stats.update(this.feedbacks,y),this.renderList();let C=this.scopeAnnotationsByUrl?this.feedbacks.filter(k=>k.url===a.url):this.feedbacks;this.markers.render(C);}catch(p){m&&m(),this.bus.emit("feedback:error",p instanceof Error?p:new Error(String(p)));}finally{this.isLoadingMore=false;}}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let o=chunkGKRKCSID_cjs.b("div",{class:"sp-empty"});o.setAttribute("role","status"),o.setAttribute("aria-live","polite");let a=chunkGKRKCSID_cjs.b("div",{class:"sp-empty-text"});chunkGKRKCSID_cjs.c(a,this.t("panel.empty")),o.appendChild(a),this.listContainer.appendChild(o);return}let e=chunkGKRKCSID_cjs.W(this.feedbacks,this.sortControls.sortMode),t=e.map(o=>o.id),s=this.bulk.createSelectAllBar(t,this.t("bulk.selectAll"));if(this.listContainer.appendChild(s),this.sortControls.groupByPage){let o=chunkGKRKCSID_cjs.X(e),a=0;for(let[d,c]of o){let b=chunkGKRKCSID_cjs.Y(d,c.length,this.colors);this.listContainer.appendChild(b);let m=chunkGKRKCSID_cjs.b("div",{class:"sp-group-content"});for(let p of c){let y=this.createCard(p,a+1);y.style.setProperty("--sp-card-i",String(a)),m.appendChild(y),a++;}this.listContainer.appendChild(m);}}else e.forEach((o,a)=>{let d=this.createCard(o,a+1);d.style.setProperty("--sp-card-i",String(a)),this.listContainer.appendChild(d);});let n=this.totalFeedbacks-this.feedbacks.length;if(n>0){let o=chunkGKRKCSID_cjs.b("div",{class:"sp-load-more-wrap"}),a=document.createElement("button");a.className="sp-btn-ghost sp-btn-load-more",chunkGKRKCSID_cjs.c(a,chunkGKRKCSID_cjs.N(this.t,"panel.loadMore",{remaining:n})),a.addEventListener("click",()=>this.loadMoreFeedbacks().catch(()=>{})),o.appendChild(a),this.listContainer.appendChild(o);}}createCard(e,t){let s=chunkGKRKCSID_cjs.F(e.status),n=chunkGKRKCSID_cjs.x(e.type,this.colors),o=chunkGKRKCSID_cjs.b("div",{class:`sp-card ${s?"sp-card--resolved":""}`});o.setAttribute("role","listitem"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Feedback #${t}: ${chunkGKRKCSID_cjs.O(e.type,this.t)} \u2014 ${e.message.slice(0,80)}`),o.dataset.feedbackId=e.id;let a=chunkGKRKCSID_cjs.b("div",{class:"sp-card-bar"});a.style.background=s?"#9ca3af":n;let d=chunkGKRKCSID_cjs.b("div",{class:"sp-card-body"}),c=chunkGKRKCSID_cjs.b("div",{class:"sp-card-header"}),b=this.bulk.createCheckbox(e.id);c.appendChild(b);let m=chunkGKRKCSID_cjs.b("span",{class:"sp-card-number"});chunkGKRKCSID_cjs.c(m,`#${t}`);let p=chunkGKRKCSID_cjs.b("span",{class:"sp-badge"}),y=chunkGKRKCSID_cjs.A(e.type,this.colors);p.style.background=y,p.style.color=n,chunkGKRKCSID_cjs.c(p,chunkGKRKCSID_cjs.O(e.type,this.t));let C=chunkGKRKCSID_cjs.b("span",{class:"sp-badge sp-badge--status"});C.dataset.status=e.status,C.style.background=chunkGKRKCSID_cjs.z(e.status,this.colors),C.style.color=chunkGKRKCSID_cjs.y(e.status,this.colors),chunkGKRKCSID_cjs.c(C,chunkGKRKCSID_cjs.P(e.status,this.t));let k=chunkGKRKCSID_cjs.b("span",{class:"sp-card-date"});chunkGKRKCSID_cjs.c(k,chunkGKRKCSID_cjs.e(e.createdAt,this.locale)),c.appendChild(m),c.appendChild(p),c.appendChild(C),c.appendChild(k);let T=chunkGKRKCSID_cjs.b("div",{class:"sp-card-message"});chunkGKRKCSID_cjs.c(T,e.message);let f=document.createElement("button");f.className="sp-card-expand",f.dataset.action="expand",chunkGKRKCSID_cjs.c(f,this.t("panel.showMore")),f.style.display="none",f.setAttribute("aria-expanded","false"),requestAnimationFrame(()=>{T.scrollHeight>T.clientHeight&&(f.style.display="block");});let L=chunkGKRKCSID_cjs.b("div",{class:"sp-card-footer"}),i=document.createElement("button");if(i.className="sp-btn-resolve",i.dataset.action="resolve",s){i.appendChild(chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.s));let v=document.createElement("span");chunkGKRKCSID_cjs.c(v,` ${this.t("panel.reopen")}`),i.appendChild(v);}else {i.appendChild(chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.k));let v=document.createElement("span");chunkGKRKCSID_cjs.c(v,` ${this.t("panel.resolve")}`),i.appendChild(v);}let r=document.createElement("button");r.className="sp-btn-delete",r.dataset.action="delete",r.appendChild(chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.t));let u=document.createElement("span");return chunkGKRKCSID_cjs.c(u,` ${this.t("panel.delete")}`),r.appendChild(u),L.appendChild(i),L.appendChild(r),d.appendChild(c),d.appendChild(T),d.appendChild(f),d.appendChild(L),o.appendChild(a),o.appendChild(d),o}async bulkResolve(e){try{await Promise.all(e.map(t=>this.client.resolveFeedback(t,!0))),await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}async bulkDelete(e){try{await Promise.all(e.map(t=>this.client.deleteFeedback(t)));for(let t of e)this.bus.emit("feedback:deleted",t);await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}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(s=>{let n=chunkGKRKCSID_cjs.b("div",{class:"sp-confirm-backdrop"}),o=`sp-confirm-title-${Date.now()}`,a=`sp-confirm-msg-${Date.now()}`,d=chunkGKRKCSID_cjs.b("div",{class:"sp-confirm-dialog"});d.setAttribute("role","alertdialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby",o),d.setAttribute("aria-describedby",a);let c=chunkGKRKCSID_cjs.b("div",{class:"sp-confirm-title"});c.id=o,chunkGKRKCSID_cjs.c(c,e);let b=chunkGKRKCSID_cjs.b("div",{class:"sp-confirm-message"});b.id=a,chunkGKRKCSID_cjs.c(b,t);let m=chunkGKRKCSID_cjs.b("div",{class:"sp-confirm-actions"}),p=document.createElement("button");p.type="button",p.className="sp-btn-ghost",chunkGKRKCSID_cjs.c(p,this.t("panel.cancel"));let y=document.createElement("button");y.type="button",y.className="sp-btn-danger",chunkGKRKCSID_cjs.c(y,this.t("panel.confirmDelete"));let C=false,k=f=>{C||(C=true,n.removeEventListener("keydown",T),n.style.opacity="0",d.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{n.remove(),s(f);},200));},T=f=>{let L=f;if(L.key==="Escape"){k(false);return}L.key==="Tab"&&(L.preventDefault(),n.getRootNode().activeElement===p?y.focus():p.focus());};n.addEventListener("keydown",T),p.addEventListener("click",()=>k(false)),y.addEventListener("click",()=>k(true)),n.addEventListener("click",f=>{f.target===n&&k(false);}),m.appendChild(p),m.appendChild(y),d.appendChild(c),d.appendChild(b),d.appendChild(m),n.appendChild(d),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(n):this.root.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1",d.style.transform="translateY(0) scale(1)",p.focus();});})}async deleteFeedback(e,t){this.pendingMutations.add(e.id);let s=chunkGKRKCSID_cjs.d(t);try{await this.client.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}async toggleResolve(e,t){this.pendingMutations.add(e.id);let s=chunkGKRKCSID_cjs.d(t);try{let n=!chunkGKRKCSID_cjs.F(e.status);await this.client.resolveFeedback(e.id,n),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}buildTypeDropdown(){return this.typeOptions=[{value:"all",label:this.t("panel.filterAll"),icon:chunkGKRKCSID_cjs.p,color:this.colors.accent,bg:this.colors.accentLight},{value:"question",label:this.t("type.question"),icon:chunkGKRKCSID_cjs.l,color:this.colors.typeQuestion,bg:this.colors.typeQuestionBg},{value:"change",label:this.t("type.change"),icon:chunkGKRKCSID_cjs.m,color:this.colors.typeChange,bg:this.colors.typeChangeBg},{value:"bug",label:this.t("type.bug"),icon:chunkGKRKCSID_cjs.n,color:this.colors.typeBug,bg:this.colors.typeBugBg},{value:"other",label:this.t("type.other"),icon:chunkGKRKCSID_cjs.o,color:this.colors.typeOther,bg:this.colors.typeOtherBg}],this.typeDropdownContainer=chunkGKRKCSID_cjs.b("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.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=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-btn__icon"});t.appendChild(chunkGKRKCSID_cjs.a(e.icon)),this.typeDropdownBtn.appendChild(t);let s=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-btn__label"}),n=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-btn__prefix"});chunkGKRKCSID_cjs.c(n,this.t("type.label"));let o=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-btn__value"});chunkGKRKCSID_cjs.c(o,e.label),s.appendChild(n),s.appendChild(o),this.typeDropdownBtn.appendChild(s);let a=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-btn__chevron"});a.appendChild(chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.r)),this.typeDropdownBtn.appendChild(a);}openTypeDropdown(){this.typeDropdownMenu=chunkGKRKCSID_cjs.b("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 s=this.activeFilters.has(e.value);t.className=`sp-filter-dropdown-option${s?" 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(s));let n=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-option__icon"});n.appendChild(chunkGKRKCSID_cjs.a(e.icon)),t.appendChild(n);let o=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-option__label"});if(chunkGKRKCSID_cjs.c(o,e.label),t.appendChild(o),s){let a=chunkGKRKCSID_cjs.b("span",{class:"sp-filter-dropdown-option__check"});a.appendChild(chunkGKRKCSID_cjs.a(chunkGKRKCSID_cjs.k)),t.appendChild(a);}t.addEventListener("click",a=>{a.stopPropagation(),this.selectTypeFilter(e.value);}),this.typeDropdownMenu.appendChild(t);}this.typeDropdownContainer.appendChild(this.typeDropdownMenu),requestAnimationFrame(()=>{this.typeDropdownOutsideHandler=e=>{this.typeDropdownMenu&&!this.typeDropdownContainer.contains(e.target)&&this.closeTypeDropdown();},document.addEventListener("click",this.typeDropdownOutsideHandler,true);}),this.typeDropdownMenu.addEventListener("keydown",e=>{e.key==="Escape"&&(this.closeTypeDropdown(),this.typeDropdownBtn.focus());});}closeTypeDropdown(){this.typeDropdownMenu&&(this.typeDropdownMenu.remove(),this.typeDropdownMenu=null),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.typeDropdownOutsideHandler&&(document.removeEventListener("click",this.typeDropdownOutsideHandler,true),this.typeDropdownOutsideHandler=null);}selectTypeFilter(e){this.activeFilters.clear(),this.activeFilters.add(e),this.renderTypeDropdownTrigger(),this.closeTypeDropdown(),this.loadFeedbacks().catch(()=>{});}buildStatusSegmented(){return this.statusSegmented=new M({options:[{value:"all",label:this.t("panel.statusAll"),icon:chunkGKRKCSID_cjs.p,color:this.colors.accent,bg:this.colors.accentLight},{value:"open",label:this.t("panel.statusOpen"),icon:chunkGKRKCSID_cjs.q,color:this.colors.statusOpen,bg:this.colors.statusOpenBg},{value:"resolved",label:this.t("panel.statusResolved"),icon:chunkGKRKCSID_cjs.k,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 M({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");}getFocusedFeedback(){let e=chunkGKRKCSID_cjs.ba(this.listContainer);if(e<0)return;let t=this.listContainer.querySelectorAll(".sp-card")[e];if(t)return this.feedbacks.find(s=>s.id===t.dataset.feedbackId)}scrollToFeedback(e){let t=CSS.escape(e),s=this.listContainer.querySelector(`[data-feedback-id="${t}"]`);s&&(s.scrollIntoView({behavior:"smooth",block:"center"}),s.classList.add("sp-anim-flash"),s.addEventListener("animationend",()=>{s.classList.remove("sp-anim-flash");},{once:true}));}async refresh(){this.isOpen&&await this.loadFeedbacks();}get isCurrentlyOpen(){return this.isOpen}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.closeTypeDropdown(),this.sortControls.destroy(),this.bulk.destroy(),this.exportBtn.destroy(),this.shortcuts.destroy(),this.detail.destroy(),this.root.remove();}};exports.Panel=ue;//# sourceMappingURL=panel-M2QKMFYO.cjs.map
2
- //# sourceMappingURL=panel-M2QKMFYO.cjs.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkNVNA5AI2_cjs=require('./chunk-NVNA5AI2.cjs');var M=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=chunkNVNA5AI2_cjs.b("div",{class:`sp-segmented${e.extraClass?` ${e.extraClass}`:""}`,role:"radiogroup"}),this.element.setAttribute("aria-label",e.ariaLabel);for(let t of this.opts){let s=document.createElement("button");s.type="button",s.className=e.modifierPrefix!==void 0?`sp-segmented__btn ${e.modifierPrefix}${t.value}`:"sp-segmented__btn",s.dataset[this.datasetKey]=t.value,s.setAttribute("role","radio");let n=this.current===t.value;if(s.setAttribute("aria-checked",String(n)),s.tabIndex=n?0:-1,n&&s.classList.add("sp-segmented__btn--active"),t.color&&s.style.setProperty("--sp-chip-color",t.color),t.bg&&s.style.setProperty("--sp-chip-bg",t.bg),t.icon){let a=chunkNVNA5AI2_cjs.b("span",{class:"sp-segmented__icon"});a.appendChild(chunkNVNA5AI2_cjs.a(t.icon)),s.appendChild(a);}let o=chunkNVNA5AI2_cjs.b("span",{class:"sp-segmented__label"});chunkNVNA5AI2_cjs.c(o,t.label),s.appendChild(o),s.addEventListener("click",()=>this.select(t.value)),s.addEventListener("keydown",a=>this.handleKey(a,t.value)),this.element.appendChild(s);}}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 s=t.dataset[this.datasetKey]===this.current;t.classList.toggle("sp-segmented__btn--active",s),t.setAttribute("aria-checked",String(s)),t.tabIndex=s?0:-1;}}setOptionVisible(e,t){let s=this.element.querySelector(`[data-${this.kebabKey()}="${e}"]`);return s?(s.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 s=this.opts.map(d=>d.value).filter(d=>{let c=this.element.querySelector(`[data-${this.kebabKey()}="${d}"]`);return c!==null&&c.style.display!=="none"}),n=s.indexOf(t);if(n<0)return;let o;switch(e.key){case "ArrowLeft":o=(n-1+s.length)%s.length;break;case "ArrowRight":o=(n+1)%s.length;break;case "Home":o=0;break;case "End":o=s.length-1;break;default:return}e.preventDefault();let a=s[o];a!==void 0&&(this.select(a),this.focusOption(a));}kebabKey(){return this.datasetKey.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}};var me=chunkNVNA5AI2_cjs.D.filter(O=>!chunkNVNA5AI2_cjs.F(O)),ue=class{constructor(e,t,s,n,o,a,d,c,b){this.colors=t;this.bus=s;this.client=n;this.projectName=o;this.markers=a;this.t=d;this.locale=c;this.shadowRoot=e,this.getScope=b?.getScope??(()=>({url:window.location.pathname,urlPattern:null})),this.scopeAnnotationsByUrl=b?.scopeAnnotationsByUrl??true,this.root=chunkNVNA5AI2_cjs.b("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 m=chunkNVNA5AI2_cjs.b("div",{class:"sp-panel-header"}),p=chunkNVNA5AI2_cjs.b("span",{class:"sp-panel-title"});chunkNVNA5AI2_cjs.c(p,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(chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.i)),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(chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.t));let y=document.createElement("span");chunkNVNA5AI2_cjs.c(y,` ${this.t("panel.deleteAll")}`),this.deleteAllBtn.appendChild(y),this.deleteAllBtn.addEventListener("click",()=>this.confirmDeleteAll()),this.exportBtn=new chunkNVNA5AI2_cjs.S(t,()=>this.feedbacks,this.t);let C=chunkNVNA5AI2_cjs.b("div",{class:"sp-panel-header-right"});C.appendChild(this.exportBtn.element),C.appendChild(this.deleteAllBtn),C.appendChild(this.closeBtn),m.appendChild(p),m.appendChild(C),this.stats=new chunkNVNA5AI2_cjs.ba(t,this.t);let k=chunkNVNA5AI2_cjs.b("div",{class:"sp-filters"}),T=chunkNVNA5AI2_cjs.b("div",{class:"sp-search-wrap"}),f=chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.j);f.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);}),T.appendChild(f),T.appendChild(this.searchInput);let L=chunkNVNA5AI2_cjs.b("div",{class:"sp-filter-bar"});L.appendChild(this.buildTypeDropdown()),L.appendChild(this.buildStatusSegmented()),L.appendChild(this.buildScopeSegmented()),this.sortControls=new chunkNVNA5AI2_cjs._(t,()=>this.renderList(),this.t),k.appendChild(T),k.appendChild(L),k.appendChild(this.sortControls.element),this.listContainer=chunkNVNA5AI2_cjs.b("div",{class:"sp-list"}),this.listContainer.setAttribute("role","list"),this.listContainer.setAttribute("aria-label",this.t("panel.feedbackList")),this.bulk=new chunkNVNA5AI2_cjs.U(t,{onResolve:i=>this.bulkResolve(i),onDelete:i=>this.bulkDelete(i)},this.t),this.bulk.setListContainer(this.listContainer),this.detail=new chunkNVNA5AI2_cjs.W(t,{onBack:()=>this.detail.hide(),onResolve:async i=>{try{let r=!chunkNVNA5AI2_cjs.F(i.status);await this.client.resolveFeedback(i.id,r),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onDelete:async i=>{try{await this.client.deleteFeedback(i.id),this.bus.emit("feedback:deleted",i.id),await this.loadFeedbacks(),this.detail.hide();}catch(r){throw this.bus.emit("feedback:error",r instanceof Error?r:new Error(String(r))),r}},onGoToAnnotation:i=>{if(i.annotations.length>0){let r=i.annotations[0];if(!r)return;window.scrollTo({left:r.scrollX,top:r.scrollY,behavior:"smooth"}),this.markers.pinHighlight(i);}}},this.t,c),this.shortcuts=new chunkNVNA5AI2_cjs.fa(t,{onNavigate:i=>{let r=chunkNVNA5AI2_cjs.ca(this.listContainer);chunkNVNA5AI2_cjs.da(this.listContainer,i==="down"?r+1:r-1);},onResolve:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="resolve"]');u&&this.toggleResolve(i,u).catch(()=>{});}},onDelete:()=>{let i=this.getFocusedFeedback();if(i&&!this.pendingMutations.has(i.id)){let u=this.listContainer.querySelector(`[data-feedback-id="${CSS.escape(i.id)}"]`)?.querySelector('[data-action="delete"]');u&&this.deleteFeedback(i,u).catch(()=>{});}},onFocusSearch:()=>this.searchInput.focus(),onToggleSelect:()=>{let i=this.getFocusedFeedback();i&&this.bulk.toggle(i.id);}},this.t),this.root.appendChild(m),this.root.appendChild(this.stats.element),this.root.appendChild(k),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.root),this.onListClick=i=>{let r=i.target;if(r.closest(".sp-bulk-checkbox"))return;let u=r.closest("[data-action]");if(u){i.stopPropagation();let A=u.closest(".sp-card");if(!A)return;let w=A.dataset.feedbackId,g=this.feedbacks.find(E=>E.id===w);if(!g)return;let B=u.dataset.action;if(B==="expand"){let E=A.querySelector(".sp-card-message");if(!E)return;let R=E.classList.toggle("sp-card-message--expanded");chunkNVNA5AI2_cjs.c(u,R?this.t("panel.showLess"):this.t("panel.showMore")),u.setAttribute("aria-expanded",String(R));}else if(B==="resolve"){if(this.pendingMutations.has(g.id))return;let E=u;this.toggleResolve(g,E).catch(()=>{});}else if(B==="delete"){if(this.pendingMutations.has(g.id))return;let E=u;this.deleteFeedback(g,E).catch(()=>{});}return}let v=r.closest(".sp-card");if(v){let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}}},this.listContainer.addEventListener("click",this.onListClick),this.onListKeydown=i=>{let r=i;if(r.key!=="Enter"&&r.key!==" ")return;let u=r.target,v=u.closest(".sp-card");if(!v||u!==v)return;r.preventDefault();let A=v.dataset.feedbackId,w=this.feedbacks.find(g=>g.id===A);if(w){let g=this.feedbacks.indexOf(w)+1;this.detail.show(w,g);}},this.listContainer.addEventListener("keydown",this.onListKeydown),this.onListMouseover=i=>{let u=i.target.closest(".sp-card");if(!u)return;let v=u.dataset.feedbackId;v&&this.markers.highlight(v);},this.listContainer.addEventListener("mouseover",this.onListMouseover),this.onListMouseout=i=>{let r=i.relatedTarget;r&&this.listContainer.contains(r)||this.markers.highlight("");},this.listContainer.addEventListener("mouseout",this.onListMouseout),this.bus.on("panel:toggle",i=>{i?this.open():this.close();}),e.addEventListener("keydown",i=>{let r=i;if(r.key==="Escape"&&this.isOpen){if(this.detail.isVisible){this.detail.hide();return}this.close();return}if(r.key==="Tab"&&this.isOpen){let u=B=>{let E=B;for(;E&&E!==this.root;){if(E.style.display==="none")return false;E=E.parentElement;}return true},v=Array.from(this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(B=>u(B)&&!B.hasAttribute("disabled"));if(v.length===0)return;let A=v[0],w=v[v.length-1];if(!A||!w)return;let g=e.activeElement;r.shiftKey&&g===A?(r.preventDefault(),w.focus()):!r.shiftKey&&g===w&&(r.preventDefault(),A.focus());}}),this.onMarkerClick=(i=>{this.scrollToFeedback(i.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"]);typeDropdownBtn;typeDropdownContainer;typeDropdownMenu=null;typeDropdownOutsideHandler=null;statusSegmented;typeOptions;feedbacks=[];currentPage=1;totalFeedbacks=0;isLoadingMore=false;isOpen=false;searchTimeout=null;loadController=null;pendingMutations=new Set;stats;sortControls;bulk;exportBtn;shortcuts;detail;shadowRoot;getScope;scopeAnnotationsByUrl;scopeSegmented;initialScopeFilter="this";onMarkerClick;onListClick;onListKeydown;onListMouseover;onListMouseout;async open(){this.isOpen||(this.isOpen=true,this.root.classList.add("sp-panel--open"),this.root.setAttribute("aria-hidden","false"),this.bus.emit("open"),this.shortcuts.enable(this.shadowRoot),await this.loadFeedbacks(),requestAnimationFrame(()=>{this.searchInput?this.searchInput.focus():this.closeBtn.focus();}));}close(){if(!this.isOpen)return;this.isOpen=false,this.root.classList.remove("sp-panel--open"),this.root.setAttribute("aria-hidden","true"),this.bus.emit("close"),this.shortcuts.disable(),this.detail.hide(),this.root.getRootNode().querySelector(".sp-fab")?.focus();}showLoading(){this.listContainer.replaceChildren();let e=chunkNVNA5AI2_cjs.b("div",{class:"sp-loading"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label",this.t("panel.loading"));let t=chunkNVNA5AI2_cjs.b("div",{class:"sp-spinner"});e.appendChild(t),this.listContainer.appendChild(e);}showError(){this.listContainer.replaceChildren();let e=chunkNVNA5AI2_cjs.b("div",{class:"sp-empty"});e.setAttribute("role","status"),e.setAttribute("aria-live","polite");let t=chunkNVNA5AI2_cjs.b("div",{class:"sp-empty-text"});chunkNVNA5AI2_cjs.c(t,this.t("panel.loadError"));let s=document.createElement("button");s.className="sp-btn-ghost",s.style.marginTop="8px",chunkNVNA5AI2_cjs.c(s,this.t("panel.retry")),s.addEventListener("click",()=>this.loadFeedbacks().catch(()=>{})),e.appendChild(t),e.appendChild(s),this.listContainer.appendChild(e);}statusBucket(e){if(e!=="all")return chunkNVNA5AI2_cjs.F(e)?chunkNVNA5AI2_cjs.E:me}async loadFeedbacks(){this.loadController?.abort(),this.loadController=new AbortController;let{signal:e}=this.loadController;this.currentPage=1;let t=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 a=this.scopeSegmented.value,d={page:1,limit:20};s&&(d.type=s),n&&(d.statuses=n),t&&(d.search=t),a==="this"?d.url=o.url:a==="template"&&o.urlPattern&&(d.urlPattern=o.urlPattern);let c=this.feedbacks.length>0;c||this.showLoading();try{let{feedbacks:b,total:m}=await this.client.getFeedbacks(this.projectName,d);if(e.aborted)return;this.feedbacks=b,this.totalFeedbacks=m,this.stats.update(b,m),this.bulk.reset(),this.renderList();let p=this.scopeAnnotationsByUrl?b.filter(y=>y.url===o.url):b;this.markers.render(p);}catch(b){if(e.aborted)return;c||this.showError(),this.bus.emit("feedback:error",b instanceof Error?b:new Error(String(b)));}}async loadMoreFeedbacks(){if(this.isLoadingMore)return;this.isLoadingMore=true;let e=this.loadController,t=this.currentPage+1,s=this.searchInput.value.trim()||void 0,n=this.activeFilters.has("all")?void 0:Array.from(this.activeFilters)[0],o=this.statusBucket(this.statusSegmented.value),a=this.getScope(),d=this.scopeSegmented.value,c={page:t,limit:20};n&&(c.type=n),o&&(c.statuses=o),s&&(c.search=s),d==="this"?c.url=a.url:d==="template"&&a.urlPattern&&(c.urlPattern=a.urlPattern);let b=this.listContainer.querySelector(".sp-btn-load-more"),m;b&&(m=chunkNVNA5AI2_cjs.d(b));try{let{feedbacks:p,total:y}=await this.client.getFeedbacks(this.projectName,c);if(e!==this.loadController)return;this.currentPage=t,this.totalFeedbacks=y,this.feedbacks=[...this.feedbacks,...p],this.stats.update(this.feedbacks,y),this.renderList();let C=this.scopeAnnotationsByUrl?this.feedbacks.filter(k=>k.url===a.url):this.feedbacks;this.markers.render(C);}catch(p){m&&m(),this.bus.emit("feedback:error",p instanceof Error?p:new Error(String(p)));}finally{this.isLoadingMore=false;}}renderList(){if(this.listContainer.replaceChildren(),this.feedbacks.length===0){let o=chunkNVNA5AI2_cjs.b("div",{class:"sp-empty"});o.setAttribute("role","status"),o.setAttribute("aria-live","polite");let a=chunkNVNA5AI2_cjs.b("div",{class:"sp-empty-text"});chunkNVNA5AI2_cjs.c(a,this.t("panel.empty")),o.appendChild(a),this.listContainer.appendChild(o);return}let e=chunkNVNA5AI2_cjs.X(this.feedbacks,this.sortControls.sortMode),t=e.map(o=>o.id),s=this.bulk.createSelectAllBar(t,this.t("bulk.selectAll"));if(this.listContainer.appendChild(s),this.sortControls.groupByPage){let o=chunkNVNA5AI2_cjs.Y(e),a=0;for(let[d,c]of o){let b=chunkNVNA5AI2_cjs.Z(d,c.length,this.colors);this.listContainer.appendChild(b);let m=chunkNVNA5AI2_cjs.b("div",{class:"sp-group-content"});for(let p of c){let y=this.createCard(p,a+1);y.style.setProperty("--sp-card-i",String(a)),m.appendChild(y),a++;}this.listContainer.appendChild(m);}}else e.forEach((o,a)=>{let d=this.createCard(o,a+1);d.style.setProperty("--sp-card-i",String(a)),this.listContainer.appendChild(d);});let n=this.totalFeedbacks-this.feedbacks.length;if(n>0){let o=chunkNVNA5AI2_cjs.b("div",{class:"sp-load-more-wrap"}),a=document.createElement("button");a.className="sp-btn-ghost sp-btn-load-more",chunkNVNA5AI2_cjs.c(a,chunkNVNA5AI2_cjs.O(this.t,"panel.loadMore",{remaining:n})),a.addEventListener("click",()=>this.loadMoreFeedbacks().catch(()=>{})),o.appendChild(a),this.listContainer.appendChild(o);}}createCard(e,t){let s=chunkNVNA5AI2_cjs.F(e.status),n=chunkNVNA5AI2_cjs.x(e.type,this.colors),o=chunkNVNA5AI2_cjs.b("div",{class:`sp-card ${s?"sp-card--resolved":""}`});o.setAttribute("role","listitem"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Feedback #${t}: ${chunkNVNA5AI2_cjs.P(e.type,this.t)} \u2014 ${e.message.slice(0,80)}`),o.dataset.feedbackId=e.id;let a=chunkNVNA5AI2_cjs.b("div",{class:"sp-card-bar"});a.style.background=s?"#9ca3af":n;let d=chunkNVNA5AI2_cjs.b("div",{class:"sp-card-body"}),c=chunkNVNA5AI2_cjs.b("div",{class:"sp-card-header"}),b=this.bulk.createCheckbox(e.id);c.appendChild(b);let m=chunkNVNA5AI2_cjs.b("span",{class:"sp-card-number"});chunkNVNA5AI2_cjs.c(m,`#${t}`);let p=chunkNVNA5AI2_cjs.b("span",{class:"sp-badge"}),y=chunkNVNA5AI2_cjs.A(e.type,this.colors);p.style.background=y,p.style.color=n,chunkNVNA5AI2_cjs.c(p,chunkNVNA5AI2_cjs.P(e.type,this.t));let C=chunkNVNA5AI2_cjs.b("span",{class:"sp-badge sp-badge--status"});C.dataset.status=e.status,C.style.background=chunkNVNA5AI2_cjs.z(e.status,this.colors),C.style.color=chunkNVNA5AI2_cjs.y(e.status,this.colors),chunkNVNA5AI2_cjs.c(C,chunkNVNA5AI2_cjs.Q(e.status,this.t));let k=chunkNVNA5AI2_cjs.b("span",{class:"sp-card-date"});chunkNVNA5AI2_cjs.c(k,chunkNVNA5AI2_cjs.e(e.createdAt,this.locale)),c.appendChild(m),c.appendChild(p),c.appendChild(C),c.appendChild(k);let T=chunkNVNA5AI2_cjs.b("div",{class:"sp-card-message"});chunkNVNA5AI2_cjs.c(T,e.message);let f=document.createElement("button");f.className="sp-card-expand",f.dataset.action="expand",chunkNVNA5AI2_cjs.c(f,this.t("panel.showMore")),f.style.display="none",f.setAttribute("aria-expanded","false"),requestAnimationFrame(()=>{T.scrollHeight>T.clientHeight&&(f.style.display="block");});let L=chunkNVNA5AI2_cjs.b("div",{class:"sp-card-footer"}),i=document.createElement("button");if(i.className="sp-btn-resolve",i.dataset.action="resolve",s){i.appendChild(chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.s));let v=document.createElement("span");chunkNVNA5AI2_cjs.c(v,` ${this.t("panel.reopen")}`),i.appendChild(v);}else {i.appendChild(chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.k));let v=document.createElement("span");chunkNVNA5AI2_cjs.c(v,` ${this.t("panel.resolve")}`),i.appendChild(v);}let r=document.createElement("button");r.className="sp-btn-delete",r.dataset.action="delete",r.appendChild(chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.t));let u=document.createElement("span");return chunkNVNA5AI2_cjs.c(u,` ${this.t("panel.delete")}`),r.appendChild(u),L.appendChild(i),L.appendChild(r),d.appendChild(c),d.appendChild(T),d.appendChild(f),d.appendChild(L),o.appendChild(a),o.appendChild(d),o}async bulkResolve(e){try{await Promise.all(e.map(t=>this.client.resolveFeedback(t,!0))),await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}async bulkDelete(e){try{await Promise.all(e.map(t=>this.client.deleteFeedback(t)));for(let t of e)this.bus.emit("feedback:deleted",t);await this.loadFeedbacks();}catch(t){throw this.bus.emit("feedback:error",t instanceof Error?t:new Error(String(t))),t}}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(s=>{let n=chunkNVNA5AI2_cjs.b("div",{class:"sp-confirm-backdrop"}),o=`sp-confirm-title-${Date.now()}`,a=`sp-confirm-msg-${Date.now()}`,d=chunkNVNA5AI2_cjs.b("div",{class:"sp-confirm-dialog"});d.setAttribute("role","alertdialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby",o),d.setAttribute("aria-describedby",a);let c=chunkNVNA5AI2_cjs.b("div",{class:"sp-confirm-title"});c.id=o,chunkNVNA5AI2_cjs.c(c,e);let b=chunkNVNA5AI2_cjs.b("div",{class:"sp-confirm-message"});b.id=a,chunkNVNA5AI2_cjs.c(b,t);let m=chunkNVNA5AI2_cjs.b("div",{class:"sp-confirm-actions"}),p=document.createElement("button");p.type="button",p.className="sp-btn-ghost",chunkNVNA5AI2_cjs.c(p,this.t("panel.cancel"));let y=document.createElement("button");y.type="button",y.className="sp-btn-danger",chunkNVNA5AI2_cjs.c(y,this.t("panel.confirmDelete"));let C=false,k=f=>{C||(C=true,n.removeEventListener("keydown",T),n.style.opacity="0",d.style.transform="translateY(8px) scale(0.97)",setTimeout(()=>{n.remove(),s(f);},200));},T=f=>{let L=f;if(L.key==="Escape"){k(false);return}L.key==="Tab"&&(L.preventDefault(),n.getRootNode().activeElement===p?y.focus():p.focus());};n.addEventListener("keydown",T),p.addEventListener("click",()=>k(false)),y.addEventListener("click",()=>k(true)),n.addEventListener("click",f=>{f.target===n&&k(false);}),m.appendChild(p),m.appendChild(y),d.appendChild(c),d.appendChild(b),d.appendChild(m),n.appendChild(d),this.root.getRootNode()instanceof ShadowRoot?this.root.getRootNode().appendChild(n):this.root.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1",d.style.transform="translateY(0) scale(1)",p.focus();});})}async deleteFeedback(e,t){this.pendingMutations.add(e.id);let s=chunkNVNA5AI2_cjs.d(t);try{await this.client.deleteFeedback(e.id),this.bus.emit("feedback:deleted",e.id),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}async toggleResolve(e,t){this.pendingMutations.add(e.id);let s=chunkNVNA5AI2_cjs.d(t);try{let n=!chunkNVNA5AI2_cjs.F(e.status);await this.client.resolveFeedback(e.id,n),await this.loadFeedbacks();}catch(n){s(),this.bus.emit("feedback:error",n instanceof Error?n:new Error(String(n)));}finally{this.pendingMutations.delete(e.id);}}buildTypeDropdown(){return this.typeOptions=[{value:"all",label:this.t("panel.filterAll"),icon:chunkNVNA5AI2_cjs.p,color:this.colors.accent,bg:this.colors.accentLight},{value:"question",label:this.t("type.question"),icon:chunkNVNA5AI2_cjs.l,color:this.colors.typeQuestion,bg:this.colors.typeQuestionBg},{value:"change",label:this.t("type.change"),icon:chunkNVNA5AI2_cjs.m,color:this.colors.typeChange,bg:this.colors.typeChangeBg},{value:"bug",label:this.t("type.bug"),icon:chunkNVNA5AI2_cjs.n,color:this.colors.typeBug,bg:this.colors.typeBugBg},{value:"other",label:this.t("type.other"),icon:chunkNVNA5AI2_cjs.o,color:this.colors.typeOther,bg:this.colors.typeOtherBg}],this.typeDropdownContainer=chunkNVNA5AI2_cjs.b("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.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=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-btn__icon"});t.appendChild(chunkNVNA5AI2_cjs.a(e.icon)),this.typeDropdownBtn.appendChild(t);let s=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-btn__label"}),n=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-btn__prefix"});chunkNVNA5AI2_cjs.c(n,this.t("type.label"));let o=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-btn__value"});chunkNVNA5AI2_cjs.c(o,e.label),s.appendChild(n),s.appendChild(o),this.typeDropdownBtn.appendChild(s);let a=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-btn__chevron"});a.appendChild(chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.r)),this.typeDropdownBtn.appendChild(a);}openTypeDropdown(){this.typeDropdownMenu=chunkNVNA5AI2_cjs.b("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 s=this.activeFilters.has(e.value);t.className=`sp-filter-dropdown-option${s?" 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(s));let n=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-option__icon"});n.appendChild(chunkNVNA5AI2_cjs.a(e.icon)),t.appendChild(n);let o=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-option__label"});if(chunkNVNA5AI2_cjs.c(o,e.label),t.appendChild(o),s){let a=chunkNVNA5AI2_cjs.b("span",{class:"sp-filter-dropdown-option__check"});a.appendChild(chunkNVNA5AI2_cjs.a(chunkNVNA5AI2_cjs.k)),t.appendChild(a);}t.addEventListener("click",a=>{a.stopPropagation(),this.selectTypeFilter(e.value);}),this.typeDropdownMenu.appendChild(t);}this.typeDropdownContainer.appendChild(this.typeDropdownMenu),requestAnimationFrame(()=>{this.typeDropdownOutsideHandler=e=>{this.typeDropdownMenu&&!this.typeDropdownContainer.contains(e.target)&&this.closeTypeDropdown();},document.addEventListener("click",this.typeDropdownOutsideHandler,true);}),this.typeDropdownMenu.addEventListener("keydown",e=>{e.key==="Escape"&&(this.closeTypeDropdown(),this.typeDropdownBtn.focus());});}closeTypeDropdown(){this.typeDropdownMenu&&(this.typeDropdownMenu.remove(),this.typeDropdownMenu=null),this.typeDropdownBtn.setAttribute("aria-expanded","false"),this.typeDropdownOutsideHandler&&(document.removeEventListener("click",this.typeDropdownOutsideHandler,true),this.typeDropdownOutsideHandler=null);}selectTypeFilter(e){this.activeFilters.clear(),this.activeFilters.add(e),this.renderTypeDropdownTrigger(),this.closeTypeDropdown(),this.loadFeedbacks().catch(()=>{});}buildStatusSegmented(){return this.statusSegmented=new M({options:[{value:"all",label:this.t("panel.statusAll"),icon:chunkNVNA5AI2_cjs.p,color:this.colors.accent,bg:this.colors.accentLight},{value:"open",label:this.t("panel.statusOpen"),icon:chunkNVNA5AI2_cjs.q,color:this.colors.statusOpen,bg:this.colors.statusOpenBg},{value:"resolved",label:this.t("panel.statusResolved"),icon:chunkNVNA5AI2_cjs.k,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 M({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");}getFocusedFeedback(){let e=chunkNVNA5AI2_cjs.ca(this.listContainer);if(e<0)return;let t=this.listContainer.querySelectorAll(".sp-card")[e];if(t)return this.feedbacks.find(s=>s.id===t.dataset.feedbackId)}scrollToFeedback(e){let t=CSS.escape(e),s=this.listContainer.querySelector(`[data-feedback-id="${t}"]`);s&&(s.scrollIntoView({behavior:"smooth",block:"center"}),s.classList.add("sp-anim-flash"),s.addEventListener("animationend",()=>{s.classList.remove("sp-anim-flash");},{once:true}));}async refresh(){this.isOpen&&await this.loadFeedbacks();}get isCurrentlyOpen(){return this.isOpen}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.closeTypeDropdown(),this.sortControls.destroy(),this.bulk.destroy(),this.exportBtn.destroy(),this.shortcuts.destroy(),this.detail.destroy(),this.root.remove();}};exports.Panel=ue;//# sourceMappingURL=panel-XUTDVTAR.cjs.map
2
- //# sourceMappingURL=panel-XUTDVTAR.cjs.map