UNPKG

28.5 kBJavaScriptView Raw
1(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:jt,find:S,findAll:E,closest:D,remove:C,addClass:A,removeClass:L,toggleClass:O,takeClass:T,defineExtension:$t,removeExtension:Jt,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",allowEval:true,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("<table>"+e+"</table>",1);case"col":return i("<table><colgroup>"+e+"</colgroup></table>",2);case"tr":return i("<table><tbody>"+e+"</tbody></table>",2);case"td":case"th":return i("<table><tbody><tr>"+e+"</tr></tbody></table>",3);case"script":return i("<div>"+e+"</div>",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<e.length;r++){t.push(e[r])}}return t}function k(e,t){if(e){for(var r=0;r<e.length;r++){t(e[r])}}}function m(e){var t=e.getBoundingClientRect();var r=t.top;var n=t.bottom;return r<window.innerHeight&&n>=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 Mt(q().body,function(){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 O(e,t){e=X(e);e.classList.toggle(t)}function T(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){Gt(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){Gt(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;r<t.length;r++){if(e===t[r]){return true}}return false}function V(t,r){k(t.attributes,function(e){if(!r.hasAttribute(e.name)&&j(e.name)){t.removeAttribute(e.name)}});k(r.attributes,function(e){if(j(e.name)){t.setAttribute(e.name,e.value)}})}function _(e,t){var r=Zt(t);for(var n=0;n<r.length;n++){var i=r[n];try{if(i.isInlineSwap(e)){return true}}catch(e){nt(e)}}return e==="outerHTML"}function W(e,t,r){var n="#"+t.id;var i="outerHTML";if(e==="true"){}else if(e.indexOf(":")>0){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=Zt(t);for(var o=0;o<a.length;o++){var u=a[o];try{var s=u.handleSwap(e,r,n,i);if(s){if(typeof s.length!=="undefined"){for(var l=0;l<s.length;l++){var f=s[l];if(f.nodeType!==Node.TEXT_NODE&&f.nodeType!==Node.COMMENT_NODE){i.tasks.push(Z(f))}}}return}}catch(e){nt(e)}}ie(r,n,i)}}var ue=/<title>([\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(r<e.length){if(ve.exec(e.charAt(r))){var n=r;while(de.exec(e.charAt(r+1))){r++}t.push(e.substr(n,r-n+1))}else if(ge.indexOf(e.charAt(r))!==-1){var i=e.charAt(r);var n=r;r++;while(r<e.length&&e.charAt(r)!==i){if(e.charAt(r)==="\\"){r++}r++}t.push(e.substr(n,r-n+1))}else{var a=e.charAt(r);t.push(a)}r++}return t}function ye(e,t,r){return ve.exec(e.charAt(0))&&e!=="true"&&e!=="false"&&e!=="this"&&e!==r&&t!=="."}function xe(e,t,r){if(t[0]==="["){t.shift();var n=1;var i=" return (function("+r+"){ return (";var a=null;while(t.length>0){var o=t[0];if(o==="]"){n--;if(n===0){if(a===null){i=i+"true"}t.shift();i+=")})";try{var u=Mt(e,function(){return Function(i)()},function(){return true});u.source=i;return u}catch(e){et(q().body,"htmx:syntax:error",{error:e,source:i});return null}}}else if(o==="["){n++}if(ye(o,a,r)){i+="(("+r+"."+o+") ? ("+r+"."+o+") : (window."+o+"))"}else{i=i+o}a=t.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(e,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){Vt(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 Oe(e,t){return N(e).boosted&&e.tagName==="A"&&t.type==="click"&&t.ctrlKey}function Te(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(Te(o,e)){return}if(Oe(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(){Vt(i,a,n,e);r.throttle=null},o.throttle)}else if(o.delay){r.delayed=setTimeout(function(){Vt(i,a,n,e)},o.delay)}else{Vt(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;Vt(t.verb,t.path,e)}}function Ie(e,t,r){var n=y(r);for(var i=0;i<n.length;i++){var a=n[i].split(/:(.+)/);if(a[0]==="connect"){Me(e,a[1])}if(a[0]==="send"){Xe(e)}}}function Me(u,e){if(e.indexOf("ws:")!==0&&e.indexOf("wss:")!==0){e="wss:"+e}var t=v.createWebSocket(e);t.onerror=function(e){et(u,"htmx:wsError",{error:e,socket:t});De(u)};N(u).webSocket=t;t.addEventListener("message",function(e){if(De(u)){return}var t=e.data;rt(u,function(e){t=e.transformResponse(t,null,u)});var r=Nt(u);var n=d(t);var i=p(n.children);for(var a=0;a<i.length;a++){var o=i[a];W(R(o,"hx-swap-oob")||"true",o,r)}ht(r.tasks)})}function De(e){if(!I(e)){N(e).webSocket.close();return true}}function Xe(s){var l=c(s,function(e){return N(e).webSocket!=null});if(l){var f=N(l).webSocket;s.addEventListener(we(s)[0].trigger,function(e){var t=Tt(s,l);var r=Ct(s,"post");var n=r.errors;var i=r.values;var a=Ft(s);var o=M(i,a);var u=Rt(o,s);u["HEADERS"]=t;if(n&&n.length>0){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;i<n.length;i++){var a=n[i].split(/:(.+)/);if(a[0]==="connect"){Pe(e,a[1])}if(a[0]==="swap"){Ue(e,a[1])}}}function Pe(t,e){var r=v.createEventSource(e);r.onerror=function(e){et(t,"htmx:sseError",{error:e,source:r});je(t)};N(t).sseEventSource=r}function Ue(a,o){var u=c(a,Ve);if(u){var s=N(u).sseEventSource;var l=function(e){if(je(u)){s.removeEventListener(o,l);return}var t=e.data;rt(a,function(e){t=e.transformResponse(t,null,a)});var r=qt(a);var n=z(a);var i=Nt(a);le(r.swapStyle,a,n,t,i);it(a,"htmx:sseMessage",e)};N(a).sseListener=l;s.addEventListener(o,l)}else{et(a,"htmx:noSSESourceError")}}function ze(e,t,r,n){var i=c(e,Ve);if(i){var a=N(i).sseEventSource;var o=function(){if(!je(i)){if(I(e)){Vt(t,r,e)}else{a.removeEventListener(n,o)}}};N(e).sseListener=o;a.addEventListener(n,o)}else{et(e,"htmx:noSSESourceError")}}function je(e){if(!I(e)){N(e).sseEventSource.close();return true}}function Ve(e){return N(e).sseEventSource!=null}function _e(e,t,r,n,i){var a=function(){if(!n.loaded){n.loaded=true;Vt(t,r,e)}};if(i){setTimeout(a,i)}else{a()}}function We(n,i,e){var a=false;k(t,function(t){if(o(n,"hx-"+t)){var r=R(n,"hx-"+t);a=true;i.path=r;i.verb=t;e.forEach(function(e){if(e.sseEvent){ze(n,t,r,e.sseEvent)}else if(e.trigger==="revealed"){Ne();ke(n)}else if(e.trigger==="load"){_e(n,t,r,i,e.delay)}else if(e.pollInterval){i.polling=true;Ee(n,t,r,e.pollInterval)}else{Re(n,t,r,i,e)}})}});return a}function Be(e){if(e.type==="text/javascript"||e.type===""){try{Mt(e,function(){Function(e.innerText)()})}catch(e){nt(e)}}}function $e(e){if(h(e,"script")){Be(e)}k(E(e,"script"),function(e){Be(e)})}function Je(){return document.querySelector("[hx-boost], [data-hx-boost]")}function Ze(e){if(e.querySelectorAll){var t=Je()?", a, form":"";var r=e.querySelectorAll(n+t+", [hx-sse], [data-hx-sse], [hx-ws],"+" [data-hx-ws]");return r}else{return[]}}function Ge(e){var t=N(e);if(!t.initialized){t.initialized=true;it(e,"htmx:beforeProcessNode");if(e.value){t.lastValue=e.value}var r=we(e);var n=We(e,t,r);if(!n&&H(e,"hx-boost")==="true"){Ae(e,t,r)}var i=R(e,"hx-sse");if(i){Fe(e,t,i)}var a=R(e,"hx-ws");if(a){Ie(e,t,a)}it(e,"htmx:afterProcessNode")}}function Ye(e){e=X(e);Ge(e);k(Ze(e),function(e){Ge(e)})}function Ke(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Qe(e,t){var r;if(window.CustomEvent&&typeof window.CustomEvent==="function"){r=new CustomEvent(e,{bubbles:true,cancelable:true,detail:t})}else{r=q().createEvent("CustomEvent");r.initCustomEvent(e,true,true,t)}return r}function et(e,t,r){it(e,t,M({error:t},r))}function tt(e){return e==="htmx:afterProcessNode"}function rt(e,t){k(Zt(e),function(e){try{t(e)}catch(e){nt(e)}})}function nt(e){if(console.error){console.error(e)}else if(console.log){console.log("ERROR: ",e)}}function it(e,t,r){e=X(e);if(r==null){r={}}r["elt"]=e;var n=Qe(t,r);if(v.logger&&!tt(t)){v.logger(e,t,r)}if(r.error){nt(r.error);it(e,"htmx:error",{errorInfo:r})}var i=e.dispatchEvent(n);var a=Ke(t);if(i&&a!==t){var o=Qe(a,n.detail);i=i&&e.dispatchEvent(o)}rt(e,function(e){i=i&&e.onEvent(t,n)!==false});return i}var at=null;function ot(){var e=q().querySelector("[hx-history-elt],[data-hx-history-elt]");return e||q().body}function ut(e,t,r,n){var i=x(localStorage.getItem("htmx-history-cache"))||[];for(var a=0;a<i.length;a++){if(i[a].url===e){i=i.slice(a,1);break}}i.push({url:e,content:t,title:r,scroll:n});while(i.length>v.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<t.length;r++){if(t[r].url===e){return t[r]}}return null}function lt(e){var t=v.config.requestClass;var r=e.cloneNode(true);k(E(r,"."+t),function(e){L(e,t)});return r.innerHTML}function ft(){var e=ot();var t=at||location.pathname+location.search;it(q().body,"htmx:beforeHistorySave",{path:t,historyElt:e});if(v.config.historyEnabled)history.replaceState({htmx:true},q().title,window.location.href);ut(t,lt(e),q().title,window.scrollY)}function ct(e){if(v.config.historyEnabled)history.pushState({htmx:true},"",e);at=e}function ht(e){k(e,function(e){e.call()})}function vt(n){var e=new XMLHttpRequest;var i={path:n,xhr:e};it(q().body,"htmx:historyCacheMiss",i);e.open("GET",n,true);e.onload=function(){if(this.status>=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;r<e.length;r++){var n=e[r];if(n.isSameNode(t)){return true}}return false}function wt(e){if(e.name===""||e.name==null||e.disabled){return false}if(e.type==="button"||e.type==="submit"||e.tagName==="image"||e.tagName==="reset"||e.tagName==="file"){return false}if(e.type==="checkbox"||e.type==="radio"){return e.checked}return true}function St(t,r,n,e,i){if(e==null||bt(t,e)){return}else{t.push(e)}if(wt(e)){var a=l(e,"name");var o=e.value;if(e.multiple){o=p(e.querySelectorAll("option:checked")).map(function(e){return e.value})}if(e.files){o=p(e.files)}if(a!=null&&o!=null){var u=r[a];if(u){if(Array.isArray(u)){if(Array.isArray(o)){r[a]=u.concat(o)}else{u.push(o)}}else{if(Array.isArray(o)){r[a]=[u].concat(o)}else{r[a]=[u,o]}}}else{r[a]=o}}if(i){Et(e,n)}}if(h(e,"form")){var s=e.elements;k(s,function(e){St(t,r,n,e,i)})}}function Et(e,t){if(e.willValidate){it(e,"htmx:validation:validate");if(!e.checkValidity()){t.push({elt:e,message:e.validationMessage,validity:e.validity});it(e,"htmx:validation:failed",{message:e.validationMessage,validity:e.validity})}}}function Ct(e,t){var r=[];var n={form:{},element:{},includes:{}};var i=[];var a=h(e,"form")&&e.noValidate!==true;if(t!=="get"){St(r,n.form,i,D(e,"form"),a)}St(r,n.element,i,e,a);var o=H(e,"hx-include");if(o){var u=q().querySelectorAll(o);k(u,function(e){St(r,n.includes,i,e,a)})}var s=M(n.includes,n.element);s=M(s,n.form);return{errors:i,values:s}}function At(e,t,r){if(e!==""){e+="&"}e+=encodeURIComponent(t)+"="+encodeURIComponent(r);return e}function Lt(e){var t="";for(var r in e){if(e.hasOwnProperty(r)){var n=e[r];if(Array.isArray(n)){k(n,function(e){t=At(t,r,e)})}else{t=At(t,r,n)}}}return t}function Ot(e){var t=new FormData;for(var r in e){if(e.hasOwnProperty(r)){var n=e[r];if(Array.isArray(n)){k(n,function(e){t.append(r,e)})}else{t.append(r,n)}}}return t}function Tt(e,t,r){var n={"HX-Request":"true","HX-Trigger":l(e,"id"),"HX-Trigger-Name":l(e,"name"),"HX-Target":R(t,"id"),"HX-Current-URL":q().location.href};if(r!==undefined){n["HX-Prompt"]=r}return n}function Rt(t,e){var r=H(e,"hx-params");if(r){if(r==="none"){return{}}else if(r==="*"){return t}else if(r.indexOf("not ")===0){k(r.substr(4).split(","),function(e){e=e.trim();delete t[e]});return t}else{var n={};k(r.split(","),function(e){e=e.trim();n[e]=t[e]});return n}}else{return t}}function qt(e){var t=H(e,"hx-swap");var r={swapStyle:v.config.defaultSwapStyle,swapDelay:v.config.defaultSwapDelay,settleDelay:v.config.defaultSettleDelay};if(t){var n=y(t);if(n.length>0){r["swapStyle"]=n[0];for(var i=1;i<n.length;i++){var a=n[i];if(a.indexOf("swap:")===0){r["swapDelay"]=f(a.substr(5))}if(a.indexOf("settle:")===0){r["settleDelay"]=f(a.substr(7))}if(a.indexOf("scroll:")===0){r["scroll"]=a.substr(7)}if(a.indexOf("show:")===0){r["show"]=a.substr(5)}}}}return r}function Ht(t,r,n){var i=null;rt(r,function(e){if(i==null){i=e.encodeParameters(t,n,r)}});if(i!=null){return i}else{if(H(r,"hx-encoding")==="multipart/form-data"){return Ot(n)}else{return Lt(n)}}}function Nt(e){return{tasks:[],elts:[e]}}function kt(e,t,r){if(r.scroll){if(r.scroll==="top"){e.scrollTop=0}if(r.scroll==="bottom"){e.scrollTop=e.scrollHeight}}if(r.show){if(r.show==="top"){e.scrollIntoView(true)}if(r.show==="bottom"){e.scrollIntoView(false)}}}function It(e,t,r,n){if(n==null){n={}}if(e==null){return n}var i=R(e,t);if(i){var a=i.trim();if(a.indexOf("{")!==0){a="{"+a+"}"}var o=r(a);for(var u in o){if(o.hasOwnProperty(u)){if(n[u]==null){n[u]=o[u]}}}}return It(s(e),t,r,n)}function Mt(e,t,r){if(v.config.allowEval){return t()}else{et(e,"htmx:evalDisallowedError");return r}}function Dt(t,e){return It(t,"hx-vars",function(e){return Mt(t,function(){return Function("return ("+e+")")()},{})},e)}function Xt(e,t){return It(e,"hx-vals",function(e){return x(e)},t)}function Ft(e){return M(Dt(e),Xt(e))}function Pt(t,r,n){if(n!==null){try{t.setRequestHeader(r,n)}catch(e){t.setRequestHeader(r,encodeURIComponent(n));t.setRequestHeader(r+"-URI-AutoEncoded","true")}}}function Ut(t){if(t.responseURL&&typeof URL!=="undefined"){try{var e=new URL(t.responseURL);return e.pathname+e.search}catch(e){et(q().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function zt(e,t){return e.getAllResponseHeaders().match(t)}function jt(e,t,r){if(r){if(r instanceof Element||a(r,"String")){Vt(e,t,null,null,null,X(r))}else{Vt(e,t,X(r.source),r.event,r.handler,X(r.target))}}else{Vt(e,t)}}function Vt(e,t,r,n,i,a){if(r==null){r=q().body}if(i==null){i=_t}if(!I(r)){return}var o=a||z(r);if(o==null){et(r,"htmx:targetError",{target:R(r,"hx-target")});return}var u=N(r);if(u.requestInFlight){u.queuedRequest=function(){Vt(e,t,r,n)};return}else{u.requestInFlight=true}var s=function(){u.requestInFlight=false;var e=u.queuedRequest;u.queuedRequest=null;if(e){e()}};var l=H(r,"hx-prompt");if(l){var f=prompt(l);if(f===null||!it(r,"htmx:prompt",{prompt:f,target:o}))return s()}var c=H(r,"hx-confirm");if(c){if(!confirm(c))return s()}var h=new XMLHttpRequest;var v=Tt(r,o,f);var d=Ct(r,e);var g=d.errors;var p=d.values;var m=Ft(r);var y=M(p,m);var x=Rt(y,r);if(e!=="get"&&H(r,"hx-encoding")==null){v["Content-Type"]="application/x-www-form-urlencoded; charset=UTF-8"}if(t==null||t===""){t=q().location.href}var b={parameters:x,unfilteredParameters:y,headers:v,target:o,verb:e,errors:g,path:t,triggeringEvent:n};if(!it(r,"htmx:configRequest",b))return s();t=b.path;e=b.verb;v=b.headers;x=b.parameters;g=b.errors;if(g&&g.length>0){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 O=v[L];Pt(h,L,O)}}var T={xhr:h,target:o,requestConfig:b,pathInfo:{path:t,finalPath:C,anchor:E}};h.onload=function(){try{i(r,T)}catch(e){et(r,"htmx:onLoadError",M({error:e},T));throw e}finally{yt(r);var e=N(r).replacedWith||r;it(e,"htmx:afterRequest",T);it(e,"htmx:afterOnLoad",T);s()}};h.onerror=function(){yt(r);et(r,"htmx:afterRequest",T);et(r,"htmx:sendError",T);s()};h.onabort=function(){yt(r);s()};if(!it(r,"htmx:beforeRequest",T))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 _t(a,o){var u=o.xhr;var s=o.target;if(!it(a,"htmx:beforeOnLoad",o))return;if(zt(u,/HX-Trigger:/i)){fe(u,"HX-Trigger",a)}if(zt(u,/HX-Push:/i)){var l=u.getResponseHeader("HX-Push")}if(zt(u,/HX-Redirect:/i)){window.location.href=u.getResponseHeader("HX-Redirect");return}if(zt(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(zt(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)||Ut(u)||o.pathInfo.finalPath||o.pathInfo.path;ct(e);it(q().body,"htmx:pushedIntoHistory",{path:e})}kt(s,r.elts,h);if(zt(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 Wt={};function Bt(){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 $t(e,t){Wt[e]=M(Bt(),t)}function Jt(e){delete Wt[e]}function Zt(e,r,n){if(e==undefined){return r}if(r==undefined){r=[]}if(n==undefined){n=[]}var t=R(e,"hx-ext");if(t){k(t.split(","),function(e){e=e.replace(/ /g,"");if(e.slice(0,7)=="ignore:"){n.push(e.slice(7));return}if(n.indexOf(e)<0){var t=Wt[e];if(t&&r.indexOf(t)<0){r.push(t)}}})}return Zt(s(e),r,n)}function Gt(e){if(q().readyState!=="loading"){e()}else{q().addEventListener("DOMContentLoaded",e)}}function Yt(){if(v.config.includeIndicatorStyles!==false){q().head.insertAdjacentHTML("beforeend","<style> ."+v.config.indicatorClass+"{opacity:0;transition: opacity 200ms ease-in;} ."+v.config.requestClass+" ."+v.config.indicatorClass+"{opacity:1} ."+v.config.requestClass+"."+v.config.indicatorClass+"{opacity:1} </style>")}}function Kt(){var e=q().querySelector('meta[name="htmx-config"]');if(e){return x(e.content)}else{return null}}function Qt(){var e=Kt();if(e){v.config=M(v.config,e)}}Gt(function(){Qt();Yt();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}()});
\No newline at end of file