diff --git a/README.md b/README.md index d45a9253..e32c7069 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,15 @@ - Fix target and source elements sent to `selectAndSwap` during the **SSE** swapping process that were inverted in the original code, now allowing to properly use `hx-target` for example to specify which element to swap with SSE - [SSE swap listeners](https://htmx.org/attributes/hx-sse/) are now removed from the event sources when the associated element gets removed from the page - Values passed along a `DELETE` request are encoded as URL parameters _(as for a `GET` request)_ instead of being sent as form data -- The [`Content-Type`](https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Content-Type) header is no longer overridden to `application/x-www-form-urlencoded` when using [`htmx.ajax()`](https://htmx.org/api/#ajax) method _(HTMX would by default override it for any non-GET request on an element that doesn't define the `hx-encoding` attribute, but one might want to define this header in their AJAX request using the `context.headers` property)_ +- The [`Content-Type`](https://developer.mozilla.org/en/docs/Web/HTTP/Headers/Content-Type) header is no longer overridden to `application/x-www-form-urlencoded` when using [`htmx.ajax()`](https://htmx.org/api/#ajax) method _(HTMX would by default override it for any non-GET request on an element that doesn't define the [`hx-encoding`](https://htmx.org/attributes/hx-encoding/) attribute, but one might want to define this header in their AJAX request using the `context.headers` property)_ +- [`htmx.ajax()`](https://htmx.org/api/#ajax) now correctly handles files passed to it through the `context.values` property _(HTMX would by default override the content type to `application/x-www-form-urlencoded` instead of letting [xhr.send](https://xhr.spec.whatwg.org/#the-send()-method) deduce the multipart/form-data content type itself + it would only use the values of the [`hx-encoding`](https://htmx.org/attributes/hx-encoding/) and [`enctype`](https://developer.mozilla.org/en/docs/Web/API/HTMLFormElement/enctype), thus ignore the fact that the payload contains file input values and should be treated as `multipart/form-data`)_ ## Changes - The htmx-indicator is not hidden on request's response if the response has a `HX-Redirect` header set (just a personal visual preference) - If the target specified to [`htmx.ajax()`](https://htmx.org/api/#ajax) (and so the `targetOverride` passed to `issueAjaxRequest()`) can't be found, an error is thrown (instead of the HTMX default implementation that crawls the hierarchy to find the first `hx-target` specified on a parent element as a fallback) - In the default HTMX implementation, elements that have an ID have a special treatment during swapping ; if an element with an ID is about to be inserted, and to replace another element with the same ID, for a reason I ignore, HTMX clones the old elements "settling attributes" _(that are, by default, `class`, `style`, `width` & `height`)_ into the new element, then restores the new element initial attributes after the settling. My problem with this ; using a [MutationObserver](https://developer.mozilla.org/en/docs/Web/API/MutationObserver) to apply style to newly added nodes _(for example a line that should be positionned at current local time with a line of JS in a calendar)_ results in those modifications being reverted by HTMX after the settling. Since this cloning step appears useless to me (maybe am I wrong though ?), I got rid of it here, as well as the `attributesToSettle` property that was only used for that purpose. - When an HTMX error is logged, the `detail` context object passed along in the internal functions is now included in the log, for an easier debugging. This way, a `hx-targetError` for example, will also log the actual target that HTMX was trying to retrieve. - The attribute `hx-push-url` is no longer inherited by default by children elements. You can specify `hx-push-url="inherit"` on children elements though, to inherit the value from the closest parent that defines a `hx-push-url`. -- HTMX uses `writeLayout` and `readLayout` _(more details below)_ internally to postpone the elements clean up & settling [to the next animation frame](https://developer.mozilla.org/fr/docs/Web/API/Window/requestAnimationFrame), so the swap function returns faster _(now takes roughly half the time)_ and the browser can update the DOM _(and the page layout display)_ sooner, providing a better visual experience. +- HTMX uses `writeLayout` and `readLayout` _(more details below)_ internally to postpone the elements clean up & settling [to the next animation frame](https://developer.mozilla.org/en/docs/Web/API/Window/requestAnimationFrame), so the swap function returns faster _(now takes roughly half the time)_ and the browser can update the DOM _(and the page layout display)_ sooner, providing a better visual experience. - When using the [`hx-swap`](https://htmx.org/attributes/hx-swap/) attribute set to `"none"`, it's no longer required to have a value defined for the [`hx-target`](https://htmx.org/attributes/hx-target/) attribute _(in this case, simply no element will trigger the [htmx:beforeSwap](https://htmx.org/events/#htmx:beforeSwap) event, nor being added/removed the [swapping class](https://htmx.org/reference/#classes))_ ## Additions - `hx-error-target` and `hx-error-swap` attributes to allow swapping server's reponse on error (i.e request with a `status >= 300`). Those attributes behave exactly like, respectively, [hx-target](https://htmx.org/attributes/hx-target/) and [hx-swap](https://htmx.org/attributes/hx-swap/) @@ -26,4 +27,4 @@ - The [`htmx:beforeOnLoad`](https://htmx.org/events/#htmx:beforeOnLoad), [`htmx:beforeSwap`](https://htmx.org/events/#htmx:beforeSwap), [`htmx:afterSwap`](https://htmx.org/events/#htmx:afterSwap), [`htmx:afterSettle`](https://htmx.org/events/#htmx:afterSettle), [`htmx:swapError`](https://htmx.org/events/#htmx:swapError), [`htmx:afterRequest`](https://htmx.org/events/#htmx:afterRequest), [`htmx:afterOnLoad`](https://htmx.org/events/#htmx:afterOnLoad), [`htmx:onLoadError`](https://htmx.org/events/#htmx:onLoadError) events are now passed an additional property `isError` in the event's `detail` property, which indicates if the request's response has an error status _(ie a code >= 400)_ - The `hx-target` attribute accepts 2 new values : `next-sibling` (which targets the [next sibling element](https://developer.mozilla.org/en-US/docs/Web/API/Element/nextElementSibling)) and `previous-sibling` (which targets the [previous sibling element](https://developer.mozilla.org/en-US/docs/Web/API/Element/previousElementSibling)) - The HTMX API now provides the methods `readLayout` and `writeLayout`, to execute layout read/write operations while avoiding [layout thrashing](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid_layout_thrashing) -- The HTMX API now provides the method `resizeSelect`, which takes a [select HTML element](https://developer.mozilla.org/fr/docs/Web/HTML/Element/select) as parameter, and resizes it so it fits its selected option +- The HTMX API now provides the method `resizeSelect`, which takes a [select HTML element](https://developer.mozilla.org/en/docs/Web/HTML/Element/select) as parameter, and resizes it so it fits its selected option diff --git a/dist/htmx.js b/dist/htmx.js index 5e2fd68c..71ae5de0 100644 --- a/dist/htmx.js +++ b/dist/htmx.js @@ -2352,6 +2352,20 @@ return (function () { } } + /** + * valuesContainAnyFile returns true if any of the values is a File input value + * @param {Object} inputValues + * @returns {boolean} + */ + function valuesContainAnyFile(inputValues) { + for (var name in inputValues) { + if (inputValues[name] instanceof File) { + return true + } + } + return false + } + function isAnchorLink(elt) { return getRawAttribute(elt, 'href') && getRawAttribute(elt, 'href').indexOf("#") >=0 } @@ -2433,7 +2447,8 @@ return (function () { return encodedParameters; } else { if (getClosestAttributeValue(elt, "hx-encoding") === "multipart/form-data" || - (matches(elt, "form") && getRawAttribute(elt, 'enctype') === "multipart/form-data")) { + (matches(elt, "form") && getRawAttribute(elt, 'enctype') === "multipart/form-data") || + valuesContainAnyFile(filteredParameters)) { return makeFormData(filteredParameters); } else { return urlEncode(filteredParameters); @@ -2773,7 +2788,7 @@ return (function () { var allParameters = mergeObjects(rawParameters, expressionVars); var filteredParameters = filterValues(allParameters, elt); - if (verb !== 'get' && getClosestAttributeValue(elt, "hx-encoding") == null && !headers["Content-Type"]) { + if (verb !== 'get' && getClosestAttributeValue(elt, "hx-encoding") == null && !headers["Content-Type"] && !valuesContainAnyFile(filteredParameters)) { headers['Content-Type'] = 'application/x-www-form-urlencoded'; } diff --git a/dist/htmx.min.js b/dist/htmx.min.js index 41212475..b0942e75 100644 --- a/dist/htmx.min.js +++ b/dist/htmx.min.js @@ -1 +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 U={onLoad:t,process:bt,on:I,off:M,trigger:K,ajax:ur,find:C,findAll:R,closest:H,values:function(e,t){var r=zt(e,t||"post");return r.values},remove:O,addClass:L,removeClass:q,toggleClass:A,takeClass:T,defineExtension:pr,removeExtension:gr,logAll:E,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,inlineScriptNonce:"",withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",disableSelector:"[hx-disable], [data-hx-disable]",useTemplateFragments:false,scrollBehavior:"smooth",defaultFocusScroll:false},eventSources:[],parseInterval:g,_:e,createEventSource:function(e){const t=new EventSource(e,{withCredentials:true});U.eventSources.push(t);return t},createWebSocket:function(e){return new WebSocket(e,[])},readLayout:B,writeLayout:te,resizeSelect:re,version:"1.7.0"};var r={bodyContains:G,filterValues:Zt,hasAttribute:s,getAttributeValue:z,getClosestMatch:c,getExpressionVars:or,getHeaders:$t,getInputValues:zt,getInternalData:J,getSwapSpecification:Yt,getTriggerSpecs:Be,getTarget:ue,makeFragment:v,mergeObjects:Q,makeSettleInfo:Qt,oobSwap:de,selectAndSwap:Ae,settleImmediately:kt,shouldCancel:Je,triggerEvent:K,triggerErrorEvent:Z,withExtensions:Ct};var n=["get","post","put","delete","patch"];var i=n.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function g(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 f(e,t){return e.getAttribute&&e.getAttribute(t)}function s(e,t){return e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function z(e,t){return f(e,t)||f(e,"data-"+t)}function u(e){return e.parentElement}function _(){return document}function c(e,t){if(t(e)){return e}else if(u(e)){return c(u(e),t)}else{return null}}function o(e,t,r){var n=z(t,r);var i=z(t,"hx-disinherit");if(e!==t&&i&&(i==="*"||i.split(" ").indexOf(r)>=0)){return"unset"}else{return n}}function W(t,r){var n=null;c(t,function(e){return n=o(t,e,r)});if(n!=="unset"){return n}}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 a(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 l(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=_().createDocumentFragment()}return i}function v(e){if(U.config.useTemplateFragments){var t=l("",0);return t.querySelector("template").content}else{var r=a(e);switch(r){case"thead":case"tbody":case"tfoot":case"colgroup":case"caption":return l(""+e+"
",1);case"col":return l(""+e+"
",2);case"tr":return l(""+e+"
",2);case"td":case"th":return l(""+e+"
",3);case"script":return l("
"+e+"
",1);default:return l(e,0)}}}function Y(e){if(e){e()}}function p(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function m(e){return p(e,"Function")}function y(e){return p(e,"Object")}function J(e){var t="htmx-internal-data";var r=e[t];if(!r){r=e[t]={}}return r}function x(e){var t=[];if(e){for(var r=0;r=0}function G(e){if(e.getRootNode()instanceof ShadowRoot){return _().body.contains(e.getRootNode().host)}else{return _().body.contains(e)}}function w(e){return e.trim().split(/\s+/)}function Q(e,t){for(var r in t){if(t.hasOwnProperty(r)){e[r]=t[r]}}return e}function S(e){try{return JSON.parse(e)}catch(e){Rt(e);return null}}function e(e){return rr(_().body,function(){return eval(e)})}function t(t){var e=U.on("htmx:load",function(e){t(e.detail.elt)});return e}function E(){U.logger=function(e,t,r){if(console){console.log(t,e,r)}}}function C(e,t){if(t){return e.querySelector(t)}else{return C(_(),e)}}function R(e,t){if(t){return e.querySelectorAll(t)}else{return R(_(),e)}}function O(e,t){e=k(e);if(t){setTimeout(function(){O(e)},t)}else{e.parentElement.removeChild(e)}}function L(e,t,r){e=k(e);if(r){setTimeout(function(){L(e,t)},r)}else{e.classList&&e.classList.add(t)}}function q(e,t,r){e=k(e);if(r){setTimeout(function(){q(e,t)},r)}else{if(e.classList){e.classList.remove(t);if(e.classList.length===0){e.removeAttribute("class")}}}}function A(e,t){e=k(e);e.classList.toggle(t)}function T(e,t){e=k(e);$(e.parentElement.children,function(e){q(e,t)});L(e,t)}function H(e,t){e=k(e);if(e.closest){return e.closest(t)}else{do{if(e==null||h(e,t)){return e}}while(e=e&&u(e))}}function N(e,t){if(t.indexOf("closest ")===0){return[H(e,t.substr(8))]}else if(t.indexOf("find ")===0){return[C(e,t.substr(5))]}else if(t==="document"){return[document]}else if(t==="window"){return[window]}else{return _().querySelectorAll(t)}}function ee(e,t){if(t){return N(e,t)[0]}else{return N(_().body,e)[0]}}function k(e){if(p(e,"String")){return C(e)}else{return e}}function P(e,t,r){if(m(t)){return{target:_().body,event:e,listener:t}}else{return{target:k(e),event:t,listener:r}}}function I(t,r,n){yr(function(){var e=P(t,r,n);e.target.addEventListener(e.event,e.listener)});var e=m(r);return e?r:n}function M(t,r,n){yr(function(){var e=P(t,r,n);e.target.removeEventListener(e.event,e.listener)});return m(r)?r:n}let d;let D;let F=[],X=[];const V=[];let j;function B(e){F.push(e);if(document.hidden){ne()}}function te(e){X.push(e);if(document.hidden){ne()}}function re(e){if(e.options.length>1&&e.options[e.selectedIndex]){B(function(){V.push(e)})}}function ne(){const t=F;F=[];for(let e=0;e0){j=V[0];V.splice(0,1);const f=j.options[j.selectedIndex];const n=getComputedStyle(j);const i=n.getPropertyValue("height");const o=n.getPropertyValue("padding");const a=n.getPropertyValue("font-family");const s=n.getPropertyValue("border");const l=n.getPropertyValue("box-sizing");const u=n.getPropertyValue("appearance");const c=f.textContent.trim();if(document.hidden){D.textContent=c;d.style.setProperty("height",i);d.style.setProperty("padding",o);d.style.setProperty("fontFamily",a);d.style.setProperty("border",s);d.style.setProperty("boxSizing",l);d.style.setProperty("appearance",u)}else{te(function(){D.textContent=c;d.style.setProperty("height",i);d.style.setProperty("padding",o);d.style.setProperty("fontFamily",a);d.style.setProperty("border",s);d.style.setProperty("boxSizing",l);d.style.setProperty("appearance",u)})}}const r=X;X=[];for(let e=0;e0){a=e.substr(0,e.indexOf(":"));t=e.substr(e.indexOf(":")+1,e.length)}else{a=e}var r=_().querySelectorAll(t);if(r){$(r,function(e){var t;var r=i.cloneNode(true);t=_().createDocumentFragment();t.appendChild(r);if(!ce(a,e)){t=r}var n={shouldSwap:true,target:e,fragment:t};if(!K(e,"htmx:oobBeforeSwap",n))return;e=n.target;if(n["shouldSwap"]){Le(a,e,e,t,o)}$(o.elts,function(e){K(e,"htmx:oobAfterSwap",n)})});i.parentNode.removeChild(i)}else{i.parentNode.removeChild(i);Z(_().body,"htmx:oobErrorNoTarget",{content:i})}return e}function he(e,r){$(R(e,"[hx-swap-oob], [data-hx-swap-oob]"),function(e){var t=z(e,"hx-swap-oob");if(t!=null){de(t,e,r)}})}function ve(e){$(R(e,"[hx-preserve], [data-hx-preserve]"),function(e){var t=z(e,"id");var r=_().getElementById(t);if(r!=null){e.parentNode.replaceChild(r,e)}})}function pe(e){return function(){q(e,U.config.addedClass);bt(e);pt(e);ge(e);K(e,"htmx:load")}}function ge(e){var t="[autofocus]";var r=h(e,t)?e:e.querySelector(t);if(r!=null){r.focus()}}function me(e,t,r,n){while(r.childNodes.length>0){var i=r.firstChild;L(i,U.config.addedClass);e.insertBefore(i,t);if(i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.COMMENT_NODE){n.tasks.push(pe(i))}}}function ye(t){var e=J(t);if(e.webSocket){e.webSocket.close()}if(e.sseEventSource){e.sseEventSource.close()}K(t,"htmx:beforeCleanupElement");if(e.listenerInfos){$(e.listenerInfos,function(e){if(t!==e.on){e.on.removeEventListener(e.trigger,e.listener)}})}if(t.children){$(t.children,function(e){ye(e)})}}function xe(e,t,r){if(e.tagName==="BODY"){return Re(e,t,r)}else{if(!u(e)){return}var n;var i=e.previousSibling;me(u(e),e,t,r);if(i==null){n=u(e).firstChild}else{n=i.nextSibling}J(e).replacedWith=n;r.elts=[];while(n&&n!==e){if(n.nodeType===Node.ELEMENT_NODE){r.elts.push(n)}n=n.nextElementSibling}te(function(){ye(e)});u(e).removeChild(e)}}function be(e,t,r){return me(e,e.firstChild,t,r)}function we(e,t,r){return me(u(e),e,t,r)}function Se(e,t,r){return me(e,null,t,r)}function Ee(e,t,r){return me(u(e),e.nextSibling,t,r)}function Ce(e,t,r){ye(e);return u(e).removeChild(e)}function Re(e,t,r){var n=e.firstChild;me(e,n,t,r);if(n){while(n.nextSibling){var i=n.nextSibling;te(function(){ye(i)});e.removeChild(n.nextSibling)}te(function(){ye(n)});e.removeChild(n)}}function Oe(e,t){var r=W(e,"hx-select");if(r){var n=_().createDocumentFragment();$(t.querySelectorAll(r),function(e){n.appendChild(e)});t=n}return t}function Le(e,t,r,n,i){switch(e){case"none":return;case"outerHTML":xe(r,n,i);return;case"afterbegin":be(r,n,i);return;case"beforebegin":we(r,n,i);return;case"beforeend":Se(r,n,i);return;case"afterend":Ee(r,n,i);return;case"delete":Ce(r,n,i);return;default:var o=mr(t);for(var a=0;a-1){var t=e.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");var r=t.match(/]*>|>)([\s\S]*?)<\/title>/im);if(r){return r[2]}}}function Ae(e,t,r,n,i){i.title=qe(n);var o=v(n);if(o){he(o,i);o=Oe(r,o);ve(o);return Le(e,r,t,o,i)}}function Te(e,t,r){var n=e.getResponseHeader(t);if(n.indexOf("{")===0){var i=S(n);for(var o in i){if(i.hasOwnProperty(o)){var a=i[o];if(!y(a)){a={value:a}}K(r,o,a)}}}else{if(typeof n==="string"){const s=n.split(", ");for(var o of s){K(r,o,[])}}else{K(r,n,[])}}}var He=/\s/;var Ne=/[\s,]/;var ke=/[_$a-zA-Z]/;var Pe=/[_$a-zA-Z0-9]/;var Ie=['"',"'","/"];var Me=/[^\s]/;function De(e){var t=[];var r=0;while(r0){var a=t[0];if(a==="]"){n--;if(n===0){if(o===null){i=i+"true"}t.shift();i+=")})";try{var s=rr(e,function(){return Function(i)()},function(){return true});s.source=i;return s}catch(e){Z(_().body,"htmx:syntax:error",{error:e,source:i});return null}}}else if(a==="["){n++}if(Fe(a,o,r)){i+="(("+r+"."+a+") ? ("+r+"."+a+") : (window."+a+"))"}else{i=i+a}o=t.shift()}}}function Ve(e,t){var r="";while(e.length>0&&!e[0].match(t)){r+=e.shift()}return r}var je="input, textarea, select";function Be(e){var t=z(e,"hx-trigger");var r=[];if(t){var n=De(t);do{Ve(n,Me);var f=n.length;var i=Ve(n,/[,\[\s]/);if(i!==""){if(i==="every"){var o={trigger:"every"};Ve(n,Me);o.pollInterval=g(Ve(n,/[,\[\s]/));Ve(n,Me);var a=Xe(e,n,"event");if(a){o.eventFilter=a}r.push(o)}else if(i.indexOf("sse:")===0){r.push({trigger:"sse",sseEvent:i.substring(4)})}else{var s={trigger:i};var a=Xe(e,n,"event");if(a){s.eventFilter=a}while(n.length>0&&n[0]!==","){Ve(n,Me);var l=n.shift();if(l==="changed"){s.changed=true}else if(l==="once"){s.once=true}else if(l==="consume"){s.consume=true}else if(l==="delay"&&n[0]===":"){n.shift();s.delay=g(Ve(n,Ne))}else if(l==="from"&&n[0]===":"){n.shift();var u=Ve(n,Ne);if(u==="closest"||u==="find"){n.shift();u+=" "+Ve(n,Ne)}s.from=u}else if(l==="target"&&n[0]===":"){n.shift();s.target=Ve(n,Ne)}else if(l==="throttle"&&n[0]===":"){n.shift();s.throttle=g(Ve(n,Ne))}else if(l==="queue"&&n[0]===":"){n.shift();s.queue=Ve(n,Ne)}else if((l==="root"||l==="threshold")&&n[0]===":"){n.shift();s[l]=Ve(n,Ne)}else{Z(e,"htmx:syntax:error",{token:n.shift()})}}r.push(s)}}if(n.length===f){Z(e,"htmx:syntax:error",{token:n.shift()})}Ve(n,Me)}while(n[0]===","&&n.shift())}if(r.length>0){return r}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"]')){return[{trigger:"click"}]}else if(h(e,je)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function Ue(e){J(e).cancelled=true}function ze(e,t,r,n){var i=J(e);i.timeout=setTimeout(function(){if(G(e)&&i.cancelled!==true){if(!Ze(n,St("hx:poll:trigger",{triggerSpec:n,target:e}))){cr(t,r,e)}ze(e,t,z(e,"hx-"+t),n)}},n.pollInterval)}function _e(e){return location.hostname===e.hostname&&f(e,"href")&&f(e,"href").indexOf("#")!==0}function We(t,r,e){if(t.tagName==="A"&&_e(t)&&t.target===""||t.tagName==="FORM"){r.boosted=true;var n,i;if(t.tagName==="A"){n="get";i=f(t,"href");r.pushURL=true}else{var o=f(t,"method");n=o?o.toLowerCase():"get";if(n==="get"){r.pushURL=true}i=f(t,"action")}e.forEach(function(e){Ke(t,n,i,r,e,true)})}}function Je(e,t){if(e.type==="submit"||e.type==="click"){if(t.tagName==="FORM"){return true}if(h(t,'input[type="submit"], button')&&H(t,"form")!==null){return true}if(t.tagName==="A"&&t.href&&(t.getAttribute("href")==="#"||t.getAttribute("href").indexOf("#")!==0)){return true}}return false}function $e(e,t){return J(e).boosted&&e.tagName==="A"&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function Ze(e,t){var r=e.eventFilter;if(r){try{return r(t)!==true}catch(e){Z(_().body,"htmx:eventFilter:error",{error:e,source:r.source});return true}}return false}function Ke(o,a,s,e,l,u){var t;if(l.from){t=N(o,l.from)}else{t=[o]}$(t,function(n){var i=function(e){if(!G(o)){n.removeEventListener(l.trigger,i);return}if($e(o,e)){return}if(u||Je(e,o)){e.preventDefault()}if(Ze(l,e)){return}var t=J(e);t.triggerSpec=l;if(t.handledFor==null){t.handledFor=[]}var r=J(o);if(t.handledFor.indexOf(o)<0){t.handledFor.push(o);if(l.consume){e.stopPropagation()}if(l.target&&e.target){if(!h(e.target,l.target)){return}}if(l.once){if(r.triggeredOnce){return}else{r.triggeredOnce=true}}if(l.changed){if(r.lastValue===o.value){return}else{r.lastValue=o.value}}if(r.delayed){clearTimeout(r.delayed)}if(r.throttle){return}if(l.throttle){if(!r.throttle){cr(a,s,o,e);r.throttle=setTimeout(function(){r.throttle=null},l.throttle)}}else if(l.delay){r.delayed=setTimeout(function(){cr(a,s,o,e)},l.delay)}else{cr(a,s,o,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:l.trigger,listener:i,on:n});n.addEventListener(l.trigger,i)})}var Ye=false;var Ge=null;function Qe(){if(!Ge){Ge=function(){Ye=true};window.addEventListener("scroll",Ge);setInterval(function(){if(Ye){Ye=false;$(_().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"),function(e){et(e)})}},200)}}function et(e){if(!s(e,"data-hx-revealed")&&b(e)){e.setAttribute("data-hx-revealed","true");var t=J(e);if(t.initialized){cr(t.verb,t.path,e)}else{e.addEventListener("htmx:afterProcessNode",function(){cr(t.verb,t.path,e)},{once:true})}}}function tt(e,t,r){var n=w(r);for(var i=0;i=0){var t=ot(n);setTimeout(function(){rt(s,r,n+1)},t)}};t.onopen=function(e){n=0};J(s).webSocket=t;t.addEventListener("message",function(e){if(nt(s)){return}var t=e.data;Ct(s,function(e){t=e.transformResponse(t,null,s)});var r=Qt(s);var n=v(t);var i=x(n.children);for(var o=0;o0){K(u,"htmx:validation:halted",i);return}t.send(JSON.stringify(l));if(Je(e,u)){e.preventDefault()}})}else{Z(u,"htmx:noWebSocketSourceError")}}function ot(e){var t=U.config.wsReconnectDelay;if(typeof t==="function"){return t(e)}if(t==="full-jitter"){var r=Math.min(e,6);var n=1e3*Math.pow(2,r);return n*Math.random()}Rt('htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"')}function at(e,t,r){var n=w(r);for(var i=0;iU.config.historyCacheSize){i.shift()}while(i.length>0){try{localStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){Z(_().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function At(e){var t=S(localStorage.getItem("htmx-history-cache"))||[];for(var r=0;r=200&&this.status<400){K(_().body,"htmx:historyCacheMissLoad",i);var e=v(this.response);e=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;var t=Lt();var r=Qt(t);Re(t,e,r);kt(r.tasks);Ot=n;K(_().body,"htmx:historyRestore",{path:n})}else{Z(_().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function It(e){Ht();e=e||location.pathname+location.search;var t=At(e);if(t){var r=v(t.content);var n=Lt();var i=Qt(n);Re(n,r,i);kt(i.tasks);document.title=t.title;window.scrollTo(0,t.scroll);Ot=e;K(_().body,"htmx:historyRestore",{path:e})}else{if(U.config.refreshOnHistoryMiss){window.location.reload(true)}else{Pt(e)}}}function Mt(e){var t=z(e,"hx-push-url");if(!t||t==="false"){return false}if(t==="inherit"){var r=u(e);if(!r){Z(e,"htmx:pushUrlInheritNoParentError");return false}t=W(r,"hx-push-url")}return t&&t!=="false"||J(e).boosted&&J(e).pushURL}function Dt(e){var t=W(e,"hx-push-url");if(t==="inherit"){var r=u(e);if(!r){Z(e,"htmx:pushUrlInheritNoParentError");return false}t=W(r,"hx-push-url")}return t==="true"||t==="false"?null:t}function Ft(e){var t=se(e,"hx-indicator");if(t==null){t=[e]}$(t,function(e){e.classList["add"].call(e.classList,U.config.requestClass)});return t}function Xt(e){$(e,function(e){e.classList["remove"].call(e.classList,U.config.requestClass)})}function Vt(e,t){for(var r=0;r=0}function Yt(e,t,f,r){var n;if(typeof r==="string"){n=r}else if(t){n=W(e,"hx-error-swap")}else if(f){n=W(e,"hx-sse-swap")}if(!t&&!n){n=W(e,"hx-swap")}var i={swapStyle:J(e).boosted?"innerHTML":U.config.defaultSwapStyle,swapDelay:U.config.defaultSwapDelay,settleDelay:U.config.defaultSettleDelay};if(J(e).boosted&&!Kt(e)){i["show"]="top"}if(n){var o=w(n);if(o.length>0){i["swapStyle"]=o[0];for(var a=1;a0?l.join(":"):null;i["scroll"]=d;i["scrollTarget"]=u}if(s.indexOf("show:")===0){var h=s.substr(5);var l=h.split(":");var v=l.pop();var u=l.length>0?l.join(":"):null;i["show"]=v;i["showTarget"]=u}if(s.indexOf("focus-scroll:")===0){var p=s.substr("focus-scroll:".length);i["focusScroll"]=p=="true"}}}}return i}function Gt(t,r,n){var i=null;Ct(r,function(e){if(i==null){i=e.encodeParameters(t,n,r)}});if(i!=null){return i}else{if(W(r,"hx-encoding")==="multipart/form-data"||h(r,"form")&&f(r,"enctype")==="multipart/form-data"){return Jt(n)}else{return Wt(n)}}}function Qt(e){return{tasks:[],elts:e?[e]:[]}}function er(e,t){var r=e[0];var n=e[e.length-1];if(t.scroll){var i=null;if(t.scrollTarget){i=ee(r,t.scrollTarget)}if(t.scroll==="top"&&(r||i)){i=i||r;i.scrollTop=0}if(t.scroll==="bottom"&&(n||i)){i=i||n;i.scrollTop=i.scrollHeight}}if(t.show){var i=null;if(t.showTarget){var o=t.showTarget;if(t.showTarget==="window"){o="body"}i=ee(r,o)}if(t.show==="top"&&(r||i)){i=i||r;i.scrollIntoView({block:"start",behavior:U.config.scrollBehavior})}if(t.show==="bottom"&&(n||i)){i=i||n;i.scrollIntoView({block:"end",behavior:U.config.scrollBehavior})}}}function tr(e,t,r,n){if(n==null){n={}}if(e==null){return n}var i=z(e,t);if(i){var o=i.trim();var a=r;if(o.indexOf("javascript:")===0){o=o.substr(11);a=true}else if(o.indexOf("js:")===0){o=o.substr(3);a=true}if(o.indexOf("{")!==0){o="{"+o+"}"}var s;if(a){s=rr(e,function(){return Function("return ("+o+")")()},{})}else{s=S(o)}for(var l in s){if(s.hasOwnProperty(l)){if(n[l]==null){n[l]=s[l]}}}}return tr(u(e),t,r,n)}function rr(e,t,r){if(U.config.allowEval){return t()}else{Z(e,"htmx:evalDisallowedError");return r}}function nr(e,t){return tr(e,"hx-vars",true,t)}function ir(e,t){return tr(e,"hx-vals",false,t)}function or(e){return Q(nr(e),ir(e))}function ar(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 sr(t){if(t.responseURL&&typeof URL!=="undefined"){try{var e=new URL(t.responseURL);return e.pathname+e.search}catch(e){Z(_().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function lr(e,t){return e.getAllResponseHeaders().match(t)}function ur(e,t,r){e=e.toLowerCase();if(r){if(r instanceof Element||p(r,"String")){return cr(e,t,null,null,{targetOverride:k(r),returnPromise:true})}else{return cr(e,t,k(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:k(r.target),swapOverride:r.swap,returnPromise:true})}}else{return cr(e,t,null,null,{returnPromise:true})}}function fr(e){var t=[];while(e){t.push(e);e=e.parentElement}return t}function cr(e,t,n,f,r){var c=null;var d=null;r=r!=null?r:{};if(r.returnPromise&&typeof Promise!=="undefined"){var h=new Promise(function(e,t){c=e;d=t})}if(n==null){n=_().body}var v=r.handler||dr;if(!G(n)){return}var p=r.targetOverride||ue(n);var g=r.swapOverride||W(n,"hx-swap");if(r.targetOverride===null||(p==null||p==ae)&&g!="none"){Z(n,"htmx:targetError",{target:z(n,"hx-target")});return}var m=n;var i=J(n);var y=W(n,"hx-sync");var x=null;var b=false;if(y){var w=y.split(":");var S=w[0].trim();if(S==="this"){m=le(n,"hx-sync")}else{m=ee(n,S)}y=(w[1]||"drop").trim();i=J(m);if(y==="drop"&&i.xhr&&i.abortable!==true){return}else if(y==="abort"){if(i.xhr){return}else{b=true}}else if(y==="replace"){K(m,"htmx:abort")}else if(y.indexOf("queue")===0){var E=y.split(" ");x=(E[1]||"last").trim()}}if(i.xhr){if(i.abortable){K(m,"htmx:abort")}else{if(x==null){if(f){var C=J(f);if(C&&C.triggerSpec&&C.triggerSpec.queue){x=C.triggerSpec.queue}}if(x==null){x="last"}}if(i.queuedRequests==null){i.queuedRequests=[]}if(x==="first"&&i.queuedRequests.length===0){i.queuedRequests.push(function(){cr(e,t,n,f,r)})}else if(x==="all"){i.queuedRequests.push(function(){cr(e,t,n,f,r)})}else if(x==="last"){i.queuedRequests=[];i.queuedRequests.push(function(){cr(e,t,n,f,r)})}return}}var o=new XMLHttpRequest;i.xhr=o;i.abortable=b;var a=function(){i.xhr=null;i.abortable=false;if(i.queuedRequests!=null&&i.queuedRequests.length>0){var e=i.queuedRequests.shift();e()}};var R=W(n,"hx-prompt");if(R){var O=prompt(R);if(O===null||!K(n,"htmx:prompt",{prompt:O,target:p})){Y(c);a();return h}}var L=W(n,"hx-confirm");if(L){if(!confirm(L)){Y(c);a();return h}}var s=$t(n,p,O);if(r.headers){s=Q(s,r.headers)}var q=zt(n,e);var A=q.errors;var T=q.values;if(r.values){T=Q(T,r.values)}var H=or(n);var N=Q(T,H);var k=Zt(N,n);if(e!=="get"&&W(n,"hx-encoding")==null&&!s["Content-Type"]){s["Content-Type"]="application/x-www-form-urlencoded"}if(t==null||t===""){t=_().location.href}var P=tr(n,"hx-request");var l={parameters:k,unfilteredParameters:N,headers:s,target:p,verb:e,errors:A,withCredentials:r.credentials||P.credentials||U.config.withCredentials,timeout:r.timeout||P.timeout||U.config.timeout,path:t,triggeringEvent:f};if(!K(n,"htmx:configRequest",l)){Y(c);a();return h}t=l.path;e=l.verb;s=l.headers;k=l.parameters;A=l.errors;if(A&&A.length>0){K(n,"htmx:validation:halted",l);Y(c);a();return h}var I=t.split("#");var M=I[0];var D=I[1];if(e==="get"||e==="delete"){var F=M;var X=Object.keys(k).length!==0;if(X){if(F.indexOf("?")<0){F+="?"}else{F+="&"}F+=Wt(k);if(D){F+="#"+D}}o.open(e.toUpperCase(),F,true)}else{o.open(e.toUpperCase(),t,true)}o.overrideMimeType("text/html");o.withCredentials=l.withCredentials;o.timeout=l.timeout;if(P.noHeaders){}else{for(var V in s){if(s.hasOwnProperty(V)){var j=s[V];ar(o,V,j)}}}var u={xhr:o,target:p,requestConfig:l,etc:r,pathInfo:{path:t,finalPath:F,anchor:D},swapOverride:r.swapOverride};o.onload=function(){try{var e=fr(n);v(n,u);if(!lr(o,/HX-Redirect:/i)){Xt(B)}K(n,"htmx:afterRequest",u);K(n,"htmx:afterOnLoad",u);if(!G(n)){var t=null;while(e.length>0&&t==null){var r=e.shift();if(G(r)){t=r}}if(t){K(t,"htmx:afterRequest",u);K(t,"htmx:afterOnLoad",u)}}Y(c);a()}catch(e){Z(n,"htmx:onLoadError",Q({error:e},u));throw e}};o.onerror=function(){Xt(B);Z(n,"htmx:afterRequest",u);Z(n,"htmx:sendError",u);Y(d);a()};o.onabort=function(){Xt(B);Z(n,"htmx:afterRequest",u);Z(n,"htmx:sendAbort",u);Y(d);a()};o.ontimeout=function(){Xt(B);Z(n,"htmx:afterRequest",u);Z(n,"htmx:timeout",u);Y(d);a()};if(!K(n,"htmx:beforeRequest",u)){Y(c);a();return h}var B=Ft(n);$(["loadstart","loadend","progress","abort"],function(t){$([o,o.upload],function(e){e.addEventListener(t,function(e){K(n,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});K(n,"htmx:beforeSend",u);o.send(e==="get"?null:Gt(o,n,k));return h}function dr(s,l){var u=l.xhr;var f=l.target;var e=u.status>=400;l.isError=e;if(!K(s,"htmx:beforeOnLoad",l))return;if(lr(u,/HX-Trigger:/i)){Te(u,"HX-Trigger",s)}if(lr(u,/HX-Push:/i)){var c=u.getResponseHeader("HX-Push")}if(lr(u,/HX-Redirect:/i)){window.location.href=u.getResponseHeader("HX-Redirect");return}if(lr(u,/HX-Refresh:/i)){if("true"===u.getResponseHeader("HX-Refresh")){location.reload();return}}if(lr(u,/HX-Retarget:/i)){l.target=_().querySelector(u.getResponseHeader("HX-Retarget"))}var d;if(c=="false"){d=false}else{d=Mt(s)||c}var r=u.status>=200&&u.status<400&&u.status!==204;var h=u.response;var t=Q({shouldSwap:r,serverResponse:h,isError:e},l);if(e){t.shouldSwap=true}if(f&&!K(f,"htmx:beforeSwap",t))return;f=t.target;h=t.serverResponse;e=t.isError;l.failed=e;l.successful=!e;if(e){f=fe(s);if(!f){return}}if(t.shouldSwap){if(u.status===286){Ue(s)}Ct(s,function(e){h=e.transformResponse(h,u,s)});if(d){Ht()}var v=Yt(s,e,false,l.swapOverride);if(f){f.classList.add(U.config.swappingClass)}var n=function(){try{var e=document.activeElement;var t={};try{t={elt:e,start:e?e.selectionStart:null,end:e?e.selectionEnd:null}}catch(e){}var n=Qt(f);Ae(v.swapStyle,f,s,h,n);if(t.elt&&!G(t.elt)&&t.elt.id){var r=document.getElementById(t.elt.id);var i={preventScroll:v.focusScroll!==undefined?!v.focusScroll:!U.config.defaultFocusScroll};if(r){if(t.start&&r.setSelectionRange){r.setSelectionRange(t.start,t.end)}r.focus(i)}}if(f){f.classList.remove(U.config.swappingClass)}$(n.elts,function(e){if(e.classList){e.classList.add(U.config.settlingClass)}K(e,"htmx:afterSwap",l)});if(l.pathInfo.anchor){location.hash=l.pathInfo.anchor}if(lr(u,/HX-Trigger-After-Swap:/i)){var o=s;if(!G(s)){o=_().body}Te(u,"HX-Trigger-After-Swap",o)}var a=function(){$(n.tasks,function(e){e.call()});$(n.elts,function(e){if(e.classList){e.classList.remove(U.config.settlingClass)}K(e,"htmx:afterSettle",l)});if(d){var e=c||Dt(s)||sr(u)||l.pathInfo.finalPath||l.pathInfo.path;Nt(e);K(_().body,"htmx:pushedIntoHistory",{path:e})}if(n.title){var t=C("title");if(t){t.innerHTML=n.title}else{window.document.title=n.title}}er(n.elts,v);if(lr(u,/HX-Trigger-After-Settle:/i)){var r=s;if(!G(s)){r=_().body}Te(u,"HX-Trigger-After-Settle",r)}};if(v.settleDelay>0){setTimeout(a,v.settleDelay)}else{te(function(){a()})}}catch(e){Z(s,"htmx:swapError",l);throw e}};if(v.swapDelay>0){setTimeout(n,v.swapDelay)}else{n()}}if(e){Z(s,"htmx:responseError",Q({error:"Response Status Error Code "+u.status+" from "+l.pathInfo.path},l))}}var hr={};function vr(){return{init:function(e){return null},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 pr(e,t){if(t.init){t.init(r)}hr[e]=Q(vr(),t)}function gr(e){delete hr[e]}function mr(e,r,n){if(e==undefined){return r}if(r==undefined){r=[]}if(n==undefined){n=[]}var t=z(e,"hx-ext");if(t){$(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=hr[e];if(t&&r.indexOf(t)<0){r.push(t)}}})}return mr(u(e),r,n)}function yr(e){if(_().readyState!=="loading"){e()}else{_().addEventListener("DOMContentLoaded",e)}}function xr(){if(U.config.includeIndicatorStyles!==false){_().head.insertAdjacentHTML("beforeend","")}}function br(){var e=_().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function wr(){var e=br();if(e){U.config=Q(U.config,e)}}yr(function(){wr();xr();var e=_().body;bt(e);var t=_().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){var t=e.target;var r=J(t);if(r&&r.xhr){r.xhr.abort()}});window.onpopstate=function(e){if(e.state&&e.state.htmx){It();$(t,function(e){K(e,"htmx:restored",{document:_(),triggerEvent:K})})}};oe();setTimeout(function(){K(e,"htmx:load",{})},0)});return U}()}); \ No newline at end of file +(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 U={onLoad:t,process:bt,on:I,off:M,trigger:K,ajax:fr,find:C,findAll:R,closest:H,values:function(e,t){var r=zt(e,t||"post");return r.values},remove:O,addClass:L,removeClass:q,toggleClass:A,takeClass:T,defineExtension:gr,removeExtension:mr,logAll:E,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,inlineScriptNonce:"",withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",disableSelector:"[hx-disable], [data-hx-disable]",useTemplateFragments:false,scrollBehavior:"smooth",defaultFocusScroll:false},eventSources:[],parseInterval:g,_:e,createEventSource:function(e){const t=new EventSource(e,{withCredentials:true});U.eventSources.push(t);return t},createWebSocket:function(e){return new WebSocket(e,[])},readLayout:B,writeLayout:te,resizeSelect:re,version:"1.7.0"};var r={bodyContains:G,filterValues:Zt,hasAttribute:s,getAttributeValue:z,getClosestMatch:c,getExpressionVars:ar,getHeaders:$t,getInputValues:zt,getInternalData:J,getSwapSpecification:Gt,getTriggerSpecs:Be,getTarget:ue,makeFragment:v,mergeObjects:Q,makeSettleInfo:er,oobSwap:de,selectAndSwap:Ae,settleImmediately:kt,shouldCancel:Je,triggerEvent:K,triggerErrorEvent:Z,withExtensions:Ct};var n=["get","post","put","delete","patch"];var i=n.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function g(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 f(e,t){return e.getAttribute&&e.getAttribute(t)}function s(e,t){return e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function z(e,t){return f(e,t)||f(e,"data-"+t)}function u(e){return e.parentElement}function _(){return document}function c(e,t){if(t(e)){return e}else if(u(e)){return c(u(e),t)}else{return null}}function o(e,t,r){var n=z(t,r);var i=z(t,"hx-disinherit");if(e!==t&&i&&(i==="*"||i.split(" ").indexOf(r)>=0)){return"unset"}else{return n}}function W(t,r){var n=null;c(t,function(e){return n=o(t,e,r)});if(n!=="unset"){return n}}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 a(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 l(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=_().createDocumentFragment()}return i}function v(e){if(U.config.useTemplateFragments){var t=l("",0);return t.querySelector("template").content}else{var r=a(e);switch(r){case"thead":case"tbody":case"tfoot":case"colgroup":case"caption":return l(""+e+"
",1);case"col":return l(""+e+"
",2);case"tr":return l(""+e+"
",2);case"td":case"th":return l(""+e+"
",3);case"script":return l("
"+e+"
",1);default:return l(e,0)}}}function Y(e){if(e){e()}}function p(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function m(e){return p(e,"Function")}function y(e){return p(e,"Object")}function J(e){var t="htmx-internal-data";var r=e[t];if(!r){r=e[t]={}}return r}function x(e){var t=[];if(e){for(var r=0;r=0}function G(e){if(e.getRootNode()instanceof ShadowRoot){return _().body.contains(e.getRootNode().host)}else{return _().body.contains(e)}}function w(e){return e.trim().split(/\s+/)}function Q(e,t){for(var r in t){if(t.hasOwnProperty(r)){e[r]=t[r]}}return e}function S(e){try{return JSON.parse(e)}catch(e){Rt(e);return null}}function e(e){return nr(_().body,function(){return eval(e)})}function t(t){var e=U.on("htmx:load",function(e){t(e.detail.elt)});return e}function E(){U.logger=function(e,t,r){if(console){console.log(t,e,r)}}}function C(e,t){if(t){return e.querySelector(t)}else{return C(_(),e)}}function R(e,t){if(t){return e.querySelectorAll(t)}else{return R(_(),e)}}function O(e,t){e=k(e);if(t){setTimeout(function(){O(e)},t)}else{e.parentElement.removeChild(e)}}function L(e,t,r){e=k(e);if(r){setTimeout(function(){L(e,t)},r)}else{e.classList&&e.classList.add(t)}}function q(e,t,r){e=k(e);if(r){setTimeout(function(){q(e,t)},r)}else{if(e.classList){e.classList.remove(t);if(e.classList.length===0){e.removeAttribute("class")}}}}function A(e,t){e=k(e);e.classList.toggle(t)}function T(e,t){e=k(e);$(e.parentElement.children,function(e){q(e,t)});L(e,t)}function H(e,t){e=k(e);if(e.closest){return e.closest(t)}else{do{if(e==null||h(e,t)){return e}}while(e=e&&u(e))}}function N(e,t){if(t.indexOf("closest ")===0){return[H(e,t.substr(8))]}else if(t.indexOf("find ")===0){return[C(e,t.substr(5))]}else if(t==="document"){return[document]}else if(t==="window"){return[window]}else{return _().querySelectorAll(t)}}function ee(e,t){if(t){return N(e,t)[0]}else{return N(_().body,e)[0]}}function k(e){if(p(e,"String")){return C(e)}else{return e}}function P(e,t,r){if(m(t)){return{target:_().body,event:e,listener:t}}else{return{target:k(e),event:t,listener:r}}}function I(t,r,n){xr(function(){var e=P(t,r,n);e.target.addEventListener(e.event,e.listener)});var e=m(r);return e?r:n}function M(t,r,n){xr(function(){var e=P(t,r,n);e.target.removeEventListener(e.event,e.listener)});return m(r)?r:n}let d;let F;let D=[],X=[];const V=[];let j;function B(e){D.push(e);if(document.hidden){ne()}}function te(e){X.push(e);if(document.hidden){ne()}}function re(e){if(e.options.length>1&&e.options[e.selectedIndex]){B(function(){V.push(e)})}}function ne(){const t=D;D=[];for(let e=0;e0){j=V[0];V.splice(0,1);const f=j.options[j.selectedIndex];const n=getComputedStyle(j);const i=n.getPropertyValue("height");const o=n.getPropertyValue("padding");const a=n.getPropertyValue("font-family");const s=n.getPropertyValue("border");const l=n.getPropertyValue("box-sizing");const u=n.getPropertyValue("appearance");const c=f.textContent.trim();if(document.hidden){F.textContent=c;d.style.setProperty("height",i);d.style.setProperty("padding",o);d.style.setProperty("fontFamily",a);d.style.setProperty("border",s);d.style.setProperty("boxSizing",l);d.style.setProperty("appearance",u)}else{te(function(){F.textContent=c;d.style.setProperty("height",i);d.style.setProperty("padding",o);d.style.setProperty("fontFamily",a);d.style.setProperty("border",s);d.style.setProperty("boxSizing",l);d.style.setProperty("appearance",u)})}}const r=X;X=[];for(let e=0;e0){a=e.substr(0,e.indexOf(":"));t=e.substr(e.indexOf(":")+1,e.length)}else{a=e}var r=_().querySelectorAll(t);if(r){$(r,function(e){var t;var r=i.cloneNode(true);t=_().createDocumentFragment();t.appendChild(r);if(!ce(a,e)){t=r}var n={shouldSwap:true,target:e,fragment:t};if(!K(e,"htmx:oobBeforeSwap",n))return;e=n.target;if(n["shouldSwap"]){Le(a,e,e,t,o)}$(o.elts,function(e){K(e,"htmx:oobAfterSwap",n)})});i.parentNode.removeChild(i)}else{i.parentNode.removeChild(i);Z(_().body,"htmx:oobErrorNoTarget",{content:i})}return e}function he(e,r){$(R(e,"[hx-swap-oob], [data-hx-swap-oob]"),function(e){var t=z(e,"hx-swap-oob");if(t!=null){de(t,e,r)}})}function ve(e){$(R(e,"[hx-preserve], [data-hx-preserve]"),function(e){var t=z(e,"id");var r=_().getElementById(t);if(r!=null){e.parentNode.replaceChild(r,e)}})}function pe(e){return function(){q(e,U.config.addedClass);bt(e);pt(e);ge(e);K(e,"htmx:load")}}function ge(e){var t="[autofocus]";var r=h(e,t)?e:e.querySelector(t);if(r!=null){r.focus()}}function me(e,t,r,n){while(r.childNodes.length>0){var i=r.firstChild;L(i,U.config.addedClass);e.insertBefore(i,t);if(i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.COMMENT_NODE){n.tasks.push(pe(i))}}}function ye(t){var e=J(t);if(e.webSocket){e.webSocket.close()}if(e.sseEventSource){e.sseEventSource.close()}K(t,"htmx:beforeCleanupElement");if(e.listenerInfos){$(e.listenerInfos,function(e){if(t!==e.on){e.on.removeEventListener(e.trigger,e.listener)}})}if(t.children){$(t.children,function(e){ye(e)})}}function xe(e,t,r){if(e.tagName==="BODY"){return Re(e,t,r)}else{if(!u(e)){return}var n;var i=e.previousSibling;me(u(e),e,t,r);if(i==null){n=u(e).firstChild}else{n=i.nextSibling}J(e).replacedWith=n;r.elts=[];while(n&&n!==e){if(n.nodeType===Node.ELEMENT_NODE){r.elts.push(n)}n=n.nextElementSibling}te(function(){ye(e)});u(e).removeChild(e)}}function be(e,t,r){return me(e,e.firstChild,t,r)}function we(e,t,r){return me(u(e),e,t,r)}function Se(e,t,r){return me(e,null,t,r)}function Ee(e,t,r){return me(u(e),e.nextSibling,t,r)}function Ce(e,t,r){ye(e);return u(e).removeChild(e)}function Re(e,t,r){var n=e.firstChild;me(e,n,t,r);if(n){while(n.nextSibling){var i=n.nextSibling;te(function(){ye(i)});e.removeChild(n.nextSibling)}te(function(){ye(n)});e.removeChild(n)}}function Oe(e,t){var r=W(e,"hx-select");if(r){var n=_().createDocumentFragment();$(t.querySelectorAll(r),function(e){n.appendChild(e)});t=n}return t}function Le(e,t,r,n,i){switch(e){case"none":return;case"outerHTML":xe(r,n,i);return;case"afterbegin":be(r,n,i);return;case"beforebegin":we(r,n,i);return;case"beforeend":Se(r,n,i);return;case"afterend":Ee(r,n,i);return;case"delete":Ce(r,n,i);return;default:var o=yr(t);for(var a=0;a-1){var t=e.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");var r=t.match(/]*>|>)([\s\S]*?)<\/title>/im);if(r){return r[2]}}}function Ae(e,t,r,n,i){i.title=qe(n);var o=v(n);if(o){he(o,i);o=Oe(r,o);ve(o);return Le(e,r,t,o,i)}}function Te(e,t,r){var n=e.getResponseHeader(t);if(n.indexOf("{")===0){var i=S(n);for(var o in i){if(i.hasOwnProperty(o)){var a=i[o];if(!y(a)){a={value:a}}K(r,o,a)}}}else{if(typeof n==="string"){const s=n.split(", ");for(var o of s){K(r,o,[])}}else{K(r,n,[])}}}var He=/\s/;var Ne=/[\s,]/;var ke=/[_$a-zA-Z]/;var Pe=/[_$a-zA-Z0-9]/;var Ie=['"',"'","/"];var Me=/[^\s]/;function Fe(e){var t=[];var r=0;while(r0){var a=t[0];if(a==="]"){n--;if(n===0){if(o===null){i=i+"true"}t.shift();i+=")})";try{var s=nr(e,function(){return Function(i)()},function(){return true});s.source=i;return s}catch(e){Z(_().body,"htmx:syntax:error",{error:e,source:i});return null}}}else if(a==="["){n++}if(De(a,o,r)){i+="(("+r+"."+a+") ? ("+r+"."+a+") : (window."+a+"))"}else{i=i+a}o=t.shift()}}}function Ve(e,t){var r="";while(e.length>0&&!e[0].match(t)){r+=e.shift()}return r}var je="input, textarea, select";function Be(e){var t=z(e,"hx-trigger");var r=[];if(t){var n=Fe(t);do{Ve(n,Me);var f=n.length;var i=Ve(n,/[,\[\s]/);if(i!==""){if(i==="every"){var o={trigger:"every"};Ve(n,Me);o.pollInterval=g(Ve(n,/[,\[\s]/));Ve(n,Me);var a=Xe(e,n,"event");if(a){o.eventFilter=a}r.push(o)}else if(i.indexOf("sse:")===0){r.push({trigger:"sse",sseEvent:i.substring(4)})}else{var s={trigger:i};var a=Xe(e,n,"event");if(a){s.eventFilter=a}while(n.length>0&&n[0]!==","){Ve(n,Me);var l=n.shift();if(l==="changed"){s.changed=true}else if(l==="once"){s.once=true}else if(l==="consume"){s.consume=true}else if(l==="delay"&&n[0]===":"){n.shift();s.delay=g(Ve(n,Ne))}else if(l==="from"&&n[0]===":"){n.shift();var u=Ve(n,Ne);if(u==="closest"||u==="find"){n.shift();u+=" "+Ve(n,Ne)}s.from=u}else if(l==="target"&&n[0]===":"){n.shift();s.target=Ve(n,Ne)}else if(l==="throttle"&&n[0]===":"){n.shift();s.throttle=g(Ve(n,Ne))}else if(l==="queue"&&n[0]===":"){n.shift();s.queue=Ve(n,Ne)}else if((l==="root"||l==="threshold")&&n[0]===":"){n.shift();s[l]=Ve(n,Ne)}else{Z(e,"htmx:syntax:error",{token:n.shift()})}}r.push(s)}}if(n.length===f){Z(e,"htmx:syntax:error",{token:n.shift()})}Ve(n,Me)}while(n[0]===","&&n.shift())}if(r.length>0){return r}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"]')){return[{trigger:"click"}]}else if(h(e,je)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function Ue(e){J(e).cancelled=true}function ze(e,t,r,n){var i=J(e);i.timeout=setTimeout(function(){if(G(e)&&i.cancelled!==true){if(!Ze(n,St("hx:poll:trigger",{triggerSpec:n,target:e}))){dr(t,r,e)}ze(e,t,z(e,"hx-"+t),n)}},n.pollInterval)}function _e(e){return location.hostname===e.hostname&&f(e,"href")&&f(e,"href").indexOf("#")!==0}function We(t,r,e){if(t.tagName==="A"&&_e(t)&&t.target===""||t.tagName==="FORM"){r.boosted=true;var n,i;if(t.tagName==="A"){n="get";i=f(t,"href");r.pushURL=true}else{var o=f(t,"method");n=o?o.toLowerCase():"get";if(n==="get"){r.pushURL=true}i=f(t,"action")}e.forEach(function(e){Ke(t,n,i,r,e,true)})}}function Je(e,t){if(e.type==="submit"||e.type==="click"){if(t.tagName==="FORM"){return true}if(h(t,'input[type="submit"], button')&&H(t,"form")!==null){return true}if(t.tagName==="A"&&t.href&&(t.getAttribute("href")==="#"||t.getAttribute("href").indexOf("#")!==0)){return true}}return false}function $e(e,t){return J(e).boosted&&e.tagName==="A"&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function Ze(e,t){var r=e.eventFilter;if(r){try{return r(t)!==true}catch(e){Z(_().body,"htmx:eventFilter:error",{error:e,source:r.source});return true}}return false}function Ke(o,a,s,e,l,u){var t;if(l.from){t=N(o,l.from)}else{t=[o]}$(t,function(n){var i=function(e){if(!G(o)){n.removeEventListener(l.trigger,i);return}if($e(o,e)){return}if(u||Je(e,o)){e.preventDefault()}if(Ze(l,e)){return}var t=J(e);t.triggerSpec=l;if(t.handledFor==null){t.handledFor=[]}var r=J(o);if(t.handledFor.indexOf(o)<0){t.handledFor.push(o);if(l.consume){e.stopPropagation()}if(l.target&&e.target){if(!h(e.target,l.target)){return}}if(l.once){if(r.triggeredOnce){return}else{r.triggeredOnce=true}}if(l.changed){if(r.lastValue===o.value){return}else{r.lastValue=o.value}}if(r.delayed){clearTimeout(r.delayed)}if(r.throttle){return}if(l.throttle){if(!r.throttle){dr(a,s,o,e);r.throttle=setTimeout(function(){r.throttle=null},l.throttle)}}else if(l.delay){r.delayed=setTimeout(function(){dr(a,s,o,e)},l.delay)}else{dr(a,s,o,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:l.trigger,listener:i,on:n});n.addEventListener(l.trigger,i)})}var Ye=false;var Ge=null;function Qe(){if(!Ge){Ge=function(){Ye=true};window.addEventListener("scroll",Ge);setInterval(function(){if(Ye){Ye=false;$(_().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"),function(e){et(e)})}},200)}}function et(e){if(!s(e,"data-hx-revealed")&&b(e)){e.setAttribute("data-hx-revealed","true");var t=J(e);if(t.initialized){dr(t.verb,t.path,e)}else{e.addEventListener("htmx:afterProcessNode",function(){dr(t.verb,t.path,e)},{once:true})}}}function tt(e,t,r){var n=w(r);for(var i=0;i=0){var t=ot(n);setTimeout(function(){rt(s,r,n+1)},t)}};t.onopen=function(e){n=0};J(s).webSocket=t;t.addEventListener("message",function(e){if(nt(s)){return}var t=e.data;Ct(s,function(e){t=e.transformResponse(t,null,s)});var r=er(s);var n=v(t);var i=x(n.children);for(var o=0;o0){K(u,"htmx:validation:halted",i);return}t.send(JSON.stringify(l));if(Je(e,u)){e.preventDefault()}})}else{Z(u,"htmx:noWebSocketSourceError")}}function ot(e){var t=U.config.wsReconnectDelay;if(typeof t==="function"){return t(e)}if(t==="full-jitter"){var r=Math.min(e,6);var n=1e3*Math.pow(2,r);return n*Math.random()}Rt('htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"')}function at(e,t,r){var n=w(r);for(var i=0;iU.config.historyCacheSize){i.shift()}while(i.length>0){try{localStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){Z(_().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function At(e){var t=S(localStorage.getItem("htmx-history-cache"))||[];for(var r=0;r=200&&this.status<400){K(_().body,"htmx:historyCacheMissLoad",i);var e=v(this.response);e=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;var t=Lt();var r=er(t);Re(t,e,r);kt(r.tasks);Ot=n;K(_().body,"htmx:historyRestore",{path:n})}else{Z(_().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function It(e){Ht();e=e||location.pathname+location.search;var t=At(e);if(t){var r=v(t.content);var n=Lt();var i=er(n);Re(n,r,i);kt(i.tasks);document.title=t.title;window.scrollTo(0,t.scroll);Ot=e;K(_().body,"htmx:historyRestore",{path:e})}else{if(U.config.refreshOnHistoryMiss){window.location.reload(true)}else{Pt(e)}}}function Mt(e){var t=z(e,"hx-push-url");if(!t||t==="false"){return false}if(t==="inherit"){var r=u(e);if(!r){Z(e,"htmx:pushUrlInheritNoParentError");return false}t=W(r,"hx-push-url")}return t&&t!=="false"||J(e).boosted&&J(e).pushURL}function Ft(e){var t=W(e,"hx-push-url");if(t==="inherit"){var r=u(e);if(!r){Z(e,"htmx:pushUrlInheritNoParentError");return false}t=W(r,"hx-push-url")}return t==="true"||t==="false"?null:t}function Dt(e){var t=se(e,"hx-indicator");if(t==null){t=[e]}$(t,function(e){e.classList["add"].call(e.classList,U.config.requestClass)});return t}function Xt(e){$(e,function(e){e.classList["remove"].call(e.classList,U.config.requestClass)})}function Vt(e,t){for(var r=0;r=0}function Gt(e,t,f,r){var n;if(typeof r==="string"){n=r}else if(t){n=W(e,"hx-error-swap")}else if(f){n=W(e,"hx-sse-swap")}if(!t&&!n){n=W(e,"hx-swap")}var i={swapStyle:J(e).boosted?"innerHTML":U.config.defaultSwapStyle,swapDelay:U.config.defaultSwapDelay,settleDelay:U.config.defaultSettleDelay};if(J(e).boosted&&!Yt(e)){i["show"]="top"}if(n){var o=w(n);if(o.length>0){i["swapStyle"]=o[0];for(var a=1;a0?l.join(":"):null;i["scroll"]=d;i["scrollTarget"]=u}if(s.indexOf("show:")===0){var h=s.substr(5);var l=h.split(":");var v=l.pop();var u=l.length>0?l.join(":"):null;i["show"]=v;i["showTarget"]=u}if(s.indexOf("focus-scroll:")===0){var p=s.substr("focus-scroll:".length);i["focusScroll"]=p=="true"}}}}return i}function Qt(t,r,n){var i=null;Ct(r,function(e){if(i==null){i=e.encodeParameters(t,n,r)}});if(i!=null){return i}else{if(W(r,"hx-encoding")==="multipart/form-data"||h(r,"form")&&f(r,"enctype")==="multipart/form-data"||Kt(n)){return Jt(n)}else{return Wt(n)}}}function er(e){return{tasks:[],elts:e?[e]:[]}}function tr(e,t){var r=e[0];var n=e[e.length-1];if(t.scroll){var i=null;if(t.scrollTarget){i=ee(r,t.scrollTarget)}if(t.scroll==="top"&&(r||i)){i=i||r;i.scrollTop=0}if(t.scroll==="bottom"&&(n||i)){i=i||n;i.scrollTop=i.scrollHeight}}if(t.show){var i=null;if(t.showTarget){var o=t.showTarget;if(t.showTarget==="window"){o="body"}i=ee(r,o)}if(t.show==="top"&&(r||i)){i=i||r;i.scrollIntoView({block:"start",behavior:U.config.scrollBehavior})}if(t.show==="bottom"&&(n||i)){i=i||n;i.scrollIntoView({block:"end",behavior:U.config.scrollBehavior})}}}function rr(e,t,r,n){if(n==null){n={}}if(e==null){return n}var i=z(e,t);if(i){var o=i.trim();var a=r;if(o.indexOf("javascript:")===0){o=o.substr(11);a=true}else if(o.indexOf("js:")===0){o=o.substr(3);a=true}if(o.indexOf("{")!==0){o="{"+o+"}"}var s;if(a){s=nr(e,function(){return Function("return ("+o+")")()},{})}else{s=S(o)}for(var l in s){if(s.hasOwnProperty(l)){if(n[l]==null){n[l]=s[l]}}}}return rr(u(e),t,r,n)}function nr(e,t,r){if(U.config.allowEval){return t()}else{Z(e,"htmx:evalDisallowedError");return r}}function ir(e,t){return rr(e,"hx-vars",true,t)}function or(e,t){return rr(e,"hx-vals",false,t)}function ar(e){return Q(ir(e),or(e))}function sr(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 lr(t){if(t.responseURL&&typeof URL!=="undefined"){try{var e=new URL(t.responseURL);return e.pathname+e.search}catch(e){Z(_().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function ur(e,t){return e.getAllResponseHeaders().match(t)}function fr(e,t,r){e=e.toLowerCase();if(r){if(r instanceof Element||p(r,"String")){return dr(e,t,null,null,{targetOverride:k(r),returnPromise:true})}else{return dr(e,t,k(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:k(r.target),swapOverride:r.swap,returnPromise:true})}}else{return dr(e,t,null,null,{returnPromise:true})}}function cr(e){var t=[];while(e){t.push(e);e=e.parentElement}return t}function dr(e,t,n,f,r){var c=null;var d=null;r=r!=null?r:{};if(r.returnPromise&&typeof Promise!=="undefined"){var h=new Promise(function(e,t){c=e;d=t})}if(n==null){n=_().body}var v=r.handler||hr;if(!G(n)){return}var p=r.targetOverride||ue(n);var g=r.swapOverride||W(n,"hx-swap");if(r.targetOverride===null||(p==null||p==ae)&&g!="none"){Z(n,"htmx:targetError",{target:z(n,"hx-target")});return}var m=n;var i=J(n);var y=W(n,"hx-sync");var x=null;var b=false;if(y){var w=y.split(":");var S=w[0].trim();if(S==="this"){m=le(n,"hx-sync")}else{m=ee(n,S)}y=(w[1]||"drop").trim();i=J(m);if(y==="drop"&&i.xhr&&i.abortable!==true){return}else if(y==="abort"){if(i.xhr){return}else{b=true}}else if(y==="replace"){K(m,"htmx:abort")}else if(y.indexOf("queue")===0){var E=y.split(" ");x=(E[1]||"last").trim()}}if(i.xhr){if(i.abortable){K(m,"htmx:abort")}else{if(x==null){if(f){var C=J(f);if(C&&C.triggerSpec&&C.triggerSpec.queue){x=C.triggerSpec.queue}}if(x==null){x="last"}}if(i.queuedRequests==null){i.queuedRequests=[]}if(x==="first"&&i.queuedRequests.length===0){i.queuedRequests.push(function(){dr(e,t,n,f,r)})}else if(x==="all"){i.queuedRequests.push(function(){dr(e,t,n,f,r)})}else if(x==="last"){i.queuedRequests=[];i.queuedRequests.push(function(){dr(e,t,n,f,r)})}return}}var o=new XMLHttpRequest;i.xhr=o;i.abortable=b;var a=function(){i.xhr=null;i.abortable=false;if(i.queuedRequests!=null&&i.queuedRequests.length>0){var e=i.queuedRequests.shift();e()}};var R=W(n,"hx-prompt");if(R){var O=prompt(R);if(O===null||!K(n,"htmx:prompt",{prompt:O,target:p})){Y(c);a();return h}}var L=W(n,"hx-confirm");if(L){if(!confirm(L)){Y(c);a();return h}}var s=$t(n,p,O);if(r.headers){s=Q(s,r.headers)}var q=zt(n,e);var A=q.errors;var T=q.values;if(r.values){T=Q(T,r.values)}var H=ar(n);var N=Q(T,H);var k=Zt(N,n);if(e!=="get"&&W(n,"hx-encoding")==null&&!s["Content-Type"]&&!Kt(k)){s["Content-Type"]="application/x-www-form-urlencoded"}if(t==null||t===""){t=_().location.href}var P=rr(n,"hx-request");var l={parameters:k,unfilteredParameters:N,headers:s,target:p,verb:e,errors:A,withCredentials:r.credentials||P.credentials||U.config.withCredentials,timeout:r.timeout||P.timeout||U.config.timeout,path:t,triggeringEvent:f};if(!K(n,"htmx:configRequest",l)){Y(c);a();return h}t=l.path;e=l.verb;s=l.headers;k=l.parameters;A=l.errors;if(A&&A.length>0){K(n,"htmx:validation:halted",l);Y(c);a();return h}var I=t.split("#");var M=I[0];var F=I[1];if(e==="get"||e==="delete"){var D=M;var X=Object.keys(k).length!==0;if(X){if(D.indexOf("?")<0){D+="?"}else{D+="&"}D+=Wt(k);if(F){D+="#"+F}}o.open(e.toUpperCase(),D,true)}else{o.open(e.toUpperCase(),t,true)}o.overrideMimeType("text/html");o.withCredentials=l.withCredentials;o.timeout=l.timeout;if(P.noHeaders){}else{for(var V in s){if(s.hasOwnProperty(V)){var j=s[V];sr(o,V,j)}}}var u={xhr:o,target:p,requestConfig:l,etc:r,pathInfo:{path:t,finalPath:D,anchor:F},swapOverride:r.swapOverride};o.onload=function(){try{var e=cr(n);v(n,u);if(!ur(o,/HX-Redirect:/i)){Xt(B)}K(n,"htmx:afterRequest",u);K(n,"htmx:afterOnLoad",u);if(!G(n)){var t=null;while(e.length>0&&t==null){var r=e.shift();if(G(r)){t=r}}if(t){K(t,"htmx:afterRequest",u);K(t,"htmx:afterOnLoad",u)}}Y(c);a()}catch(e){Z(n,"htmx:onLoadError",Q({error:e},u));throw e}};o.onerror=function(){Xt(B);Z(n,"htmx:afterRequest",u);Z(n,"htmx:sendError",u);Y(d);a()};o.onabort=function(){Xt(B);Z(n,"htmx:afterRequest",u);Z(n,"htmx:sendAbort",u);Y(d);a()};o.ontimeout=function(){Xt(B);Z(n,"htmx:afterRequest",u);Z(n,"htmx:timeout",u);Y(d);a()};if(!K(n,"htmx:beforeRequest",u)){Y(c);a();return h}var B=Dt(n);$(["loadstart","loadend","progress","abort"],function(t){$([o,o.upload],function(e){e.addEventListener(t,function(e){K(n,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});K(n,"htmx:beforeSend",u);o.send(e==="get"?null:Qt(o,n,k));return h}function hr(s,l){var u=l.xhr;var f=l.target;var e=u.status>=400;l.isError=e;if(!K(s,"htmx:beforeOnLoad",l))return;if(ur(u,/HX-Trigger:/i)){Te(u,"HX-Trigger",s)}if(ur(u,/HX-Push:/i)){var c=u.getResponseHeader("HX-Push")}if(ur(u,/HX-Redirect:/i)){window.location.href=u.getResponseHeader("HX-Redirect");return}if(ur(u,/HX-Refresh:/i)){if("true"===u.getResponseHeader("HX-Refresh")){location.reload();return}}if(ur(u,/HX-Retarget:/i)){l.target=_().querySelector(u.getResponseHeader("HX-Retarget"))}var d;if(c=="false"){d=false}else{d=Mt(s)||c}var r=u.status>=200&&u.status<400&&u.status!==204;var h=u.response;var t=Q({shouldSwap:r,serverResponse:h,isError:e},l);if(e){t.shouldSwap=true}if(f&&!K(f,"htmx:beforeSwap",t))return;f=t.target;h=t.serverResponse;e=t.isError;l.failed=e;l.successful=!e;if(e){f=fe(s);if(!f){return}}if(t.shouldSwap){if(u.status===286){Ue(s)}Ct(s,function(e){h=e.transformResponse(h,u,s)});if(d){Ht()}var v=Gt(s,e,false,l.swapOverride);if(f){f.classList.add(U.config.swappingClass)}var n=function(){try{var e=document.activeElement;var t={};try{t={elt:e,start:e?e.selectionStart:null,end:e?e.selectionEnd:null}}catch(e){}var n=er(f);Ae(v.swapStyle,f,s,h,n);if(t.elt&&!G(t.elt)&&t.elt.id){var r=document.getElementById(t.elt.id);var i={preventScroll:v.focusScroll!==undefined?!v.focusScroll:!U.config.defaultFocusScroll};if(r){if(t.start&&r.setSelectionRange){r.setSelectionRange(t.start,t.end)}r.focus(i)}}if(f){f.classList.remove(U.config.swappingClass)}$(n.elts,function(e){if(e.classList){e.classList.add(U.config.settlingClass)}K(e,"htmx:afterSwap",l)});if(l.pathInfo.anchor){location.hash=l.pathInfo.anchor}if(ur(u,/HX-Trigger-After-Swap:/i)){var o=s;if(!G(s)){o=_().body}Te(u,"HX-Trigger-After-Swap",o)}var a=function(){$(n.tasks,function(e){e.call()});$(n.elts,function(e){if(e.classList){e.classList.remove(U.config.settlingClass)}K(e,"htmx:afterSettle",l)});if(d){var e=c||Ft(s)||lr(u)||l.pathInfo.finalPath||l.pathInfo.path;Nt(e);K(_().body,"htmx:pushedIntoHistory",{path:e})}if(n.title){var t=C("title");if(t){t.innerHTML=n.title}else{window.document.title=n.title}}tr(n.elts,v);if(ur(u,/HX-Trigger-After-Settle:/i)){var r=s;if(!G(s)){r=_().body}Te(u,"HX-Trigger-After-Settle",r)}};if(v.settleDelay>0){setTimeout(a,v.settleDelay)}else{te(function(){a()})}}catch(e){Z(s,"htmx:swapError",l);throw e}};if(v.swapDelay>0){setTimeout(n,v.swapDelay)}else{n()}}if(e){Z(s,"htmx:responseError",Q({error:"Response Status Error Code "+u.status+" from "+l.pathInfo.path},l))}}var vr={};function pr(){return{init:function(e){return null},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 gr(e,t){if(t.init){t.init(r)}vr[e]=Q(pr(),t)}function mr(e){delete vr[e]}function yr(e,r,n){if(e==undefined){return r}if(r==undefined){r=[]}if(n==undefined){n=[]}var t=z(e,"hx-ext");if(t){$(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=vr[e];if(t&&r.indexOf(t)<0){r.push(t)}}})}return yr(u(e),r,n)}function xr(e){if(_().readyState!=="loading"){e()}else{_().addEventListener("DOMContentLoaded",e)}}function br(){if(U.config.includeIndicatorStyles!==false){_().head.insertAdjacentHTML("beforeend","")}}function wr(){var e=_().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function Sr(){var e=wr();if(e){U.config=Q(U.config,e)}}xr(function(){Sr();br();var e=_().body;bt(e);var t=_().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){var t=e.target;var r=J(t);if(r&&r.xhr){r.xhr.abort()}});window.onpopstate=function(e){if(e.state&&e.state.htmx){It();$(t,function(e){K(e,"htmx:restored",{document:_(),triggerEvent:K})})}};oe();setTimeout(function(){K(e,"htmx:load",{})},0)});return U}()}); \ No newline at end of file diff --git a/src/htmx.js b/src/htmx.js index 5e2fd68c..71ae5de0 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -2352,6 +2352,20 @@ return (function () { } } + /** + * valuesContainAnyFile returns true if any of the values is a File input value + * @param {Object} inputValues + * @returns {boolean} + */ + function valuesContainAnyFile(inputValues) { + for (var name in inputValues) { + if (inputValues[name] instanceof File) { + return true + } + } + return false + } + function isAnchorLink(elt) { return getRawAttribute(elt, 'href') && getRawAttribute(elt, 'href').indexOf("#") >=0 } @@ -2433,7 +2447,8 @@ return (function () { return encodedParameters; } else { if (getClosestAttributeValue(elt, "hx-encoding") === "multipart/form-data" || - (matches(elt, "form") && getRawAttribute(elt, 'enctype') === "multipart/form-data")) { + (matches(elt, "form") && getRawAttribute(elt, 'enctype') === "multipart/form-data") || + valuesContainAnyFile(filteredParameters)) { return makeFormData(filteredParameters); } else { return urlEncode(filteredParameters); @@ -2773,7 +2788,7 @@ return (function () { var allParameters = mergeObjects(rawParameters, expressionVars); var filteredParameters = filterValues(allParameters, elt); - if (verb !== 'get' && getClosestAttributeValue(elt, "hx-encoding") == null && !headers["Content-Type"]) { + if (verb !== 'get' && getClosestAttributeValue(elt, "hx-encoding") == null && !headers["Content-Type"] && !valuesContainAnyFile(filteredParameters)) { headers['Content-Type'] = 'application/x-www-form-urlencoded'; }