/* @ecl/web-components-description-list - 0.13.0 Built on 2024-01-19T09:41:07.282Z */
var ECL=function(e){"use strict";function s(e,t){return void 0===t&&(t=document),[].slice.call(t.querySelectorAll(e))}var t=function(){function i(e,t){var t=void 0===t?{}:t,i=t.listsSelector,i=void 0===i?"[data-ecl-description-list-collapsible]":i,s=t.visibleItemsSelector,s=void 0===s?"data-ecl-description-list-visible-items":s,l=t.moreItemLabelSelector,l=void 0===l?"data-ecl-description-list-more-label":l,t=t.attachClickListener,t=void 0===t||t;if(!e||e.nodeType!==Node.ELEMENT_NODE)throw new TypeError("DOM element should be given to initialize this widget.");this.element=e,this.moreItemLabelSelector=l,this.listsSelector=i,this.attachClickListener=t,this.visibleItemsSelector=s,this.moreItemLabel=null,this.lists=null,this.handleClickOnMore=this.handleClickOnMore.bind(this)}i.autoInit=function(e,t){t=(void 0===t?{}:t).DESCRIPTION_LIST,t=new i(e,void 0===t?{}:t);return t.init(),e.ECLDescriptionList=t};var e=i.prototype;return e.init=function(){var i=this;if(!ECL)throw new TypeError("Called init but ECL is not present");ECL.components=ECL.components||new Map,this.moreItemLabel=this.element.getAttribute(this.moreItemLabelSelector),this.visibleItems=this.element.getAttribute(this.visibleItemsSelector),this.lists=s(this.listsSelector,this.element),this.lists[0]&&0<this.visibleItems&&this.moreItemLabel&&(this.lists.forEach(function(e){var t;e.children&&e.children.length>i.visibleItems&&((t=document.createElement("a")).classList.add("ecl-link","ecl-description-list__see_more"),t.href="#",t.innerHTML=i.moreItemLabel,e.appendChild(t),i.showHide(s(".ecl-description-list__definition-item",e)),i.attachClickListener)&&t.addEventListener("click",i.handleClickOnMore)}),this.element.setAttribute("data-ecl-auto-initialized","true"),ECL.components.set(this.element,this))},e.showHide=function(e){if(e)for(var t=Array.from(e),e="ecl-description-list__definition-item",i=e+"--hidden",s=e+"--last-visible",l=0;l<t.length;l+=1){var n=t[l];l<this.visibleItems?(n.classList.remove(i),n.classList.remove(s)):l>=this.visibleItems&&n.classList.add(i),l===this.visibleItems-1?n.classList.add(s):n.classList.remove(s)}},e.destroy=function(){var e,t=this;this.attachClickListener&&0<this.visibleItems&&(e=s(".ecl-description-list__see_more"))[0]&&e.forEach(function(e){e.removeEventListener("click",t.handleClickOnMore)}),this.element&&(this.element.removeAttribute("data-ecl-auto-initialized"),ECL.components.delete(this.element))},e.handleClickOnMore=function(e){e.preventDefault();var t=e.target.parentNode;this.element.contains(t)&&(Array.from(t.children).forEach(function(e){e.classList.remove("ecl-description-list__definition-item--hidden"),e.classList.remove("ecl-description-list__definition-item--last-visible")}),e.target.remove())},i}();return e.DescriptionList=t,e.default=t,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
