|
1
|
|
-var Pe=r=>{throw TypeError(r)};var xe=(r,e,t)=>e.has(r)||Pe("Cannot "+t);var i=(r,e,t)=>(xe(r,e,"read from private field"),t?t.call(r):e.get(r)),u=(r,e,t)=>e.has(r)?Pe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),l=(r,e,t,s)=>(xe(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t),A=(r,e,t)=>(xe(r,e,"access private method"),t);import{L as Le}from"./chunks/lightbox.js?ver=1.7.0";const be=()=>window.fluentcart_review_vars&&window.fluentcart_review_vars.trans||{};function Ie(r,e,t){const s=t.get(r);if(s&&(s.abort(),t.delete(r)),!e||!e.autoplay)return null;const a=new AbortController,o={signal:a.signal};return r.addEventListener("mouseenter",()=>e.autoplay.start(),o),r.addEventListener("mouseleave",()=>e.autoplay.stop(),o),t.set(r,a),a}const Ne=new WeakMap;function Oe(r){const e=r==="prev"?"m15 18-6-6 6-6":"m9 18 6-6-6-6",t=r==="prev"?be().prev_page||"Previous":be().next_page||"Next",s=document.createElement("button");return s.type="button",s.className=`fct-reviews-slider-nav fct-reviews-slider-${r}`,s.setAttribute("aria-label",t),s.innerHTML='<svg class="fct-nav-arrow-svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="'+e+'"/></svg>',s}const $e=260,We=12,Je=120;function Qe(r){return r&&r.querySelector(".fct-review-photo-only")?Je:$e}function Ye(r,e=$e){const t={};for(let s=2;s<=r;s++)t[e*s+We*(s-1)]={slidesPerView:s};return t}function Ze(r,e){return e!=="segmented"?{el:r,clickable:!0,type:e}:{el:r,type:"custom",renderCustom(t,s,a){let o="";for(let d=1;d<=a;d++){let g="swiper-pagination-segment";d<s?g+=" is-completed":d===s&&(g+=" is-active"),o+=`<button type="button" class="${g}" data-segment-page="${d}" aria-label="${et(d,a)}"`+(d===s?' aria-current="true"':"")+"></button>"}return o+`<span class="segment-counter">${s} / ${a}</span>`}}}function et(r,e){return(be().slider_page_of||"Page %1$s of %2$s").replace("%1$s",r).replace("%2$s",e)}function tt(r,e){r.addEventListener("click",t=>{var S,c;const s=t.target.closest("[data-segment-page]");if(!s)return;const a=parseInt(s.getAttribute("data-segment-page"),10);if(!a)return;const o=(S=e.snapGrid)==null?void 0:S[a-1],d=o===void 0?-1:(c=e.slidesGrid)==null?void 0:c.indexOf(o),g=d>=0?d:a-1;if(typeof e.slideToLoop=="function"&&e.params.loop){e.slideToLoop(g);return}e.slideTo(g)})}function it(r){const e=r.nextElementSibling;e&&e.classList.contains("fct-reviews-slider-pagination-wrap")&&e.remove()}function st(r,e,t,s,a){const o=rt(r);if(o.className="fct-reviews-slider-frame is-arrows-"+s+" fct-arrows-"+a,s==="bottom"){const d=document.createElement("div");d.className="fct-reviews-slider-nav-row",d.appendChild(e),d.appendChild(t),o.appendChild(d);return}o.appendChild(e),o.appendChild(t)}function Re(r){const e=r.parentElement;!e||!e.classList.contains("fct-reviews-slider-frame")||e.replaceWith(r)}function rt(r){const e=r.parentElement;if(e&&e.classList.contains("fct-reviews-slider-frame"))return[...e.querySelectorAll(".fct-reviews-slider-nav, .fct-reviews-slider-nav-row")].forEach(s=>s.remove()),e;const t=document.createElement("div");return r.replaceWith(t),t.appendChild(r),t}function Be(r,e=null){const t=parseInt(r.getAttribute("data-reviews-slider"),10);if(Ie(r,null,Ne),it(r),!t||typeof window.Swiper!="function")return Re(r),null;e&&(e.destroy(!0,!0),r.classList.remove("swiper","fct-arrows-sm","fct-arrows-md","fct-arrows-lg"));let s={};try{s=JSON.parse(r.getAttribute("data-slider-settings")||"{}")}catch{}const a=s.arrows!=="no",o=["overlap","outside","bottom"].includes(s.arrowsPosition)?s.arrowsPosition:"overlap",d=s.pagination==="yes",g=["bullets","fraction","progressbar","segmented"].includes(s.paginationType)?s.paginationType:"bullets",S=s.autoplay||"no",c=!!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),h=Array.from(r.children).filter(p=>p.classList.contains("fct-review-item"));if(!h.length)return Re(r),null;const w=document.createElement("div");w.className="swiper-wrapper",h.forEach(p=>{const y=document.createElement("div");y.className="swiper-slide",y.appendChild(p),w.appendChild(y)}),r.innerHTML="",r.appendChild(w),r.classList.add("swiper",`fct-arrows-${s.arrowsSize||"md"}`);let m=null,E=null;a&&(m=Oe("prev"),E=Oe("next"),st(r,m,E,o,s.arrowsSize||"md"));let n=null;if(d){const p=document.createElement("div");p.className="fct-carousel-pagination fct-pagination-"+g+" fct-reviews-slider-pagination-wrap",n=document.createElement("div"),n.className="swiper-pagination fct-reviews-slider-pagination",p.appendChild(n),r.insertAdjacentElement("afterend",p)}const v=new window.Swiper(r,{slidesPerView:1,spaceBetween:We,autoHeight:!1,slidesPerGroupAuto:!0,observer:!0,observeParents:!0,loop:s.infinite==="yes",autoplay:["yes","hover"].includes(S)?{delay:Number(s.autoplayDelay)||3e3,pauseOnMouseEnter:!0,disableOnInteraction:!1,stopOnLastSlide:s.infinite!=="yes"}:!1,watchOverflow:!1,a11y:{enabled:!0},keyboard:{enabled:!0},navigation:a?{prevEl:m,nextEl:E}:!1,pagination:n?Ze(n,g):!1,on:{init(p){(S==="hover"||c)&&p.autoplay&&p.autoplay.stop()}},breakpointsBase:"container",breakpoints:Ye(t,Qe(r))});return n&&g==="segmented"&&tt(n,v),S==="hover"&&Ie(r,v,Ne),v}function at(r,e){return r-e>1}function nt(r,e){const t=parseInt(e,10);if(!t||t<1)return null;const s=String(r).trim().split(/\s+/);return s.length<=t?null:s.slice(0,t).join(" ")+"…"}function He(r,e={}){const t=!!r;return{expanded:t,label:t?e.show_less||"Show less":e.read_more||"Read more"}}function ot({expanded:r=!1,truncated:e=!1,hasToggle:t=!1}={}){return r?"leave":e?t?"none":"add":t?"remove":"none"}function lt(r,e={},t=null){r.querySelectorAll(".fct-review-item-content, .wp-block-fluent-cart-review-item-content").forEach(a=>{const o=a.nextElementSibling,d=o&&o.classList.contains("fct-review-readmore")?o:null,g=!!d&&d.getAttribute("aria-expanded")==="true",S=parseInt(a.getAttribute("data-max-words"),10)||0;if(S){a.dataset.fullText===void 0&&(a.dataset.fullText=a.textContent);const m=nt(a.dataset.fullText,S);if(m===null){a.textContent=a.dataset.fullText,a.classList.remove("is-clamped"),d&&d.remove();return}a.classList.remove("is-clamped");const E=p=>{const y=He(p,e);return a.textContent=y.expanded?a.dataset.fullText:m,y};if(d){E(g);return}const n=document.createElement("button");n.type="button",n.className="fct-review-readmore";const v=p=>{const y=E(p);n.setAttribute("aria-expanded",y.expanded?"true":"false"),n.textContent=y.label};v(!1),n.addEventListener("click",()=>{v(n.getAttribute("aria-expanded")!=="true"),typeof t=="function"&&t()}),a.insertAdjacentElement("afterend",n);return}if(!r.matches(".fct-reviews-list--grid, .fct-reviews-list--slider"))return;g||a.classList.add("is-clamped");const c=ot({expanded:g,truncated:at(a.scrollHeight,a.clientHeight),hasToggle:!!d});if(c==="leave"||c==="none")return;if(c==="remove"){d.remove();return}const h=document.createElement("button");h.type="button",h.className="fct-review-readmore";const w=m=>{const E=He(m,e);a.classList.toggle("is-clamped",!E.expanded),h.setAttribute("aria-expanded",E.expanded?"true":"false"),h.textContent=E.label};w(!1),h.addEventListener("click",()=>{w(h.getAttribute("aria-expanded")!=="true"),typeof t=="function"&&t()}),a.insertAdjacentElement("afterend",h)})}const _e=()=>window.fluentcart_review_vars&&window.fluentcart_review_vars.trans||{},De=(()=>{let r=null,e=!1,t=null,s=[],a="";const o=()=>r?document.getElementById(r.classList.lightbox):null,d=n=>[n.classList.lightbox,n.classList.lightboxOverlay].map(v=>document.getElementById(v)).filter(Boolean),g=n=>{d(n).forEach(v=>{v.removeAttribute("id"),v.removeAttribute("tabindex"),s.push(v)}),Le.isBuiltOnce=!1},S=()=>{s.forEach(n=>n.remove()),s=[]},c=n=>{n.disableKeyboardNav(),window.removeEventListener("resize",n.boundSizeOverlay),n.onImageLoaded=()=>{},n.sizeContainer=()=>{},n.showImage=()=>{},n.enableKeyboardNav=()=>{},n.sizeOverlay=()=>{}},h=()=>{const n=o();return n?[...n.querySelectorAll('a[role="button"], button, [tabindex="0"]')].filter(v=>v.offsetParent!==null):[]},w=n=>{if(!e||!r)return;if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),r.end();return}if(n.key!=="Tab")return;n.stopPropagation();const v=o(),p=h();if(!v)return;if(!p.length){n.preventDefault(),v.focus();return}const y=p[0],T=p[p.length-1],Te=!v.contains(document.activeElement)||document.activeElement===v;n.shiftKey&&(Te||document.activeElement===y)?(n.preventDefault(),T.focus()):!n.shiftKey&&(Te||document.activeElement===T)&&(n.preventDefault(),y.focus())},m=n=>{const v=document.getElementById(n.classList.lightbox);if(!v)return;v.setAttribute("role","dialog"),v.setAttribute("aria-modal","true"),v.setAttribute("aria-label",_e().photo_preview||"Photo preview");const p=v.querySelector("."+n.classList.lbClose);p&&p.setAttribute("aria-label",_e().close||"Close"),v.focus();const y=document.getElementById(n.classList.lightboxOverlay);y&&y.addEventListener("focus",()=>v.focus())},E=n=>{if(n!==r||!e){n.disableKeyboardNav();return}e=!1,r=null,document.removeEventListener("keydown",w,!0),n.endLightbox(),document.body.style.overflow=a,g(n),c(n),clearTimeout(t),t=setTimeout(S,n.options.fadeDuration),n.opener&&n.opener.focus()};return{isShowing(){return e},open(n,v,p){if(clearTimeout(t),e&&r){const T=r;e=!1,r=null,document.removeEventListener("keydown",w,!0),g(T),c(T)}else a=document.body.style.overflow;S(),[...document.querySelectorAll(".fct-lightbox, .fct-lightboxOverlay")].forEach(T=>T.remove()),Le.isBuiltOnce=!1;const y=new Le({wrapAround:!0},[]);y.endLightbox=y.end.bind(y),y.end=()=>E(y),y.opener=n,r=y,e=!0,document.addEventListener("keydown",w,!0),y.setAlbum(v),y.start(p,()=>m(y))}}})();var b,k,Ae,M,P,z,Ee,B,H,I,K,N,D,$,G,U,X,J,Q,Y,Z,ee,te,ie,x,_,W,se,re,ae,ne,oe,le,de,ce,ue,he,fe,me,pe,we,F,q,C,L,O,V,f,R,ve,Fe,qe,ke,Ve,je,ze,Ke,Ce,Ge,Ue,Xe,ge;class Se{constructor(e){u(this,f);u(this,b);u(this,k);u(this,Ae);u(this,M);u(this,P);u(this,z);u(this,Ee,1);u(this,B,"created_at");u(this,H,"DESC");u(this,I,null);u(this,K,0);u(this,N,!1);u(this,D,!1);u(this,$,!1);u(this,G,!0);u(this,U,!0);u(this,X,!0);u(this,J,!0);u(this,Q,!0);u(this,Y,!0);u(this,Z,!0);u(this,ee,!0);u(this,te,!0);u(this,ie,!0);u(this,x,null);u(this,_,null);u(this,W,!1);u(this,se,"numbers");u(this,re,0);u(this,ae,0);u(this,ne,0);u(this,oe,0);u(this,le,!1);u(this,de,!1);u(this,ce,!1);u(this,ue,!1);u(this,he,!1);u(this,fe,!1);u(this,me,!0);u(this,pe,"");u(this,we,"overlay");u(this,F,"");u(this,q,null);u(this,C,null);u(this,L,null);u(this,O,new AbortController);u(this,V,{});var a;l(this,b,e),l(this,k,e.getAttribute("data-post-id")),l(this,Ae,e.getAttribute("data-product-name")||""),l(this,M,e.getAttribute("data-rest-url")),l(this,P,e.getAttribute("data-rest-nonce")),l(this,z,parseInt(e.getAttribute("data-per-page"))||10);const t=Number(e.getAttribute("data-min-rating"));l(this,K,Number.isInteger(t)&&t>=1&&t<=5?t:0),l(this,G,e.getAttribute("data-show-verified")!=="0"),l(this,U,e.getAttribute("data-show-date")!=="0"),l(this,X,e.getAttribute("data-show-reviewer")!=="0"),l(this,J,e.getAttribute("data-show-view-reply")!=="0"),l(this,Q,e.getAttribute("data-show-avatar")!=="0"),l(this,Y,e.getAttribute("data-show-title")!=="0"),l(this,Z,e.getAttribute("data-show-content")!=="0"),l(this,ee,e.getAttribute("data-show-photos")!=="0"),l(this,te,e.getAttribute("data-show-footer")!=="0"),l(this,ie,e.getAttribute("data-show-variation")!=="0"),l(this,se,e.getAttribute("data-pagination-type")||"numbers"),l(this,re,parseInt(e.getAttribute("data-max-words"),10)||0),l(this,ae,parseInt(e.getAttribute("data-media-visible"),10)||0),l(this,ne,parseInt(e.getAttribute("data-media-width"),10)||0),l(this,oe,parseInt(e.getAttribute("data-media-height"),10)||0),l(this,le,e.getAttribute("data-media-full-width")==="1"),l(this,de,e.getAttribute("data-media-flush")==="1"),l(this,ce,e.getAttribute("data-media-backdrop")==="1"),l(this,ue,e.getAttribute("data-photos-first")==="1"),l(this,he,e.getAttribute("data-rating-first")==="1"),l(this,fe,e.getAttribute("data-badge-last")==="1"),l(this,me,e.getAttribute("data-show-meta")!=="0"),l(this,pe,e.getAttribute("data-item-class")||""),l(this,we,e.getAttribute("data-media-more")||"overlay"),l(this,$,e.getAttribute("data-only-with-photos")==="1"),l(this,N,i(this,$)),l(this,F,((a=e.querySelector("[data-reviews-list]"))==null?void 0:a.getAttribute("data-client-id"))||"");const s=e.getAttribute("data-default-sort");if(s){const[o,d]=s.split("-");o&&l(this,B,o),d&&l(this,H,d)}}init(){if(i(this,b).hasAttribute("data-fluent-cart-review-summary")){document.addEventListener("fct-review-submitted",s=>{var a;String((a=s.detail)==null?void 0:a.postId)===String(i(this,k))&&A(this,f,ge).call(this)},{signal:i(this,O).signal});return}const e=i(this,b).querySelector("[data-reviews-list]");if(e&&e.querySelector("[data-review-id], [data-reviews-empty]")){A(this,f,qe).call(this,e);const s=i(this,b).querySelector("[data-reviews-pagination]");s&&A(this,f,Ce).call(this,s)}else A(this,f,R).call(this);if(A(this,f,Ue).call(this),A(this,f,Ge).call(this),window.location.hash==="#fct-product-reviews"){const s=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;requestAnimationFrame(()=>{i(this,b).scrollIntoView({behavior:s?"auto":"smooth",block:"start"})})}document.addEventListener("fct-review-submitted",s=>{var a;String((a=s.detail)==null?void 0:a.postId)===String(i(this,k))&&(A(this,f,R).call(this,1),A(this,f,ge).call(this))},{signal:i(this,O).signal})}destroy(){i(this,_)&&i(this,_).call(this),i(this,O).abort(),i(this,q)&&(i(this,q).abort(),l(this,q,null)),i(this,L)&&(i(this,L).abort(),l(this,L,null)),i(this,x)&&(i(this,x).destroy(!0,!0),l(this,x,null)),l(this,W,!1),l(this,V,{})}}b=new WeakMap,k=new WeakMap,Ae=new WeakMap,M=new WeakMap,P=new WeakMap,z=new WeakMap,Ee=new WeakMap,B=new WeakMap,H=new WeakMap,I=new WeakMap,K=new WeakMap,N=new WeakMap,D=new WeakMap,$=new WeakMap,G=new WeakMap,U=new WeakMap,X=new WeakMap,J=new WeakMap,Q=new WeakMap,Y=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,x=new WeakMap,_=new WeakMap,W=new WeakMap,se=new WeakMap,re=new WeakMap,ae=new WeakMap,ne=new WeakMap,oe=new WeakMap,le=new WeakMap,de=new WeakMap,ce=new WeakMap,ue=new WeakMap,he=new WeakMap,fe=new WeakMap,me=new WeakMap,pe=new WeakMap,we=new WeakMap,F=new WeakMap,q=new WeakMap,C=new WeakMap,L=new WeakMap,O=new WeakMap,V=new WeakMap,f=new WeakSet,R=function(e=1){l(this,Ee,e);const t=i(this,b).querySelector("[data-reviews-list]"),s=i(this,b).querySelector("[data-reviews-loading]");i(this,q)&&i(this,q).abort(),l(this,q,new AbortController),A(this,f,ve).call(this,t,s,!0);const a=new URLSearchParams({page:e,per_page:i(this,z),sort_by:i(this,B),sort_order:i(this,H),show_reviewer:i(this,X)?"1":"0",show_date:i(this,U)?"1":"0",show_verified:i(this,G)?"1":"0",show_view_reply:i(this,J)?"1":"0",show_avatar:i(this,Q)?"1":"0",show_title:i(this,Y)?"1":"0",show_content:i(this,Z)?"1":"0",show_photos:i(this,ee)?"1":"0",show_footer:i(this,te)?"1":"0",show_variation:i(this,ie)?"1":"0",pagination_type:i(this,se),max_words:i(this,re),media_visible:i(this,ae),media_width:i(this,ne),media_height:i(this,oe),media_full_width:i(this,le)?"1":"0",media_flush:i(this,de)?"1":"0",media_backdrop:i(this,ce)?"1":"0",photos_first:i(this,ue)?"1":"0",rating_first:i(this,he)?"1":"0",badge_last:i(this,fe)?"1":"0",show_meta:i(this,me)?"1":"0",item_class:i(this,pe),media_more:i(this,we)});i(this,F)&&a.set("client_id",i(this,F)),i(this,I)&&a.set("rating",i(this,I)),i(this,N)&&a.set("has_media","1"),i(this,D)&&a.set("verified_only","1"),fetch(`${i(this,M)}/public/reviews/${i(this,k)}${i(this,M).includes("?")?"&":"?"}${a}`,{method:"GET",headers:{"X-WP-Nonce":i(this,P)},signal:i(this,q).signal}).then(o=>{if(!o.ok)throw new Error(o.statusText);return o.json()}).then(o=>{if(A(this,f,ve).call(this,t,s,!1),o.reviews&&o.reviews.data){A(this,f,Fe).call(this,o.reviews.data,t,o.reviews_html||""),A(this,f,Ke).call(this,o.pagination_html||"");const d=i(this,b).querySelector("[data-reviews-total-count]");d&&(d.textContent=o.reviews.total.toLocaleString())}}).catch(o=>{if(o.name==="AbortError")return;A(this,f,ve).call(this,t,s,!1),t&&(t.textContent="",l(this,x,Be(t,i(this,x))));const d=i(this,b).querySelector("[data-reviews-error]");d&&(d.hidden=!1)})},ve=function(e,t,s){if(t&&(t.classList.toggle("is-visible",s),s&&e)){const a=e.getBoundingClientRect(),o=t.getBoundingClientRect();t.style.setProperty("--fct-reviews-rows-top",Math.round(a.top-o.top)+"px"),t.style.setProperty("--fct-reviews-rows-center-x",Math.round(a.left-o.left+a.width/2)+"px"),t.style.setProperty("--fct-reviews-rows-height",Math.round(a.height)+"px")}e&&(e.classList.toggle("is-loading",s),s?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"))},Fe=function(e,t,s){l(this,V,e.reduce((o,d)=>(o[d.id]=d,o),{}));const a=i(this,b).querySelector("[data-reviews-error]");a&&(a.hidden=!0),t.innerHTML=s,A(this,f,qe).call(this,t)},qe=function(e){l(this,x,Be(e,i(this,x))),A(this,f,ke).call(this,e),A(this,f,Ve).call(this),e.querySelectorAll("[data-view-replies]").forEach(t=>{t.addEventListener("click",()=>{const s=t.getAttribute("data-review-id");A(this,f,je).call(this,s)})})},ke=function(e){e&&(lt(e,be(),()=>i(this,x)&&i(this,x).update()),i(this,x)&&i(this,x).update())},Ve=function(){if(i(this,W))return;l(this,W,!0);let e=null;window.addEventListener("resize",()=>{e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{e=null,A(this,f,ke).call(this,i(this,b).querySelector("[data-reviews-list]"))})},{signal:i(this,O).signal})},je=function(e){i(this,_)&&i(this,_).call(this);const t=i(this,b).querySelector("[data-review-modal-shell]")||document.querySelector("[data-review-modal-shell]");if(!t)return;t.querySelector("[data-review-modal-body]")&&i(this,C)===null&&l(this,C,t.innerHTML),i(this,C)!==null&&(t.innerHTML=i(this,C)),t.removeAttribute("hidden"),document.body.style.overflow="hidden";const a=document.activeElement,o=t.querySelector("[data-review-modal]");o&&(o.setAttribute("tabindex","-1"),requestAnimationFrame(()=>{o.focus()}));const d=()=>{t.removeEventListener("click",S),t.setAttribute("hidden",""),i(this,C)!==null&&(t.innerHTML=i(this,C)),document.body.style.overflow="",document.removeEventListener("keydown",g),a&&typeof a.focus=="function"&&a.focus(),i(this,L)&&(i(this,L).abort(),l(this,L,null)),i(this,_)===d&&l(this,_,null)};l(this,_,d);const g=c=>{var E;if(De.isShowing())return;if(c.key==="Escape"){d();return}if(c.key!=="Tab")return;const h=t.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])');if(!h.length){c.preventDefault(),(E=t.querySelector("[data-review-modal]"))==null||E.focus();return}const w=h[0],m=h[h.length-1];c.shiftKey&&document.activeElement===w?(c.preventDefault(),m.focus()):!c.shiftKey&&document.activeElement===m&&(c.preventDefault(),w.focus())},S=c=>{c.target===t&&d()};t.addEventListener("click",S),document.addEventListener("keydown",g),A(this,f,ze).call(this,e,t,d)},ze=function(e,t,s){t.querySelector("[data-review-modal]")&&(i(this,L)&&i(this,L).abort(),l(this,L,new AbortController),fetch(`${i(this,M)}/public/reviews/${i(this,k)}/${e}/modal`,{method:"GET",headers:{"X-WP-Nonce":i(this,P)},signal:i(this,L).signal}).then(o=>{if(!o.ok)throw new Error("Failed to load review");return o.json()}).then(o=>{var g;if(!o.view)throw new Error("Empty view");t.innerHTML=o.view;const d=t.querySelector("[data-review-modal]");d&&(d.setAttribute("tabindex","-1"),requestAnimationFrame(()=>d.focus())),(g=t.querySelector("[data-modal-close]"))==null||g.addEventListener("click",s),document.dispatchEvent(new CustomEvent("fct-review-modal-opened",{detail:{overlay:t,review:i(this,V)[e],reviewId:e,container:i(this,b)}}))}).catch(o=>{var S;if(o.name==="AbortError")return;const d=t.querySelector("[data-review-modal-body]")||t.querySelector("[data-review-modal]"),g=t.querySelector("[data-modal-error-template]");d&&g&&(d.replaceChildren(g.content.cloneNode(!0)),(S=d.querySelector("[data-modal-close]"))==null||S.addEventListener("click",s))}))},Ke=function(e){const t=i(this,b).querySelector("[data-reviews-pagination]");t&&(t.innerHTML=e||"",A(this,f,Ce).call(this,t))},Ce=function(e){e.querySelectorAll("[data-page]").forEach(t=>{t.disabled||t.addEventListener("click",()=>{A(this,f,R).call(this,parseInt(t.dataset.page)),i(this,b).scrollIntoView({behavior:"smooth",block:"start"})})})},Ge=function(){const e=c=>c.closest(".fct-review-media-gallery, [data-review-media]")||c.parentElement,t=c=>[...c.querySelectorAll('.fct-review-media-thumb[data-media-type="image"]')],s=(c,h,w)=>{const m=t(c);if(!m.length)return;const E=m.map(n=>({link:n.getAttribute("data-media-url"),alt:n.getAttribute("alt")||"",title:""}));De.open(w,E,Math.min(Math.max(0,h),E.length-1))},a=c=>{const h=e(c);s(h,t(h).indexOf(c),c)},o=c=>{const h=e(c),w=()=>[...h.querySelectorAll(".fct-review-media-thumb[hidden]")],m=w().filter(p=>p.getAttribute("data-media-type")==="video");m.forEach(p=>{p.hidden=!1});const E=t(h),n=E.find(p=>p.hidden);n&&s(h,E.indexOf(n),c);const v=w().length;if(!v){const p=m[0]&&m[0].querySelector(".fct-review-media-play");p&&p.focus(),c.remove();return}m.length&&d(c,v)},d=(c,h)=>{const w=c.querySelector("span");c.setAttribute("data-media-more-count",String(h)),w&&(w.textContent="+"+h);const m=_e().view_more_attachments;m?c.setAttribute("aria-label",m.replace("%s",String(h))):c.removeAttribute("aria-label")},g=c=>{const h=c.closest(".fct-review-media-video"),w=h&&h.querySelector("video");if(!w)return;h.classList.add("is-playing"),w.controls=!0;const m=w.play();m&&typeof m.catch=="function"&&m.catch(()=>{})},S=c=>{const h=c.closest(".fct-review-media-more");if(h)return o(h),!0;const w=c.closest(".fct-review-media-play");if(w)return g(w),!0;const m=c.closest('.fct-review-media-thumb[data-media-type="image"]');return m&&m.getAttribute("data-media-url")?(a(m),!0):!1};i(this,b).addEventListener("click",c=>{S(c.target)&&c.preventDefault()}),i(this,b).addEventListener("keydown",c=>{if(c.key!=="Enter"&&c.key!==" ")return;const h=c.target.closest('.fct-review-media-thumb[data-media-type="image"]');!h||!h.getAttribute("data-media-url")||(c.preventDefault(),a(h))})},Ue=function(){const e=i(this,b).querySelector("[data-reviews-sort]");e&&e.addEventListener("change",()=>{const[s,a]=e.value.split("-");l(this,B,s),l(this,H,a),A(this,f,R).call(this,1)});const t=i(this,b).querySelector("[data-reviews-filter-chips]");t&&t.addEventListener("click",s=>{const a=s.target.closest("[data-filter-chip]");a&&A(this,f,Xe).call(this,a.dataset.filterChip)})},Xe=function(e){const t=Number(e);Number.isInteger(t)&&t>=1&&t<i(this,K)||(l(this,I,null),l(this,N,i(this,$)),l(this,D,!1),e==="all"||(e==="has_media"?l(this,N,!0):e==="verified"?l(this,D,!0):l(this,I,parseInt(e))),i(this,b).querySelectorAll("[data-filter-chip]").forEach(s=>{const a=s.dataset.filterChip===e;s.classList.toggle("active",a),s.setAttribute("aria-pressed",a?"true":"false")}),A(this,f,R).call(this,1))},ge=function(e=!1){fetch(`${i(this,M)}/public/reviews/${i(this,k)}/summary`,{method:"GET",headers:{"X-WP-Nonce":i(this,P)}}).then(t=>t.ok?t.json():Promise.reject(new Error("summary request failed"))).then(t=>{if(!(t!=null&&t.summary))return;const s=t.summary,a=i(this,b).querySelector("[data-reviews-average]");a&&(a.textContent=s.average);const o=i(this,b).querySelector("[data-reviews-stars]");o&&t.stars_html&&(o.innerHTML=t.stars_html,t.stars_label&&o.setAttribute("aria-label",t.stars_label));const d=i(this,b).querySelector("[data-reviews-total]");if(d&&(d.textContent=d.textContent.replace(/[\d,]+/,s.total.toLocaleString())),s.breakdown)for(const g of[5,4,3,2,1]){const S=s.breakdown[g]||0,c=s.total>0?Math.round(S/s.total*100):0,w=i(this,b).querySelectorAll("[data-reviews-bar-row]")[5-g];if(w){const m=w.querySelector("[data-reviews-bar-fill]"),E=w.querySelector("[data-reviews-bar-count]");m&&(m.style.width=c+"%"),E&&(E.textContent=S.toLocaleString())}}}).catch(()=>{e||setTimeout(()=>A(this,f,ge).call(this,!0),2e3)})};const ye="[data-fluent-cart-reviews], [data-fluent-cart-review-summary]",j=new Map;function dt(){j.forEach((r,e)=>{e.isConnected||(r.destroy(),j.delete(e))})}function Me(r=document){const e=r&&typeof r.querySelectorAll=="function"?r:document;dt();const t=[...e.querySelectorAll(ye)];typeof e.matches=="function"&&e.matches(ye)&&t.unshift(e),t.forEach(s=>{if(j.has(s))return;const a=new Se(s);a.init(),j.set(s,a)})}function ct(r=document){const e=r&&typeof r.querySelectorAll=="function"?r:document,t=[...e.querySelectorAll(ye)];typeof e.matches=="function"&&e.matches(ye)&&t.unshift(e),t.forEach(s=>{const a=j.get(s);a&&(a.destroy(),j.delete(s))})}Se.reInit=Me;Se.destroy=ct;window.FluentCartProductReviews=Se;window.fluentCartInitReviews=Me;document.addEventListener("DOMContentLoaded",()=>Me(document)); |
|
1
|
+var Te=i=>{throw TypeError(i)};var Se=(i,e,t)=>e.has(i)||Te("Cannot "+t);var s=(i,e,t)=>(Se(i,e,"read from private field"),t?t.call(i):e.get(i)),u=(i,e,t)=>e.has(i)?Te("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),c=(i,e,t,r)=>(Se(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),A=(i,e,t)=>(Se(i,e,"access private method"),t);import{L as xe}from"./chunks/lightbox.js?ver=1.7.1";const ge=()=>window.fluentcart_review_vars&&window.fluentcart_review_vars.trans||{};function Pe(i,e,t){const r=t.get(i);if(r&&(r.abort(),t.delete(i)),!e||!e.autoplay)return null;const n=new AbortController,a={signal:n.signal};return i.addEventListener("mouseenter",()=>e.autoplay.start(),a),i.addEventListener("mouseleave",()=>e.autoplay.stop(),a),t.set(i,n),n}const Ne=new WeakMap;function Ie(i){const e=i==="prev"?"m15 18-6-6 6-6":"m9 18 6-6-6-6",t=i==="prev"?ge().prev_page||"Previous":ge().next_page||"Next",r=document.createElement("button");return r.type="button",r.className=`fct-reviews-slider-nav fct-reviews-slider-${i}`,r.setAttribute("aria-label",t),r.innerHTML='<svg class="fct-nav-arrow-svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="'+e+'"/></svg>',r}const He=260,$e=12,Je=120;function Qe(i){return i&&i.querySelector(".fct-review-photo-only")?Je:He}function Ye(i,e=He){const t={};for(let r=2;r<=i;r++)t[e*r+$e*(r-1)]={slidesPerView:r};return t}function Ze(i,e){return e!=="segmented"?{el:i,clickable:!0,type:e}:{el:i,type:"custom",renderCustom(t,r,n){let a="";for(let l=1;l<=n;l++){let g="swiper-pagination-segment";l<r?g+=" is-completed":l===r&&(g+=" is-active"),a+=`<button type="button" class="${g}" data-segment-page="${l}" aria-label="${et(l,n)}"`+(l===r?' aria-current="true"':"")+"></button>"}return a+`<span class="segment-counter">${r} / ${n}</span>`}}}function et(i,e){return(ge().slider_page_of||"Page %1$s of %2$s").replace("%1$s",i).replace("%2$s",e)}function tt(i,e){i.addEventListener("click",t=>{var S,d;const r=t.target.closest("[data-segment-page]");if(!r)return;const n=parseInt(r.getAttribute("data-segment-page"),10);if(!n)return;const a=(S=e.snapGrid)==null?void 0:S[n-1],l=a===void 0?-1:(d=e.slidesGrid)==null?void 0:d.indexOf(a),g=l>=0?l:n-1;if(typeof e.slideToLoop=="function"&&e.params.loop){e.slideToLoop(g);return}e.slideTo(g)})}function it(i){const e=i.nextElementSibling;e&&e.classList.contains("fct-reviews-slider-pagination-wrap")&&e.remove()}function rt(i,e,t,r,n){const a=st(i);if(a.className="fct-reviews-slider-frame is-arrows-"+r+" fct-arrows-"+n,r==="bottom"){const l=document.createElement("div");l.className="fct-reviews-slider-nav-row",l.appendChild(e),l.appendChild(t),a.appendChild(l);return}a.appendChild(e),a.appendChild(t)}function Oe(i){const e=i.parentElement;!e||!e.classList.contains("fct-reviews-slider-frame")||e.replaceWith(i)}function st(i){const e=i.parentElement;if(e&&e.classList.contains("fct-reviews-slider-frame"))return[...e.querySelectorAll(".fct-reviews-slider-nav, .fct-reviews-slider-nav-row")].forEach(r=>r.remove()),e;const t=document.createElement("div");return i.replaceWith(t),t.appendChild(i),t}function Be(i,e=null){const t=parseInt(i.getAttribute("data-reviews-slider"),10);if(Pe(i,null,Ne),it(i),!t||typeof window.Swiper!="function")return Oe(i),null;e&&(e.destroy(!0,!0),i.classList.remove("swiper","fct-arrows-sm","fct-arrows-md","fct-arrows-lg"));let r={};try{r=JSON.parse(i.getAttribute("data-slider-settings")||"{}")}catch{}const n=r.arrows!=="no",a=["overlap","outside","bottom"].includes(r.arrowsPosition)?r.arrowsPosition:"overlap",l=r.pagination==="yes",g=["bullets","fraction","progressbar","segmented"].includes(r.paginationType)?r.paginationType:"bullets",S=r.autoplay||"no",d=!!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),h=Array.from(i.children).filter(p=>p.classList.contains("fct-review-item"));if(!h.length)return Oe(i),null;const w=document.createElement("div");w.className="swiper-wrapper",h.forEach(p=>{const y=document.createElement("div");y.className="swiper-slide",y.appendChild(p),w.appendChild(y)}),i.innerHTML="",i.appendChild(w),i.classList.add("swiper",`fct-arrows-${r.arrowsSize||"md"}`);let m=null,E=null;n&&(m=Ie("prev"),E=Ie("next"),rt(i,m,E,a,r.arrowsSize||"md"));let o=null;if(l){const p=document.createElement("div");p.className="fct-carousel-pagination fct-pagination-"+g+" fct-reviews-slider-pagination-wrap",o=document.createElement("div"),o.className="swiper-pagination fct-reviews-slider-pagination",p.appendChild(o),i.insertAdjacentElement("afterend",p)}const v=new window.Swiper(i,{slidesPerView:1,spaceBetween:$e,autoHeight:!1,slidesPerGroupAuto:!0,observer:!0,observeParents:!0,loop:r.infinite==="yes",autoplay:["yes","hover"].includes(S)?{delay:Number(r.autoplayDelay)||3e3,pauseOnMouseEnter:!0,disableOnInteraction:!1,stopOnLastSlide:r.infinite!=="yes"}:!1,watchOverflow:!1,a11y:{enabled:!0},keyboard:{enabled:!0},navigation:n?{prevEl:m,nextEl:E}:!1,pagination:o?Ze(o,g):!1,on:{init(p){(S==="hover"||d)&&p.autoplay&&p.autoplay.stop()}},breakpointsBase:"container",breakpoints:Ye(t,Qe(i))});return o&&g==="segmented"&&tt(o,v),S==="hover"&&Pe(i,v,Ne),v}function nt(i,e){return i-e>1}function at(i,e){const t=parseInt(e,10);if(!t||t<1)return null;const r=String(i).trim().split(/\s+/);return r.length<=t?null:r.slice(0,t).join(" ")+"…"}function Re(i,e={}){const t=!!i;return{expanded:t,label:t?e.show_less||"Show less":e.read_more||"Read more"}}function ot({expanded:i=!1,truncated:e=!1,hasToggle:t=!1}={}){return i?"leave":e?t?"none":"add":t?"remove":"none"}function lt(i,e={},t=null){i.querySelectorAll(".fct-review-item-content, .wp-block-fluent-cart-review-item-content").forEach(n=>{const a=n.nextElementSibling,l=a&&a.classList.contains("fct-review-readmore")?a:null,g=!!l&&l.getAttribute("aria-expanded")==="true",S=parseInt(n.getAttribute("data-max-words"),10)||0;if(S){n.dataset.fullText===void 0&&(n.dataset.fullText=n.textContent);const m=at(n.dataset.fullText,S);if(m===null){n.textContent=n.dataset.fullText,n.classList.remove("is-clamped"),l&&l.remove();return}n.classList.remove("is-clamped");const E=p=>{const y=Re(p,e);return n.textContent=y.expanded?n.dataset.fullText:m,y};if(l){E(g);return}const o=document.createElement("button");o.type="button",o.className="fct-review-readmore";const v=p=>{const y=E(p);o.setAttribute("aria-expanded",y.expanded?"true":"false"),o.textContent=y.label};v(!1),o.addEventListener("click",()=>{v(o.getAttribute("aria-expanded")!=="true"),typeof t=="function"&&t()}),n.insertAdjacentElement("afterend",o);return}if(!i.matches(".fct-reviews-list--grid, .fct-reviews-list--slider"))return;g||n.classList.add("is-clamped");const d=ot({expanded:g,truncated:nt(n.scrollHeight,n.clientHeight),hasToggle:!!l});if(d==="leave"||d==="none")return;if(d==="remove"){l.remove();return}const h=document.createElement("button");h.type="button",h.className="fct-review-readmore";const w=m=>{const E=Re(m,e);n.classList.toggle("is-clamped",!E.expanded),h.setAttribute("aria-expanded",E.expanded?"true":"false"),h.textContent=E.label};w(!1),h.addEventListener("click",()=>{w(h.getAttribute("aria-expanded")!=="true"),typeof t=="function"&&t()}),n.insertAdjacentElement("afterend",h)})}const We=()=>({ratings:[],hasMedia:!1,verified:!1});function dt(i,e,t=0){if(e==="all")return We();if(e==="has_media")return{...i,hasMedia:!i.hasMedia};if(e==="verified")return{...i,verified:!i.verified};const r=Number(e);if(!Number.isInteger(r)||r<1||r>5||r<t)return i;const n=i.ratings.includes(r)?i.ratings.filter(a=>a!==r):[...i.ratings,r];return{...i,ratings:n.sort((a,l)=>l-a)}}function ct(i,e){return e==="all"?!i.ratings.length&&!i.hasMedia&&!i.verified:e==="has_media"?i.hasMedia:e==="verified"?i.verified:i.ratings.includes(Number(e))}const Le=()=>window.fluentcart_review_vars&&window.fluentcart_review_vars.trans||{},De=(()=>{let i=null,e=!1,t=null,r=[],n="";const a=()=>i?document.getElementById(i.classList.lightbox):null,l=o=>[o.classList.lightbox,o.classList.lightboxOverlay].map(v=>document.getElementById(v)).filter(Boolean),g=o=>{l(o).forEach(v=>{v.removeAttribute("id"),v.removeAttribute("tabindex"),r.push(v)}),xe.isBuiltOnce=!1},S=()=>{r.forEach(o=>o.remove()),r=[]},d=o=>{o.disableKeyboardNav(),window.removeEventListener("resize",o.boundSizeOverlay),o.onImageLoaded=()=>{},o.sizeContainer=()=>{},o.showImage=()=>{},o.enableKeyboardNav=()=>{},o.sizeOverlay=()=>{}},h=()=>{const o=a();return o?[...o.querySelectorAll('a[role="button"], button, [tabindex="0"]')].filter(v=>v.offsetParent!==null):[]},w=o=>{if(!e||!i)return;if(o.key==="Escape"){o.preventDefault(),o.stopPropagation(),i.end();return}if(o.key!=="Tab")return;o.stopPropagation();const v=a(),p=h();if(!v)return;if(!p.length){o.preventDefault(),v.focus();return}const y=p[0],P=p[p.length-1],Me=!v.contains(document.activeElement)||document.activeElement===v;o.shiftKey&&(Me||document.activeElement===y)?(o.preventDefault(),P.focus()):!o.shiftKey&&(Me||document.activeElement===P)&&(o.preventDefault(),y.focus())},m=o=>{const v=document.getElementById(o.classList.lightbox);if(!v)return;v.setAttribute("role","dialog"),v.setAttribute("aria-modal","true"),v.setAttribute("aria-label",Le().photo_preview||"Photo preview");const p=v.querySelector("."+o.classList.lbClose);p&&p.setAttribute("aria-label",Le().close||"Close"),v.focus();const y=document.getElementById(o.classList.lightboxOverlay);y&&y.addEventListener("focus",()=>v.focus())},E=o=>{if(o!==i||!e){o.disableKeyboardNav();return}e=!1,i=null,document.removeEventListener("keydown",w,!0),o.endLightbox(),document.body.style.overflow=n,g(o),d(o),clearTimeout(t),t=setTimeout(S,o.options.fadeDuration),o.opener&&o.opener.focus()};return{isShowing(){return e},open(o,v,p){if(clearTimeout(t),e&&i){const P=i;e=!1,i=null,document.removeEventListener("keydown",w,!0),g(P),d(P)}else n=document.body.style.overflow;S(),[...document.querySelectorAll(".fct-lightbox, .fct-lightboxOverlay")].forEach(P=>P.remove()),xe.isBuiltOnce=!1;const y=new xe({wrapAround:!0},[]);y.endLightbox=y.end.bind(y),y.end=()=>E(y),y.opener=o,i=y,e=!0,document.addEventListener("keydown",w,!0),y.setAlbum(v),y.start(p,()=>m(y))}}})();var b,C,ye,T,N,V,Ae,B,R,_,j,z,K,G,U,X,J,Q,Y,Z,ee,te,x,q,D,ie,re,se,ne,ae,oe,le,de,ce,ue,he,fe,me,pe,H,$,k,M,L,I,W,f,O,we,Fe,_e,qe,Ve,je,ze,Ke,ke,Ge,Ue,Xe,ve;class Ee{constructor(e){u(this,f);u(this,b);u(this,C);u(this,ye);u(this,T);u(this,N);u(this,V);u(this,Ae,1);u(this,B,"created_at");u(this,R,"DESC");u(this,_,We());u(this,j,0);u(this,z,!1);u(this,K,!0);u(this,G,!0);u(this,U,!0);u(this,X,!0);u(this,J,!0);u(this,Q,!0);u(this,Y,!0);u(this,Z,!0);u(this,ee,!0);u(this,te,!0);u(this,x,null);u(this,q,null);u(this,D,!1);u(this,ie,"numbers");u(this,re,0);u(this,se,0);u(this,ne,0);u(this,ae,0);u(this,oe,!1);u(this,le,!1);u(this,de,!1);u(this,ce,!1);u(this,ue,!1);u(this,he,!1);u(this,fe,!0);u(this,me,"");u(this,pe,"overlay");u(this,H,"");u(this,$,"");u(this,k,null);u(this,M,null);u(this,L,null);u(this,I,new AbortController);u(this,W,{});var n;c(this,b,e),c(this,C,e.getAttribute("data-post-id")),c(this,ye,e.getAttribute("data-product-name")||""),c(this,T,e.getAttribute("data-rest-url")),c(this,N,e.getAttribute("data-rest-nonce")),c(this,V,parseInt(e.getAttribute("data-per-page"))||10);const t=Number(e.getAttribute("data-min-rating"));c(this,j,Number.isInteger(t)&&t>=1&&t<=5?t:0),c(this,K,e.getAttribute("data-show-verified")!=="0"),c(this,G,e.getAttribute("data-show-date")!=="0"),c(this,U,e.getAttribute("data-show-reviewer")!=="0"),c(this,X,e.getAttribute("data-show-view-reply")!=="0"),c(this,J,e.getAttribute("data-show-avatar")!=="0"),c(this,Q,e.getAttribute("data-show-title")!=="0"),c(this,Y,e.getAttribute("data-show-content")!=="0"),c(this,Z,e.getAttribute("data-show-photos")!=="0"),c(this,ee,e.getAttribute("data-show-footer")!=="0"),c(this,te,e.getAttribute("data-show-variation")!=="0"),c(this,ie,e.getAttribute("data-pagination-type")||"numbers"),c(this,re,parseInt(e.getAttribute("data-max-words"),10)||0),c(this,se,parseInt(e.getAttribute("data-media-visible"),10)||0),c(this,ne,parseInt(e.getAttribute("data-media-width"),10)||0),c(this,ae,parseInt(e.getAttribute("data-media-height"),10)||0),c(this,oe,e.getAttribute("data-media-full-width")==="1"),c(this,le,e.getAttribute("data-media-flush")==="1"),c(this,de,e.getAttribute("data-media-backdrop")==="1"),c(this,ce,e.getAttribute("data-photos-first")==="1"),c(this,ue,e.getAttribute("data-rating-first")==="1"),c(this,he,e.getAttribute("data-badge-last")==="1"),c(this,fe,e.getAttribute("data-show-meta")!=="0"),c(this,me,e.getAttribute("data-item-class")||""),c(this,pe,e.getAttribute("data-media-more")||"overlay"),c(this,z,e.getAttribute("data-only-with-photos")==="1"),c(this,$,e.getAttribute("data-rating-token")||""),c(this,H,((n=e.querySelector("[data-reviews-list]"))==null?void 0:n.getAttribute("data-client-id"))||"");const r=e.getAttribute("data-default-sort");if(r){const[a,l]=r.split("-");a&&c(this,B,a),l&&c(this,R,l)}}init(){if(s(this,b).hasAttribute("data-fluent-cart-review-summary")){document.addEventListener("fct-review-submitted",r=>{var n;String((n=r.detail)==null?void 0:n.postId)===String(s(this,C))&&A(this,f,ve).call(this)},{signal:s(this,I).signal});return}const e=s(this,b).querySelector("[data-reviews-list]");if(e&&e.querySelector("[data-review-id], [data-reviews-empty]")){A(this,f,_e).call(this,e);const r=s(this,b).querySelector("[data-reviews-pagination]");r&&A(this,f,ke).call(this,r)}else A(this,f,O).call(this);if(A(this,f,Ue).call(this),A(this,f,Ge).call(this),window.location.hash==="#fct-product-reviews"){const r=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;requestAnimationFrame(()=>{s(this,b).scrollIntoView({behavior:r?"auto":"smooth",block:"start"})})}document.addEventListener("fct-review-submitted",r=>{var n;String((n=r.detail)==null?void 0:n.postId)===String(s(this,C))&&(A(this,f,O).call(this,1),A(this,f,ve).call(this))},{signal:s(this,I).signal})}destroy(){s(this,q)&&s(this,q).call(this),s(this,I).abort(),s(this,k)&&(s(this,k).abort(),c(this,k,null)),s(this,L)&&(s(this,L).abort(),c(this,L,null)),s(this,x)&&(s(this,x).destroy(!0,!0),c(this,x,null)),c(this,D,!1),c(this,W,{})}}b=new WeakMap,C=new WeakMap,ye=new WeakMap,T=new WeakMap,N=new WeakMap,V=new WeakMap,Ae=new WeakMap,B=new WeakMap,R=new WeakMap,_=new WeakMap,j=new WeakMap,z=new WeakMap,K=new WeakMap,G=new WeakMap,U=new WeakMap,X=new WeakMap,J=new WeakMap,Q=new WeakMap,Y=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,x=new WeakMap,q=new WeakMap,D=new WeakMap,ie=new WeakMap,re=new WeakMap,se=new WeakMap,ne=new WeakMap,ae=new WeakMap,oe=new WeakMap,le=new WeakMap,de=new WeakMap,ce=new WeakMap,ue=new WeakMap,he=new WeakMap,fe=new WeakMap,me=new WeakMap,pe=new WeakMap,H=new WeakMap,$=new WeakMap,k=new WeakMap,M=new WeakMap,L=new WeakMap,I=new WeakMap,W=new WeakMap,f=new WeakSet,O=function(e=1){c(this,Ae,e);const t=s(this,b).querySelector("[data-reviews-list]"),r=s(this,b).querySelector("[data-reviews-loading]");s(this,k)&&s(this,k).abort(),c(this,k,new AbortController),A(this,f,we).call(this,t,r,!0);const n=new URLSearchParams({page:e,per_page:s(this,V),sort_by:s(this,B),sort_order:s(this,R),show_reviewer:s(this,U)?"1":"0",show_date:s(this,G)?"1":"0",show_verified:s(this,K)?"1":"0",show_view_reply:s(this,X)?"1":"0",show_avatar:s(this,J)?"1":"0",show_title:s(this,Q)?"1":"0",show_content:s(this,Y)?"1":"0",show_photos:s(this,Z)?"1":"0",show_footer:s(this,ee)?"1":"0",show_variation:s(this,te)?"1":"0",pagination_type:s(this,ie),max_words:s(this,re),media_visible:s(this,se),media_width:s(this,ne),media_height:s(this,ae),media_full_width:s(this,oe)?"1":"0",media_flush:s(this,le)?"1":"0",media_backdrop:s(this,de)?"1":"0",photos_first:s(this,ce)?"1":"0",rating_first:s(this,ue)?"1":"0",badge_last:s(this,he)?"1":"0",show_meta:s(this,fe)?"1":"0",item_class:s(this,me),media_more:s(this,pe)});s(this,$)&&n.set("rating_token",s(this,$)),s(this,H)&&n.set("client_id",s(this,H)),s(this,_).ratings.length&&n.set("ratings",s(this,_).ratings.join(",")),(s(this,_).hasMedia||s(this,z))&&n.set("has_media","1"),s(this,_).verified&&n.set("verified_only","1"),fetch(`${s(this,T)}/public/reviews/${s(this,C)}${s(this,T).includes("?")?"&":"?"}${n}`,{method:"GET",headers:{"X-WP-Nonce":s(this,N)},signal:s(this,k).signal}).then(a=>{if(!a.ok)throw new Error(a.statusText);return a.json()}).then(a=>{if(A(this,f,we).call(this,t,r,!1),a.reviews&&a.reviews.data){A(this,f,Fe).call(this,a.reviews.data,t,a.reviews_html||""),A(this,f,Ke).call(this,a.pagination_html||"");const l=s(this,b).querySelector("[data-reviews-total-count]");l&&(l.textContent=a.reviews.total.toLocaleString())}}).catch(a=>{if(a.name==="AbortError")return;A(this,f,we).call(this,t,r,!1),t&&(t.textContent="",c(this,x,Be(t,s(this,x))));const l=s(this,b).querySelector("[data-reviews-error]");l&&(l.hidden=!1)})},we=function(e,t,r){if(t&&(t.classList.toggle("is-visible",r),r&&e)){const n=e.getBoundingClientRect(),a=t.getBoundingClientRect();t.style.setProperty("--fct-reviews-rows-top",Math.round(n.top-a.top)+"px"),t.style.setProperty("--fct-reviews-rows-center-x",Math.round(n.left-a.left+n.width/2)+"px"),t.style.setProperty("--fct-reviews-rows-height",Math.round(n.height)+"px")}e&&(e.classList.toggle("is-loading",r),r?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"))},Fe=function(e,t,r){c(this,W,e.reduce((a,l)=>(a[l.id]=l,a),{}));const n=s(this,b).querySelector("[data-reviews-error]");n&&(n.hidden=!0),t.innerHTML=r,A(this,f,_e).call(this,t)},_e=function(e){c(this,x,Be(e,s(this,x))),A(this,f,qe).call(this,e),A(this,f,Ve).call(this),e.querySelectorAll("[data-view-replies]").forEach(t=>{t.addEventListener("click",()=>{const r=t.getAttribute("data-review-id");A(this,f,je).call(this,r)})})},qe=function(e){e&&(lt(e,ge(),()=>s(this,x)&&s(this,x).update()),s(this,x)&&s(this,x).update())},Ve=function(){if(s(this,D))return;c(this,D,!0);let e=null;window.addEventListener("resize",()=>{e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{e=null,A(this,f,qe).call(this,s(this,b).querySelector("[data-reviews-list]"))})},{signal:s(this,I).signal})},je=function(e){s(this,q)&&s(this,q).call(this);const t=s(this,b).querySelector("[data-review-modal-shell]")||document.querySelector("[data-review-modal-shell]");if(!t)return;t.querySelector("[data-review-modal-body]")&&s(this,M)===null&&c(this,M,t.innerHTML),s(this,M)!==null&&(t.innerHTML=s(this,M)),t.removeAttribute("hidden"),document.body.style.overflow="hidden";const n=document.activeElement,a=t.querySelector("[data-review-modal]");a&&(a.setAttribute("tabindex","-1"),requestAnimationFrame(()=>{a.focus()}));const l=()=>{t.removeEventListener("click",S),t.setAttribute("hidden",""),s(this,M)!==null&&(t.innerHTML=s(this,M)),document.body.style.overflow="",document.removeEventListener("keydown",g),n&&typeof n.focus=="function"&&n.focus(),s(this,L)&&(s(this,L).abort(),c(this,L,null)),s(this,q)===l&&c(this,q,null)};c(this,q,l);const g=d=>{var E;if(De.isShowing())return;if(d.key==="Escape"){l();return}if(d.key!=="Tab")return;const h=t.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])');if(!h.length){d.preventDefault(),(E=t.querySelector("[data-review-modal]"))==null||E.focus();return}const w=h[0],m=h[h.length-1];d.shiftKey&&document.activeElement===w?(d.preventDefault(),m.focus()):!d.shiftKey&&document.activeElement===m&&(d.preventDefault(),w.focus())},S=d=>{d.target===t&&l()};t.addEventListener("click",S),document.addEventListener("keydown",g),A(this,f,ze).call(this,e,t,l)},ze=function(e,t,r){t.querySelector("[data-review-modal]")&&(s(this,L)&&s(this,L).abort(),c(this,L,new AbortController),fetch(`${s(this,T)}/public/reviews/${s(this,C)}/${e}/modal`,{method:"GET",headers:{"X-WP-Nonce":s(this,N)},signal:s(this,L).signal}).then(a=>{if(!a.ok)throw new Error("Failed to load review");return a.json()}).then(a=>{var g;if(!a.view)throw new Error("Empty view");t.innerHTML=a.view;const l=t.querySelector("[data-review-modal]");l&&(l.setAttribute("tabindex","-1"),requestAnimationFrame(()=>l.focus())),(g=t.querySelector("[data-modal-close]"))==null||g.addEventListener("click",r),document.dispatchEvent(new CustomEvent("fct-review-modal-opened",{detail:{overlay:t,review:s(this,W)[e],reviewId:e,container:s(this,b)}}))}).catch(a=>{var S;if(a.name==="AbortError")return;const l=t.querySelector("[data-review-modal-body]")||t.querySelector("[data-review-modal]"),g=t.querySelector("[data-modal-error-template]");l&&g&&(l.replaceChildren(g.content.cloneNode(!0)),(S=l.querySelector("[data-modal-close]"))==null||S.addEventListener("click",r))}))},Ke=function(e){const t=s(this,b).querySelector("[data-reviews-pagination]");t&&(t.innerHTML=e||"",A(this,f,ke).call(this,t))},ke=function(e){e.querySelectorAll("[data-page]").forEach(t=>{t.disabled||t.addEventListener("click",()=>{A(this,f,O).call(this,parseInt(t.dataset.page)),s(this,b).scrollIntoView({behavior:"smooth",block:"start"})})})},Ge=function(){const e=d=>d.closest(".fct-review-media-gallery, [data-review-media]")||d.parentElement,t=d=>[...d.querySelectorAll('.fct-review-media-thumb[data-media-type="image"]')],r=(d,h,w)=>{const m=t(d);if(!m.length)return;const E=m.map(o=>({link:o.getAttribute("data-media-url"),alt:o.getAttribute("alt")||"",title:""}));De.open(w,E,Math.min(Math.max(0,h),E.length-1))},n=d=>{const h=e(d);r(h,t(h).indexOf(d),d)},a=d=>{const h=e(d),w=()=>[...h.querySelectorAll(".fct-review-media-thumb[hidden]")],m=w().filter(p=>p.getAttribute("data-media-type")==="video");m.forEach(p=>{p.hidden=!1});const E=t(h),o=E.find(p=>p.hidden);o&&r(h,E.indexOf(o),d);const v=w().length;if(!v){const p=m[0]&&m[0].querySelector(".fct-review-media-play");p&&p.focus(),d.remove();return}m.length&&l(d,v)},l=(d,h)=>{const w=d.querySelector("span");d.setAttribute("data-media-more-count",String(h)),w&&(w.textContent="+"+h);const m=Le().view_more_attachments;m?d.setAttribute("aria-label",m.replace("%s",String(h))):d.removeAttribute("aria-label")},g=d=>{const h=d.closest(".fct-review-media-video"),w=h&&h.querySelector("video");if(!w)return;h.classList.add("is-playing"),w.controls=!0;const m=w.play();m&&typeof m.catch=="function"&&m.catch(()=>{})},S=d=>{const h=d.closest(".fct-review-media-more");if(h)return a(h),!0;const w=d.closest(".fct-review-media-play");if(w)return g(w),!0;const m=d.closest('.fct-review-media-thumb[data-media-type="image"]');return m&&m.getAttribute("data-media-url")?(n(m),!0):!1};s(this,b).addEventListener("click",d=>{S(d.target)&&d.preventDefault()}),s(this,b).addEventListener("keydown",d=>{if(d.key!=="Enter"&&d.key!==" ")return;const h=d.target.closest('.fct-review-media-thumb[data-media-type="image"]');!h||!h.getAttribute("data-media-url")||(d.preventDefault(),n(h))})},Ue=function(){const e=s(this,b).querySelector("[data-reviews-sort]");e&&e.addEventListener("change",()=>{const[r,n]=e.value.split("-");c(this,B,r),c(this,R,n),A(this,f,O).call(this,1)});const t=s(this,b).querySelector("[data-reviews-filter-chips]");t&&t.addEventListener("click",r=>{const n=r.target.closest("[data-filter-chip]");n&&A(this,f,Xe).call(this,n.dataset.filterChip)})},Xe=function(e){const t=dt(s(this,_),e,s(this,j));t!==s(this,_)&&(c(this,_,t),s(this,b).querySelectorAll("[data-filter-chip]").forEach(r=>{const n=ct(s(this,_),r.dataset.filterChip);r.classList.toggle("active",n),r.setAttribute("aria-pressed",n?"true":"false")}),A(this,f,O).call(this,1))},ve=function(e=!1){fetch(`${s(this,T)}/public/reviews/${s(this,C)}/summary`,{method:"GET",headers:{"X-WP-Nonce":s(this,N)}}).then(t=>t.ok?t.json():Promise.reject(new Error("summary request failed"))).then(t=>{if(!(t!=null&&t.summary))return;const r=t.summary,n=s(this,b).querySelector("[data-reviews-average]");n&&(n.textContent=r.average);const a=s(this,b).querySelector("[data-reviews-stars]");a&&t.stars_html&&(a.innerHTML=t.stars_html,t.stars_label&&a.setAttribute("aria-label",t.stars_label));const l=s(this,b).querySelector("[data-reviews-total]");if(l&&(l.textContent=l.textContent.replace(/[\d,]+/,r.total.toLocaleString())),r.breakdown)for(const g of[5,4,3,2,1]){const S=r.breakdown[g]||0,d=r.total>0?Math.round(S/r.total*100):0,w=s(this,b).querySelectorAll("[data-reviews-bar-row]")[5-g];if(w){const m=w.querySelector("[data-reviews-bar-fill]"),E=w.querySelector("[data-reviews-bar-count]");m&&(m.style.width=d+"%"),E&&(E.textContent=S.toLocaleString())}}}).catch(()=>{e||setTimeout(()=>A(this,f,ve).call(this,!0),2e3)})};const be="[data-fluent-cart-reviews], [data-fluent-cart-review-summary]",F=new Map;function ut(){F.forEach((i,e)=>{e.isConnected||(i.destroy(),F.delete(e))})}function Ce(i=document){const e=i&&typeof i.querySelectorAll=="function"?i:document;ut();const t=[...e.querySelectorAll(be)];typeof e.matches=="function"&&e.matches(be)&&t.unshift(e),t.forEach(r=>{if(F.has(r))return;const n=new Ee(r);n.init(),F.set(r,n)})}function ht(i=document){const e=i&&typeof i.querySelectorAll=="function"?i:document,t=[...e.querySelectorAll(be)];typeof e.matches=="function"&&e.matches(be)&&t.unshift(e),t.forEach(r=>{const n=F.get(r);n&&(n.destroy(),F.delete(r))})}Ee.reInit=Ce;Ee.destroy=ht;window.FluentCartProductReviews=Ee;window.fluentCartInitReviews=Ce;document.addEventListener("DOMContentLoaded",()=>Ce(document)); |