(()=>{"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 n(n){document.querySelectorAll(`[${n.wrapAttr}]`).forEach(r=>{if(t.has(r))return;t.add(r);const a=r.getAttribute(n.wrapAttr);"numbered"===a?function(t,e){const n=t.querySelector(e.grid),r=t.querySelector(".flexa-pagination");if(!n||!r)return;const a=Array.from(n.querySelectorAll(e.item)),o=Math.max(1,parseInt(t.getAttribute("data-per-page")||"6",10)||6),l=Math.ceil(a.length/o);if(l<=1)return;const s=t.getAttribute("data-prev-label")||"‹",i=t.getAttribute("data-next-label")||"›";let c=1;const d=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className="page-numbers"+(n?" "+n:""),r.textContent=t,e===c&&"current"===n&&r.setAttribute("aria-current","page"),r.addEventListener("click",()=>u(e)),r},u=t=>{c=Math.min(Math.max(1,t),l),(()=>{const t=(c-1)*o;a.forEach((e,n)=>{e.style.display=n>=t&&n<t+o?"":"none"})})(),r.textContent="",c>1&&r.appendChild(d(s,c-1,"prev")),function(t,e,n=1,r=1){const a=[];for(let o=1;o<=t;o++)o<=r||o>t-r||o>=e-n&&o<=e+n?a.push(o):"dots"!==a[a.length-1]&&a.push("dots");return a}(l,c).forEach(t=>{if("dots"===t){const t=document.createElement("span");t.className="page-numbers dots",t.textContent="…",r.appendChild(t)}else r.appendChild(d(String(t),t,t===c?"current":""))}),c<l&&r.appendChild(d(i,c+1,"next"))};u(1)}(r,n):"loadmore"===a&&function(t,n){const r=t.querySelector(n.grid),a=t.querySelector(".flexa-pagination-loadmore"),o=t.querySelector(".flexa-pagination-loadmore__btn");if(!r||!a||!o)return;const l=Array.from(r.querySelectorAll(n.item)),s=Math.max(1,parseInt(t.getAttribute("data-loadmore-rows")||"2",10)||2),i=parseInt(t.getAttribute("data-loadmore-step")||"",10);let c=s*e(r);const d=()=>{l.forEach((t,e)=>{t.style.display=e<c?"":"none"}),a.style.display=c>=l.length?"none":""};c>=l.length?a.style.display="none":(d(),o.addEventListener("click",()=>{c+=i>0?i:e(r),d()}))}(r,n)})}const r={wrapAttr:"data-flexa-rss-pagination",grid:".flexa-rss__grid",item:".flexa-rss__item"};function a(){n(r)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",a):a()})();