(function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else{e.htmx=t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";var t=["get","post","put","delete","patch"];function a(e){if(e==="null"||e==="false"||e===""){return null}else if(e.lastIndexOf("ms")===e.length-2){return parseFloat(e.substr(0,e.length-2))}else if(e.lastIndexOf("s")===e.length-1){return parseFloat(e.substr(0,e.length-1))*1e3}else{return parseFloat(e)}}function u(e,t){return e.getAttribute&&e.getAttribute(t)}function w(e,t){return u(e,t)||u(e,"data-"+t)}function o(e){return e.parentElement}function E(){return document}function l(e,t){if(t(e)){return e}else if(o(e)){return l(o(e),t)}else{return null}}function L(e,t){var r=null;l(e,function(e){return r=w(e,t)});return r}function s(e,t){var r=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return r&&r.call(e,t)}function r(e){var t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;var r=t.exec(e);if(r){return r[1].toLowerCase()}else{return""}}function n(e,t){var r=new DOMParser;var n=r.parseFromString(e,"text/html");var i=n.body;while(t>0){t--;i=i.firstChild}if(i==null){i=E().createDocumentFragment()}return i}function f(e){var t=r(e);switch(t){case"thead":case"tbody":case"tfoot":case"colgroup":case"caption":return n(""+e+"
",1);case"col":return n(""+e+"
",2);case"tr":return n(""+e+"
",2);case"td":case"th":return n(""+e+"
",3);default:return n(e,0)}}function i(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function c(e){return i(e,"Function")}function v(e){return i(e,"Object")}function O(e){var t="htmx-internal-data";var r=e[t];if(!r){r=e[t]={}}return r}function h(e){var t=[];if(e){for(var r=0;r=0}function m(e){return E().body.contains(e)}function g(e){return e.split(/\s+/)}function T(e,t){for(var r in t){if(t.hasOwnProperty(r)){e[r]=t[r]}}return e}function e(e){return eval(e)}function p(t){var e=htmx.on("load.htmx",function(e){t(e.detail.elt)});return e}function y(){htmx.logger=function(e,t,r){if(console){console.log(t,e,r)}}}function x(e,t){if(t){return e.querySelector(t)}else{return E().body.querySelector(e)}}function b(e,t){if(t){return e.querySelectorAll(t)}else{return E().body.querySelectorAll(e)}}function S(e,t){if(t){setTimeout(function(){S(e)},t)}else{e.parentElement.removeChild(e)}}function H(e,t,r){if(r){setTimeout(function(){H(e,t)},r)}else{e.classList.add(t)}}function N(e,t,r){if(r){setTimeout(function(){N(e,t)},r)}else{e.classList.remove(t)}}function q(e,t){e.classList.toggle(t)}function X(e,t){C(e.parentElement.children,function(e){N(e,t)});H(e,t)}function A(e,t){do{if(e==null||s(e,t))return e}while(e=e&&o(e))}function R(e,t,r){if(c(t)){return{target:E().body,event:e,listener:t}}else{return{target:e,event:t,listener:r}}}function k(t,r,n){at(function(){var e=R(t,r,n);e.target.addEventListener(e.event,e.listener)});var e=c(r);return e?r:n}function D(t,r,n){at(function(){var e=R(t,r,n);e.target.removeEventListener(e.event,e.listener)});return c(r)?r:n}function M(e){var t=l(e,function(e){return w(e,"hx-target")!==null});if(t){var r=w(t,"hx-target");if(r==="this"){return t}else if(r.indexOf("closest ")===0){return A(e,r.substr(8))}else{return E().querySelector(r)}}else{var n=O(e);if(n.boosted){return E().body}else{return e}}}function I(t,r){C(t.attributes,function(e){if(!r.hasAttribute(e.name)){t.removeAttribute(e.name)}});C(r.attributes,function(e){t.setAttribute(e.name,e.value)})}function F(e,t){var r=ot(t);for(var n=0;n0){var i=r.firstChild;e.insertBefore(i,t);if(i.nodeType!==Node.TEXT_NODE){n.tasks.push(U(i))}}}function B(e){var t=O(e);if(t.webSocket){t.webSocket.close()}if(t.sseEventSource){t.sseEventSource.close()}if(e.children){C(e.children,function(e){B(e)})}}function W(e,t,r){if(e.tagName==="BODY"){return K(e,t)}else{var n=e.previousSibling;z(o(e),e,t,r);if(n==null){var i=o(e).firstChild}else{var i=n.nextSibling}while(i&&i!=e){r.elts.push(i);i=i.nextSibling}B(e);o(e).removeChild(e)}}function V(e,t,r){return z(e,e.firstChild,t,r)}function G(e,t,r){return z(o(e),e,t,r)}function Y(e,t,r){return z(e,null,t,r)}function _(e,t,r){return z(o(e),e.nextSibling,t,r)}function K(e,t,r){var n=e.firstChild;z(e,n,t,r);if(n){while(n.nextSibling){e.removeChild(n.nextSibling)}e.removeChild(n)}}function Q(e,t){var r=L(e,"hx-select");if(r){var n=E().createDocumentFragment();C(t.querySelectorAll(r),function(e){n.appendChild(e)});t=n}return t}function Z(e,t,r,n,i){switch(e){case"outerHTML":W(r,n,i);return;case"afterbegin":V(r,n,i);return;case"beforebegin":G(r,n,i);return;case"beforeend":Y(r,n,i);return;case"afterend":_(r,n,i);return;default:var o=ot(t);for(var a=0;ahtmx.config.historyCacheSize){i.shift()}localStorage.setItem("htmx-history-cache",JSON.stringify(i))}function Re(e){var t=JSON.parse(localStorage.getItem("htmx-history-cache"))||[];for(var r=0;r=200&&this.status<400){Ne(E().body,"historyCacheMissLoad.htmx",i);var e=f(this.response);e=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;var t=Xe();var r=$e(t);K(t,e,r);Me(r.tasks);qe=n}else{Oe(E().body,"historyCacheMissLoadError.htmx",i)}};e.send()}function Fe(e){ke(qe);e=e||location.pathname+location.search;Ne(E().body,"historyRestore.htmx",{path:e});var t=Re(e);if(t){var r=f(t.content);var n=Xe();var i=$e(n);K(n,r,i);Me(i.tasks);document.title=t.title;window.scrollTo(0,t.scroll);qe=e}else{Ie(e)}}function Pe(e){return L(e,"hx-push-url")==="true"||e.tagName==="A"&&O(e).boosted}function je(e){Ue(e,"add")}function Je(e){Ue(e,"remove")}function Ue(e,t){var r=L(e,"hx-indicator");if(r){var n=E().querySelectorAll(r)}else{n=[e]}C(n,function(e){e.classList[t].call(e.classList,"htmx-request")})}function ze(e,t){for(var r=0;r0){r["swapStyle"]=n[0];for(var i=1;i=200&&this.status<400){if(this.status===286){re(a)}if(this.status!==204){if(!Ne(a,"beforeSwap.htmx",S))return;var i=this.response;Te(a,function(e){i=e.transformResponse(i,f,a)});if(n){ke()}var o=Qe(a);l.classList.add("htmx-swapping");var e=function(){try{var e=$e(l);$(o.swapStyle,l,a,i,e);l.classList.remove("htmx-swapping");C(e.elts,function(e){if(e.classList){e.classList.add("htmx-settling")}});Ne(a,"afterSwap.htmx",S);if(p){location.hash=p}var t=function(){C(e.tasks,function(e){e.call()});C(e.elts,function(e){if(e.classList){e.classList.remove("htmx-settling")}});if(n){De(r||u)}Ne(a,"afterSettle.htmx",S)};if(o.settleDelay>0){setTimeout(t,o.settleDelay)}else{t()}}catch(e){Oe(a,"swapError.htmx",S);throw e}};if(o.swapDelay>0){setTimeout(e,o.swapDelay)}else{e()}}}else{Oe(a,"responseError.htmx",T({error:"Response Status Error Code "+this.status+" from "+u},S))}}catch(e){Oe(a,"onLoadError.htmx",T({error:e},S));throw e}finally{Je(a);Ne(a,"afterRequest.htmx",S);Ne(a,"afterOnLoad.htmx",S);s()}};f.onerror=function(){Je(a);Oe(a,"afterRequest.htmx",S);Oe(a,"sendError.htmx",S);s()};if(!Ne(a,"beforeRequest.htmx",S))return s();je(a);f.send(e==="get"?null:Ze(f,a,h))}var tt={};function rt(){return{onEvent:function(e,t){return true},transformResponse:function(e,t,r){return e},isInlineSwap:function(e){return false},handleSwap:function(e,t,r,n){return false},encodeParameters:function(e,t,r){return null}}}function nt(e,t){tt[e]=T(rt(),t)}function it(e){delete tt[e]}function ot(e,r){if(e==null){return r}if(r==null){r=[]}var t=w(e,"hx-ext");if(t){C(t.split(","),function(e){e=e.replace(/ /g,"");var t=tt[e];if(t&&r.indexOf(t)<0){r.push(t)}})}return ot(o(e),r)}function at(e){if(E().readyState!=="loading"){e()}else{E().addEventListener("DOMContentLoaded",e)}}(function(){var e=ut();if(e===null||e.includeIndicatorStyles!==false){E().head.insertAdjacentHTML("beforeend","")}})();function ut(){var e=E().querySelector('meta[name="htmx-config"]');if(e){return JSON.parse(e.content)}else{return null}}function lt(){var e=ut();if(e){htmx.config=T(htmx.config,e)}}at(function(){lt();var e=E().body;we(e);Ne(e,"load.htmx",{});window.onpopstate=function(){Fe()}});return{onLoad:p,process:we,on:k,off:D,trigger:Ne,find:x,findAll:b,closest:A,remove:S,addClass:H,removeClass:N,toggleClass:q,takeClass:X,defineExtension:nt,removeExtension:it,logAll:y,logger:null,config:{historyEnabled:true,historyCacheSize:10,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:100,includeIndicatorStyles:true},parseInterval:a,_:e,createEventSource:function(e){return new EventSource(e,{withCredentials:true})},createWebSocket:function(e){return new WebSocket(e,[])}}}()});