(function(){const f=[];function c(t){return htmx.closest(t,"[data-loading-states]")||document.body}function u(t,n){if(document.body.contains(t)){n()}}function o(t,n){const a=htmx.closest(t,"[data-loading-path]");if(!a){return true}return a.getAttribute("data-loading-path")===n}function e(t,n,a,o){const i=htmx.closest(t,"[data-loading-delay]");if(i){const c=i.getAttribute("data-loading-delay")||200;const e=setTimeout(function(){a();f.push(function(){u(n,o)})},c);f.push(function(){u(n,function(){clearTimeout(e)})})}else{a();f.push(function(){u(n,o)})}}function s(t,n,a){return Array.from(htmx.findAll(t,"["+n+"]")).filter(function(t){return o(t,a)})}function r(t){if(t.getAttribute("data-loading-target")){return Array.from(htmx.findAll(t.getAttribute("data-loading-target")))}return[t]}htmx.defineExtension("loading-states",{onEvent:function(t,n){if(t==="htmx:beforeRequest"){const a=c(n.target);const o=["data-loading","data-loading-class","data-loading-class-remove","data-loading-disable","data-loading-aria-busy"];const i={};o.forEach(function(t){i[t]=s(a,t,n.detail.pathInfo.requestPath)});i["data-loading"].forEach(function(n){r(n).forEach(function(t){e(n,t,function(){t.style.display=n.getAttribute("data-loading")||"inline-block"},function(){t.style.display="none"})})});i["data-loading-class"].forEach(function(t){const a=t.getAttribute("data-loading-class").split(" ");r(t).forEach(function(n){e(t,n,function(){a.forEach(function(t){n.classList.add(t)})},function(){a.forEach(function(t){n.classList.remove(t)})})})});i["data-loading-class-remove"].forEach(function(t){const a=t.getAttribute("data-loading-class-remove").split(" ");r(t).forEach(function(n){e(t,n,function(){a.forEach(function(t){n.classList.remove(t)})},function(){a.forEach(function(t){n.classList.add(t)})})})});i["data-loading-disable"].forEach(function(n){r(n).forEach(function(t){e(n,t,function(){t.disabled=true},function(){t.disabled=false})})});i["data-loading-aria-busy"].forEach(function(n){r(n).forEach(function(t){e(n,t,function(){t.setAttribute("aria-busy","true")},function(){t.removeAttribute("aria-busy")})})})}if(t==="htmx:beforeOnLoad"){while(f.length>0){f.shift()()}}}})})();