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