diff --git a/sipa/static/js/htmx.js b/sipa/static/js/htmx.js
deleted file mode 100644
index 4c7206a8..00000000
--- a/sipa/static/js/htmx.js
+++ /dev/null
@@ -1,3701 +0,0 @@
-// UMD insanity
-// This code sets up support for (in order) AMD, ES6 modules, and globals.
-(function (root, factory) {
- //@ts-ignore
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- //@ts-ignore
- define([], factory);
- } else if (typeof module === 'object' && module.exports) {
- // Node. Does not work with strict CommonJS, but
- // only CommonJS-like environments that support module.exports,
- // like Node.
- module.exports = factory();
- } else {
- // Browser globals
- root.htmx = root.htmx || factory();
- }
-}(typeof self !== 'undefined' ? self : this, function () {
-return (function () {
- 'use strict';
-
- // Public API
- //** @type {import("./htmx").HtmxApi} */
- // TODO: list all methods in public API
- var htmx = {
- onLoad: onLoadHelper,
- process: processNode,
- on: addEventListenerImpl,
- off: removeEventListenerImpl,
- trigger : triggerEvent,
- ajax : ajaxHelper,
- find : find,
- findAll : findAll,
- closest : closest,
- values : function(elt, type){
- var inputValues = getInputValues(elt, type || "post");
- return inputValues.values;
- },
- remove : removeElement,
- addClass : addClassToElement,
- removeClass : removeClassFromElement,
- toggleClass : toggleClassOnElement,
- takeClass : takeClassForElement,
- defineExtension : defineExtension,
- removeExtension : removeExtension,
- logAll : logAll,
- logNone : logNone,
- 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
- },
- parseInterval:parseInterval,
- _:internalEval,
- createEventSource: function(url){
- return new EventSource(url, {withCredentials:true})
- },
- createWebSocket: function(url){
- var sock = new WebSocket(url, []);
- sock.binaryType = htmx.config.wsBinaryType;
- return sock;
- },
- version: "1.9.5"
- };
-
- /** @type {import("./htmx").HtmxInternalApi} */
- var internalAPI = {
- addTriggerHandler: addTriggerHandler,
- bodyContains: bodyContains,
- canAccessLocalStorage: canAccessLocalStorage,
- findThisElement: findThisElement,
- filterValues: filterValues,
- hasAttribute: hasAttribute,
- getAttributeValue: getAttributeValue,
- getClosestAttributeValue: getClosestAttributeValue,
- getClosestMatch: getClosestMatch,
- getExpressionVars: getExpressionVars,
- getHeaders: getHeaders,
- getInputValues: getInputValues,
- getInternalData: getInternalData,
- getSwapSpecification: getSwapSpecification,
- getTriggerSpecs: getTriggerSpecs,
- getTarget: getTarget,
- makeFragment: makeFragment,
- mergeObjects: mergeObjects,
- makeSettleInfo: makeSettleInfo,
- oobSwap: oobSwap,
- querySelectorExt: querySelectorExt,
- selectAndSwap: selectAndSwap,
- settleImmediately: settleImmediately,
- shouldCancel: shouldCancel,
- triggerEvent: triggerEvent,
- triggerErrorEvent: triggerErrorEvent,
- withExtensions: withExtensions,
- }
-
- var VERBS = ['get', 'post', 'put', 'delete', 'patch'];
- var VERB_SELECTOR = VERBS.map(function(verb){
- return "[hx-" + verb + "], [data-hx-" + verb + "]"
- }).join(", ");
-
- //====================================================================
- // Utilities
- //====================================================================
-
- function parseInterval(str) {
- if (str == undefined) {
- return undefined
- }
- if (str.slice(-2) == "ms") {
- return parseFloat(str.slice(0,-2)) || undefined
- }
- if (str.slice(-1) == "s") {
- return (parseFloat(str.slice(0,-1)) * 1000) || undefined
- }
- if (str.slice(-1) == "m") {
- return (parseFloat(str.slice(0,-1)) * 1000 * 60) || undefined
- }
- return parseFloat(str) || undefined
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {string} name
- * @returns {(string | null)}
- */
- function getRawAttribute(elt, name) {
- return elt.getAttribute && elt.getAttribute(name);
- }
-
- // resolve with both hx and data-hx prefixes
- function hasAttribute(elt, qualifiedName) {
- return elt.hasAttribute && (elt.hasAttribute(qualifiedName) ||
- elt.hasAttribute("data-" + qualifiedName));
- }
-
- /**
- *
- * @param {HTMLElement} elt
- * @param {string} qualifiedName
- * @returns {(string | null)}
- */
- function getAttributeValue(elt, qualifiedName) {
- return getRawAttribute(elt, qualifiedName) || getRawAttribute(elt, "data-" + qualifiedName);
- }
-
- /**
- * @param {HTMLElement} elt
- * @returns {HTMLElement | null}
- */
- function parentElt(elt) {
- return elt.parentElement;
- }
-
- /**
- * @returns {Document}
- */
- function getDocument() {
- return document;
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {(e:HTMLElement) => boolean} condition
- * @returns {HTMLElement | null}
- */
- function getClosestMatch(elt, condition) {
- while (elt && !condition(elt)) {
- elt = parentElt(elt);
- }
-
- return elt ? elt : null;
- }
-
- function getAttributeValueWithDisinheritance(initialElement, ancestor, attributeName){
- var attributeValue = getAttributeValue(ancestor, attributeName);
- var disinherit = getAttributeValue(ancestor, "hx-disinherit");
- if (initialElement !== ancestor && disinherit && (disinherit === "*" || disinherit.split(" ").indexOf(attributeName) >= 0)) {
- return "unset";
- } else {
- return attributeValue
- }
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {string} attributeName
- * @returns {string | null}
- */
- function getClosestAttributeValue(elt, attributeName) {
- var closestAttr = null;
- getClosestMatch(elt, function (e) {
- return closestAttr = getAttributeValueWithDisinheritance(elt, e, attributeName);
- });
- if (closestAttr !== "unset") {
- return closestAttr;
- }
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {string} selector
- * @returns {boolean}
- */
- function matches(elt, selector) {
- // @ts-ignore: non-standard properties for browser compatibility
- // noinspection JSUnresolvedVariable
- var matchesFunction = elt.matches || elt.matchesSelector || elt.msMatchesSelector || elt.mozMatchesSelector || elt.webkitMatchesSelector || elt.oMatchesSelector;
- return matchesFunction && matchesFunction.call(elt, selector);
- }
-
- /**
- * @param {string} str
- * @returns {string}
- */
- function getStartTag(str) {
- var tagMatcher = /<([a-z][^\/\0>\x20\t\r\n\f]*)/i
- var match = tagMatcher.exec( str );
- if (match) {
- return match[1].toLowerCase();
- } else {
- return "";
- }
- }
-
- /**
- *
- * @param {string} resp
- * @param {number} depth
- * @returns {Element}
- */
- function parseHTML(resp, depth) {
- var parser = new DOMParser();
- var responseDoc = parser.parseFromString(resp, "text/html");
-
- /** @type {Element} */
- var responseNode = responseDoc.body;
- while (depth > 0) {
- depth--;
- // @ts-ignore
- responseNode = responseNode.firstChild;
- }
- if (responseNode == null) {
- // @ts-ignore
- responseNode = getDocument().createDocumentFragment();
- }
- return responseNode;
- }
-
- function aFullPageResponse(resp) {
- return resp.match(/
" + resp + " ", 0);
- // @ts-ignore type mismatch between DocumentFragment and Element.
- // TODO: Are these close enough for htmx to use interchangeably?
- return documentFragment.querySelector('template').content;
- } else {
- var startTag = getStartTag(resp);
- switch (startTag) {
- case "thead":
- case "tbody":
- case "tfoot":
- case "colgroup":
- case "caption":
- return parseHTML("", 1);
- case "col":
- return parseHTML("", 2);
- case "tr":
- return parseHTML("", 2);
- case "td":
- case "th":
- return parseHTML("", 3);
- case "script":
- return parseHTML("" + resp + "
", 1);
- default:
- return parseHTML(resp, 0);
- }
- }
- }
-
- /**
- * @param {Function} func
- */
- function maybeCall(func){
- if(func) {
- func();
- }
- }
-
- /**
- * @param {any} o
- * @param {string} type
- * @returns
- */
- function isType(o, type) {
- return Object.prototype.toString.call(o) === "[object " + type + "]";
- }
-
- /**
- * @param {*} o
- * @returns {o is Function}
- */
- function isFunction(o) {
- return isType(o, "Function");
- }
-
- /**
- * @param {*} o
- * @returns {o is Object}
- */
- function isRawObject(o) {
- return isType(o, "Object");
- }
-
- /**
- * getInternalData retrieves "private" data stored by htmx within an element
- * @param {HTMLElement} elt
- * @returns {*}
- */
- function getInternalData(elt) {
- var dataProp = 'htmx-internal-data';
- var data = elt[dataProp];
- if (!data) {
- data = elt[dataProp] = {};
- }
- return data;
- }
-
- /**
- * toArray converts an ArrayLike object into a real array.
- * @param {ArrayLike} arr
- * @returns {any[]}
- */
- function toArray(arr) {
- var returnArr = [];
- if (arr) {
- for (var i = 0; i < arr.length; i++) {
- returnArr.push(arr[i]);
- }
- }
- return returnArr
- }
-
- function forEach(arr, func) {
- if (arr) {
- for (var i = 0; i < arr.length; i++) {
- func(arr[i]);
- }
- }
- }
-
- function isScrolledIntoView(el) {
- var rect = el.getBoundingClientRect();
- var elemTop = rect.top;
- var elemBottom = rect.bottom;
- return elemTop < window.innerHeight && elemBottom >= 0;
- }
-
- function bodyContains(elt) {
- // IE Fix
- if (elt.getRootNode && elt.getRootNode() instanceof window.ShadowRoot) {
- return getDocument().body.contains(elt.getRootNode().host);
- } else {
- return getDocument().body.contains(elt);
- }
- }
-
- function splitOnWhitespace(trigger) {
- return trigger.trim().split(/\s+/);
- }
-
- /**
- * mergeObjects takes all of the keys from
- * obj2 and duplicates them into obj1
- * @param {Object} obj1
- * @param {Object} obj2
- * @returns {Object}
- */
- function mergeObjects(obj1, obj2) {
- for (var key in obj2) {
- if (obj2.hasOwnProperty(key)) {
- obj1[key] = obj2[key];
- }
- }
- return obj1;
- }
-
- function parseJSON(jString) {
- try {
- return JSON.parse(jString);
- } catch(error) {
- logError(error);
- return null;
- }
- }
-
- function canAccessLocalStorage() {
- var test = 'htmx:localStorageTest';
- try {
- localStorage.setItem(test, test);
- localStorage.removeItem(test);
- return true;
- } catch(e) {
- return false;
- }
- }
-
- function normalizePath(path) {
- try {
- var url = new URL(path);
- if (url) {
- path = url.pathname + url.search;
- }
- // remove trailing slash, unless index page
- if (!path.match('^/$')) {
- path = path.replace(/\/+$/, '');
- }
- return path;
- } catch (e) {
- // be kind to IE11, which doesn't support URL()
- return path;
- }
- }
-
- //==========================================================================================
- // public API
- //==========================================================================================
-
- function internalEval(str){
- return maybeEval(getDocument().body, function () {
- return eval(str);
- });
- }
-
- function onLoadHelper(callback) {
- var value = htmx.on("htmx:load", function(evt) {
- callback(evt.detail.elt);
- });
- return value;
- }
-
- function logAll(){
- htmx.logger = function(elt, event, data) {
- if(console) {
- console.log(event, elt, data);
- }
- }
- }
-
- function logNone() {
- htmx.logger = null
- }
-
- function find(eltOrSelector, selector) {
- if (selector) {
- return eltOrSelector.querySelector(selector);
- } else {
- return find(getDocument(), eltOrSelector);
- }
- }
-
- function findAll(eltOrSelector, selector) {
- if (selector) {
- return eltOrSelector.querySelectorAll(selector);
- } else {
- return findAll(getDocument(), eltOrSelector);
- }
- }
-
- function removeElement(elt, delay) {
- elt = resolveTarget(elt);
- if (delay) {
- setTimeout(function(){
- removeElement(elt);
- elt = null;
- }, delay);
- } else {
- elt.parentElement.removeChild(elt);
- }
- }
-
- function addClassToElement(elt, clazz, delay) {
- elt = resolveTarget(elt);
- if (delay) {
- setTimeout(function(){
- addClassToElement(elt, clazz);
- elt = null;
- }, delay);
- } else {
- elt.classList && elt.classList.add(clazz);
- }
- }
-
- function removeClassFromElement(elt, clazz, delay) {
- elt = resolveTarget(elt);
- if (delay) {
- setTimeout(function(){
- removeClassFromElement(elt, clazz);
- elt = null;
- }, delay);
- } else {
- if (elt.classList) {
- elt.classList.remove(clazz);
- // if there are no classes left, remove the class attribute
- if (elt.classList.length === 0) {
- elt.removeAttribute("class");
- }
- }
- }
- }
-
- function toggleClassOnElement(elt, clazz) {
- elt = resolveTarget(elt);
- elt.classList.toggle(clazz);
- }
-
- function takeClassForElement(elt, clazz) {
- elt = resolveTarget(elt);
- forEach(elt.parentElement.children, function(child){
- removeClassFromElement(child, clazz);
- })
- addClassToElement(elt, clazz);
- }
-
- function closest(elt, selector) {
- elt = resolveTarget(elt);
- if (elt.closest) {
- return elt.closest(selector);
- } else {
- // TODO remove when IE goes away
- do{
- if (elt == null || matches(elt, selector)){
- return elt;
- }
- }
- while (elt = elt && parentElt(elt));
- return null;
- }
- }
-
- function normalizeSelector(selector) {
- var trimmedSelector = selector.trim();
- if (trimmedSelector.startsWith("<") && trimmedSelector.endsWith("/>")) {
- return trimmedSelector.substring(1, trimmedSelector.length - 2);
- } else {
- return trimmedSelector;
- }
- }
-
- function querySelectorAllExt(elt, selector) {
- if (selector.indexOf("closest ") === 0) {
- return [closest(elt, normalizeSelector(selector.substr(8)))];
- } else if (selector.indexOf("find ") === 0) {
- return [find(elt, normalizeSelector(selector.substr(5)))];
- } else if (selector.indexOf("next ") === 0) {
- return [scanForwardQuery(elt, normalizeSelector(selector.substr(5)))];
- } else if (selector.indexOf("previous ") === 0) {
- return [scanBackwardsQuery(elt, normalizeSelector(selector.substr(9)))];
- } else if (selector === 'document') {
- return [document];
- } else if (selector === 'window') {
- return [window];
- } else if (selector === 'body') {
- return [document.body];
- } else {
- return getDocument().querySelectorAll(normalizeSelector(selector));
- }
- }
-
- var scanForwardQuery = function(start, match) {
- var results = getDocument().querySelectorAll(match);
- for (var i = 0; i < results.length; i++) {
- var elt = results[i];
- if (elt.compareDocumentPosition(start) === Node.DOCUMENT_POSITION_PRECEDING) {
- return elt;
- }
- }
- }
-
- var scanBackwardsQuery = function(start, match) {
- var results = getDocument().querySelectorAll(match);
- for (var i = results.length - 1; i >= 0; i--) {
- var elt = results[i];
- if (elt.compareDocumentPosition(start) === Node.DOCUMENT_POSITION_FOLLOWING) {
- return elt;
- }
- }
- }
-
- function querySelectorExt(eltOrSelector, selector) {
- if (selector) {
- return querySelectorAllExt(eltOrSelector, selector)[0];
- } else {
- return querySelectorAllExt(getDocument().body, eltOrSelector)[0];
- }
- }
-
- function resolveTarget(arg2) {
- if (isType(arg2, 'String')) {
- return find(arg2);
- } else {
- return arg2;
- }
- }
-
- function processEventArgs(arg1, arg2, arg3) {
- if (isFunction(arg2)) {
- return {
- target: getDocument().body,
- event: arg1,
- listener: arg2
- }
- } else {
- return {
- target: resolveTarget(arg1),
- event: arg2,
- listener: arg3
- }
- }
-
- }
-
- function addEventListenerImpl(arg1, arg2, arg3) {
- ready(function(){
- var eventArgs = processEventArgs(arg1, arg2, arg3);
- eventArgs.target.addEventListener(eventArgs.event, eventArgs.listener);
- })
- var b = isFunction(arg2);
- return b ? arg2 : arg3;
- }
-
- function removeEventListenerImpl(arg1, arg2, arg3) {
- ready(function(){
- var eventArgs = processEventArgs(arg1, arg2, arg3);
- eventArgs.target.removeEventListener(eventArgs.event, eventArgs.listener);
- })
- return isFunction(arg2) ? arg2 : arg3;
- }
-
- //====================================================================
- // Node processing
- //====================================================================
-
- var DUMMY_ELT = getDocument().createElement("output"); // dummy element for bad selectors
- function findAttributeTargets(elt, attrName) {
- var attrTarget = getClosestAttributeValue(elt, attrName);
- if (attrTarget) {
- if (attrTarget === "this") {
- return [findThisElement(elt, attrName)];
- } else {
- var result = querySelectorAllExt(elt, attrTarget);
- if (result.length === 0) {
- logError('The selector "' + attrTarget + '" on ' + attrName + " returned no matches!");
- return [DUMMY_ELT]
- } else {
- return result;
- }
- }
- }
- }
-
- function findThisElement(elt, attribute){
- return getClosestMatch(elt, function (elt) {
- return getAttributeValue(elt, attribute) != null;
- })
- }
-
- function getTarget(elt) {
- var targetStr = getClosestAttributeValue(elt, "hx-target");
- if (targetStr) {
- if (targetStr === "this") {
- return findThisElement(elt,'hx-target');
- } else {
- return querySelectorExt(elt, targetStr)
- }
- } else {
- var data = getInternalData(elt);
- if (data.boosted) {
- return getDocument().body;
- } else {
- return elt;
- }
- }
- }
-
- function shouldSettleAttribute(name) {
- var attributesToSettle = htmx.config.attributesToSettle;
- for (var i = 0; i < attributesToSettle.length; i++) {
- if (name === attributesToSettle[i]) {
- return true;
- }
- }
- return false;
- }
-
- function cloneAttributes(mergeTo, mergeFrom) {
- forEach(mergeTo.attributes, function (attr) {
- if (!mergeFrom.hasAttribute(attr.name) && shouldSettleAttribute(attr.name)) {
- mergeTo.removeAttribute(attr.name)
- }
- });
- forEach(mergeFrom.attributes, function (attr) {
- if (shouldSettleAttribute(attr.name)) {
- mergeTo.setAttribute(attr.name, attr.value);
- }
- });
- }
-
- function isInlineSwap(swapStyle, target) {
- var extensions = getExtensions(target);
- for (var i = 0; i < extensions.length; i++) {
- var extension = extensions[i];
- try {
- if (extension.isInlineSwap(swapStyle)) {
- return true;
- }
- } catch(e) {
- logError(e);
- }
- }
- return swapStyle === "outerHTML";
- }
-
- /**
- *
- * @param {string} oobValue
- * @param {HTMLElement} oobElement
- * @param {*} settleInfo
- * @returns
- */
- function oobSwap(oobValue, oobElement, settleInfo) {
- var selector = "#" + getRawAttribute(oobElement, "id");
- var swapStyle = "outerHTML";
- if (oobValue === "true") {
- // do nothing
- } else if (oobValue.indexOf(":") > 0) {
- swapStyle = oobValue.substr(0, oobValue.indexOf(":"));
- selector = oobValue.substr(oobValue.indexOf(":") + 1, oobValue.length);
- } else {
- swapStyle = oobValue;
- }
-
- var targets = getDocument().querySelectorAll(selector);
- if (targets) {
- forEach(
- targets,
- function (target) {
- var fragment;
- var oobElementClone = oobElement.cloneNode(true);
- fragment = getDocument().createDocumentFragment();
- fragment.appendChild(oobElementClone);
- if (!isInlineSwap(swapStyle, target)) {
- fragment = oobElementClone; // if this is not an inline swap, we use the content of the node, not the node itself
- }
-
- var beforeSwapDetails = {shouldSwap: true, target: target, fragment:fragment };
- if (!triggerEvent(target, 'htmx:oobBeforeSwap', beforeSwapDetails)) return;
-
- target = beforeSwapDetails.target; // allow re-targeting
- if (beforeSwapDetails['shouldSwap']){
- swap(swapStyle, target, target, fragment, settleInfo);
- }
- forEach(settleInfo.elts, function (elt) {
- triggerEvent(elt, 'htmx:oobAfterSwap', beforeSwapDetails);
- });
- }
- );
- oobElement.parentNode.removeChild(oobElement);
- } else {
- oobElement.parentNode.removeChild(oobElement);
- triggerErrorEvent(getDocument().body, "htmx:oobErrorNoTarget", {content: oobElement});
- }
- return oobValue;
- }
-
- function handleOutOfBandSwaps(elt, fragment, settleInfo) {
- var oobSelects = getClosestAttributeValue(elt, "hx-select-oob");
- if (oobSelects) {
- var oobSelectValues = oobSelects.split(",");
- for (let i = 0; i < oobSelectValues.length; i++) {
- var oobSelectValue = oobSelectValues[i].split(":", 2);
- var id = oobSelectValue[0].trim();
- if (id.indexOf("#") === 0) {
- id = id.substring(1);
- }
- var oobValue = oobSelectValue[1] || "true";
- var oobElement = fragment.querySelector("#" + id);
- if (oobElement) {
- oobSwap(oobValue, oobElement, settleInfo);
- }
- }
- }
- forEach(findAll(fragment, '[hx-swap-oob], [data-hx-swap-oob]'), function (oobElement) {
- var oobValue = getAttributeValue(oobElement, "hx-swap-oob");
- if (oobValue != null) {
- oobSwap(oobValue, oobElement, settleInfo);
- }
- });
- }
-
- function handlePreservedElements(fragment) {
- forEach(findAll(fragment, '[hx-preserve], [data-hx-preserve]'), function (preservedElt) {
- var id = getAttributeValue(preservedElt, "id");
- var oldElt = getDocument().getElementById(id);
- if (oldElt != null) {
- preservedElt.parentNode.replaceChild(oldElt, preservedElt);
- }
- });
- }
-
- function handleAttributes(parentNode, fragment, settleInfo) {
- forEach(fragment.querySelectorAll("[id]"), function (newNode) {
- var id = getRawAttribute(newNode, "id")
- if (id && id.length > 0) {
- var normalizedId = id.replace("'", "\\'");
- var normalizedTag = newNode.tagName.replace(':', '\\:');
- var oldNode = parentNode.querySelector(normalizedTag + "[id='" + normalizedId + "']");
- if (oldNode && oldNode !== parentNode) {
- var newAttributes = newNode.cloneNode();
- cloneAttributes(newNode, oldNode);
- settleInfo.tasks.push(function () {
- cloneAttributes(newNode, newAttributes);
- });
- }
- }
- });
- }
-
- function makeAjaxLoadTask(child) {
- return function () {
- removeClassFromElement(child, htmx.config.addedClass);
- processNode(child);
- processScripts(child);
- processFocus(child)
- triggerEvent(child, 'htmx:load');
- };
- }
-
- function processFocus(child) {
- var autofocus = "[autofocus]";
- var autoFocusedElt = matches(child, autofocus) ? child : child.querySelector(autofocus)
- if (autoFocusedElt != null) {
- autoFocusedElt.focus();
- }
- }
-
- function insertNodesBefore(parentNode, insertBefore, fragment, settleInfo) {
- handleAttributes(parentNode, fragment, settleInfo);
- while(fragment.childNodes.length > 0){
- var child = fragment.firstChild;
- addClassToElement(child, htmx.config.addedClass);
- parentNode.insertBefore(child, insertBefore);
- if (child.nodeType !== Node.TEXT_NODE && child.nodeType !== Node.COMMENT_NODE) {
- settleInfo.tasks.push(makeAjaxLoadTask(child));
- }
- }
- }
-
- // based on https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0,
- // derived from Java's string hashcode implementation
- function stringHash(string, hash) {
- var char = 0;
- while (char < string.length){
- hash = (hash << 5) - hash + string.charCodeAt(char++) | 0; // bitwise or ensures we have a 32-bit int
- }
- return hash;
- }
-
- function attributeHash(elt) {
- var hash = 0;
- // IE fix
- if (elt.attributes) {
- for (var i = 0; i < elt.attributes.length; i++) {
- var attribute = elt.attributes[i];
- if(attribute.value){ // only include attributes w/ actual values (empty is same as non-existent)
- hash = stringHash(attribute.name, hash);
- hash = stringHash(attribute.value, hash);
- }
- }
- }
- return hash;
- }
-
- function deInitOnHandlers(elt) {
- var internalData = getInternalData(elt);
- if (internalData.onHandlers) {
- for (let i = 0; i < internalData.onHandlers.length; i++) {
- const handlerInfo = internalData.onHandlers[i];
- elt.removeEventListener(handlerInfo.event, handlerInfo.listener);
- }
- delete internalData.onHandlers
- }
- }
-
- function deInitNode(element) {
- var internalData = getInternalData(element);
- if (internalData.timeout) {
- clearTimeout(internalData.timeout);
- }
- if (internalData.webSocket) {
- internalData.webSocket.close();
- }
- if (internalData.sseEventSource) {
- internalData.sseEventSource.close();
- }
- if (internalData.listenerInfos) {
- forEach(internalData.listenerInfos, function (info) {
- if (info.on) {
- info.on.removeEventListener(info.trigger, info.listener);
- }
- });
- }
- if (internalData.initHash) {
- internalData.initHash = null
- }
- deInitOnHandlers(element);
- }
-
- function cleanUpElement(element) {
- triggerEvent(element, "htmx:beforeCleanupElement")
- deInitNode(element);
- if (element.children) { // IE
- forEach(element.children, function(child) { cleanUpElement(child) });
- }
- }
-
- function swapOuterHTML(target, fragment, settleInfo) {
- if (target.tagName === "BODY") {
- return swapInnerHTML(target, fragment, settleInfo);
- } else {
- // @type {HTMLElement}
- var newElt
- var eltBeforeNewContent = target.previousSibling;
- insertNodesBefore(parentElt(target), target, fragment, settleInfo);
- if (eltBeforeNewContent == null) {
- newElt = parentElt(target).firstChild;
- } else {
- newElt = eltBeforeNewContent.nextSibling;
- }
- getInternalData(target).replacedWith = newElt; // tuck away so we can fire events on it later
- settleInfo.elts = settleInfo.elts.filter(function(e) { return e != target });
- while(newElt && newElt !== target) {
- if (newElt.nodeType === Node.ELEMENT_NODE) {
- settleInfo.elts.push(newElt);
- }
- newElt = newElt.nextElementSibling;
- }
- cleanUpElement(target);
- parentElt(target).removeChild(target);
- }
- }
-
- function swapAfterBegin(target, fragment, settleInfo) {
- return insertNodesBefore(target, target.firstChild, fragment, settleInfo);
- }
-
- function swapBeforeBegin(target, fragment, settleInfo) {
- return insertNodesBefore(parentElt(target), target, fragment, settleInfo);
- }
-
- function swapBeforeEnd(target, fragment, settleInfo) {
- return insertNodesBefore(target, null, fragment, settleInfo);
- }
-
- function swapAfterEnd(target, fragment, settleInfo) {
- return insertNodesBefore(parentElt(target), target.nextSibling, fragment, settleInfo);
- }
- function swapDelete(target, fragment, settleInfo) {
- cleanUpElement(target);
- return parentElt(target).removeChild(target);
- }
-
- function swapInnerHTML(target, fragment, settleInfo) {
- var firstChild = target.firstChild;
- insertNodesBefore(target, firstChild, fragment, settleInfo);
- if (firstChild) {
- while (firstChild.nextSibling) {
- cleanUpElement(firstChild.nextSibling)
- target.removeChild(firstChild.nextSibling);
- }
- cleanUpElement(firstChild)
- target.removeChild(firstChild);
- }
- }
-
- function maybeSelectFromResponse(elt, fragment, selectOverride) {
- var selector = selectOverride || getClosestAttributeValue(elt, "hx-select");
- if (selector) {
- var newFragment = getDocument().createDocumentFragment();
- forEach(fragment.querySelectorAll(selector), function (node) {
- newFragment.appendChild(node);
- });
- fragment = newFragment;
- }
- return fragment;
- }
-
- function swap(swapStyle, elt, target, fragment, settleInfo) {
- switch (swapStyle) {
- case "none":
- return;
- case "outerHTML":
- swapOuterHTML(target, fragment, settleInfo);
- return;
- case "afterbegin":
- swapAfterBegin(target, fragment, settleInfo);
- return;
- case "beforebegin":
- swapBeforeBegin(target, fragment, settleInfo);
- return;
- case "beforeend":
- swapBeforeEnd(target, fragment, settleInfo);
- return;
- case "afterend":
- swapAfterEnd(target, fragment, settleInfo);
- return;
- case "delete":
- swapDelete(target, fragment, settleInfo);
- return;
- default:
- var extensions = getExtensions(elt);
- for (var i = 0; i < extensions.length; i++) {
- var ext = extensions[i];
- try {
- var newElements = ext.handleSwap(swapStyle, target, fragment, settleInfo);
- if (newElements) {
- if (typeof newElements.length !== 'undefined') {
- // if handleSwap returns an array (like) of elements, we handle them
- for (var j = 0; j < newElements.length; j++) {
- var child = newElements[j];
- if (child.nodeType !== Node.TEXT_NODE && child.nodeType !== Node.COMMENT_NODE) {
- settleInfo.tasks.push(makeAjaxLoadTask(child));
- }
- }
- }
- return;
- }
- } catch (e) {
- logError(e);
- }
- }
- if (swapStyle === "innerHTML") {
- swapInnerHTML(target, fragment, settleInfo);
- } else {
- swap(htmx.config.defaultSwapStyle, elt, target, fragment, settleInfo);
- }
- }
- }
-
- function findTitle(content) {
- if (content.indexOf(' -1) {
- var contentWithSvgsRemoved = content.replace(/]*>|>)([\s\S]*?)<\/svg>/gim, '');
- var result = contentWithSvgsRemoved.match(/]*>|>)([\s\S]*?)<\/title>/im);
-
- if (result) {
- return result[2];
- }
- }
- }
-
- function selectAndSwap(swapStyle, target, elt, responseText, settleInfo, selectOverride) {
- settleInfo.title = findTitle(responseText);
- var fragment = makeFragment(responseText);
- if (fragment) {
- handleOutOfBandSwaps(elt, fragment, settleInfo);
- fragment = maybeSelectFromResponse(elt, fragment, selectOverride);
- handlePreservedElements(fragment);
- return swap(swapStyle, elt, target, fragment, settleInfo);
- }
- }
-
- function handleTrigger(xhr, header, elt) {
- var triggerBody = xhr.getResponseHeader(header);
- if (triggerBody.indexOf("{") === 0) {
- var triggers = parseJSON(triggerBody);
- for (var eventName in triggers) {
- if (triggers.hasOwnProperty(eventName)) {
- var detail = triggers[eventName];
- if (!isRawObject(detail)) {
- detail = {"value": detail}
- }
- triggerEvent(elt, eventName, detail);
- }
- }
- } else {
- var eventNames = triggerBody.split(",")
- for (var i = 0; i < eventNames.length; i++) {
- triggerEvent(elt, eventNames[i].trim(), []);
- }
- }
- }
-
- var WHITESPACE = /\s/;
- var WHITESPACE_OR_COMMA = /[\s,]/;
- var SYMBOL_START = /[_$a-zA-Z]/;
- var SYMBOL_CONT = /[_$a-zA-Z0-9]/;
- var STRINGISH_START = ['"', "'", "/"];
- var NOT_WHITESPACE = /[^\s]/;
- function tokenizeString(str) {
- var tokens = [];
- var position = 0;
- while (position < str.length) {
- if(SYMBOL_START.exec(str.charAt(position))) {
- var startPosition = position;
- while (SYMBOL_CONT.exec(str.charAt(position + 1))) {
- position++;
- }
- tokens.push(str.substr(startPosition, position - startPosition + 1));
- } else if (STRINGISH_START.indexOf(str.charAt(position)) !== -1) {
- var startChar = str.charAt(position);
- var startPosition = position;
- position++;
- while (position < str.length && str.charAt(position) !== startChar ) {
- if (str.charAt(position) === "\\") {
- position++;
- }
- position++;
- }
- tokens.push(str.substr(startPosition, position - startPosition + 1));
- } else {
- var symbol = str.charAt(position);
- tokens.push(symbol);
- }
- position++;
- }
- return tokens;
- }
-
- function isPossibleRelativeReference(token, last, paramName) {
- return SYMBOL_START.exec(token.charAt(0)) &&
- token !== "true" &&
- token !== "false" &&
- token !== "this" &&
- token !== paramName &&
- last !== ".";
- }
-
- function maybeGenerateConditional(elt, tokens, paramName) {
- if (tokens[0] === '[') {
- tokens.shift();
- var bracketCount = 1;
- var conditionalSource = " return (function(" + paramName + "){ return (";
- var last = null;
- while (tokens.length > 0) {
- var token = tokens[0];
- if (token === "]") {
- bracketCount--;
- if (bracketCount === 0) {
- if (last === null) {
- conditionalSource = conditionalSource + "true";
- }
- tokens.shift();
- conditionalSource += ")})";
- try {
- var conditionFunction = maybeEval(elt,function () {
- return Function(conditionalSource)();
- },
- function(){return true})
- conditionFunction.source = conditionalSource;
- return conditionFunction;
- } catch (e) {
- triggerErrorEvent(getDocument().body, "htmx:syntax:error", {error:e, source:conditionalSource})
- return null;
- }
- }
- } else if (token === "[") {
- bracketCount++;
- }
- if (isPossibleRelativeReference(token, last, paramName)) {
- conditionalSource += "((" + paramName + "." + token + ") ? (" + paramName + "." + token + ") : (window." + token + "))";
- } else {
- conditionalSource = conditionalSource + token;
- }
- last = tokens.shift();
- }
- }
- }
-
- function consumeUntil(tokens, match) {
- var result = "";
- while (tokens.length > 0 && !tokens[0].match(match)) {
- result += tokens.shift();
- }
- return result;
- }
-
- var INPUT_SELECTOR = 'input, textarea, select';
-
- /**
- * @param {HTMLElement} elt
- * @returns {import("./htmx").HtmxTriggerSpecification[]}
- */
- function getTriggerSpecs(elt) {
- var explicitTrigger = getAttributeValue(elt, 'hx-trigger');
- var triggerSpecs = [];
- if (explicitTrigger) {
- var tokens = tokenizeString(explicitTrigger);
- do {
- consumeUntil(tokens, NOT_WHITESPACE);
- var initialLength = tokens.length;
- var trigger = consumeUntil(tokens, /[,\[\s]/);
- if (trigger !== "") {
- if (trigger === "every") {
- var every = {trigger: 'every'};
- consumeUntil(tokens, NOT_WHITESPACE);
- every.pollInterval = parseInterval(consumeUntil(tokens, /[,\[\s]/));
- consumeUntil(tokens, NOT_WHITESPACE);
- var eventFilter = maybeGenerateConditional(elt, tokens, "event");
- if (eventFilter) {
- every.eventFilter = eventFilter;
- }
- triggerSpecs.push(every);
- } else if (trigger.indexOf("sse:") === 0) {
- triggerSpecs.push({trigger: 'sse', sseEvent: trigger.substr(4)});
- } else {
- var triggerSpec = {trigger: trigger};
- var eventFilter = maybeGenerateConditional(elt, tokens, "event");
- if (eventFilter) {
- triggerSpec.eventFilter = eventFilter;
- }
- while (tokens.length > 0 && tokens[0] !== ",") {
- consumeUntil(tokens, NOT_WHITESPACE)
- var token = tokens.shift();
- if (token === "changed") {
- triggerSpec.changed = true;
- } else if (token === "once") {
- triggerSpec.once = true;
- } else if (token === "consume") {
- triggerSpec.consume = true;
- } else if (token === "delay" && tokens[0] === ":") {
- tokens.shift();
- triggerSpec.delay = parseInterval(consumeUntil(tokens, WHITESPACE_OR_COMMA));
- } else if (token === "from" && tokens[0] === ":") {
- tokens.shift();
- var from_arg = consumeUntil(tokens, WHITESPACE_OR_COMMA);
- if (from_arg === "closest" || from_arg === "find" || from_arg === "next" || from_arg === "previous") {
- tokens.shift();
- from_arg +=
- " " +
- consumeUntil(
- tokens,
- WHITESPACE_OR_COMMA
- );
- }
- triggerSpec.from = from_arg;
- } else if (token === "target" && tokens[0] === ":") {
- tokens.shift();
- triggerSpec.target = consumeUntil(tokens, WHITESPACE_OR_COMMA);
- } else if (token === "throttle" && tokens[0] === ":") {
- tokens.shift();
- triggerSpec.throttle = parseInterval(consumeUntil(tokens, WHITESPACE_OR_COMMA));
- } else if (token === "queue" && tokens[0] === ":") {
- tokens.shift();
- triggerSpec.queue = consumeUntil(tokens, WHITESPACE_OR_COMMA);
- } else if ((token === "root" || token === "threshold") && tokens[0] === ":") {
- tokens.shift();
- triggerSpec[token] = consumeUntil(tokens, WHITESPACE_OR_COMMA);
- } else {
- triggerErrorEvent(elt, "htmx:syntax:error", {token:tokens.shift()});
- }
- }
- triggerSpecs.push(triggerSpec);
- }
- }
- if (tokens.length === initialLength) {
- triggerErrorEvent(elt, "htmx:syntax:error", {token:tokens.shift()});
- }
- consumeUntil(tokens, NOT_WHITESPACE);
- } while (tokens[0] === "," && tokens.shift())
- }
-
- if (triggerSpecs.length > 0) {
- return triggerSpecs;
- } else if (matches(elt, 'form')) {
- return [{trigger: 'submit'}];
- } else if (matches(elt, 'input[type="button"], input[type="submit"]')){
- return [{trigger: 'click'}];
- } else if (matches(elt, INPUT_SELECTOR)) {
- return [{trigger: 'change'}];
- } else {
- return [{trigger: 'click'}];
- }
- }
-
- function cancelPolling(elt) {
- getInternalData(elt).cancelled = true;
- }
-
- function processPolling(elt, handler, spec) {
- var nodeData = getInternalData(elt);
- nodeData.timeout = setTimeout(function () {
- if (bodyContains(elt) && nodeData.cancelled !== true) {
- if (!maybeFilterEvent(spec, elt, makeEvent('hx:poll:trigger', {
- triggerSpec: spec,
- target: elt
- }))) {
- handler(elt);
- }
- processPolling(elt, handler, spec);
- }
- }, spec.pollInterval);
- }
-
- function isLocalLink(elt) {
- return location.hostname === elt.hostname &&
- getRawAttribute(elt,'href') &&
- getRawAttribute(elt,'href').indexOf("#") !== 0;
- }
-
- function boostElement(elt, nodeData, triggerSpecs) {
- if ((elt.tagName === "A" && isLocalLink(elt) && (elt.target === "" || elt.target === "_self")) || elt.tagName === "FORM") {
- nodeData.boosted = true;
- var verb, path;
- if (elt.tagName === "A") {
- verb = "get";
- path = elt.href; // DOM property gives the fully resolved href of a relative link
- } else {
- var rawAttribute = getRawAttribute(elt, "method");
- verb = rawAttribute ? rawAttribute.toLowerCase() : "get";
- if (verb === "get") {
- }
- path = getRawAttribute(elt, 'action');
- }
- triggerSpecs.forEach(function(triggerSpec) {
- addEventListener(elt, function(elt, evt) {
- if (closest(elt, htmx.config.disableSelector)) {
- cleanUpElement(elt)
- return
- }
- issueAjaxRequest(verb, path, elt, evt)
- }, nodeData, triggerSpec, true);
- });
- }
- }
-
- /**
- *
- * @param {Event} evt
- * @param {HTMLElement} elt
- * @returns
- */
- function shouldCancel(evt, elt) {
- if (evt.type === "submit" || evt.type === "click") {
- if (elt.tagName === "FORM") {
- return true;
- }
- if (matches(elt, 'input[type="submit"], button') && closest(elt, 'form') !== null) {
- return true;
- }
- if (elt.tagName === "A" && elt.href &&
- (elt.getAttribute('href') === '#' || elt.getAttribute('href').indexOf("#") !== 0)) {
- return true;
- }
- }
- return false;
- }
-
- function ignoreBoostedAnchorCtrlClick(elt, evt) {
- return getInternalData(elt).boosted && elt.tagName === "A" && evt.type === "click" && (evt.ctrlKey || evt.metaKey);
- }
-
- function maybeFilterEvent(triggerSpec, elt, evt) {
- var eventFilter = triggerSpec.eventFilter;
- if(eventFilter){
- try {
- return eventFilter.call(elt, evt) !== true;
- } catch(e) {
- triggerErrorEvent(getDocument().body, "htmx:eventFilter:error", {error: e, source:eventFilter.source});
- return true;
- }
- }
- return false;
- }
-
- function addEventListener(elt, handler, nodeData, triggerSpec, explicitCancel) {
- var elementData = getInternalData(elt);
- var eltsToListenOn;
- if (triggerSpec.from) {
- eltsToListenOn = querySelectorAllExt(elt, triggerSpec.from);
- } else {
- eltsToListenOn = [elt];
- }
- // store the initial values of the elements, so we can tell if they change
- if (triggerSpec.changed) {
- eltsToListenOn.forEach(function (eltToListenOn) {
- var eltToListenOnData = getInternalData(eltToListenOn);
- eltToListenOnData.lastValue = eltToListenOn.value;
- })
- }
- forEach(eltsToListenOn, function (eltToListenOn) {
- var eventListener = function (evt) {
- if (!bodyContains(elt)) {
- eltToListenOn.removeEventListener(triggerSpec.trigger, eventListener);
- return;
- }
- if (ignoreBoostedAnchorCtrlClick(elt, evt)) {
- return;
- }
- if (explicitCancel || shouldCancel(evt, elt)) {
- evt.preventDefault();
- }
- if (maybeFilterEvent(triggerSpec, elt, evt)) {
- return;
- }
- var eventData = getInternalData(evt);
- eventData.triggerSpec = triggerSpec;
- if (eventData.handledFor == null) {
- eventData.handledFor = [];
- }
- if (eventData.handledFor.indexOf(elt) < 0) {
- eventData.handledFor.push(elt);
- if (triggerSpec.consume) {
- evt.stopPropagation();
- }
- if (triggerSpec.target && evt.target) {
- if (!matches(evt.target, triggerSpec.target)) {
- return;
- }
- }
- if (triggerSpec.once) {
- if (elementData.triggeredOnce) {
- return;
- } else {
- elementData.triggeredOnce = true;
- }
- }
- if (triggerSpec.changed) {
- var eltToListenOnData = getInternalData(eltToListenOn)
- if (eltToListenOnData.lastValue === eltToListenOn.value) {
- return;
- }
- eltToListenOnData.lastValue = eltToListenOn.value
- }
- if (elementData.delayed) {
- clearTimeout(elementData.delayed);
- }
- if (elementData.throttle) {
- return;
- }
-
- if (triggerSpec.throttle) {
- if (!elementData.throttle) {
- handler(elt, evt);
- elementData.throttle = setTimeout(function () {
- elementData.throttle = null;
- }, triggerSpec.throttle);
- }
- } else if (triggerSpec.delay) {
- elementData.delayed = setTimeout(function() { handler(elt, evt) }, triggerSpec.delay);
- } else {
- triggerEvent(elt, 'htmx:trigger')
- handler(elt, evt);
- }
- }
- };
- if (nodeData.listenerInfos == null) {
- nodeData.listenerInfos = [];
- }
- nodeData.listenerInfos.push({
- trigger: triggerSpec.trigger,
- listener: eventListener,
- on: eltToListenOn
- })
- eltToListenOn.addEventListener(triggerSpec.trigger, eventListener);
- });
- }
-
- var windowIsScrolling = false // used by initScrollHandler
- var scrollHandler = null;
- function initScrollHandler() {
- if (!scrollHandler) {
- scrollHandler = function() {
- windowIsScrolling = true
- };
- window.addEventListener("scroll", scrollHandler)
- setInterval(function() {
- if (windowIsScrolling) {
- windowIsScrolling = false;
- forEach(getDocument().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"), function (elt) {
- maybeReveal(elt);
- })
- }
- }, 200);
- }
- }
-
- function maybeReveal(elt) {
- if (!hasAttribute(elt,'data-hx-revealed') && isScrolledIntoView(elt)) {
- elt.setAttribute('data-hx-revealed', 'true');
- var nodeData = getInternalData(elt);
- if (nodeData.initHash) {
- triggerEvent(elt, 'revealed');
- } else {
- // if the node isn't initialized, wait for it before triggering the request
- elt.addEventListener("htmx:afterProcessNode", function(evt) { triggerEvent(elt, 'revealed') }, {once: true});
- }
- }
- }
-
- //====================================================================
- // Web Sockets
- //====================================================================
-
- function processWebSocketInfo(elt, nodeData, info) {
- var values = splitOnWhitespace(info);
- for (var i = 0; i < values.length; i++) {
- var value = values[i].split(/:(.+)/);
- if (value[0] === "connect") {
- ensureWebSocket(elt, value[1], 0);
- }
- if (value[0] === "send") {
- processWebSocketSend(elt);
- }
- }
- }
-
- function ensureWebSocket(elt, wssSource, retryCount) {
- if (!bodyContains(elt)) {
- return; // stop ensuring websocket connection when socket bearing element ceases to exist
- }
-
- if (wssSource.indexOf("/") == 0) { // complete absolute paths only
- 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;
- }
- }
- var socket = htmx.createWebSocket(wssSource);
- socket.onerror = function (e) {
- triggerErrorEvent(elt, "htmx:wsError", {error:e, socket:socket});
- maybeCloseWebSocketSource(elt);
- };
-
- socket.onclose = function (e) {
- if ([1006, 1012, 1013].indexOf(e.code) >= 0) { // Abnormal Closure/Service Restart/Try Again Later
- var delay = getWebSocketReconnectDelay(retryCount);
- setTimeout(function() {
- ensureWebSocket(elt, wssSource, retryCount+1); // creates a websocket with a new timeout
- }, delay);
- }
- };
- socket.onopen = function (e) {
- retryCount = 0;
- }
-
- getInternalData(elt).webSocket = socket;
- socket.addEventListener('message', function (event) {
- if (maybeCloseWebSocketSource(elt)) {
- return;
- }
-
- var response = event.data;
- withExtensions(elt, function(extension){
- response = extension.transformResponse(response, null, elt);
- });
-
- var settleInfo = makeSettleInfo(elt);
- var fragment = makeFragment(response);
- var children = toArray(fragment.children);
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- oobSwap(getAttributeValue(child, "hx-swap-oob") || "true", child, settleInfo);
- }
-
- settleImmediately(settleInfo.tasks);
- });
- }
-
- function maybeCloseWebSocketSource(elt) {
- if (!bodyContains(elt)) {
- getInternalData(elt).webSocket.close();
- return true;
- }
- }
-
- function processWebSocketSend(elt) {
- var webSocketSourceElt = getClosestMatch(elt, function (parent) {
- return getInternalData(parent).webSocket != null;
- });
- if (webSocketSourceElt) {
- elt.addEventListener(getTriggerSpecs(elt)[0].trigger, function (evt) {
- var webSocket = getInternalData(webSocketSourceElt).webSocket;
- var headers = getHeaders(elt, webSocketSourceElt);
- var results = getInputValues(elt, 'post');
- var errors = results.errors;
- var rawParameters = results.values;
- var expressionVars = getExpressionVars(elt);
- var allParameters = mergeObjects(rawParameters, expressionVars);
- var filteredParameters = filterValues(allParameters, elt);
- filteredParameters['HEADERS'] = headers;
- if (errors && errors.length > 0) {
- triggerEvent(elt, 'htmx:validation:halted', errors);
- return;
- }
- webSocket.send(JSON.stringify(filteredParameters));
- if(shouldCancel(evt, elt)){
- evt.preventDefault();
- }
- });
- } else {
- triggerErrorEvent(elt, "htmx:noWebSocketSourceError");
- }
- }
-
- function getWebSocketReconnectDelay(retryCount) {
- var delay = htmx.config.wsReconnectDelay;
- if (typeof delay === 'function') {
- // @ts-ignore
- 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"');
- }
-
- //====================================================================
- // Server Sent Events
- //====================================================================
-
- function processSSEInfo(elt, nodeData, info) {
- var values = splitOnWhitespace(info);
- for (var i = 0; i < values.length; i++) {
- var value = values[i].split(/:(.+)/);
- if (value[0] === "connect") {
- processSSESource(elt, value[1]);
- }
-
- if ((value[0] === "swap")) {
- processSSESwap(elt, value[1])
- }
- }
- }
-
- function processSSESource(elt, sseSrc) {
- var source = htmx.createEventSource(sseSrc);
- source.onerror = function (e) {
- triggerErrorEvent(elt, "htmx:sseError", {error:e, source:source});
- maybeCloseSSESource(elt);
- };
- getInternalData(elt).sseEventSource = source;
- }
-
- function processSSESwap(elt, sseEventName) {
- var sseSourceElt = getClosestMatch(elt, hasEventSource);
- if (sseSourceElt) {
- var sseEventSource = getInternalData(sseSourceElt).sseEventSource;
- var sseListener = function (event) {
- if (maybeCloseSSESource(sseSourceElt)) {
- return;
- }
- if (!bodyContains(elt)) {
- sseEventSource.removeEventListener(sseEventName, sseListener);
- return;
- }
-
- ///////////////////////////
- // TODO: merge this code with AJAX and WebSockets code in the future.
-
- var response = event.data;
- withExtensions(elt, function(extension){
- response = extension.transformResponse(response, null, elt);
- });
-
- var swapSpec = getSwapSpecification(elt)
- var target = getTarget(elt)
- var settleInfo = makeSettleInfo(elt);
-
- selectAndSwap(swapSpec.swapStyle, target, elt, response, settleInfo)
- settleImmediately(settleInfo.tasks)
- triggerEvent(elt, "htmx:sseMessage", event)
- };
-
- getInternalData(elt).sseListener = sseListener;
- sseEventSource.addEventListener(sseEventName, sseListener);
- } else {
- triggerErrorEvent(elt, "htmx:noSSESourceError");
- }
- }
-
- function processSSETrigger(elt, handler, sseEventName) {
- var sseSourceElt = getClosestMatch(elt, hasEventSource);
- if (sseSourceElt) {
- var sseEventSource = getInternalData(sseSourceElt).sseEventSource;
- var sseListener = function () {
- if (!maybeCloseSSESource(sseSourceElt)) {
- if (bodyContains(elt)) {
- handler(elt);
- } else {
- sseEventSource.removeEventListener(sseEventName, sseListener);
- }
- }
- };
- getInternalData(elt).sseListener = sseListener;
- sseEventSource.addEventListener(sseEventName, sseListener);
- } else {
- triggerErrorEvent(elt, "htmx:noSSESourceError");
- }
- }
-
- function maybeCloseSSESource(elt) {
- if (!bodyContains(elt)) {
- getInternalData(elt).sseEventSource.close();
- return true;
- }
- }
-
- function hasEventSource(node) {
- return getInternalData(node).sseEventSource != null;
- }
-
- //====================================================================
-
- function loadImmediately(elt, handler, nodeData, delay) {
- var load = function(){
- if (!nodeData.loaded) {
- nodeData.loaded = true;
- handler(elt);
- }
- }
- if (delay) {
- setTimeout(load, delay);
- } else {
- load();
- }
- }
-
- function processVerbs(elt, nodeData, triggerSpecs) {
- var explicitAction = false;
- forEach(VERBS, function (verb) {
- if (hasAttribute(elt,'hx-' + verb)) {
- var path = getAttributeValue(elt, 'hx-' + verb);
- explicitAction = true;
- nodeData.path = path;
- nodeData.verb = verb;
- triggerSpecs.forEach(function(triggerSpec) {
- addTriggerHandler(elt, triggerSpec, nodeData, function (elt, evt) {
- if (closest(elt, htmx.config.disableSelector)) {
- cleanUpElement(elt)
- return
- }
- issueAjaxRequest(verb, path, elt, evt)
- })
- });
- }
- });
- return explicitAction;
- }
-
- function addTriggerHandler(elt, triggerSpec, nodeData, handler) {
- if (triggerSpec.sseEvent) {
- processSSETrigger(elt, handler, triggerSpec.sseEvent);
- } else if (triggerSpec.trigger === "revealed") {
- initScrollHandler();
- addEventListener(elt, handler, nodeData, triggerSpec);
- maybeReveal(elt);
- } else if (triggerSpec.trigger === "intersect") {
- var observerOptions = {};
- if (triggerSpec.root) {
- observerOptions.root = querySelectorExt(elt, triggerSpec.root)
- }
- if (triggerSpec.threshold) {
- observerOptions.threshold = parseFloat(triggerSpec.threshold);
- }
- var observer = new IntersectionObserver(function (entries) {
- for (var i = 0; i < entries.length; i++) {
- var entry = entries[i];
- if (entry.isIntersecting) {
- triggerEvent(elt, "intersect");
- break;
- }
- }
- }, observerOptions);
- observer.observe(elt);
- addEventListener(elt, handler, nodeData, triggerSpec);
- } else if (triggerSpec.trigger === "load") {
- if (!maybeFilterEvent(triggerSpec, elt, makeEvent("load", {elt: elt}))) {
- loadImmediately(elt, handler, nodeData, triggerSpec.delay);
- }
- } else if (triggerSpec.pollInterval) {
- nodeData.polling = true;
- processPolling(elt, handler, triggerSpec);
- } else {
- addEventListener(elt, handler, nodeData, triggerSpec);
- }
- }
-
- function evalScript(script) {
- if (htmx.config.allowScriptTags && (script.type === "text/javascript" || script.type === "module" || script.type === "") ) {
- var newScript = getDocument().createElement("script");
- forEach(script.attributes, function (attr) {
- newScript.setAttribute(attr.name, attr.value);
- });
- newScript.textContent = script.textContent;
- newScript.async = false;
- if (htmx.config.inlineScriptNonce) {
- newScript.nonce = htmx.config.inlineScriptNonce;
- }
- var parent = script.parentElement;
-
- try {
- parent.insertBefore(newScript, script);
- } catch (e) {
- logError(e);
- } finally {
- // remove old script element, but only if it is still in DOM
- if (script.parentElement) {
- script.parentElement.removeChild(script);
- }
- }
- }
- }
-
- function processScripts(elt) {
- if (matches(elt, "script")) {
- evalScript(elt);
- }
- forEach(findAll(elt, "script"), function (script) {
- evalScript(script);
- });
- }
-
- function hasChanceOfBeingBoosted() {
- return document.querySelector("[hx-boost], [data-hx-boost]");
- }
-
- function findHxOnWildcardElements(elt) {
- if (!document.evaluate) return []
-
- let node = null
- const elements = []
- const iter = document.evaluate('//*[@*[ starts-with(name(), "hx-on:") or starts-with(name(), "data-hx-on:") ]]', elt)
- while (node = iter.iterateNext()) elements.push(node)
- return elements
- }
-
- function findElementsToProcess(elt) {
- if (elt.querySelectorAll) {
- var boostedElts = hasChanceOfBeingBoosted() ? ", a" : "";
- var results = elt.querySelectorAll(VERB_SELECTOR + boostedElts + ", form, [type='submit'], [hx-sse], [data-hx-sse], [hx-ws]," +
- " [data-hx-ws], [hx-ext], [data-hx-ext], [hx-trigger], [data-hx-trigger], [hx-on], [data-hx-on]");
- return results;
- } else {
- return [];
- }
- }
-
- function initButtonTracking(elt) {
- // Handle submit buttons/inputs that have the form attribute set
- // see https://developer.mozilla.org/docs/Web/HTML/Element/button
- var form = resolveTarget("#" + getRawAttribute(elt, "form")) || closest(elt, "form")
- if (!form) {
- return
- }
-
- var maybeSetLastButtonClicked = function (evt) {
- var elt = closest(evt.target, "button, input[type='submit']");
- if (elt !== null) {
- var internalData = getInternalData(form);
- internalData.lastButtonClicked = elt;
- }
- };
-
- // need to handle both click and focus in:
- // focusin - in case someone tabs in to a button and hits the space bar
- // click - on OSX buttons do not focus on click see https://bugs.webkit.org/show_bug.cgi?id=13724
-
- elt.addEventListener('click', maybeSetLastButtonClicked)
- elt.addEventListener('focusin', maybeSetLastButtonClicked)
- elt.addEventListener('focusout', function(evt){
- var internalData = getInternalData(form);
- internalData.lastButtonClicked = null;
- })
- }
-
- function countCurlies(line) {
- var tokens = tokenizeString(line);
- var netCurlies = 0;
- for (let i = 0; i < tokens.length; i++) {
- const token = tokens[i];
- if (token === "{") {
- netCurlies++;
- } else if (token === "}") {
- netCurlies--;
- }
- }
- return netCurlies;
- }
-
- function addHxOnEventHandler(elt, eventName, code) {
- var nodeData = getInternalData(elt);
- nodeData.onHandlers = [];
- var func;
- var listener = function (e) {
- return maybeEval(elt, function() {
- if (!func) {
- func = new Function("event", code);
- }
- func.call(elt, e);
- });
- };
- elt.addEventListener(eventName, listener);
- nodeData.onHandlers.push({event:eventName, listener:listener});
- }
-
- function processHxOn(elt) {
- var hxOnValue = getAttributeValue(elt, 'hx-on');
- if (hxOnValue) {
- var handlers = {}
- var lines = hxOnValue.split("\n");
- var currentEvent = null;
- var curlyCount = 0;
- while (lines.length > 0) {
- var line = lines.shift();
- var match = line.match(/^\s*([a-zA-Z:\-]+:)(.*)/);
- if (curlyCount === 0 && match) {
- line.split(":")
- currentEvent = match[1].slice(0, -1); // strip last colon
- handlers[currentEvent] = match[2];
- } else {
- handlers[currentEvent] += line;
- }
- curlyCount += countCurlies(line);
- }
-
- for (var eventName in handlers) {
- addHxOnEventHandler(elt, eventName, handlers[eventName]);
- }
- }
- }
-
- function processHxOnWildcard(elt) {
- // wipe any previous on handlers so that this function takes precedence
- deInitOnHandlers(elt)
-
- for (var i = 0; i < elt.attributes.length; i++) {
- var name = elt.attributes[i].name
- var value = elt.attributes[i].value
- if (name.startsWith("hx-on:") || name.startsWith("data-hx-on:")) {
- let eventName = name.slice(name.indexOf(":") + 1)
- // if the eventName starts with a colon, prepend "htmx" for shorthand support
- if (eventName.startsWith(":")) eventName = "htmx" + eventName
-
- addHxOnEventHandler(elt, eventName, value)
- }
- }
- }
-
- function initNode(elt) {
- if (closest(elt, htmx.config.disableSelector)) {
- cleanUpElement(elt)
- return;
- }
- var nodeData = getInternalData(elt);
- if (nodeData.initHash !== attributeHash(elt)) {
- // clean up any previously processed info
- deInitNode(elt);
-
- nodeData.initHash = attributeHash(elt);
-
- processHxOn(elt);
-
- triggerEvent(elt, "htmx:beforeProcessNode")
-
- if (elt.value) {
- nodeData.lastValue = elt.value;
- }
-
- var triggerSpecs = getTriggerSpecs(elt);
- var hasExplicitHttpAction = processVerbs(elt, nodeData, triggerSpecs);
-
- if (!hasExplicitHttpAction) {
- if (getClosestAttributeValue(elt, "hx-boost") === "true") {
- boostElement(elt, nodeData, triggerSpecs);
- } else if (hasAttribute(elt, 'hx-trigger')) {
- triggerSpecs.forEach(function (triggerSpec) {
- // For "naked" triggers, don't do anything at all
- addTriggerHandler(elt, triggerSpec, nodeData, function () {
- })
- })
- }
- }
-
- // Handle submit buttons/inputs that have the form attribute set
- // see https://developer.mozilla.org/docs/Web/HTML/Element/button
- if (elt.tagName === "FORM" || (getRawAttribute(elt, "type") === "submit" && hasAttribute(elt, "form"))) {
- initButtonTracking(elt)
- }
-
- var sseInfo = getAttributeValue(elt, 'hx-sse');
- if (sseInfo) {
- processSSEInfo(elt, nodeData, sseInfo);
- }
-
- var wsInfo = getAttributeValue(elt, 'hx-ws');
- if (wsInfo) {
- processWebSocketInfo(elt, nodeData, wsInfo);
- }
- triggerEvent(elt, "htmx:afterProcessNode");
- }
- }
-
- function processNode(elt) {
- elt = resolveTarget(elt);
- if (closest(elt, htmx.config.disableSelector)) {
- cleanUpElement(elt)
- return;
- }
- initNode(elt);
- forEach(findElementsToProcess(elt), function(child) { initNode(child) });
- // Because it happens second, the new way of adding onHandlers superseeds the old one
- // i.e. if there are any hx-on:eventName attributes, the hx-on attribute will be ignored
- forEach(findHxOnWildcardElements(elt), processHxOnWildcard);
- }
-
- //====================================================================
- // Event/Log Support
- //====================================================================
-
- function kebabEventName(str) {
- return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
- }
-
- function makeEvent(eventName, detail) {
- var evt;
- if (window.CustomEvent && typeof window.CustomEvent === 'function') {
- evt = new CustomEvent(eventName, {bubbles: true, cancelable: true, detail: detail});
- } else {
- evt = getDocument().createEvent('CustomEvent');
- evt.initCustomEvent(eventName, true, true, detail);
- }
- return evt;
- }
-
- function triggerErrorEvent(elt, eventName, detail) {
- triggerEvent(elt, eventName, mergeObjects({error:eventName}, detail));
- }
-
- function ignoreEventForLogging(eventName) {
- return eventName === "htmx:afterProcessNode"
- }
-
- /**
- * `withExtensions` locates all active extensions for a provided element, then
- * executes the provided function using each of the active extensions. It should
- * be called internally at every extendable execution point in htmx.
- *
- * @param {HTMLElement} elt
- * @param {(extension:import("./htmx").HtmxExtension) => void} toDo
- * @returns void
- */
- function withExtensions(elt, toDo) {
- forEach(getExtensions(elt), function(extension){
- try {
- toDo(extension);
- } catch (e) {
- logError(e);
- }
- });
- }
-
- function logError(msg) {
- if(console.error) {
- console.error(msg);
- } else if (console.log) {
- console.log("ERROR: ", msg);
- }
- }
-
- function triggerEvent(elt, eventName, detail) {
- elt = resolveTarget(elt);
- if (detail == null) {
- detail = {};
- }
- detail["elt"] = elt;
- var event = makeEvent(eventName, detail);
- if (htmx.logger && !ignoreEventForLogging(eventName)) {
- htmx.logger(elt, eventName, detail);
- }
- if (detail.error) {
- logError(detail.error);
- triggerEvent(elt, "htmx:error", {errorInfo:detail})
- }
- var eventResult = elt.dispatchEvent(event);
- var kebabName = kebabEventName(eventName);
- if (eventResult && kebabName !== eventName) {
- var kebabedEvent = makeEvent(kebabName, event.detail);
- eventResult = eventResult && elt.dispatchEvent(kebabedEvent)
- }
- withExtensions(elt, function (extension) {
- eventResult = eventResult && (extension.onEvent(eventName, event) !== false)
- });
- return eventResult;
- }
-
- //====================================================================
- // History Support
- //====================================================================
- var currentPathForHistory = location.pathname+location.search;
-
- function getHistoryElement() {
- var historyElt = getDocument().querySelector('[hx-history-elt],[data-hx-history-elt]');
- return historyElt || getDocument().body;
- }
-
- function saveToHistoryCache(url, content, title, scroll) {
- if (!canAccessLocalStorage()) {
- return;
- }
-
- url = normalizePath(url);
-
- var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
- for (var i = 0; i < historyCache.length; i++) {
- if (historyCache[i].url === url) {
- historyCache.splice(i, 1);
- break;
- }
- }
- var newHistoryItem = {url:url, content: content, title:title, scroll:scroll};
- triggerEvent(getDocument().body, "htmx:historyItemCreated", {item:newHistoryItem, cache: historyCache})
- historyCache.push(newHistoryItem)
- while (historyCache.length > htmx.config.historyCacheSize) {
- historyCache.shift();
- }
- while(historyCache.length > 0){
- try {
- localStorage.setItem("htmx-history-cache", JSON.stringify(historyCache));
- break;
- } catch (e) {
- triggerErrorEvent(getDocument().body, "htmx:historyCacheError", {cause:e, cache: historyCache})
- historyCache.shift(); // shrink the cache and retry
- }
- }
- }
-
- function getCachedHistory(url) {
- if (!canAccessLocalStorage()) {
- return null;
- }
-
- url = normalizePath(url);
-
- var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
- for (var i = 0; i < historyCache.length; i++) {
- if (historyCache[i].url === url) {
- return historyCache[i];
- }
- }
- return null;
- }
-
- function cleanInnerHtmlForHistory(elt) {
- var className = htmx.config.requestClass;
- var clone = elt.cloneNode(true);
- forEach(findAll(clone, "." + className), function(child){
- removeClassFromElement(child, className);
- });
- return clone.innerHTML;
- }
-
- function saveCurrentPageToHistory() {
- var elt = getHistoryElement();
- var path = currentPathForHistory || location.pathname+location.search;
-
- // Allow history snapshot feature to be disabled where hx-history="false"
- // is present *anywhere* in the current document we're about to save,
- // so we can prevent privileged data entering the cache.
- // The page will still be reachable as a history entry, but htmx will fetch it
- // live from the server onpopstate rather than look in the localStorage cache
- var disableHistoryCache = getDocument().querySelector('[hx-history="false" i],[data-hx-history="false" i]');
- if (!disableHistoryCache) {
- triggerEvent(getDocument().body, "htmx:beforeHistorySave", {path: path, historyElt: elt});
- saveToHistoryCache(path, cleanInnerHtmlForHistory(elt), getDocument().title, window.scrollY);
- }
-
- if (htmx.config.historyEnabled) history.replaceState({htmx: true}, getDocument().title, window.location.href);
- }
-
- function pushUrlIntoHistory(path) {
- // remove the cache buster parameter, if any
- if (htmx.config.getCacheBusterParam) {
- path = path.replace(/org\.htmx\.cache-buster=[^&]*&?/, '')
- if (path.endsWith('&') || path.endsWith("?")) {
- path = path.slice(0, -1);
- }
- }
- if(htmx.config.historyEnabled) {
- history.pushState({htmx:true}, "", path);
- }
- currentPathForHistory = path;
- }
-
- function replaceUrlInHistory(path) {
- if(htmx.config.historyEnabled) history.replaceState({htmx:true}, "", path);
- currentPathForHistory = path;
- }
-
- function settleImmediately(tasks) {
- forEach(tasks, function (task) {
- task.call();
- });
- }
-
- function loadHistoryFromServer(path) {
- var request = new XMLHttpRequest();
- var details = {path: path, xhr:request};
- triggerEvent(getDocument().body, "htmx:historyCacheMiss", details);
- request.open('GET', path, true);
- request.setRequestHeader("HX-History-Restore-Request", "true");
- request.onload = function () {
- if (this.status >= 200 && this.status < 400) {
- triggerEvent(getDocument().body, "htmx:historyCacheMissLoad", details);
- var fragment = makeFragment(this.response);
- // @ts-ignore
- fragment = fragment.querySelector('[hx-history-elt],[data-hx-history-elt]') || fragment;
- var historyElement = getHistoryElement();
- var settleInfo = makeSettleInfo(historyElement);
- var title = findTitle(this.response);
- if (title) {
- var titleElt = find("title");
- if (titleElt) {
- titleElt.innerHTML = title;
- } else {
- window.document.title = title;
- }
- }
- // @ts-ignore
- swapInnerHTML(historyElement, fragment, settleInfo)
- settleImmediately(settleInfo.tasks);
- currentPathForHistory = path;
- triggerEvent(getDocument().body, "htmx:historyRestore", {path: path, cacheMiss:true, serverResponse:this.response});
- } else {
- triggerErrorEvent(getDocument().body, "htmx:historyCacheMissLoadError", details);
- }
- };
- request.send();
- }
-
- function restoreHistory(path) {
- saveCurrentPageToHistory();
- path = path || location.pathname+location.search;
- var cached = getCachedHistory(path);
- if (cached) {
- var fragment = makeFragment(cached.content);
- var historyElement = getHistoryElement();
- var settleInfo = makeSettleInfo(historyElement);
- swapInnerHTML(historyElement, fragment, settleInfo)
- settleImmediately(settleInfo.tasks);
- document.title = cached.title;
- setTimeout(function () {
- window.scrollTo(0, cached.scroll);
- }, 0); // next 'tick', so browser has time to render layout
- currentPathForHistory = path;
- triggerEvent(getDocument().body, "htmx:historyRestore", {path:path, item:cached});
- } else {
- if (htmx.config.refreshOnHistoryMiss) {
-
- // @ts-ignore: optional parameter in reload() function throws error
- window.location.reload(true);
- } else {
- loadHistoryFromServer(path);
- }
- }
- }
-
- function addRequestIndicatorClasses(elt) {
- var indicators = findAttributeTargets(elt, 'hx-indicator');
- if (indicators == null) {
- indicators = [elt];
- }
- forEach(indicators, function (ic) {
- var internalData = getInternalData(ic);
- internalData.requestCount = (internalData.requestCount || 0) + 1;
- ic.classList["add"].call(ic.classList, htmx.config.requestClass);
- });
- return indicators;
- }
-
- function removeRequestIndicatorClasses(indicators) {
- forEach(indicators, function (ic) {
- var internalData = getInternalData(ic);
- internalData.requestCount = (internalData.requestCount || 0) - 1;
- if (internalData.requestCount === 0) {
- ic.classList["remove"].call(ic.classList, htmx.config.requestClass);
- }
- });
- }
-
- //====================================================================
- // Input Value Processing
- //====================================================================
-
- function haveSeenNode(processed, elt) {
- for (var i = 0; i < processed.length; i++) {
- var node = processed[i];
- if (node.isSameNode(elt)) {
- return true;
- }
- }
- return false;
- }
-
- function shouldInclude(elt) {
- if(elt.name === "" || elt.name == null || elt.disabled) {
- return false;
- }
- // ignore "submitter" types (see jQuery src/serialize.js)
- if (elt.type === "button" || elt.type === "submit" || elt.tagName === "image" || elt.tagName === "reset" || elt.tagName === "file" ) {
- return false;
- }
- if (elt.type === "checkbox" || elt.type === "radio" ) {
- return elt.checked;
- }
- return true;
- }
-
- function addValueToValues(name, value, values) {
- // This is a little ugly because both the current value of the named value in the form
- // and the new value could be arrays, so we have to handle all four cases :/
- if (name != null && value != null) {
- var current = values[name];
- if (current === undefined) {
- values[name] = value;
- } else if (Array.isArray(current)) {
- if (Array.isArray(value)) {
- values[name] = current.concat(value);
- } else {
- current.push(value);
- }
- } else {
- if (Array.isArray(value)) {
- values[name] = [current].concat(value);
- } else {
- values[name] = [current, value];
- }
- }
- }
- }
-
- function processInputValue(processed, values, errors, elt, validate) {
- if (elt == null || haveSeenNode(processed, elt)) {
- return;
- } else {
- processed.push(elt);
- }
- if (shouldInclude(elt)) {
- var name = getRawAttribute(elt,"name");
- var value = elt.value;
- if (elt.multiple) {
- value = toArray(elt.querySelectorAll("option:checked")).map(function (e) { return e.value });
- }
- // include file inputs
- if (elt.files) {
- value = toArray(elt.files);
- }
- addValueToValues(name, value, values);
- if (validate) {
- validateElement(elt, errors);
- }
- }
- if (matches(elt, 'form')) {
- var inputs = elt.elements;
- forEach(inputs, function(input) {
- processInputValue(processed, values, errors, input, validate);
- });
- }
- }
-
- function validateElement(element, errors) {
- if (element.willValidate) {
- triggerEvent(element, "htmx:validation:validate")
- if (!element.checkValidity()) {
- errors.push({elt: element, message:element.validationMessage, validity:element.validity});
- triggerEvent(element, "htmx:validation:failed", {message:element.validationMessage, validity:element.validity})
- }
- }
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {string} verb
- */
- function getInputValues(elt, verb) {
- var processed = [];
- var values = {};
- var formValues = {};
- var errors = [];
- var internalData = getInternalData(elt);
-
- // only validate when form is directly submitted and novalidate or formnovalidate are not set
- // or if the element has an explicit hx-validate="true" on it
- var validate = (matches(elt, 'form') && elt.noValidate !== true) || getAttributeValue(elt, "hx-validate") === "true";
- if (internalData.lastButtonClicked) {
- validate = validate && internalData.lastButtonClicked.formNoValidate !== true;
- }
-
- // for a non-GET include the closest form
- if (verb !== 'get') {
- processInputValue(processed, formValues, errors, closest(elt, 'form'), validate);
- }
-
- // include the element itself
- processInputValue(processed, values, errors, elt, validate);
-
- // if a button or submit was clicked last, include its value
- if (internalData.lastButtonClicked || elt.tagName === "BUTTON" ||
- (elt.tagName === "INPUT" && getRawAttribute(elt, "type") === "submit")) {
- var button = internalData.lastButtonClicked || elt
- var name = getRawAttribute(button, "name")
- addValueToValues(name, button.value, formValues)
- }
-
- // include any explicit includes
- var includes = findAttributeTargets(elt, "hx-include");
- forEach(includes, function(node) {
- processInputValue(processed, values, errors, node, validate);
- // if a non-form is included, include any input values within it
- if (!matches(node, 'form')) {
- forEach(node.querySelectorAll(INPUT_SELECTOR), function (descendant) {
- processInputValue(processed, values, errors, descendant, validate);
- })
- }
- });
-
- // form values take precedence, overriding the regular values
- values = mergeObjects(values, formValues);
-
- return {errors:errors, values:values};
- }
-
- function appendParam(returnStr, name, realValue) {
- if (returnStr !== "") {
- returnStr += "&";
- }
- if (String(realValue) === "[object Object]") {
- realValue = JSON.stringify(realValue);
- }
- var s = encodeURIComponent(realValue);
- returnStr += encodeURIComponent(name) + "=" + s;
- return returnStr;
- }
-
- function urlEncode(values) {
- var returnStr = "";
- for (var name in values) {
- if (values.hasOwnProperty(name)) {
- var value = values[name];
- if (Array.isArray(value)) {
- forEach(value, function(v) {
- returnStr = appendParam(returnStr, name, v);
- });
- } else {
- returnStr = appendParam(returnStr, name, value);
- }
- }
- }
- return returnStr;
- }
-
- function makeFormData(values) {
- var formData = new FormData();
- for (var name in values) {
- if (values.hasOwnProperty(name)) {
- var value = values[name];
- if (Array.isArray(value)) {
- forEach(value, function(v) {
- formData.append(name, v);
- });
- } else {
- formData.append(name, value);
- }
- }
- }
- return formData;
- }
-
- //====================================================================
- // Ajax
- //====================================================================
-
- /**
- * @param {HTMLElement} elt
- * @param {HTMLElement} target
- * @param {string} prompt
- * @returns {Object} // TODO: Define/Improve HtmxHeaderSpecification
- */
- function getHeaders(elt, target, prompt) {
- var headers = {
- "HX-Request" : "true",
- "HX-Trigger" : getRawAttribute(elt, "id"),
- "HX-Trigger-Name" : getRawAttribute(elt, "name"),
- "HX-Target" : getAttributeValue(target, "id"),
- "HX-Current-URL" : getDocument().location.href,
- }
- getValuesForElement(elt, "hx-headers", false, headers)
- if (prompt !== undefined) {
- headers["HX-Prompt"] = prompt;
- }
- if (getInternalData(elt).boosted) {
- headers["HX-Boosted"] = "true";
- }
- return headers;
- }
-
- /**
- * filterValues takes an object containing form input values
- * and returns a new object that only contains keys that are
- * specified by the closest "hx-params" attribute
- * @param {Object} inputValues
- * @param {HTMLElement} elt
- * @returns {Object}
- */
- function filterValues(inputValues, elt) {
- var paramsValue = getClosestAttributeValue(elt, "hx-params");
- if (paramsValue) {
- if (paramsValue === "none") {
- return {};
- } else if (paramsValue === "*") {
- return inputValues;
- } else if(paramsValue.indexOf("not ") === 0) {
- forEach(paramsValue.substr(4).split(","), function (name) {
- name = name.trim();
- delete inputValues[name];
- });
- return inputValues;
- } else {
- var newValues = {}
- forEach(paramsValue.split(","), function (name) {
- name = name.trim();
- newValues[name] = inputValues[name];
- });
- return newValues;
- }
- } else {
- return inputValues;
- }
- }
-
- function isAnchorLink(elt) {
- return getRawAttribute(elt, 'href') && getRawAttribute(elt, 'href').indexOf("#") >=0
- }
-
- /**
- *
- * @param {HTMLElement} elt
- * @param {string} swapInfoOverride
- * @returns {import("./htmx").HtmxSwapSpecification}
- */
- function getSwapSpecification(elt, swapInfoOverride) {
- var swapInfo = swapInfoOverride ? swapInfoOverride : getClosestAttributeValue(elt, "hx-swap");
- var swapSpec = {
- "swapStyle" : getInternalData(elt).boosted ? 'innerHTML' : htmx.config.defaultSwapStyle,
- "swapDelay" : htmx.config.defaultSwapDelay,
- "settleDelay" : htmx.config.defaultSettleDelay
- }
- if (getInternalData(elt).boosted && !isAnchorLink(elt)) {
- swapSpec["show"] = "top"
- }
- if (swapInfo) {
- var split = splitOnWhitespace(swapInfo);
- if (split.length > 0) {
- swapSpec["swapStyle"] = split[0];
- for (var i = 1; i < split.length; i++) {
- var modifier = split[i];
- if (modifier.indexOf("swap:") === 0) {
- swapSpec["swapDelay"] = parseInterval(modifier.substr(5));
- }
- if (modifier.indexOf("settle:") === 0) {
- swapSpec["settleDelay"] = parseInterval(modifier.substr(7));
- }
- if (modifier.indexOf("transition:") === 0) {
- swapSpec["transition"] = modifier.substr(11) === "true";
- }
- if (modifier.indexOf("scroll:") === 0) {
- var scrollSpec = modifier.substr(7);
- var splitSpec = scrollSpec.split(":");
- var scrollVal = splitSpec.pop();
- var selectorVal = splitSpec.length > 0 ? splitSpec.join(":") : null;
- swapSpec["scroll"] = scrollVal;
- swapSpec["scrollTarget"] = selectorVal;
- }
- if (modifier.indexOf("show:") === 0) {
- var showSpec = modifier.substr(5);
- var splitSpec = showSpec.split(":");
- var showVal = splitSpec.pop();
- var selectorVal = splitSpec.length > 0 ? splitSpec.join(":") : null;
- swapSpec["show"] = showVal;
- swapSpec["showTarget"] = selectorVal;
- }
- if (modifier.indexOf("focus-scroll:") === 0) {
- var focusScrollVal = modifier.substr("focus-scroll:".length);
- swapSpec["focusScroll"] = focusScrollVal == "true";
- }
- }
- }
- }
- return swapSpec;
- }
-
- function usesFormData(elt) {
- return getClosestAttributeValue(elt, "hx-encoding") === "multipart/form-data" ||
- (matches(elt, "form") && getRawAttribute(elt, 'enctype') === "multipart/form-data");
- }
-
- function encodeParamsForBody(xhr, elt, filteredParameters) {
- var encodedParameters = null;
- withExtensions(elt, function (extension) {
- if (encodedParameters == null) {
- encodedParameters = extension.encodeParameters(xhr, filteredParameters, elt);
- }
- });
- if (encodedParameters != null) {
- return encodedParameters;
- } else {
- if (usesFormData(elt)) {
- return makeFormData(filteredParameters);
- } else {
- return urlEncode(filteredParameters);
- }
- }
- }
-
- /**
- *
- * @param {Element} target
- * @returns {import("./htmx").HtmxSettleInfo}
- */
- function makeSettleInfo(target) {
- return {tasks: [], elts: [target]};
- }
-
- function updateScrollState(content, swapSpec) {
- var first = content[0];
- var last = content[content.length - 1];
- if (swapSpec.scroll) {
- var target = null;
- if (swapSpec.scrollTarget) {
- target = querySelectorExt(first, swapSpec.scrollTarget);
- }
- if (swapSpec.scroll === "top" && (first || target)) {
- target = target || first;
- target.scrollTop = 0;
- }
- if (swapSpec.scroll === "bottom" && (last || target)) {
- target = target || last;
- target.scrollTop = target.scrollHeight;
- }
- }
- if (swapSpec.show) {
- var target = null;
- if (swapSpec.showTarget) {
- var targetStr = swapSpec.showTarget;
- if (swapSpec.showTarget === "window") {
- targetStr = "body";
- }
- target = querySelectorExt(first, targetStr);
- }
- if (swapSpec.show === "top" && (first || target)) {
- target = target || first;
- target.scrollIntoView({block:'start', behavior: htmx.config.scrollBehavior});
- }
- if (swapSpec.show === "bottom" && (last || target)) {
- target = target || last;
- target.scrollIntoView({block:'end', behavior: htmx.config.scrollBehavior});
- }
- }
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {string} attr
- * @param {boolean=} evalAsDefault
- * @param {Object=} values
- * @returns {Object}
- */
- function getValuesForElement(elt, attr, evalAsDefault, values) {
- if (values == null) {
- values = {};
- }
- if (elt == null) {
- return values;
- }
- var attributeValue = getAttributeValue(elt, attr);
- if (attributeValue) {
- var str = attributeValue.trim();
- var evaluateValue = evalAsDefault;
- if (str === "unset") {
- return null;
- }
- if (str.indexOf("javascript:") === 0) {
- str = str.substr(11);
- evaluateValue = true;
- } else if (str.indexOf("js:") === 0) {
- str = str.substr(3);
- evaluateValue = true;
- }
- if (str.indexOf('{') !== 0) {
- str = "{" + str + "}";
- }
- var varsValues;
- if (evaluateValue) {
- varsValues = maybeEval(elt,function () {return Function("return (" + str + ")")();}, {});
- } else {
- varsValues = parseJSON(str);
- }
- for (var key in varsValues) {
- if (varsValues.hasOwnProperty(key)) {
- if (values[key] == null) {
- values[key] = varsValues[key];
- }
- }
- }
- }
- return getValuesForElement(parentElt(elt), attr, evalAsDefault, values);
- }
-
- function maybeEval(elt, toEval, defaultVal) {
- if (htmx.config.allowEval) {
- return toEval();
- } else {
- triggerErrorEvent(elt, 'htmx:evalDisallowedError');
- return defaultVal;
- }
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {*} expressionVars
- * @returns
- */
- function getHXVarsForElement(elt, expressionVars) {
- return getValuesForElement(elt, "hx-vars", true, expressionVars);
- }
-
- /**
- * @param {HTMLElement} elt
- * @param {*} expressionVars
- * @returns
- */
- function getHXValsForElement(elt, expressionVars) {
- return getValuesForElement(elt, "hx-vals", false, expressionVars);
- }
-
- /**
- * @param {HTMLElement} elt
- * @returns {Object}
- */
- function getExpressionVars(elt) {
- return mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt));
- }
-
- function safelySetHeaderValue(xhr, header, headerValue) {
- if (headerValue !== null) {
- try {
- xhr.setRequestHeader(header, headerValue);
- } catch (e) {
- // On an exception, try to set the header URI encoded instead
- xhr.setRequestHeader(header, encodeURIComponent(headerValue));
- xhr.setRequestHeader(header + "-URI-AutoEncoded", "true");
- }
- }
- }
-
- function getPathFromResponse(xhr) {
- // NB: IE11 does not support this stuff
- if (xhr.responseURL && typeof(URL) !== "undefined") {
- try {
- var url = new URL(xhr.responseURL);
- return url.pathname + url.search;
- } catch (e) {
- triggerErrorEvent(getDocument().body, "htmx:badResponseUrl", {url: xhr.responseURL});
- }
- }
- }
-
- function hasHeader(xhr, regexp) {
- return xhr.getAllResponseHeaders().match(regexp);
- }
-
- function ajaxHelper(verb, path, context) {
- verb = verb.toLowerCase();
- if (context) {
- if (context instanceof Element || isType(context, 'String')) {
- return issueAjaxRequest(verb, path, null, null, {
- targetOverride: resolveTarget(context),
- returnPromise: true
- });
- } else {
- return issueAjaxRequest(verb, path, resolveTarget(context.source), context.event,
- {
- handler : context.handler,
- headers : context.headers,
- values : context.values,
- targetOverride: resolveTarget(context.target),
- swapOverride: context.swap,
- returnPromise: true
- });
- }
- } else {
- return issueAjaxRequest(verb, path, null, null, {
- returnPromise: true
- });
- }
- }
-
- function hierarchyForElt(elt) {
- var arr = [];
- while (elt) {
- arr.push(elt);
- elt = elt.parentElement;
- }
- return arr;
- }
-
- function verifyPath(elt, path, requestConfig) {
- var url = new URL(path, document.location.href);
- var origin = document.location.origin;
- var sameHost = origin === url.origin;
- if (htmx.config.selfRequestsOnly) {
- if (!sameHost) {
- return false;
- }
- }
- return triggerEvent(elt, "htmx:validateUrl", mergeObjects({url: url, sameHost: sameHost}, requestConfig));
- }
-
- function issueAjaxRequest(verb, path, elt, event, etc, confirmed) {
- var resolve = null;
- var reject = null;
- etc = etc != null ? etc : {};
- if(etc.returnPromise && typeof Promise !== "undefined"){
- var promise = new Promise(function (_resolve, _reject) {
- resolve = _resolve;
- reject = _reject;
- });
- }
- if(elt == null) {
- elt = getDocument().body;
- }
- var responseHandler = etc.handler || handleAjaxResponse;
-
- if (!bodyContains(elt)) {
- return; // do not issue requests for elements removed from the DOM
- }
- var target = etc.targetOverride || getTarget(elt);
- if (target == null || target == DUMMY_ELT) {
- triggerErrorEvent(elt, 'htmx:targetError', {target: getAttributeValue(elt, "hx-target")});
- return;
- }
-
- // allow event-based confirmation w/ a callback
- if (!confirmed) {
- var issueRequest = function() {
- return issueAjaxRequest(verb, path, elt, event, etc, true);
- }
- var confirmDetails = {target: target, elt: elt, path: path, verb: verb, triggeringEvent: event, etc: etc, issueRequest: issueRequest};
- if (triggerEvent(elt, 'htmx:confirm', confirmDetails) === false) {
- return;
- }
- }
-
- var syncElt = elt;
- var eltData = getInternalData(elt);
- var syncStrategy = getClosestAttributeValue(elt, "hx-sync");
- var queueStrategy = null;
- var abortable = false;
- if (syncStrategy) {
- var syncStrings = syncStrategy.split(":");
- var selector = syncStrings[0].trim();
- if (selector === "this") {
- syncElt = findThisElement(elt, 'hx-sync');
- } else {
- syncElt = querySelectorExt(elt, selector);
- }
- // default to the drop strategy
- syncStrategy = (syncStrings[1] || 'drop').trim();
- eltData = getInternalData(syncElt);
- if (syncStrategy === "drop" && eltData.xhr && eltData.abortable !== true) {
- return;
- } else if (syncStrategy === "abort") {
- if (eltData.xhr) {
- return;
- } else {
- abortable = true;
- }
- } else if (syncStrategy === "replace") {
- triggerEvent(syncElt, 'htmx:abort'); // abort the current request and continue
- } else if (syncStrategy.indexOf("queue") === 0) {
- var queueStrArray = syncStrategy.split(" ");
- queueStrategy = (queueStrArray[1] || "last").trim();
- }
- }
-
- if (eltData.xhr) {
- if (eltData.abortable) {
- triggerEvent(syncElt, 'htmx:abort'); // abort the current request and continue
- } else {
- if(queueStrategy == null){
- if (event) {
- var eventData = getInternalData(event);
- if (eventData && eventData.triggerSpec && eventData.triggerSpec.queue) {
- queueStrategy = eventData.triggerSpec.queue;
- }
- }
- if (queueStrategy == null) {
- queueStrategy = "last";
- }
- }
- if (eltData.queuedRequests == null) {
- eltData.queuedRequests = [];
- }
- if (queueStrategy === "first" && eltData.queuedRequests.length === 0) {
- eltData.queuedRequests.push(function () {
- issueAjaxRequest(verb, path, elt, event, etc)
- });
- } else if (queueStrategy === "all") {
- eltData.queuedRequests.push(function () {
- issueAjaxRequest(verb, path, elt, event, etc)
- });
- } else if (queueStrategy === "last") {
- eltData.queuedRequests = []; // dump existing queue
- eltData.queuedRequests.push(function () {
- issueAjaxRequest(verb, path, elt, event, etc)
- });
- }
- return;
- }
- }
-
- var xhr = new XMLHttpRequest();
- eltData.xhr = xhr;
- eltData.abortable = abortable;
- var endRequestLock = function(){
- eltData.xhr = null;
- eltData.abortable = false;
- if (eltData.queuedRequests != null &&
- eltData.queuedRequests.length > 0) {
- var queuedRequest = eltData.queuedRequests.shift();
- queuedRequest();
- }
- }
- var promptQuestion = getClosestAttributeValue(elt, "hx-prompt");
- if (promptQuestion) {
- var promptResponse = prompt(promptQuestion);
- // prompt returns null if cancelled and empty string if accepted with no entry
- if (promptResponse === null ||
- !triggerEvent(elt, 'htmx:prompt', {prompt: promptResponse, target:target})) {
- maybeCall(resolve);
- endRequestLock();
- return promise;
- }
- }
-
- var confirmQuestion = getClosestAttributeValue(elt, "hx-confirm");
- if (confirmQuestion) {
- if(!confirm(confirmQuestion)) {
- maybeCall(resolve);
- endRequestLock()
- return promise;
- }
- }
-
-
- var headers = getHeaders(elt, target, promptResponse);
- if (etc.headers) {
- headers = mergeObjects(headers, etc.headers);
- }
- var results = getInputValues(elt, verb);
- var errors = results.errors;
- var rawParameters = results.values;
- if (etc.values) {
- rawParameters = mergeObjects(rawParameters, etc.values);
- }
- var expressionVars = getExpressionVars(elt);
- var allParameters = mergeObjects(rawParameters, expressionVars);
- var filteredParameters = filterValues(allParameters, elt);
-
- if (verb !== 'get' && !usesFormData(elt)) {
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
- }
-
- if (htmx.config.getCacheBusterParam && verb === 'get') {
- filteredParameters['org.htmx.cache-buster'] = getRawAttribute(target, "id") || "true";
- }
-
- // behavior of anchors w/ empty href is to use the current URL
- if (path == null || path === "") {
- path = getDocument().location.href;
- }
-
-
- var requestAttrValues = getValuesForElement(elt, 'hx-request');
-
- var eltIsBoosted = getInternalData(elt).boosted;
-
- var useUrlParams = htmx.config.methodsThatUseUrlParams.indexOf(verb) >= 0
-
- var requestConfig = {
- boosted: eltIsBoosted,
- useUrlParams: useUrlParams,
- parameters: filteredParameters,
- unfilteredParameters: allParameters,
- headers:headers,
- target:target,
- verb:verb,
- errors:errors,
- withCredentials: etc.credentials || requestAttrValues.credentials || htmx.config.withCredentials,
- timeout: etc.timeout || requestAttrValues.timeout || htmx.config.timeout,
- path:path,
- triggeringEvent:event
- };
-
- if(!triggerEvent(elt, 'htmx:configRequest', requestConfig)){
- maybeCall(resolve);
- endRequestLock();
- return promise;
- }
-
- // copy out in case the object was overwritten
- path = requestConfig.path;
- verb = requestConfig.verb;
- headers = requestConfig.headers;
- filteredParameters = requestConfig.parameters;
- errors = requestConfig.errors;
- useUrlParams = requestConfig.useUrlParams;
-
- if(errors && errors.length > 0){
- triggerEvent(elt, 'htmx:validation:halted', requestConfig)
- maybeCall(resolve);
- endRequestLock();
- return promise;
- }
-
- var splitPath = path.split("#");
- var pathNoAnchor = splitPath[0];
- var anchor = splitPath[1];
-
- var finalPath = path
- if (useUrlParams) {
- finalPath = pathNoAnchor;
- var values = Object.keys(filteredParameters).length !== 0;
- if (values) {
- if (finalPath.indexOf("?") < 0) {
- finalPath += "?";
- } else {
- finalPath += "&";
- }
- finalPath += urlEncode(filteredParameters);
- if (anchor) {
- finalPath += "#" + anchor;
- }
- }
- }
-
- if (!verifyPath(elt, finalPath, requestConfig)) {
- triggerErrorEvent(elt, 'htmx:invalidPath', requestConfig)
- return;
- };
-
- xhr.open(verb.toUpperCase(), finalPath, true);
- xhr.overrideMimeType("text/html");
- xhr.withCredentials = requestConfig.withCredentials;
- xhr.timeout = requestConfig.timeout;
-
- // request headers
- if (requestAttrValues.noHeaders) {
- // ignore all headers
- } else {
- for (var header in headers) {
- if (headers.hasOwnProperty(header)) {
- var headerValue = headers[header];
- safelySetHeaderValue(xhr, header, headerValue);
- }
- }
- }
-
- var responseInfo = {
- xhr: xhr, target: target, requestConfig: requestConfig, etc: etc, boosted: eltIsBoosted,
- pathInfo: {
- requestPath: path,
- finalRequestPath: finalPath,
- anchor: anchor
- }
- };
-
- xhr.onload = function () {
- try {
- var hierarchy = hierarchyForElt(elt);
- responseInfo.pathInfo.responsePath = getPathFromResponse(xhr);
- responseHandler(elt, responseInfo);
- removeRequestIndicatorClasses(indicators);
- triggerEvent(elt, 'htmx:afterRequest', responseInfo);
- triggerEvent(elt, 'htmx:afterOnLoad', responseInfo);
- // if the body no longer contains the element, trigger the event on the closest parent
- // remaining in the DOM
- if (!bodyContains(elt)) {
- var secondaryTriggerElt = null;
- while (hierarchy.length > 0 && secondaryTriggerElt == null) {
- var parentEltInHierarchy = hierarchy.shift();
- if (bodyContains(parentEltInHierarchy)) {
- secondaryTriggerElt = parentEltInHierarchy;
- }
- }
- if (secondaryTriggerElt) {
- triggerEvent(secondaryTriggerElt, 'htmx:afterRequest', responseInfo);
- triggerEvent(secondaryTriggerElt, 'htmx:afterOnLoad', responseInfo);
- }
- }
- maybeCall(resolve);
- endRequestLock();
- } catch (e) {
- triggerErrorEvent(elt, 'htmx:onLoadError', mergeObjects({error:e}, responseInfo));
- throw e;
- }
- }
- xhr.onerror = function () {
- removeRequestIndicatorClasses(indicators);
- triggerErrorEvent(elt, 'htmx:afterRequest', responseInfo);
- triggerErrorEvent(elt, 'htmx:sendError', responseInfo);
- maybeCall(reject);
- endRequestLock();
- }
- xhr.onabort = function() {
- removeRequestIndicatorClasses(indicators);
- triggerErrorEvent(elt, 'htmx:afterRequest', responseInfo);
- triggerErrorEvent(elt, 'htmx:sendAbort', responseInfo);
- maybeCall(reject);
- endRequestLock();
- }
- xhr.ontimeout = function() {
- removeRequestIndicatorClasses(indicators);
- triggerErrorEvent(elt, 'htmx:afterRequest', responseInfo);
- triggerErrorEvent(elt, 'htmx:timeout', responseInfo);
- maybeCall(reject);
- endRequestLock();
- }
- if(!triggerEvent(elt, 'htmx:beforeRequest', responseInfo)){
- maybeCall(resolve);
- endRequestLock()
- return promise
- }
- var indicators = addRequestIndicatorClasses(elt);
-
- forEach(['loadstart', 'loadend', 'progress', 'abort'], function(eventName) {
- forEach([xhr, xhr.upload], function (target) {
- target.addEventListener(eventName, function(event){
- triggerEvent(elt, "htmx:xhr:" + eventName, {
- lengthComputable:event.lengthComputable,
- loaded:event.loaded,
- total:event.total
- });
- })
- });
- });
- triggerEvent(elt, 'htmx:beforeSend', responseInfo);
- var params = useUrlParams ? null : encodeParamsForBody(xhr, elt, filteredParameters)
- xhr.send(params);
- return promise;
- }
-
- function determineHistoryUpdates(elt, responseInfo) {
-
- var xhr = responseInfo.xhr;
-
- //===========================================
- // First consult response headers
- //===========================================
- var pathFromHeaders = null;
- var typeFromHeaders = null;
- if (hasHeader(xhr,/HX-Push:/i)) {
- pathFromHeaders = xhr.getResponseHeader("HX-Push");
- typeFromHeaders = "push";
- } else if (hasHeader(xhr,/HX-Push-Url:/i)) {
- pathFromHeaders = xhr.getResponseHeader("HX-Push-Url");
- typeFromHeaders = "push";
- } else if (hasHeader(xhr,/HX-Replace-Url:/i)) {
- pathFromHeaders = xhr.getResponseHeader("HX-Replace-Url");
- typeFromHeaders = "replace";
- }
-
- // if there was a response header, that has priority
- if (pathFromHeaders) {
- if (pathFromHeaders === "false") {
- return {}
- } else {
- return {
- type: typeFromHeaders,
- path : pathFromHeaders
- }
- }
- }
-
- //===========================================
- // Next resolve via DOM values
- //===========================================
- var requestPath = responseInfo.pathInfo.finalRequestPath;
- var responsePath = responseInfo.pathInfo.responsePath;
-
- var pushUrl = getClosestAttributeValue(elt, "hx-push-url");
- var replaceUrl = getClosestAttributeValue(elt, "hx-replace-url");
- var elementIsBoosted = getInternalData(elt).boosted;
-
- var saveType = null;
- var path = null;
-
- if (pushUrl) {
- saveType = "push";
- path = pushUrl;
- } else if (replaceUrl) {
- saveType = "replace";
- path = replaceUrl;
- } else if (elementIsBoosted) {
- saveType = "push";
- path = responsePath || requestPath; // if there is no response path, go with the original request path
- }
-
- if (path) {
- // false indicates no push, return empty object
- if (path === "false") {
- return {};
- }
-
- // true indicates we want to follow wherever the server ended up sending us
- if (path === "true") {
- path = responsePath || requestPath; // if there is no response path, go with the original request path
- }
-
- // restore any anchor associated with the request
- if (responseInfo.pathInfo.anchor &&
- path.indexOf("#") === -1) {
- path = path + "#" + responseInfo.pathInfo.anchor;
- }
-
- return {
- type:saveType,
- path: path
- }
- } else {
- return {};
- }
- }
-
- function handleAjaxResponse(elt, responseInfo) {
- var xhr = responseInfo.xhr;
- var target = responseInfo.target;
- var etc = responseInfo.etc;
-
- if (!triggerEvent(elt, 'htmx:beforeOnLoad', responseInfo)) return;
-
- if (hasHeader(xhr, /HX-Trigger:/i)) {
- handleTrigger(xhr, "HX-Trigger", elt);
- }
-
- if (hasHeader(xhr, /HX-Location:/i)) {
- saveCurrentPageToHistory();
- var redirectPath = xhr.getResponseHeader("HX-Location");
- var swapSpec;
- if (redirectPath.indexOf("{") === 0) {
- swapSpec = parseJSON(redirectPath);
- // what's the best way to throw an error if the user didn't include this
- redirectPath = swapSpec['path'];
- delete swapSpec['path'];
- }
- ajaxHelper('GET', redirectPath, swapSpec).then(function(){
- pushUrlIntoHistory(redirectPath);
- });
- return;
- }
-
- if (hasHeader(xhr, /HX-Redirect:/i)) {
- location.href = xhr.getResponseHeader("HX-Redirect");
- return;
- }
-
- if (hasHeader(xhr,/HX-Refresh:/i)) {
- if ("true" === xhr.getResponseHeader("HX-Refresh")) {
- location.reload();
- return;
- }
- }
-
- if (hasHeader(xhr,/HX-Retarget:/i)) {
- responseInfo.target = getDocument().querySelector(xhr.getResponseHeader("HX-Retarget"));
- }
-
- var historyUpdate = determineHistoryUpdates(elt, responseInfo);
-
- // by default htmx only swaps on 200 return codes and does not swap
- // on 204 'No Content'
- // this can be ovverriden by responding to the htmx:beforeSwap event and
- // overriding the detail.shouldSwap property
- var shouldSwap = xhr.status >= 200 && xhr.status < 400 && xhr.status !== 204;
- var serverResponse = xhr.response;
- var isError = xhr.status >= 400;
- var beforeSwapDetails = mergeObjects({shouldSwap: shouldSwap, serverResponse:serverResponse, isError:isError}, responseInfo);
- if (!triggerEvent(target, 'htmx:beforeSwap', beforeSwapDetails)) return;
-
- target = beforeSwapDetails.target; // allow re-targeting
- serverResponse = beforeSwapDetails.serverResponse; // allow updating content
- isError = beforeSwapDetails.isError; // allow updating error
-
- responseInfo.target = target; // Make updated target available to response events
- responseInfo.failed = isError; // Make failed property available to response events
- responseInfo.successful = !isError; // Make successful property available to response events
-
- if (beforeSwapDetails.shouldSwap) {
- if (xhr.status === 286) {
- cancelPolling(elt);
- }
-
- withExtensions(elt, function (extension) {
- serverResponse = extension.transformResponse(serverResponse, xhr, elt);
- });
-
- // Save current page if there will be a history update
- if (historyUpdate.type) {
- saveCurrentPageToHistory();
- }
-
- var swapOverride = etc.swapOverride;
- if (hasHeader(xhr,/HX-Reswap:/i)) {
- swapOverride = xhr.getResponseHeader("HX-Reswap");
- }
- var swapSpec = getSwapSpecification(elt, swapOverride);
-
- target.classList.add(htmx.config.swappingClass);
-
- // optional transition API promise callbacks
- var settleResolve = null;
- var settleReject = null;
-
- var doSwap = function () {
- try {
- var activeElt = document.activeElement;
- var selectionInfo = {};
- try {
- selectionInfo = {
- elt: activeElt,
- // @ts-ignore
- start: activeElt ? activeElt.selectionStart : null,
- // @ts-ignore
- end: activeElt ? activeElt.selectionEnd : null
- };
- } catch (e) {
- // safari issue - see https://github.com/microsoft/playwright/issues/5894
- }
-
- var selectOverride;
- if (hasHeader(xhr, /HX-Reselect:/i)) {
- selectOverride = xhr.getResponseHeader("HX-Reselect");
- }
-
- var settleInfo = makeSettleInfo(target);
- selectAndSwap(swapSpec.swapStyle, target, elt, serverResponse, settleInfo, selectOverride);
-
- if (selectionInfo.elt &&
- !bodyContains(selectionInfo.elt) &&
- getRawAttribute(selectionInfo.elt, "id")) {
- var newActiveElt = document.getElementById(getRawAttribute(selectionInfo.elt, "id"));
- var focusOptions = { preventScroll: swapSpec.focusScroll !== undefined ? !swapSpec.focusScroll : !htmx.config.defaultFocusScroll };
- if (newActiveElt) {
- // @ts-ignore
- if (selectionInfo.start && newActiveElt.setSelectionRange) {
- // @ts-ignore
- try {
- newActiveElt.setSelectionRange(selectionInfo.start, selectionInfo.end);
- } catch (e) {
- // the setSelectionRange method is present on fields that don't support it, so just let this fail
- }
- }
- newActiveElt.focus(focusOptions);
- }
- }
-
- target.classList.remove(htmx.config.swappingClass);
- forEach(settleInfo.elts, function (elt) {
- if (elt.classList) {
- elt.classList.add(htmx.config.settlingClass);
- }
- triggerEvent(elt, 'htmx:afterSwap', responseInfo);
- });
-
- if (hasHeader(xhr, /HX-Trigger-After-Swap:/i)) {
- var finalElt = elt;
- if (!bodyContains(elt)) {
- finalElt = getDocument().body;
- }
- handleTrigger(xhr, "HX-Trigger-After-Swap", finalElt);
- }
-
- var doSettle = function () {
- forEach(settleInfo.tasks, function (task) {
- task.call();
- });
- forEach(settleInfo.elts, function (elt) {
- if (elt.classList) {
- elt.classList.remove(htmx.config.settlingClass);
- }
- triggerEvent(elt, 'htmx:afterSettle', responseInfo);
- });
-
- // if we need to save history, do so
- if (historyUpdate.type) {
- if (historyUpdate.type === "push") {
- pushUrlIntoHistory(historyUpdate.path);
- triggerEvent(getDocument().body, 'htmx:pushedIntoHistory', {path: historyUpdate.path});
- } else {
- replaceUrlInHistory(historyUpdate.path);
- triggerEvent(getDocument().body, 'htmx:replacedInHistory', {path: historyUpdate.path});
- }
- }
- if (responseInfo.pathInfo.anchor) {
- var anchorTarget = find("#" + responseInfo.pathInfo.anchor);
- if(anchorTarget) {
- anchorTarget.scrollIntoView({block:'start', behavior: "auto"});
- }
- }
-
- if(settleInfo.title) {
- var titleElt = find("title");
- if(titleElt) {
- titleElt.innerHTML = settleInfo.title;
- } else {
- window.document.title = settleInfo.title;
- }
- }
-
- updateScrollState(settleInfo.elts, swapSpec);
-
- if (hasHeader(xhr, /HX-Trigger-After-Settle:/i)) {
- var finalElt = elt;
- if (!bodyContains(elt)) {
- finalElt = getDocument().body;
- }
- handleTrigger(xhr, "HX-Trigger-After-Settle", finalElt);
- }
- maybeCall(settleResolve);
- }
-
- if (swapSpec.settleDelay > 0) {
- setTimeout(doSettle, swapSpec.settleDelay)
- } else {
- doSettle();
- }
- } catch (e) {
- triggerErrorEvent(elt, 'htmx:swapError', responseInfo);
- maybeCall(settleReject);
- throw e;
- }
- };
-
- var shouldTransition = htmx.config.globalViewTransitions
- if(swapSpec.hasOwnProperty('transition')){
- shouldTransition = swapSpec.transition;
- }
-
- if(shouldTransition &&
- triggerEvent(elt, 'htmx:beforeTransition', responseInfo) &&
- typeof Promise !== "undefined" && document.startViewTransition){
- var settlePromise = new Promise(function (_resolve, _reject) {
- settleResolve = _resolve;
- settleReject = _reject;
- });
- // wrap the original doSwap() in a call to startViewTransition()
- var innerDoSwap = doSwap;
- doSwap = function() {
- document.startViewTransition(function () {
- innerDoSwap();
- return settlePromise;
- });
- }
- }
-
-
- if (swapSpec.swapDelay > 0) {
- setTimeout(doSwap, swapSpec.swapDelay)
- } else {
- doSwap();
- }
- }
- if (isError) {
- triggerErrorEvent(elt, 'htmx:responseError', mergeObjects({error: "Response Status Error Code " + xhr.status + " from " + responseInfo.pathInfo.requestPath}, responseInfo));
- }
- }
-
- //====================================================================
- // Extensions API
- //====================================================================
-
- /** @type {Object} */
- var extensions = {};
-
- /**
- * extensionBase defines the default functions for all extensions.
- * @returns {import("./htmx").HtmxExtension}
- */
- function extensionBase() {
- return {
- init: function(api) {return null;},
- onEvent : function(name, evt) {return true;},
- transformResponse : function(text, xhr, elt) {return text;},
- isInlineSwap : function(swapStyle) {return false;},
- handleSwap : function(swapStyle, target, fragment, settleInfo) {return false;},
- encodeParameters : function(xhr, parameters, elt) {return null;}
- }
- }
-
- /**
- * defineExtension initializes the extension and adds it to the htmx registry
- *
- * @param {string} name
- * @param {import("./htmx").HtmxExtension} extension
- */
- function defineExtension(name, extension) {
- if(extension.init) {
- extension.init(internalAPI)
- }
- extensions[name] = mergeObjects(extensionBase(), extension);
- }
-
- /**
- * removeExtension removes an extension from the htmx registry
- *
- * @param {string} name
- */
- function removeExtension(name) {
- delete extensions[name];
- }
-
- /**
- * getExtensions searches up the DOM tree to return all extensions that can be applied to a given element
- *
- * @param {HTMLElement} elt
- * @param {import("./htmx").HtmxExtension[]=} extensionsToReturn
- * @param {import("./htmx").HtmxExtension[]=} extensionsToIgnore
- */
- function getExtensions(elt, extensionsToReturn, extensionsToIgnore) {
-
- if (elt == undefined) {
- return extensionsToReturn;
- }
- if (extensionsToReturn == undefined) {
- extensionsToReturn = [];
- }
- if (extensionsToIgnore == undefined) {
- extensionsToIgnore = [];
- }
- var extensionsForElement = getAttributeValue(elt, "hx-ext");
- if (extensionsForElement) {
- forEach(extensionsForElement.split(","), function(extensionName){
- extensionName = extensionName.replace(/ /g, '');
- if (extensionName.slice(0, 7) == "ignore:") {
- extensionsToIgnore.push(extensionName.slice(7));
- return;
- }
- if (extensionsToIgnore.indexOf(extensionName) < 0) {
- var extension = extensions[extensionName];
- if (extension && extensionsToReturn.indexOf(extension) < 0) {
- extensionsToReturn.push(extension);
- }
- }
- });
- }
- return getExtensions(parentElt(elt), extensionsToReturn, extensionsToIgnore);
- }
-
- //====================================================================
- // Initialization
- //====================================================================
- var isReady = false
- getDocument().addEventListener('DOMContentLoaded', function() {
- isReady = true
- })
-
- /**
- * Execute a function now if DOMContentLoaded has fired, otherwise listen for it.
- *
- * This function uses isReady because there is no realiable way to ask the browswer whether
- * the DOMContentLoaded event has already been fired; there's a gap between DOMContentLoaded
- * firing and readystate=complete.
- */
- function ready(fn) {
- // Checking readyState here is a failsafe in case the htmx script tag entered the DOM by
- // some means other than the initial page load.
- if (isReady || getDocument().readyState === 'complete') {
- fn();
- } else {
- getDocument().addEventListener('DOMContentLoaded', fn);
- }
- }
-
- function insertIndicatorStyles() {
- if (htmx.config.includeIndicatorStyles !== false) {
- getDocument().head.insertAdjacentHTML("beforeend",
- "");
- }
- }
-
- function getMetaConfig() {
- var element = getDocument().querySelector('meta[name="htmx-config"]');
- if (element) {
- // @ts-ignore
- return parseJSON(element.content);
- } else {
- return null;
- }
- }
-
- function mergeMetaConfig() {
- var metaConfig = getMetaConfig();
- if (metaConfig) {
- htmx.config = mergeObjects(htmx.config , metaConfig)
- }
- }
-
- // initialize the document
- ready(function () {
- mergeMetaConfig();
- insertIndicatorStyles();
- var body = getDocument().body;
- processNode(body);
- var restoredElts = getDocument().querySelectorAll(
- "[hx-trigger='restored'],[data-hx-trigger='restored']"
- );
- body.addEventListener("htmx:abort", function (evt) {
- var target = evt.target;
- var internalData = getInternalData(target);
- if (internalData && internalData.xhr) {
- internalData.xhr.abort();
- }
- });
- var originalPopstate = window.onpopstate;
- window.onpopstate = function (event) {
- if (event.state && event.state.htmx) {
- restoreHistory();
- forEach(restoredElts, function(elt){
- triggerEvent(elt, 'htmx:restored', {
- 'document': getDocument(),
- 'triggerEvent': triggerEvent
- });
- });
- } else {
- if (originalPopstate) {
- originalPopstate(event);
- }
- }
- };
- setTimeout(function () {
- triggerEvent(body, 'htmx:load', {}); // give ready handlers a chance to load up before firing this event
- body = null; // kill reference for gc
- }, 0);
- })
-
- return htmx;
- }
-)()
-}));
diff --git a/sipa/static/js/htmx.min.js b/sipa/static/js/htmx.min.js
new file mode 100644
index 00000000..47eb70fe
--- /dev/null
+++ b/sipa/static/js/htmx.min.js
@@ -0,0 +1 @@
+(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:F,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:Br,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.10"};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 a(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/"+n+" ",0);return i.querySelector("template").content}switch(r){case"thead":case"tbody":case"tfoot":case"colgroup":case"caption":return a("",1);case"col":return a("",2);case"tr":return a("",2);case"td":case"th":return a("",3);case"script":case"style":return a(""+n+"
",1);default:return a(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 B(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 F(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=g(e);if(t){setTimeout(function(){_(e);e=null},t)}else{e.parentElement.removeChild(e)}}function z(e,t,r){e=g(e);if(r){setTimeout(function(){z(e,t);e=null},r)}else{e.classList&&e.classList.add(t)}}function n(e,t,r){e=g(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=g(e);e.classList.toggle(t)}function W(e,t){e=g(e);oe(e.parentElement.children,function(e){n(e,t)});z(e,t)}function v(e,t){e=g(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 s(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(s(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 g(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:g(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 me=re().createElement("output");function pe(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[me]}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"]){Fe(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 m(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=Be(r,o,a);Re(o);return Fe(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)){p(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){mt(e)})}},200)}}function mt(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 pt(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)){p(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);mt(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(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+=Bt(o)}for(var l in r){Ft(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=B(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=pe(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=pe(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 pr(n)}else{return mr(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:g(r),returnPromise:true})}else{return he(e,t,g(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:g(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=s(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==me){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 m=ne(n,"hx-sync");var p=null;var x=false;if(m){var B=m.split(":");var F=B[0].trim();if(F==="this"){g=xe(n,"hx-sync")}else{g=ue(n,F)}m=(B[1]||"drop").trim();f=ae(g);if(m==="drop"&&f.xhr&&f.abortable!==true){ie(o);return l}else if(m==="abort"){if(f.xhr){ie(o);return l}else{x=true}}else if(m==="replace"){ce(g,"htmx:abort")}else if(m.indexOf("queue")===0){var V=m.split(" ");p=(V[1]||"last").trim()}}if(f.xhr){if(f.abortable){ce(g,"htmx:abort")}else{if(p==null){if(i){var y=ae(i);if(y&&y.triggerSpec&&y.triggerSpec.queue){p=y.triggerSpec.queue}}if(p==null){p="last"}}if(f.queuedRequests==null){f.queuedRequests=[]}if(p==="first"&&f.queuedRequests.length===0){f.queuedRequests.push(function(){he(t,r,n,i,a)})}else if(p==="all"){f.queuedRequests.push(function(){he(t,r,n,i,a)})}else if(p==="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+=mr(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 m=Q.config.ignoreTitle;var o=le({shouldSwap:i,serverResponse:g,isError:a,ignoreTitle:m},u);if(!ce(c,"htmx:beforeSwap",o))return;c=o.target;g=o.serverResponse;a=o.isError;m=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")){m=v.ignoreTitle}c.classList.add(Q.config.swappingClass);var p=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&&!m){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(p)};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){p=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 Br(e){delete Xr[e]}function Fr(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 Fr(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
diff --git a/sipa/static/js/pygal-tooltips.js b/sipa/static/js/pygal-tooltips.js
deleted file mode 100644
index 9e2a87e6..00000000
--- a/sipa/static/js/pygal-tooltips.js
+++ /dev/null
@@ -1,353 +0,0 @@
-(function() {
- var $, get_translation, init, init_svg, matches, padding, r_translation, sibl, svg_ns, tooltip_timeout, xlink_ns;
-
- svg_ns = 'http://www.w3.org/2000/svg';
-
- xlink_ns = 'http://www.w3.org/1999/xlink';
-
- $ = function(sel, ctx) {
- if (ctx == null) {
- ctx = null;
- }
- ctx = ctx || document;
- return Array.prototype.slice.call(ctx.querySelectorAll(sel), 0).filter(function(e) {
- return e !== ctx;
- });
- };
-
- matches = function(el, selector) {
- return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
- };
-
- sibl = function(el, match) {
- if (match == null) {
- match = null;
- }
- return Array.prototype.filter.call(el.parentElement.children, function(child) {
- return child !== el && (!match || matches(child, match));
- });
- };
-
- Array.prototype.one = function() {
- return this.length > 0 && this[0] || {};
- };
-
- padding = 5;
-
- tooltip_timeout = null;
-
- r_translation = /translate\((\d+)[ ,]+(\d+)\)/;
-
- get_translation = function(el) {
- return (r_translation.exec(el.getAttribute('transform')) || []).slice(1).map(function(x) {
- return +x;
- });
- };
-
- init = function(ctx) {
- var bbox, box, config, el, graph, inner_svg, num, parent, tooltip, tooltip_el, tt, uid, untooltip, xconvert, yconvert, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
- if ($('svg', ctx).length) {
- inner_svg = $('svg', ctx).one();
- parent = inner_svg.parentElement;
- box = inner_svg.viewBox.baseVal;
- bbox = parent.getBBox();
- xconvert = function(x) {
- return ((x - box.x) / box.width) * bbox.width;
- };
- yconvert = function(y) {
- return ((y - box.y) / box.height) * bbox.height;
- };
- } else {
- xconvert = yconvert = function(x) {
- return x;
- };
- }
- if (((_ref = window.pygal) != null ? _ref.config : void 0) != null) {
- if (window.pygal.config.no_prefix != null) {
- config = window.pygal.config;
- } else {
- uid = ctx.id.replace('chart-', '');
- config = window.pygal.config[uid];
- }
- } else {
- config = window.config;
- }
- tooltip_el = null;
- graph = $('.graph').one();
- tt = $('.tooltip', ctx).one();
- _ref1 = $('.reactive', ctx);
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- el = _ref1[_i];
- el.addEventListener('mouseenter', (function(el) {
- return function() {
- return el.classList.add('active');
- };
- })(el));
- el.addEventListener('mouseleave', (function(el) {
- return function() {
- return el.classList.remove('active');
- };
- })(el));
- }
- _ref2 = $('.activate-serie', ctx);
- for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
- el = _ref2[_j];
- num = el.id.replace('activate-serie-', '');
- el.addEventListener('mouseenter', (function(num) {
- return function() {
- var re, _k, _l, _len2, _len3, _ref3, _ref4, _results;
- _ref3 = $('.serie-' + num + ' .reactive', ctx);
- for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
- re = _ref3[_k];
- re.classList.add('active');
- }
- _ref4 = $('.serie-' + num + ' .showable', ctx);
- _results = [];
- for (_l = 0, _len3 = _ref4.length; _l < _len3; _l++) {
- re = _ref4[_l];
- _results.push(re.classList.add('shown'));
- }
- return _results;
- };
- })(num));
- el.addEventListener('mouseleave', (function(num) {
- return function() {
- var re, _k, _l, _len2, _len3, _ref3, _ref4, _results;
- _ref3 = $('.serie-' + num + ' .reactive', ctx);
- for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
- re = _ref3[_k];
- re.classList.remove('active');
- }
- _ref4 = $('.serie-' + num + ' .showable', ctx);
- _results = [];
- for (_l = 0, _len3 = _ref4.length; _l < _len3; _l++) {
- re = _ref4[_l];
- _results.push(re.classList.remove('shown'));
- }
- return _results;
- };
- })(num));
- el.addEventListener('click', (function(el, num) {
- return function() {
- var ov, re, rect, show, _k, _l, _len2, _len3, _ref3, _ref4, _results;
- rect = $('rect', el).one();
- show = rect.style.fill !== '';
- rect.style.fill = show ? '' : 'transparent';
- _ref3 = $('.serie-' + num + ' .reactive', ctx);
- for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
- re = _ref3[_k];
- re.style.display = show ? '' : 'none';
- }
- _ref4 = $('.text-overlay .serie-' + num, ctx);
- _results = [];
- for (_l = 0, _len3 = _ref4.length; _l < _len3; _l++) {
- ov = _ref4[_l];
- _results.push(ov.style.display = show ? '' : 'none');
- }
- return _results;
- };
- })(el, num));
- }
- _ref3 = $('.tooltip-trigger', ctx);
- for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
- el = _ref3[_k];
- el.addEventListener('mouseenter', (function(el) {
- return function() {
- return tooltip_el = tooltip(el);
- };
- })(el));
- }
- tt.addEventListener('mouseenter', function() {
- return tooltip_el != null ? tooltip_el.classList.add('active') : void 0;
- });
- tt.addEventListener('mouseleave', function() {
- return tooltip_el != null ? tooltip_el.classList.remove('active') : void 0;
- });
- ctx.addEventListener('mouseleave', function() {
- if (tooltip_timeout) {
- clearTimeout(tooltip_timeout);
- }
- return untooltip(0);
- });
- graph.addEventListener('mousemove', function(el) {
- if (tooltip_timeout) {
- return;
- }
- if (!matches(el.target, '.background')) {
- return;
- }
- return untooltip(1000);
- });
- tooltip = function(el) {
- var a, baseline, cls, current_x, current_y, dy, h, i, key, keys, label, legend, name, plot_x, plot_y, rect, serie_index, subval, text, text_group, texts, traversal, value, w, x, x_elt, x_label, xlink, y, y_elt, _l, _len3, _len4, _len5, _m, _n, _ref4, _ref5, _ref6, _ref7, _ref8;
- clearTimeout(tooltip_timeout);
- tooltip_timeout = null;
- tt.style.opacity = 1;
- tt.style.display = '';
- text_group = $('g.text', tt).one();
- rect = $('rect', tt).one();
- text_group.innerHTML = '';
- label = sibl(el, '.label').one().textContent;
- x_label = sibl(el, '.x_label').one().textContent;
- value = sibl(el, '.value').one().textContent;
- xlink = sibl(el, '.xlink').one().textContent;
- serie_index = null;
- parent = el;
- traversal = [];
- while (parent) {
- traversal.push(parent);
- if (parent.classList.contains('series')) {
- break;
- }
- parent = parent.parentElement;
- }
- if (parent) {
- _ref4 = parent.classList;
- for (_l = 0, _len3 = _ref4.length; _l < _len3; _l++) {
- cls = _ref4[_l];
- if (cls.indexOf('serie-') === 0) {
- serie_index = +cls.replace('serie-', '');
- break;
- }
- }
- }
- legend = null;
- if (serie_index !== null) {
- legend = config.legends[serie_index];
- }
- dy = 0;
- keys = [[label, 'label']];
- _ref5 = value.split('\n');
- for (i = _m = 0, _len4 = _ref5.length; _m < _len4; i = ++_m) {
- subval = _ref5[i];
- keys.push([subval, 'value-' + i]);
- }
- if (config.tooltip_fancy_mode) {
- keys.push([xlink, 'xlink']);
- keys.unshift([x_label, 'x_label']);
- keys.unshift([legend, 'legend']);
- }
- texts = {};
- for (_n = 0, _len5 = keys.length; _n < _len5; _n++) {
- _ref6 = keys[_n], key = _ref6[0], name = _ref6[1];
- if (key) {
- text = document.createElementNS(svg_ns, 'text');
- text.textContent = key;
- text.setAttribute('x', padding);
- text.setAttribute('dy', dy);
- text.classList.add(name.indexOf('value') === 0 ? 'value' : name);
- if (name.indexOf('value') === 0 && config.tooltip_fancy_mode) {
- text.classList.add('color-' + serie_index);
- }
- if (name === 'xlink') {
- a = document.createElementNS(svg_ns, 'a');
- a.setAttributeNS(xlink_ns, 'href', key);
- a.textContent = void 0;
- a.appendChild(text);
- text.textContent = 'Link >';
- text_group.appendChild(a);
- } else {
- text_group.appendChild(text);
- }
- dy += text.getBBox().height + padding / 2;
- baseline = padding;
- if (text.style.dominantBaseline !== void 0) {
- text.style.dominantBaseline = 'text-before-edge';
- } else {
- baseline += text.getBBox().height * .8;
- }
- text.setAttribute('y', baseline);
- texts[name] = text;
- }
- }
- w = text_group.getBBox().width + 2 * padding;
- h = text_group.getBBox().height + 2 * padding;
- rect.setAttribute('width', w);
- rect.setAttribute('height', h);
- if (texts.value) {
- texts.value.setAttribute('dx', (w - texts.value.getBBox().width) / 2 - padding);
- }
- if (texts.x_label) {
- texts.x_label.setAttribute('dx', w - texts.x_label.getBBox().width - 2 * padding);
- }
- if (texts.xlink) {
- texts.xlink.setAttribute('dx', w - texts.xlink.getBBox().width - 2 * padding);
- }
- x_elt = sibl(el, '.x').one();
- y_elt = sibl(el, '.y').one();
- x = parseInt(x_elt.textContent);
- if (x_elt.classList.contains('centered')) {
- x -= w / 2;
- } else if (x_elt.classList.contains('left')) {
- x -= w;
- } else if (x_elt.classList.contains('auto')) {
- x = xconvert(el.getBBox().x + el.getBBox().width / 2) - w / 2;
- }
- y = parseInt(y_elt.textContent);
- if (y_elt.classList.contains('centered')) {
- y -= h / 2;
- } else if (y_elt.classList.contains('top')) {
- y -= h;
- } else if (y_elt.classList.contains('auto')) {
- y = yconvert(el.getBBox().y + el.getBBox().height / 2) - h / 2;
- }
- _ref7 = get_translation(tt.parentElement), plot_x = _ref7[0], plot_y = _ref7[1];
- if (x + w + plot_x > config.width) {
- x = config.width - w - plot_x;
- }
- if (y + h + plot_y > config.height) {
- y = config.height - h - plot_y;
- }
- if (x + plot_x < 0) {
- x = -plot_x;
- }
- if (y + plot_y < 0) {
- y = -plot_y;
- }
- _ref8 = get_translation(tt), current_x = _ref8[0], current_y = _ref8[1];
- if (current_x === x && current_y === y) {
- return el;
- }
- tt.setAttribute('transform', "translate(" + x + " " + y + ")");
- return el;
- };
- return untooltip = function(ms) {
- return tooltip_timeout = setTimeout(function() {
- tt.style.display = 'none';
- tt.style.opacity = 0;
- if (tooltip_el != null) {
- tooltip_el.classList.remove('active');
- }
- return tooltip_timeout = null;
- }, ms);
- };
- };
-
- init_svg = function() {
- var chart, charts, _i, _len, _results;
- charts = $('.pygal-chart');
- if (charts.length) {
- _results = [];
- for (_i = 0, _len = charts.length; _i < _len; _i++) {
- chart = charts[_i];
- _results.push(init(chart));
- }
- return _results;
- }
- };
-
- if (document.readyState !== 'loading') {
- init_svg();
- } else {
- document.addEventListener('DOMContentLoaded', function() {
- return init_svg();
- });
- }
-
- window.pygal = window.pygal || {};
-
- window.pygal.init = init;
-
- window.pygal.init_svg = init_svg;
-
-}).call(this);
diff --git a/sipa/static/js/pygal-tooltips.min.js b/sipa/static/js/pygal-tooltips.min.js
new file mode 100644
index 00000000..bf566908
--- /dev/null
+++ b/sipa/static/js/pygal-tooltips.min.js
@@ -0,0 +1,2 @@
+/*! pygal.js 2015-10-30 */
+(function(){var a,b,c,d,e,f,g,h,i,j,k;i="http://www.w3.org/2000/svg",k="http://www.w3.org/1999/xlink",a=function(a,b){return null==b&&(b=null),b=b||document,Array.prototype.slice.call(b.querySelectorAll(a),0).filter(function(a){return a!==b})},e=function(a,b){return(a.matches||a.matchesSelector||a.msMatchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.oMatchesSelector).call(a,b)},h=function(a,b){return null==b&&(b=null),Array.prototype.filter.call(a.parentElement.children,function(c){return c!==a&&(!b||e(c,b))})},Array.prototype.one=function(){return this.length>0&&this[0]||{}},f=5,j=null,g=/translate\((\d+)[ ,]+(\d+)\)/,b=function(a){return(g.exec(a.getAttribute("transform"))||[]).slice(1).map(function(a){return+a})},c=function(c){var d,g,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H;for(a("svg",c).length?(o=a("svg",c).one(),q=o.parentElement,g=o.viewBox.baseVal,d=q.getBBox(),w=function(a){return(a-g.x)/g.width*d.width},x=function(a){return(a-g.y)/g.height*d.height}):w=x=function(a){return a},null!=(null!=(E=window.pygal)?E.config:void 0)?null!=window.pygal.config.no_prefix?l=window.pygal.config:(u=c.id.replace("chart-",""),l=window.pygal.config[u]):l=window.config,s=null,n=a(".graph").one(),t=a(".tooltip",c).one(),F=a(".reactive",c),y=0,B=F.length;B>y;y++)m=F[y],m.addEventListener("mouseenter",function(a){return function(){return a.classList.add("active")}}(m)),m.addEventListener("mouseleave",function(a){return function(){return a.classList.remove("active")}}(m));for(G=a(".activate-serie",c),z=0,C=G.length;C>z;z++)m=G[z],p=m.id.replace("activate-serie-",""),m.addEventListener("mouseenter",function(b){return function(){var d,e,f,g,h,i,j,k;for(i=a(".serie-"+b+" .reactive",c),e=0,g=i.length;g>e;e++)d=i[e],d.classList.add("active");for(j=a(".serie-"+b+" .showable",c),k=[],f=0,h=j.length;h>f;f++)d=j[f],k.push(d.classList.add("shown"));return k}}(p)),m.addEventListener("mouseleave",function(b){return function(){var d,e,f,g,h,i,j,k;for(i=a(".serie-"+b+" .reactive",c),e=0,g=i.length;g>e;e++)d=i[e],d.classList.remove("active");for(j=a(".serie-"+b+" .showable",c),k=[],f=0,h=j.length;h>f;f++)d=j[f],k.push(d.classList.remove("shown"));return k}}(p)),m.addEventListener("click",function(b,d){return function(){var e,f,g,h,i,j,k,l,m,n,o;for(g=a("rect",b).one(),h=""!==g.style.fill,g.style.fill=h?"":"transparent",m=a(".serie-"+d+" .reactive",c),i=0,k=m.length;k>i;i++)f=m[i],f.style.display=h?"":"none";for(n=a(".text-overlay .serie-"+d,c),o=[],j=0,l=n.length;l>j;j++)e=n[j],o.push(e.style.display=h?"":"none");return o}}(m,p));for(H=a(".tooltip-trigger",c),A=0,D=H.length;D>A;A++)m=H[A],m.addEventListener("mouseenter",function(a){return function(){return s=r(a)}}(m));return t.addEventListener("mouseenter",function(){return null!=s?s.classList.add("active"):void 0}),t.addEventListener("mouseleave",function(){return null!=s?s.classList.remove("active"):void 0}),c.addEventListener("mouseleave",function(){return j&&clearTimeout(j),v(0)}),n.addEventListener("mousemove",function(a){return!j&&e(a.target,".background")?v(1e3):void 0}),r=function(c){var d,e,g,m,n,o,p,r,s,u,v,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_;for(clearTimeout(j),j=null,t.style.opacity=1,t.style.display="",G=a("g.text",t).one(),C=a("rect",t).one(),G.innerHTML="",v=h(c,".label").one().textContent,N=h(c,".x_label").one().textContent,J=h(c,".value").one().textContent,O=h(c,".xlink").one().textContent,D=null,q=c,I=[];q&&(I.push(q),!q.classList.contains("series"));)q=q.parentElement;if(q)for(X=q.classList,R=0,S=X.length;S>R;R++)if(g=X[R],0===g.indexOf("serie-")){D=+g.replace("serie-","");break}for(y=null,null!==D&&(y=l.legends[D]),o=0,u=[[v,"label"]],Y=J.split("\n"),r=V=0,T=Y.length;T>V;r=++V)E=Y[r],u.push([E,"value-"+r]);for(l.tooltip_fancy_mode&&(u.push([O,"xlink"]),u.unshift([N,"x_label"]),u.unshift([y,"legend"])),H={},W=0,U=u.length;U>W;W++)Z=u[W],s=Z[0],z=Z[1],s&&(F=document.createElementNS(i,"text"),F.textContent=s,F.setAttribute("x",f),F.setAttribute("dy",o),F.classList.add(0===z.indexOf("value")?"value":z),0===z.indexOf("value")&&l.tooltip_fancy_mode&&F.classList.add("color-"+D),"xlink"===z?(d=document.createElementNS(i,"a"),d.setAttributeNS(k,"href",s),d.textContent=void 0,d.appendChild(F),F.textContent="Link >",G.appendChild(d)):G.appendChild(F),o+=F.getBBox().height+f/2,e=f,void 0!==F.style.dominantBaseline?F.style.dominantBaseline="text-before-edge":e+=.8*F.getBBox().height,F.setAttribute("y",e),H[z]=F);return K=G.getBBox().width+2*f,p=G.getBBox().height+2*f,C.setAttribute("width",K),C.setAttribute("height",p),H.value&&H.value.setAttribute("dx",(K-H.value.getBBox().width)/2-f),H.x_label&&H.x_label.setAttribute("dx",K-H.x_label.getBBox().width-2*f),H.xlink&&H.xlink.setAttribute("dx",K-H.xlink.getBBox().width-2*f),M=h(c,".x").one(),Q=h(c,".y").one(),L=parseInt(M.textContent),M.classList.contains("centered")?L-=K/2:M.classList.contains("left")?L-=K:M.classList.contains("auto")&&(L=w(c.getBBox().x+c.getBBox().width/2)-K/2),P=parseInt(Q.textContent),Q.classList.contains("centered")?P-=p/2:Q.classList.contains("top")?P-=p:Q.classList.contains("auto")&&(P=x(c.getBBox().y+c.getBBox().height/2)-p/2),$=b(t.parentElement),A=$[0],B=$[1],L+K+A>l.width&&(L=l.width-K-A),P+p+B>l.height&&(P=l.height-p-B),0>L+A&&(L=-A),0>P+B&&(P=-B),_=b(t),m=_[0],n=_[1],m===L&&n===P?c:(t.setAttribute("transform","translate("+L+" "+P+")"),c)},v=function(a){return j=setTimeout(function(){return t.style.display="none",t.style.opacity=0,null!=s&&s.classList.remove("active"),j=null},a)}},d=function(){var b,d,e,f,g;if(d=a(".pygal-chart"),d.length){for(g=[],e=0,f=d.length;f>e;e++)b=d[e],g.push(c(b));return g}},"loading"!==document.readyState?d():document.addEventListener("DOMContentLoaded",function(){return d()}),window.pygal=window.pygal||{},window.pygal.init=c,window.pygal.init_svg=d}).call(this);
\ No newline at end of file
diff --git a/sipa/templates/base.html b/sipa/templates/base.html
index c379b4c5..3da77002 100644
--- a/sipa/templates/base.html
+++ b/sipa/templates/base.html
@@ -83,7 +83,7 @@
-
+
{% block custom_script %}{% endblock %}
diff --git a/sipa/templates/usersuite/index.html b/sipa/templates/usersuite/index.html
index fd54b4bf..97e0f99b 100644
--- a/sipa/templates/usersuite/index.html
+++ b/sipa/templates/usersuite/index.html
@@ -24,5 +24,5 @@
{% block custom_script %}
-
+
{% endblock %}