import"./xihTtKlq.mjs";import{At as e,Ft as t,Ht as n,J as r,Jt as i,Lt as a,N as o,O as s,Pt as c,Qt as l,Rt as u,S as d,U as ee,V as f,Wt as p,Z as m,Zt as te,at as ne,b as re,c as h,dn as ie,et as g,fn as ae,gt as _,it as oe,k as se,kt as v,l as ce,m as le,nt as y,q as ue,tt as de,vn as fe,w as pe,yn as b,yt as x}from"./DRAiiyBy.mjs";import{t as me}from"./C3-3c3M6.mjs";import{a as he}from"./BhKzNVnb.mjs";import"./BFCdESQQ.mjs";import{t as ge}from"./WoN3D9AG.mjs";import"./CMhxvAXz.mjs";import{n as _e}from"./CfWZUDe_.mjs";import{i as ve}from"./D5pOLiFY.mjs";import{t as ye}from"./CL-xaCec.mjs";import{t as be}from"./402fj26Z.mjs";var S=[{maxWidth:500,itemsPerRow:3,columnGap:10,rowsPerLoad:3,maxLoadMoreClicks:2,initialRows:10},{maxWidth:600,itemsPerRow:4,columnGap:15,rowsPerLoad:2,maxLoadMoreClicks:2,initialRows:8},{maxWidth:750,itemsPerRow:5,columnGap:15,rowsPerLoad:2,maxLoadMoreClicks:2,initialRows:6},{maxWidth:900,itemsPerRow:6,columnGap:15,rowsPerLoad:2,maxLoadMoreClicks:1,initialRows:5},{maxWidth:1050,itemsPerRow:7,columnGap:15,rowsPerLoad:2,maxLoadMoreClicks:1,initialRows:4}],C={itemsPerRow:8,columnGap:15,rowsPerLoad:2,maxLoadMoreClicks:1,initialRows:4},xe=800,w=300,T=w*4,E=e=>{let t=Math.abs(e)/xe*1e3;return Math.min(T,Math.max(w,t))},Se=(e,t,n)=>{let r=(t??S).find(t=>e<=t.maxWidth)||C;if(n){let e=Math.floor(n/r.itemsPerRow);return{...r,initialRows:e}}return r},Ce=(e,t,n)=>{let r=e.querySelectorAll(`:scope > *`),i=(t-1)*n,a=r[Math.min(i+n-1,r.length-1)];if(!a)return!1;let o=a.getBoundingClientRect(),s=window.innerHeight;return o.bottom>s},we=(e,t,n,r,i)=>{e.style.height=`${t}px`,e.offsetHeight,e.style.height=`${n}px`,i&&setTimeout(i,r)},Te=(e,t)=>{let n=e.offsetHeight;e.style.height=`${n}px`;let r=e.querySelectorAll(`:scope > *`),i=[];r.forEach((e,n)=>{n>=t&&(i.push(e),e.style.display=`none`)}),e.style.height=`auto`;let a=e.scrollHeight;return e.style.height=`${n}px`,i.forEach(e=>{e.style.display=``}),{currentHeight:n,targetHeight:a}},Ee=e=>(e.style.height=`auto`,e.scrollHeight),D=((e,t,n,r)=>{let i=e=>((1.993*e+-1.9860000000000002)*e+.9930000000000001)*e,a=e=>((-2*e+3)*e+0)*e;return e=>{if(e===0||e===1)return e;let t=0,n=1;for(let r=0;r<30;r++){let r=(t+n)/2,o=i(r);if(Math.abs(o-e)<1e-7)return a(r);oe?window:document.getElementById(`scrollable`)||window,O=e=>e instanceof Window?e.scrollY:e.scrollTop,k=(e,t)=>{e instanceof Window?e.scrollTo(0,t):e.scrollTop=t},Oe=(e,t,n,r,i,a)=>{let o=De(r),s=O(o),c=t-n,l=Math.max(0,s-c),u=s-l,d=e.style.transition;e.style.transition=`none`;let ee=performance.now(),f=r=>{let p=r-ee,m=Math.min(p/i,1),te=D(m),ne=t-c*te;e.style.height=`${ne}px`,u!==0&&k(o,s-u*te),m<1?requestAnimationFrame(f):(e.style.height=`${n}px`,k(o,l),e.style.transition=d,a?.())};requestAnimationFrame(f)},ke=(e,t,n,r,i)=>{let a=n-t,o=e.style.transition;e.style.transition=`none`;let s=performance.now(),c=l=>{let u=l-s,d=Math.min(u/r,1),ee=D(d);e.style.height=`${t+a*ee}px`,d<1?requestAnimationFrame(c):(e.style.height=`${n}px`,e.style.transition=o,i?.())};requestAnimationFrame(c)},A=e=>{let t=e??S;return t.at(-1)?.maxWidth===1/0?t:[...t,{...C,maxWidth:1/0}]},j=(e,t)=>(t?1:e.initialRows)*e.itemsPerRow,Ae=({scope:e,breakpoints:t,singleRowStart:n,itemCount:r,hideLoadMoreWhenFits:i,initialVisibleCount:a})=>{let o=`[data-expandable-grid="${e}"]`,s=`${o} .expandable-grid{--items-per-row:var(--js-items-per-row, ${t[0].itemsPerRow});--column-gap:var(--js-column-gap, ${t[0].columnGap}px);}`,c=0;return`${s}\n${t.map(e=>{let t=a??j(e,n),s=[`${o} .expandable-grid{--items-per-row:${e.itemsPerRow};--column-gap:${e.columnGap}px;}`,`${o}.is-starting-view .expandable-grid>:nth-child(n+${t+1}){display:none;}`];i&&r<=t&&s.push(`${o}.is-starting-view .load-more-container,${o}.is-starting-view .counting-text{display:none;}`);let l=s.join(``),u=c;c=e.maxWidth;let d=[];return u>0&&d.push(`(min-width: ${u+.01}px)`),e.maxWidth!==1/0&&d.push(`(max-width: ${e.maxWidth}px)`),d.length?`@container ${d.join(` and `)}{${l}}`:l}).join(` `)}`},je=e=>{let t=A(e.gridBreakpoints),n=t.map(t=>e.initialVisibleCount??j(t,e.singleRowStart));return{styleTag:``,maxItemCount:Math.max(...n),minItemCount:Math.min(...n),minLoadMoreClicks:Math.min(...t.map(e=>e.maxLoadMoreClicks))}},Me={loadMore:{id:`a4N_Bg`},showLess:{id:`8wM9ab`}},Ne=new Set([`$$slots`,`$$events`,`$$legacy`,`class`,`itemCount`,`slug`,`singleRowStart`,`totalItemCount`,`resetKey`,`onLoadMore`,`isLoadingMore`,`isLoadingItems`,`header`,`items`,`hideViewAll`,`viewAllCard`,`countingText`,`maxLoadMoreClicks`,`gridBreakpoints`,`headingId`,`initialVisibleCount`]),Pe=y(`
`),Fe=y(`
`),Ie=y(``),Le=y(`
`),Re=y(`
`);function ze(y,S){let C=oe();ae(S,!0);let xe=()=>l(ze,`$layout`,D),w=()=>l(he,`$mobileView`,D),T=()=>l(me,`$i18n`,D),[D,De]=te(),O=h(S,`singleRowStart`,3,!0),k=h(S,`isLoadingMore`,3,!1),A=h(S,`isLoadingItems`,3,!1),j=h(S,`hideViewAll`,3,!1),Ae=ce(S,Ne),ze=ve(),Be=p(0),Ve=i(()=>_(Be)||xe()||800),He=p(null),M=p(null),N=p(1),P=p(0),F=p(1),Ue=p(0),I=p(!0),L=p(!1),R=p(!1),We=p(!1),z=p(!1),B=p(!1),V=p(!1),H=i(()=>Se(_(Ve),S.gridBreakpoints,S.initialVisibleCount)),U=i(()=>_(H).itemsPerRow),Ge=i(()=>_(H).columnGap),W=i(()=>_(H).rowsPerLoad),G=i(()=>S.maxLoadMoreClicks??_(H).maxLoadMoreClicks),K=i(()=>O()?1:_(H).initialRows),Ke=i(()=>!!S.onLoadMore||!Number.isFinite(_(G))),q=i(()=>_(N)*_(U)),qe=i(()=>_(U)*(1+_(W)*_(G))-1),Je=i(()=>!j()&&!_(Ke)&&_(P)>=_(G)&&!_(z)&&S.itemCount>=_(qe)&&S.viewAllCard!==void 0),Ye=i(()=>_(Je)?_(q)-1:_(q)),Xe=i(()=>S.onLoadMore?S.itemCount>_(q)||!_(V)&&S.totalItemCount!==void 0&&S.totalItemCount>S.itemCount:S.itemCount>_(q)&&_(P)<_(G)),Ze=i(()=>!_(Ke)&&!_(Xe)&&_(N)>_(K)),Qe=i(()=>_(P)===0&&(!_(We)||_(N)===_(K))),$e=i(()=>A()&&S.itemCount===0),et=i(()=>!!S.onLoadMore&&!_(V)&&S.totalItemCount!==void 0&&S.totalItemCount>S.itemCount),J=i(()=>je({initialVisibleCount:S.initialVisibleCount,scope:C,gridBreakpoints:S.gridBreakpoints,singleRowStart:O(),itemCount:S.itemCount,hideLoadMoreWhenFits:!_(et)&&!_($e)})),Y=i(()=>_(Qe)&&(S.maxLoadMoreClicks??_(J).minLoadMoreClicks)>0),tt=i(()=>_(Y)&&S.itemCount>_(J).minItemCount),X=i(()=>_(Xe)||_(tt)||_($e)),nt=i(()=>_(Y)?_(J).maxItemCount:_(Ye)),rt=i(()=>_(Y)?Math.min(_(J).maxItemCount,_(K)*_(U)):_(Ye));e(()=>{!_(We)&&_(K)>0&&(n(We,!0),n(N,_(K),!0),n(F,_(K),!0),n(I,!1))}),e(()=>{_(N),_(U),_(Ve),!_(M)||_(R)||_(B)||requestAnimationFrame(()=>{if(!_(M))return;let e=_(M).offsetHeight,t=Ee(_(M));if(e!==t){if(_(I)){n(L,!0);let r=E(t-e);_(M).style.setProperty(`--transition-duration`,`${r/1e3}s`),we(_(M),e,t,r,()=>{n(L,!1),_(M)&&(_(M).style.height=`auto`)})}else _(M).style.height=`${t}px`,n(I,!0),requestAnimationFrame(()=>{_(M)&&(_(M).style.height=`auto`)})}})}),e(()=>{if(_(U)!==_(Ue)){n(Ue,_(U),!0),n(I,!1);let e=O()?1:_(H).initialRows,t=S.maxLoadMoreClicks??_(H).maxLoadMoreClicks,r=e+_(H).rowsPerLoad*t,i=Math.min(_(P),t),a;if(i===0)a=e;else{let t=e+i*_(H).rowsPerLoad;a=Math.max(_(N),t)}a>r&&(a=r,i=t),n(N,a,!0),n(P,i,!0),n(F,a,!0)}}),e(()=>{_(N)>_(F)&&n(F,_(N),!0),_(F)>_(K)&&_(N)===_(K)&&n(F,_(K),!0)});let Z=p(u(S.resetKey));e(()=>{S.resetKey!==void 0&&S.resetKey!==_(Z)&&_(Z)!==void 0?(n(Z,S.resetKey,!0),n(I,!1),n(N,_(K),!0),n(P,0),n(F,_(K),!0),n(z,!1),n(V,!1),setTimeout(()=>{n(I,!0)},0)):_(Z)===void 0&&n(Z,S.resetKey,!0)});let it=async()=>{if(!_(M))return;n(B,!0);let e=(_(N)+_(W))*_(U);if(S.onLoadMore&&S.itemCount=_(G)&&n(z,!0),n(P,_(P)+1),_e.track(`card_list_load_more_clicked`,{slug:S.slug,itemsPerRow:_(U),clickCount:_(P)});let t=_(N)+_(W),r=_(M).offsetHeight;if(_(M).style.height=`${r}px`,n(N,t),await x(),_(M).querySelectorAll(`:scope > *`).length===0){n(B,!1);return}let i=Ce(_(M),t,_(U)),a=Ee(_(M)),o=E(a-r);i?(n(N,_(N)-_(W)),await x(),n(L,!0),_(M).style.height=`${r}px`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{_(M)&&(n(N,t),n(z,!1),ke(_(M),r,a,o,()=>{n(L,!1),n(B,!1),_(M)&&(_(M).style.height=`auto`)}))})})):(n(N,_(N)-_(W)),await x(),n(L,!0),_(M).style.height=`${r}px`,_(M).style.setProperty(`--transition-duration`,`${o/1e3}s`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{_(M)&&(n(N,t),n(z,!1),_(M).style.height=`${a}px`,setTimeout(()=>{n(L,!1),n(B,!1),_(M)&&(_(M).style.height=`auto`)},o))})}))},at=()=>{if(!_(M))return;n(z,!1),_e.track(`card_list_show_less_clicked`,{slug:S.slug,itemsPerRow:_(U),clickCount:_(P)});let e=_(K),t=e*_(U),r=w()?window:document.getElementById(`scrollable`),i=r instanceof Window?r.scrollY:r?.scrollTop??0,a=Te(_(M),t);if(r instanceof Window?r.scrollTo(0,i):r&&(r.scrollTop=i),_(M).querySelectorAll(`:scope > *`).length===0){n(N,e,!0),n(P,0);return}let o=a.currentHeight-90,s=a.targetHeight-90;n(R,!0),n(L,!0),_(M).style.height=`${o}px`;let c=()=>{n(N,e,!0),n(P,0),n(L,!1),n(R,!1),_(M)&&(_(M).style.height=`auto`)},l=E(o-s);Oe(_(M),o,s,w(),l,c)};var Q=Re();d(Q,()=>({...Ae,class:[`expandable-grid-container`,S.class],"data-expandable-grid":C,[re]:{"is-starting-view":_(Y)}}),void 0,void 0,void 0,`svelte-lrjd55`);var ot=c(Q);ee(ot,()=>_(J).styleTag);var st=a(ot,2),ct=e=>{var t=Pe(),n=c(t);f(n,()=>S.header),b(t),g(e,t)};r(st,e=>{S.header&&e(ct)});var $=a(st,2);let lt,ut;var dt=c($);f(dt,()=>S.items,()=>({visibleCount:_(nt),shouldShowViewAll:_(Je),itemsPerRow:_(U),isStartingView:_(Qe),estimatedVisibleCount:_(rt)}));var ft=a(dt,2),pt=e=>{var n=de(),r=t(n);f(r,()=>S.viewAllCard),g(e,n)};r(ft,e=>{_(Je)&&S.viewAllCard&&e(pt)}),b($),le($,e=>n(M,e),()=>_(M));var mt=a($,2),ht=e=>{var t=Fe(),n=c(t);{let e=i(()=>({displayCount:Math.min(_(rt),S.itemCount),totalCount:S.totalItemCount??S.itemCount}));f(n,()=>S.countingText,()=>_(e))}b(t),g(e,t)};r(mt,e=>{S.countingText&&(_(X)||_(Ze)||_(B))&&e(ht)});var gt=a(mt,2),_t=e=>{var t=Le();let n;var o=a(c(t),2);ue(o,()=>`${_(X)}-${_(Ze)}`,e=>{{let t=i(()=>_(X)?it:at),n=i(()=>_(L)||_(B)||A()||_(X)&&k()),a=i(()=>_(X)?`load-more-${S.slug}`:`show-less-${S.slug}`),o=i(()=>S.headingId?`${S.slug}-action ${S.headingId}`:void 0);ye(e,{variant:`subtle-link`,get onclick(){return _(t)},get disabled(){return _(n)},get"data-analytics"(){return _(a)},get"aria-labelledby"(){return _(o)},children:(e,t)=>{var n=Ie(),i=c(n),a=e=>{be(e,{get loading(){return k()},children:(e,t)=>{fe();var n=ne();v(e=>m(n,e),[()=>T()._(Me.loadMore)]),g(e,n)},$$slots:{default:!0}})},o=e=>{var t=ne();v(e=>m(t,e),[()=>T()._(Me.showLess)]),g(e,t)};r(i,e=>{_(X)?e(a):e(o,-1)}),b(n),v(()=>pe(n,`id`,`${S.slug}-action`)),g(e,n)},$$slots:{default:!0}})}}),fe(2),b(t),v(()=>n=se(t,1,`load-more-container svelte-lrjd55`,null,n,{"mt-5":!O(),"mt-2":O()})),g(e,t)};r(gt,e=>{(_(X)||_(Ze)||_(B))&&e(_t)}),b(Q),le(Q,e=>n(He,e),()=>_(He)),o(Q,(e,t)=>ge?.(e,t),()=>e=>n(Be,e.width,!0)),v(()=>{lt=se($,1,`expandable-grid svelte-lrjd55`,null,lt,{"is-transitioning":_(L),"is-shrinking":_(R)}),pe($,`data-test-visible-count`,_(rt)),ut=s($,``,ut,{"--js-items-per-row":_(U),"--js-column-gap":`${_(Ge)??``}px`,"--grid-bottom-extension":`90px`})}),g(y,Q),ie(),De()}export{C as i,A as n,S as r,ze as t};