Files
Giraffe.Htmx/src/Common/wwwroot/htmax.min.js
T

1 line
65 KiB
JavaScript

var htmx=(()=>{const e={parse(t){if(!t)return{};if(t.startsWith("{"))return JSON.parse(t);let r=/(?:"([^"]+)"|'([^']+)'|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<((?:[^/]|\/(?!>))+)\/>|([^\s,]+)))?(?=\s|,|$)/g,i={};for(let s of t.matchAll(r)){let[,t,r,n,o,a,l,c]=s,h=t??r??n,u=(o??a??l??c??"true").trim();try{u=JSON.parse(u)}catch{}let d=n?.includes("."),f=d?h.split(".").reduceRight((e,t)=>({[t]:e}),u):{[h]:u};e.merge(f,i)}return i},split:e=>e.split(/,(?![^\[]*\])(?![^(]*\))(?![^<]*\/>)(?=(?:[^"']|"[^"]*"|'[^']*')*$)/),merge(t,r){"string"==typeof t&&(t=e.parse(t));for(let[i,s]of Object.entries(t)){if(["__proto__","constructor","prototype"].includes(i))continue;let t=s&&"object"==typeof s&&!Array.isArray(s),n=r[i]&&"object"==typeof r[i]&&!Array.isArray(r[i]);t&&n?e.merge(s,r[i]):r[i]=s}return r}};class t{#e=null;#t=[];issue(e,t){return e.queueStrategy=t,this.#e?"replace"===t||"abort"!==t&&"abort"===this.#e.queueStrategy?(this.#t.forEach(e=>e.status="dropped"),this.#t=[],this.#e.request?.abort?.(),this.#e=e,!0):("queue all"===t?(this.#t.push(e),e.status="queued"):"drop"===t?e.status="dropped":"queue last"===t?(this.#t.forEach(e=>e.status="dropped"),this.#t=[e],e.status="queued"):0===this.#t.length&&"abort"!==t?(this.#t.push(e),e.status="queued"):e.status="dropped",!1):(this.#e=e,!0)}finish(){this.#e=null}next(){return this.#t.shift()}abort(){this.#e?.request?.abort?.()}more(){return this.#t?.length}}return new class{#r=e;#i=new Map;#s="";#n=new Set;#o;#a=Function;#l=Object.getPrototypeOf(async function(){}).constructor;#c={createHTML:e=>e,createScript:e=>e};#h;#u="a,form";#d=["get","post","put","patch","delete"];#f;#m;#p;#g;constructor(){this.#x(),this.#b(),this.#h=this.#y("[hx-action],[hx-get],[hx-post],[hx-put],[hx-patch],[hx-delete]"),this.#f=(new XPathEvaluator).createExpression(`.//*[@*[${this.#v("hx-on").map(e=>`starts-with(name(), "${e}")`).join(" or ")}]]`),this.#o={attributeValue:this.#w.bind(this),parseTriggerSpecs:this.#S.bind(this),determineMethodAndAction:this.#E.bind(this),createRequestContext:this.#A.bind(this),collectFormData:this.#q.bind(this),getAttributeObject:this.#C.bind(this),insertContent:this.#T.bind(this),morph:this.#H.bind(this),isSoftMatch:this.#k.bind(this),initSecurity:(e,t,r)=>{e&&(this.#c=e),t&&(this.#a=t),r&&(this.#l=r)},onTrigger:this.#_.bind(this),htmxProp:this.#N.bind(this),triggerHtmxEvent:this.#M.bind(this),executeJavaScript:this.#L.bind(this)};let e=()=>{this.#O(),this.process(document.body)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}#x(){this.version="4.0.0-beta5",this.config={logAll:!1,prefix:"data-hx-",transitions:!1,history:!0,mode:"same-origin",defaultSwap:"innerHTML",defaultFocusScroll:!1,indicatorClass:"htmx-indicator",requestClass:"htmx-request",includeIndicatorCSS:!0,defaultTimeout:6e4,extensions:"",morphIgnore:["data-htmx-powered"],morphSkip:"[hx-morph-skip]",morphSkipChildren:"[hx-morph-skip-children]",morphScanLimit:10,noSwap:[204,304],implicitInheritance:!1,defaultSettleDelay:1};let t=document.querySelector('meta[name="htmx-config"]');t&&e.merge(t.content,this.config),this.#s=this.config.extensions}#b(){if(!1!==this.config.includeIndicatorCSS){let e=this.config.indicatorClass,t=this.config.requestClass,r=new CSSStyleSheet;r.replaceSync(`.${e}{opacity:0;visibility: hidden} .${t} .${e}, .${t}.${e}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r]}}registerExtension(e,t){return!(this.#s&&!this.#s.split(/,\s*/).includes(e))&&(!this.#n.has(e)&&(this.#n.add(e),t.init&&t.init(this.#o),void Object.entries(t).forEach(([e,t])=>{this.#i.get(e)?.push(t)||this.#i.set(e,[t])})))}#I(e){let t=this.config.prefix;return!e.closest||null!=e.closest("[hx-ignore]")||t&&null!=e.closest(`[${t}ignore]`)}#R(e,t){let r=this.config.prefix;return e.getAttribute(t)??(r?e.getAttribute(t.replace("hx-",r)):null)}#P(e,t){let r=this.config.prefix&&t.replace("hx-",this.config.prefix);return e.hasAttribute(t)?t:r&&e.hasAttribute(r)?r:null}#y(e){return this.#v(e).join(",")}#v(e){let t=[e];return this.config.prefix&&t.push(e.replaceAll("hx-",this.config.prefix)),t}#j(e,t){let r=[...e.querySelectorAll?.(t)??[]];return e.matches?.(t)&&r.unshift(e),r}#D(e){return"before"===e?"beforebegin":"after"===e?"afterend":"prepend"===e?"afterbegin":"append"===e?"beforeend":e}#V(e,t){let r=[];return this.#w(e,t,void 0,(e,t)=>{e?.split(/\s*[,:]\s*/).includes("this")&&r.push(t)}),r}#w(e,t,r,i){t=this.#W(t);let s=this.#W(":inherited"),n=this.#W(":append"),o=this.#R(e,t)??this.#R(e,t+s);if(null!=o)return i?i(o,e):o;let a=CSS.escape(this.config.implicitInheritance?t:t+s),l=CSS.escape(t+s+n),c=this.#y(`[${a}],[${l}]`),h=this.#P(e,t+n)??this.#P(e,t+s+n);if(h){let r=e.getAttribute(h),s=e.parentNode?.closest?.(c);if(i&&i(r,e),s){let e=this.#w(s,t,void 0,i);return e?(e+","+r).replace(/[{}]/g,""):r}return r}let u=e.parentNode?.closest?.(c);return u?(o=this.#w(u,t,void 0,i),!i&&o&&this.config.implicitInheritance&&this.#B(e,"htmx:after:implicitInheritance",{elt:e,name:t,parent:u}),o):r}#S(t){return e.split(t).flatMap(t=>{let[,r,i]=t.match(/^\s*(\S+\[[^\]]*\]|\S+)\s*(.*?)\s*$/)??[];if(!r)return[];if(/\[[^\]]*$/.test(r))throw"unterminated:"+r;return[{name:r,...e.parse(i)}]})}#E(e,t){if(this.#$(e))return this.#F(e,t);{let t=this.#w(e,"hx-method")||"GET",r=this.#w(e,"hx-action");if(!r)for(let i of this.#d){let s=this.#w(e,"hx-"+i);if(null!=s){r=s,t=i;break}}return t=t.toUpperCase(),{action:r,method:t}}}#F(e,t){if(e.matches("a"))return{action:e.getAttribute("href"),method:"GET"};return{action:t.submitter?.getAttribute?.("formAction")||e.getAttribute("action"),method:(t.submitter?.getAttribute?.("formMethod")||e.getAttribute("method")||"GET").toUpperCase()}}#N(e){return e._htmx||(e._htmx={listeners:[],triggerSpecs:[]},e.setAttribute("data-htmx-powered","true")),e._htmx}#U(e){return e._htmx_state||={}}#z(e){if(this.#J(e)&&this.#M(e,"htmx:before:init",{},!0)){let t=this.#N(e);t.initialized=!0,t.eventHandler=this.#Q(e),this.#G(e),this.#X(e),this.#M(e,"htmx:after:init",{},!0)}}#Q(e){return async t=>{try{let r=this.#A(e,t);await this.#K(r)}catch(t){this.#M(e,"htmx:error",{error:t})}}}#A(t,r){let{action:i,method:s}=this.#E(t,r),[n,o]=(i||"").split("#"),a=new AbortController,l={sourceElement:t,sourceEvent:r,status:"created",select:this.#w(t,"hx-select"),selectOOB:this.#w(t,"hx-select-oob"),target:this.#w(t,"hx-target"),swap:this.#w(t,"hx-swap")??this.config.defaultSwap,push:this.#w(t,"hx-push-url"),replace:this.#w(t,"hx-replace-url"),transition:this.config.transitions,confirm:this.#w(t,"hx-confirm"),request:{validate:"true"===this.#w(t,"hx-validate",!t.matches("form")||t.noValidate||r.submitter?.formNoValidate?"false":"true"),action:n,anchor:o,method:s,headers:this.#Y(t),abort:a.abort.bind(a),credentials:"same-origin",signal:a.signal,mode:this.config.mode}};t._htmx?.boosted&&e.merge(t._htmx.boosted,l),l.target=this.#Z(t,l.target),l.request.headers["HX-Request-Type"]=l.target===document.body||l.select?"full":"partial",l.target&&(l.request.headers["HX-Target"]=this.#ee(l.target));let c=this.#w(t,"hx-config");return c&&(e.merge(c,l.request),l.request.mode=this.config.mode),l}#ee(e){return`${e.tagName.toLowerCase()}${e.id?"#"+encodeURI(e.id):""}`}#Y(e){let t={"HX-Request":"true","HX-Source":this.#ee(e),"HX-Current-URL":location.href,Accept:"text/html"};return this.#$(e)&&(t["HX-Boosted"]="true"),t}#te(e,t){return this.#C(e,"hx-headers",e=>{for(let r in e)t.request.headers[r]=String(e[r])},{ctx:t})}#Z(e,t){return t instanceof Element?t:null!=t?this.#re(e,t,"hx-target"):this.#$(e)?document.body:e}#$(e){return e?._htmx?.boosted}async#K(e){let t=e.sourceElement,r=e.sourceEvent;if(!t.isConnected)return;if(this.#ie(r))return;this.#se(r)&&r.preventDefault();let i=/GET|DELETE/.test(e.request.method),s=i?t.matches("form")?t:null:t.form||t.closest("form"),n=this.#q(t,s,r.submitter,e.request.validate,i);if(!n)return;let o=this.#C(t,"hx-vals",t=>{e.vals=t;for(let e in t)n.set(e,t[e])},{ctx:e});if(o&&await o,e.values)for(let t in e.values)n.delete(t),n.append(t,e.values[t]);let a=this.#te(t,e);if(a&&await a,Object.assign(e.request,{form:s,submitter:r.submitter,body:n}),!this.#M(t,"htmx:config:request",{ctx:e}))return;if(!this.#d.includes(e.request.method.toLowerCase()))return;let l=this.#ne(e.request.action);if(null!=l){let t=Object.fromEntries(e.request.body);return void await this.#L(e.sourceElement,t,l,!1)}if(i){let t=new URL(e.request.action,document.baseURI);for(let r of e.request.body.keys())t.searchParams.delete(r);for(let[r,i]of e.request.body)t.searchParams.append(r,i);t.origin===location.origin?e.request.action=t.pathname+t.search:e.request.action=t.href,e.request.body=null}else"multipart/form-data"!==(this.#w(t,"hx-encoding")??s?.enctype)&&(e.request.body=new URLSearchParams(e.request.body));await this.#oe(e)}async#oe(e){let t=e.sourceElement,r=this.#ae(t),i=this.#le(t);if(!i.issue(e,r))return;e.status="issuing";let s=[],n=[];try{if(e.confirm){if(!await new Promise(r=>{let i={ctx:e,issueRequest:()=>r(!0),dropRequest:()=>r(!1)};if(this.#M(t,"htmx:confirm",i)){let i=this.#ne(e.confirm);r(i?this.#L(t,{ctx:e},i,!0):window.confirm(e.confirm))}}))return}if(this.#ce(e),s=this.#he(t),n=this.#ue(t),e.fetch||=window.fetch.bind(window),!this.#M(t,"htmx:before:request",{ctx:e}))return;let r=await e.fetch(e.request.action,e.request);if(e.response={raw:r,status:r.status,headers:r.headers},this.#de(e),!this.#M(t,"htmx:before:response",{ctx:e}))return;if(e.text=await r.text(),!this.#M(t,"htmx:after:request",{ctx:e}))return;if(e.response.status>=400&&this.#M(t,"htmx:response:error",{ctx:e}),this.#fe(e))return void(e.keepIndicators=!0);"issuing"===e.status&&(e.hx.retarget&&(e.target=e.hx.retarget),e.hx.reswap&&(e.swap=e.hx.reswap),e.hx.reselect&&(e.select=e.hx.reselect),e.status="response received",this.#me(e),await this.swap(e),e.status="swapped")}catch(r){e.status="error: "+r,this.#M(t,"htmx:error",{ctx:e,error:r})}finally{clearTimeout(e.requestTimeout),this.#M(t,"htmx:finally:request",{ctx:e}),e.keepIndicators||(this.#pe(s),this.#ge(n)),i.finish(),i.more()&&this.#oe(i.next())}}#de(e){e.hx={};for(let[t,r]of e.response.raw.headers)t.toLowerCase().startsWith("hx-")&&(e.hx[t.slice(3).toLowerCase().replace(/-/g,"")]=r)}#fe(t){if(t.hx.trigger&&this.#xe(t.hx.trigger,t.sourceElement),"true"===t.hx.refresh)return location.reload(),!0;if(t.hx.redirect)return location.href=t.hx.redirect,!0;if(t.hx.location){let r=t.hx.location,i={};return("{"===r[0]||/[\s,]/.test(r))&&(i=e.parse(r),r=i.path,delete i.path),i.push??="true",this.ajax("GET",r,i),!0}}#ce(e){let t=null!=e.request.timeout?this.parseInterval(e.request.timeout):this.config.defaultTimeout;t&&(e.requestTimeout=setTimeout(()=>e.request?.abort?.(),t))}#ae(e){let t=this.#w(e,"hx-sync");if(!t)return"queue first";let r=t.split(":").pop().trim();return/^(drop|abort|replace|queue)/.test(r)?r:"queue first"}#le(e){let r=this.#w(e,"hx-sync"),i=e;if(r){let t=r.includes(":")?r.slice(0,r.lastIndexOf(":")).trim():/^(drop|abort|replace|queue)/.test(r)?null:r;t&&(i=this.#re(e,t,"hx-sync")||e)}return this.#U(i).rq||=new t}#ie(e){return"click"===e.type&&(e.ctrlKey||e.metaKey||e.shiftKey)&&!!e.currentTarget?.closest?.("a[href]")}#se(e){let t=e.currentTarget;if("submit"===e.type&&"FORM"===t?.tagName)return!0;if(!("click"===e.type&&0===e.button))return!1;let r=t?.closest?.('button, input[type="submit"], input[type="image"]'),i=r?.form||r?.closest("form");if(r&&!r.disabled&&i&&("submit"===r.type||"image"===r.type||!r.type&&"BUTTON"===r.tagName))return!0;let s=t?.closest?.("a");if(!s||!s.href)return!1;let n=s.getAttribute("href");return!(n&&n.startsWith("#")&&n.length>1)}#G(e,t=e._htmx.eventHandler){let r=this.#w(e,"hx-trigger");r||(r=e.matches("form")?"submit":e.matches("input:not([type=button]):not([type=submit]),select,textarea")?"change":"click"),this.#_(e,r,t)}#_(e,t,r){let i=this.#S(t);this.#N(e).triggerSpecs.push(...i);for(let t of i){t.listeners=[];let[i,s]=this.#be(t.name),n=[e];"outside"===t.from?n=[document]:t.from&&"self"!==t.from&&(n=this.#ye(e,t.from));let o=e=>{if((t.halt||t.prevent)&&e.preventDefault(),(t.halt||t.stop||t.consume)&&e.stopPropagation(),t.once)for(let e of t.listeners)e.fromElt.removeEventListener(e.eventName,e.handler,e);r(e)},a=o;if(t.delay?a=e=>{clearTimeout(t.timeout),t.timeout=setTimeout(()=>o(e),this.parseInterval(t.delay))}:t.throttle&&(a=e=>{t.throttled?t.throttledEvent=e:(t.throttled=!0,o(e),t.throttleTimeout=setTimeout(()=>{if(t.throttled=!1,t.throttledEvent){let e=t.throttledEvent;t.throttledEvent=null,a(e)}},this.parseInterval(t.throttle)))}),t.handler=r=>{if(("self"!==t.from||r.target===e)&&("outside"!==t.from||!e.contains(r.target))&&(!t.target||r.target?.matches?.(t.target))){if(t.changed){let e=t.values??=new WeakMap,r=!1;for(let t of n)e.get(t)!==t.value&&(r=!0,e.set(t,t.value));if(!r)return}if(s){this.#se(r)&&r.preventDefault();let t={};for(let e in r)t[e]=r[e];if(!this.#L(e,t,s,!0,!1))return}a(r)}},"intersect"===i||"revealed"===i){let r={rootMargin:t.rootMargin};t.root&&(r.root=this.#re(e,t.root)),t.threshold&&(r.threshold=parseFloat(t.threshold));let s="revealed"===i;t.observer=new IntersectionObserver(r=>{for(let i=0;i<r.length;i++)if(r[i].isIntersecting){this.trigger(e,"intersect",{},!1),s&&t.observer.disconnect();break}},r),i="intersect",t.observer.observe(e)}if("every"===i){let r=Object.keys(t).find(e=>"name"!==e);t.interval=setInterval(()=>{e.isConnected?this.#M(e,"every",{},!1):clearInterval(t.interval)},this.parseInterval(r))}if("load"!==i)for(let r of n){let s={fromElt:r,eventName:i,handler:t.handler,capture:!!t.capture,passive:!!t.passive};e._htmx.listeners.push(s),t.listeners.push(s),r.addEventListener(i,t.handler,s)}else t.handler(new CustomEvent("load"))}}#be(e){let t=e.match(/^([^\[]*)\[([^\]]*)]/);return t?[t[1],t[2]]:[e,null]}#xe(t,r){if("{"===t[0]){let i=e.parse(t);for(let e in i){let t=i[e],s=r;t?.target&&(s=this.find(t.target)),this.trigger(s,e,"object"==typeof t?t:{value:t})}}else t.split(",").forEach(e=>this.trigger(r,e.trim(),{}))}#ve(e){let t={},r=Object.getPrototypeOf(this);for(let i of Object.getOwnPropertyNames(r))"constructor"!==i&&"function"==typeof this[i]&&(["find","findAll"].includes(i)?t[i]=(t,r)=>void 0===r?this[i](e,t):this[i](t,r):t[i]=this[i].bind(this));return t}#L(e,t,r,i=!0,s=!0){let n={};Object.assign(n,this.#ve(e));let o={};this.#B(e,"htmx:scope",{scope:o}),Object.assign(n,o),Object.assign(n,t);let a=Object.keys(n),l=Object.values(n);return new(s?this.#l:this.#a)(...a,i?`return (${r})`:r).call(e,...l)}process(e,t){if(!e?.isConnected)return;if(!(e instanceof Element)){for(let r of e.children||[])this.process(r,t);return}if(t&&this.#we(e,!0),this.#I(e))return;if(!this.#M(e,"htmx:before:process"))return;let r=[e],i=this.#f.evaluate(e),s=null;for(;s=i.iterateNext();)r.push(s);for(let e of r)!this.#I(e)&&this.#M(e,"htmx:before:on:init",{},!0)&&this.#Se(e);for(let t of this.#j(e,this.#h))this.#z(t);for(let t of this.#j(e,this.#u))this.#Ee(t);this.#M(e,"htmx:after:process")}#Ee(e){let t=this.#w(e,"hx-boost");if(t&&"false"!==t&&this.#Ae(e)&&this.#M(e,"htmx:before:init",{},!0)){let r=this.#N(e);r.initialized=!0,r.eventHandler=this.#Q(e),r.boosted=t;let i=e.matches("a")?"click":"submit";e._htmx.listeners.push({fromElt:e,eventName:i,handler:e._htmx.eventHandler}),e.addEventListener(i,e._htmx.eventHandler),this.#M(e,"htmx:after:init",{},!0)}}#Ae(e){if(this.#J(e))if("A"===e.tagName){if(""===e.target||"_self"===e.target)return!e.hasAttribute("download")&&!e.getAttribute("href")?.startsWith?.("#")&&this.#qe(e.href)}else if("FORM"===e.tagName)return"dialog"!==e.method&&this.#qe(e.action)}#qe(e){try{return new URL(e,window.location.href).origin===window.location.origin}catch(e){return!1}}#J(e){return!e._htmx?.initialized&&!this.#I(e)}#we(e,t){let r=[e,...e.querySelectorAll?.("[data-htmx-powered]")??[]];for(let e of r)if(e._htmx){this.#M(e,"htmx:before:cleanup");for(let t of e._htmx.triggerSpecs||[])t.interval&&clearInterval(t.interval),t.timeout&&clearTimeout(t.timeout),t.throttleTimeout&&clearTimeout(t.throttleTimeout),t.observer?.disconnect();for(let t of e._htmx.listeners||[])t.fromElt.removeEventListener(t.eventName,t.handler,t);e.removeAttribute("data-htmx-powered"),this.#M(e,"htmx:after:cleanup"),t&&delete e._htmx}}#Ce(e){let t=document.createElement("div");t.hidden=!0,document.body.insertAdjacentElement("afterend",t);let r=e.querySelectorAll?.(this.#y("[hx-preserve]"))||[];for(let e of r){let r=document.getElementById(e.id);r&&this.#Te(t,r,null)}return t}#He(e){for(let t of[...e.children]){let e=document.getElementById(t.id);e&&(this.#Te(e.parentNode,t,e),this.#we(e),e.remove())}e.remove()}#ke(e){let t=this.#c.createHTML(e);return Document.parseHTMLUnsafe?.(t)||(new DOMParser).parseFromString(t,"text/html")}#_e(e){let t=e.replace(/<hx-([a-z]+)(\s+|>)/gi,'<template hx type="$1"$2').replace(/<\/hx-[a-z]+>/gi,"</template>"),r="";t=t.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,e=>(r=this.#ke(e).title,""));let i,s,n=t.match(/<([a-z][^\/>\x20\t\r\n\f]*)/i)?.[1]?.toLowerCase();if("html"===n||"body"===n?(i=this.#ke(t),s=document.createDocumentFragment(),s.append(i.body)):(i=this.#ke(`<template>${t}</template>`),s=i.querySelector("template").content),!r){let e=s.querySelector("title:not(svg title)");e&&(r=e.textContent,e.remove())}return this.#Ne(s),{fragment:s,title:r}}#Me(e,t,r,i){let s=t.id?"#"+CSS.escape(t.id):null;"true"!==r&&r&&!r.includes(" ")&&([r,s=s]=r.split(/:(.*)/)),"true"!==r&&r||(r="outerHTML");let n=this.#Le(r);if(s=n.target||s,n.strip??=!n.style.startsWith("outer"),!s)return;let o=[...document.querySelectorAll(s)];for(let r of o){let s=document.createDocumentFragment();s.append(t.cloneNode(!0)),e.push({type:"oob",fragment:s,target:r,swapSpec:n,sourceElement:i})}t.remove()}#Oe(e,t,r){let i=[];if(r)for(let s of r.split(",")){let[r,n="true"]=s.split(/:(.*)/);for(let s of e.querySelectorAll(r))this.#Me(i,s,n,t)}for(let r of e.querySelectorAll(this.#y("[hx-swap-oob]"))){let e=this.#P(r,"hx-swap-oob"),s=r.getAttribute(e);r.removeAttribute(e),this.#Me(i,r,s,t)}return i}#Ie(e,t,r){t?t.before(...r.childNodes):e.append(...r.childNodes)}#Le(t){t=t.trim();let r=this.config.defaultSwap;if(t&&!/^\S*:/.test(t)){let e=t.match(/^(\S+)\s*(.*)$/);r=e[1],t=e[2]}return{style:this.#D(r),...e.parse(t)}}#Re(e,t){let r=[];for(let i of e.querySelectorAll("template[hx]")){let e=i.getAttribute("type");if("partial"===e){let e=this.#R(i,"hx-target")||(i.id?"#"+CSS.escape(i.id):null);if(e){this.#Ne(i.content);let s=this.#Le(this.#R(i,"hx-swap")||this.config.defaultSwap);for(let n of document.querySelectorAll(e))r.push({type:"partial",fragment:i.content.cloneNode(!0),target:n,swapSpec:s,sourceElement:t.sourceElement})}}else this.#B(i,"htmx:process:"+e,{ctx:t,tasks:r});i.remove()}return r}#Pe(e,t,r,i){try{null!=r&&e.setSelectionRange&&e.setSelectionRange(r,i),e.focus(t)}catch(e){}}#je(e){let t=this.#j(e,"[autofocus]")[0];t&&this.#Pe(t)}#De(e,t){if(e.scroll){let r=e.scrollTarget?this.#Ve(e.scrollTarget):t;r&&("top"===e.scroll?r.scrollTop=0:"bottom"===e.scroll&&(r.scrollTop=r.scrollHeight))}if("top"===e.show||"bottom"===e.show){let r=e.showTarget?this.#Ve(e.showTarget):t;r?.scrollIntoView("top"===e.show)}}#We(e){e.request?.anchor&&document.getElementById(e.request.anchor)?.scrollIntoView({block:"start",behavior:"auto"})}#Ne(e){let t=this.#j(e,"script");for(let e of t){let t=document.createElement("script");for(let r of e.attributes)t.setAttribute(r.name,r.value);this.config.inlineScriptNonce&&(t.nonce=this.config.inlineScriptNonce),t.textContent=this.#c.createScript(e.textContent),e.replaceWith(t)}}async swap(e){try{this.#Be(e);let{fragment:t,title:r}=this.#_e(e.text);e.title=r;let i=[],s=this.#Oe(t,e.sourceElement,e.selectOOB),n=this.#Re(t,e);i.push(...s,...n);let o=this.#$e(e,t,n);if(o&&i.unshift(o),!this.#M(e.sourceElement,"htmx:before:swap",{ctx:e,tasks:i}))return;let a=[],l=[];for(let t of i)t.swapSpec?.transition??o?.transition??e.transition?l.push(t):a.push(this.#T(t));if(l.length>0){let e=async()=>{for(let e of l)await this.#T(e,!1)};a.push(this.#Fe(e))}await Promise.all(a),this.#M(e.sourceElement,"htmx:after:swap",{ctx:e}),e.title&&!o?.swapSpec?.ignoreTitle&&(document.title=e.title),this.#We(e)}finally{this.#M(e.sourceElement,"htmx:swap:finally",{ctx:e})}}#$e(e,t,r){let i=this.#Le(e.swap||this.config.defaultSwap);if("delete"===i.style||t.childElementCount>0||t.textContent.trim()||(i.swapEmpty??this.config.defaultSwapEmpty??!r.length)){if(e.select){let r=t.querySelectorAll(e.select);(t=document.createDocumentFragment()).append(...r)}return this.#$(e.sourceElement)&&(i.show||="top"),{type:"main",fragment:t,target:this.#Z(e.sourceElement||document.body,i.target||e.target),swapSpec:i,sourceElement:e.sourceElement,transition:e.transition&&!1!==i.transition}}}async#T(e,t=!0){let{target:r,swapSpec:i,fragment:s}=e;if("string"==typeof r&&(r=document.querySelector(r)),!r)return;"string"==typeof i&&(i=this.#Le(i));let n,o=i.style;if("none"===o)return;if("BODY"===s.firstElementChild?.tagName&&("outerHTML"===o?o="outerSync":o.startsWith("outer")||(i.strip=!0)),i.strip&&s.firstElementChild&&(s=document.createDocumentFragment(),s.append(...(e.fragment.firstElementChild.content||e.fragment.firstElementChild).childNodes)),this.#Ue(r,"htmx-swapping"),t&&e.swapSpec?.swap&&await this.timeout(e.swapSpec?.swap),"delete"===o)return void(r.parentNode&&(this.#we(r),r.parentNode.removeChild(r)));let a=[],l=i.settle??this.config.defaultSettleDelay,c=r.parentNode;if("innerHTML"===o||"outerHTML"===o&&c){let e=document.activeElement;if(e?.id){let t,r;try{t=e.selectionStart,r=e.selectionEnd}catch(e){}n={elt:e,start:t,end:r}}a=t&&l?this.#ze(s,r):[]}let h=this.#Ce(s),u=[...s.childNodes];try{if("innerHTML"===o){for(const e of r.children)this.#we(e);r.replaceChildren(...s.childNodes)}else if("textContent"===o){for(const e of r.querySelectorAll("[data-htmx-powered]"))this.#we(e);r.textContent=s.textContent}else if("outerHTML"===o)c&&(this.#Ie(c,r,s),this.#we(r),c.removeChild(r),r=u[0]||c);else if("outerSync"===o){this.#Je(r,s.firstElementChild);for(const e of r.children)this.#we(e);r.replaceChildren(...s.firstElementChild.childNodes),u=[r]}else if("innerMorph"===o)this.#H(r,s,!0),u=[...r.childNodes];else if("outerMorph"===o)this.#H(r,s,!1),u.push(r);else if("beforebegin"===o)c&&this.#Ie(c,r,s);else if("afterbegin"===o)this.#Ie(r,r.firstChild,s);else if("beforeend"===o)this.#Ie(r,null,s);else if("afterend"===o)c&&this.#Ie(c,r.nextSibling,s);else{let e=this.#i.get("handle_swap")||[],t=!1;for(const n of e){let e=n(o,r,s,i);if(e){t=!0,Array.isArray(e)&&(u=e);break}}if(!t)throw new Error(`Unknown swap style: ${o}`)}}finally{this.#Qe(r,"htmx-swapping")}if(this.#He(h),n&&!n.elt.matches(":focus")){let e=document.getElementById(n.elt.id);if(e){let t={preventScroll:void 0!==i.focusScroll?!i.focusScroll:!this.config.defaultFocusScroll};this.#Pe(e,t,n.start,n.end)}}this.#M(r,"htmx:before:settle",{task:e,newContent:u,settleTasks:a});for(const e of u)this.#Ue(e,"htmx-added");if(t&&a.length>0){this.#Ue(r,"htmx-settling"),await this.timeout(l);for(let e of a)e();this.#Qe(r,"htmx-settling")}this.#M(r,"htmx:after:settle",{task:e,newContent:u,settleTasks:a});for(const e of u)this.#Qe(e,"htmx-added"),this.process(e),this.#je(e);this.#De(i,r)}#M(e,t,r={},i=!0){if(r.error){let i=`htmx: ${t}: ${r.error.message??r.error}`;r.error instanceof Error?console.error(i,r.error,{elt:e,detail:r}):console.error(i,{elt:e,detail:r})}else r.warn?console.warn(`htmx: ${t}: ${r.warn}`,{elt:e,detail:r}):this.config.logAll&&console.log(`htmx: ${t}`,{elt:e,detail:r});return e=this.#Ge(e),this.#B(e,t,r),this.trigger(e,this.#W(t),r,i)}#B(e,t,r={}){let i=this.#i.get(t.replace(/:/g,"_"));if(i){r.cancelled=!1;for(const t of i)if(!1===t(e,r)||r.cancelled)return r.cancelled=!0,!1}return!0}timeout(e){if((e=this.parseInterval(e))>0)return new Promise(t=>setTimeout(t,e))}onLoad(e){this.on(this.#W("htmx:after:process"),t=>{e(t.target)})}on(e,t,r){let i,s=document;return void 0===r?(i=e,r=t):(s=this.#Ge(e),i=t),s.addEventListener(i,r),r}find(e,t){return this.#Ve(e,t)}findAll(e,t){return this.#ye(e,t)}parseInterval(e){if("number"==typeof e)return e;let[,t,r]=e?.match(/^([\d.]+)(ms|s|m)?$/)||[],i=parseFloat(t)*({ms:1,s:1e3,m:6e4}[r]||1);return isNaN(i)?void 0:i}trigger(e,t,r={},i=!0){e=this.#Ge(e);let s=new CustomEvent(t,{detail:r,cancelable:!0,bubbles:i,composed:!0}),n=e?.isConnected?e:document;return!r.cancelled&&n.dispatchEvent(s)}ajax(e,t,r){(!r||r instanceof Element||"string"==typeof r)&&(r={target:r});let i="string"==typeof r.source?document.querySelector(r.source):r.source;if("string"==typeof r.source&&!i)return Promise.reject(new Error("Source not found"));if(r.target){let e=this.#Z(document.body,r.target);if(!e)return Promise.reject(new Error("Target not found"));i||=e}i||=document.body;let s=this.#A(i,r.event||{});return Object.assign(s,r),r.target&&(s.target=this.#Z(document.body,r.target)),Object.assign(s.request,{action:t,method:e.toUpperCase()}),r.headers&&Object.assign(s.request.headers,r.headers),this.#K(s)}#O(){this.config.history&&(history.state||history.replaceState({htmx:!0},"",location.href),window.addEventListener("popstate",e=>{e.state&&e.state.htmx&&(this.#p?.abort(),this.#Xe())}))}#Ke(e){this.config.history&&(history.pushState({htmx:!0},"",e),this.#M(document,"htmx:after:history:push",{path:e}))}#Ye(e){this.config.history&&(history.replaceState({htmx:!0},"",e),this.#M(document,"htmx:after:history:replace",{path:e}))}#Xe(e){e=e||location.pathname+location.search;let t=document.querySelector(this.#y("[hx-history-elt]"))||document.body;this.#M(document,"htmx:before:history:restore",{path:e,cacheMiss:!0})&&("reload"===this.config.history?location.reload():(this.#p=new AbortController,this.ajax("GET",e,{target:t,swap:"outerSync",select:t!==document.body?this.#y("[hx-history-elt]"):void 0,request:{headers:{"HX-History-Restore-Request":"true"},signal:this.#p.signal}})))}#Ze(e){let{sourceElement:t,push:r,replace:i,hx:s,response:n}=e;if((s?.pushurl||s?.replaceurl)&&(r=s.pushurl,i=s.replaceurl),null==r&&null==i&&this.#$(t)&&(r="true"),"false"!==r&&!1!==r||(r=null),"false"!==i&&!1!==i||(i=null),!r&&!i)return null;let o=r||i;if("true"===o){let t=n?.raw?.url||e.request.action,r=new URL(t,location.href);o=r.pathname+r.search+(e.request.anchor?"#"+e.request.anchor:"")}return{type:r?"push":"replace",path:o}}#Be(e){let t=this.#Ze(e);if(!t)return;let r={history:t,sourceElement:e.sourceElement,response:e.response};this.#M(document,"htmx:before:history:update",r)&&("push"===t.type?this.#Ke(t.path):this.#Ye(t.path),this.#M(document,"htmx:after:history:update",r))}#Se(e){if(e._htmx?.onInitialized)return;let t=this.#v("hx-on"),r=this.config.metaCharacter||":",i=t=>async r=>{try{await this.#L(e,{event:r},`with(event?.detail||{}){${t}}`,!1)}catch(t){"symbol"!=typeof t&&this.#M(e,"htmx:error",{error:t})}};for(let s of e.getAttributeNames()){let n=t.find(e=>s.startsWith(e));if(!n)continue;this.#N(e).onInitialized=!0;let o=s.substring(n.length),a=e.getAttribute(s);if(!o){for(let t of a.split(/;(?=[^;]*->)/)){let r=t.indexOf("->");-1!==r&&this.#_(e,t.substring(0,r).trim(),i(t.substring(r+2).trim()))}continue}if(o[0]!==r)continue;let l=o.substring(1);l.startsWith(r)&&(l="htmx"+r+l.substring(1)),this.#_(e,l,i(a))}}#he(e){let t,r=this.#w(e,"hx-indicator");t=r?this.#ye(e,r,"hx-indicator"):[e];for(const e of t){let t=this.#U(e);t.rc=(t.rc||0)+1,this.#Ue(e,this.config.requestClass)}return t}#pe(e){for(let t of e){let e=this.#U(t);e.rc&&--e.rc<=0&&(this.#Qe(t,this.config.requestClass),delete e.rc)}}#ue(e){let t=this.#w(e,"hx-disable"),r=[];if(t){r=this.#ye(e,t,"hx-disable");for(let e of r){let t=this.#U(e);t.dc=(t.dc||0)+1,e.disabled=!0}}return r}#ge(e){for(const t of e){let e=this.#U(t);e.dc&&--e.dc<=0&&(t.disabled=!1,delete e.dc)}}#q(e,t,r,i,s){if(i&&t&&!t.reportValidity())return;let n=t?new FormData(t):new FormData,o=t?new Set(t.elements):new Set;if(!t){if(i&&e.reportValidity&&!e.reportValidity())return;this.#et(e,o,n,s)}r&&r.name&&(n.append(r.name,r.value),o.add(r));let a=this.#w(e,"hx-include");if(a)for(let t of this.#ye(e,a)){if(i&&t.reportValidity&&!t.reportValidity())return;this.#et(t,o,n)}return n}#et(e,t,r,i){let s=e.tagName,n=[];"BUTTON"===s?n=[e]:!["INPUT","SELECT","TEXTAREA","FIELDSET"].includes(s)&&i||(n=this.#j(e,"input, select, textarea"));for(let e of n){if(!e.name||e.matches(":disabled")||t.has(e))continue;t.add(e);let i=e.type;if("checkbox"===i||"radio"===i)e.checked&&r.append(e.name,e.value);else if("file"===i)for(let t of e.files)r.append(e.name,t);else if("select-multiple"===i)for(let t of e.selectedOptions)r.append(e.name,t.value);else r.append(e.name,e.value)}}#C(t,r,i,s={}){let n=this.#w(t,r);if(!n)return null;let o=this.#ne(n);if(o)return 0!==o.indexOf("{")&&(o="{"+o+"}"),this.#L(t,s,o,!0).then(e=>{i(e)});i(e.parse(n))}#tt(e){let t=e.trim();return t.startsWith("<")&&t.endsWith("/>")?t.slice(1,-2):t}#ye(t,r,i,s){let n=r??t,o=r?this.#Ge(t):document;if(n.startsWith("global "))return this.#ye(o,n.slice(7),i,!0);let a=n?e.split(n):[],l=[],c=[];for(const e of a){let t,r=this.#tt(e);if(r.startsWith("closest "))t=o.closest(r.slice(8));else if(r.startsWith("find "))t=o.querySelector(r.slice(5));else if(r.startsWith("findAll "))l.push(...o.querySelectorAll(r.slice(8)));else if("next"===r||"nextElementSibling"===r)t=o.nextElementSibling;else if(r.startsWith("next "))t=this.#rt(o,r.slice(5),!!s);else if("previous"===r||"previousElementSibling"===r)t=o.previousElementSibling;else if(r.startsWith("previous "))t=this.#it(o,r.slice(9),!!s);else if("document"===r)t=document;else if("window"===r)t=window;else if("body"===r)t=document.body;else if("host"===r)t=o.getRootNode().host;else if("this"===r){if(i){l.push(...this.#V(o,i));continue}t=o}else c.push(r);t&&l.push(t)}if(c.length>0){let e=c.join(","),t=this.#st(o,!!s);l.push(...t.querySelectorAll(e))}return[...new Set(l)]}#rt(e,t,r){return this.#nt(this.#st(e,r).querySelectorAll(t),e,Node.DOCUMENT_POSITION_PRECEDING)}#it(e,t,r){let i=[...this.#st(e,r).querySelectorAll(t)].reverse();return this.#nt(i,e,Node.DOCUMENT_POSITION_FOLLOWING)}#nt(e,t,r){for(const i of e)if(i.compareDocumentPosition(t)===r)return i}#st(e,t){return e.isConnected&&e.getRootNode?e.getRootNode?.({composed:t}):document}#re(e,t,r){let i=this.#ye(e,t,r)[0];return i||console.warn(`htmx: '${t}' on ${r} did not match any element`,{elt:e,selector:t,attr:r}),i}#Ve(e,t,r){return this.#ye(e,t,r)[0]}#ne(e){if(null!=e){if(e.startsWith("js:"))return e.substring(3);if(e.startsWith("javascript:"))return e.substring(11)}}#X(e){let t=()=>{this.#le(e).abort()};e.addEventListener("htmx:abort",t),e._htmx.listeners.push({fromElt:e,eventName:"htmx:abort",handler:t})}#H(e,t,r){let{persistentIds:i,idMap:s}=this.#ot(e,t),n=document.createElement("div");n.hidden=!0,document.body.after(n);let o={target:e,idMap:s,persistentIds:i,pantry:n,futureMatches:new WeakSet};r?this.#at(o,e,t):this.#at(o,e.parentNode,t,e,e.nextSibling),this.#we(n),n.remove()}#at(e,t,r,i=null,s=null){t instanceof HTMLTemplateElement&&r instanceof HTMLTemplateElement&&(t=t.content,r=r.content),i||=t.firstChild;let n=r.firstChild;for(;n;){let r;if(i&&i!=s&&(r=this.#lt(e,n,i,s),r&&r!==i)){let o=i;for(;o&&o!==r;){let r=o;o=o.nextSibling,r instanceof Element&&(e.idMap.has(r)||this.#ct(e,r,n))?this.#Te(t,r,s):this.#ht(e,r)}}if(!r&&n instanceof Element&&e.persistentIds.has(n.id)){let s=CSS.escape(n.id);r=e.target.id===n.id&&e.target||e.target.querySelector(`[id="${s}"]`)||e.pantry.querySelector(`[id="${s}"]`);let o=r;for(;o=o.parentNode;){let t=e.idMap.get(o);t&&(t.delete(r.id),t.size||e.idMap.delete(o))}this.#Te(t,r,i)}if(r){this.#ut(r,n,e),i=r.nextSibling,n=n.nextSibling;continue}let o=n.nextSibling;if(e.idMap.has(n)){let r=document.createElement(n.tagName);t.insertBefore(r,i),this.#ut(r,n,e),i=r.nextSibling}else t.insertBefore(n,i),i=n.nextSibling;n=o}for(;i&&i!=s;){let t=i;i=i.nextSibling,this.#ht(e,t)}}#ct(e,t,r){if(e.futureMatches.has(t))return!0;for(let i=r.nextSibling,s=0;i&&s<this.config.morphScanLimit;i=i.nextSibling,s++)if(i instanceof Element&&t.isEqualNode(i))return e.futureMatches.add(t),!0;return!1}#lt(e,t,r,i){if(3===t.nodeType)return 3===r?.nodeType?r:null;if(!(t instanceof Element))return null;let s=null,n=0,o=this.config.morphScanLimit,a=e.idMap.get(t),l=a?.size||0;if(t.id&&!a)return null;let c=r;for(;c&&c!=i;){let r=e.idMap.get(c);if(this.#o.isSoftMatch(c,t)){if(r&&a&&[...r].some(e=>a.has(e)))return c;if(!r){if(o>0&&c.isEqualNode(t))return c;s||(s=c)}}if(n+=r?.size||0,n>l)break;if(null!=document.activeElement?.selectionStart&&c.contains(document.activeElement))break;if(--o<1&&0===l)break;c=c.nextSibling}return s&&this.#ct(e,s,t)?null:s}#k(e,t){return e instanceof Element&&e.tagName===t.tagName&&(!("SCRIPT"===e.tagName&&!e.isEqualNode(t))&&(!(!e._x_bindings?.id||!t.matches?.("[\\:id], [x-bind\\:id]"))||(!e.id||e.id===t.id)))}#ht(e,t){e.idMap.has(t)?this.#Te(e.pantry,t,null):(this.#we(t),t.remove())}#Te(e,t,r){if(e.moveBefore)try{return void e.moveBefore(t,r)}catch(e){}e.insertBefore(t,r)}#ut(e,t,r){if(3===e.nodeType)return void(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue));if(this.config.morphSkip&&e.matches?.(this.config.morphSkip))return;if(!this.#B(e,"htmx:before:morph:node",{oldNode:e,newNode:t}))return;this.#Je(e,t),e instanceof HTMLTextAreaElement&&e.defaultValue!=t.defaultValue&&(e.value=t.value),this.config.morphSkipChildren&&e.matches?.(this.config.morphSkipChildren)||e.isEqualNode(t)&&"TEMPLATE"!==t.tagName&&!t.querySelector?.("template")||this.#at(r,e,t)}#Je(e,t){let r=this.config.morphIgnore||[],i=!1,s=e=>this.#v("hx-").some(t=>e.startsWith(t));for(const n of t.attributes)if(!r.some(e=>n.name.startsWith(e))&&e.getAttribute(n.name)!==n.value){if(s(n.name)&&(i=!0),!this.#B(e,"htmx:before:morph:attr",{attrName:n.name,newValue:n.value}))continue;e.setAttribute(n.name,n.value),"value"===n.name&&e instanceof HTMLInputElement&&"file"!==e.type&&(e.value=n.value)}for(let n=e.attributes.length-1;n>=0;n--){let o=e.attributes[n];if(o&&!t.hasAttribute(o.name)&&!r.some(e=>o.name.startsWith(e))){if(s(o.name)&&(i=!0),!this.#B(e,"htmx:before:morph:attr",{attrName:o.name,newValue:null}))continue;e.removeAttribute(o.name)}}i&&this.#we(e,!0)}#dt(e,t,r,i){for(const s of i)if(t.has(s.id)){let t=s;for(;t&&t!==r;){let r=e.get(t);null==r&&(r=new Set,e.set(t,r)),r.add(s.id),t=t.parentElement}}}#ot(e,t){let r=this.#j(e,"[id]"),i=t.querySelectorAll("[id]"),s=this.#ft(r,i),n=new Map;return this.#dt(n,s,e.parentElement,r),this.#dt(n,s,t,i),{persistentIds:s,idMap:n}}#ft(e,t){let r=new Set,i=new Map;for(const{id:t,tagName:s}of e)i.has(t)?r.add(t):t&&i.set(t,s);let s=new Set;for(const{id:e,tagName:n}of t)s.has(e)?r.add(e):i.get(e)===n&&s.add(e);for(const e of r)s.delete(e);return s}#me(t){let r=t.response.raw.status,i=this.config.noSwap.map(e=>e+""),s=r+"";for(let r of[s,s.slice(0,2)+"x",s[0]+"xx"]){if(i.includes(r))return void(t.swap="none");let s=this.#w(t.sourceElement,"hx-status:"+r);if(s)return void e.merge(s,t)}}#Fe(e){return new Promise(t=>{this.#m||=[],this.#m.push({task:e,resolve:t}),this.#g||this.#mt()})}async#mt(){if(0===this.#m.length||this.#g)return;this.#g=!0;let{task:e,resolve:t}=this.#m.shift();try{document.startViewTransition?(this.#M(document,"htmx:before:viewTransition",{task:e}),await document.startViewTransition(e).finished,this.#M(document,"htmx:after:viewTransition",{task:e})):await e()}catch(e){}finally{this.#g=!1,t(),this.#mt()}}#ze(e,t){let r=t.querySelectorAll("[id]"),i=Object.fromEntries([...r].map(e=>[e.id,e])),s=e.querySelectorAll("[id]"),n=[];for(let e of s){let t=i[e.id];if(t?.tagName===e.tagName){let r=e.cloneNode(!1);this.#Je(e,t),n.push(()=>{this.#Je(e,r)})}}return n}#Ue(e,t){e?.classList?.add?.(t)}#Qe(e,t){e?.classList?.remove?.(t),0===e?.classList?.length&&e.removeAttribute("class")}#Ge(e){return"string"==typeof e?this.find(e):e}#W(e){return this.config.metaCharacter?e.replace(/:/g,this.config.metaCharacter):e}}})();(()=>{let e;async function*t(e){let t=new TextDecoder,r="",i=!1,s={data:"",event:"",id:"",retry:null},n=!0;try{for(;;){let{done:o,value:a}=await e.read();if(o)break;let l=t.decode(a,{stream:!0});n&&(65279===l.charCodeAt(0)&&(l=l.slice(1)),n=!1),r+=l;let c=r.split(/\r\n|\r|\n/);r=c.pop()||"";for(let e of c){if(!e){i&&(yield s,i=!1,s={data:"",event:"",id:"",retry:null});continue}let t,r,n=e.indexOf(":");if(0!==n)if(n<0?(t=e,r=""):(t=e.slice(0,n),r=e.slice(n+1)," "===r[0]&&(r=r.slice(1))),"data"===t)s.data+=(i?"\n":"")+r,i=!0;else if("event"===t)s.event=r;else if("id"===t)r.includes("\0")||(s.id=r);else if("retry"===t){let e=parseInt(r,10);isNaN(e)||(s.retry=e)}}}}finally{e.releaseLock()}}async function r(r){let i=r.sourceElement,n=function(t){let r=null!=e.attributeValue(t.sourceElement,"hx-sse:connect");return{reconnect:r,reconnectDelay:500,reconnectMaxDelay:6e4,reconnectMaxAttempts:1/0,reconnectJitter:.3,pauseOnBackground:r,...htmx.config.sse||{},...t.request.sse||{}}}(r),o=!1,a={url:r.request.action,config:n,abortController:null,reader:null,lastEventId:null,delayCanceller:null,visibilityHandler:null,attempt:0,cancelled:!1,status:null};e.htmxProp(i).sse=a;let l=!1,c=null;if(n.pauseOnBackground){let e=()=>{document.hidden?(l=!0,a.reader?.cancel()):l&&(l=!1,c&&c())};document.addEventListener("visibilitychange",e),a.visibilityHandler=e}if(a.cancelled=!1,!e.triggerHtmxEvent(i,"htmx:before:sse:connection",{connection:a})||a.cancelled)return void s(i,"cancelled");a.status=r.response.status,e.triggerHtmxEvent(i,"htmx:after:sse:connection",{connection:a});let h=r.response.raw;try{for(;i.isConnected;){if(a.attempt>0){if(l){if(await new Promise(e=>{c=e}),c=null,!i.isConnected)break;a.attempt=1,o=!0}if(!o&&(!n.reconnect||a.attempt>n.reconnectMaxAttempts))break;let t=htmx.parseInterval(n.reconnectDelay)??n.reconnectDelay,s=htmx.parseInterval(n.reconnectMaxDelay)??n.reconnectMaxDelay,u=Math.min(t*Math.pow(2,a.attempt-1),s);if(n.reconnectJitter>0){let e=u*n.reconnectJitter;u=Math.max(0,u+(2*Math.random()-1)*e)}if(a.cancelled=!1,!e.triggerHtmxEvent(i,"htmx:before:sse:connection",{connection:a})||a.cancelled)break;if(await new Promise(e=>{a.delayCanceller=e,setTimeout(e,u)}),a.delayCanceller=null,!i.isConnected)break;let d=new AbortController;a.abortController=d;try{a.lastEventId&&(r.request.headers["Last-Event-ID"]=a.lastEventId),h=await fetch(r.request.action,{...r.request,signal:d.signal})}catch(t){if(d.signal.aborted)break;e.triggerHtmxEvent(i,"htmx:sse:error",{error:t,url:r.request.action}),o=!1,a.attempt++;continue}if(!h.ok){e.triggerHtmxEvent(i,"htmx:sse:error",{error:new Error(`SSE reconnect failed with status ${h.status}`),status:h.status,url:r.request.action}),o=!1,a.attempt++;continue}a.status=h.status,e.triggerHtmxEvent(i,"htmx:after:sse:connection",{connection:a}),a.attempt=0}o=!1;try{a.reader=h.body.getReader();for await(let l of t(a.reader)){if(!i.isConnected||o)break;let t={message:{data:l.data,event:l.event,id:l.id,cancelled:!1}};if(e.triggerHtmxEvent(i,"htmx:before:sse:message",t)&&!t.message.cancelled){if(l.id&&(a.lastEventId=l.id),null!=l.retry&&(n.reconnectDelay=l.retry),t.message.event){htmx.trigger(i,t.message.event,{data:t.message.data,id:t.message.id}),delete t.message.cancelled,e.triggerHtmxEvent(i,"htmx:after:sse:message",t);let r=e.attributeValue(i,"hx-sse:close");if(r&&t.message.event===r)return void s(i,"message");continue}r.text=t.message.data,r.swap.includes("swapEmpty")||(r.swap+=" swapEmpty:false"),await htmx.swap(r),delete t.message.cancelled,e.triggerHtmxEvent(i,"htmx:after:sse:message",t)}}}catch(t){a.abortController?.signal?.aborted||e.triggerHtmxEvent(i,"htmx:sse:error",{error:t,url:r.request.action})}if(a.reader=null,!i.isConnected)break;a.attempt++}}finally{s(i,i.isConnected?"ended":"removed")}}function i(t){let r=e.attributeValue(t,"hx-sse:connect");if(!r)return;if(t._htmx?.sse)return;let i=e.attributeValue(t,"hx-trigger")||"load";e.onTrigger(t,i,()=>{t._htmx?.sse||htmx.ajax("GET",r,{source:t})})}function s(t,r){let i=t?._htmx?.sse;i&&(i.abortController?.abort(),i.reader?.cancel?.(),i.delayCanceller&&i.delayCanceller(),i.visibilityHandler&&document.removeEventListener("visibilitychange",i.visibilityHandler),e.triggerHtmxEvent(t,"htmx:sse:close",{connection:i,reason:r||"cleanup"}),delete t._htmx.sse)}function n(e){if(e.hasAttribute("sse-connect")){console.warn("htmx: [hx-sse] legacy attribute sse-connect is deprecated; use hx-sse:connect instead");let t=e.getAttribute("sse-connect"),r=(htmx.config.prefix||"hx-")+"sse"+(htmx.config.metaCharacter||":")+"connect";e.hasAttribute(r)||e.setAttribute(r,t)}e.hasAttribute("sse-swap")&&console.warn("htmx: [hx-sse] sse-swap is removed in htmx 4. Unnamed SSE messages are swapped automatically. Named events are dispatched as DOM events.")}htmx.registerExtension("sse",{init:t=>{e=t},htmx_config_request:(e,t)=>{t.ctx.request.headers.Accept="text/html, text/event-stream"},htmx_before_response:(t,i)=>{let n=i.ctx,o=n.response.raw.headers.get("Content-Type");if(o?.includes("text/event-stream"))return r(n).catch(r=>{e.triggerHtmxEvent(t,"htmx:sse:error",{error:r,url:n.request.action}),s(t)}),!1},htmx_after_process:e=>{n(e),i(e);let t=htmx.config.metaCharacter||":",r=`[${CSS.escape("hx-sse"+t+"connect")}]`;htmx.config.prefix&&(r+=`,[${CSS.escape(htmx.config.prefix+"sse"+t+"connect")}]`),e.querySelectorAll(`${r},[sse-connect]`).forEach(e=>{n(e),i(e)})},htmx_before_cleanup:e=>{s(e)}})})(),(()=>{let e;function t(e){let t=htmx.config.metaCharacter||":",r=`[${CSS.escape("hx-ws"+t+e)}]`;return htmx.config.prefix&&(r+=`,[${CSS.escape(htmx.config.prefix+"ws"+t+e)}]`),r}function r(t){const r={reconnect:!0,reconnectDelay:500,reconnectMaxDelay:6e4,reconnectMaxAttempts:1/0,reconnectJitter:.3,pauseOnBackground:!0,pendingRequestTTL:3e4};let i=htmx.config.ws||{},s={};if(t){s=e.createRequestContext(t,new CustomEvent("_")).request.ws||{}}let n={...r,...i,...s};return"boolean"==typeof n.reconnectJitter&&(n.reconnectJitter=n.reconnectJitter?.3:0),n}function i(e){if(e.startsWith("ws://")||e.startsWith("wss://"))return e;if(e.startsWith("http://"))return"ws://"+e.slice(7);if(e.startsWith("https://"))return"wss://"+e.slice(8);let t="https:"===window.location.protocol?"wss:":"ws:",r=window.location.host;return e.startsWith("//")?t+e:e.startsWith("/")?t+"//"+r+e:t+"//"+r+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/")+1)+e}const s=new Map;function n(t,n){let o=i(t);if(s.has(o))return s.get(o);let a={url:o,config:r(n),socket:null,attempt:0,timer:null,pendingRequests:new Map,visibilityHandler:null,cancelled:!1};return!e.triggerHtmxEvent(n,"htmx:before:ws:connection",{connection:a})||a.cancelled?(e.triggerHtmxEvent(n,"htmx:ws:close",{connection:a,reason:"cancelled",code:null}),null):(s.set(o,a),l(o,a),a.config.pauseOnBackground&&(a.visibilityHandler=()=>{document.hidden?a.socket&&a.socket.readyState===WebSocket.OPEN&&a.socket.close():a.socket&&a.socket.readyState!==WebSocket.CLOSED||(a.attempt=0,l(o,a))},document.addEventListener("visibilitychange",a.visibilityHandler)),a)}function o(e){let r=t("connect")+","+t("send");for(let t of document.querySelectorAll(r))if(t._htmx?.ws?.url===e)return t;return null}function a(e,t){if(t.timer&&clearTimeout(t.timer),t.visibilityHandler&&document.removeEventListener("visibilitychange",t.visibilityHandler),t.abortController&&t.abortController.abort(),t.pendingRequests.clear(),t.socket)try{t.socket.readyState!==WebSocket.OPEN&&t.socket.readyState!==WebSocket.CONNECTING||t.socket.close()}catch(e){}s.delete(e)}function l(t,r){if(r.abortController&&r.abortController.abort(),r.socket){let e=r.socket;r.socket=null;try{e.readyState!==WebSocket.OPEN&&e.readyState!==WebSocket.CONNECTING||e.close()}catch(e){}}try{r.socket=new WebSocket(t);let i=new AbortController;r.abortController=i;let n={signal:i.signal};r.socket.addEventListener("open",()=>{let i=o(t);i?(e.triggerHtmxEvent(i,"htmx:after:ws:connection",{connection:r}),r.attempt=0):a(t,r)},n),r.socket.addEventListener("message",t=>{!function(t,r){let i=null;try{i=JSON.parse(r.data)}catch(e){}c(t);let s=null,n=i?.["HX-Request-ID"]||i?.request_id;n&&t.pendingRequests.has(n)?(s=t.pendingRequests.get(n).element,t.pendingRequests.delete(n),s.isConnected||(s=o(t.url))):s=o(t.url);if(!s)return void a(t.url,t);let l,h={message:{text:r.data,json:i,cancelled:!1}};if(!e.triggerHtmxEvent(s,"htmx:before:ws:message",h)||h.message.cancelled)return;h.message.json?void 0!==h.message.json.content?l=h.message.json.content:void 0!==h.message.json.payload&&(l=h.message.json.payload,t._payloadWarnFired||(console.warn("htmx: [hx-ws] json.payload is deprecated; use json.content instead"),t._payloadWarnFired=!0)):l=h.message.text;if(null!=l){let t=h.message.json?.target||e.attributeValue(s,"hx-target"),r=h.message.json?.swap||e.attributeValue(s,"hx-swap");htmx.swap({sourceElement:s,target:t||s,swap:r||(t?htmx.config.defaultSwap:"none"),text:l,transition:!1})}delete h.message.cancelled,e.triggerHtmxEvent(s,"htmx:after:ws:message",h)}(r,t)},n),r.socket.addEventListener("close",i=>{if(i.target!==r.socket)return;let n=o(t);if(n&&e.triggerHtmxEvent(n,"htmx:ws:close",{connection:r,reason:"closed",code:i.code}),!s.has(t))return;let c=r.config;c.pauseOnBackground&&document.hidden||(c.reconnect&&o(t)?function(t,r){let i=r.config;r.attempt++;let s=r.attempt;if(!i.reconnect||s>i.reconnectMaxAttempts)return void a(t,r);let n=htmx.parseInterval(i.reconnectDelay)??i.reconnectDelay,c=htmx.parseInterval(i.reconnectMaxDelay)??i.reconnectMaxDelay,h=Math.min(n*Math.pow(2,s-1),c);if(i.reconnectJitter>0){let e=h*i.reconnectJitter;h=Math.max(0,h+(2*Math.random()-1)*e)}let u=o(t);if(!u)return void a(t,r);if(r.cancelled=!1,!e.triggerHtmxEvent(u,"htmx:before:ws:connection",{connection:r})||r.cancelled)return e.triggerHtmxEvent(u,"htmx:ws:close",{connection:r,reason:"cancelled",code:null}),void a(t,r);r.timer=setTimeout(()=>{o(t)?l(t,r):a(t,r)},h)}(t,r):a(t,r))},n),r.socket.addEventListener("error",r=>{let i=o(t);i&&e.triggerHtmxEvent(i,"htmx:ws:error",{url:t,error:r})},n)}catch(r){let i=o(t);i&&e.triggerHtmxEvent(i,"htmx:ws:error",{url:t,error:r})}}function c(e){let t=e.config,r=Date.now(),i=t.pendingRequestTTL||3e4;for(let[t,s]of e.pendingRequests)r-s.timestamp>i&&e.pendingRequests.delete(t)}function h(r){if(e.htmxProp(r).ws??={},r._htmx.ws.sendInitialized)return;let o=e.attributeValue(r,"hx-ws:send"),a=o&&"true"!==o?o:null,l=e.attributeValue(r,"hx-trigger");l||(l=r.matches("form")?"submit":r.matches("input:not([type=button]),select,textarea")?"change":"click"),e.onTrigger(r,l,async o=>{if(r.matches("form")&&"submit"===o.type&&o.preventDefault(),a&&!r._htmx?.ws?.url){let e=n(a,r);e&&(r._htmx.ws.url=e.url)}await async function(r,n){let o=e.attributeValue(r,"hx-ws:send"),a=o&&"true"!==o?o:null;if(!a){let i=r.closest(t("connect"));i&&(a=e.attributeValue(i,"hx-ws:connect"))}if(!a)return void e.triggerHtmxEvent(r,"htmx:ws:error",{url:null,error:"No WebSocket connection found for element"});let l=i(a),h=s.get(l);if(h&&h.socket&&h.socket.readyState===WebSocket.CONNECTING&&await new Promise(e=>{h.socket.addEventListener("open",e,{once:!0}),h.socket.addEventListener("close",e,{once:!0}),h.socket.addEventListener("error",e,{once:!0})}),!h||!h.socket||h.socket.readyState!==WebSocket.OPEN)return void e.triggerHtmxEvent(r,"htmx:ws:error",{url:l,error:"Connection not open"});c(h);let u={...e.createRequestContext(r,n).request.headers};delete u.Accept;let d=crypto.randomUUID();u["HX-Request-ID"]=d;let f=r.form||r.closest("form"),m=e.collectFormData(r,f,n.submitter),p={};for(let[e,t]of m)p[e]=e in p?[].concat(p[e],t):t;let g=e.getAttributeObject(r,"hx-vals",e=>Object.assign(p,e));g&&await g;let x={headers:u,body:p};if(e.triggerHtmxEvent(r,"htmx:before:ws:request",x))try{h.socket.send(JSON.stringify(x)),h.pendingRequests.set(d,{element:r,timestamp:Date.now()}),e.triggerHtmxEvent(r,"htmx:after:ws:request",x)}catch(t){e.triggerHtmxEvent(r,"htmx:ws:error",{url:l,error:t})}}(r,o)}),r._htmx.ws.sendInitialized=!0}function u(t){let r=t._htmx?.ws?.url;r&&s.has(r)&&(t._htmx.ws.url=null,o(r)||function(t,r){let i=s.get(t);i&&(i.timer&&clearTimeout(i.timer),i.visibilityHandler&&document.removeEventListener("visibilitychange",i.visibilityHandler),i.abortController&&i.abortController.abort(),i.pendingRequests.clear(),e.triggerHtmxEvent(r,"htmx:ws:close",{connection:i,reason:"removed",code:null}),i.socket&&i.socket.readyState===WebSocket.OPEN&&i.socket.close(),s.delete(t))}(r,t))}htmx.registerExtension("ws",{init:t=>{e=t,htmx.config.ws||(htmx.config.ws={})},htmx_after_process:r=>{const i=t=>{!function(e){if(e.hasAttribute("ws-connect")||e.hasAttribute("ws-send")){if(console.warn("htmx: [hx-ws] legacy attributes ws-connect and ws-send are deprecated; use hx-ws:connect and hx-ws:send instead"),e.hasAttribute("ws-connect")){let t=e.getAttribute("ws-connect"),r=htmx.config.metaCharacter||":",i=(htmx.config.prefix||"hx-")+"ws"+r+"connect";e.hasAttribute(i)||e.setAttribute(i,t)}if(e.hasAttribute("ws-send")){let t=htmx.config.metaCharacter||":",r=(htmx.config.prefix||"hx-")+"ws"+t+"send";e.hasAttribute(r)||e.setAttribute(r,"")}}}(t),null!=e.attributeValue(t,"hx-ws:connect")&&function(t){if(e.htmxProp(t).ws??={},t._htmx.ws.initialized)return;let r=e.attributeValue(t,"hx-ws:connect");if(!r)return;let i=e.attributeValue(t,"hx-trigger")||"load";e.onTrigger(t,i,()=>{if(t._htmx?.ws?.url)return;let e=n(r,t);e&&(t._htmx.ws.url=e.url)}),t._htmx.ws.initialized=!0}(t),null!=e.attributeValue(t,"hx-ws:send")&&h(t)};i(r);let s=t("connect")+","+t("send")+",[ws-connect],[ws-send]";r.querySelectorAll(s).forEach(i)},htmx_before_cleanup:e=>{u(e)}}),"undefined"!=typeof window&&window.htmx&&(window.addEventListener("pagehide",()=>{s.forEach(e=>{e.socket&&e.socket.close(1001,"page navigating away")})}),window.htmx.ext=window.htmx.ext||{},window.htmx.ext.ws={getRegistry:()=>({clear:()=>{let e=Array.from(s.values());s.clear(),e.forEach(e=>{e.timer&&clearTimeout(e.timer),e.visibilityHandler&&document.removeEventListener("visibilitychange",e.visibilityHandler),e.abortController&&e.abortController.abort(),e.socket&&e.socket.close(),e.pendingRequests.clear()})},get:e=>s.get(i(e)),has:e=>s.has(i(e)),get size(){return s.size}})})})(),(()=>{let e;htmx.registerExtension("preload",{init:t=>{e=t},htmx_after_init:t=>{!function(t){let r=e.attributeValue(t,"hx-preload");if(null==r&&!t._htmx?.boosted)return;let i=[],s=5e3;if(r){let t=e.parseTriggerSpecs(r);if(0===t.length)return;for(const e of t)i.push(e.name),e.timeout&&(s=htmx.parseInterval(e.timeout))}else{let r=t._htmx?.boosted&&"A"===t.tagName,n=null!=e.attributeValue(t,"hx-get");if(!r&&!n)return;if(r&&!1===htmx.config?.preload?.autoBoost)return;htmx.config?.preload?.boostTimeout&&(s=htmx.parseInterval(htmx.config.preload.boostTimeout)),i.push(htmx.config?.preload?.boostEvent||"mousedown"),i.push("touchstart")}let n=async r=>{let{method:i}=e.determineMethodAndAction(t,r);if("GET"!==i)return;if(t._htmx?.preload)return;let n=e.createRequestContext(t,r),o=t.form||t.closest("form"),a=e.collectFormData(t,o,r.submitter),l=e.getAttributeObject(t,"hx-vals",e=>{for(let t in e)a.set(t,e[t])});l&&await l;let c=n.request.action.replace?.(/#.*$/,""),h=new URLSearchParams(a);h.size&&(c+=(/\?/.test(c)?"&":"?")+h),t._htmx.preload={prefetch:fetch(c,n.request),action:c,expiresAt:Date.now()+s};try{await t._htmx.preload.prefetch}catch(e){delete t._htmx.preload}};for(let e of i)t.addEventListener(e,n,{passive:!0});t._htmx.preloadListener=n,t._htmx.preloadEvents=i}(t)},htmx_before_request:(e,t)=>{let{ctx:r}=t;if(e._htmx?.preload&&e._htmx.preload.action===r.request.action&&Date.now()<e._htmx.preload.expiresAt){let t=e._htmx.preload.prefetch;r.fetch=()=>t,delete e._htmx.preload}else e._htmx&&delete e._htmx.preload},htmx_before_cleanup:e=>{if(e._htmx?.preloadListener)for(let t of e._htmx.preloadEvents)e.removeEventListener(t,e._htmx.preloadListener)}})})(),(()=>{if("undefined"==typeof navigation)return;let e,t=0,r=new Set,i=null;function s(){navigation.addEventListener("navigate",e=>{if(!e.canIntercept)return;let s,n=history.state;e.intercept({handler:()=>new Promise(e=>{s=e}),scroll:"manual",focusReset:"manual"}),e.signal.addEventListener("abort",()=>{t>0&&(r.forEach(e=>e()),r.clear(),t=0),i=null}),i=()=>{s(),history.replaceState(n,"")}},{once:!0}),navigation.navigate(location.href,{history:"replace"})}function n(){i&&(i(),i=null)}htmx.registerExtension("browser-indicator",{init:t=>{e=t},htmx_before_history_update:()=>{n()},htmx_before_request:(i,n)=>{(function(t){return"true"===e.attributeValue(t,"hx-browser-indicator")||!(!htmx.config.boostBrowserIndicator||!t._htmx?.boosted)})(i)&&(n.ctx._browserIndicator=!0,t++,1===t&&s(),n.ctx.request?.abort&&r.add(n.ctx.request.abort))},htmx_finally_request:(e,i)=>{i.ctx._browserIndicator&&(i.ctx.request?.abort&&r.delete(i.ctx.request.abort),0!==t&&(t--,0===t&&n()))}})})(),(()=>{let e;function t(t,r,i){(async()=>{let s=+r.headers.get("Content-Length")||null;e.triggerHtmxEvent(t,"htmx:download:start",{total:s});let n=r.body.getReader(),o=[],a=0;for(;;){let{done:r,value:i}=await n.read();if(r)break;o.push(i),a+=i.length,e.triggerHtmxEvent(t,"htmx:download:progress",{loaded:a,total:s,percent:s?Math.round(a/s*100):null})}let l=new Blob(o,{type:r.headers.get("Content-Type")||"application/octet-stream"}),c=function(e,t){let r=e.get("Content-Disposition");if(r){let e=r.match(/filename\*?=['"]?(?:UTF-8'')?([^'";]+)/i);if(e)return decodeURIComponent(e[1])}return t.split("/").pop().split("?")[0]||"download"}(r.headers,i),h=URL.createObjectURL(l);Object.assign(document.createElement("a"),{href:h,download:c}).click(),URL.revokeObjectURL(h),e.triggerHtmxEvent(t,"htmx:download:complete",{filename:c,size:l.size})})()}htmx.registerExtension("download",{init:t=>{e=t},htmx_before_response:(e,{ctx:r})=>{let i=r.response.headers.get("HX-Download");if(i)return void(async()=>{t(r.sourceElement,await fetch(i),i)})();let s=r.response.headers.get("Content-Disposition");return"download"===r.swap||s?.includes("attachment")?(t(r.sourceElement,r.response.raw,r.request.action),!1):void 0}})})(),(()=>{let e;function t(e){if(e.optimisticDiv){e.optimisticDiv.remove();for(let t of e.optHidden)t.style.display=""}}htmx.registerExtension("hx-optimistic",{init:t=>{e=t},htmx_config_request:(e,t)=>{let r=t.ctx.request.body;r?.entries&&(t.ctx.optimisticBody=r)},htmx_before_request:(t,r)=>{!function(t){if(t.optimistic=e.attributeValue(t.sourceElement,"hx-optimistic"),!t.optimistic)return;let r=document.querySelector(t.optimistic);if(!r)return;let i=t.target;if("string"==typeof i&&(i=document.querySelector(i)),!i)return;let s=document.createElement("div");if(s.style.cssText="all: initial",s.classList.add("hx-optimistic"),s.innerHTML=r.innerHTML,t.optimisticBody){let e=new Set(t.optimisticBody.keys());for(let r of e){let e=t.optimisticBody.getAll(r).filter(e=>"string"==typeof e);if(!e.length)continue;let i=1===e.length?e[0]:JSON.stringify(e);try{s.dataset[r]=i}catch(e){try{s.setAttribute("data-"+r,i)}catch(e){}}}}let n="before"===(o=t.swap)?"beforebegin":"after"===o?"afterend":"prepend"===o?"afterbegin":"append"===o?"beforeend":o;var o;if(t.optHidden=[],"innerHTML"===n){for(let e of i.children)e.style.display="none",t.optHidden.push(e);i.appendChild(s)}else["beforebegin","afterbegin","beforeend","afterend"].includes(n)?i.insertAdjacentElement(n,s):(i.style.display="none",t.optHidden.push(i),i.after(s));t.optimisticDiv=s,htmx.process(s)}(r.ctx)},htmx_error:(e,r)=>{t(r.ctx)},htmx_before_swap:(e,r)=>{t(r.ctx)}})})(),(()=>{let e;htmx.registerExtension("hx-targets",{init:t=>{e=t},htmx_before_swap:(t,r)=>{let{ctx:i,tasks:s}=r,n=e.attributeValue(i.sourceElement,"hx-targets");if(!n)return;let o=htmx.findAll(i.sourceElement,n);if(!o.length)return void console.warn(`htmx: '${n}' on hx-targets did not match any elements`,{selector:n});let a=s.findIndex(e=>"main"===e.type);if(-1===a)return;let l=s[a],c=Array.from(o).map(e=>({...l,fragment:l.fragment.cloneNode(!0),target:e}));s.splice(a,1,...c)}})})(),(()=>{let e,t=new Set,r=!1,i=Symbol(),s=null,n=null,o=0,a=0,l=0,c=!1;const h={childList:!0,subtree:!0,attributes:!0,characterData:!0};function u(){s||(n=()=>d(),document.addEventListener("input",n,!0),document.addEventListener("change",n,!0),s=new MutationObserver(n),s.observe(document.documentElement,h))}function d(){if(r)return;if(o>0)return;let e=Date.now();e-l>1e3&&(l=e,a=0,c=!1),++a>50&&!c&&(console.warn("htmx: hx-live recompute exceeded 50/sec."),c=!0),r=!0,queueMicrotask(()=>{s?.disconnect(),t.forEach(e=>e()),0===t.size?s&&(document.removeEventListener("input",n,!0),document.removeEventListener("change",n,!0),s.disconnect(),s=null,n=null):s.observe(document.documentElement,h),r=!1})}let f=new Set(["disabled","hidden","required","readonly","open","inert","multiple","autofocus","novalidate","default","reversed","loop","muted","controls","autoplay","playsinline","formnovalidate","async","defer","ismap","typemustmatch","allowfullscreen","itemscope","nomodule"]),m=new Set(["checked","value","selected"]),p=new Set(["contenteditable","draggable","spellcheck"]);function g(e,t,...r){let i=t.startsWith("."),s="class"===t,n=t.startsWith("aria-"),o=m.has(t);if(0===r.length){let r=e[0];if(!r)return;return i?r.classList.contains(t.slice(1)):s?r.getAttribute("class"):n?"true"===r.getAttribute(t):f.has(t)?r.hasAttribute(t):o?r[t]:r.getAttribute(t)}let a=r[0];for(let r of e)if(i)r.classList.toggle(t.slice(1),!!a),0===r.classList.length&&r.removeAttribute("class");else if(s)y(r,a);else if(n){let e="string"==typeof a||"number"==typeof a?String(a):a?"true":"false";r.setAttribute(t,e)}else o?!1===a||null==a?(r[t]="boolean"!=typeof r[t]&&"",r.removeAttribute(t)):!0===a?(r[t]=!0,r.setAttribute(t,"")):(r[t]=a,r.setAttribute(t,String(a))):f.has(t)?a?r.setAttribute(t,""):r.removeAttribute(t):p.has(t)?null==a?r.removeAttribute(t):!0===a?r.setAttribute(t,"true"):!1===a?r.setAttribute(t,"false"):r.setAttribute(t,String(a)):null==a||!1===a?r.removeAttribute(t):r.setAttribute(t,!0===a?"":String(a))}function x(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function b(e){return new Proxy({},{get:(t,r)=>{if("string"!=typeof r)return;let i=x(r),s=e.closest("[data-"+i+"]");if(!s)return;let n=s.dataset[r];try{return JSON.parse(n)}catch{return n}},set:(t,r,i)=>{if("string"!=typeof r)return!1;let s=x(r);return(e.closest("[data-"+s+"]")||e).dataset[r]="string"==typeof i?i:JSON.stringify(i),!0},has:(t,r)=>{if("string"!=typeof r)return!1;let i=x(r);return!!e.closest("[data-"+i+"]")},ownKeys:()=>{let t=[],r=new Set;for(let i=e;i;i=i.parentElement)for(let e of Object.keys(i.dataset))"htmxPowered"===e||r.has(e)||(r.add(e),t.push(e));return t},getOwnPropertyDescriptor:(t,r)=>{if("string"!=typeof r||"htmxPowered"===r)return;let i=x(r);return e.closest("[data-"+i+"]")?{enumerable:!0,configurable:!0}:void 0}})}function y(t,r){let i=e.htmxProp(t),s=i.liveClasses||new Set,n=new Set;if("string"==typeof r)for(let e of r.trim().split(/\s+/).filter(Boolean))n.add(e),t.classList.add(e);else if(r&&"object"==typeof r)for(let[e,i]of Object.entries(r))for(let r of e.trim().split(/\s+/).filter(Boolean))n.add(r),t.classList.toggle(r,!!i);for(let e of s)n.has(e)||t.classList.remove(e);0===t.classList.length&&t.removeAttribute("class"),i.liveClasses=n}function v(e,t,r){let i=t.startsWith("."),s=i?t.slice(1):t,n=t.startsWith("aria-"),o=i?"."+s:"["+t+"]",a=null==r?e[0]?.parentElement:r.nodeType?r:null,l=a?[a,...a.querySelectorAll(o)]:document.querySelectorAll("string"==typeof r?r:r?.from||o),c=new Set(e);for(let e of l)c.has(e)||(i?(e.classList?.remove(s),0===e.classList?.length&&e.removeAttribute("class")):n?e.setAttribute(t,"false"):e.removeAttribute(t));for(let r of e)i?r.classList?.add(s):n?r.setAttribute(t,"true"):r.setAttribute(t,"")}function w(e,...t){let r=e||document;for(let e of t)e?.nodeType&&(r=e);return new Promise(e=>{let i=[],s=!1,n=t=>{if(!s){s=!0;for(let e of i)e();e(t)}};for(let e of t){if(null==e||e?.nodeType)continue;let t="number"==typeof e?e:"string"==typeof e?htmx.parseInterval(e):void 0;if(void 0!==t&&t>0){let r=setTimeout(()=>n(e),t);i.push(()=>clearTimeout(r))}else if("string"==typeof e){let t=e=>n(e);r.addEventListener(e,t,{once:!0}),i.push(()=>r.removeEventListener(e,t))}}})}function S(e,t,r){let i=e.startsWith("."),s=i?e.slice(1):e,n=e.startsWith("aria-"),o=t&&("string"==typeof t?t.split("|").map(e=>e.trim()):t);if(o)if(i){let e=o.findIndex(e=>e&&r.classList.contains(e));e>=0&&r.classList.remove(o[e]);let t=o[(e+1)%o.length];t&&r.classList.add(t)}else{let t=r.getAttribute(e)??"",i=o.indexOf(t),s=o[(i+1)%o.length];""===s?r.removeAttribute(e):r.setAttribute(e,s)}else if(i)r.classList.toggle(s);else if(n){let t=r.getAttribute(e);r.setAttribute(e,"true"===t?"false":"true")}else r.toggleAttribute(e)}function E(){let e=new Map;return(t,r)=>{let s=(n=r?r.toString():null,e.get(n)||(e.set(n,{last:0,reject:null}),e.get(n)));var n;s.reject?.(i),s.reject=null;let o=++s.last;if(!r)return new Promise((e,r)=>{s.reject=r,setTimeout(()=>{o===s.last&&(s.reject=null,e())},t)});setTimeout(()=>o===s.last&&r(),t)}}function A(t){let r=e.htmxProp(t);return r.debounce||(r.debounce=E())}function q(e,t=document){return r=>{if("string"!=typeof r)return N(r?.nodeType?[r]:[...r||[]]);let i=r,s=i.match(/^(.+)\s+in\s+(.+)$/),n=[t];if(s&&(i=s[1],n="this"===s[2]||"me"===s[2]?[e]:[...document.querySelectorAll(s[2])]),!n.length)return N([]);let o,a=e=>{if(1===n.length)return[...n[0].querySelectorAll(e)];let t=[],r=new Set;for(let i of n)for(let s of i.querySelectorAll(e))r.has(s)||(r.add(s),t.push(s));return t.sort((e,t)=>4&e.compareDocumentPosition(t)?-1:1)},l=i.match(/^(next|previous|closest|first|last)\s+(.+)$/);if(l){let[,t,r]=l,i=t=>e.compareDocumentPosition(t);if("closest"===t){let t=e.closest?.(r);o=t?[t]:[]}else{let e=a(r);if("first"===t)o=e.slice(0,1);else if("last"===t)o=e.slice(-1);else if("next"===t){let t=e.find(e=>4&i(e));o=t?[t]:[]}else{let t=e.reverse().find(e=>2&i(e));o=t?[t]:[]}}}else o=a(i);return N(o)}}let C,T,H,k=new Set(["map","filter","reduce","reduceRight","forEach","some","every","find","findIndex","findLast","findLastIndex","flatMap","flat","slice","indexOf","lastIndexOf","includes","join","at"]),_={before:"beforebegin",after:"afterend",start:"afterbegin",end:"beforeend"};function N(e){let t=new Proxy({},{get:(r,i)=>{if("count"===i)return e.length;if("arr"===i)return()=>e.slice();if(i===Symbol.iterator)return()=>e.values();if("q"===i)return t=>{let r=new Set;for(let i of e)for(let e of q(i,i)(t).arr())r.add(e);return N([...r])};if("trigger"===i)return(r,i,s)=>(e.forEach(e=>htmx.trigger(e,r,i,s)),t);if("insert"===i)return(r,i)=>(e.forEach(e=>e.insertAdjacentHTML(_[r],i)),t);if("take"===i)return(r,i)=>(v(e,r,i),t);if("toggle"===i)return(r,i)=>(e.forEach(e=>S(r,i,e)),t);if("attr"===i)return(r,...i)=>0===i.length?g(e,r):(g(e,r,...i),t);if("data"===i)return e[0]?b(e[0]):void 0;if(k.has(i))return e[i].bind(e);let s=e[0]?.[i];return"function"==typeof s?(...t)=>e.map(e=>e[i](...t))[0]:s&&"object"==typeof s?N(e.map(e=>e[i])):s},set:(t,r,i)=>(e.forEach(e=>e[r]=i),d(),!0)});return t}function M(e){for(let t of T)if(e.startsWith(t)&&e.length>t.length)return e.slice(t.length)}function L(e){let r=e._htmx;if(r?.liveRuns){for(let e of r.liveRuns)t.delete(e);delete r.liveRuns,delete r.liveRegistered,delete r.liveAttrs}}function O(r){if(r.closest("[hx-ignore]"))return;let s=e.htmxProp(r);if(!s.liveRegistered){let n=H.find(e=>r.hasAttribute(e));if(n){s.liveRegistered=!0,u();let o=r.getAttribute(n),a=A(r),l=async()=>{if(r.isConnected)try{await e.executeJavaScript(r,{debounce:a},o,!1)}catch(e){e!==i&&console.error("htmx: hx-live expression threw",e,{elt:r})}else t.delete(l)};t.add(l),s.liveRuns=s.liveRuns||new Set,s.liveRuns.add(l),l()}}s.liveAttrs||=new Set;for(let e of r.attributes){let t=M(e.name);t&&!s.liveAttrs.has(t)&&(s.liveAttrs.add(t),R(r,t,e.value))}}function I(e){C||function(){let e=htmx.config.metaCharacter||":",t=htmx.config.prefix;T=["hx-live"+e],t&&T.push(t+"live"+e);let r=htmx.config.live?.bindPrefix;void 0===r&&(window.Alpine?(r="",console.warn('hx-live: Alpine.js detected — ":" short-form bindings disabled. Set htmx.config.live.bindPrefix to configure.')):r=":"),r&&T.push(r),H=["hx-live"],t&&H.push(t+"live");let i=T.map(e=>`starts-with(name(), "${e}")`).join(" or "),s=H.map(e=>`@${e}`).join(" or ");C=(new XPathEvaluator).createExpression(`.//*[@*[${i}] or ${s}]`)}(),1===e.nodeType&&O(e);let t,r=C.evaluate(e),i=[];for(;t=r.iterateNext();)i.push(t);for(t of i)O(t)}function R(r,n,o){u();let a=A(r),l=/\bawait\b/.test(o)?async()=>{if(r.isConnected)try{let t=await e.executeJavaScript(r,{debounce:a},o,!0);P(r,n,t),s?.takeRecords()}catch(e){e!==i&&console.error("htmx: hx-live expression threw",e,{elt:r,attr:n})}else t.delete(l)}:()=>{if(r.isConnected)try{let t=e.executeJavaScript(r,{debounce:a},o,!0,!1);P(r,n,t)}catch(e){e!==i&&console.error("htmx: hx-live expression threw",e,{elt:r,attr:n})}else t.delete(l)};t.add(l);let c=e.htmxProp(r);c.liveRuns=c.liveRuns||new Set,c.liveRuns.add(l),l()}function P(t,r,i){"text"!==r?"html"!==r?"style"!==r?g([t],r,i):function(t,r){let i=e.htmxProp(t),s=i.liveStyles||new Set,n=new Set;if("string"==typeof r)for(let e of r.split(";")){let r=e.indexOf(":");if(r<0)continue;let i=e.slice(0,r).trim(),s=e.slice(r+1).trim();i&&(n.add(i),t.style.setProperty(i,s))}else if(r&&"object"==typeof r)for(let[e,i]of Object.entries(r)){let r=x(e);n.add(r),null==i||""===i?t.style.removeProperty(r):t.style.setProperty(r,String(i))}for(let e of s)n.has(e)||t.style.removeProperty(e);0===t.style.length&&t.removeAttribute("style"),i.liveStyles=n}(t,i):t.innerHTML=null==i?"":String(i):t.textContent=null==i?"":String(i)}let j=e=>null==e?[]:"string"==typeof e?document.querySelectorAll(e):e.nodeType?[e]:e;htmx.live={q:e=>q(document.documentElement)(e),debounce:E(),refresh:()=>d(),take:(e,t,r)=>v([...j(e)],t,r),toggle:(e,t,r)=>[...j(e)].forEach(e=>S(t,r,e)),attr:(e,t,...r)=>g([...j(e)],t,...r),forEvent:(...e)=>w(null,...e),nextFrame:()=>new Promise(e=>requestAnimationFrame(e))},htmx.registerExtension("hx-live",{init:t=>{e=t},htmx_before_cleanup:e=>{L(e)},htmx_before_morph_attr:(e,t)=>{T.some(e=>t.attrName.startsWith(e))&&L(e)},htmx_after_process:e=>{I(e)},htmx_before_swap:()=>{o++},htmx_swap_finally:()=>{0===--o&&t.size>0&&d()},htmx_scope:(e,t)=>{Object.assign(t.scope,{q:q(e),forEvent:(...t)=>w(e,...t),nextFrame:()=>new Promise(e=>requestAnimationFrame(e)),trigger:(t,r,i)=>htmx.trigger(e,t,r,i),debounce:A(e),take:(t,r)=>v([e],t,r),toggle:(t,r)=>S(t,r,e),attr:(t,...r)=>g([e],t,...r),insert:(t,r)=>e.insertAdjacentHTML(_[t],r),matches:t=>e.matches(t),style:e.style,classList:e.classList,data:b(e)})}})})();