var t=(function(h){if(!(typeof window>"u")&&window){var p=function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=document.createElement(n);return Object.keys(r).forEach(function(d){a.setAttribute(d,r[d])}),a},A=0,b=function(e,n){if(e.getAttribute("maxlength")){var r=e.dataset.counterLabel||n.counterLabel,a=(function(f){var m=f.assistDelay,i=f.counterClassName,c=p("span",{class:i,"aria-hidden":"true"}),u=p("span",{style:"position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px, 1px, 1px, 1px);clip-path:inset(50%);white-space:nowrap;",id:"short-and-sweet-counter-".concat(A++),role:"status","aria-live":"polite"}),l=document.createDocumentFragment();l.appendChild(c),l.appendChild(u);var s=null;return{id:u.id,fragment:l,updateText:function(o){c.textContent=o},updateAssist:function(o,g){clearTimeout(s),g?u.textContent=o:s=setTimeout(function(){u.textContent=o},m)},syncAssist:function(){clearTimeout(s),u.textContent=c.textContent},resetAssist:function(){clearTimeout(s),u.textContent=""}}})(n);e.setAttribute("aria-controls",a.id),n.append(e,a.fragment);var d=!0,x=function(){var m,i=(m=e.getAttribute("maxlength"))!=null?parseInt(m,10):null,c=e.value.length>i;c&&(function(o){e.value=e.value.substr(0,o)})(i);var u,l=e.value.length,s=(u={maxlength:i,length:l,remaining:i-l},r.replace(/(?:{([a-zA-Z]+)})/g,function(o,g){return u[g]}));a.updateText(s),d?d=!1:a.updateAssist(s,c)};e.addEventListener("focus",a.syncAssist),e.addEventListener("blur",a.resetAssist),e.addEventListener("input",x),x()}},C={counterClassName:"short-and-sweet-counter",counterLabel:"{remaining} characters left",assistDelay:2e3,append:function(e,n){e.parentNode.appendChild(n)}},v=function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return n.map(function(a){return b(a,Object.assign({},C,r))})};return function(e,n){return typeof e=="string"?v((r=document.querySelectorAll(e),Array.prototype.slice.call(r)),n):v([e],n)[0];var r}}})();t("textarea.charcount,input.charcount",{counterClassName:"small text-muted"}),document.addEventListener("joomla:updated",h=>{h.target.querySelectorAll("textarea.charcount,input.charcount").forEach(p=>t(p,{counterClassName:"small text-muted"}))});