(()=>{"use strict";const t=new WeakSet;function e(t){const e=getComputedStyle(t).gridTemplateColumns;return e&&"none"!==e?Math.max(1,e.split(" ").filter(Boolean).length):1}function a(a){document.querySelectorAll(`[${a.wrapAttr}]`).forEach(n=>{if(t.has(n))return;t.add(n);const r=n.getAttribute(a.wrapAttr);"numbered"===r?function(t,e){const a=t.querySelector(e.grid),n=t.querySelector(".flexa-pagination");if(!a||!n)return;const r=Array.from(a.querySelectorAll(e.item)),l=Math.max(1,parseInt(t.getAttribute("data-per-page")||"6",10)||6),o=Math.ceil(r.length/l);if(o<=1)return;const s=t.getAttribute("data-prev-label")||"‹",c=t.getAttribute("data-next-label")||"›";let i=1;const d=(t,e,a)=>{const n=document.createElement("button");return n.type="button",n.className="page-numbers"+(a?" "+a:""),n.textContent=t,e===i&&"current"===a&&n.setAttribute("aria-current","page"),n.addEventListener("click",()=>u(e)),n},u=t=>{i=Math.min(Math.max(1,t),o),(()=>{const t=(i-1)*l;r.forEach((e,a)=>{e.style.display=a>=t&&a<t+l?"":"none"})})(),n.textContent="",i>1&&n.appendChild(d(s,i-1,"prev")),function(t,e,a=1,n=1){const r=[];for(let l=1;l<=t;l++)l<=n||l>t-n||l>=e-a&&l<=e+a?r.push(l):"dots"!==r[r.length-1]&&r.push("dots");return r}(o,i).forEach(t=>{if("dots"===t){const t=document.createElement("span");t.className="page-numbers dots",t.textContent="…",n.appendChild(t)}else n.appendChild(d(String(t),t,t===i?"current":""))}),i<o&&n.appendChild(d(c,i+1,"next"))};u(1)}(n,a):"loadmore"===r&&function(t,a){const n=t.querySelector(a.grid),r=t.querySelector(".flexa-pagination-loadmore"),l=t.querySelector(".flexa-pagination-loadmore__btn");if(!n||!r||!l)return;const o=Array.from(n.querySelectorAll(a.item)),s=Math.max(1,parseInt(t.getAttribute("data-loadmore-rows")||"2",10)||2),c=parseInt(t.getAttribute("data-loadmore-step")||"",10);let i=s*e(n);const d=()=>{o.forEach((t,e)=>{t.style.display=e<i?"":"none"}),r.style.display=i>=o.length?"none":""};i>=o.length?r.style.display="none":(d(),l.addEventListener("click",()=>{i+=c>0?c:e(n),d()}))}(n,a)})}const n={wrapAttr:"data-flexa-pd-pagination",grid:".commentlist",item:":scope > li"};function r(t){const e=t.querySelector(".flexa-product-detail__nav"),a=t.querySelector(".flexa-product-detail__tab.is-active");if(!e||!a)return;const n=e.getBoundingClientRect(),r=a.getBoundingClientRect(),l=r.left-n.left+e.scrollLeft;e.style.setProperty("--flexa-pd-ind-x",`${l}px`),e.style.setProperty("--flexa-pd-ind-w",`${r.width}px`),e.classList.add("is-indicator-ready")}function l(t){"1"!==t.dataset.flexaProductDetailReady&&(t.dataset.flexaProductDetailReady="1",t.querySelectorAll(".flexa-product-detail__tab").forEach(e=>{e.addEventListener("click",()=>{const a=e.getAttribute("data-tab");null!==a&&function(t,e){t.querySelectorAll(".flexa-product-detail__tab").forEach(t=>{const a=t.getAttribute("data-tab")===e;t.classList.toggle("is-active",a),t.setAttribute("aria-selected",a?"true":"false")}),t.querySelectorAll(".flexa-product-detail__panel").forEach(t=>{t.classList.toggle("is-active",t.getAttribute("data-tab")===e)}),r(t)}(t,a)})}),r(t),window.addEventListener("resize",()=>r(t)),function(t){t.querySelectorAll('select#rating, select[name="rating"]').forEach(t=>{if("1"===t.dataset.flexaStars)return;if(t.parentElement?.querySelector("p.stars"))return;t.dataset.flexaStars="1";const e=document.createElement("span");e.className="flexa-product-detail__stars";const a=[];for(let t=1;t<=5;t++){const n=document.createElement("button");n.type="button",n.className="flexa-product-detail__star",n.dataset.value=String(t),n.setAttribute("aria-label",String(t)),n.textContent="★",a.push(n),e.appendChild(n)}const n=t=>{a.forEach((e,a)=>e.classList.toggle("is-on",a<t))};e.addEventListener("click",e=>{const a=e.target.closest(".flexa-product-detail__star");if(!a)return;const r=parseInt(a.dataset.value||"0",10);t.value=String(r),t.dispatchEvent(new Event("change",{bubbles:!0})),n(r)}),e.addEventListener("mouseover",t=>{const e=t.target.closest(".flexa-product-detail__star");e&&n(parseInt(e.dataset.value||"0",10))}),e.addEventListener("mouseleave",()=>n(parseInt(t.value||"0",10))),t.style.display="none",t.parentElement?.insertBefore(e,t),n(parseInt(t.value||"0",10))})}(t))}function o(){document.querySelectorAll(".flexa-product-detail").forEach(l),a(n)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",o):o()})();