(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 v={onLoad:b,process:Ye,on:P,off:U,trigger:it,ajax:zt,find:S,findAll:E,closest:D,remove:C,addClass:A,removeClass:L,toggleClass:T,takeClass:O,defineExtension:Bt,removeExtension:$t,logAll:w,logger:null,config:{historyEnabled:true,historyCacheSize:10,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:100,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",attributesToSettle:["class","style","width","height"]},parseInterval:f,_:e,createEventSource:function(e){return new EventSource(e,{withCredentials:true})},createWebSocket:function(e){return new WebSocket(e,[])}};var t=["get","post","put","delete","patch"];var n=t.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function f(e){if(e==undefined){return undefined}if(e.slice(-2)=="ms"){return parseFloat(e.slice(0,-2))||undefined}if(e.slice(-1)=="s"){return parseFloat(e.slice(0,-1))*1e3||undefined}return parseFloat(e)||undefined}function l(e,t){return e.getAttribute&&e.getAttribute(t)}function o(e,t){return e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function R(e,t){return l(e,t)||l(e,"data-"+t)}function s(e){return e.parentElement}function q(){return document}function c(e,t){if(t(e)){return e}else if(s(e)){return c(s(e),t)}else{return null}}function H(e,t){var r=null;c(e,function(e){return r=R(e,t)});return r}function h(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 i(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=q().createDocumentFragment()}return i}function d(e){var t=r(e);switch(t){case"thead":case"tbody":case"tfoot":case"colgroup":case"caption":return i(""+e+"
",1);case"col":return i(""+e+"
",2);case"tr":return i(""+e+"
",2);case"td":case"th":return i(""+e+"
",3);case"script":return i("
"+e+"
",1);default:return i(e,0)}}function a(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function u(e){return a(e,"Function")}function g(e){return a(e,"Object")}function N(e){var t="htmx-internal-data";var r=e[t];if(!r){r=e[t]={}}return r}function p(e){var t=[];if(e){for(var r=0;r=0}function I(e){return q().body.contains(e)}function y(e){return e.trim().split(/\s+/)}function M(e,t){for(var r in t){if(t.hasOwnProperty(r)){e[r]=t[r]}}return e}function x(e){try{return JSON.parse(e)}catch(e){nt(e);return null}}function e(e){return eval(e)}function b(t){var e=v.on("htmx:load",function(e){t(e.detail.elt)});return e}function w(){v.logger=function(e,t,r){if(console){console.log(t,e,r)}}}function S(e,t){if(t){return e.querySelector(t)}else{return S(q(),e)}}function E(e,t){if(t){return e.querySelectorAll(t)}else{return E(q(),e)}}function C(e,t){e=X(e);if(t){setTimeout(function(){C(e)},t)}else{e.parentElement.removeChild(e)}}function A(e,t,r){e=X(e);if(r){setTimeout(function(){A(e,t)},r)}else{e.classList.add(t)}}function L(e,t,r){e=X(e);if(r){setTimeout(function(){L(e,t)},r)}else{e.classList.remove(t)}}function T(e,t){e=X(e);e.classList.toggle(t)}function O(e,t){e=X(e);k(e.parentElement.children,function(e){L(e,t)});A(e,t)}function D(e,t){e=X(e);do{if(e==null||h(e,t))return e}while(e=e&&s(e))}function X(e){if(a(e,"String")){return S(e)}else{return e}}function F(e,t,r){if(u(t)){return{target:q().body,event:e,listener:t}}else{return{target:X(e),event:t,listener:r}}}function P(t,r,n){Zt(function(){var e=F(t,r,n);e.target.addEventListener(e.event,e.listener)});var e=u(r);return e?r:n}function U(t,r,n){Zt(function(){var e=F(t,r,n);e.target.removeEventListener(e.event,e.listener)});return u(r)?r:n}function z(e){var t=c(e,function(e){return R(e,"hx-target")!==null});if(t){var r=R(t,"hx-target");if(r==="this"){return t}else if(r.indexOf("closest ")===0){return D(e,r.substr(8))}else if(r.indexOf("find ")===0){return S(e,r.substr(5))}else{return q().querySelector(r)}}else{var n=N(e);if(n.boosted){return q().body}else{return e}}}function j(e){var t=v.config.attributesToSettle;for(var r=0;r0){i=e.substr(0,e.indexOf(":"));n=e.substr(e.indexOf(":")+1,e.length)}else{i=e}var a=q().querySelector(n);if(a){var o;o=q().createDocumentFragment();o.appendChild(t);if(!_(i,a)){o=t}oe(i,a,a,o,r)}else{t.parentNode.removeChild(t);et(q().body,"htmx:oobErrorNoTarget",{content:t})}return e}function B(e,r){k(E(e,"[hx-swap-oob], [data-hx-swap-oob]"),function(e){var t=R(e,"hx-swap-oob");if(t!=null){W(t,e,r)}})}function $(e){k(E(e,"[hx-preserve], [data-hx-preserve]"),function(e){var t=R(e,"id");var r=q().getElementById(t);e.parentNode.replaceChild(r,e)})}function J(n,e,i){k(e.querySelectorAll("[id]"),function(e){if(e.id&&e.id.length>0){var t=n.querySelector(e.tagName+"[id='"+e.id+"']");if(t&&t!==n){var r=e.cloneNode();V(e,t);i.tasks.push(function(){V(e,r)})}}})}function Z(e){return function(){Ye(e);$e(e);G(e);it(e,"htmx:load")}}function G(e){var t="[autofocus]";var r=h(e,t)?e:e.querySelector(t);if(r!=null){r.focus()}}function Y(e,t,r,n){J(e,r,n);while(r.childNodes.length>0){var i=r.firstChild;e.insertBefore(i,t);if(i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.COMMENT_NODE){n.tasks.push(Z(i))}}}function K(e){var t=N(e);if(t.webSocket){t.webSocket.close()}if(t.sseEventSource){t.sseEventSource.close()}if(e.children){k(e.children,function(e){K(e)})}}function Q(e,t,r){if(e.tagName==="BODY"){return ie(e,t)}else{var n=e.previousSibling;Y(s(e),e,t,r);if(n==null){var i=s(e).firstChild}else{var i=n.nextSibling}N(e).replacedWith=i;while(i&&i!==e){if(i.nodeType===Node.ELEMENT_NODE){r.elts.push(i)}i=i.nextElementSibling}K(e);s(e).removeChild(e)}}function ee(e,t,r){return Y(e,e.firstChild,t,r)}function te(e,t,r){return Y(s(e),e,t,r)}function re(e,t,r){return Y(e,null,t,r)}function ne(e,t,r){return Y(s(e),e.nextSibling,t,r)}function ie(e,t,r){var n=e.firstChild;Y(e,n,t,r);if(n){while(n.nextSibling){K(n.nextSibling);e.removeChild(n.nextSibling)}K(n);e.removeChild(n)}}function ae(e,t){var r=H(e,"hx-select");if(r){var n=q().createDocumentFragment();k(t.querySelectorAll(r),function(e){n.appendChild(e)});t=n}return t}function oe(e,t,r,n,i){switch(e){case"none":return;case"outerHTML":Q(r,n,i);return;case"afterbegin":ee(r,n,i);return;case"beforebegin":te(r,n,i);return;case"beforeend":re(r,n,i);return;case"afterend":ne(r,n,i);return;default:var a=Jt(t);for(var o=0;o([\s\S]+?)<\/title>/im;function se(e){var t=ue.exec(e);if(t){return t[1]}}function le(e,t,r,n,i){var a=se(n);if(a){var o=S("title");if(o){o.innerHTML=a}else{window.document.title=a}}var u=d(n);if(u){B(u,i);$(u);u=ae(r,u);return oe(e,r,t,u,i)}}function fe(e,t,r){var n=e.getResponseHeader(t);if(n.indexOf("{")===0){var i=x(n);for(var a in i){if(i.hasOwnProperty(a)){var o=i[a];if(!g(o)){o={value:o}}it(r,a,o)}}}else{it(r,n,[])}}var ce=/\s/;var he=/[\s,]/;var ve=/[_$a-zA-Z]/;var de=/[_$a-zA-Z0-9]/;var ge=['"',"'","/"];var pe=/[^\s]/;function me(e){var t=[];var r=0;while(r0){var a=e[0];if(a==="]"){r--;if(r===0){if(i===null){n=n+"true"}e.shift();n+=")})";try{var o=Function(n)();o.source=n;return o}catch(e){et(q().body,"htmx:syntax:error",{error:e,source:n});return null}}}else if(a==="["){r++}if(ye(a,i,t)){n+="(("+t+"."+a+") ? ("+t+"."+a+") : (window."+a+"))"}else{n=n+a}i=e.shift()}}}function be(e,t){var r="";while(e.length>0&&!e[0].match(t)){r+=e.shift()}return r}function we(e){var t=R(e,"hx-trigger");var r=[];if(t){var n=me(t);do{be(n,pe);var i=n.length;var a=be(n,/[,\[\s]/);if(a!==""){if(a==="every"){var o={trigger:"every"};be(n,pe);o.pollInterval=f(be(n,ce));r.push(o)}else if(a.indexOf("sse:")===0){r.push({trigger:"sse",sseEvent:a.substr(4)})}else{var u={trigger:a};var s=xe(n,"event");if(s){u.eventFilter=s}while(n.length>0&&n[0]!==","){be(n,pe);var l=n.shift();if(l==="changed"){u.changed=true}else if(l==="once"){u.once=true}else if(l==="delay"&&n[0]===":"){n.shift();u.delay=f(be(n,he))}else if(l==="from"&&n[0]===":"){n.shift();u.from=be(n,he)}else if(l==="throttle"&&n[0]===":"){n.shift();u.throttle=f(be(n,he))}else{et(e,"htmx:syntax:error",{token:n.shift()})}}r.push(u)}}if(n.length===i){et(e,"htmx:syntax:error",{token:n.shift()})}be(n,pe)}while(n[0]===","&&n.shift())}if(r.length>0){return r}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,"input, textarea, select")){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function Se(e){N(e).cancelled=true}function Ee(e,t,r,n){var i=N(e);i.timeout=setTimeout(function(){if(I(e)&&i.cancelled!==true){jt(t,r,e);Ee(e,t,R(e,"hx-"+t),n)}},n)}function Ce(e){return location.hostname===e.hostname&&l(e,"href")&&l(e,"href").indexOf("#")!==0}function Ae(t,r,e){if(t.tagName==="A"&&Ce(t)||t.tagName==="FORM"){r.boosted=true;var n,i;if(t.tagName==="A"){n="get";i=l(t,"href")}else{var a=l(t,"method");n=a?a.toLowerCase():"get";i=l(t,"action")}e.forEach(function(e){Re(t,n,i,r,e,true)})}}function Le(e){return e.tagName==="FORM"||h(e,'input[type="submit"], button')&&D(e,"form")!==null||e.tagName==="A"&&e.href&&e.href.indexOf("#")!==0}function Te(e,t){return N(e).boosted&&e.tagName==="A"&&t.type==="click"&&t.ctrlKey}function Oe(e,t){var r=e.eventFilter;if(r){try{return r(t)!==true}catch(e){et(q().body,"htmx:eventFilter:error",{error:e,source:r.source});return true}}return false}function Re(n,i,a,e,o,u){var s=n;if(o.from){s=S(o.from)}var l=function(e){if(!I(n)){s.removeEventListener(o.trigger,l);return}if(Oe(o,e)){return}if(Te(n,e)){return}if(u||Le(n)){e.preventDefault()}var t=N(e);var r=N(n);if(!t.handled){t.handled=true;if(o.once){if(r.triggeredOnce){return}else{r.triggeredOnce=true}}if(o.changed){if(r.lastValue===n.value){return}else{r.lastValue=n.value}}if(r.delayed){clearTimeout(r.delayed)}if(r.throttle){return}if(o.throttle){r.throttle=setTimeout(function(){jt(i,a,n,e);r.throttle=null},o.throttle)}else if(o.delay){r.delayed=setTimeout(function(){jt(i,a,n,e)},o.delay)}else{jt(i,a,n,e)}}};e.trigger=o.trigger;e.eventListener=l;s.addEventListener(o.trigger,l)}var qe=false;var He=null;function Ne(){if(!He){He=function(){qe=true};window.addEventListener("scroll",He);setInterval(function(){if(qe){qe=false;k(q().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"),function(e){ke(e)})}},200)}}function ke(e){var t=N(e);if(!t.revealed&&m(e)){t.revealed=true;jt(t.verb,t.path,e)}}function Ie(e,t,r){var n=y(r);for(var i=0;i0){it(s,"htmx:validation:halted",n);return}f.send(JSON.stringify(u));if(Le(s)){e.preventDefault()}})}else{et(s,"htmx:noWebSocketSourceError")}}function Fe(e,t,r){var n=y(r);for(var i=0;iv.config.historyCacheSize){i.shift()}try{localStorage.setItem("htmx-history-cache",JSON.stringify(i))}catch(e){et(q().body,"htmx:historyCacheError",{cause:e})}}function st(e){var t=x(localStorage.getItem("htmx-history-cache"))||[];for(var r=0;r=200&&this.status<400){it(q().body,"htmx:historyCacheMissLoad",i);var e=d(this.response);e=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;var t=ot();var r=Nt(t);ie(t,e,r);ht(r.tasks);at=n}else{et(q().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function dt(e){ft();e=e||location.pathname+location.search;it(q().body,"htmx:historyRestore",{path:e});var t=st(e);if(t){var r=d(t.content);var n=ot();var i=Nt(n);ie(n,r,i);ht(i.tasks);document.title=t.title;window.scrollTo(0,t.scroll);at=e}else{vt(e)}}function gt(e){var t=H(e,"hx-push-url");return t&&t!=="false"||e.tagName==="A"&&N(e).boosted}function pt(e){var t=H(e,"hx-push-url");return t==="true"||t==="false"?null:t}function mt(e){xt(e,"add")}function yt(e){xt(e,"remove")}function xt(e,t){var r=H(e,"hx-indicator");if(r){var n;if(r.indexOf("closest ")===0){n=[D(e,r.substr(8))]}else{n=q().querySelectorAll(r)}}else{n=[e]}k(n,function(e){e.classList[t].call(e.classList,v.config.requestClass)})}function bt(e,t){for(var r=0;r0){r["swapStyle"]=n[0];for(var i=1;i0){it(r,"htmx:validation:halted",b);return s()}var w=t.split("#");var S=w[0];var E=w[1];if(e==="get"){var C=S;var A=Object.keys(x).length!==0;if(A){if(C.indexOf("?")<0){C+="?"}else{C+="&"}C+=Lt(x);if(E){C+="#"+E}}h.open("GET",C,true)}else{h.open(e.toUpperCase(),t,true)}h.overrideMimeType("text/html");for(var L in v){if(v.hasOwnProperty(L)){var T=v[L];Ft(h,L,T)}}var O={xhr:h,target:o,requestConfig:b,pathInfo:{path:t,finalPath:C,anchor:E}};h.onload=function(){try{i(r,O)}catch(e){et(r,"htmx:onLoadError",M({error:e},O));throw e}finally{yt(r);var e=N(r).replacedWith||r;it(e,"htmx:afterRequest",O);it(e,"htmx:afterOnLoad",O);s()}};h.onerror=function(){yt(r);et(r,"htmx:afterRequest",O);et(r,"htmx:sendError",O);s()};h.onabort=function(){yt(r);s()};if(!it(r,"htmx:beforeRequest",O))return s();mt(r);k(["loadstart","loadend","progress","abort"],function(t){k([h,h.upload],function(e){e.addEventListener(t,function(e){it(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});h.send(e==="get"?null:Ht(h,r,x))}function Vt(a,o){var u=o.xhr;var s=o.target;if(!it(a,"htmx:beforeOnLoad",o))return;if(Ut(u,/HX-Trigger:/i)){fe(u,"HX-Trigger",a)}if(Ut(u,/HX-Push:/i)){var l=u.getResponseHeader("HX-Push")}if(Ut(u,/HX-Redirect:/i)){window.location.href=u.getResponseHeader("HX-Redirect");return}if(Ut(u,/HX-Refresh:/i)){if("true"===u.getResponseHeader("HX-Refresh")){location.reload();return}}var f=gt(a)||l;if(u.status>=200&&u.status<400){if(u.status===286){Se(a)}if(u.status!==204){if(!it(s,"htmx:beforeSwap",o))return;var c=u.response;rt(a,function(e){c=e.transformResponse(c,u,a)});if(f){ft()}var h=qt(a);s.classList.add(v.config.swappingClass);var e=function(){try{var e=document.activeElement;var t={elt:e,start:e?e.selectionStart:null,end:e?e.selectionEnd:null};var r=Nt(s);le(h.swapStyle,s,a,c,r);if(t.elt&&!I(t.elt)&&t.elt.id){var n=document.getElementById(t.elt.id);if(n){if(t.start&&n.setSelectionRange){n.setSelectionRange(t.start,t.end)}n.focus()}}s.classList.remove(v.config.swappingClass);k(r.elts,function(e){if(e.classList){e.classList.add(v.config.settlingClass)}it(e,"htmx:afterSwap",o)});if(o.pathInfo.anchor){location.hash=o.pathInfo.anchor}if(Ut(u,/HX-Trigger-After-Swap:/i)){fe(u,"HX-Trigger-After-Swap",a)}var i=function(){k(r.tasks,function(e){e.call()});k(r.elts,function(e){if(e.classList){e.classList.remove(v.config.settlingClass)}it(e,"htmx:afterSettle",o)});if(f){var e=l||pt(a)||Pt(u)||o.pathInfo.finalPath||o.pathInfo.path;ct(e);it(q().body,"htmx:pushedIntoHistory",{path:e})}kt(s,r.elts,h);if(Ut(u,/HX-Trigger-After-Settle:/i)){fe(u,"HX-Trigger-After-Settle",a)}};if(h.settleDelay>0){setTimeout(i,h.settleDelay)}else{i()}}catch(e){et(a,"htmx:swapError",o);throw e}};if(h.swapDelay>0){setTimeout(e,h.swapDelay)}else{e()}}}else{et(a,"htmx:responseError",M({error:"Response Status Error Code "+u.status+" from "+o.pathInfo.path},o))}}var _t={};function Wt(){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 Bt(e,t){_t[e]=M(Wt(),t)}function $t(e){delete _t[e]}function Jt(e,r){if(e==null){return r}if(r==null){r=[]}var t=R(e,"hx-ext");if(t){k(t.split(","),function(e){e=e.replace(/ /g,"");var t=_t[e];if(t&&r.indexOf(t)<0){r.push(t)}})}return Jt(s(e),r)}function Zt(e){if(q().readyState!=="loading"){e()}else{q().addEventListener("DOMContentLoaded",e)}}function Gt(){if(v.config.includeIndicatorStyles!==false){q().head.insertAdjacentHTML("beforeend","")}}function Yt(){var e=q().querySelector('meta[name="htmx-config"]');if(e){return x(e.content)}else{return null}}function Kt(){var e=Yt();if(e){v.config=M(v.config,e)}}Zt(function(){Kt();Gt();var e=q().body;Ye(e);window.onpopstate=function(e){if(e.state&&e.state.htmx){dt()}};setTimeout(function(){it(e,"htmx:load",{})},0)});return v}()});