From 9447f3b491794d49636dff1a3ab9737b85d3df91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20M=C3=A9ndez?= Date: Sat, 23 Mar 2024 12:38:19 -0500 Subject: [PATCH] Updated htmx.js and its debug extension --- static/js/ext/ajax-header.js | 7 - static/js/ext/class-tools.js | 84 ------ static/js/ext/client-side-templates.js | 102 ------- static/js/ext/disable-element.js | 16 -- static/js/ext/event-header.js | 37 --- static/js/ext/loading-states.js | 179 ------------- static/js/ext/method-override.js | 11 - static/js/ext/preload.js | 137 ---------- static/js/ext/sse.js | 318 ---------------------- static/js/ext/ws.js | 355 ------------------------- static/js/htmx.min.js | 2 +- 11 files changed, 1 insertion(+), 1247 deletions(-) delete mode 100644 static/js/ext/ajax-header.js delete mode 100644 static/js/ext/class-tools.js delete mode 100644 static/js/ext/client-side-templates.js delete mode 100644 static/js/ext/disable-element.js delete mode 100644 static/js/ext/event-header.js delete mode 100644 static/js/ext/loading-states.js delete mode 100644 static/js/ext/method-override.js delete mode 100644 static/js/ext/preload.js delete mode 100644 static/js/ext/sse.js delete mode 100644 static/js/ext/ws.js diff --git a/static/js/ext/ajax-header.js b/static/js/ext/ajax-header.js deleted file mode 100644 index 5c6221b..0000000 --- a/static/js/ext/ajax-header.js +++ /dev/null @@ -1,7 +0,0 @@ -htmx.defineExtension('ajax-header', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - evt.detail.headers['X-Requested-With'] = 'XMLHttpRequest'; - } - } -}); \ No newline at end of file diff --git a/static/js/ext/class-tools.js b/static/js/ext/class-tools.js deleted file mode 100644 index 08f34b4..0000000 --- a/static/js/ext/class-tools.js +++ /dev/null @@ -1,84 +0,0 @@ -(function(){ - - function splitOnWhitespace(trigger) { - return trigger.split(/\s+/); - } - - function parseClassOperation(trimmedValue) { - var split = splitOnWhitespace(trimmedValue); - if (split.length > 1) { - var operation = split[0]; - var classDef = split[1].trim(); - var cssClass; - var delay; - if (classDef.indexOf(":") > 0) { - var splitCssClass = classDef.split(':'); - cssClass = splitCssClass[0]; - delay = htmx.parseInterval(splitCssClass[1]); - } else { - cssClass = classDef; - delay = 100; - } - return { - operation:operation, - cssClass:cssClass, - delay:delay - } - } else { - return null; - } - } - - function processClassList(elt, classList) { - var runs = classList.split("&"); - for (var i = 0; i < runs.length; i++) { - var run = runs[i]; - var currentRunTime = 0; - var classOperations = run.split(","); - for (var j = 0; j < classOperations.length; j++) { - var value = classOperations[j]; - var trimmedValue = value.trim(); - var classOperation = parseClassOperation(trimmedValue); - if (classOperation) { - if (classOperation.operation === "toggle") { - setTimeout(function () { - setInterval(function () { - elt.classList[classOperation.operation].call(elt.classList, classOperation.cssClass); - }, classOperation.delay); - }, currentRunTime); - currentRunTime = currentRunTime + classOperation.delay; - } else { - currentRunTime = currentRunTime + classOperation.delay; - setTimeout(function () { - elt.classList[classOperation.operation].call(elt.classList, classOperation.cssClass); - }, currentRunTime); - } - } - } - } - } - - function maybeProcessClasses(elt) { - if (elt.getAttribute) { - var classList = elt.getAttribute("classes") || elt.getAttribute("data-classes"); - if (classList) { - processClassList(elt, classList); - } - } - } - - htmx.defineExtension('class-tools', { - onEvent: function (name, evt) { - if (name === "htmx:afterProcessNode") { - var elt = evt.detail.elt; - maybeProcessClasses(elt); - if (elt.querySelectorAll) { - var children = elt.querySelectorAll("[classes], [data-classes]"); - for (var i = 0; i < children.length; i++) { - maybeProcessClasses(children[i]); - } - } - } - } - }); -})(); diff --git a/static/js/ext/client-side-templates.js b/static/js/ext/client-side-templates.js deleted file mode 100644 index 9ea0cf0..0000000 --- a/static/js/ext/client-side-templates.js +++ /dev/null @@ -1,102 +0,0 @@ -UNPKG - htmx.org

UNPKG

1.43 kBJavaScriptView Raw
1htmx.defineExtension('client-side-templates', { -
2 transformResponse : function(text, xhr, elt) { -
3 -
4 var mustacheTemplate = htmx.closest(elt, "[mustache-template]"); -
5 if (mustacheTemplate) { -
6 var data = JSON.parse(text); -
7 var templateId = mustacheTemplate.getAttribute('mustache-template'); -
8 var template = htmx.find("#" + templateId); -
9 if (template) { -
10 return Mustache.render(template.innerHTML, data); -
11 } else { -
12 throw "Unknown mustache template: " + templateId; -
13 } -
14 } -
15 -
16 var handlebarsTemplate = htmx.closest(elt, "[handlebars-template]"); -
17 if (handlebarsTemplate) { -
18 var data = JSON.parse(text); -
19 var templateName = handlebarsTemplate.getAttribute('handlebars-template'); -
20 return Handlebars.partials[templateName](data); -
21 } -
22 -
23 var nunjucksTemplate = htmx.closest(elt, "[nunjucks-template]"); -
24 if (nunjucksTemplate) { -
25 var data = JSON.parse(text); -
26 var templateName = nunjucksTemplate.getAttribute('nunjucks-template'); -
27 var template = htmx.find('#' + templateName); -
28 if (template) { -
29 return nunjucks.renderString(template.innerHTML, data); -
30 } else { -
31 return nunjucks.render(templateName, data); -
32 } -
33 } -
34 -
35 return text; -
36 } -
37}); -

Build: a7ebffa

© 2022 UNPKG

\ No newline at end of file diff --git a/static/js/ext/disable-element.js b/static/js/ext/disable-element.js deleted file mode 100644 index 3493d81..0000000 --- a/static/js/ext/disable-element.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -// Disable Submit Button -htmx.defineExtension('disable-element', { - onEvent: function (name, evt) { - let elt = evt.detail.elt; - let target = elt.getAttribute("hx-disable-element"); - let targetElement = (target == "self") ? elt : document.querySelector(target); - - if (name === "htmx:beforeRequest" && targetElement) { - targetElement.disabled = true; - } else if (name == "htmx:afterRequest" && targetElement) { - targetElement.disabled = false; - } - } -}); \ No newline at end of file diff --git a/static/js/ext/event-header.js b/static/js/ext/event-header.js deleted file mode 100644 index c7d2933..0000000 --- a/static/js/ext/event-header.js +++ /dev/null @@ -1,37 +0,0 @@ -(function(){ - function stringifyEvent(event) { - var obj = {}; - for (var key in event) { - obj[key] = event[key]; - } - return JSON.stringify(obj, function(key, value){ - if(value instanceof Node){ - var nodeRep = value.tagName; - if (nodeRep) { - nodeRep = nodeRep.toLowerCase(); - if(value.id){ - nodeRep += "#" + value.id; - } - if(value.classList && value.classList.length){ - nodeRep += "." + value.classList.toString().replace(" ", ".") - } - return nodeRep; - } else { - return "Node" - } - } - if (value instanceof Window) return 'Window'; - return value; - }); - } - - htmx.defineExtension('event-header', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - if (evt.detail.triggeringEvent) { - evt.detail.headers['Triggering-Event'] = stringifyEvent(evt.detail.triggeringEvent); - } - } - } - }); -})(); diff --git a/static/js/ext/loading-states.js b/static/js/ext/loading-states.js deleted file mode 100644 index d18b109..0000000 --- a/static/js/ext/loading-states.js +++ /dev/null @@ -1,179 +0,0 @@ -;(function () { - let loadingStatesUndoQueue = [] - - function loadingStateContainer(target) { - return htmx.closest(target, '[data-loading-states]') || document.body - } - - function mayProcessUndoCallback(target, callback) { - if (document.body.contains(target)) { - callback() - } - } - - function mayProcessLoadingStateByPath(elt, requestPath) { - const pathElt = htmx.closest(elt, '[data-loading-path]') - if (!pathElt) { - return true - } - - return pathElt.getAttribute('data-loading-path') === requestPath - } - - function queueLoadingState(sourceElt, targetElt, doCallback, undoCallback) { - const delayElt = htmx.closest(sourceElt, '[data-loading-delay]') - if (delayElt) { - const delayInMilliseconds = - delayElt.getAttribute('data-loading-delay') || 200 - const timeout = setTimeout(() => { - doCallback() - - loadingStatesUndoQueue.push(() => { - mayProcessUndoCallback(targetElt, () => undoCallback()) - }) - }, delayInMilliseconds) - - loadingStatesUndoQueue.push(() => { - mayProcessUndoCallback(targetElt, () => clearTimeout(timeout)) - }) - } else { - doCallback() - loadingStatesUndoQueue.push(() => { - mayProcessUndoCallback(targetElt, () => undoCallback()) - }) - } - } - - function getLoadingStateElts(loadingScope, type, path) { - return Array.from(htmx.findAll(loadingScope, `[${type}]`)).filter( - (elt) => mayProcessLoadingStateByPath(elt, path) - ) - } - - function getLoadingTarget(elt) { - if (elt.getAttribute('data-loading-target')) { - return Array.from( - htmx.findAll(elt.getAttribute('data-loading-target')) - ) - } - return [elt] - } - - htmx.defineExtension('loading-states', { - onEvent: function (name, evt) { - if (name === 'htmx:beforeRequest') { - const container = loadingStateContainer(evt.target) - - const loadingStateTypes = [ - 'data-loading', - 'data-loading-class', - 'data-loading-class-remove', - 'data-loading-disable', - 'data-loading-aria-busy', - ] - - let loadingStateEltsByType = {} - - loadingStateTypes.forEach((type) => { - loadingStateEltsByType[type] = getLoadingStateElts( - container, - type, - evt.detail.pathInfo.requestPath - ) - }) - - loadingStateEltsByType['data-loading'].forEach((sourceElt) => { - getLoadingTarget(sourceElt).forEach((targetElt) => { - queueLoadingState( - sourceElt, - targetElt, - () => - (targetElt.style.display = - sourceElt.getAttribute('data-loading') || - 'inline-block'), - () => (targetElt.style.display = 'none') - ) - }) - }) - - loadingStateEltsByType['data-loading-class'].forEach( - (sourceElt) => { - const classNames = sourceElt - .getAttribute('data-loading-class') - .split(' ') - - getLoadingTarget(sourceElt).forEach((targetElt) => { - queueLoadingState( - sourceElt, - targetElt, - () => - classNames.forEach((className) => - targetElt.classList.add(className) - ), - () => - classNames.forEach((className) => - targetElt.classList.remove(className) - ) - ) - }) - } - ) - - loadingStateEltsByType['data-loading-class-remove'].forEach( - (sourceElt) => { - const classNames = sourceElt - .getAttribute('data-loading-class-remove') - .split(' ') - - getLoadingTarget(sourceElt).forEach((targetElt) => { - queueLoadingState( - sourceElt, - targetElt, - () => - classNames.forEach((className) => - targetElt.classList.remove(className) - ), - () => - classNames.forEach((className) => - targetElt.classList.add(className) - ) - ) - }) - } - ) - - loadingStateEltsByType['data-loading-disable'].forEach( - (sourceElt) => { - getLoadingTarget(sourceElt).forEach((targetElt) => { - queueLoadingState( - sourceElt, - targetElt, - () => (targetElt.disabled = true), - () => (targetElt.disabled = false) - ) - }) - } - ) - - loadingStateEltsByType['data-loading-aria-busy'].forEach( - (sourceElt) => { - getLoadingTarget(sourceElt).forEach((targetElt) => { - queueLoadingState( - sourceElt, - targetElt, - () => (targetElt.setAttribute("aria-busy", "true")), - () => (targetElt.removeAttribute("aria-busy")) - ) - }) - } - ) - } - - if (name === 'htmx:afterOnLoad') { - while (loadingStatesUndoQueue.length > 0) { - loadingStatesUndoQueue.shift()() - } - } - }, - }) -})() diff --git a/static/js/ext/method-override.js b/static/js/ext/method-override.js deleted file mode 100644 index 2e3504c..0000000 --- a/static/js/ext/method-override.js +++ /dev/null @@ -1,11 +0,0 @@ -htmx.defineExtension('method-override', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - var method = evt.detail.verb; - if (method !== "get" || method !== "post") { - evt.detail.headers['X-HTTP-Method-Override'] = method.toUpperCase(); - evt.detail.verb = "post"; - } - } - } -}); diff --git a/static/js/ext/preload.js b/static/js/ext/preload.js deleted file mode 100644 index 9caa7e3..0000000 --- a/static/js/ext/preload.js +++ /dev/null @@ -1,137 +0,0 @@ -// This adds the "preload" extension to htmx. By default, this will -// preload the targets of any tags with `href` or `hx-get` attributes -// if they also have a `preload` attribute as well. See documentation -// for more details -htmx.defineExtension("preload", { - - onEvent: function(name, event) { - - // Only take actions on "htmx:afterProcessNode" - if (name !== "htmx:afterProcessNode") { - return; - } - - // SOME HELPER FUNCTIONS WE'LL NEED ALONG THE WAY - - // attr gets the closest non-empty value from the attribute. - var attr = function(node, property) { - if (node == undefined) {return undefined;} - return node.getAttribute(property) || node.getAttribute("data-" + property) || attr(node.parentElement, property) - } - - // load handles the actual HTTP fetch, and uses htmx.ajax in cases where we're - // preloading an htmx resource (this sends the same HTTP headers as a regular htmx request) - var load = function(node) { - - // Called after a successful AJAX request, to mark the - // content as loaded (and prevent additional AJAX calls.) - var done = function(html) { - node.preloadState = "DONE" - - if (attr(node, "preload-images") == "true") { - document.createElement("div").innerHTML = html // create and populate a node to load linked resources, too. - } - } - - return function() { - - // If this value has already been loaded, then do not try again. - if (node.preloadState !== "READY") { - return; - } - - // Special handling for HX-GET - use built-in htmx.ajax function - // so that headers match other htmx requests, then set - // node.preloadState = TRUE so that requests are not duplicated - // in the future - var hxGet = node.getAttribute("hx-get") || node.getAttribute("data-hx-get") - if (hxGet) { - htmx.ajax("GET", hxGet, {handler:function(elt, info) { - done(info.xhr.responseText); - }}); - return; - } - - // Otherwise, perform a standard xhr request, then set - // node.preloadState = TRUE so that requests are not duplicated - // in the future. - if (node.getAttribute("href")) { - var r = new XMLHttpRequest(); - r.open("GET", node.getAttribute("href")); - r.onload = function() {done(r.responseText);}; - r.send(); - return; - } - } - } - - // This function processes a specific node and sets up event handlers. - // We'll search for nodes and use it below. - var init = function(node) { - - // If this node DOES NOT include a "GET" transaction, then there's nothing to do here. - if (node.getAttribute("href") + node.getAttribute("hx-get") + node.getAttribute("data-hx-get") == "") { - return; - } - - // Guarantee that we only initialize each node once. - if (node.preloadState !== undefined) { - return; - } - - // Get event name from config. - var on = attr(node, "preload") || "mousedown" - - // FALL THROUGH to here means we need to add an EventListener - - // Apply the listener to the node - node.addEventListener(on, function(evt) { - if (node.preloadState === "PAUSE") { // Only add one event listener - node.preloadState = "READY"; // Requred for the `load` function to trigger - - // Special handling for "mouseover" events. Wait 100ms before triggering load. - if (on === "mouseover") { - window.setTimeout(load(node), 100); - } else { - load(node)() // all other events trigger immediately. - } - } - }) - - // Special handling for certain built-in event handlers - switch (on) { - - case "mouseover": - // Mirror `touchstart` events (fires immediately) - node.addEventListener("touchstart", load(node)); - - // WHhen the mouse leaves, immediately disable the preload - node.addEventListener("mouseout", function(evt) { - if ((evt.target === node) && (node.preloadState === "READY")) { - node.preloadState = "PAUSE"; - } - }) - break; - - case "mousedown": - // Mirror `touchstart` events (fires immediately) - node.addEventListener("touchstart", load(node)); - break; - } - - // Mark the node as ready to run. - node.preloadState = "PAUSE"; - htmx.trigger(node, "preload:init") // This event can be used to load content immediately. - } - - // Search for all child nodes that have a "preload" attribute - event.target.querySelectorAll("[preload]").forEach(function(node) { - - // Initialize the node with the "preload" attribute - init(node) - - // Initialize all child elements that are anchors or have `hx-get` (use with care) - node.querySelectorAll("a,[hx-get],[data-hx-get]").forEach(init) - }) - } -}) diff --git a/static/js/ext/sse.js b/static/js/ext/sse.js deleted file mode 100644 index 3457143..0000000 --- a/static/js/ext/sse.js +++ /dev/null @@ -1,318 +0,0 @@ -/* -Server Sent Events Extension -============================ -This extension adds support for Server Sent Events to htmx. See /www/extensions/sse.md for usage instructions. - -*/ - -(function(){ - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension("sse", { - - /** - * Init saves the provided reference to the internal HTMX API. - * - * @param {import("../htmx").HtmxInternalApi} api - * @returns void - */ - init: function(apiRef) { - // store a reference to the internal API. - api = apiRef; - - // set a function in the public API for creating new EventSource objects - if (htmx.createEventSource == undefined) { - htmx.createEventSource = createEventSource; - } - }, - - /** - * onEvent handles all events passed to this extension. - * - * @param {string} name - * @param {Event} evt - * @returns void - */ - onEvent: function(name, evt) { - - switch (name) { - - // Try to remove remove an EventSource when elements are removed - case "htmx:beforeCleanupElement": - var internalData = api.getInternalData(evt.target) - if (internalData.sseEventSource) { - internalData.sseEventSource.close(); - } - return; - - // Try to create EventSources when elements are processed - case "htmx:afterProcessNode": - createEventSourceOnElement(evt.target); - } - } - }); - - /////////////////////////////////////////////// - // HELPER FUNCTIONS - /////////////////////////////////////////////// - - - /** - * createEventSource is the default method for creating new EventSource objects. - * it is hoisted into htmx.config.createEventSource to be overridden by the user, if needed. - * - * @param {string} url - * @returns EventSource - */ - function createEventSource(url) { - return new EventSource(url, {withCredentials:true}); - } - - function splitOnWhitespace(trigger) { - return trigger.trim().split(/\s+/); - } - - function getLegacySSEURL(elt) { - var legacySSEValue = api.getAttributeValue(elt, "hx-sse"); - if (legacySSEValue) { - var values = splitOnWhitespace(legacySSEValue); - for (var i = 0; i < values.length; i++) { - var value = values[i].split(/:(.+)/); - if (value[0] === "connect") { - return value[1]; - } - } - } - } - - function getLegacySSESwaps(elt) { - var legacySSEValue = api.getAttributeValue(elt, "hx-sse"); - var returnArr = []; - if (legacySSEValue) { - var values = splitOnWhitespace(legacySSEValue); - for (var i = 0; i < values.length; i++) { - var value = values[i].split(/:(.+)/); - if (value[0] === "swap") { - returnArr.push(value[1]); - } - } - } - return returnArr; - } - - /** - * createEventSourceOnElement creates a new EventSource connection on the provided element. - * If a usable EventSource already exists, then it is returned. If not, then a new EventSource - * is created and stored in the element's internalData. - * @param {HTMLElement} elt - * @param {number} retryCount - * @returns {EventSource | null} - */ - function createEventSourceOnElement(elt, retryCount) { - - if (elt == null) { - return null; - } - - var internalData = api.getInternalData(elt); - - // get URL from element's attribute - var sseURL = api.getAttributeValue(elt, "sse-connect"); - - - if (sseURL == undefined) { - var legacyURL = getLegacySSEURL(elt) - if (legacyURL) { - sseURL = legacyURL; - } else { - return null; - } - } - - // Connect to the EventSource - var source = htmx.createEventSource(sseURL); - internalData.sseEventSource = source; - - // Create event handlers - source.onerror = function (err) { - - // Log an error event - api.triggerErrorEvent(elt, "htmx:sseError", {error:err, source:source}); - - // If parent no longer exists in the document, then clean up this EventSource - if (maybeCloseSSESource(elt)) { - return; - } - - // Otherwise, try to reconnect the EventSource - if (source.readyState === EventSource.CLOSED) { - retryCount = retryCount || 0; - var timeout = Math.random() * (2 ^ retryCount) * 500; - window.setTimeout(function() { - createEventSourceOnElement(elt, Math.min(7, retryCount+1)); - }, timeout); - } - }; - - // Add message handlers for every `sse-swap` attribute - queryAttributeOnThisOrChildren(elt, "sse-swap").forEach(function(child) { - - var sseSwapAttr = api.getAttributeValue(child, "sse-swap"); - if (sseSwapAttr) { - var sseEventNames = sseSwapAttr.split(","); - } else { - var sseEventNames = getLegacySSESwaps(child); - } - - for (var i = 0 ; i < sseEventNames.length ; i++) { - var sseEventName = sseEventNames[i].trim(); - var listener = function(event) { - - // If the parent is missing then close SSE and remove listener - if (maybeCloseSSESource(elt)) { - source.removeEventListener(sseEventName, listener); - return; - } - - // swap the response into the DOM and trigger a notification - swap(child, event.data); - api.triggerEvent(elt, "htmx:sseMessage", event); - }; - - // Register the new listener - api.getInternalData(elt).sseEventListener = listener; - source.addEventListener(sseEventName, listener); - } - }); - - // Add message handlers for every `hx-trigger="sse:*"` attribute - queryAttributeOnThisOrChildren(elt, "hx-trigger").forEach(function(child) { - - var sseEventName = api.getAttributeValue(child, "hx-trigger"); - if (sseEventName == null) { - return; - } - - // Only process hx-triggers for events with the "sse:" prefix - if (sseEventName.slice(0, 4) != "sse:") { - return; - } - - var listener = function(event) { - - // If parent is missing, then close SSE and remove listener - if (maybeCloseSSESource(elt)) { - source.removeEventListener(sseEventName, listener); - return; - } - - // Trigger events to be handled by the rest of htmx - htmx.trigger(child, sseEventName, event); - htmx.trigger(child, "htmx:sseMessage", event); - } - - // Register the new listener - api.getInternalData(elt).sseEventListener = listener; - source.addEventListener(sseEventName.slice(4), listener); - }); - } - - /** - * maybeCloseSSESource confirms that the parent element still exists. - * If not, then any associated SSE source is closed and the function returns true. - * - * @param {HTMLElement} elt - * @returns boolean - */ - function maybeCloseSSESource(elt) { - if (!api.bodyContains(elt)) { - var source = api.getInternalData(elt).sseEventSource; - if (source != undefined) { - source.close(); - // source = null - return true; - } - } - return false; - } - - /** - * queryAttributeOnThisOrChildren returns all nodes that contain the requested attributeName, INCLUDING THE PROVIDED ROOT ELEMENT. - * - * @param {HTMLElement} elt - * @param {string} attributeName - */ - function queryAttributeOnThisOrChildren(elt, attributeName) { - - var result = []; - - // If the parent element also contains the requested attribute, then add it to the results too. - if (api.hasAttribute(elt, attributeName) || api.hasAttribute(elt, "hx-sse")) { - result.push(elt); - } - - // Search all child nodes that match the requested attribute - elt.querySelectorAll("[" + attributeName + "], [data-" + attributeName + "], [hx-sse], [data-hx-sse]").forEach(function(node) { - result.push(node); - }); - - return result; - } - - /** - * @param {HTMLElement} elt - * @param {string} content - */ - function swap(elt, content) { - - api.withExtensions(elt, function(extension) { - content = extension.transformResponse(content, null, elt); - }); - - var swapSpec = api.getSwapSpecification(elt); - var target = api.getTarget(elt); - var settleInfo = api.makeSettleInfo(elt); - - api.selectAndSwap(swapSpec.swapStyle, target, elt, content, settleInfo); - - settleInfo.elts.forEach(function (elt) { - if (elt.classList) { - elt.classList.add(htmx.config.settlingClass); - } - api.triggerEvent(elt, 'htmx:beforeSettle'); - }); - - // Handle settle tasks (with delay if requested) - if (swapSpec.settleDelay > 0) { - setTimeout(doSettle(settleInfo), swapSpec.settleDelay); - } else { - doSettle(settleInfo)(); - } - } - - /** - * doSettle mirrors much of the functionality in htmx that - * settles elements after their content has been swapped. - * TODO: this should be published by htmx, and not duplicated here - * @param {import("../htmx").HtmxSettleInfo} settleInfo - * @returns () => void - */ - function doSettle(settleInfo) { - - return function() { - settleInfo.tasks.forEach(function (task) { - task.call(); - }); - - settleInfo.elts.forEach(function (elt) { - if (elt.classList) { - elt.classList.remove(htmx.config.settlingClass); - } - api.triggerEvent(elt, 'htmx:afterSettle'); - }); - } - } - -})(); \ No newline at end of file diff --git a/static/js/ext/ws.js b/static/js/ext/ws.js deleted file mode 100644 index 474df02..0000000 --- a/static/js/ext/ws.js +++ /dev/null @@ -1,355 +0,0 @@ -/* -WebSockets Extension -============================ -This extension adds support for WebSockets to htmx. See /www/extensions/ws.md for usage instructions. -*/ - -(function(){ - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension("ws", { - - /** - * init is called once, when this extension is first registered. - * @param {import("../htmx").HtmxInternalApi} apiRef - */ - init: function(apiRef) { - - // Store reference to internal API - api = apiRef; - - // Default function for creating new EventSource objects - if (htmx.createWebSocket == undefined) { - htmx.createWebSocket = createWebSocket; - } - - // Default setting for reconnect delay - if (htmx.config.wsReconnectDelay == undefined) { - htmx.config.wsReconnectDelay = "full-jitter"; - } - }, - - /** - * onEvent handles all events passed to this extension. - * - * @param {string} name - * @param {Event} evt - */ - onEvent: function(name, evt) { - - switch (name) { - - // Try to remove remove an EventSource when elements are removed - case "htmx:beforeCleanupElement": - - var internalData = api.getInternalData(evt.target) - - if (internalData.webSocket != undefined) { - internalData.webSocket.close(); - } - return; - - // Try to create EventSources when elements are processed - case "htmx:afterProcessNode": - var parent = evt.target; - - forEach(queryAttributeOnThisOrChildren(parent, "ws-connect"), function(child) { - ensureWebSocket(child) - }); - forEach(queryAttributeOnThisOrChildren(parent, "ws-send"), function (child) { - ensureWebSocketSend(child) - }); - } - } - }); - - function splitOnWhitespace(trigger) { - return trigger.trim().split(/\s+/); - } - - function getLegacyWebsocketURL(elt) { - var legacySSEValue = api.getAttributeValue(elt, "hx-ws"); - if (legacySSEValue) { - var values = splitOnWhitespace(legacySSEValue); - for (var i = 0; i < values.length; i++) { - var value = values[i].split(/:(.+)/); - if (value[0] === "connect") { - return value[1]; - } - } - } - } - - /** - * ensureWebSocket creates a new WebSocket on the designated element, using - * the element's "ws-connect" attribute. - * @param {HTMLElement} elt - * @param {number=} retryCount - * @returns - */ - function ensureWebSocket(elt, retryCount) { - - // If the element containing the WebSocket connection no longer exists, then - // do not connect/reconnect the WebSocket. - if (!api.bodyContains(elt)) { - return; - } - - // Get the source straight from the element's value - var wssSource = api.getAttributeValue(elt, "ws-connect") - - if (wssSource == null || wssSource === "") { - var legacySource = getLegacyWebsocketURL(elt); - if (legacySource == null) { - return; - } else { - wssSource = legacySource; - } - } - - // Default value for retryCount - if (retryCount == undefined) { - retryCount = 0; - } - - // Guarantee that the wssSource value is a fully qualified URL - if (wssSource.indexOf("/") == 0) { - var base_part = location.hostname + (location.port ? ':'+location.port: ''); - if (location.protocol == 'https:') { - wssSource = "wss://" + base_part + wssSource; - } else if (location.protocol == 'http:') { - wssSource = "ws://" + base_part + wssSource; - } - } - - // Create a new WebSocket and event handlers - /** @type {WebSocket} */ - var socket = htmx.createWebSocket(wssSource); - - var messageQueue = []; - - socket.onopen = function (e) { - retryCount = 0; - handleQueuedMessages(messageQueue, socket); - } - - socket.onclose = function (e) { - // If Abnormal Closure/Service Restart/Try Again Later, then set a timer to reconnect after a pause. - if ([1006, 1012, 1013].indexOf(e.code) >= 0) { - var delay = getWebSocketReconnectDelay(retryCount); - setTimeout(function() { - ensureWebSocket(elt, retryCount+1); - }, delay); - } - }; - - socket.onerror = function (e) { - api.triggerErrorEvent(elt, "htmx:wsError", {error:e, socket:socket}); - maybeCloseWebSocketSource(elt); - }; - - socket.addEventListener('message', function (event) { - if (maybeCloseWebSocketSource(elt)) { - return; - } - - var response = event.data; - api.withExtensions(elt, function(extension){ - response = extension.transformResponse(response, null, elt); - }); - - var settleInfo = api.makeSettleInfo(elt); - var fragment = api.makeFragment(response); - - if (fragment.children.length) { - var children = Array.from(fragment.children); - for (var i = 0; i < children.length; i++) { - api.oobSwap(api.getAttributeValue(children[i], "hx-swap-oob") || "true", children[i], settleInfo); - } - } - - api.settleImmediately(settleInfo.tasks); - }); - - // Put the WebSocket into the HTML Element's custom data. - api.getInternalData(elt).webSocket = socket; - api.getInternalData(elt).webSocketMessageQueue = messageQueue; - } - - /** - * ensureWebSocketSend attaches trigger handles to elements with - * "ws-send" attribute - * @param {HTMLElement} elt - */ - function ensureWebSocketSend(elt) { - var legacyAttribute = api.getAttributeValue(elt, "hx-ws"); - if (legacyAttribute && legacyAttribute !== 'send') { - return; - } - - var webSocketParent = api.getClosestMatch(elt, hasWebSocket) - processWebSocketSend(webSocketParent, elt); - } - - /** - * hasWebSocket function checks if a node has webSocket instance attached - * @param {HTMLElement} node - * @returns {boolean} - */ - function hasWebSocket(node) { - return api.getInternalData(node).webSocket != null; - } - - /** - * processWebSocketSend adds event listeners to the
element so that - * messages can be sent to the WebSocket server when the form is submitted. - * @param {HTMLElement} parent - * @param {HTMLElement} child - */ - function processWebSocketSend(parent, child) { - var nodeData = api.getInternalData(child); - let triggerSpecs = api.getTriggerSpecs(child); - triggerSpecs.forEach(function(ts) { - api.addTriggerHandler(child, ts, nodeData, function (evt) { - var webSocket = api.getInternalData(parent).webSocket; - var messageQueue = api.getInternalData(parent).webSocketMessageQueue; - var headers = api.getHeaders(child, parent); - var results = api.getInputValues(child, 'post'); - var errors = results.errors; - var rawParameters = results.values; - var expressionVars = api.getExpressionVars(child); - var allParameters = api.mergeObjects(rawParameters, expressionVars); - var filteredParameters = api.filterValues(allParameters, child); - filteredParameters['HEADERS'] = headers; - if (errors && errors.length > 0) { - api.triggerEvent(child, 'htmx:validation:halted', errors); - return; - } - webSocketSend(webSocket, JSON.stringify(filteredParameters), messageQueue); - if(api.shouldCancel(evt, child)){ - evt.preventDefault(); - } - }); - }); - } - - /** - * webSocketSend provides a safe way to send messages through a WebSocket. - * It checks that the socket is in OPEN state and, otherwise, awaits for it. - * @param {WebSocket} socket - * @param {string} message - * @param {string[]} messageQueue - * @return {boolean} - */ - function webSocketSend(socket, message, messageQueue) { - if (socket.readyState != socket.OPEN) { - messageQueue.push(message); - } else { - socket.send(message); - } - } - - /** - * handleQueuedMessages sends messages awaiting in the message queue - */ - function handleQueuedMessages(messageQueue, socket) { - while (messageQueue.length > 0) { - var message = messageQueue[0] - if (socket.readyState == socket.OPEN) { - socket.send(message); - messageQueue.shift() - } else { - break; - } - } - } - - /** - * getWebSocketReconnectDelay is the default easing function for WebSocket reconnects. - * @param {number} retryCount // The number of retries that have already taken place - * @returns {number} - */ - function getWebSocketReconnectDelay(retryCount) { - - /** @type {"full-jitter" | (retryCount:number) => number} */ - var delay = htmx.config.wsReconnectDelay; - if (typeof delay === 'function') { - return delay(retryCount); - } - if (delay === 'full-jitter') { - var exp = Math.min(retryCount, 6); - var maxDelay = 1000 * Math.pow(2, exp); - return maxDelay * Math.random(); - } - - logError('htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"'); - } - - /** - * maybeCloseWebSocketSource checks to the if the element that created the WebSocket - * still exists in the DOM. If NOT, then the WebSocket is closed and this function - * returns TRUE. If the element DOES EXIST, then no action is taken, and this function - * returns FALSE. - * - * @param {*} elt - * @returns - */ - function maybeCloseWebSocketSource(elt) { - if (!api.bodyContains(elt)) { - api.getInternalData(elt).webSocket.close(); - return true; - } - return false; - } - - /** - * createWebSocket is the default method for creating new WebSocket objects. - * it is hoisted into htmx.createWebSocket to be overridden by the user, if needed. - * - * @param {string} url - * @returns WebSocket - */ - function createWebSocket(url){ - return new WebSocket(url, []); - } - - /** - * queryAttributeOnThisOrChildren returns all nodes that contain the requested attributeName, INCLUDING THE PROVIDED ROOT ELEMENT. - * - * @param {HTMLElement} elt - * @param {string} attributeName - */ - function queryAttributeOnThisOrChildren(elt, attributeName) { - - var result = [] - - // If the parent element also contains the requested attribute, then add it to the results too. - if (api.hasAttribute(elt, attributeName) || api.hasAttribute(elt, "hx-ws")) { - result.push(elt); - } - - // Search all child nodes that match the requested attribute - elt.querySelectorAll("[" + attributeName + "], [data-" + attributeName + "], [data-hx-ws], [hx-ws]").forEach(function(node) { - result.push(node) - }) - - return result - } - - /** - * @template T - * @param {T[]} arr - * @param {(T) => void} func - */ - function forEach(arr, func) { - if (arr) { - for (var i = 0; i < arr.length; i++) { - func(arr[i]); - } - } - } - -})(); - diff --git a/static/js/htmx.min.js b/static/js/htmx.min.js index 027cd1e..d68f3c6 100644 --- a/static/js/htmx.min.js +++ b/static/js/htmx.min.js @@ -1 +1 @@ -(function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else{e.htmx=e.htmx||t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";var U={onLoad:t,process:vt,on:X,off:F,trigger:$,ajax:nr,find:R,findAll:O,closest:N,values:function(e,t){var r=Pt(e,t||"post");return r.values},remove:q,addClass:L,removeClass:T,toggleClass:A,takeClass:H,defineExtension:fr,removeExtension:cr,logAll:C,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:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",disableSelector:"[hx-disable], [data-hx-disable]",useTemplateFragments:false,scrollBehavior:"smooth",defaultFocusScroll:false},parseInterval:v,_:e,createEventSource:function(e){return new EventSource(e,{withCredentials:true})},createWebSocket:function(e){return new WebSocket(e,[])},version:"1.8.0"};var r={addTriggerHandler:st,bodyContains:K,canAccessLocalStorage:E,filterValues:Ut,hasAttribute:o,getAttributeValue:V,getClosestMatch:h,getExpressionVars:Qt,getHeaders:Bt,getInputValues:Pt,getInternalData:W,getSwapSpecification:_t,getTriggerSpecs:Me,getTarget:re,makeFragment:g,mergeObjects:Y,makeSettleInfo:Gt,oobSwap:ae,selectAndSwap:Ee,settleImmediately:Lt,shouldCancel:je,triggerEvent:$,triggerErrorEvent:J,withExtensions:xt};var n=["get","post","put","delete","patch"];var i=n.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function v(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}if(e.slice(-1)=="m"){return parseFloat(e.slice(0,-1))*1e3*60||undefined}return parseFloat(e)||undefined}function f(e,t){return e.getAttribute&&e.getAttribute(t)}function o(e,t){return e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function V(e,t){return f(e,t)||f(e,"data-"+t)}function u(e){return e.parentElement}function _(){return document}function h(e,t){while(e&&!t(e)){e=u(e)}return e?e:null}function a(e,t,r){var n=V(t,r);var i=V(t,"hx-disinherit");if(e!==t&&i&&(i==="*"||i.split(" ").indexOf(r)>=0)){return"unset"}else{return n}}function z(t,r){var n=null;h(t,function(e){return n=a(t,e,r)});if(n!=="unset"){return n}}function d(e,t){var r=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return r&&r.call(e,t)}function s(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 g(e){if(U.config.useTemplateFragments){var t=l("",0);return t.querySelector("template").content}else{var r=s(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 Z(e){if(e){e()}}function p(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function m(e){return p(e,"Function")}function x(e){return p(e,"Object")}function W(e){var t="htmx-internal-data";var r=e[t];if(!r){r=e[t]={}}return r}function y(e){var t=[];if(e){for(var r=0;r=0}function K(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 Y(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){yt(e);return null}}function E(){var e="htmx:localStorageTest";try{localStorage.setItem(e,e);localStorage.removeItem(e);return true}catch(e){return false}}function e(e){return Zt(_().body,function(){return eval(e)})}function t(t){var e=U.on("htmx:load",function(e){t(e.detail.elt)});return e}function C(){U.logger=function(e,t,r){if(console){console.log(t,e,r)}}}function R(e,t){if(t){return e.querySelector(t)}else{return R(_(),e)}}function O(e,t){if(t){return e.querySelectorAll(t)}else{return O(_(),e)}}function q(e,t){e=D(e);if(t){setTimeout(function(){q(e)},t)}else{e.parentElement.removeChild(e)}}function L(e,t,r){e=D(e);if(r){setTimeout(function(){L(e,t)},r)}else{e.classList&&e.classList.add(t)}}function T(e,t,r){e=D(e);if(r){setTimeout(function(){T(e,t)},r)}else{if(e.classList){e.classList.remove(t);if(e.classList.length===0){e.removeAttribute("class")}}}}function A(e,t){e=D(e);e.classList.toggle(t)}function H(e,t){e=D(e);G(e.parentElement.children,function(e){T(e,t)});L(e,t)}function N(e,t){e=D(e);if(e.closest){return e.closest(t)}else{do{if(e==null||d(e,t)){return e}}while(e=e&&u(e))}}function I(e,t){if(t.indexOf("closest ")===0){return[N(e,t.substr(8))]}else if(t.indexOf("find ")===0){return[R(e,t.substr(5))]}else if(t.indexOf("next ")===0){return[k(e,t.substr(5))]}else if(t.indexOf("previous ")===0){return[M(e,t.substr(9))]}else if(t==="document"){return[document]}else if(t==="window"){return[window]}else{return _().querySelectorAll(t)}}var k=function(e,t){var r=_().querySelectorAll(t);for(var n=0;n=0;n--){var i=r[n];if(i.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING){return i}}};function Q(e,t){if(t){return I(e,t)[0]}else{return I(_().body,e)[0]}}function D(e){if(p(e,"String")){return R(e)}else{return e}}function P(e,t,r){if(m(t)){return{target:_().body,event:e,listener:t}}else{return{target:D(e),event:t,listener:r}}}function X(t,r,n){dr(function(){var e=P(t,r,n);e.target.addEventListener(e.event,e.listener)});var e=m(r);return e?r:n}function F(t,r,n){dr(function(){var e=P(t,r,n);e.target.removeEventListener(e.event,e.listener)});return m(r)?r:n}var ee=_().createElement("output");function j(e,t){var r=z(e,t);if(r){if(r==="this"){return[te(e,t)]}else{var n=I(e,r);if(n.length===0){yt('The selector "'+r+'" on '+t+" returned no matches!");return[ee]}else{return n}}}}function te(e,t){return h(e,function(e){return V(e,t)!=null})}function re(e){var t=z(e,"hx-target");if(t){if(t==="this"){return te(e,"hx-target")}else{return Q(e,t)}}else{var r=W(e);if(r.boosted){return _().body}else{return e}}}function B(e){var t=U.config.attributesToSettle;for(var r=0;r0){o=e.substr(0,e.indexOf(":"));t=e.substr(e.indexOf(":")+1,e.length)}else{o=e}var r=_().querySelectorAll(t);if(r){G(r,function(e){var t;var r=i.cloneNode(true);t=_().createDocumentFragment();t.appendChild(r);if(!ie(o,e)){t=r}var n={shouldSwap:true,target:e,fragment:t};if(!$(e,"htmx:oobBeforeSwap",n))return;e=n.target;if(n["shouldSwap"]){we(o,e,e,t,a)}G(a.elts,function(e){$(e,"htmx:oobAfterSwap",n)})});i.parentNode.removeChild(i)}else{i.parentNode.removeChild(i);J(_().body,"htmx:oobErrorNoTarget",{content:i})}return e}function oe(e,t,r){var n=z(e,"hx-select-oob");if(n){var i=n.split(",");for(let e=0;e0){var t=n.querySelector(e.tagName+"[id='"+e.id+"']");if(t&&t!==n){var r=e.cloneNode();ne(e,t);i.tasks.push(function(){ne(e,r)})}}})}function ue(e){return function(){T(e,U.config.addedClass);vt(e);ut(e);fe(e);$(e,"htmx:load")}}function fe(e){var t="[autofocus]";var r=d(e,t)?e:e.querySelector(t);if(r!=null){r.focus()}}function ce(e,t,r,n){le(e,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(ue(i))}}}function he(t){var e=W(t);if(e.webSocket){e.webSocket.close()}if(e.sseEventSource){e.sseEventSource.close()}$(t,"htmx:beforeCleanupElement");if(e.listenerInfos){G(e.listenerInfos,function(e){if(t!==e.on){e.on.removeEventListener(e.trigger,e.listener)}})}if(t.children){G(t.children,function(e){he(e)})}}function de(e,t,r){if(e.tagName==="BODY"){return ye(e,t,r)}else{var n;var i=e.previousSibling;ce(u(e),e,t,r);if(i==null){n=u(e).firstChild}else{n=i.nextSibling}W(e).replacedWith=n;r.elts=[];while(n&&n!==e){if(n.nodeType===Node.ELEMENT_NODE){r.elts.push(n)}n=n.nextElementSibling}he(e);u(e).removeChild(e)}}function ve(e,t,r){return ce(e,e.firstChild,t,r)}function ge(e,t,r){return ce(u(e),e,t,r)}function pe(e,t,r){return ce(e,null,t,r)}function me(e,t,r){return ce(u(e),e.nextSibling,t,r)}function xe(e,t,r){he(e);return u(e).removeChild(e)}function ye(e,t,r){var n=e.firstChild;ce(e,n,t,r);if(n){while(n.nextSibling){he(n.nextSibling);e.removeChild(n.nextSibling)}he(n);e.removeChild(n)}}function be(e,t){var r=z(e,"hx-select");if(r){var n=_().createDocumentFragment();G(t.querySelectorAll(r),function(e){n.appendChild(e)});t=n}return t}function we(e,t,r,n,i){switch(e){case"none":return;case"outerHTML":de(r,n,i);return;case"afterbegin":ve(r,n,i);return;case"beforebegin":ge(r,n,i);return;case"beforeend":pe(r,n,i);return;case"afterend":me(r,n,i);return;case"delete":xe(r,n,i);return;default:var a=hr(t);for(var o=0;o-1){var t=e.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");var r=t.match(/]*>|>)([\s\S]*?)<\/title>/im);if(r){return r[2]}}}function Ee(e,t,r,n,i){i.title=Se(n);var a=g(n);if(a){oe(r,a,i);a=be(r,a);se(a);return we(e,r,t,a,i)}}function Ce(e,t,r){var n=e.getResponseHeader(t);if(n.indexOf("{")===0){var i=S(n);for(var a in i){if(i.hasOwnProperty(a)){var o=i[a];if(!x(o)){o={value:o}}$(r,a,o)}}}else{$(r,n,[])}}var Re=/\s/;var Oe=/[\s,]/;var qe=/[_$a-zA-Z]/;var Le=/[_$a-zA-Z0-9]/;var Te=['"',"'","/"];var Ae=/[^\s]/;function He(e){var t=[];var r=0;while(r0){var o=t[0];if(o==="]"){n--;if(n===0){if(a===null){i=i+"true"}t.shift();i+=")})";try{var s=Zt(e,function(){return Function(i)()},function(){return true});s.source=i;return s}catch(e){J(_().body,"htmx:syntax:error",{error:e,source:i});return null}}}else if(o==="["){n++}if(Ne(o,a,r)){i+="(("+r+"."+o+") ? ("+r+"."+o+") : (window."+o+"))"}else{i=i+o}a=t.shift()}}}function c(e,t){var r="";while(e.length>0&&!e[0].match(t)){r+=e.shift()}return r}var ke="input, textarea, select";function Me(e){var t=V(e,"hx-trigger");var r=[];if(t){var n=He(t);do{c(n,Ae);var f=n.length;var i=c(n,/[,\[\s]/);if(i!==""){if(i==="every"){var a={trigger:"every"};c(n,Ae);a.pollInterval=v(c(n,/[,\[\s]/));c(n,Ae);var o=Ie(e,n,"event");if(o){a.eventFilter=o}r.push(a)}else if(i.indexOf("sse:")===0){r.push({trigger:"sse",sseEvent:i.substr(4)})}else{var s={trigger:i};var o=Ie(e,n,"event");if(o){s.eventFilter=o}while(n.length>0&&n[0]!==","){c(n,Ae);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=v(c(n,Oe))}else if(l==="from"&&n[0]===":"){n.shift();var u=c(n,Oe);if(u==="closest"||u==="find"||u==="next"||u==="previous"){n.shift();u+=" "+c(n,Oe)}s.from=u}else if(l==="target"&&n[0]===":"){n.shift();s.target=c(n,Oe)}else if(l==="throttle"&&n[0]===":"){n.shift();s.throttle=v(c(n,Oe))}else if(l==="queue"&&n[0]===":"){n.shift();s.queue=c(n,Oe)}else if((l==="root"||l==="threshold")&&n[0]===":"){n.shift();s[l]=c(n,Oe)}else{J(e,"htmx:syntax:error",{token:n.shift()})}}r.push(s)}}if(n.length===f){J(e,"htmx:syntax:error",{token:n.shift()})}c(n,Ae)}while(n[0]===","&&n.shift())}if(r.length>0){return r}else if(d(e,"form")){return[{trigger:"submit"}]}else if(d(e,'input[type="button"]')){return[{trigger:"click"}]}else if(d(e,ke)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function De(e){W(e).cancelled=true}function Pe(e,t,r){var n=W(e);n.timeout=setTimeout(function(){if(K(e)&&n.cancelled!==true){if(!Ue(r,pt("hx:poll:trigger",{triggerSpec:r,target:e}))){t(e)}Pe(e,t,r)}},r.pollInterval)}function Xe(e){return location.hostname===e.hostname&&f(e,"href")&&f(e,"href").indexOf("#")!==0}function Fe(t,r,e){if(t.tagName==="A"&&Xe(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"){r.boosted=true;var n,i;if(t.tagName==="A"){n="get";i=f(t,"href")}else{var a=f(t,"method");n=a?a.toLowerCase():"get";if(n==="get"){}i=f(t,"action")}e.forEach(function(e){Ve(t,function(e){ar(n,i,t,e)},r,e,true)})}}function je(e,t){if(e.type==="submit"||e.type==="click"){if(t.tagName==="FORM"){return true}if(d(t,'input[type="submit"], button')&&N(t,"form")!==null){return true}if(t.tagName==="A"&&t.href&&(t.getAttribute("href")==="#"||t.getAttribute("href").indexOf("#")!==0)){return true}}return false}function Be(e,t){return W(e).boosted&&e.tagName==="A"&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function Ue(e,t){var r=e.eventFilter;if(r){try{return r(t)!==true}catch(e){J(_().body,"htmx:eventFilter:error",{error:e,source:r.source});return true}}return false}function Ve(a,o,e,s,l){var t;if(s.from){t=I(a,s.from)}else{t=[a]}G(t,function(n){var i=function(e){if(!K(a)){n.removeEventListener(s.trigger,i);return}if(Be(a,e)){return}if(l||je(e,a)){e.preventDefault()}if(Ue(s,e)){return}var t=W(e);t.triggerSpec=s;if(t.handledFor==null){t.handledFor=[]}var r=W(a);if(t.handledFor.indexOf(a)<0){t.handledFor.push(a);if(s.consume){e.stopPropagation()}if(s.target&&e.target){if(!d(e.target,s.target)){return}}if(s.once){if(r.triggeredOnce){return}else{r.triggeredOnce=true}}if(s.changed){if(r.lastValue===a.value){return}else{r.lastValue=a.value}}if(r.delayed){clearTimeout(r.delayed)}if(r.throttle){return}if(s.throttle){if(!r.throttle){o(a,e);r.throttle=setTimeout(function(){r.throttle=null},s.throttle)}}else if(s.delay){r.delayed=setTimeout(function(){o(a,e)},s.delay)}else{o(a,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:s.trigger,listener:i,on:n});n.addEventListener(s.trigger,i)})}var _e=false;var ze=null;function We(){if(!ze){ze=function(){_e=true};window.addEventListener("scroll",ze);setInterval(function(){if(_e){_e=false;G(_().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"),function(e){Ge(e)})}},200)}}function Ge(t){if(!o(t,"data-hx-revealed")&&b(t)){t.setAttribute("data-hx-revealed","true");var e=W(t);if(e.initialized){$(t,"revealed")}else{t.addEventListener("htmx:afterProcessNode",function(e){$(t,"revealed")},{once:true})}}}function Je(e,t,r){var n=w(r);for(var i=0;i=0){var t=Ye(n);setTimeout(function(){$e(s,r,n+1)},t)}};t.onopen=function(e){n=0};W(s).webSocket=t;t.addEventListener("message",function(e){if(Ze(s)){return}var t=e.data;xt(s,function(e){t=e.transformResponse(t,null,s)});var r=Gt(s);var n=g(t);var i=y(n.children);for(var a=0;a0){$(u,"htmx:validation:halted",i);return}t.send(JSON.stringify(l));if(je(e,u)){e.preventDefault()}})}else{J(u,"htmx:noWebSocketSourceError")}}function Ye(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()}yt('htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"')}function Qe(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){J(_().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Et(e){if(!E()){return null}var t=S(localStorage.getItem("htmx-history-cache"))||[];for(var r=0;r=200&&this.status<400){$(_().body,"htmx:historyCacheMissLoad",i);var e=g(this.response);e=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;var t=wt();var r=Gt(t);ye(t,e,r);Lt(r.tasks);bt=n;$(_().body,"htmx:historyRestore",{path:n})}else{J(_().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function At(e){Rt();e=e||location.pathname+location.search;var t=Et(e);if(t){var r=g(t.content);var n=wt();var i=Gt(n);ye(n,r,i);Lt(i.tasks);document.title=t.title;window.scrollTo(0,t.scroll);bt=e;$(_().body,"htmx:historyRestore",{path:e})}else{if(U.config.refreshOnHistoryMiss){window.location.reload(true)}else{Tt(e)}}}function Ht(e){var t=j(e,"hx-indicator");if(t==null){t=[e]}G(t,function(e){e.classList["add"].call(e.classList,U.config.requestClass)});return t}function Nt(e){G(e,function(e){e.classList["remove"].call(e.classList,U.config.requestClass)})}function It(e,t){for(var r=0;r=0}function _t(e,t){var r=t?t:z(e,"hx-swap");var n={swapStyle:W(e).boosted?"innerHTML":U.config.defaultSwapStyle,swapDelay:U.config.defaultSwapDelay,settleDelay:U.config.defaultSettleDelay};if(W(e).boosted&&!Vt(e)){n["show"]="top"}if(r){var i=w(r);if(i.length>0){n["swapStyle"]=i[0];for(var a=1;a0?l.join(":"):null;n["scroll"]=f;n["scrollTarget"]=u}if(o.indexOf("show:")===0){var c=o.substr(5);var l=c.split(":");var h=l.pop();var u=l.length>0?l.join(":"):null;n["show"]=h;n["showTarget"]=u}if(o.indexOf("focus-scroll:")===0){var d=o.substr("focus-scroll:".length);n["focusScroll"]=d=="true"}}}}return n}function zt(e){return z(e,"hx-encoding")==="multipart/form-data"||d(e,"form")&&f(e,"enctype")==="multipart/form-data"}function Wt(t,r,n){var i=null;xt(r,function(e){if(i==null){i=e.encodeParameters(t,n,r)}});if(i!=null){return i}else{if(zt(r)){return jt(n)}else{return Ft(n)}}}function Gt(e){return{tasks:[],elts:[e]}}function Jt(e,t){var r=e[0];var n=e[e.length-1];if(t.scroll){var i=null;if(t.scrollTarget){i=Q(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 a=t.showTarget;if(t.showTarget==="window"){a="body"}i=Q(r,a)}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 $t(e,t,r,n){if(n==null){n={}}if(e==null){return n}var i=V(e,t);if(i){var a=i.trim();var o=r;if(a.indexOf("javascript:")===0){a=a.substr(11);o=true}else if(a.indexOf("js:")===0){a=a.substr(3);o=true}if(a.indexOf("{")!==0){a="{"+a+"}"}var s;if(o){s=Zt(e,function(){return Function("return ("+a+")")()},{})}else{s=S(a)}for(var l in s){if(s.hasOwnProperty(l)){if(n[l]==null){n[l]=s[l]}}}}return $t(u(e),t,r,n)}function Zt(e,t,r){if(U.config.allowEval){return t()}else{J(e,"htmx:evalDisallowedError");return r}}function Kt(e,t){return $t(e,"hx-vars",true,t)}function Yt(e,t){return $t(e,"hx-vals",false,t)}function Qt(e){return Y(Kt(e),Yt(e))}function er(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 tr(t){if(t.responseURL&&typeof URL!=="undefined"){try{var e=new URL(t.responseURL);return e.pathname+e.search}catch(e){J(_().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function rr(e,t){return e.getAllResponseHeaders().match(t)}function nr(e,t,r){e=e.toLowerCase();if(r){if(r instanceof Element||p(r,"String")){return ar(e,t,null,null,{targetOverride:D(r),returnPromise:true})}else{return ar(e,t,D(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:D(r.target),swapOverride:r.swap,returnPromise:true})}}else{return ar(e,t,null,null,{returnPromise:true})}}function ir(e){var t=[];while(e){t.push(e);e=e.parentElement}return t}function ar(e,t,n,f,r){var c=null;var h=null;r=r!=null?r:{};if(r.returnPromise&&typeof Promise!=="undefined"){var d=new Promise(function(e,t){c=e;h=t})}if(n==null){n=_().body}var v=r.handler||sr;if(!K(n)){return}var g=r.targetOverride||re(n);if(g==null||g==ee){J(n,"htmx:targetError",{target:V(n,"hx-target")});return}var p=n;var i=W(n);var a=z(n,"hx-sync");var m=null;var x=false;if(a){var y=a.split(":");var b=y[0].trim();if(b==="this"){p=te(n,"hx-sync")}else{p=Q(n,b)}a=(y[1]||"drop").trim();i=W(p);if(a==="drop"&&i.xhr&&i.abortable!==true){return}else if(a==="abort"){if(i.xhr){return}else{x=true}}else if(a==="replace"){$(p,"htmx:abort")}else if(a.indexOf("queue")===0){var w=a.split(" ");m=(w[1]||"last").trim()}}if(i.xhr){if(i.abortable){$(p,"htmx:abort")}else{if(m==null){if(f){var S=W(f);if(S&&S.triggerSpec&&S.triggerSpec.queue){m=S.triggerSpec.queue}}if(m==null){m="last"}}if(i.queuedRequests==null){i.queuedRequests=[]}if(m==="first"&&i.queuedRequests.length===0){i.queuedRequests.push(function(){ar(e,t,n,f,r)})}else if(m==="all"){i.queuedRequests.push(function(){ar(e,t,n,f,r)})}else if(m==="last"){i.queuedRequests=[];i.queuedRequests.push(function(){ar(e,t,n,f,r)})}return}}var o=new XMLHttpRequest;i.xhr=o;i.abortable=x;var s=function(){i.xhr=null;i.abortable=false;if(i.queuedRequests!=null&&i.queuedRequests.length>0){var e=i.queuedRequests.shift();e()}};var E=z(n,"hx-prompt");if(E){var C=prompt(E);if(C===null||!$(n,"htmx:prompt",{prompt:C,target:g})){Z(c);s();return d}}var R=z(n,"hx-confirm");if(R){if(!confirm(R)){Z(c);s();return d}}var O=Bt(n,g,C);if(r.headers){O=Y(O,r.headers)}var q=Pt(n,e);var L=q.errors;var T=q.values;if(r.values){T=Y(T,r.values)}var A=Qt(n);var H=Y(T,A);var N=Ut(H,n);if(e!=="get"&&!zt(n)){O["Content-Type"]="application/x-www-form-urlencoded"}if(t==null||t===""){t=_().location.href}var I=$t(n,"hx-request");var l={parameters:N,unfilteredParameters:H,headers:O,target:g,verb:e,errors:L,withCredentials:r.credentials||I.credentials||U.config.withCredentials,timeout:r.timeout||I.timeout||U.config.timeout,path:t,triggeringEvent:f};if(!$(n,"htmx:configRequest",l)){Z(c);s();return d}t=l.path;e=l.verb;O=l.headers;N=l.parameters;L=l.errors;if(L&&L.length>0){$(n,"htmx:validation:halted",l);Z(c);s();return d}var k=t.split("#");var M=k[0];var D=k[1];var P=null;if(e==="get"){P=M;var X=Object.keys(N).length!==0;if(X){if(P.indexOf("?")<0){P+="?"}else{P+="&"}P+=Ft(N);if(D){P+="#"+D}}o.open("GET",P,true)}else{o.open(e.toUpperCase(),t,true)}o.overrideMimeType("text/html");o.withCredentials=l.withCredentials;o.timeout=l.timeout;if(I.noHeaders){}else{for(var F in O){if(O.hasOwnProperty(F)){var j=O[F];er(o,F,j)}}}var u={xhr:o,target:g,requestConfig:l,etc:r,pathInfo:{requestPath:t,finalRequestPath:P||t,anchor:D}};o.onload=function(){try{var e=ir(n);u.pathInfo.responsePath=tr(o);v(n,u);Nt(B);$(n,"htmx:afterRequest",u);$(n,"htmx:afterOnLoad",u);if(!K(n)){var t=null;while(e.length>0&&t==null){var r=e.shift();if(K(r)){t=r}}if(t){$(t,"htmx:afterRequest",u);$(t,"htmx:afterOnLoad",u)}}Z(c);s()}catch(e){J(n,"htmx:onLoadError",Y({error:e},u));throw e}};o.onerror=function(){Nt(B);J(n,"htmx:afterRequest",u);J(n,"htmx:sendError",u);Z(h);s()};o.onabort=function(){Nt(B);J(n,"htmx:afterRequest",u);J(n,"htmx:sendAbort",u);Z(h);s()};o.ontimeout=function(){Nt(B);J(n,"htmx:afterRequest",u);J(n,"htmx:timeout",u);Z(h);s()};if(!$(n,"htmx:beforeRequest",u)){Z(c);s();return d}var B=Ht(n);G(["loadstart","loadend","progress","abort"],function(t){G([o,o.upload],function(e){e.addEventListener(t,function(e){$(n,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});$(n,"htmx:beforeSend",u);o.send(e==="get"?null:Wt(o,n,N));return d}function or(e,t){var r=t.xhr;var n=null;var i=null;if(rr(r,/HX-Push:/i)){n=r.getResponseHeader("HX-Push");i="push"}else if(rr(r,/HX-Push-Url:/i)){n=r.getResponseHeader("HX-Push-Url");i="push"}else if(rr(r,/HX-Replace-Url:/i)){n=r.getResponseHeader("HX-Replace-Url");i="replace"}if(n){if(n==="false"){return{}}else{return{type:i,path:n}}}var a=t.pathInfo.finalRequestPath;var o=t.pathInfo.responsePath;var s=z(e,"hx-push-url");var f=z(e,"hx-replace-url");var c=W(e).boosted;var l=null;var u=null;if(s){l="push";u=s}else if(f){l="replace";u=f}else if(c){l="push";u=o||a}if(u){if(u==="false"){return{}}if(u==="true"){u=o||a}if(t.pathInfo.anchor&&u.indexOf("#")===-1){u=u+"#"+t.pathInfo.anchor}return{type:l,path:u}}else{return{}}}function sr(s,l){var u=l.xhr;var f=l.target;var n=l.etc;if(!$(s,"htmx:beforeOnLoad",l))return;if(rr(u,/HX-Trigger:/i)){Ce(u,"HX-Trigger",s)}if(rr(u,/HX-Location:/i)){Rt();var e=u.getResponseHeader("HX-Location");var c;if(e.indexOf("{")===0){c=S(e);e=c["path"];delete c["path"]}nr("GET",e,c).then(()=>{Ot(e)});return}if(rr(u,/HX-Redirect:/i)){location.href=u.getResponseHeader("HX-Redirect");return}if(rr(u,/HX-Refresh:/i)){if("true"===u.getResponseHeader("HX-Refresh")){location.reload();return}}if(rr(u,/HX-Retarget:/i)){l.target=_().querySelector(u.getResponseHeader("HX-Retarget"))}var h=or(s,l);var i=u.status>=200&&u.status<400&&u.status!==204;var d=u.response;var t=u.status>=400;var r=Y({shouldSwap:i,serverResponse:d,isError:t},l);if(!$(f,"htmx:beforeSwap",r))return;f=r.target;d=r.serverResponse;t=r.isError;l.failed=t;l.successful=!t;if(r.shouldSwap){if(u.status===286){De(s)}xt(s,function(e){d=e.transformResponse(d,u,s)});if(h.type){Rt()}var a=n.swapOverride;if(rr(u,/HX-Reswap:/i)){a=u.getResponseHeader("HX-Reswap")}var c=_t(s,a);f.classList.add(U.config.swappingClass);var o=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=Gt(f);Ee(c.swapStyle,f,s,d,n);if(t.elt&&!K(t.elt)&&t.elt.id){var r=document.getElementById(t.elt.id);var i={preventScroll:c.focusScroll!==undefined?!c.focusScroll:!U.config.defaultFocusScroll};if(r){if(t.start&&r.setSelectionRange){r.setSelectionRange(t.start,t.end)}r.focus(i)}}f.classList.remove(U.config.swappingClass);G(n.elts,function(e){if(e.classList){e.classList.add(U.config.settlingClass)}$(e,"htmx:afterSwap",l)});if(rr(u,/HX-Trigger-After-Swap:/i)){var a=s;if(!K(s)){a=_().body}Ce(u,"HX-Trigger-After-Swap",a)}var o=function(){G(n.tasks,function(e){e.call()});G(n.elts,function(e){if(e.classList){e.classList.remove(U.config.settlingClass)}$(e,"htmx:afterSettle",l)});if(h.type){if(h.type==="push"){Ot(h.path);$(_().body,"htmx:pushedIntoHistory",{path:h.path})}else{qt(h.path);$(_().body,"htmx:replacedInHistory",{path:h.path})}}if(l.pathInfo.anchor){var e=R("#"+l.pathInfo.anchor);if(e){e.scrollIntoView({block:"start",behavior:"auto"})}}if(n.title){var t=R("title");if(t){t.innerHTML=n.title}else{window.document.title=n.title}}Jt(n.elts,c);if(rr(u,/HX-Trigger-After-Settle:/i)){var r=s;if(!K(s)){r=_().body}Ce(u,"HX-Trigger-After-Settle",r)}};if(c.settleDelay>0){setTimeout(o,c.settleDelay)}else{o()}}catch(e){J(s,"htmx:swapError",l);throw e}};if(c.swapDelay>0){setTimeout(o,c.swapDelay)}else{o()}}if(t){J(s,"htmx:responseError",Y({error:"Response Status Error Code "+u.status+" from "+l.pathInfo.path},l))}}var lr={};function ur(){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 fr(e,t){if(t.init){t.init(r)}lr[e]=Y(ur(),t)}function cr(e){delete lr[e]}function hr(e,r,n){if(e==undefined){return r}if(r==undefined){r=[]}if(n==undefined){n=[]}var t=V(e,"hx-ext");if(t){G(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=lr[e];if(t&&r.indexOf(t)<0){r.push(t)}}})}return hr(u(e),r,n)}function dr(e){if(_().readyState!=="loading"){e()}else{_().addEventListener("DOMContentLoaded",e)}}function vr(){if(U.config.includeIndicatorStyles!==false){_().head.insertAdjacentHTML("beforeend","")}}function gr(){var e=_().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function pr(){var e=gr();if(e){U.config=Y(U.config,e)}}dr(function(){pr();vr();var e=_().body;vt(e);var t=_().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){var t=e.target;var r=W(t);if(r&&r.xhr){r.xhr.abort()}});window.onpopstate=function(e){if(e.state&&e.state.htmx){At();G(t,function(e){$(e,"htmx:restored",{document:_(),triggerEvent:$})})}};setTimeout(function(){$(e,"htmx:load",{})},0)});return U}()}); \ No newline at end of file +(function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else if(typeof module==="object"&&module.exports){module.exports=t()}else{e.htmx=e.htmx||t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";var Q={onLoad:B,process:zt,on:de,off:ge,trigger:ce,ajax:Nr,find:C,findAll:f,closest:v,values:function(e,t){var r=dr(e,t||"post");return r.values},remove:_,addClass:z,removeClass:n,toggleClass:$,takeClass:W,defineExtension:Ur,removeExtension:Fr,logAll:V,logNone:j,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,allowScriptTags:true,inlineScriptNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",useTemplateFragments:false,scrollBehavior:"smooth",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get"],selfRequestsOnly:false,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null},parseInterval:d,_:t,createEventSource:function(e){return new EventSource(e,{withCredentials:true})},createWebSocket:function(e){var t=new WebSocket(e,[]);t.binaryType=Q.config.wsBinaryType;return t},version:"1.9.11"};var r={addTriggerHandler:Lt,bodyContains:se,canAccessLocalStorage:U,findThisElement:xe,filterValues:yr,hasAttribute:o,getAttributeValue:te,getClosestAttributeValue:ne,getClosestMatch:c,getExpressionVars:Hr,getHeaders:xr,getInputValues:dr,getInternalData:ae,getSwapSpecification:wr,getTriggerSpecs:it,getTarget:ye,makeFragment:l,mergeObjects:le,makeSettleInfo:T,oobSwap:Ee,querySelectorExt:ue,selectAndSwap:je,settleImmediately:nr,shouldCancel:ut,triggerEvent:ce,triggerErrorEvent:fe,withExtensions:R};var w=["get","post","put","delete","patch"];var i=w.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");var S=e("head"),q=e("title"),H=e("svg",true);function e(e,t=false){return new RegExp(`<${e}(\\s[^>]*>|>)([\\s\\S]*?)<\\/${e}>`,t?"gim":"im")}function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e.getAttribute&&e.getAttribute(t)}function o(e,t){return e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function te(e,t){return ee(e,t)||ee(e,"data-"+t)}function u(e){return e.parentElement}function re(){return document}function c(e,t){while(e&&!t(e)){e=u(e)}return e?e:null}function L(e,t,r){var n=te(t,r);var i=te(t,"hx-disinherit");if(e!==t&&i&&(i==="*"||i.split(" ").indexOf(r)>=0)){return"unset"}else{return n}}function ne(t,r){var n=null;c(t,function(e){return n=L(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 s(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=re().createDocumentFragment()}return i}function N(e){return/",0);var a=i.querySelector("template").content;if(Q.config.allowScriptTags){oe(a.querySelectorAll("script"),function(e){if(Q.config.inlineScriptNonce){e.nonce=Q.config.inlineScriptNonce}e.htmxExecuted=navigator.userAgent.indexOf("Firefox")===-1})}else{oe(a.querySelectorAll("script"),function(e){_(e)})}return a}switch(r){case"thead":case"tbody":case"tfoot":case"colgroup":case"caption":return s(""+n+"
",1);case"col":return s(""+n+"
",2);case"tr":return s(""+n+"
",2);case"td":case"th":return s(""+n+"
",3);case"script":case"style":return s("
"+n+"
",1);default:return s(n,0)}}function ie(e){if(e){e()}}function I(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function k(e){return I(e,"Function")}function P(e){return I(e,"Object")}function ae(e){var t="htmx-internal-data";var r=e[t];if(!r){r=e[t]={}}return r}function M(e){var t=[];if(e){for(var r=0;r=0}function se(e){if(e.getRootNode&&e.getRootNode()instanceof window.ShadowRoot){return re().body.contains(e.getRootNode().host)}else{return re().body.contains(e)}}function D(e){return e.trim().split(/\s+/)}function le(e,t){for(var r in t){if(t.hasOwnProperty(r)){e[r]=t[r]}}return e}function E(e){try{return JSON.parse(e)}catch(e){b(e);return null}}function U(){var e="htmx:localStorageTest";try{localStorage.setItem(e,e);localStorage.removeItem(e);return true}catch(e){return false}}function F(t){try{var e=new URL(t);if(e){t=e.pathname+e.search}if(!/^\/$/.test(t)){t=t.replace(/\/+$/,"")}return t}catch(e){return t}}function t(e){return Tr(re().body,function(){return eval(e)})}function B(t){var e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function V(){Q.logger=function(e,t,r){if(console){console.log(t,e,r)}}}function j(){Q.logger=null}function C(e,t){if(t){return e.querySelector(t)}else{return C(re(),e)}}function f(e,t){if(t){return e.querySelectorAll(t)}else{return f(re(),e)}}function _(e,t){e=p(e);if(t){setTimeout(function(){_(e);e=null},t)}else{e.parentElement.removeChild(e)}}function z(e,t,r){e=p(e);if(r){setTimeout(function(){z(e,t);e=null},r)}else{e.classList&&e.classList.add(t)}}function n(e,t,r){e=p(e);if(r){setTimeout(function(){n(e,t);e=null},r)}else{if(e.classList){e.classList.remove(t);if(e.classList.length===0){e.removeAttribute("class")}}}}function $(e,t){e=p(e);e.classList.toggle(t)}function W(e,t){e=p(e);oe(e.parentElement.children,function(e){n(e,t)});z(e,t)}function v(e,t){e=p(e);if(e.closest){return e.closest(t)}else{do{if(e==null||h(e,t)){return e}}while(e=e&&u(e));return null}}function g(e,t){return e.substring(0,t.length)===t}function G(e,t){return e.substring(e.length-t.length)===t}function J(e){var t=e.trim();if(g(t,"<")&&G(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function Z(e,t){if(t.indexOf("closest ")===0){return[v(e,J(t.substr(8)))]}else if(t.indexOf("find ")===0){return[C(e,J(t.substr(5)))]}else if(t==="next"){return[e.nextElementSibling]}else if(t.indexOf("next ")===0){return[K(e,J(t.substr(5)))]}else if(t==="previous"){return[e.previousElementSibling]}else if(t.indexOf("previous ")===0){return[Y(e,J(t.substr(9)))]}else if(t==="document"){return[document]}else if(t==="window"){return[window]}else if(t==="body"){return[document.body]}else{return re().querySelectorAll(J(t))}}var K=function(e,t){var r=re().querySelectorAll(t);for(var n=0;n=0;n--){var i=r[n];if(i.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING){return i}}};function ue(e,t){if(t){return Z(e,t)[0]}else{return Z(re().body,e)[0]}}function p(e){if(I(e,"String")){return C(e)}else{return e}}function ve(e,t,r){if(k(t)){return{target:re().body,event:e,listener:t}}else{return{target:p(e),event:t,listener:r}}}function de(t,r,n){jr(function(){var e=ve(t,r,n);e.target.addEventListener(e.event,e.listener)});var e=k(r);return e?r:n}function ge(t,r,n){jr(function(){var e=ve(t,r,n);e.target.removeEventListener(e.event,e.listener)});return k(r)?r:n}var pe=re().createElement("output");function me(e,t){var r=ne(e,t);if(r){if(r==="this"){return[xe(e,t)]}else{var n=Z(e,r);if(n.length===0){b('The selector "'+r+'" on '+t+" returned no matches!");return[pe]}else{return n}}}}function xe(e,t){return c(e,function(e){return te(e,t)!=null})}function ye(e){var t=ne(e,"hx-target");if(t){if(t==="this"){return xe(e,"hx-target")}else{return ue(e,t)}}else{var r=ae(e);if(r.boosted){return re().body}else{return e}}}function be(e){var t=Q.config.attributesToSettle;for(var r=0;r0){o=e.substr(0,e.indexOf(":"));t=e.substr(e.indexOf(":")+1,e.length)}else{o=e}var r=re().querySelectorAll(t);if(r){oe(r,function(e){var t;var r=i.cloneNode(true);t=re().createDocumentFragment();t.appendChild(r);if(!Se(o,e)){t=r}var n={shouldSwap:true,target:e,fragment:t};if(!ce(e,"htmx:oobBeforeSwap",n))return;e=n.target;if(n["shouldSwap"]){Be(o,e,e,t,a)}oe(a.elts,function(e){ce(e,"htmx:oobAfterSwap",n)})});i.parentNode.removeChild(i)}else{i.parentNode.removeChild(i);fe(re().body,"htmx:oobErrorNoTarget",{content:i})}return e}function Ce(e,t,r){var n=ne(e,"hx-select-oob");if(n){var i=n.split(",");for(var a=0;a0){var r=t.replace("'","\\'");var n=e.tagName.replace(":","\\:");var i=o.querySelector(n+"[id='"+r+"']");if(i&&i!==o){var a=e.cloneNode();we(e,i);s.tasks.push(function(){we(e,a)})}}})}function Oe(e){return function(){n(e,Q.config.addedClass);zt(e);Nt(e);qe(e);ce(e,"htmx:load")}}function qe(e){var t="[autofocus]";var r=h(e,t)?e:e.querySelector(t);if(r!=null){r.focus()}}function a(e,t,r,n){Te(e,r,n);while(r.childNodes.length>0){var i=r.firstChild;z(i,Q.config.addedClass);e.insertBefore(i,t);if(i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.COMMENT_NODE){n.tasks.push(Oe(i))}}}function He(e,t){var r=0;while(r-1){var t=e.replace(H,"");var r=t.match(q);if(r){return r[2]}}}function je(e,t,r,n,i,a){i.title=Ve(n);var o=l(n);if(o){Ce(r,o,i);o=Fe(r,o,a);Re(o);return Be(e,r,t,o,i)}}function _e(e,t,r){var n=e.getResponseHeader(t);if(n.indexOf("{")===0){var i=E(n);for(var a in i){if(i.hasOwnProperty(a)){var o=i[a];if(!P(o)){o={value:o}}ce(r,a,o)}}}else{var s=n.split(",");for(var l=0;l0){var o=t[0];if(o==="]"){n--;if(n===0){if(a===null){i=i+"true"}t.shift();i+=")})";try{var s=Tr(e,function(){return Function(i)()},function(){return true});s.source=i;return s}catch(e){fe(re().body,"htmx:syntax:error",{error:e,source:i});return null}}}else if(o==="["){n++}if(Qe(o,a,r)){i+="(("+r+"."+o+") ? ("+r+"."+o+") : (window."+o+"))"}else{i=i+o}a=t.shift()}}}function y(e,t){var r="";while(e.length>0&&!t.test(e[0])){r+=e.shift()}return r}function tt(e){var t;if(e.length>0&&Ze.test(e[0])){e.shift();t=y(e,Ke).trim();e.shift()}else{t=y(e,x)}return t}var rt="input, textarea, select";function nt(e,t,r){var n=[];var i=Ye(t);do{y(i,Je);var a=i.length;var o=y(i,/[,\[\s]/);if(o!==""){if(o==="every"){var s={trigger:"every"};y(i,Je);s.pollInterval=d(y(i,/[,\[\s]/));y(i,Je);var l=et(e,i,"event");if(l){s.eventFilter=l}n.push(s)}else if(o.indexOf("sse:")===0){n.push({trigger:"sse",sseEvent:o.substr(4)})}else{var u={trigger:o};var l=et(e,i,"event");if(l){u.eventFilter=l}while(i.length>0&&i[0]!==","){y(i,Je);var f=i.shift();if(f==="changed"){u.changed=true}else if(f==="once"){u.once=true}else if(f==="consume"){u.consume=true}else if(f==="delay"&&i[0]===":"){i.shift();u.delay=d(y(i,x))}else if(f==="from"&&i[0]===":"){i.shift();if(Ze.test(i[0])){var c=tt(i)}else{var c=y(i,x);if(c==="closest"||c==="find"||c==="next"||c==="previous"){i.shift();var h=tt(i);if(h.length>0){c+=" "+h}}}u.from=c}else if(f==="target"&&i[0]===":"){i.shift();u.target=tt(i)}else if(f==="throttle"&&i[0]===":"){i.shift();u.throttle=d(y(i,x))}else if(f==="queue"&&i[0]===":"){i.shift();u.queue=y(i,x)}else if(f==="root"&&i[0]===":"){i.shift();u[f]=tt(i)}else if(f==="threshold"&&i[0]===":"){i.shift();u[f]=y(i,x)}else{fe(e,"htmx:syntax:error",{token:i.shift()})}}n.push(u)}}if(i.length===a){fe(e,"htmx:syntax:error",{token:i.shift()})}y(i,Je)}while(i[0]===","&&i.shift());if(r){r[t]=n}return n}function it(e){var t=te(e,"hx-trigger");var r=[];if(t){var n=Q.config.triggerSpecsCache;r=n&&n[t]||nt(e,t,n)}if(r.length>0){return r}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(h(e,rt)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function at(e){ae(e).cancelled=true}function ot(e,t,r){var n=ae(e);n.timeout=setTimeout(function(){if(se(e)&&n.cancelled!==true){if(!ct(r,e,Wt("hx:poll:trigger",{triggerSpec:r,target:e}))){t(e)}ot(e,t,r)}},r.pollInterval)}function st(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function lt(t,r,e){if(t.tagName==="A"&&st(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"){r.boosted=true;var n,i;if(t.tagName==="A"){n="get";i=ee(t,"href")}else{var a=ee(t,"method");n=a?a.toLowerCase():"get";if(n==="get"){}i=ee(t,"action")}e.forEach(function(e){ht(t,function(e,t){if(v(e,Q.config.disableSelector)){m(e);return}he(n,i,e,t)},r,e,true)})}}function ut(e,t){if(e.type==="submit"||e.type==="click"){if(t.tagName==="FORM"){return true}if(h(t,'input[type="submit"], button')&&v(t,"form")!==null){return true}if(t.tagName==="A"&&t.href&&(t.getAttribute("href")==="#"||t.getAttribute("href").indexOf("#")!==0)){return true}}return false}function ft(e,t){return ae(e).boosted&&e.tagName==="A"&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function ct(e,t,r){var n=e.eventFilter;if(n){try{return n.call(t,r)!==true}catch(e){fe(re().body,"htmx:eventFilter:error",{error:e,source:n.source});return true}}return false}function ht(a,o,e,s,l){var u=ae(a);var t;if(s.from){t=Z(a,s.from)}else{t=[a]}if(s.changed){t.forEach(function(e){var t=ae(e);t.lastValue=e.value})}oe(t,function(n){var i=function(e){if(!se(a)){n.removeEventListener(s.trigger,i);return}if(ft(a,e)){return}if(l||ut(e,a)){e.preventDefault()}if(ct(s,a,e)){return}var t=ae(e);t.triggerSpec=s;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(a)<0){t.handledFor.push(a);if(s.consume){e.stopPropagation()}if(s.target&&e.target){if(!h(e.target,s.target)){return}}if(s.once){if(u.triggeredOnce){return}else{u.triggeredOnce=true}}if(s.changed){var r=ae(n);if(r.lastValue===n.value){return}r.lastValue=n.value}if(u.delayed){clearTimeout(u.delayed)}if(u.throttle){return}if(s.throttle>0){if(!u.throttle){o(a,e);u.throttle=setTimeout(function(){u.throttle=null},s.throttle)}}else if(s.delay>0){u.delayed=setTimeout(function(){o(a,e)},s.delay)}else{ce(a,"htmx:trigger");o(a,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:s.trigger,listener:i,on:n});n.addEventListener(s.trigger,i)})}var vt=false;var dt=null;function gt(){if(!dt){dt=function(){vt=true};window.addEventListener("scroll",dt);setInterval(function(){if(vt){vt=false;oe(re().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"),function(e){pt(e)})}},200)}}function pt(t){if(!o(t,"data-hx-revealed")&&X(t)){t.setAttribute("data-hx-revealed","true");var e=ae(t);if(e.initHash){ce(t,"revealed")}else{t.addEventListener("htmx:afterProcessNode",function(e){ce(t,"revealed")},{once:true})}}}function mt(e,t,r){var n=D(r);for(var i=0;i=0){var t=wt(n);setTimeout(function(){xt(s,r,n+1)},t)}};t.onopen=function(e){n=0};ae(s).webSocket=t;t.addEventListener("message",function(e){if(yt(s)){return}var t=e.data;R(s,function(e){t=e.transformResponse(t,null,s)});var r=T(s);var n=l(t);var i=M(n.children);for(var a=0;a0){ce(u,"htmx:validation:halted",i);return}t.send(JSON.stringify(l));if(ut(e,u)){e.preventDefault()}})}else{fe(u,"htmx:noWebSocketSourceError")}}function wt(e){var t=Q.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()}b('htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"')}function St(e,t,r){var n=D(r);for(var i=0;i0){setTimeout(i,n)}else{i()}}function Ht(t,i,e){var a=false;oe(w,function(r){if(o(t,"hx-"+r)){var n=te(t,"hx-"+r);a=true;i.path=n;i.verb=r;e.forEach(function(e){Lt(t,e,i,function(e,t){if(v(e,Q.config.disableSelector)){m(e);return}he(r,n,e,t)})})}});return a}function Lt(n,e,t,r){if(e.sseEvent){Rt(n,r,e.sseEvent)}else if(e.trigger==="revealed"){gt();ht(n,r,t,e);pt(n)}else if(e.trigger==="intersect"){var i={};if(e.root){i.root=ue(n,e.root)}if(e.threshold){i.threshold=parseFloat(e.threshold)}var a=new IntersectionObserver(function(e){for(var t=0;t0){t.polling=true;ot(n,r,e)}else{ht(n,r,t,e)}}function At(e){if(!e.htmxExecuted&&Q.config.allowScriptTags&&(e.type==="text/javascript"||e.type==="module"||e.type==="")){var t=re().createElement("script");oe(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}var r=e.parentElement;try{r.insertBefore(t,e)}catch(e){b(e)}finally{if(e.parentElement){e.parentElement.removeChild(e)}}}}function Nt(e){if(h(e,"script")){At(e)}oe(f(e,"script"),function(e){At(e)})}function It(e){var t=e.attributes;for(var r=0;r0){var o=n.shift();var s=o.match(/^\s*([a-zA-Z:\-\.]+:)(.*)/);if(a===0&&s){o.split(":");i=s[1].slice(0,-1);r[i]=s[2]}else{r[i]+=o}a+=Ft(o)}for(var l in r){Bt(e,l,r[l])}}}function jt(e){Ae(e);for(var t=0;tQ.config.historyCacheSize){i.shift()}while(i.length>0){try{localStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){fe(re().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Yt(e){if(!U()){return null}e=F(e);var t=E(localStorage.getItem("htmx-history-cache"))||[];for(var r=0;r=200&&this.status<400){ce(re().body,"htmx:historyCacheMissLoad",o);var e=l(this.response);e=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;var t=Zt();var r=T(t);var n=Ve(this.response);if(n){var i=C("title");if(i){i.innerHTML=n}else{window.document.title=n}}Ue(t,e,r);nr(r.tasks);Jt=a;ce(re().body,"htmx:historyRestore",{path:a,cacheMiss:true,serverResponse:this.response})}else{fe(re().body,"htmx:historyCacheMissLoadError",o)}};e.send()}function ar(e){er();e=e||location.pathname+location.search;var t=Yt(e);if(t){var r=l(t.content);var n=Zt();var i=T(n);Ue(n,r,i);nr(i.tasks);document.title=t.title;setTimeout(function(){window.scrollTo(0,t.scroll)},0);Jt=e;ce(re().body,"htmx:historyRestore",{path:e,item:t})}else{if(Q.config.refreshOnHistoryMiss){window.location.reload(true)}else{ir(e)}}}function or(e){var t=me(e,"hx-indicator");if(t==null){t=[e]}oe(t,function(e){var t=ae(e);t.requestCount=(t.requestCount||0)+1;e.classList["add"].call(e.classList,Q.config.requestClass)});return t}function sr(e){var t=me(e,"hx-disabled-elt");if(t==null){t=[]}oe(t,function(e){var t=ae(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","")});return t}function lr(e,t){oe(e,function(e){var t=ae(e);t.requestCount=(t.requestCount||0)-1;if(t.requestCount===0){e.classList["remove"].call(e.classList,Q.config.requestClass)}});oe(t,function(e){var t=ae(e);t.requestCount=(t.requestCount||0)-1;if(t.requestCount===0){e.removeAttribute("disabled")}})}function ur(e,t){for(var r=0;r=0}function wr(e,t){var r=t?t:ne(e,"hx-swap");var n={swapStyle:ae(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&ae(e).boosted&&!br(e)){n["show"]="top"}if(r){var i=D(r);if(i.length>0){for(var a=0;a0?l.join(":"):null;n["scroll"]=u;n["scrollTarget"]=f}else if(o.indexOf("show:")===0){var c=o.substr(5);var l=c.split(":");var h=l.pop();var f=l.length>0?l.join(":"):null;n["show"]=h;n["showTarget"]=f}else if(o.indexOf("focus-scroll:")===0){var v=o.substr("focus-scroll:".length);n["focusScroll"]=v=="true"}else if(a==0){n["swapStyle"]=o}else{b("Unknown modifier in hx-swap: "+o)}}}}return n}function Sr(e){return ne(e,"hx-encoding")==="multipart/form-data"||h(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function Er(t,r,n){var i=null;R(r,function(e){if(i==null){i=e.encodeParameters(t,n,r)}});if(i!=null){return i}else{if(Sr(r)){return mr(n)}else{return pr(n)}}}function T(e){return{tasks:[],elts:[e]}}function Cr(e,t){var r=e[0];var n=e[e.length-1];if(t.scroll){var i=null;if(t.scrollTarget){i=ue(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 a=t.showTarget;if(t.showTarget==="window"){a="body"}i=ue(r,a)}if(t.show==="top"&&(r||i)){i=i||r;i.scrollIntoView({block:"start",behavior:Q.config.scrollBehavior})}if(t.show==="bottom"&&(n||i)){i=i||n;i.scrollIntoView({block:"end",behavior:Q.config.scrollBehavior})}}}function Rr(e,t,r,n){if(n==null){n={}}if(e==null){return n}var i=te(e,t);if(i){var a=i.trim();var o=r;if(a==="unset"){return null}if(a.indexOf("javascript:")===0){a=a.substr(11);o=true}else if(a.indexOf("js:")===0){a=a.substr(3);o=true}if(a.indexOf("{")!==0){a="{"+a+"}"}var s;if(o){s=Tr(e,function(){return Function("return ("+a+")")()},{})}else{s=E(a)}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 Tr(e,t,r){if(Q.config.allowEval){return t()}else{fe(e,"htmx:evalDisallowedError");return r}}function Or(e,t){return Rr(e,"hx-vars",true,t)}function qr(e,t){return Rr(e,"hx-vals",false,t)}function Hr(e){return le(Or(e),qr(e))}function Lr(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 Ar(t){if(t.responseURL&&typeof URL!=="undefined"){try{var e=new URL(t.responseURL);return e.pathname+e.search}catch(e){fe(re().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function O(e,t){return t.test(e.getAllResponseHeaders())}function Nr(e,t,r){e=e.toLowerCase();if(r){if(r instanceof Element||I(r,"String")){return he(e,t,null,null,{targetOverride:p(r),returnPromise:true})}else{return he(e,t,p(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:p(r.target),swapOverride:r.swap,select:r.select,returnPromise:true})}}else{return he(e,t,null,null,{returnPromise:true})}}function Ir(e){var t=[];while(e){t.push(e);e=e.parentElement}return t}function kr(e,t,r){var n;var i;if(typeof URL==="function"){i=new URL(t,document.location.href);var a=document.location.origin;n=a===i.origin}else{i=t;n=g(t,document.location.origin)}if(Q.config.selfRequestsOnly){if(!n){return false}}return ce(e,"htmx:validateUrl",le({url:i,sameHost:n},r))}function he(t,r,n,i,a,e){var o=null;var s=null;a=a!=null?a:{};if(a.returnPromise&&typeof Promise!=="undefined"){var l=new Promise(function(e,t){o=e;s=t})}if(n==null){n=re().body}var M=a.handler||Mr;var X=a.select||null;if(!se(n)){ie(o);return l}var u=a.targetOverride||ye(n);if(u==null||u==pe){fe(n,"htmx:targetError",{target:te(n,"hx-target")});ie(s);return l}var f=ae(n);var c=f.lastButtonClicked;if(c){var h=ee(c,"formaction");if(h!=null){r=h}var v=ee(c,"formmethod");if(v!=null){if(v.toLowerCase()!=="dialog"){t=v}}}var d=ne(n,"hx-confirm");if(e===undefined){var D=function(e){return he(t,r,n,i,a,!!e)};var U={target:u,elt:n,path:r,verb:t,triggeringEvent:i,etc:a,issueRequest:D,question:d};if(ce(n,"htmx:confirm",U)===false){ie(o);return l}}var g=n;var p=ne(n,"hx-sync");var m=null;var x=false;if(p){var F=p.split(":");var B=F[0].trim();if(B==="this"){g=xe(n,"hx-sync")}else{g=ue(n,B)}p=(F[1]||"drop").trim();f=ae(g);if(p==="drop"&&f.xhr&&f.abortable!==true){ie(o);return l}else if(p==="abort"){if(f.xhr){ie(o);return l}else{x=true}}else if(p==="replace"){ce(g,"htmx:abort")}else if(p.indexOf("queue")===0){var V=p.split(" ");m=(V[1]||"last").trim()}}if(f.xhr){if(f.abortable){ce(g,"htmx:abort")}else{if(m==null){if(i){var y=ae(i);if(y&&y.triggerSpec&&y.triggerSpec.queue){m=y.triggerSpec.queue}}if(m==null){m="last"}}if(f.queuedRequests==null){f.queuedRequests=[]}if(m==="first"&&f.queuedRequests.length===0){f.queuedRequests.push(function(){he(t,r,n,i,a)})}else if(m==="all"){f.queuedRequests.push(function(){he(t,r,n,i,a)})}else if(m==="last"){f.queuedRequests=[];f.queuedRequests.push(function(){he(t,r,n,i,a)})}ie(o);return l}}var b=new XMLHttpRequest;f.xhr=b;f.abortable=x;var w=function(){f.xhr=null;f.abortable=false;if(f.queuedRequests!=null&&f.queuedRequests.length>0){var e=f.queuedRequests.shift();e()}};var j=ne(n,"hx-prompt");if(j){var S=prompt(j);if(S===null||!ce(n,"htmx:prompt",{prompt:S,target:u})){ie(o);w();return l}}if(d&&!e){if(!confirm(d)){ie(o);w();return l}}var E=xr(n,u,S);if(t!=="get"&&!Sr(n)){E["Content-Type"]="application/x-www-form-urlencoded"}if(a.headers){E=le(E,a.headers)}var _=dr(n,t);var C=_.errors;var R=_.values;if(a.values){R=le(R,a.values)}var z=Hr(n);var $=le(R,z);var T=yr($,n);if(Q.config.getCacheBusterParam&&t==="get"){T["org.htmx.cache-buster"]=ee(u,"id")||"true"}if(r==null||r===""){r=re().location.href}var O=Rr(n,"hx-request");var W=ae(n).boosted;var q=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;var H={boosted:W,useUrlParams:q,parameters:T,unfilteredParameters:$,headers:E,target:u,verb:t,errors:C,withCredentials:a.credentials||O.credentials||Q.config.withCredentials,timeout:a.timeout||O.timeout||Q.config.timeout,path:r,triggeringEvent:i};if(!ce(n,"htmx:configRequest",H)){ie(o);w();return l}r=H.path;t=H.verb;E=H.headers;T=H.parameters;C=H.errors;q=H.useUrlParams;if(C&&C.length>0){ce(n,"htmx:validation:halted",H);ie(o);w();return l}var G=r.split("#");var J=G[0];var L=G[1];var A=r;if(q){A=J;var Z=Object.keys(T).length!==0;if(Z){if(A.indexOf("?")<0){A+="?"}else{A+="&"}A+=pr(T);if(L){A+="#"+L}}}if(!kr(n,A,H)){fe(n,"htmx:invalidPath",H);ie(s);return l}b.open(t.toUpperCase(),A,true);b.overrideMimeType("text/html");b.withCredentials=H.withCredentials;b.timeout=H.timeout;if(O.noHeaders){}else{for(var N in E){if(E.hasOwnProperty(N)){var K=E[N];Lr(b,N,K)}}}var I={xhr:b,target:u,requestConfig:H,etc:a,boosted:W,select:X,pathInfo:{requestPath:r,finalRequestPath:A,anchor:L}};b.onload=function(){try{var e=Ir(n);I.pathInfo.responsePath=Ar(b);M(n,I);lr(k,P);ce(n,"htmx:afterRequest",I);ce(n,"htmx:afterOnLoad",I);if(!se(n)){var t=null;while(e.length>0&&t==null){var r=e.shift();if(se(r)){t=r}}if(t){ce(t,"htmx:afterRequest",I);ce(t,"htmx:afterOnLoad",I)}}ie(o);w()}catch(e){fe(n,"htmx:onLoadError",le({error:e},I));throw e}};b.onerror=function(){lr(k,P);fe(n,"htmx:afterRequest",I);fe(n,"htmx:sendError",I);ie(s);w()};b.onabort=function(){lr(k,P);fe(n,"htmx:afterRequest",I);fe(n,"htmx:sendAbort",I);ie(s);w()};b.ontimeout=function(){lr(k,P);fe(n,"htmx:afterRequest",I);fe(n,"htmx:timeout",I);ie(s);w()};if(!ce(n,"htmx:beforeRequest",I)){ie(o);w();return l}var k=or(n);var P=sr(n);oe(["loadstart","loadend","progress","abort"],function(t){oe([b,b.upload],function(e){e.addEventListener(t,function(e){ce(n,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});ce(n,"htmx:beforeSend",I);var Y=q?null:Er(b,n,T);b.send(Y);return l}function Pr(e,t){var r=t.xhr;var n=null;var i=null;if(O(r,/HX-Push:/i)){n=r.getResponseHeader("HX-Push");i="push"}else if(O(r,/HX-Push-Url:/i)){n=r.getResponseHeader("HX-Push-Url");i="push"}else if(O(r,/HX-Replace-Url:/i)){n=r.getResponseHeader("HX-Replace-Url");i="replace"}if(n){if(n==="false"){return{}}else{return{type:i,path:n}}}var a=t.pathInfo.finalRequestPath;var o=t.pathInfo.responsePath;var s=ne(e,"hx-push-url");var l=ne(e,"hx-replace-url");var u=ae(e).boosted;var f=null;var c=null;if(s){f="push";c=s}else if(l){f="replace";c=l}else if(u){f="push";c=o||a}if(c){if(c==="false"){return{}}if(c==="true"){c=o||a}if(t.pathInfo.anchor&&c.indexOf("#")===-1){c=c+"#"+t.pathInfo.anchor}return{type:f,path:c}}else{return{}}}function Mr(l,u){var f=u.xhr;var c=u.target;var e=u.etc;var t=u.requestConfig;var h=u.select;if(!ce(l,"htmx:beforeOnLoad",u))return;if(O(f,/HX-Trigger:/i)){_e(f,"HX-Trigger",l)}if(O(f,/HX-Location:/i)){er();var r=f.getResponseHeader("HX-Location");var v;if(r.indexOf("{")===0){v=E(r);r=v["path"];delete v["path"]}Nr("GET",r,v).then(function(){tr(r)});return}var n=O(f,/HX-Refresh:/i)&&"true"===f.getResponseHeader("HX-Refresh");if(O(f,/HX-Redirect:/i)){location.href=f.getResponseHeader("HX-Redirect");n&&location.reload();return}if(n){location.reload();return}if(O(f,/HX-Retarget:/i)){if(f.getResponseHeader("HX-Retarget")==="this"){u.target=l}else{u.target=ue(l,f.getResponseHeader("HX-Retarget"))}}var d=Pr(l,u);var i=f.status>=200&&f.status<400&&f.status!==204;var g=f.response;var a=f.status>=400;var p=Q.config.ignoreTitle;var o=le({shouldSwap:i,serverResponse:g,isError:a,ignoreTitle:p},u);if(!ce(c,"htmx:beforeSwap",o))return;c=o.target;g=o.serverResponse;a=o.isError;p=o.ignoreTitle;u.target=c;u.failed=a;u.successful=!a;if(o.shouldSwap){if(f.status===286){at(l)}R(l,function(e){g=e.transformResponse(g,f,l)});if(d.type){er()}var s=e.swapOverride;if(O(f,/HX-Reswap:/i)){s=f.getResponseHeader("HX-Reswap")}var v=wr(l,s);if(v.hasOwnProperty("ignoreTitle")){p=v.ignoreTitle}c.classList.add(Q.config.swappingClass);var m=null;var x=null;var y=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 r;if(h){r=h}if(O(f,/HX-Reselect:/i)){r=f.getResponseHeader("HX-Reselect")}if(d.type){ce(re().body,"htmx:beforeHistoryUpdate",le({history:d},u));if(d.type==="push"){tr(d.path);ce(re().body,"htmx:pushedIntoHistory",{path:d.path})}else{rr(d.path);ce(re().body,"htmx:replacedInHistory",{path:d.path})}}var n=T(c);je(v.swapStyle,c,l,g,n,r);if(t.elt&&!se(t.elt)&&ee(t.elt,"id")){var i=document.getElementById(ee(t.elt,"id"));var a={preventScroll:v.focusScroll!==undefined?!v.focusScroll:!Q.config.defaultFocusScroll};if(i){if(t.start&&i.setSelectionRange){try{i.setSelectionRange(t.start,t.end)}catch(e){}}i.focus(a)}}c.classList.remove(Q.config.swappingClass);oe(n.elts,function(e){if(e.classList){e.classList.add(Q.config.settlingClass)}ce(e,"htmx:afterSwap",u)});if(O(f,/HX-Trigger-After-Swap:/i)){var o=l;if(!se(l)){o=re().body}_e(f,"HX-Trigger-After-Swap",o)}var s=function(){oe(n.tasks,function(e){e.call()});oe(n.elts,function(e){if(e.classList){e.classList.remove(Q.config.settlingClass)}ce(e,"htmx:afterSettle",u)});if(u.pathInfo.anchor){var e=re().getElementById(u.pathInfo.anchor);if(e){e.scrollIntoView({block:"start",behavior:"auto"})}}if(n.title&&!p){var t=C("title");if(t){t.innerHTML=n.title}else{window.document.title=n.title}}Cr(n.elts,v);if(O(f,/HX-Trigger-After-Settle:/i)){var r=l;if(!se(l)){r=re().body}_e(f,"HX-Trigger-After-Settle",r)}ie(m)};if(v.settleDelay>0){setTimeout(s,v.settleDelay)}else{s()}}catch(e){fe(l,"htmx:swapError",u);ie(x);throw e}};var b=Q.config.globalViewTransitions;if(v.hasOwnProperty("transition")){b=v.transition}if(b&&ce(l,"htmx:beforeTransition",u)&&typeof Promise!=="undefined"&&document.startViewTransition){var w=new Promise(function(e,t){m=e;x=t});var S=y;y=function(){document.startViewTransition(function(){S();return w})}}if(v.swapDelay>0){setTimeout(y,v.swapDelay)}else{y()}}if(a){fe(l,"htmx:responseError",le({error:"Response Status Error Code "+f.status+" from "+u.pathInfo.requestPath},u))}}var Xr={};function Dr(){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 Ur(e,t){if(t.init){t.init(r)}Xr[e]=le(Dr(),t)}function Fr(e){delete Xr[e]}function Br(e,r,n){if(e==undefined){return r}if(r==undefined){r=[]}if(n==undefined){n=[]}var t=te(e,"hx-ext");if(t){oe(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=Xr[e];if(t&&r.indexOf(t)<0){r.push(t)}}})}return Br(u(e),r,n)}var Vr=false;re().addEventListener("DOMContentLoaded",function(){Vr=true});function jr(e){if(Vr||re().readyState==="complete"){e()}else{re().addEventListener("DOMContentLoaded",e)}}function _r(){if(Q.config.includeIndicatorStyles!==false){re().head.insertAdjacentHTML("beforeend","")}}function zr(){var e=re().querySelector('meta[name="htmx-config"]');if(e){return E(e.content)}else{return null}}function $r(){var e=zr();if(e){Q.config=le(Q.config,e)}}jr(function(){$r();_r();var e=re().body;zt(e);var t=re().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){var t=e.target;var r=ae(t);if(r&&r.xhr){r.xhr.abort()}});const r=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){ar();oe(t,function(e){ce(e,"htmx:restored",{document:re(),triggerEvent:ce})})}else{if(r){r(e)}}};setTimeout(function(){ce(e,"htmx:load",{});e=null},0)});return Q}()}); \ No newline at end of file