1import v from"woody_library_woody_component";class _ extends v{#e=null;#t=null;#o={card:".card",active_toggler_class:"active",togglers:".focus-map-toggler-list",togglers_item:".card-toggler"};constructor(){super()}init(a){super.init(a),this.style.display="block",this.config=Object.assign(this.#o,this.config);const r=this.querySelectorAll(this.config.togglers_item);r?.length>0&&r.forEach(l=>{l.classList.contains(this.config.active_toggler_class)&&(this.#e=l.dataset.index),l.addEventListener("click",s=>{this.dispatchEvent(new CustomEvent("togglerclick",{detail:{index:s.target.dataset.index}})),this.updateCardContent(s.target.dataset.index)}),l.addEventListener("keydown",s=>{(s.key==="Enter"||s.key===" ")&&(this.dispatchEvent(new CustomEvent("togglerclick",{detail:{index:s.target.dataset.index}})),this.updateCardContent(s.target.dataset.index))})}),this.updateTogglers(),this.dispatchEvent(new CustomEvent("initialized"))}getActiveTogglerIndex(){const a=this.getActiveToggler();return a?a.dataset.index:null}getActiveToggler(){return this.querySelector(`${this.config.togglers_item}.${this.config.active_toggler_class}`)}getTogglerForIndex(a){return this.querySelector(`${this.config.togglers_item}[data-index='${a}']`)}updateCardContent(a){if(a==this.#e)return;const r=this.getTogglerForIndex(a);if(!r){console.warn("CardTogglerComponent.updateCardContent - no toggler found for data-index='"+a+"'");return}const l=r.dataset.postId,s=r.dataset.contentIndex,t=this.closest(".page-section").id.replace("pageSection-",""),e=this.closest(".woody-component-focus")||this.closest(".woody-component-focus-map"),g=e!==null?e.parentNode:"",o=g!==""?Array.from(g.parentNode.children).indexOf(g):"",f=this.closest(".woody-component-tabs"),m=f!==null,d=window.globals.current_lang?window.globals.current_lang:"";let c="";if(t!==""&&o>=0&&s!=="")if(m){const i=f.parentNode.parentNode,x=i!==""?Array.from(i.children).indexOf(f.parentNode):"",u=this.closest(".tabs-panel"),h=u!==null?u.parentNode:"",p=h!==""?Array.from(h.children).indexOf(u):"";c=`section_${t}_section_content_${x}_tabs_${p}_light_section_content_${o}_content_selection_${s}_custom_content`}else c=`section_${t}_section_content_${o}_content_selection_${s}_custom_content`;this.querySelectorAll(`.${this.config.active_toggler_class}`).forEach(i=>i.classList.remove(this.config.active_toggler_class)),r.classList.add(this.config.active_toggler_class),this.#e=a,this.updateTogglers();let n=this.querySelector(this.config.card);if((l||c)&&n){n.classList.remove("card-loaded"),n.classList.add("skeleton-card");const i=n.getAttribute("data-card-path")||"";let x=n.getAttribute("class").match(/\bratio[^\s]*/)[0],u=n.getAttribute("data-card-display-options")||"",h=btoa(u);fetch(`/wp-json/woody/page/preview?lang=${d}&post=${l}&field=${c}¤t_id=${window.globals.post_id}&html_format=true&tpl_twig=${i}&ratio=${x}&display=${h}`).then(p=>p.json()).then(p=>{i&&this.appendCardContent(p,n,i,u)}).catch(p=>{console.warn("CardTogglerComponent.updateCardContent - error : ",p)})}}updateTogglers(){if(this.config.togglers&&!this.#t&&(this.#t=this.querySelector(this.config.togglers)),this.#t!==null){let e=function(g,o,f,m){let d=null;const c=g[o],n=c!=null?c.closest(".focus-map-toggler-list"):null;if(c!=null&&c.classList.add(f),n!=null&&n.dataset.labelDefault&&n.dataset.labelPrev&&n.dataset.labelNext)switch(m){case"prev":d=n.dataset.labelDefault+" "+n.dataset.labelPrev;break;case"next":d=n.dataset.labelDefault+" "+n.dataset.labelNext;break;case"index":default:d=n.dataset.labelDefault+" "+(parseInt(c.dataset.contentIndex)+1);break}c!=null&&d!=null&&c.setAttribute("aria-label",d)};const a=this.#t.querySelector(".focus-map-toggler--next"),r=this.#t.querySelector(".focus-map-toggler--next-next"),l=this.#t.querySelector(".focus-map-toggler--prev"),s=this.#t.querySelector(".focus-map-toggler--prev-prev");a&&a.classList.remove("focus-map-toggler--next"),r&&r.classList.remove("focus-map-toggler--next-next"),l&&l.classList.remove("focus-map-toggler--prev"),s&&s.classList.remove("focus-map-toggler--prev-prev");const t=this.#t.querySelectorAll(this.config.togglers_item);t.forEach((g,o)=>{g.classList.contains(this.config.active_toggler_class)&&(o===0?(e(t,o+1,"focu
1s-map-toggler--next","next"),e(t,o+2,"focus-map-toggler--next-next","index")):o===t.length-1?(e(t,o-1,"focus-map-toggler--prev","prev"),e(t,o-2,"focus-map-toggler--prev-prev","index")):o===1?(e(t,o-1,"focus-map-toggler--prev","prev"),e(t,o+1,"focus-map-toggler--next","next"),e(t,o+2,"focus-map-toggler--next-next","index")):o===t.length-2?(e(t,o-1,"focus-map-toggler--prev","prev"),e(t,o-2,"focus-map-toggler--prev-prev","index"),e(t,o+1,"focus-map-toggler--next","next")):(e(t,o-1,"focus-map-toggler--prev","prev"),e(t,o-2,"focus-map-toggler--prev-prev","index"),e(t,o+1,"focus-map-toggler--next","next"),e(t,o+2,"focus-map-toggler--next-next","index")))})}}appendCardContent(a,r,l,s){const t=r.parentNode;if(r.outerHTML=a,t!==null){let e=t.querySelector(this.config.card);e&&(e.setAttribute("data-card-path",l),s&&e.setAttribute("data-card-display-options",s),e.classList.add("card-loaded"),e.querySelector(".card-link")&&e.querySelector(".card-link").focus())}}}export{_ as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.