import{c as $,m as i,g as F,e as z,s as K}from"./CdB5IfUT.js";import{c as p}from"./CvGTXoDv.js";function X({swiper:t,extendParams:N,on:r}){N({a11y:{enabled:!0,notificationClass:"swiper-notification",prevSlideMessage:"Previous slide",nextSlideMessage:"Next slide",firstSlideMessage:"This is the first slide",lastSlideMessage:"This is the last slide",paginationBulletMessage:"Go to slide {{index}}",slideLabelMessage:"{{index}} / {{slidesLength}}",containerMessage:null,containerRoleDescriptionMessage:null,containerRole:null,itemRoleDescriptionMessage:null,slideRole:"group",id:null,scrollOnFocus:!0,wrapperLiveRegion:!0}}),t.a11y={clicked:!1};let l=null,u,g,y=new Date().getTime();function m(e){const a=l;a.length!==0&&K(a,e)}function P(e=16){const a=()=>Math.round(16*Math.random()).toString(16);return"x".repeat(e).replace(/x/g,a)}function E(e){e=i(e),e.forEach(a=>{a.setAttribute("tabIndex","0")})}function L(e){e=i(e),e.forEach(a=>{a.setAttribute("tabIndex","-1")})}function v(e,a){e=i(e),e.forEach(n=>{n.setAttribute("role",a)})}function x(e,a){e=i(e),e.forEach(n=>{n.setAttribute("aria-roledescription",a)})}function B(e,a){e=i(e),e.forEach(n=>{n.setAttribute("aria-controls",a)})}function b(e,a){e=i(e),e.forEach(n=>{n.setAttribute("aria-label",a)})}function O(e,a){e=i(e),e.forEach(n=>{n.setAttribute("id",a)})}function G(e,a){e=i(e),e.forEach(n=>{n.setAttribute("aria-live",a)})}function M(e){e=i(e),e.forEach(a=>{a.setAttribute("aria-disabled",!0)})}function A(e){e=i(e),e.forEach(a=>{a.setAttribute("aria-disabled",!1)})}function f(e){if(e.keyCode!==13&&e.keyCode!==32)return;const a=t.params.a11y,n=e.target;if(!(t.pagination&&t.pagination.el&&(n===t.pagination.el||t.pagination.el.contains(e.target))&&!e.target.matches(p(t.params.pagination.bulletClass)))){if(t.navigation&&t.navigation.prevEl&&t.navigation.nextEl){const o=i(t.navigation.prevEl);i(t.navigation.nextEl).includes(n)&&(t.isEnd&&!t.params.loop||t.slideNext(),t.isEnd?m(a.lastSlideMessage):m(a.nextSlideMessage)),o.includes(n)&&(t.isBeginning&&!t.params.loop||t.slidePrev(),t.isBeginning?m(a.firstSlideMessage):m(a.prevSlideMessage))}t.pagination&&n.matches(p(t.params.pagination.bulletClass))&&n.click()}}function q(){if(t.params.loop||t.params.rewind||!t.navigation)return;const{nextEl:e,prevEl:a}=t.navigation;a&&(t.isBeginning?(M(a),L(a)):(A(a),E(a))),e&&(t.isEnd?(M(e),L(e)):(A(e),E(e)))}function k(){return t.pagination&&t.pagination.bullets&&t.pagination.bullets.length}function S(){return k()&&t.params.pagination.clickable}function H(){const e=t.params.a11y;k()&&t.pagination.bullets.forEach(a=>{t.params.pagination.clickable&&(E(a),t.params.pagination.renderBullet||(v(a,"button"),b(a,e.paginationBulletMessage.replace(/\{\{index\}\}/,z(a)+1)))),a.matches(p(t.params.pagination.bulletActiveClass))?a.setAttribute("aria-current","true"):a.removeAttribute("aria-current")})}const C=(e,a,n)=>{E(e),e.tagName!=="BUTTON"&&(v(e,"button"),e.addEventListener("keydown",f)),b(e,n),B(e,a)},R=e=>{g&&g!==e.target&&!g.contains(e.target)&&(u=!0),t.a11y.clicked=!0},I=()=>{u=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.destroyed||(t.a11y.clicked=!1)})})},T=e=>{y=new Date().getTime()},h=e=>{if(t.a11y.clicked||!t.params.a11y.scrollOnFocus||new Date().getTime()-y<100)return;const a=e.target.closest(`.${t.params.slideClass}, swiper-slide`);if(!a||!t.slides.includes(a))return;g=a;const n=t.slides.indexOf(a)===t.activeIndex,o=t.params.watchSlidesProgress&&t.visibleSlides&&t.visibleSlides.includes(a);n||o||e.sourceCapabilities&&e.sourceCapabilities.firesTouchEvents||(t.isHorizontal()?t.el.scrollLeft=0:t.el.scrollTop=0,requestAnimationFrame(()=>{u||(t.params.loop?t.slideToLoop(t.getSlideIndexWhenGrid(parseInt(a.getAttribute("data-swiper-slide-index"))),0):t.slideTo(t.getSlideIndexWhenGrid(t.slides.indexOf(a)),0),u=!1)}))},D=()=>{const e=t.params.a11y;e.itemRoleDescriptionMessage&&x(t.slides,e.itemRoleDescriptionMessage),e.slideRole&&v(t.slides,e.slideRole);const a=t.slides.length;e.slideLabelMessage&&t.slides.forEach((n,o)=>{const s=t.params.loop?parseInt(n.getAttribute("data-swiper-slide-index"),10):o,d=e.slideLabelMessage.replace(/\{\{index\}\}/,s+1).replace(/\{\{slidesLength\}\}/,a);b(n,d)})},U=()=>{const e=t.params.a11y;t.el.append(l);const a=t.el;e.containerRoleDescriptionMessage&&x(a,e.containerRoleDescriptionMessage),e.containerMessage&&b(a,e.containerMessage),e.containerRole&&v(a,e.containerRole);const n=t.wrapperEl,o=e.id||n.getAttribute("id")||`swiper-wrapper-${P(16)}`;if(O(n,o),e.wrapperLiveRegion){const c=t.params.autoplay&&t.params.autoplay.enabled?"off":"polite";G(n,c)}D();let{nextEl:s,prevEl:d}=t.navigation?t.navigation:{};s=i(s),d=i(d),s&&s.forEach(c=>C(c,o,e.nextSlideMessage)),d&&d.forEach(c=>C(c,o,e.prevSlideMessage)),S()&&i(t.pagination.el).forEach(W=>{W.addEventListener("keydown",f)}),F().addEventListener("visibilitychange",T),t.el.addEventListener("focus",h,!0),t.el.addEventListener("focus",h,!0),t.el.addEventListener("pointerdown",R,!0),t.el.addEventListener("pointerup",I,!0)};function V(){l&&l.remove();let{nextEl:e,prevEl:a}=t.navigation?t.navigation:{};e=i(e),a=i(a),e&&e.forEach(o=>o.removeEventListener("keydown",f)),a&&a.forEach(o=>o.removeEventListener("keydown",f)),S()&&i(t.pagination.el).forEach(s=>{s.removeEventListener("keydown",f)}),F().removeEventListener("visibilitychange",T),t.el&&typeof t.el!="string"&&(t.el.removeEventListener("focus",h,!0),t.el.removeEventListener("pointerdown",R,!0),t.el.removeEventListener("pointerup",I,!0))}r("beforeInit",()=>{l=$("span",t.params.a11y.notificationClass),l.setAttribute("aria-live","assertive"),l.setAttribute("aria-atomic","true")}),r("afterInit",()=>{t.params.a11y.enabled&&U()}),r("slidesLengthChange snapGridLengthChange slidesGridLengthChange",()=>{t.params.a11y.enabled&&D()}),r("fromEdge toEdge afterInit lock unlock",()=>{t.params.a11y.enabled&&q()}),r("paginationUpdate",()=>{t.params.a11y.enabled&&H()}),r("destroy",()=>{t.params.a11y.enabled&&V()})}export{X as A};
